Bug 25655: DBIC schema
[srvgit] / Koha / Schema / Result / Reserve.pm
1 use utf8;
2 package Koha::Schema::Result::Reserve;
3
4 # Created by DBIx::Class::Schema::Loader
5 # DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7 =head1 NAME
8
9 Koha::Schema::Result::Reserve
10
11 =cut
12
13 use strict;
14 use warnings;
15
16 use base 'DBIx::Class::Core';
17
18 =head1 TABLE: C<reserves>
19
20 =cut
21
22 __PACKAGE__->table("reserves");
23
24 =head1 ACCESSORS
25
26 =head2 reserve_id
27
28   data_type: 'integer'
29   is_auto_increment: 1
30   is_nullable: 0
31
32 primary key
33
34 =head2 borrowernumber
35
36   data_type: 'integer'
37   default_value: 0
38   is_foreign_key: 1
39   is_nullable: 0
40
41 foreign key from the borrowers table defining which patron this hold is for
42
43 =head2 reservedate
44
45   data_type: 'date'
46   datetime_undef_if_invalid: 1
47   is_nullable: 1
48
49 the date the hold was placed
50
51 =head2 biblionumber
52
53   data_type: 'integer'
54   default_value: 0
55   is_foreign_key: 1
56   is_nullable: 0
57
58 foreign key from the biblio table defining which bib record this hold is on
59
60 =head2 item_group_id
61
62   data_type: 'integer'
63   is_foreign_key: 1
64   is_nullable: 1
65
66 foreign key from the item_groups table defining if this is an item group level hold
67
68 =head2 branchcode
69
70   data_type: 'varchar'
71   is_foreign_key: 1
72   is_nullable: 0
73   size: 10
74
75 foreign key from the branches table defining which branch the patron wishes to pick this hold up at
76
77 =head2 desk_id
78
79   data_type: 'integer'
80   is_foreign_key: 1
81   is_nullable: 1
82
83 foreign key from the desks table defining which desk the patron should pick this hold up at
84
85 =head2 notificationdate
86
87   data_type: 'date'
88   datetime_undef_if_invalid: 1
89   is_nullable: 1
90
91 currently unused
92
93 =head2 reminderdate
94
95   data_type: 'date'
96   datetime_undef_if_invalid: 1
97   is_nullable: 1
98
99 currently unused
100
101 =head2 cancellationdate
102
103   data_type: 'date'
104   datetime_undef_if_invalid: 1
105   is_nullable: 1
106
107 the date this hold was cancelled
108
109 =head2 cancellation_reason
110
111   data_type: 'varchar'
112   is_nullable: 1
113   size: 80
114
115 optional authorised value CANCELLATION_REASON
116
117 =head2 reservenotes
118
119   data_type: 'longtext'
120   is_nullable: 1
121
122 notes related to this hold
123
124 =head2 priority
125
126   data_type: 'smallint'
127   default_value: 1
128   is_nullable: 0
129
130 where in the queue the patron sits
131
132 =head2 found
133
134   data_type: 'varchar'
135   is_nullable: 1
136   size: 1
137
138 a one letter code defining what the status is of the hold is after it has been confirmed
139
140 =head2 timestamp
141
142   data_type: 'timestamp'
143   datetime_undef_if_invalid: 1
144   default_value: current_timestamp
145   is_nullable: 0
146
147 the date and time this hold was last updated
148
149 =head2 itemnumber
150
151   data_type: 'integer'
152   is_foreign_key: 1
153   is_nullable: 1
154
155 foreign key from the items table defining the specific item the patron has placed on hold or the item this hold was filled with
156
157 =head2 waitingdate
158
159   data_type: 'date'
160   datetime_undef_if_invalid: 1
161   is_nullable: 1
162
163 the date the item was marked as waiting for the patron at the library
164
165 =head2 expirationdate
166
167   data_type: 'date'
168   datetime_undef_if_invalid: 1
169   is_nullable: 1
170
171 the date the hold expires (calculated value)
172
173 =head2 patron_expiration_date
174
175   data_type: 'date'
176   datetime_undef_if_invalid: 1
177   is_nullable: 1
178
179 the date the hold expires - usually the date entered by the patron to say they don't need the hold after a certain date
180
181 =head2 lowestPriority
182
183   accessor: 'lowest_priority'
184   data_type: 'tinyint'
185   default_value: 0
186   is_nullable: 0
187
188 =head2 suspend
189
190   data_type: 'tinyint'
191   default_value: 0
192   is_nullable: 0
193
194 =head2 suspend_until
195
196   data_type: 'datetime'
197   datetime_undef_if_invalid: 1
198   is_nullable: 1
199
200 =head2 itemtype
201
202   data_type: 'varchar'
203   is_foreign_key: 1
204   is_nullable: 1
205   size: 10
206
207 If record level hold, the optional itemtype of the item the patron is requesting
208
209 =head2 item_level_hold
210
211   data_type: 'tinyint'
212   default_value: 0
213   is_nullable: 0
214
215 Is the hold placed at item level
216
217 =head2 non_priority
218
219   data_type: 'tinyint'
220   default_value: 0
221   is_nullable: 0
222
223 Is this a non priority hold
224
225 =cut
226
227 __PACKAGE__->add_columns(
228   "reserve_id",
229   { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
230   "borrowernumber",
231   {
232     data_type      => "integer",
233     default_value  => 0,
234     is_foreign_key => 1,
235     is_nullable    => 0,
236   },
237   "reservedate",
238   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
239   "biblionumber",
240   {
241     data_type      => "integer",
242     default_value  => 0,
243     is_foreign_key => 1,
244     is_nullable    => 0,
245   },
246   "item_group_id",
247   { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
248   "branchcode",
249   { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 10 },
250   "desk_id",
251   { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
252   "notificationdate",
253   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
254   "reminderdate",
255   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
256   "cancellationdate",
257   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
258   "cancellation_reason",
259   { data_type => "varchar", is_nullable => 1, size => 80 },
260   "reservenotes",
261   { data_type => "longtext", is_nullable => 1 },
262   "priority",
263   { data_type => "smallint", default_value => 1, is_nullable => 0 },
264   "found",
265   { data_type => "varchar", is_nullable => 1, size => 1 },
266   "timestamp",
267   {
268     data_type => "timestamp",
269     datetime_undef_if_invalid => 1,
270     default_value => \"current_timestamp",
271     is_nullable => 0,
272   },
273   "itemnumber",
274   { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
275   "waitingdate",
276   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
277   "expirationdate",
278   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
279   "patron_expiration_date",
280   { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
281   "lowestPriority",
282   {
283     accessor      => "lowest_priority",
284     data_type     => "tinyint",
285     default_value => 0,
286     is_nullable   => 0,
287   },
288   "suspend",
289   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
290   "suspend_until",
291   {
292     data_type => "datetime",
293     datetime_undef_if_invalid => 1,
294     is_nullable => 1,
295   },
296   "itemtype",
297   { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
298   "item_level_hold",
299   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
300   "non_priority",
301   { data_type => "tinyint", default_value => 0, is_nullable => 0 },
302 );
303
304 =head1 PRIMARY KEY
305
306 =over 4
307
308 =item * L</reserve_id>
309
310 =back
311
312 =cut
313
314 __PACKAGE__->set_primary_key("reserve_id");
315
316 =head1 RELATIONS
317
318 =head2 biblionumber
319
320 Type: belongs_to
321
322 Related object: L<Koha::Schema::Result::Biblio>
323
324 =cut
325
326 __PACKAGE__->belongs_to(
327   "biblionumber",
328   "Koha::Schema::Result::Biblio",
329   { biblionumber => "biblionumber" },
330   { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
331 );
332
333 =head2 borrowernumber
334
335 Type: belongs_to
336
337 Related object: L<Koha::Schema::Result::Borrower>
338
339 =cut
340
341 __PACKAGE__->belongs_to(
342   "borrowernumber",
343   "Koha::Schema::Result::Borrower",
344   { borrowernumber => "borrowernumber" },
345   { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
346 );
347
348 =head2 branchcode
349
350 Type: belongs_to
351
352 Related object: L<Koha::Schema::Result::Branch>
353
354 =cut
355
356 __PACKAGE__->belongs_to(
357   "branchcode",
358   "Koha::Schema::Result::Branch",
359   { branchcode => "branchcode" },
360   { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
361 );
362
363 =head2 club_holds_to_patron_holds
364
365 Type: has_many
366
367 Related object: L<Koha::Schema::Result::ClubHoldsToPatronHold>
368
369 =cut
370
371 __PACKAGE__->has_many(
372   "club_holds_to_patron_holds",
373   "Koha::Schema::Result::ClubHoldsToPatronHold",
374   { "foreign.hold_id" => "self.reserve_id" },
375   { cascade_copy => 0, cascade_delete => 0 },
376 );
377
378 =head2 desk
379
380 Type: belongs_to
381
382 Related object: L<Koha::Schema::Result::Desk>
383
384 =cut
385
386 __PACKAGE__->belongs_to(
387   "desk",
388   "Koha::Schema::Result::Desk",
389   { desk_id => "desk_id" },
390   {
391     is_deferrable => 1,
392     join_type     => "LEFT",
393     on_delete     => "SET NULL",
394     on_update     => "CASCADE",
395   },
396 );
397
398 =head2 item_group
399
400 Type: belongs_to
401
402 Related object: L<Koha::Schema::Result::ItemGroup>
403
404 =cut
405
406 __PACKAGE__->belongs_to(
407   "item_group",
408   "Koha::Schema::Result::ItemGroup",
409   { item_group_id => "item_group_id" },
410   {
411     is_deferrable => 1,
412     join_type     => "LEFT",
413     on_delete     => "CASCADE",
414     on_update     => "CASCADE",
415   },
416 );
417
418 =head2 itemnumber
419
420 Type: belongs_to
421
422 Related object: L<Koha::Schema::Result::Item>
423
424 =cut
425
426 __PACKAGE__->belongs_to(
427   "itemnumber",
428   "Koha::Schema::Result::Item",
429   { itemnumber => "itemnumber" },
430   {
431     is_deferrable => 1,
432     join_type     => "LEFT",
433     on_delete     => "CASCADE",
434     on_update     => "CASCADE",
435   },
436 );
437
438 =head2 itemtype
439
440 Type: belongs_to
441
442 Related object: L<Koha::Schema::Result::Itemtype>
443
444 =cut
445
446 __PACKAGE__->belongs_to(
447   "itemtype",
448   "Koha::Schema::Result::Itemtype",
449   { itemtype => "itemtype" },
450   {
451     is_deferrable => 1,
452     join_type     => "LEFT",
453     on_delete     => "CASCADE",
454     on_update     => "CASCADE",
455   },
456 );
457
458
459 # Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-02-10 14:01:25
460 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NO6FSSL1Hw3wBRGG6B5BnQ
461
462 __PACKAGE__->belongs_to(
463   "item",
464   "Koha::Schema::Result::Item",
465   { itemnumber => "itemnumber" },
466   {
467     is_deferrable => 1,
468     join_type     => "LEFT",
469     on_delete     => "CASCADE",
470     on_update     => "CASCADE",
471   },
472 );
473
474 __PACKAGE__->belongs_to(
475   "biblio",
476   "Koha::Schema::Result::Biblio",
477   { biblionumber => "biblionumber" },
478   {
479     is_deferrable => 1,
480     join_type     => "LEFT",
481     on_delete     => "CASCADE",
482     on_update     => "CASCADE",
483   },
484 );
485
486 __PACKAGE__->belongs_to(
487   "patron",
488   "Koha::Schema::Result::Borrower",
489   { "foreign.borrowernumber" => "self.borrowernumber" },
490   { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
491 );
492
493 __PACKAGE__->add_columns(
494     '+item_level_hold' => { is_boolean => 1 },
495     '+lowestPriority'  => { is_boolean => 1 },
496     '+suspend'         => { is_boolean => 1 },
497     '+non_priority'    => { is_boolean => 1 }
498 );
499
500 sub koha_object_class {
501     'Koha::Hold';
502 }
503 sub koha_objects_class {
504     'Koha::Holds';
505 }
506
507 __PACKAGE__->belongs_to(
508   "itembib",
509   "Koha::Schema::Result::Item",
510   { biblionumber => "biblionumber" },
511   {
512     is_deferrable => 1,
513     join_type     => "LEFT",
514     on_delete     => "CASCADE",
515     on_update     => "CASCADE",
516   },
517 );
518
519 __PACKAGE__->has_many(
520   "cancellation_requests",
521   "Koha::Schema::Result::HoldCancellationRequest",
522   { "foreign.hold_id" => "self.reserve_id" },
523   { cascade_copy => 0, cascade_delete => 0 },
524 );
525
526 1;