From 6559f638e78ee84a5087b282b62ef74706a34449 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Thu, 21 May 2020 23:56:15 +0000 Subject: [PATCH] Bug 25560: Exclude itemtypes from UpdateNotForLoanStatusOnCheckin Adds a boolean flag itemtypes.updatenotforloanstatusoncheckin, enabled by default. When disabled (if the UpdateNoForLoanStatusOnCheckin syspref is configured) when an item of the type if checked in the notforloan status does not update. This enhancement respects the 'item-level_itypes' syspref, so will look at the authoritative item type when determining to update the notforloan status. Test plan: 1. Paste into UpdateNotForLoanStatusOnCheckin syspref 0 : 1 2. Issue and return an item and observe the item's notforloan status updates 3. Apply patch & update database cd installer/data/mysql sudo koha-shell ./updatedatabase.pl 4. Restart plack 5. Go to BK (Book) item type page (Administration > Item types > BK). 6. Observe the 'Update not for loan status on check-in' checkbox is selected by default. Untick it. 7. Make sure the 'item-level_itypes' syspref is set to 'specific item' 8. Issue and return a BK item (item level itype='BK') and observe item's notforloan status does not update 9. Issue and return a CR (Continuing Resources) item (item level itype='CR') and observe the item's notforloan status updates 10. Change 'item-level_itypes' syspref to 'bibliographic record' 11. Issue and return an item (with biblio-level itemtype='BK' & item-level itype='CR') and observe the item's notforloan status does not update 12. Issue and return an item (with biblio-level itemtype='CR' & item-level itype='BK') and observe the item's notforloan status updates Sponsored-By: Waikato Institute of Technology, NZ --- C4/Circulation.pm | 4 ++++ admin/itemtypes.pl | 3 +++ 2 files changed, 7 insertions(+) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index e439250933..0744a4f8f2 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1934,6 +1934,10 @@ sub AddReturn { } else { foreach my $key ( keys %$rules ) { + # If item type in use has a disabled updatenotforloanstatusoncheckin flag then don't update notforloan + my $updatenotforloanstatusoncheckin = C4::Context->preference("item-level_itypes") ? Koha::ItemTypes->find($item->itype)->updatenotforloanstatusoncheckin : Koha::ItemTypes->find($item->biblioitem->itemtype)->updatenotforloanstatusoncheckin; + last if !$updatenotforloanstatusoncheckin; + if ( $item->notforloan eq $key ) { $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; $item->notforloan($rules->{$key})->store({ log_action => 0 }); diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index 7b13dac7b7..707be786d5 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -104,6 +104,7 @@ if ( $op eq 'add_form' ) { my $checkinmsg = $input->param('checkinmsg'); my $checkinmsgtype = $input->param('checkinmsgtype'); my $hideinopac = $input->param('hideinopac') // 0; + my $updatenotforloanstatusoncheckin = $input->param('updatenotforloanstatusoncheckin') // 0; my $searchcategory = $input->param('searchcategory'); my $rentalcharge_daily_calendar = $input->param('rentalcharge_daily_calendar') // 0; my $rentalcharge_hourly_calendar = $input->param('rentalcharge_hourly_calendar') // 0; @@ -122,6 +123,7 @@ if ( $op eq 'add_form' ) { $itemtype->checkinmsgtype($checkinmsgtype); $itemtype->sip_media_type($sip_media_type); $itemtype->hideinopac($hideinopac); + $itemtype->updatenotforloanstatusoncheckin($updatenotforloanstatusoncheckin); $itemtype->searchcategory($searchcategory); $itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar); $itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar); @@ -153,6 +155,7 @@ if ( $op eq 'add_form' ) { checkinmsgtype => $checkinmsgtype, sip_media_type => $sip_media_type, hideinopac => $hideinopac, + updatenotforloanstatusoncheckin => $updatenotforloanstatusoncheckin, searchcategory => $searchcategory, rentalcharge_daily_calendar => $rentalcharge_daily_calendar, rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar, -- 2.11.0