From 77888ddcf925f6e5d1b33f904a73280324e54862 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Thu, 7 Mar 2024 08:50:54 +0100
Subject: [PATCH] Bug 36251: (bug 35329 follow-up) Fix patron search by first
 letter when placing a hold

Most of the patrons searches open in a modal. Except:
* the main one (members-home)
* when placing a hold
* when requesting an article
(did I miss one?)

The patron-search.inc BLOCKs need a parent block to know where to locate
the elements (form, table, etc), because we can have several patron
searches on the same page.

Bug 35329 reused '#searchresults':
  10 [% SET search_results_block_id = 'searchresults' %]
which is used on the main patron search.
The ones in the modal are correctly handled: we build the parent node in
the "patron_search_modal" block.
But for the 2 others the parent block id is wrong.

On reserve/request.tt we have one already, so we set the TT variable from the
.tt file
On circ/request-article we don't have one already, so we can reuse
searchresults (could be more specific however to include 'patrons'...)

Test plan:
Browse patrons by first letter when placing a hold and requesting an
article

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
---
 koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt | 2 +-
 koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt      | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt
index 98f72ebc77d..292b0a06c1d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/request-article.tt
@@ -104,7 +104,7 @@
                         </div>
                     [% END %]
                     [% UNLESS patron %]
-                        <fieldset class="brief">
+                        <fieldset id="searchresults" class="brief">
                             <label>Search patrons</label>
                             [% PROCESS patron_search_filters_simple %]
                             [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
index c6a8bba7000..5601456f26e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
@@ -1803,6 +1803,7 @@
         table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %];
     </script>
 
+    [% SET search_results_block_id = 'holds_patronsearch_pane_panel' %] [%# adjusting variable for patron-search.inc %]
     [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/reserve/request.pl?' _ url_biblio_params, redirect_if_attribute_equal => 'cardnumber' %]
     <script>
         $(document).ready(function() {
-- 
2.30.2