From d605b4a0919147457f63a2a1d7c38f4d89ccd70d Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Wed, 1 Apr 2020 13:39:13 +0000
Subject: [PATCH] Bug 25033: Move branchfilter to top of page

There is confusion becase it is not obvious when the suggestions page is being limited to a branch

Moving the branch filter to the top of the page makes it easier to see

To test:
1 - Apply patch
2 - From mainpage or acqui-home note the link to suggestions takes you to suggestions limited to current branch
3 - Change the dropdown
4 - Note the page refreshes and loads the correct suggestions

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: David Nind <david@davidnind.com>
---
 .../prog/en/modules/suggestion/suggestion.tt       | 26 ++++++++++++++--------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
index 0882b2c69b..4a5cbb5661 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
@@ -498,6 +498,16 @@
 
 <h1>Suggestions management</h1>
 
+<label for="branchcode">Viewing suggestions for library:</label>
+<select name="branchcode" id="branchcode">
+    <option value="">Any</option>
+    [% IF branchfilter %]
+        [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
+    [% ELSE %]
+        [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
+    [% END %]
+</select>
+
 
 [% FOR m IN messages %]
     <div class="dialog [% m.type | html %]">
@@ -751,6 +761,7 @@
             <aside>
 
 <form name="suggestionfilter" action="suggestion.pl" method="get">
+    <input type="hidden" name="branchcode" value="[% branchfilter | html %]" />
 <fieldset class="brief"><ol style="display:block;"><li><label for="displayby">Organize by: </label>
                 <select name="displayby" id="displayby" style="width:auto;">
                     [% IF ( displayby == "STATUS" ) %]
@@ -897,15 +908,6 @@
                         [% IF ( budgetsloo.selected ) %]<option value="[% budgetsloo.budget_id | html %]" selected="selected">[% budgetsloo.budget_name | html %]</option>[% ELSE %]<option value="[% budgetsloo.budget_id | html %]">[% budgetsloo.budget_name | html %]</option>[% END %]
                         [% END %]
                     </select></li>
-                    <li><label for="branchcode">Library:</label>
-                    <select name="branchcode" id="branchcode">
-                        <option value="__ANY__">Any</option>
-                        [% IF branchfilter %]
-                            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %]
-                        [% ELSE %]
-                            [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode ) %]
-                        [% END %]
-                    </select></li>
                     <li>
                         <input type="submit" value="Go" />
                     </li>
@@ -1012,6 +1014,12 @@
                     [% END %]
                 [% END %]
 
+                $("#branchcode").on('change',function(){
+                    let branchcode = $(this).val();
+                    if( branchcode == '' ){ branchcode = "__ANY__" }
+                    $('input[name="branchcode"]').val( branchcode );
+                    $('form[name="suggestionfilter"]').submit();
+                });
                 $(".checkall").click(function(e){
                     e.preventDefault();
                     $(this).parents('form').checkCheckboxes();
-- 
2.11.0