From 3522745cb37afbe58b1b8ba2e2c24732c69d8276 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Thu, 30 Aug 2018 10:33:25 +1200 Subject: [PATCH] Bug 15565: Allow up to (and including) maxreserves number of OPAC item levelholds This commit implements changes to opac-reserve.tt and opac-reserve.pl. 1. The change to opac-reserve.tt JS fixes the total_requested() function which returns an output which is always 2 digits higher than the actual number of selected item checkboxes. i.e. if the 'maxreserves' syspref (limit for the overall number of reserves allowed by a user) is 4 and a user has no previous holds and ticks 3 item checkboxes and submits the form. The 'Maximum number of reserve exceded.' popup message is displayed, however as they have selected 3 items for reservation this is less than the maxreserves value of 4. The popup is displayed because total_requested() JS function is returning 5 (i.e. 2 on top of the actual number of requested holds). This commit usbtracts 2 from the number of holds calculated by total_requested() so that the accurate number of requested holds is being used to determine whether or not to display the excess holds popup. 2. When the 'Holds per record (count)' (circulation rule) and 'maxreserves' syspref are the same value (e.g. 4) you can tick 4 item checkboxes in opac-reserve.pl and submit the form. The form will submit successfully and to the user everything looks to have worked however the holds will not be successfully created. This is because after the form is submitted to opac-reserve.pl a check is done: If 'number of submitted hold requests' + 'number of previous existing holds' greater than or equal to maxreserves syspref then set the variable '$canreserve' to 0. If the $canreserve variable is 0 the form will submit, no warning/error message is displayed to the user but the holds are not created. Users should be able to place 4 holds if the maxreserves syspref is 4 (just not more than 4 holds). This commit changes this check to: If 'number of submitted hold requests' + 'number of previous existing holds' greater than maxreserves syspref then set the variable '$canreserve' to 0.. i.e. notice we only check for greater than (not equal to). Which solves the bug of the form submitting and no holds being created when the maxreserves syspref and 'Holds per record (count)' (circulation rule) are the same. Test plan (in two parts to test fix #1 and #2 (above)): Test plan for fix #1: 1. Apply all patches on this bug report (15565) and follow and confirm the feature works as described in the test plan in the first commit 2. Set the 'maxreserves' syspref to 3 (and 'Holds per record (count)' (circulation rule) to 5) 3. Ensure your logged in patron account has no existing reserves 4. In the OPAC go to a biblio page with 3 or more items 5. In the reservation page (opac-reserve.pl) for that biblio select 2 item checkboes to place 2 item level holds and notice the 'Maximum number of reserve exceded.' popup message is displayed. As the maxreserves syspref value is 3 you should be able to place 2 holds without exceeding that value 6. Apply this patch 7. Repeat step 5 and notice the form submits without the exceeding popup message and the holds are successfully placed. Test plan for fix #2: 1. Apply all patches attached to this bug report (bug 15565) and perform the test plan in the first commit and verify it works. 2. Set your 'Holds per record (count)' (circulation rule) and 'maxreserves' syspref to the same value 3 3. Go to a biblio in the OPAC with 3 or more items 4. In the opac-reserve.pl reservation interface for that biblio tick 3 item checkboxes to place 3 item level holds and submit the form. 5. Notice the form submits and no warning/error message is displayed 6. In the opac user summary page that is displayed after the reserve form is submitted notice the holds are not displayed this is because they have not been placed 7. Apply this patch 8. Repeat step 4 and 5 and notice the holds have been successfully placed and are displayed in your opac user summary page. Sponsored-By: Brimbank Library Signed-off-by: Lisette Scheer --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 1 + opac/opac-reserve.pl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index 2d49d92..41a0ef6 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -570,6 +570,7 @@ var biblioNum = $(this).val(); if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) { total += parseInt($("input[name='checkitem_'"+biblioNum+"]:checked").length); + total -= 2; } else { total += parseInt($("select[name='holds_to_place_count_"+biblioNum+"']").val()); } diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 5c21712..697e9ae 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -215,7 +215,7 @@ if ( $query->param('place_reserve') ) { my $canreserve = 1; if ( $maxreserves - && $reserve_cnt + $nbRequested >= $maxreserves ) + && $reserve_cnt + $nbRequested > $maxreserves ) { $canreserve = 0; } -- 2.1.4