}
use Carp;
+use Try::Tiny;
use C4::Context;
use C4::Koha;
use C4::Biblio;
logaction( "CATALOGUING", "ADD", $itemnumber, "item" )
if C4::Context->preference("CataloguingLog");
+ _after_item_action_hooks({ action => 'create', item_id => $itemnumber });
+
return ( $item->{biblionumber}, $item->{biblioitemnumber}, $itemnumber );
}
materials => undef,
new_status => undef,
notforloan => 0,
- # paidfor => undef, # commented, see bug 12817
price => undef,
replacementprice => undef,
replacementpricedate => undef,
# item status is possible
ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
+ _after_item_action_hooks({ action => 'modify', item_id => $itemnumber });
+
logaction( "CATALOGUING", "MODIFY", $itemnumber, "item " . Dumper($item) )
if $log_action && C4::Context->preference("CataloguingLog");
}
my ( $itemnumber, $frombranch, $tobranch ) = @_;
my $dbh = C4::Context->dbh;
- my $item = GetItem( $itemnumber );
+ my $item = Koha::Items->find( $itemnumber );
# Remove the 'shelving cart' location status if it is being used.
- CartToShelf( $itemnumber ) if ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART' );
+ CartToShelf( $itemnumber ) if ( $item->location eq 'CART' && $item->permanent_location ne 'CART' );
$dbh->do("UPDATE branchtransfers SET datearrived = NOW(), comments = ? WHERE itemnumber = ? AND datearrived IS NULL", undef, "Canceled, new transfer from $frombranch to $tobranch created", $itemnumber);
ModZebra( $biblionumber, "specialUpdate", "biblioserver" );
+ _after_item_action_hooks({ action => 'delete', item_id => $itemnumber });
+
#search item field code
logaction("CATALOGUING", "DELETE", $itemnumber, "item") if C4::Context->preference("CataloguingLog");
return $deleted;
holding.opac_info as holding_branch_opac_info,
home.opac_info as home_branch_opac_info
";
- $query .= ",IF(tmp_holdsqueue.itemnumber,1,0) AS pending_hold" if !C4::Context->preference('AllowItemsOnHoldCheckout');
+ $query .= ",IF(tmp_holdsqueue.itemnumber,1,0) AS has_pending_hold" if !C4::Context->preference('AllowItemsOnHoldCheckout');
$query .= "
FROM items
LEFT JOIN branches AS holding ON items.holdingbranch = holding.branchcode
itemnotes = ?,
itemnotes_nonpublic = ?,
holdingbranch = ?,
- paidfor = ?,
location = ?,
permanent_location = ?,
onloan = ?,
$item->{'itemnotes'},
$item->{'itemnotes_nonpublic'},
$item->{'holdingbranch'},
- $item->{'paidfor'},
$item->{'location'},
$item->{'permanent_location'},
$item->{'onloan'},
return $report;
}
+=head2 _after_item_action_hooks
+
+Helper method that takes care of calling all plugin hooks
+
+=cut
+
+sub _after_item_action_hooks {
+ my ( $args ) = @_;
+
+ my $item_id = $args->{item_id};
+ my $action = $args->{action};
+
+ if ( C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins") ) {
+
+ my @plugins = Koha::Plugins->new->GetPlugins({
+ method => 'after_item_action',
+ });
+
+ if (@plugins) {
+
+ my $item = Koha::Items->find( $item_id );
+
+ foreach my $plugin ( @plugins ) {
+ try {
+ $plugin->after_item_action({ action => $action, item => $item, item_id => $item_id });
+ }
+ catch {
+ warn "$_";
+ };
+ }
+ }
+ }
+}
1;