2 package Koha::Schema::Result::Item;
4 # Created by DBIx::Class::Schema::Loader
5 # DO NOT MODIFY THE FIRST PART OF THIS FILE
9 Koha::Schema::Result::Item
16 use base 'DBIx::Class::Core';
18 =head1 TABLE: C<items>
22 __PACKAGE__->table("items");
32 primary key and unique identifier added by Koha
41 foreign key from biblio table used to link this item to the right bib record
43 =head2 biblioitemnumber
50 foreign key from the biblioitems table to link to item to additional information
58 item barcode (MARC21 952$p)
60 =head2 dateaccessioned
63 datetime_undef_if_invalid: 1
66 date the item was acquired or added to Koha (MARC21 952$d)
73 where the item was purchased (MARC21 952$e)
82 foreign key from the branches table for the library that owns this item (MARC21 952$a)
90 purchase price (MARC21 952$g)
92 =head2 replacementprice
98 cost the library charges to replace the item if it has been marked lost (MARC21 952$v)
100 =head2 replacementpricedate
103 datetime_undef_if_invalid: 1
106 the date the price is effective from (MARC21 952$w)
108 =head2 datelastborrowed
111 datetime_undef_if_invalid: 1
114 the date the item was last checked out/issued
119 datetime_undef_if_invalid: 1
122 the date the item was last see (usually the last time the barcode was scanned or inventory was done)
135 authorized value defining why this item is not for loan (MARC21 952$7)
143 authorized value defining this item as damaged (MARC21 952$4)
147 data_type: 'datetime'
148 datetime_undef_if_invalid: 1
151 the date and time an item was last marked as damaged, NULL if not damaged
159 authorized value defining this item as lost (MARC21 952$1)
163 data_type: 'datetime'
164 datetime_undef_if_invalid: 1
167 the date and time an item was last marked as lost, NULL if not lost
175 authorized value defining this item as withdrawn (MARC21 952$0)
179 data_type: 'datetime'
180 datetime_undef_if_invalid: 1
183 the date and time an item was last marked as withdrawn, NULL if not withdrawn
185 =head2 itemcallnumber
191 call number for this item (MARC21 952$o)
193 =head2 coded_location_qualifier
199 coded location qualifier(MARC21 952$f)
203 data_type: 'smallint'
207 number of times this item has been checked out/issued
211 data_type: 'smallint'
214 number of times this item has been renewed
218 data_type: 'smallint'
221 number of times this item has been placed on hold/reserved
228 authorized value defining use restrictions for this item (MARC21 952$5)
232 data_type: 'longtext'
235 public notes on this item (MARC21 952$z)
237 =head2 itemnotes_nonpublic
239 data_type: 'longtext'
242 non-public notes on this item (MARC21 952$x)
251 foreign key from the branches table for the library that is currently in possession item (MARC21 952$b)
255 data_type: 'timestamp'
256 datetime_undef_if_invalid: 1
257 default_value: current_timestamp
260 date and time this item was last altered
268 authorized value for the shelving location for this item (MARC21 952$c)
270 =head2 permanent_location
276 linked to the CART and PROC temporary locations feature, stores the permanent shelving location
281 datetime_undef_if_invalid: 1
284 defines if item is checked out (NULL for not checked out, and due date for checked out)
292 classification source used on this item (MARC21 952$2)
300 normalized form of the call number (MARC21 952$o) used for sorting
308 authorized value for the collection code associated with this item (MARC21 952$8)
312 data_type: 'mediumtext'
315 materials specified (MARC21 952$3)
319 data_type: 'mediumtext'
322 URL for the item (MARC21 952$u)
330 foreign key from the itemtypes table defining the type for this item (MARC21 952$y)
332 =head2 more_subfields_xml
334 data_type: 'longtext'
337 additional 952 subfields in XML format
341 data_type: 'mediumtext'
344 serial enumeration/chronology for the item (MARC21 952$h)
352 copy number (MARC21 952$t)
360 inventory number (MARC21 952$i)
368 'new' value, you can put whatever free-text information. This field is intented to be managed by the automatic_item_modification_by_age cronjob.
370 =head2 exclude_from_local_holds_priority
375 Exclude this item from local holds priority
379 __PACKAGE__->add_columns(
381 { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
384 data_type => "integer",
391 data_type => "integer",
397 { data_type => "varchar", is_nullable => 1, size => 20 },
399 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
401 { data_type => "longtext", is_nullable => 1 },
403 { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
405 { data_type => "decimal", is_nullable => 1, size => [8, 2] },
407 { data_type => "decimal", is_nullable => 1, size => [8, 2] },
408 "replacementpricedate",
409 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
411 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
413 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
415 { data_type => "tinyint", is_nullable => 1 },
417 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
419 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
422 data_type => "datetime",
423 datetime_undef_if_invalid => 1,
427 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
430 data_type => "datetime",
431 datetime_undef_if_invalid => 1,
435 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
438 data_type => "datetime",
439 datetime_undef_if_invalid => 1,
443 { data_type => "varchar", is_nullable => 1, size => 255 },
444 "coded_location_qualifier",
445 { data_type => "varchar", is_nullable => 1, size => 10 },
447 { data_type => "smallint", default_value => 0, is_nullable => 1 },
449 { data_type => "smallint", is_nullable => 1 },
451 { data_type => "smallint", is_nullable => 1 },
453 { data_type => "tinyint", is_nullable => 1 },
455 { data_type => "longtext", is_nullable => 1 },
456 "itemnotes_nonpublic",
457 { data_type => "longtext", is_nullable => 1 },
459 { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
462 data_type => "timestamp",
463 datetime_undef_if_invalid => 1,
464 default_value => \"current_timestamp",
468 { data_type => "varchar", is_nullable => 1, size => 80 },
469 "permanent_location",
470 { data_type => "varchar", is_nullable => 1, size => 80 },
472 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
474 { data_type => "varchar", is_nullable => 1, size => 10 },
476 { data_type => "varchar", is_nullable => 1, size => 255 },
478 { data_type => "varchar", is_nullable => 1, size => 80 },
480 { data_type => "mediumtext", is_nullable => 1 },
482 { data_type => "mediumtext", is_nullable => 1 },
484 { data_type => "varchar", is_nullable => 1, size => 10 },
485 "more_subfields_xml",
486 { data_type => "longtext", is_nullable => 1 },
488 { data_type => "mediumtext", is_nullable => 1 },
490 { data_type => "varchar", is_nullable => 1, size => 32 },
492 { data_type => "varchar", is_nullable => 1, size => 32 },
494 { data_type => "varchar", is_nullable => 1, size => 32 },
495 "exclude_from_local_holds_priority",
496 { data_type => "tinyint", is_nullable => 1 },
503 =item * L</itemnumber>
509 __PACKAGE__->set_primary_key("itemnumber");
511 =head1 UNIQUE CONSTRAINTS
513 =head2 C<itembarcodeidx>
523 __PACKAGE__->add_unique_constraint("itembarcodeidx", ["barcode"]);
531 Related object: L<Koha::Schema::Result::Accountline>
535 __PACKAGE__->has_many(
537 "Koha::Schema::Result::Accountline",
538 { "foreign.itemnumber" => "self.itemnumber" },
539 { cascade_copy => 0, cascade_delete => 0 },
542 =head2 article_requests
546 Related object: L<Koha::Schema::Result::ArticleRequest>
550 __PACKAGE__->has_many(
552 "Koha::Schema::Result::ArticleRequest",
553 { "foreign.itemnumber" => "self.itemnumber" },
554 { cascade_copy => 0, cascade_delete => 0 },
557 =head2 biblioitemnumber
561 Related object: L<Koha::Schema::Result::Biblioitem>
565 __PACKAGE__->belongs_to(
567 "Koha::Schema::Result::Biblioitem",
568 { biblioitemnumber => "biblioitemnumber" },
569 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
576 Related object: L<Koha::Schema::Result::Biblio>
580 __PACKAGE__->belongs_to(
582 "Koha::Schema::Result::Biblio",
583 { biblionumber => "biblionumber" },
584 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
587 =head2 branchtransfers
591 Related object: L<Koha::Schema::Result::Branchtransfer>
595 __PACKAGE__->has_many(
597 "Koha::Schema::Result::Branchtransfer",
598 { "foreign.itemnumber" => "self.itemnumber" },
599 { cascade_copy => 0, cascade_delete => 0 },
606 Related object: L<Koha::Schema::Result::ClubHold>
610 __PACKAGE__->has_many(
612 "Koha::Schema::Result::ClubHold",
613 { "foreign.item_id" => "self.itemnumber" },
614 { cascade_copy => 0, cascade_delete => 0 },
621 Related object: L<Koha::Schema::Result::CourseItem>
625 __PACKAGE__->might_have(
627 "Koha::Schema::Result::CourseItem",
628 { "foreign.itemnumber" => "self.itemnumber" },
629 { cascade_copy => 0, cascade_delete => 0 },
636 Related object: L<Koha::Schema::Result::CoverImage>
640 __PACKAGE__->has_many(
642 "Koha::Schema::Result::CoverImage",
643 { "foreign.itemnumber" => "self.itemnumber" },
644 { cascade_copy => 0, cascade_delete => 0 },
647 =head2 creator_batches
651 Related object: L<Koha::Schema::Result::CreatorBatch>
655 __PACKAGE__->has_many(
657 "Koha::Schema::Result::CreatorBatch",
658 { "foreign.item_number" => "self.itemnumber" },
659 { cascade_copy => 0, cascade_delete => 0 },
662 =head2 hold_fill_target
666 Related object: L<Koha::Schema::Result::HoldFillTarget>
670 __PACKAGE__->might_have(
672 "Koha::Schema::Result::HoldFillTarget",
673 { "foreign.itemnumber" => "self.itemnumber" },
674 { cascade_copy => 0, cascade_delete => 0 },
681 Related object: L<Koha::Schema::Result::Branch>
685 __PACKAGE__->belongs_to(
687 "Koha::Schema::Result::Branch",
688 { branchcode => "holdingbranch" },
692 on_delete => "RESTRICT",
693 on_update => "CASCADE",
701 Related object: L<Koha::Schema::Result::Branch>
705 __PACKAGE__->belongs_to(
707 "Koha::Schema::Result::Branch",
708 { branchcode => "homebranch" },
712 on_delete => "RESTRICT",
713 on_update => "CASCADE",
721 Related object: L<Koha::Schema::Result::Issue>
725 __PACKAGE__->might_have(
727 "Koha::Schema::Result::Issue",
728 { "foreign.itemnumber" => "self.itemnumber" },
729 { cascade_copy => 0, cascade_delete => 0 },
732 =head2 item_bundles_hosts
736 Related object: L<Koha::Schema::Result::ItemBundle>
740 __PACKAGE__->has_many(
741 "item_bundles_hosts",
742 "Koha::Schema::Result::ItemBundle",
743 { "foreign.host" => "self.itemnumber" },
744 { cascade_copy => 0, cascade_delete => 0 },
747 =head2 item_bundles_item
751 Related object: L<Koha::Schema::Result::ItemBundle>
755 __PACKAGE__->might_have(
757 "Koha::Schema::Result::ItemBundle",
758 { "foreign.item" => "self.itemnumber" },
759 { cascade_copy => 0, cascade_delete => 0 },
762 =head2 item_group_item
766 Related object: L<Koha::Schema::Result::ItemGroupItem>
770 __PACKAGE__->might_have(
772 "Koha::Schema::Result::ItemGroupItem",
773 { "foreign.item_id" => "self.itemnumber" },
774 { cascade_copy => 0, cascade_delete => 0 },
777 =head2 items_last_borrower
781 Related object: L<Koha::Schema::Result::ItemsLastBorrower>
785 __PACKAGE__->might_have(
786 "items_last_borrower",
787 "Koha::Schema::Result::ItemsLastBorrower",
788 { "foreign.itemnumber" => "self.itemnumber" },
789 { cascade_copy => 0, cascade_delete => 0 },
796 Related object: L<Koha::Schema::Result::Linktracker>
800 __PACKAGE__->has_many(
802 "Koha::Schema::Result::Linktracker",
803 { "foreign.itemnumber" => "self.itemnumber" },
804 { cascade_copy => 0, cascade_delete => 0 },
811 Related object: L<Koha::Schema::Result::OldIssue>
815 __PACKAGE__->has_many(
817 "Koha::Schema::Result::OldIssue",
818 { "foreign.itemnumber" => "self.itemnumber" },
819 { cascade_copy => 0, cascade_delete => 0 },
826 Related object: L<Koha::Schema::Result::OldReserve>
830 __PACKAGE__->has_many(
832 "Koha::Schema::Result::OldReserve",
833 { "foreign.itemnumber" => "self.itemnumber" },
834 { cascade_copy => 0, cascade_delete => 0 },
841 Related object: L<Koha::Schema::Result::Recall>
845 __PACKAGE__->has_many(
847 "Koha::Schema::Result::Recall",
848 { "foreign.item_id" => "self.itemnumber" },
849 { cascade_copy => 0, cascade_delete => 0 },
856 Related object: L<Koha::Schema::Result::Reserve>
860 __PACKAGE__->has_many(
862 "Koha::Schema::Result::Reserve",
863 { "foreign.itemnumber" => "self.itemnumber" },
864 { cascade_copy => 0, cascade_delete => 0 },
871 Related object: L<Koha::Schema::Result::ReturnClaim>
875 __PACKAGE__->has_many(
877 "Koha::Schema::Result::ReturnClaim",
878 { "foreign.itemnumber" => "self.itemnumber" },
879 { cascade_copy => 0, cascade_delete => 0 },
886 Related object: L<Koha::Schema::Result::Serialitem>
890 __PACKAGE__->might_have(
892 "Koha::Schema::Result::Serialitem",
893 { "foreign.itemnumber" => "self.itemnumber" },
894 { cascade_copy => 0, cascade_delete => 0 },
897 =head2 stockrotationitem
901 Related object: L<Koha::Schema::Result::Stockrotationitem>
905 __PACKAGE__->might_have(
907 "Koha::Schema::Result::Stockrotationitem",
908 { "foreign.itemnumber_id" => "self.itemnumber" },
909 { cascade_copy => 0, cascade_delete => 0 },
912 =head2 tmp_holdsqueues
916 Related object: L<Koha::Schema::Result::TmpHoldsqueue>
920 __PACKAGE__->has_many(
922 "Koha::Schema::Result::TmpHoldsqueue",
923 { "foreign.itemnumber" => "self.itemnumber" },
924 { cascade_copy => 0, cascade_delete => 0 },
928 # Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-07-13 13:32:00
929 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CjfZjLZeYYp3VMuSFJX25A
931 __PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" );
933 __PACKAGE__->belongs_to(
935 "Koha::Schema::Result::Biblio",
936 { biblionumber => "biblionumber" },
937 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
940 __PACKAGE__->add_columns(
941 '+exclude_from_local_holds_priority' => { is_boolean => 1 },
944 # Relationship with orders via the aqorders_item table that not have foreign keys
945 __PACKAGE__->has_many(
947 "Koha::Schema::Result::AqordersItem",
948 { "foreign.itemnumber" => "self.itemnumber" },
949 { cascade_copy => 0, cascade_delete => 0 },
951 __PACKAGE__->many_to_many(
958 sub effective_itemtype {
961 my $pref = C4::Context->preference('item-level_itypes');
962 if ( $pref && $self->itype() ) {
963 return $self->itype();
965 warn "item-level_itypes set but no itemtype set for item (".$self->itemnumber.")"
967 return $self->biblioitemnumber()->itemtype();