From 6997048a239747a1185c78b22e356c90d3f832ac Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Wed, 21 Nov 2018 10:55:39 +0000 Subject: [PATCH] Bug 15565: (follow-up) Place multiple holds from opac-search.pl Previously before this patch if you selected multiple bibliographic results from opac-search.pl and selected 'Place hold' and confirmed the hold only 1 hold on the first of the selected biblios would be placed. This patch fixes this bug and enables users to be able to place holds on multiple bibliographic records in opac-search.pl, select 'Place hold', select if they want each of these holds to be on 'Next available', 'Next available from group', or 'A specific item' and place their holds and all the holds they placed will be placed correctly. Test plan: 1. Follow test plan on the last patch - (Don't apply this patch) 2. Try to select multiple bibliographic record checkboxes and select 'Place hold' 3. Confirm holds and notice you are re-directed to opac-user.pl and only the first hold has been placed 4. Apply this patch 5. Restart memcached and plack if running 6. Repeat steps 2 and 3 and notice all holds were placed 7. Repeat step 2 and then select a variety of 'A specific item' and 'Next available item' holds for each of the bibliographic holds and confirm they are all placed correctly 8. Confirm you can still place multiple holds correctly in opac-reserve accessing from a OPAC biblio detail page Sponsored-By: Brimbank Library, Australia --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 6 +++++- opac/opac-reserve.pl | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) 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 a3716c1..dc19454 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -151,6 +151,7 @@
+
[% FOREACH bibitemloo IN bibitemloop %] @@ -616,7 +617,7 @@ total += parseInt($("input[name='checkitem_'"+biblioNum+"]:checked").length); total -= 2; } else { - total += parseInt($("select[name='holds_to_place_count_"+biblioNum+"']").val()); + total += parseInt($("input[name='holds_to_place_count_"+biblioNum+"']").val()); } }); return total; @@ -657,6 +658,7 @@ // When 'Place Hold' button is clicked $(".placehold").click(function(){ + var biblionumbers = ""; if (total_requested() + [% reserves_count | html %] > [% maxreserves | html %]) { alert(MSG_MAX_HOLDS_EXCEEDED); return false; @@ -671,6 +673,7 @@ var badBib = null; $("input[name='biblionumbers']:checked").each(function() { var biblioNum = $(this).val(); + biblionumbers += biblioNum + "/"; // If required hold note is empty, make it visible if( $("#holdnotes_"+biblioNum).attr( 'required' ) && $("#holdnotes_"+biblioNum).val() == '' ) { @@ -695,6 +698,7 @@ if (badBib) { // alert has been raised already return false; } + $("#biblionumbers").val(biblionumbers); return true; }); diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index eb807fa..a08c870 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -111,7 +111,7 @@ my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_l # Coming from opac-search biblionumbers param is a string, coming from # opac-reserve, it's an array. -my @biblionumbers = ref($query->param('biblionumbers')) eq 'Array' +my @biblionumbers = ref($query->multi_param('biblionumbers')) eq 'Array' ? $query->param('biblionumbers') : split(/\//, $query->param('biblionumbers')); @@ -119,6 +119,11 @@ unless (@biblionumbers) { push(@biblionumbers, $query->multi_param('biblionumber')); } +my $multiBibHolds; +if ( scalar( @biblionumbers ) > 1 ){ + $multiBibHolds = 1; +} + # Pass the numbers to the page so they can be fed back # when the hold is confirmed. TODO: Not necessary? $template->param( biblionumbers => @biblionumbers ); @@ -283,8 +288,13 @@ if ( $query->param('place_reserve') ) { ++$reserve_cnt; } } - print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds"); - exit; + + # $multiBibHolds indicates if holds on multiple biblio records has been placed + # If not set then can exit and re-direct out of loop otherwise loop through other biblionumbers in @biblionumbers + if (!$multiBibHolds) { + print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds"); + exit; + } } $canreserve = 0 unless CanBookBeReserved( $borrowernumber, $biblioNum )->{status} eq 'OK'; -- 2.1.4