From 53e099d7a00ee52cc29803c09cfaf2d26c524b0f Mon Sep 17 00:00:00 2001
From: David Cook <dcook@prosentient.com.au>
Date: Tue, 13 Feb 2024 00:26:42 +0000
Subject: [PATCH] Bug 15565: Place multiple holds on one or more records in
 OPAC

Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 .../bootstrap/en/modules/opac-reserve.tt      | 26 +++++++++++++------
 1 file changed, 18 insertions(+), 8 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 34d1f4ff5b8..a307e965891 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt
@@ -397,7 +397,7 @@
                                                                 <tr class="holdable">
                                                             [% END %]
                                                                     <td class="copynumber" data-order="[% itemLoo.copynumber | html %]">
-                                                                        <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" />
+                                                                        <input type="checkbox" class="checkitem checkitem_[% bibitemloo.biblionumber | html %]" name="checkitem_[% bibitemloo.biblionumber | html %]" value="[% itemLoo.itemnumber | html %]" />
                                                         [% ELSE %]
                                                             [% SET unholdable_items = 1 %]
                                                             [% IF ( itemLoo.checkout ) %]
@@ -656,7 +656,9 @@
             $(".confirmjs:checked").each(function() {
                 var biblioNum = $(this).val();
                 biblionumbers += biblioNum + "/";
-                selections += biblioNum + "/";
+                let select_bib = biblioNum;
+                let select_pickup;
+                let select_items = [];
 
                 // If required hold note is empty, make it visible
                 if( $("#holdnotes_"+biblioNum).attr( 'required' ) && $("#holdnotes_"+biblioNum).val() == '' ) {
@@ -682,23 +684,31 @@
                 // If the 'specific copy' radio button is checked
                 if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
                     // Find the selected copy
-                    var item = $(".checkitem_" + biblioNum + ":checked");
-                    if ($(item).size() == 0) {
+                    var items = $(".checkitem_" + biblioNum + ":checked");
+                    if ($(items).size() == 0) {
                         alert( _("Expecting a specific item selection.") );
                         badBib = biblioNum;
                         return false;
                     } else {
-                      selections += $(item).val();
+                        items.each( function(index,el){
+                            select_items.push( $(el).val() );
+                        });
                     }
                 }
-                selections += "/";
 
                 // Add the pickup location
                 var branchSel = $("#branch_" + biblioNum);
                 if (branchSel.size() > 0) {
-                    selections += $(branchSel).val();
+                    select_pickup = $(branchSel).val();
+                }
+                if ( select_items.length > 0 ){
+                    select_items.forEach( function(item_value,index){
+                        selections += select_bib + "/" + item_value + "/" + select_pickup + "/";
+                    });
+                }
+                else {
+                    selections += select_bib + "/" + "/" + select_pickup + "/";
                 }
-                selections += "/";
                 return true;
             });
 
-- 
2.39.2