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");
39 =head2 biblioitemnumber
52 =head2 dateaccessioned
55 datetime_undef_if_invalid: 1
76 =head2 replacementprice
82 =head2 replacementpricedate
85 datetime_undef_if_invalid: 1
88 =head2 datelastborrowed
91 datetime_undef_if_invalid: 1
97 datetime_undef_if_invalid: 1
119 data_type: 'datetime'
120 datetime_undef_if_invalid: 1
131 data_type: 'datetime'
132 datetime_undef_if_invalid: 1
143 data_type: 'datetime'
144 datetime_undef_if_invalid: 1
147 =head2 itemcallnumber
153 =head2 coded_location_qualifier
161 data_type: 'smallint'
166 data_type: 'smallint'
171 data_type: 'smallint'
181 data_type: 'longtext'
184 =head2 itemnotes_nonpublic
186 data_type: 'longtext'
198 data_type: 'longtext'
203 data_type: 'timestamp'
204 datetime_undef_if_invalid: 1
205 default_value: current_timestamp
214 =head2 permanent_location
223 datetime_undef_if_invalid: 1
246 data_type: 'mediumtext'
261 =head2 more_subfields_xml
263 data_type: 'longtext'
268 data_type: 'mediumtext'
291 __PACKAGE__->add_columns(
293 { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
296 data_type => "integer",
303 data_type => "integer",
309 { data_type => "varchar", is_nullable => 1, size => 20 },
311 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
313 { data_type => "longtext", is_nullable => 1 },
315 { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
317 { data_type => "decimal", is_nullable => 1, size => [8, 2] },
319 { data_type => "decimal", is_nullable => 1, size => [8, 2] },
320 "replacementpricedate",
321 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
323 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
325 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
327 { data_type => "tinyint", is_nullable => 1 },
329 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
331 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
334 data_type => "datetime",
335 datetime_undef_if_invalid => 1,
339 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
342 data_type => "datetime",
343 datetime_undef_if_invalid => 1,
347 { data_type => "tinyint", default_value => 0, is_nullable => 0 },
350 data_type => "datetime",
351 datetime_undef_if_invalid => 1,
355 { data_type => "varchar", is_nullable => 1, size => 255 },
356 "coded_location_qualifier",
357 { data_type => "varchar", is_nullable => 1, size => 10 },
359 { data_type => "smallint", is_nullable => 1 },
361 { data_type => "smallint", is_nullable => 1 },
363 { data_type => "smallint", is_nullable => 1 },
365 { data_type => "tinyint", is_nullable => 1 },
367 { data_type => "longtext", is_nullable => 1 },
368 "itemnotes_nonpublic",
369 { data_type => "longtext", is_nullable => 1 },
371 { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
373 { data_type => "longtext", is_nullable => 1 },
376 data_type => "timestamp",
377 datetime_undef_if_invalid => 1,
378 default_value => \"current_timestamp",
382 { data_type => "varchar", is_nullable => 1, size => 80 },
383 "permanent_location",
384 { data_type => "varchar", is_nullable => 1, size => 80 },
386 { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
388 { data_type => "varchar", is_nullable => 1, size => 10 },
390 { data_type => "varchar", is_nullable => 1, size => 255 },
392 { data_type => "varchar", is_nullable => 1, size => 10 },
394 { data_type => "mediumtext", is_nullable => 1 },
396 { data_type => "varchar", is_nullable => 1, size => 255 },
398 { data_type => "varchar", is_nullable => 1, size => 10 },
399 "more_subfields_xml",
400 { data_type => "longtext", is_nullable => 1 },
402 { data_type => "mediumtext", is_nullable => 1 },
404 { data_type => "varchar", is_nullable => 1, size => 32 },
406 { data_type => "varchar", is_nullable => 1, size => 32 },
408 { data_type => "varchar", is_nullable => 1, size => 32 },
415 =item * L</itemnumber>
421 __PACKAGE__->set_primary_key("itemnumber");
423 =head1 UNIQUE CONSTRAINTS
425 =head2 C<itembarcodeidx>
435 __PACKAGE__->add_unique_constraint("itembarcodeidx", ["barcode"]);
443 Related object: L<Koha::Schema::Result::Accountline>
447 __PACKAGE__->has_many(
449 "Koha::Schema::Result::Accountline",
450 { "foreign.itemnumber" => "self.itemnumber" },
451 { cascade_copy => 0, cascade_delete => 0 },
454 =head2 article_requests
458 Related object: L<Koha::Schema::Result::ArticleRequest>
462 __PACKAGE__->has_many(
464 "Koha::Schema::Result::ArticleRequest",
465 { "foreign.itemnumber" => "self.itemnumber" },
466 { cascade_copy => 0, cascade_delete => 0 },
469 =head2 biblioitemnumber
473 Related object: L<Koha::Schema::Result::Biblioitem>
477 __PACKAGE__->belongs_to(
479 "Koha::Schema::Result::Biblioitem",
480 { biblioitemnumber => "biblioitemnumber" },
481 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
488 Related object: L<Koha::Schema::Result::Biblio>
492 __PACKAGE__->belongs_to(
494 "Koha::Schema::Result::Biblio",
495 { biblionumber => "biblionumber" },
496 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
499 =head2 branchtransfers
503 Related object: L<Koha::Schema::Result::Branchtransfer>
507 __PACKAGE__->has_many(
509 "Koha::Schema::Result::Branchtransfer",
510 { "foreign.itemnumber" => "self.itemnumber" },
511 { cascade_copy => 0, cascade_delete => 0 },
518 Related object: L<Koha::Schema::Result::CourseItem>
522 __PACKAGE__->might_have(
524 "Koha::Schema::Result::CourseItem",
525 { "foreign.itemnumber" => "self.itemnumber" },
526 { cascade_copy => 0, cascade_delete => 0 },
529 =head2 creator_batches
533 Related object: L<Koha::Schema::Result::CreatorBatch>
537 __PACKAGE__->has_many(
539 "Koha::Schema::Result::CreatorBatch",
540 { "foreign.item_number" => "self.itemnumber" },
541 { cascade_copy => 0, cascade_delete => 0 },
544 =head2 hold_fill_target
548 Related object: L<Koha::Schema::Result::HoldFillTarget>
552 __PACKAGE__->might_have(
554 "Koha::Schema::Result::HoldFillTarget",
555 { "foreign.itemnumber" => "self.itemnumber" },
556 { cascade_copy => 0, cascade_delete => 0 },
563 Related object: L<Koha::Schema::Result::Branch>
567 __PACKAGE__->belongs_to(
569 "Koha::Schema::Result::Branch",
570 { branchcode => "holdingbranch" },
574 on_delete => "RESTRICT",
575 on_update => "CASCADE",
583 Related object: L<Koha::Schema::Result::Branch>
587 __PACKAGE__->belongs_to(
589 "Koha::Schema::Result::Branch",
590 { branchcode => "homebranch" },
594 on_delete => "RESTRICT",
595 on_update => "CASCADE",
603 Related object: L<Koha::Schema::Result::Issue>
607 __PACKAGE__->might_have(
609 "Koha::Schema::Result::Issue",
610 { "foreign.itemnumber" => "self.itemnumber" },
611 { cascade_copy => 0, cascade_delete => 0 },
614 =head2 items_last_borrower
618 Related object: L<Koha::Schema::Result::ItemsLastBorrower>
622 __PACKAGE__->might_have(
623 "items_last_borrower",
624 "Koha::Schema::Result::ItemsLastBorrower",
625 { "foreign.itemnumber" => "self.itemnumber" },
626 { cascade_copy => 0, cascade_delete => 0 },
633 Related object: L<Koha::Schema::Result::OldIssue>
637 __PACKAGE__->has_many(
639 "Koha::Schema::Result::OldIssue",
640 { "foreign.itemnumber" => "self.itemnumber" },
641 { cascade_copy => 0, cascade_delete => 0 },
648 Related object: L<Koha::Schema::Result::OldReserve>
652 __PACKAGE__->has_many(
654 "Koha::Schema::Result::OldReserve",
655 { "foreign.itemnumber" => "self.itemnumber" },
656 { cascade_copy => 0, cascade_delete => 0 },
663 Related object: L<Koha::Schema::Result::Reserve>
667 __PACKAGE__->has_many(
669 "Koha::Schema::Result::Reserve",
670 { "foreign.itemnumber" => "self.itemnumber" },
671 { cascade_copy => 0, cascade_delete => 0 },
678 Related object: L<Koha::Schema::Result::Serialitem>
682 __PACKAGE__->might_have(
684 "Koha::Schema::Result::Serialitem",
685 { "foreign.itemnumber" => "self.itemnumber" },
686 { cascade_copy => 0, cascade_delete => 0 },
690 # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-18 16:41:12
691 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CrNXvpDUvvcuPZK2Gfzs/Q
693 __PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" );
695 __PACKAGE__->belongs_to(
697 "Koha::Schema::Result::Biblio",
698 { biblionumber => "biblionumber" },
699 { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
703 sub effective_itemtype {
706 my $pref = C4::Context->preference('item-level_itypes');
707 if ( $pref && $self->itype() ) {
708 return $self->itype();
710 warn "item-level_itypes set but no itemtype set for item (".$self->itemnumber.")"
712 return $self->biblioitemnumber()->itemtype();