From 3f8642c26da01c8606debee9c23ce798559cafd6 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 13 Mar 2013 08:36:57 -0400 Subject: [PATCH] Bug 9805: Lost items are un-lost if returned, but not if renewed. If an item has a lost status, that status is removed when the item is returned. However, it is not removed if the item is renewed. Test Plan: 1) Apply this patch 2) Install database updates 3) Browse to the circ rules 4) Note the "Renew lost?" and "Renewal marks lost found" rules under default checkout hold and return policy 5) Set and test each of the rules both ways for the rules for all libraries Sponsored-by: Waikato Institute of Technology --- 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 diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 109809d4b99..ccf62bf2861 100644 --- a/C4/Circulation.pm +++ b/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 diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index 1d074768754..55d2306e151 100644 --- a/Koha/CirculationRules.pm +++ b/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' ], diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index fd20484c9f6..99e8098c2b7 100755 --- a/admin/smart-rules.pl +++ b/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, } } ); diff --git a/installer/data/mysql/atomicupdate/bug_9805_-_add_renew_lost_circ_rules.pl b/installer/data/mysql/atomicupdate/bug_9805_-_add_renew_lost_circ_rules.pl new file mode 100755 index 00000000000..bf40229aa8a --- /dev/null +++ b/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"; + }, +}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index d71e25ccaaf..b4d6968ee71 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/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 ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt index 606a11fb42e..328fe10996a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt +++ b/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 %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 996e466fc73..8b4a30c575f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/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 ) %] -- 2.30.2