@@ -, +, @@ renewed. --- C4/Circulation.pm | 35 +++++++++++++++++ Koha/CirculationRules.pm | 6 +++ admin/smart-rules.pl | 29 ++++++++++++-- .../bug_9805_-_add_renew_lost_circ_rules.pl | 22 +++++++++++ .../prog/en/modules/admin/smart-rules.tt | 38 +++++++++++++++++++ .../prog/en/modules/circ/renew.tt | 4 ++ .../bootstrap/en/modules/opac-user.tt | 2 + 7 files changed, 133 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_9805_-_add_renew_lost_circ_rules.pl --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -3139,6 +3139,19 @@ sub CanBookBeRenewed { my $auto_renew_code = $final_renewal ? 'auto_renew_final' : $final_unseen_renewal ? 'auto_unseen_final' : 'auto_renew'; return ( 1, $auto_renew_code ) if $auto_renew eq "ok" || $auto_renew eq "auto_too_soon" && !$override_limit; + if ( $item->itemlost ) { + my $branchcode = _GetCircControlBranch( $item, $patron ); + my $renew_lost_allowed_rule = Koha::CirculationRules->get_effective_rule( + { + categorycode => $patron->categorycode, + itemtype => undef, + branchcode => $branchcode, + rule_name => 'renew_lost_allowed', + } + ); + return ( 0, "item_lost" ) unless $renew_lost_allowed_rule->rule_value; + } + return ( 1, undef ); } @@ -3260,6 +3273,28 @@ sub AddRenewal { } ); + if ( $item_object->itemlost ) { + my $itemlost = 1; + + my $branchcode = _GetCircControlBranch( $item_object, $patron ); + my $renew_lost_found_rule = Koha::CirculationRules->get_effective_rule( + { + categorycode => $patron->categorycode, + itemtype => undef, + branchcode => $branchcode, + rule_name => 'renew_lost_found', + } + ); + + if ( $renew_lost_found_rule->rule_value ) { + $itemlost = 0; + if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) { + _FixAccountForLostAndReturned( $item_object->id, undef, $item_object->barcode ); + } + } + $item_object->itemlost($itemlost); + } + # Increment the unseen renewals, if appropriate # We only do so if the syspref is enabled and # a maximum value has been set in the circ rules --- a/Koha/CirculationRules.pm +++ a/Koha/CirculationRules.pm @@ -65,6 +65,12 @@ our $RULE_KINDS = { max_holds => { scope => [ 'branchcode', 'categorycode' ], }, + renew_lost_allowed => { + scope => [ 'branchcode', 'categorycode' ], + }, + renew_lost_found => { + scope => [ 'branchcode', 'categorycode' ], + }, holdallowed => { scope => [ 'branchcode', 'itemtype' ], --- a/admin/smart-rules.pl +++ a/admin/smart-rules.pl @@ -133,6 +133,8 @@ elsif ($op eq 'delete-branch-cat') { max_holds => undef, patron_maxissueqty => undef, patron_maxonsiteissueqty => undef, + renew_lost_allowed => undef, + renew_lost_found => undef, } } ); @@ -156,6 +158,8 @@ elsif ($op eq 'delete-branch-cat') { max_holds => undef, patron_maxissueqty => undef, patron_maxonsiteissueqty => undef, + renew_lost_allowed => undef, + renew_lost_found => undef, } } ); @@ -169,6 +173,8 @@ elsif ($op eq 'delete-branch-cat') { max_holds => undef, patron_maxissueqty => undef, patron_maxonsiteissueqty => undef, + renew_lost_allowed => undef, + renew_lost_found => undef, } } ); @@ -192,6 +198,8 @@ elsif ($op eq 'delete-branch-cat') { max_holds => undef, patron_maxissueqty => undef, patron_maxonsiteissueqty => undef, + renew_lost_allowed => undef, + renew_lost_found => undef, } } ); @@ -365,6 +373,8 @@ elsif ($op eq "set-branch-defaults") { my $hold_fulfillment_policy = $input->param('hold_fulfillment_policy'); my $returnbranch = $input->param('returnbranch'); my $max_holds = strip_non_numeric( scalar $input->param('max_holds') ); + my $renew_lost_allowed = $input->param('renew_lost_allowed'); + my $renew_lost_found = $input->param('renew_lost_found'); if ($branch eq "*") { Koha::CirculationRules->set_rules( @@ -411,12 +421,15 @@ elsif ($op eq "set-branch-defaults") { } ); } - Koha::CirculationRules->set_rule( + Koha::CirculationRules->set_rules( { branchcode => $branch, categorycode => undef, - rule_name => 'max_holds', - rule_value => $max_holds, + rules => { + max_holds => $max_holds, + renew_lost_allowed => $renew_lost_allowed, + renew_lost_found => $renew_lost_found, + }, } ); } @@ -427,6 +440,8 @@ elsif ($op eq "add-branch-cat") { $patron_maxonsiteissueqty = strip_non_numeric($patron_maxonsiteissueqty); my $max_holds = $input->param('max_holds'); $max_holds = strip_non_numeric($max_holds); + my $renew_lost_allowed = $input->param('renew_lost_allowed'); + my $renew_lost_found = $input->param('renew_lost_found'); if ($branch eq "*") { if ($categorycode eq "*") { @@ -438,6 +453,8 @@ elsif ($op eq "add-branch-cat") { max_holds => $max_holds, patron_maxissueqty => $patron_maxissueqty, patron_maxonsiteissueqty => $patron_maxonsiteissueqty, + renew_lost_allowed => $renew_lost_allowed, + renew_lost_found => $renew_lost_found, } } ); @@ -450,6 +467,8 @@ elsif ($op eq "add-branch-cat") { max_holds => $max_holds, patron_maxissueqty => $patron_maxissueqty, patron_maxonsiteissueqty => $patron_maxonsiteissueqty, + renew_lost_allowed => $renew_lost_allowed, + renew_lost_found => $renew_lost_found, } } ); @@ -463,6 +482,8 @@ elsif ($op eq "add-branch-cat") { max_holds => $max_holds, patron_maxissueqty => $patron_maxissueqty, patron_maxonsiteissueqty => $patron_maxonsiteissueqty, + renew_lost_allowed => $renew_lost_allowed, + renew_lost_found => $renew_lost_found, } } ); @@ -475,6 +496,8 @@ elsif ($op eq "add-branch-cat") { max_holds => $max_holds, patron_maxissueqty => $patron_maxissueqty, patron_maxonsiteissueqty => $patron_maxonsiteissueqty, + renew_lost_allowed => $renew_lost_allowed, + renew_lost_found => $renew_lost_found, } } ); --- a/installer/data/mysql/atomicupdate/bug_9805_-_add_renew_lost_circ_rules.pl +++ a/installer/data/mysql/atomicupdate/bug_9805_-_add_renew_lost_circ_rules.pl @@ -0,0 +1,22 @@ +use Modern::Perl; + +return { + bug_number => "9805", + description => "Lost items are un-lost if returned, but not if renewed", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) VALUES (NULL, NULL, NULL, 'renew_lost_allowed', 1) } + ); + + say $out "Added default checkout, hold and return policy renew_lost_allowed"; + + $dbh->do( + q{ INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) VALUES (NULL, NULL, NULL, 'renew_lost_found', 0) } + ); + + say $out "Added default checkout, hold and return policy renew_lost_found"; + }, +}; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -632,6 +632,8 @@ Hold policy Hold pickup library match Return policy + Renew lost? + Renewal marks lost found Actions [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty', { want_rule => 1 } ) %] @@ -794,6 +796,42 @@ + + + + + + [% IF ( default_checkout_hold_and_return_policy ) %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt @@ -169,6 +169,10 @@ [% ELSIF error == 'recalled' %]

This item has been recalled.

+ [% ELSIF error == "item_lost" %] + +

This item is lost.

+ [% ELSE %] [% error | html %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -463,6 +463,8 @@ ) [% ELSIF ( ISSUE.on_reserve ) %] Not renewable (on hold) + [% ELSIF ( ISSUE.item_lost ) %] + Not renewable (item is lost) [% ELSIF ( ISSUE.too_many ) %] Not renewable [% ELSIF ( ISSUE.too_unseen ) %] --