From 4e441efcad820781eac20355ec121293118273b1 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
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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.

Signed-off-by: Bin Wen <bin.wen@inlibro.com>

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
---
 .../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 42a3060c68..8cc68b5df1 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 c925d739e4..f825331b50 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.11.0