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