@@ -, +, @@ UpdateNotForLoanStatusOnCheckin 0 : 1 --- C4/Circulation.pm | 32 ++++++++++++++++++-------------- admin/itemtypes.pl | 3 +++ 2 files changed, 21 insertions(+), 14 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -2131,20 +2131,24 @@ sub AddReturn { } } - my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin'); - if ($yaml) { - $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt - my $rules; - eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; - if ($@) { - warn "Unable to parse UpdateNotForLoanStatusOnCheckin syspref : $@"; - } - else { - foreach my $key ( keys %$rules ) { - if ( $item->notforloan eq $key ) { - $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; - $item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1 }); - last; + # check if the item should have it's notforloan status changed + my $itemtype_object = Koha::ItemTypes->find( $itemtype ); + if ( defined $itemtype_object && $itemtype_object->updatenotforloan ) { + my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin'); + if ($yaml) { + $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt + my $rules; + eval { $rules = YAML::XS::Load(Encode::encode_utf8($yaml)); }; + if ($@) { + warn "Unable to parse UpdateNotForLoanStatusOnCheckin syspref : $@"; + } + else { + foreach my $key ( keys %$rules ) { + if ( $item->notforloan eq $key ) { + $messages->{'NotForLoanStatusUpdated'} = { from => $item->notforloan, to => $rules->{$key} }; + $item->notforloan($rules->{$key})->store({ log_action => 0, skip_record_index => 1, skip_holds_queue => 1 }); + last; + } } } } --- a/admin/itemtypes.pl +++ a/admin/itemtypes.pl @@ -94,6 +94,7 @@ if ( $op eq 'add_form' ) { my $checkinmsg = $input->param('checkinmsg'); my $checkinmsgtype = $input->param('checkinmsgtype'); my $hideinopac = $input->param('hideinopac') // 0; + my $updatenotforloan = $input->param('updatenotforloan') // 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; @@ -114,6 +115,7 @@ if ( $op eq 'add_form' ) { $itemtype->checkinmsgtype($checkinmsgtype); $itemtype->sip_media_type($sip_media_type); $itemtype->hideinopac($hideinopac); + $itemtype->updatenotforloan($updatenotforloan); $itemtype->searchcategory($searchcategory); $itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar); $itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar); @@ -147,6 +149,7 @@ if ( $op eq 'add_form' ) { checkinmsgtype => $checkinmsgtype, sip_media_type => $sip_media_type, hideinopac => $hideinopac, + updatenotforloan => $updatenotforloan, searchcategory => $searchcategory, rentalcharge_daily_calendar => $rentalcharge_daily_calendar, rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar, --