Bug 15552: Better wording of intranetreadinghistory
[koha.git] / Koha / Schema / Result / Item.pm
blobc370d868ce04231ec13a0e8a348e074297af9e90
1 use utf8;
2 package Koha::Schema::Result::Item;
4 # Created by DBIx::Class::Schema::Loader
5 # DO NOT MODIFY THE FIRST PART OF THIS FILE
7 =head1 NAME
9 Koha::Schema::Result::Item
11 =cut
13 use strict;
14 use warnings;
16 use base 'DBIx::Class::Core';
18 =head1 TABLE: C<items>
20 =cut
22 __PACKAGE__->table("items");
24 =head1 ACCESSORS
26 =head2 itemnumber
28 data_type: 'integer'
29 is_auto_increment: 1
30 is_nullable: 0
32 =head2 biblionumber
34 data_type: 'integer'
35 default_value: 0
36 is_nullable: 0
38 =head2 biblioitemnumber
40 data_type: 'integer'
41 default_value: 0
42 is_foreign_key: 1
43 is_nullable: 0
45 =head2 barcode
47 data_type: 'varchar'
48 is_nullable: 1
49 size: 20
51 =head2 dateaccessioned
53 data_type: 'date'
54 datetime_undef_if_invalid: 1
55 is_nullable: 1
57 =head2 booksellerid
59 data_type: 'mediumtext'
60 is_nullable: 1
62 =head2 homebranch
64 data_type: 'varchar'
65 is_foreign_key: 1
66 is_nullable: 1
67 size: 10
69 =head2 price
71 data_type: 'decimal'
72 is_nullable: 1
73 size: [8,2]
75 =head2 replacementprice
77 data_type: 'decimal'
78 is_nullable: 1
79 size: [8,2]
81 =head2 replacementpricedate
83 data_type: 'date'
84 datetime_undef_if_invalid: 1
85 is_nullable: 1
87 =head2 datelastborrowed
89 data_type: 'date'
90 datetime_undef_if_invalid: 1
91 is_nullable: 1
93 =head2 datelastseen
95 data_type: 'date'
96 datetime_undef_if_invalid: 1
97 is_nullable: 1
99 =head2 stack
101 data_type: 'tinyint'
102 is_nullable: 1
104 =head2 notforloan
106 data_type: 'tinyint'
107 default_value: 0
108 is_nullable: 0
110 =head2 damaged
112 data_type: 'tinyint'
113 default_value: 0
114 is_nullable: 0
116 =head2 itemlost
118 data_type: 'tinyint'
119 default_value: 0
120 is_nullable: 0
122 =head2 itemlost_on
124 data_type: 'datetime'
125 datetime_undef_if_invalid: 1
126 is_nullable: 1
128 =head2 withdrawn
130 data_type: 'tinyint'
131 default_value: 0
132 is_nullable: 0
134 =head2 withdrawn_on
136 data_type: 'datetime'
137 datetime_undef_if_invalid: 1
138 is_nullable: 1
140 =head2 itemcallnumber
142 data_type: 'varchar'
143 is_nullable: 1
144 size: 255
146 =head2 coded_location_qualifier
148 data_type: 'varchar'
149 is_nullable: 1
150 size: 10
152 =head2 issues
154 data_type: 'smallint'
155 is_nullable: 1
157 =head2 renewals
159 data_type: 'smallint'
160 is_nullable: 1
162 =head2 reserves
164 data_type: 'smallint'
165 is_nullable: 1
167 =head2 restricted
169 data_type: 'tinyint'
170 is_nullable: 1
172 =head2 itemnotes
174 data_type: 'mediumtext'
175 is_nullable: 1
177 =head2 itemnotes_nonpublic
179 data_type: 'mediumtext'
180 is_nullable: 1
182 =head2 holdingbranch
184 data_type: 'varchar'
185 is_foreign_key: 1
186 is_nullable: 1
187 size: 10
189 =head2 paidfor
191 data_type: 'mediumtext'
192 is_nullable: 1
194 =head2 timestamp
196 data_type: 'timestamp'
197 datetime_undef_if_invalid: 1
198 default_value: current_timestamp
199 is_nullable: 0
201 =head2 location
203 data_type: 'varchar'
204 is_nullable: 1
205 size: 80
207 =head2 permanent_location
209 data_type: 'varchar'
210 is_nullable: 1
211 size: 80
213 =head2 onloan
215 data_type: 'date'
216 datetime_undef_if_invalid: 1
217 is_nullable: 1
219 =head2 cn_source
221 data_type: 'varchar'
222 is_nullable: 1
223 size: 10
225 =head2 cn_sort
227 data_type: 'varchar'
228 is_nullable: 1
229 size: 255
231 =head2 ccode
233 data_type: 'varchar'
234 is_nullable: 1
235 size: 10
237 =head2 materials
239 data_type: 'text'
240 is_nullable: 1
242 =head2 uri
244 data_type: 'varchar'
245 is_nullable: 1
246 size: 255
248 =head2 itype
250 data_type: 'varchar'
251 is_nullable: 1
252 size: 10
254 =head2 more_subfields_xml
256 data_type: 'longtext'
257 is_nullable: 1
259 =head2 enumchron
261 data_type: 'text'
262 is_nullable: 1
264 =head2 copynumber
266 data_type: 'varchar'
267 is_nullable: 1
268 size: 32
270 =head2 stocknumber
272 data_type: 'varchar'
273 is_nullable: 1
274 size: 32
276 =cut
278 __PACKAGE__->add_columns(
279 "itemnumber",
280 { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
281 "biblionumber",
282 { data_type => "integer", default_value => 0, is_nullable => 0 },
283 "biblioitemnumber",
285 data_type => "integer",
286 default_value => 0,
287 is_foreign_key => 1,
288 is_nullable => 0,
290 "barcode",
291 { data_type => "varchar", is_nullable => 1, size => 20 },
292 "dateaccessioned",
293 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
294 "booksellerid",
295 { data_type => "mediumtext", is_nullable => 1 },
296 "homebranch",
297 { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
298 "price",
299 { data_type => "decimal", is_nullable => 1, size => [8, 2] },
300 "replacementprice",
301 { data_type => "decimal", is_nullable => 1, size => [8, 2] },
302 "replacementpricedate",
303 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
304 "datelastborrowed",
305 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
306 "datelastseen",
307 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
308 "stack",
309 { data_type => "tinyint", is_nullable => 1 },
310 "notforloan",
311 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
312 "damaged",
313 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
314 "itemlost",
315 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
316 "itemlost_on",
318 data_type => "datetime",
319 datetime_undef_if_invalid => 1,
320 is_nullable => 1,
322 "withdrawn",
323 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
324 "withdrawn_on",
326 data_type => "datetime",
327 datetime_undef_if_invalid => 1,
328 is_nullable => 1,
330 "itemcallnumber",
331 { data_type => "varchar", is_nullable => 1, size => 255 },
332 "coded_location_qualifier",
333 { data_type => "varchar", is_nullable => 1, size => 10 },
334 "issues",
335 { data_type => "smallint", is_nullable => 1 },
336 "renewals",
337 { data_type => "smallint", is_nullable => 1 },
338 "reserves",
339 { data_type => "smallint", is_nullable => 1 },
340 "restricted",
341 { data_type => "tinyint", is_nullable => 1 },
342 "itemnotes",
343 { data_type => "mediumtext", is_nullable => 1 },
344 "itemnotes_nonpublic",
345 { data_type => "mediumtext", is_nullable => 1 },
346 "holdingbranch",
347 { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
348 "paidfor",
349 { data_type => "mediumtext", is_nullable => 1 },
350 "timestamp",
352 data_type => "timestamp",
353 datetime_undef_if_invalid => 1,
354 default_value => \"current_timestamp",
355 is_nullable => 0,
357 "location",
358 { data_type => "varchar", is_nullable => 1, size => 80 },
359 "permanent_location",
360 { data_type => "varchar", is_nullable => 1, size => 80 },
361 "onloan",
362 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
363 "cn_source",
364 { data_type => "varchar", is_nullable => 1, size => 10 },
365 "cn_sort",
366 { data_type => "varchar", is_nullable => 1, size => 255 },
367 "ccode",
368 { data_type => "varchar", is_nullable => 1, size => 10 },
369 "materials",
370 { data_type => "text", is_nullable => 1 },
371 "uri",
372 { data_type => "varchar", is_nullable => 1, size => 255 },
373 "itype",
374 { data_type => "varchar", is_nullable => 1, size => 10 },
375 "more_subfields_xml",
376 { data_type => "longtext", is_nullable => 1 },
377 "enumchron",
378 { data_type => "text", is_nullable => 1 },
379 "copynumber",
380 { data_type => "varchar", is_nullable => 1, size => 32 },
381 "stocknumber",
382 { data_type => "varchar", is_nullable => 1, size => 32 },
385 =head1 PRIMARY KEY
387 =over 4
389 =item * L</itemnumber>
391 =back
393 =cut
395 __PACKAGE__->set_primary_key("itemnumber");
397 =head1 UNIQUE CONSTRAINTS
399 =head2 C<itembarcodeidx>
401 =over 4
403 =item * L</barcode>
405 =back
407 =cut
409 __PACKAGE__->add_unique_constraint("itembarcodeidx", ["barcode"]);
411 =head1 RELATIONS
413 =head2 accountlines
415 Type: has_many
417 Related object: L<Koha::Schema::Result::Accountline>
419 =cut
421 __PACKAGE__->has_many(
422 "accountlines",
423 "Koha::Schema::Result::Accountline",
424 { "foreign.itemnumber" => "self.itemnumber" },
425 { cascade_copy => 0, cascade_delete => 0 },
428 =head2 biblioitemnumber
430 Type: belongs_to
432 Related object: L<Koha::Schema::Result::Biblioitem>
434 =cut
436 __PACKAGE__->belongs_to(
437 "biblioitemnumber",
438 "Koha::Schema::Result::Biblioitem",
439 { biblioitemnumber => "biblioitemnumber" },
440 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
443 =head2 branchtransfers
445 Type: has_many
447 Related object: L<Koha::Schema::Result::Branchtransfer>
449 =cut
451 __PACKAGE__->has_many(
452 "branchtransfers",
453 "Koha::Schema::Result::Branchtransfer",
454 { "foreign.itemnumber" => "self.itemnumber" },
455 { cascade_copy => 0, cascade_delete => 0 },
458 =head2 course_item
460 Type: might_have
462 Related object: L<Koha::Schema::Result::CourseItem>
464 =cut
466 __PACKAGE__->might_have(
467 "course_item",
468 "Koha::Schema::Result::CourseItem",
469 { "foreign.itemnumber" => "self.itemnumber" },
470 { cascade_copy => 0, cascade_delete => 0 },
473 =head2 creator_batches
475 Type: has_many
477 Related object: L<Koha::Schema::Result::CreatorBatch>
479 =cut
481 __PACKAGE__->has_many(
482 "creator_batches",
483 "Koha::Schema::Result::CreatorBatch",
484 { "foreign.item_number" => "self.itemnumber" },
485 { cascade_copy => 0, cascade_delete => 0 },
488 =head2 hold_fill_target
490 Type: might_have
492 Related object: L<Koha::Schema::Result::HoldFillTarget>
494 =cut
496 __PACKAGE__->might_have(
497 "hold_fill_target",
498 "Koha::Schema::Result::HoldFillTarget",
499 { "foreign.itemnumber" => "self.itemnumber" },
500 { cascade_copy => 0, cascade_delete => 0 },
503 =head2 holdingbranch
505 Type: belongs_to
507 Related object: L<Koha::Schema::Result::Branch>
509 =cut
511 __PACKAGE__->belongs_to(
512 "holdingbranch",
513 "Koha::Schema::Result::Branch",
514 { branchcode => "holdingbranch" },
516 is_deferrable => 1,
517 join_type => "LEFT",
518 on_delete => "RESTRICT",
519 on_update => "CASCADE",
523 =head2 homebranch
525 Type: belongs_to
527 Related object: L<Koha::Schema::Result::Branch>
529 =cut
531 __PACKAGE__->belongs_to(
532 "homebranch",
533 "Koha::Schema::Result::Branch",
534 { branchcode => "homebranch" },
536 is_deferrable => 1,
537 join_type => "LEFT",
538 on_delete => "RESTRICT",
539 on_update => "CASCADE",
543 =head2 issue
545 Type: might_have
547 Related object: L<Koha::Schema::Result::Issue>
549 =cut
551 __PACKAGE__->might_have(
552 "issue",
553 "Koha::Schema::Result::Issue",
554 { "foreign.itemnumber" => "self.itemnumber" },
555 { cascade_copy => 0, cascade_delete => 0 },
558 =head2 items_last_borrower
560 Type: might_have
562 Related object: L<Koha::Schema::Result::ItemsLastBorrower>
564 =cut
566 __PACKAGE__->might_have(
567 "items_last_borrower",
568 "Koha::Schema::Result::ItemsLastBorrower",
569 { "foreign.itemnumber" => "self.itemnumber" },
570 { cascade_copy => 0, cascade_delete => 0 },
573 =head2 old_issues
575 Type: has_many
577 Related object: L<Koha::Schema::Result::OldIssue>
579 =cut
581 __PACKAGE__->has_many(
582 "old_issues",
583 "Koha::Schema::Result::OldIssue",
584 { "foreign.itemnumber" => "self.itemnumber" },
585 { cascade_copy => 0, cascade_delete => 0 },
588 =head2 old_reserves
590 Type: has_many
592 Related object: L<Koha::Schema::Result::OldReserve>
594 =cut
596 __PACKAGE__->has_many(
597 "old_reserves",
598 "Koha::Schema::Result::OldReserve",
599 { "foreign.itemnumber" => "self.itemnumber" },
600 { cascade_copy => 0, cascade_delete => 0 },
603 =head2 reserves
605 Type: has_many
607 Related object: L<Koha::Schema::Result::Reserve>
609 =cut
611 __PACKAGE__->has_many(
612 "reserves",
613 "Koha::Schema::Result::Reserve",
614 { "foreign.itemnumber" => "self.itemnumber" },
615 { cascade_copy => 0, cascade_delete => 0 },
618 =head2 serialitem
620 Type: might_have
622 Related object: L<Koha::Schema::Result::Serialitem>
624 =cut
626 __PACKAGE__->might_have(
627 "serialitem",
628 "Koha::Schema::Result::Serialitem",
629 { "foreign.itemnumber" => "self.itemnumber" },
630 { cascade_copy => 0, cascade_delete => 0 },
634 # Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-01-06 12:00:28
635 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3M6BvB4ATsBXgQCkFKuI3A
637 __PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" );
639 __PACKAGE__->belongs_to(
640 "biblio",
641 "Koha::Schema::Result::Biblio",
642 { biblionumber => "biblionumber" },
643 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
646 sub effective_itemtype {
647 my ( $self ) = @_;
649 my $pref = $self->result_source->schema->resultset('Systempreference')->find('item-level_itypes');
650 if ( $pref->value() && $self->itype() ) {
651 return $self->itype();
652 } else {
653 warn "item-level_itypes set but no itemtype set for item ($self->itemnumber)"
654 if $pref->value();
655 return $self->biblioitemnumber()->itemtype();