3 # Copyright ByWater Solutions 2014
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use List::MoreUtils qw(any);
28 use Koha::DateUtils qw( dt_from_string );
33 use C4::ClassSource; # FIXME We would like to avoid that
34 use C4::Log qw( logaction );
37 use Koha::CirculationRules;
38 use Koha::CoverImages;
39 use Koha::SearchEngine::Indexer;
40 use Koha::Item::Transfer::Limits;
41 use Koha::Item::Transfers;
46 use Koha::StockRotationItem;
47 use Koha::StockRotationRotas;
49 use base qw(Koha::Object);
53 Koha::Item - Koha Item object class
65 $params can take an optional 'skip_record_index' parameter.
66 If set, the reindexation process will not happen (index_records not called)
68 NOTE: This is a temporary fix to answer a performance issue when lot of items
69 are added (or modified) at the same time.
70 The correct way to fix this is to make the ES reindexation process async.
71 You should not turn it on if you do not understand what it is doing exactly.
77 my $params = @_ ? shift : {};
79 my $log_action = $params->{log_action} // 1;
81 # We do not want to oblige callers to pass this value
82 # Dev conveniences vs performance?
83 unless ( $self->biblioitemnumber ) {
84 $self->biblioitemnumber( $self->biblio->biblioitem->biblioitemnumber );
87 # See related changes from C4::Items::AddItem
88 unless ( $self->itype ) {
89 $self->itype($self->biblio->biblioitem->itemtype);
92 my $today = dt_from_string;
93 my $plugin_action = 'create';
95 unless ( $self->in_storage ) { #AddItem
96 unless ( $self->permanent_location ) {
97 $self->permanent_location($self->location);
99 unless ( $self->replacementpricedate ) {
100 $self->replacementpricedate($today);
102 unless ( $self->datelastseen ) {
103 $self->datelastseen($today);
106 unless ( $self->dateaccessioned ) {
107 $self->dateaccessioned($today);
110 if ( $self->itemcallnumber
111 or $self->cn_source )
113 my $cn_sort = GetClassSort( $self->cn_source, $self->itemcallnumber, "" );
114 $self->cn_sort($cn_sort);
117 logaction( "CATALOGUING", "ADD", $self->itemnumber, "item" )
118 if $log_action && C4::Context->preference("CataloguingLog");
122 $plugin_action = 'modify';
124 my %updated_columns = $self->_result->get_dirty_columns;
125 return $self->SUPER::store unless %updated_columns;
127 # Retrieve the item for comparison if we need to
129 exists $updated_columns{itemlost}
130 or exists $updated_columns{withdrawn}
131 or exists $updated_columns{damaged}
132 ) ? $self->get_from_storage : undef;
134 # Update *_on fields if needed
135 # FIXME: Why not for AddItem as well?
136 my @fields = qw( itemlost withdrawn damaged );
137 for my $field (@fields) {
139 # If the field is defined but empty or 0, we are
140 # removing/unsetting and thus need to clear out
142 if ( exists $updated_columns{$field}
143 && defined( $self->$field )
146 my $field_on = "${field}_on";
147 $self->$field_on(undef);
149 # If the field has changed otherwise, we much update
151 elsif (exists $updated_columns{$field}
152 && $updated_columns{$field}
153 && !$pre_mod_item->$field )
155 my $field_on = "${field}_on";
157 DateTime::Format::MySQL->format_datetime(
164 if ( exists $updated_columns{itemcallnumber}
165 or exists $updated_columns{cn_source} )
167 my $cn_sort = GetClassSort( $self->cn_source, $self->itemcallnumber, "" );
168 $self->cn_sort($cn_sort);
172 if ( exists $updated_columns{location}
173 and $self->location ne 'CART'
174 and $self->location ne 'PROC'
175 and not exists $updated_columns{permanent_location} )
177 $self->permanent_location( $self->location );
180 # If item was lost and has now been found,
181 # reverse any list item charges if necessary.
182 if ( exists $updated_columns{itemlost}
183 and $updated_columns{itemlost} <= 0
184 and $pre_mod_item->itemlost > 0 )
186 $self->_set_found_trigger($pre_mod_item);
189 logaction( "CATALOGUING", "MODIFY", $self->itemnumber, "item " . Dumper($self->unblessed) )
190 if $log_action && C4::Context->preference("CataloguingLog");
193 unless ( $self->dateaccessioned ) {
194 $self->dateaccessioned($today);
197 my $result = $self->SUPER::store;
198 my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
199 $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
200 unless $params->{skip_record_index};
201 $self->get_from_storage->_after_item_action_hooks({ action => $plugin_action });
212 my $params = @_ ? shift : {};
214 # FIXME check the item has no current issues
215 # i.e. raise the appropriate exception
217 my $result = $self->SUPER::delete;
219 my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
220 $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
221 unless $params->{skip_record_index};
223 $self->_after_item_action_hooks({ action => 'delete' });
225 logaction( "CATALOGUING", "DELETE", $self->itemnumber, "item" )
226 if C4::Context->preference("CataloguingLog");
237 my $params = @_ ? shift : {};
239 my $safe_to_delete = $self->safe_to_delete;
240 return $safe_to_delete unless $safe_to_delete eq '1';
242 $self->move_to_deleted;
244 return $self->delete($params);
247 =head3 safe_to_delete
249 returns 1 if the item is safe to delete,
251 "book_on_loan" if the item is checked out,
253 "not_same_branch" if the item is blocked by independent branches,
255 "book_reserved" if the there are holds aganst the item, or
257 "linked_analytics" if the item has linked analytic records.
259 "last_item_for_hold" if the item is the last one on a record on which a biblio-level hold is placed
266 return "book_on_loan" if $self->checkout;
268 return "not_same_branch"
269 if defined C4::Context->userenv
270 and !C4::Context->IsSuperLibrarian()
271 and C4::Context->preference("IndependentBranches")
272 and ( C4::Context->userenv->{branch} ne $self->homebranch );
274 # check it doesn't have a waiting reserve
275 return "book_reserved"
276 if $self->holds->search( { found => [ 'W', 'T' ] } )->count;
278 return "linked_analytics"
279 if C4::Items::GetAnalyticsCount( $self->itemnumber ) > 0;
281 return "last_item_for_hold"
282 if $self->biblio->items->count == 1
283 && $self->biblio->holds->search(
292 =head3 move_to_deleted
294 my $is_moved = $item->move_to_deleted;
296 Move an item to the deleteditems table.
297 This can be done before deleting an item, to make sure the data are not completely deleted.
301 sub move_to_deleted {
303 my $item_infos = $self->unblessed;
304 delete $item_infos->{timestamp}; #This ensures the timestamp date in deleteditems will be set to the current timestamp
305 return Koha::Database->new->schema->resultset('Deleteditem')->create($item_infos);
309 =head3 effective_itemtype
311 Returns the itemtype for the item based on whether item level itemtypes are set or not.
315 sub effective_itemtype {
318 return $self->_result()->effective_itemtype();
328 $self->{_home_branch} ||= Koha::Libraries->find( $self->homebranch() );
330 return $self->{_home_branch};
333 =head3 holding_branch
340 $self->{_holding_branch} ||= Koha::Libraries->find( $self->holdingbranch() );
342 return $self->{_holding_branch};
347 my $biblio = $item->biblio;
349 Return the bibliographic record of this item
355 my $biblio_rs = $self->_result->biblio;
356 return Koha::Biblio->_new_from_dbic( $biblio_rs );
361 my $biblioitem = $item->biblioitem;
363 Return the biblioitem record of this item
369 my $biblioitem_rs = $self->_result->biblioitem;
370 return Koha::Biblioitem->_new_from_dbic( $biblioitem_rs );
375 my $checkout = $item->checkout;
377 Return the checkout for this item
383 my $checkout_rs = $self->_result->issue;
384 return unless $checkout_rs;
385 return Koha::Checkout->_new_from_dbic( $checkout_rs );
390 my $holds = $item->holds();
391 my $holds = $item->holds($params);
392 my $holds = $item->holds({ found => 'W'});
394 Return holds attached to an item, optionally accept a hashref of params to pass to search
399 my ( $self,$params ) = @_;
400 my $holds_rs = $self->_result->reserves->search($params);
401 return Koha::Holds->_new_from_dbic( $holds_rs );
406 my $transfer = $item->get_transfer;
408 Return the transfer if the item is in transit or undef
414 my $transfer_rs = $self->_result->branchtransfers->search({ datearrived => undef })->first;
415 return unless $transfer_rs;
416 return Koha::Item::Transfer->_new_from_dbic( $transfer_rs );
419 =head3 last_returned_by
421 Gets and sets the last borrower to return an item.
423 Accepts and returns Koha::Patron objects
425 $item->last_returned_by( $borrowernumber );
427 $last_returned_by = $item->last_returned_by();
431 sub last_returned_by {
432 my ( $self, $borrower ) = @_;
434 my $items_last_returned_by_rs = Koha::Database->new()->schema()->resultset('ItemsLastBorrower');
437 return $items_last_returned_by_rs->update_or_create(
438 { borrowernumber => $borrower->borrowernumber, itemnumber => $self->id } );
441 unless ( $self->{_last_returned_by} ) {
442 my $result = $items_last_returned_by_rs->single( { itemnumber => $self->id } );
444 $self->{_last_returned_by} = Koha::Patrons->find( $result->get_column('borrowernumber') );
448 return $self->{_last_returned_by};
452 =head3 can_article_request
454 my $bool = $item->can_article_request( $borrower )
456 Returns true if item can be specifically requested
458 $borrower must be a Koha::Patron object
462 sub can_article_request {
463 my ( $self, $borrower ) = @_;
465 my $rule = $self->article_request_type($borrower);
467 return 1 if $rule && $rule ne 'no' && $rule ne 'bib_only';
471 =head3 hidden_in_opac
473 my $bool = $item->hidden_in_opac({ [ rules => $rules ] })
475 Returns true if item fields match the hidding criteria defined in $rules.
476 Returns false otherwise.
478 Takes HASHref that can have the following parameters:
480 $rules : { <field> => [ value_1, ... ], ... }
482 Note: $rules inherits its structure from the parsed YAML from reading
483 the I<OpacHiddenItems> system preference.
488 my ( $self, $params ) = @_;
490 my $rules = $params->{rules} // {};
493 if C4::Context->preference('hidelostitems') and
496 my $hidden_in_opac = 0;
498 foreach my $field ( keys %{$rules} ) {
500 if ( any { $self->$field eq $_ } @{ $rules->{$field} } ) {
506 return $hidden_in_opac;
509 =head3 can_be_transferred
511 $item->can_be_transferred({ to => $to_library, from => $from_library })
512 Checks if an item can be transferred to given library.
514 This feature is controlled by two system preferences:
515 UseBranchTransferLimits to enable / disable the feature
516 BranchTransferLimitsType to use either an itemnumber or ccode as an identifier
517 for setting the limitations
519 Takes HASHref that can have the following parameters:
520 MANDATORY PARAMETERS:
523 $from : Koha::Library # if not given, item holdingbranch
524 # will be used instead
526 Returns 1 if item can be transferred to $to_library, otherwise 0.
528 To find out whether at least one item of a Koha::Biblio can be transferred, please
529 see Koha::Biblio->can_be_transferred() instead of using this method for
530 multiple items of the same biblio.
534 sub can_be_transferred {
535 my ($self, $params) = @_;
537 my $to = $params->{to};
538 my $from = $params->{from};
540 $to = $to->branchcode;
541 $from = defined $from ? $from->branchcode : $self->holdingbranch;
543 return 1 if $from eq $to; # Transfer to current branch is allowed
544 return 1 unless C4::Context->preference('UseBranchTransferLimits');
546 my $limittype = C4::Context->preference('BranchTransferLimitsType');
547 return Koha::Item::Transfer::Limits->search({
550 $limittype => $limittype eq 'itemtype'
551 ? $self->effective_itemtype : $self->ccode
556 =head3 pickup_locations
558 $pickup_locations = $item->pickup_locations( {patron => $patron } )
560 Returns possible pickup locations for this item, according to patron's home library (if patron is defined and holds are allowed only from hold groups)
561 and if item can be transferred to each pickup location.
565 sub pickup_locations {
566 my ($self, $params) = @_;
568 my $patron = $params->{patron};
570 my $circ_control_branch =
571 C4::Reserves::GetReservesControlBranch( $self->unblessed(), $patron->unblessed );
573 C4::Circulation::GetBranchItemRule( $circ_control_branch, $self->itype );
575 if(defined $patron) {
576 return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} == 3 && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} );
577 return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} == 1 && $self->home_branch->branchcode ne $patron->branchcode;
580 my $pickup_libraries = Koha::Libraries->search();
581 if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup') {
582 $pickup_libraries = $self->home_branch->get_hold_libraries;
583 } elsif ($branchitemrule->{hold_fulfillment_policy} eq 'patrongroup') {
584 my $plib = Koha::Libraries->find({ branchcode => $patron->branchcode});
585 $pickup_libraries = $plib->get_hold_libraries;
586 } elsif ($branchitemrule->{hold_fulfillment_policy} eq 'homebranch') {
587 $pickup_libraries = Koha::Libraries->search({ branchcode => $self->homebranch });
588 } elsif ($branchitemrule->{hold_fulfillment_policy} eq 'holdingbranch') {
589 $pickup_libraries = Koha::Libraries->search({ branchcode => $self->holdingbranch });
592 return $pickup_libraries->search(
597 order_by => ['branchname']
599 ) unless C4::Context->preference('UseBranchTransferLimits');
601 my $limittype = C4::Context->preference('BranchTransferLimitsType');
602 my $limiter = $limittype eq 'itemtype' ? $self->effective_itemtype : $self->ccode;
603 my $limits = Koha::Item::Transfer::Limits->search(
605 fromBranch => $self->holdingbranch,
606 $limittype => $limiter
608 { columns => ['toBranch'] }
611 return $pickup_libraries->search(
613 pickup_location => 1,
615 '-not_in' => $limits->_resultset->as_query
619 order_by => ['branchname']
624 =head3 article_request_type
626 my $type = $item->article_request_type( $borrower )
628 returns 'yes', 'no', 'bib_only', or 'item_only'
630 $borrower must be a Koha::Patron object
634 sub article_request_type {
635 my ( $self, $borrower ) = @_;
637 my $branch_control = C4::Context->preference('HomeOrHoldingBranch');
639 $branch_control eq 'homebranch' ? $self->homebranch
640 : $branch_control eq 'holdingbranch' ? $self->holdingbranch
642 my $borrowertype = $borrower->categorycode;
643 my $itemtype = $self->effective_itemtype();
644 my $rule = Koha::CirculationRules->get_effective_rule(
646 rule_name => 'article_requests',
647 categorycode => $borrowertype,
648 itemtype => $itemtype,
649 branchcode => $branchcode
653 return q{} unless $rule;
654 return $rule->rule_value || q{}
663 my $attributes = { order_by => 'priority' };
664 my $dtf = Koha::Database->new->schema->storage->datetime_parser;
666 itemnumber => $self->itemnumber,
669 reservedate => { '<=' => $dtf->format_date(dt_from_string) },
670 waitingdate => { '!=' => undef },
673 my $hold_rs = $self->_result->reserves->search( $params, $attributes );
674 return Koha::Holds->_new_from_dbic($hold_rs);
677 =head3 stockrotationitem
679 my $sritem = Koha::Item->stockrotationitem;
681 Returns the stock rotation item associated with the current item.
685 sub stockrotationitem {
687 my $rs = $self->_result->stockrotationitem;
689 return Koha::StockRotationItem->_new_from_dbic( $rs );
694 my $item = $item->add_to_rota($rota_id);
696 Add this item to the rota identified by $ROTA_ID, which means associating it
697 with the first stage of that rota. Should this item already be associated
698 with a rota, then we will move it to the new rota.
703 my ( $self, $rota_id ) = @_;
704 Koha::StockRotationRotas->find($rota_id)->add_item($self->itemnumber);
708 =head3 has_pending_hold
710 my $is_pending_hold = $item->has_pending_hold();
712 This method checks the tmp_holdsqueue to see if this item has been selected for a hold, but not filled yet and returns true or false
716 sub has_pending_hold {
718 my $pending_hold = $self->_result->tmp_holdsqueues;
719 return $pending_hold->count ? 1: 0;
724 my $mss = C4::Biblio::GetMarcSubfieldStructure( '', { unsafe => 1 } );
725 my $field = $item->as_marc_field({ [ mss => $mss ] });
727 This method returns a MARC::Field object representing the Koha::Item object
728 with the current mappings configuration.
733 my ( $self, $params ) = @_;
735 my $mss = $params->{mss} // C4::Biblio::GetMarcSubfieldStructure( '', { unsafe => 1 } );
736 my $item_tag = $mss->{'items.itemnumber'}[0]->{tagfield};
740 my @columns = $self->_result->result_source->columns;
742 foreach my $item_field ( @columns ) {
743 my $mapping = $mss->{ "items.$item_field"}[0];
744 my $tagfield = $mapping->{tagfield};
745 my $tagsubfield = $mapping->{tagsubfield};
746 next if !$tagfield; # TODO: Should we raise an exception instead?
747 # Feels like safe fallback is better
749 push @subfields, $tagsubfield => $self->$item_field
750 if defined $self->$item_field and $item_field ne '';
753 my $unlinked_item_subfields = C4::Items::_parse_unlinked_item_subfields_from_xml($self->more_subfields_xml);
754 push( @subfields, @{$unlinked_item_subfields} )
755 if defined $unlinked_item_subfields and $#$unlinked_item_subfields > -1;
759 $field = MARC::Field->new(
760 "$item_tag", ' ', ' ', @subfields
766 =head3 renewal_branchcode
768 Returns the branchcode to be recorded in statistics renewal of the item
772 sub renewal_branchcode {
774 my ($self, $params ) = @_;
776 my $interface = C4::Context->interface;
778 if ( $interface eq 'opac' ){
779 my $renewal_branchcode = C4::Context->preference('OpacRenewalBranch');
780 if( !defined $renewal_branchcode || $renewal_branchcode eq 'opacrenew' ){
781 $branchcode = 'OPACRenew';
783 elsif ( $renewal_branchcode eq 'itemhomebranch' ) {
784 $branchcode = $self->homebranch;
786 elsif ( $renewal_branchcode eq 'patronhomebranch' ) {
787 $branchcode = $self->checkout->patron->branchcode;
789 elsif ( $renewal_branchcode eq 'checkoutbranch' ) {
790 $branchcode = $self->checkout->branchcode;
796 $branchcode = ( C4::Context->userenv && defined C4::Context->userenv->{branch} )
797 ? C4::Context->userenv->{branch} : $params->{branch};
804 Return the cover images associated with this item.
811 my $cover_image_rs = $self->_result->cover_images;
812 return unless $cover_image_rs;
813 return Koha::CoverImages->_new_from_dbic($cover_image_rs);
816 =head3 _set_found_trigger
818 $self->_set_found_trigger
820 Finds the most recent lost item charge for this item and refunds the patron
821 appropriately, taking into account any payments or writeoffs already applied
824 Internal function, not exported, called only by Koha::Item->store.
828 sub _set_found_trigger {
829 my ( $self, $pre_mod_item ) = @_;
831 ## If item was lost, it has now been found, reverse any list item charges if necessary.
832 my $no_refund_after_days =
833 C4::Context->preference('NoRefundOnLostReturnedItemsAge');
834 if ($no_refund_after_days) {
835 my $today = dt_from_string();
836 my $lost_age_in_days =
837 dt_from_string( $pre_mod_item->itemlost_on )->delta_days($today)
840 return $self unless $lost_age_in_days < $no_refund_after_days;
843 my $lostreturn_policy = Koha::CirculationRules->get_lostreturn_policy(
846 return_branch => C4::Context->userenv
847 ? C4::Context->userenv->{'branch'}
852 if ( $lostreturn_policy ) {
854 # refund charge made for lost book
855 my $lost_charge = Koha::Account::Lines->search(
857 itemnumber => $self->itemnumber,
858 debit_type_code => 'LOST',
859 status => [ undef, { '<>' => 'FOUND' } ]
862 order_by => { -desc => [ 'date', 'accountlines_id' ] },
867 if ( $lost_charge ) {
869 my $patron = $lost_charge->patron;
872 my $account = $patron->account;
873 my $total_to_refund = 0;
876 if ( $lost_charge->amount > $lost_charge->amountoutstanding ) {
878 # some amount has been cancelled. collect the offsets that are not writeoffs
879 # this works because the only way to subtract from this kind of a debt is
880 # using the UI buttons 'Pay' and 'Write off'
881 my $credits_offsets = Koha::Account::Offsets->search(
883 debit_id => $lost_charge->id,
884 credit_id => { '!=' => undef }, # it is not the debit itself
885 type => { '!=' => 'Writeoff' },
886 amount => { '<' => 0 } # credits are negative on the DB
890 $total_to_refund = ( $credits_offsets->count > 0 )
891 ? $credits_offsets->total * -1 # credits are negative on the DB
895 my $credit_total = $lost_charge->amountoutstanding + $total_to_refund;
898 if ( $credit_total > 0 ) {
900 C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
901 $credit = $account->add_credit(
903 amount => $credit_total,
904 description => 'Item found ' . $self->itemnumber,
905 type => 'LOST_FOUND',
906 interface => C4::Context->interface,
907 library_id => $branchcode,
908 item_id => $self->itemnumber,
909 issue_id => $lost_charge->issue_id
913 $credit->apply( { debits => [$lost_charge] } );
914 $self->{_refunded} = 1;
917 # Update the account status
918 $lost_charge->status('FOUND');
919 $lost_charge->store();
921 # Reconcile balances if required
922 if ( C4::Context->preference('AccountAutoReconcile') ) {
923 $account->reconcile_balance;
928 # restore fine for lost book
929 if ( $lostreturn_policy eq 'restore' ) {
930 my $lost_overdue = Koha::Account::Lines->search(
932 itemnumber => $self->itemnumber,
933 debit_type_code => 'OVERDUE',
937 order_by => { '-desc' => 'date' },
942 if ( $lost_overdue ) {
944 my $patron = $lost_overdue->patron;
946 my $account = $patron->account;
948 # Update status of fine
949 $lost_overdue->status('FOUND')->store();
951 # Find related forgive credit
952 my $refund = $lost_overdue->credits(
954 credit_type_code => 'FORGIVEN',
955 itemnumber => $self->itemnumber,
956 status => [ { '!=' => 'VOID' }, undef ]
958 { order_by => { '-desc' => 'date' }, rows => 1 }
962 # Revert the forgive credit
964 $self->{_restored} = 1;
967 # Reconcile balances if required
968 if ( C4::Context->preference('AccountAutoReconcile') ) {
969 $account->reconcile_balance;
973 } elsif ( $lostreturn_policy eq 'charge' ) {
974 $self->{_charge} = 1;
981 =head3 to_api_mapping
983 This method returns the mapping for representing a Koha::Item object
990 itemnumber => 'item_id',
991 biblionumber => 'biblio_id',
992 biblioitemnumber => undef,
993 barcode => 'external_id',
994 dateaccessioned => 'acquisition_date',
995 booksellerid => 'acquisition_source',
996 homebranch => 'home_library_id',
997 price => 'purchase_price',
998 replacementprice => 'replacement_price',
999 replacementpricedate => 'replacement_price_date',
1000 datelastborrowed => 'last_checkout_date',
1001 datelastseen => 'last_seen_date',
1003 notforloan => 'not_for_loan_status',
1004 damaged => 'damaged_status',
1005 damaged_on => 'damaged_date',
1006 itemlost => 'lost_status',
1007 itemlost_on => 'lost_date',
1008 withdrawn => 'withdrawn',
1009 withdrawn_on => 'withdrawn_date',
1010 itemcallnumber => 'callnumber',
1011 coded_location_qualifier => 'coded_location_qualifier',
1012 issues => 'checkouts_count',
1013 renewals => 'renewals_count',
1014 reserves => 'holds_count',
1015 restricted => 'restricted_status',
1016 itemnotes => 'public_notes',
1017 itemnotes_nonpublic => 'internal_notes',
1018 holdingbranch => 'holding_library_id',
1019 timestamp => 'timestamp',
1020 location => 'location',
1021 permanent_location => 'permanent_location',
1022 onloan => 'checked_out_date',
1023 cn_source => 'call_number_source',
1024 cn_sort => 'call_number_sort',
1025 ccode => 'collection_code',
1026 materials => 'materials_notes',
1028 itype => 'item_type',
1029 more_subfields_xml => 'extended_subfields',
1030 enumchron => 'serial_issue_number',
1031 copynumber => 'copy_number',
1032 stocknumber => 'inventory_number',
1033 new_status => 'new_status'
1039 my $itemtype = $item->itemtype;
1041 Returns Koha object for effective itemtype
1047 return Koha::ItemTypes->find( $self->effective_itemtype );
1050 =head2 Internal methods
1052 =head3 _after_item_action_hooks
1054 Helper method that takes care of calling all plugin hooks
1058 sub _after_item_action_hooks {
1059 my ( $self, $params ) = @_;
1061 my $action = $params->{action};
1063 Koha::Plugins->call(
1064 'after_item_action',
1068 item_id => $self->itemnumber,
1083 Kyle M Hall <kyle@bywatersolutions.com>