From ce6cf101b38448a316c96f65a162facfb3100e03 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Fri, 22 Feb 2019 13:26:01 +0000
Subject: [PATCH] Bug 21308: Results from order search do not show the search
 parameters

This patch modifies the orders search results page so that the search
form appears in the sidebar. This allows the user to view and re-use
their search parameters.

This patch also moves the "no search results" message to the top of the
page in a message box.

To test, apply the patch and go to Acquisitions -> Orders search.

 - Perform a search which will return results. In the sidebar you should
   see the full orders search form with your search parameters in the
   form fields.

 - Perform a search which will return no results. You should see the
   "Your search returned no results." message in a standard message
   dialog.
---
 .../prog/en/includes/filter-orders.inc             |  2 +-
 .../prog/en/modules/acqui/histsearch.tt            | 53 ++++++++++++++--------
 2 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc
index 208b2dc..9ff1be2 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc
@@ -10,7 +10,7 @@
     <li><label for="name">Vendor: </label> <input type="text" name="name" id="name" value="[% filters.name | html %]" /></li>
     <li><label for="basket">Basket: </label> <input type="text" name="basket" id="basket" value="[% filters.basket | html %]" /></li>
     <li><label for="basket_creators">Basket created by: </label>
-        <input autocomplete="off" id="find_patron" type="text" style="width:150px" class="noEnterSubmit" />
+        <input autocomplete="off" id="find_patron" type="text" class="noEnterSubmit" />
         <div>
             <div id="basket_creators" style="float:left;"></div>
         </div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
index c925d73..f825331 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
@@ -18,15 +18,17 @@
     <div class="row">
         <div class="col-sm-10 col-sm-push-2">
             <main>
+                [% IF !order_loop && search_done %]
+                    <div class="dialog message">
+                        Your search returned no results.
+                    </div>
+                [% END %]
+
+                [% UNLESS ( order_loop ) %]
+                    [% PROCESS filter_form context => "main" %]
+                [% END %]
+
 
-[% UNLESS ( order_loop ) %]<form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
-<fieldset class="rows">
-    <legend>Search orders</legend>
-    [% INCLUDE 'filter-orders.inc' %]
-</fieldset>
-    <input type="hidden" name="do_search" value="1" />
-	<fieldset class="action"><input type="submit" value="Search" /></fieldset>
-	</form>[% END %]
     [% IF ( order_loop ) %]<h1>Search results</h1>
 	<div id="acqui_histsearch">
         <table id="histsearcht">
@@ -101,8 +103,6 @@
             </tbody>
         </table>
     </div>
-    [% ELSIF search_done %]
-      There is no order for this search.
     [% END %]
 
 </main>
@@ -110,6 +110,9 @@
 
 <div class="col-sm-2 col-sm-pull-10">
     <aside>
+        [% IF ( order_loop ) %]
+            [% PROCESS filter_form context => "sidebar" %]
+        [% END %]
         [% INCLUDE 'acquisitions-menu.inc' %]
     </aside>
 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
@@ -133,16 +136,30 @@
                 "sPaginationType": "four_button"
             }, columns_settings );
 
-            [% UNLESS order_loop %]
-                patron_autocomplete({
-                    patron_container: $("#basket_creators"),
-                    input_autocomplete: $("#find_patron"),
-                    patron_input_name: 'created_by',
-                    field_to_retrieve: 'borrowernumber'
-                });
-            [% END %]
+            patron_autocomplete({
+                patron_container: $("#basket_creators"),
+                input_autocomplete: $("#find_patron"),
+                patron_input_name: 'created_by',
+                field_to_retrieve: 'borrowernumber'
+            });
         });
     </script>
 [% END %]
 
+[% BLOCK filter_form %]
+    <form action="/cgi-bin/koha/acqui/histsearch.pl" method="post">
+        [% IF ( context == "sidebar" ) %]
+            <fieldset class="brief">
+                <h4>Search orders</h4>
+        [% ELSE %]
+            <fieldset class="rows">
+                <legend>Search orders</legend>
+        [% END %]
+            [% INCLUDE 'filter-orders.inc' %]
+        </fieldset>
+        <input type="hidden" name="do_search" value="1" />
+        <fieldset class="action"><input type="submit" value="Search" /></fieldset>
+    </form>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
-- 
2.1.4