From 8f126e4ffe3db83906094182fdaf2a082a0279bb Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Thu, 21 Mar 2019 06:43:13 -0400
Subject: [PATCH] Bug 22556: Add ability to quickly filter funds/budgets by
 library on the Acquisitions home page

Some librarians would like to have a quick pulldown selector to filter budgets and funds by library on the acquisitions home page.

Test Plan:
1) Apply this patch
2) Navigate to the Acquisitions home page
3) Notice the new pulldown on the budgets table labeled "Filter by library"
4) Select a library that has one or more budgets/funds
5) Note only budgets/funds from that library now display!

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Bin Wen <bin.wen@inlibro.com>
---
 .../prog/en/modules/acqui/acqui-home.tt         | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt
index 5195d3d826..f20c54c1aa 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt
@@ -64,7 +64,7 @@
 
 [% IF ( loop_budget ) %]
 
-            <h3>All available funds[% IF LoginBranchname %] for [% LoginBranchname | html %][% END %]</h3>
+    <h3>All available funds[% IF LoginBranchname %] for [% LoginBranchname | html %][% END %]</h3>
 
     <div id="BudgetsAndFunds">
     <table id="accounts">
@@ -72,7 +72,15 @@
           <span class="actions"><a href="#" id="expand_all">Expand all</a>
           | <a href="#" id="collapse_all">Collapse all</a>
           | <a href="#" id="hide_inactive">Hide inactive budgets</a>
-          | <a href="#" id="show_inactive">Show inactive budgets</a></span>
+          | <a href="#" id="show_inactive">Show inactive budgets</a>
+          | <select id="library-filter">
+              <option value="">Filter by library</option>
+              [% FOREACH b IN Branches.all %]
+                <option value="[% b.branchname | html %]">[% b.branchname | html %]</option>
+              [% END %]
+            </select>
+        </span>
+
         </caption>
 
         <thead>
@@ -248,6 +256,11 @@
             });
             $("#hide_inactive").click();
 
+            $("#library-filter").change(function(){
+                $("#accounts").DataTable().search(this.value);
+                $("#accounts").DataTable().draw();
+            });
+
         });
     </script>
 [% END %]
-- 
2.17.1