From d8afffdc42723c689d67a44a26d05cd6c5f78090 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 4 Dec 2017 15:23:02 +1300 Subject: [PATCH] Bug 18450 - Followup - Implemented a conditional checking if the item that the patron is trying to renew has more than 1 copy available which can be renewed. This means the AllowRebnewalIfOtherItemsAvailable system preference is now appropriately implemented. In order to make the conditional statement work correctly checking three conditions each time (two system preferences and the value of the can_renew variable I had to implement a elsif statement. I spent a large amount of time trying to get a single IF statement to check the three conditions in three different combinations but it ignored the value of the can_renew variable each time and so I was forced to split it out into an If and ELSIF Test plan: 1. In More->Administration->Global system preferences ensure that both the AllowRenewalLimitOverride and AllowRenewalIfOtherItemsAvaliable preferences are both set to 'Dont allow'. 2. Place a hold on an item 3. Checkout the item out to a different patron 4. Renew the item and notice the 'Cannot renew: The item is on hold for another patron' warning 5. Click the 'Override and renew' button and notice that you can bypass the hold 6. Apply patch 7. Try to renew an item (with item level hold on it) which belongs to a biblio with either only one item or a biblio with multiple items all of which have holds on them. Notice the only button in the yellow message box displayed is 'Continue without renewing' 8. Repeat step 7 but change the hold to a 'Next available' hold rather than an item level hold. Again notice only the 'Continue without renewing' button is displayed 9. Try to renew an item (with item level hold on it) which belongs to a biblio with mutliple aviable items of it in the catalogue. Notice only the 'Continue without renewing' button is displayed 10. Repeat step 9 but change the hold to a 'Next available' hold rather than an item level hold. Notice only the 'Continue without renewing' button is displayed 11. Set both AllowRenewalLimitOverride and AllowRenewalIfOtherItemsAvaliable systempreferences to 'Allow' and repeat step 7 notice only the 'Continue without renewing' button is displayed in the yellow message box 12. Repeat step 8 and notice only the 'Continue without renewing' button is displayed 13. Repeat step 9 and notice only the 'Continue without renewing' button is displayed 14. Repeat step 10 and notice the item is immediately renewed and the yellow message box is not displayed 15. Set the AllowRenewalIfOtheritemsAvailable to 'Dont' Allow' and repeat step 7 and notice that both the 'Override and renew' and 'Continue without renewal' buttons are displayed 16. Repeat step 8 and notice both buttons are displayed 17. Repeat step 9 and notice both buttons are displayed 18. Repeat step 10 and notice both buttons are displayed 19. Set AllowRenewalIfOtherItemsAvailable syspref to 'Allow' and AllowRenewalLimitOverride syspref to 'Dont' Allow' and repeat step 7 and notice only the 'Continue without renewal' button is displayed 20. Repeat step 8 and notice only 'Continue without renewal' button is displayed 21. Repeat step 9 and notice only the 'Continue without renewal' button is displayed 22. Repeat step 10 and notice both buttons are displayed Sponsored-By: Catalyst IT --- C4/Circulation.pm | 1 + circ/renew.pl | 2 ++ .../intranet-tmpl/prog/en/modules/circ/renew.tt | 26 +++++++++++----------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 9397cbc..17c321b 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2639,6 +2639,7 @@ sub CanBookBeRenewed { my ( $reserve_found, $reserve, undef ) = C4::Reserves::CheckReserves( $itemnumber, undef, undef, \@borrowernumbers ); + warn $reserve_found; if ($reserve_found) { push( @borrowernumbers, $reserve->{borrowernumber} ); } diff --git a/circ/renew.pl b/circ/renew.pl index 246c266..fdcfe9d 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -76,6 +76,8 @@ if ($barcode) { else { $can_renew = 0; } + + $template->param(can_renew => $can_renew ); } if ( $error && ($error eq 'too_soon' or $error eq 'auto_too_soon') ) { 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 7603710..f578d8c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt @@ -106,20 +106,20 @@

This item is on hold for another patron.

- [% IF (Koha.Preference('AllowRenewalLimitOverride')) && (Koha.Preference('AllowRenewalIfOtherItemsAvailable')) %] + [% IF ((!Koha.Preference('AllowRenewalLimitOverride')) && ((Koha.Preference('AllowRenewalIfOtherItemsAvailable'))) && can_renew == 1) || ((Koha.Preference('AllowRenewalLimitOverride')) && ((Koha.Preference('AllowRenewalIfOtherItemsAvailable'))) && can_renew == 1 )%]
- - - - -
- [% ELSIF (!(Koha.Preference('AllowRenewalLimitOverride')) && (Koha.Preference('AllowRenewalIfOtherItemsAvailable'))) || (Koha.Preference('AllowRenewalLimitOverride') && (!(Koha.Preference('AllowRenewalIfOtherItemsAvaliable')))) %] -
- - - - -
+ + + + + + [% ELSIF ((Koha.Preference('AllowRenewalLimitOverride')) && (!Koha.Preference('AllowRenewalIfOtherItemsAvailable'))) %] +
+ + + + +
[% END %] [% ELSIF error == "patron_restricted" %] -- 2.1.4