Bug 24488: Show correct first patron details on Holds to pull
[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: 1
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 => 1, 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   {
341     is_deferrable => 1,
342     join_type     => "LEFT",
343     on_delete     => "CASCADE",
344     on_update     => "CASCADE",
345   },
346 );
347
348 =head2 club_holds_to_patron_holds
349
350 Type: has_many
351
352 Related object: L<Koha::Schema::Result::ClubHoldsToPatronHold>
353
354 =cut
355
356 __PACKAGE__->has_many(
357   "club_holds_to_patron_holds",
358   "Koha::Schema::Result::ClubHoldsToPatronHold",
359   { "foreign.hold_id" => "self.reserve_id" },
360   { cascade_copy => 0, cascade_delete => 0 },
361 );
362
363 =head2 desk
364
365 Type: belongs_to
366
367 Related object: L<Koha::Schema::Result::Desk>
368
369 =cut
370
371 __PACKAGE__->belongs_to(
372   "desk",
373   "Koha::Schema::Result::Desk",
374   { desk_id => "desk_id" },
375   {
376     is_deferrable => 1,
377     join_type     => "LEFT",
378     on_delete     => "SET NULL",
379     on_update     => "CASCADE",
380   },
381 );
382
383 =head2 itemnumber
384
385 Type: belongs_to
386
387 Related object: L<Koha::Schema::Result::Item>
388
389 =cut
390
391 __PACKAGE__->belongs_to(
392   "itemnumber",
393   "Koha::Schema::Result::Item",
394   { itemnumber => "itemnumber" },
395   {
396     is_deferrable => 1,
397     join_type     => "LEFT",
398     on_delete     => "CASCADE",
399     on_update     => "CASCADE",
400   },
401 );
402
403 =head2 itemtype
404
405 Type: belongs_to
406
407 Related object: L<Koha::Schema::Result::Itemtype>
408
409 =cut
410
411 __PACKAGE__->belongs_to(
412   "itemtype",
413   "Koha::Schema::Result::Itemtype",
414   { itemtype => "itemtype" },
415   {
416     is_deferrable => 1,
417     join_type     => "LEFT",
418     on_delete     => "CASCADE",
419     on_update     => "CASCADE",
420   },
421 );
422
423
424 # Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29
425 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BlMb2M0MEmFuTiMSSBEseg
426
427 __PACKAGE__->belongs_to(
428   "item",
429   "Koha::Schema::Result::Item",
430   { itemnumber => "itemnumber" },
431   {
432     is_deferrable => 1,
433     join_type     => "LEFT",
434     on_delete     => "CASCADE",
435     on_update     => "CASCADE",
436   },
437 );
438
439 __PACKAGE__->belongs_to(
440   "biblio",
441   "Koha::Schema::Result::Biblio",
442   { biblionumber => "biblionumber" },
443   {
444     is_deferrable => 1,
445     join_type     => "LEFT",
446     on_delete     => "CASCADE",
447     on_update     => "CASCADE",
448   },
449 );
450
451 __PACKAGE__->belongs_to(
452   "patron",
453   "Koha::Schema::Result::Borrower",
454   { "foreign.borrowernumber" => "self.borrowernumber" },
455   { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
456 );
457
458 __PACKAGE__->add_columns(
459     '+item_level_hold' => { is_boolean => 1 },
460     '+lowestPriority'  => { is_boolean => 1 },
461     '+suspend'         => { is_boolean => 1 },
462     '+non_priority'    => { is_boolean => 1 }
463 );
464
465 sub koha_object_class {
466     'Koha::Hold';
467 }
468 sub koha_objects_class {
469     'Koha::Holds';
470 }
471
472 __PACKAGE__->belongs_to(
473   "itembib",
474   "Koha::Schema::Result::Item",
475   { biblionumber => "biblionumber" },
476   {
477     is_deferrable => 1,
478     join_type     => "LEFT",
479     on_delete     => "CASCADE",
480     on_update     => "CASCADE",
481   },
482 );
483
484 1;