From 421ada41914f7a0e839b5aded270c3837da65cf8 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Fri, 1 Sep 2017 00:54:44 +0000
Subject: [PATCH] Bug 19233 - Add ability to send itemnumbers in report results
 to batch modification

To test:
1 - Apply patch
2 - Run a report with an itemnumber column
3 - Note there is a linked '^' after column title
4 - Hover over the '^'
5 - You should see a tooltip 'Send visible items to batch modification'
6 - Click the '^'
7 - You should be sent to batch item modification with itemnumbers that
were visible in report

Signed-off-by: George <george@nekls.org>
Signed-off-by: BWS Sandboxes <ByWaterSandboxes@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
---
 .../en/modules/reports/guided_reports_start.tt     | 28 ++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
index dcf8f5a..2e5fb62 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
@@ -695,14 +695,29 @@ canned reports and writing custom SQL reports.</p>
 
 <div class="pages">[% pagination_bar %]</div>
 [% UNLESS ( errors ) %]
+<form method="POST" id="report_results">
+<input type="hidden" name="op" value="show">
 <table>
-<tr>[% FOREACH header_ro IN header_row %]<th>[% header_ro.cell %]</th>[% END %]</tr>
+<tr>[% FOREACH header_ro IN header_row %]
+        [% IF header_ro.cell == 'itemnumber' %]
+            <th>[% header_ro.cell %] <a href="" data-toggle="tooltip" title="Send visible items to batch modification" class="send_to_item_mod">^</a></th>
+        [% ELSE %]
+            <th>[% header_ro.cell %]</th>
+        [% END %]
+    [% END %]</tr>
 [% FOREACH result IN results %]
 <tr>
-    [% FOREACH cell IN result.cells %]<td>[% cell.cell %]</td>[% END %]
+    [% FOREACH cells IN result.cells %]
+        [% place = loop.index %]
+        [% IF header_row.$place.cell == 'itemnumber' %]
+            <input type="hidden" name="[% header_row.$place.cell | html %]" value="[% cells.cell | html %]">
+        [% END %]
+        <td>[% cells.cell %]</td>
+    [% END %]
 </tr>
 [% END %]
 </table>
+</form>
 [% END %]
 [% END %]
 
@@ -949,6 +964,9 @@ Sub report:<select name="subreport">
         }
 
         $(document).ready(function(){
+
+            $('[data-toggle="tooltip"]').tooltip();
+
             $('#limit').change(function() {
                 $('#limitselect').submit();
             });
@@ -966,6 +984,12 @@ Sub report:<select name="subreport">
                 delColumn();
             });
 
+            $(".send_to_item_mod").click(function(e){
+                e.preventDefault();
+                $("#report_results").attr("action","/cgi-bin/koha/tools/batchMod.pl");
+                $("#report_results").submit();
+            });
+
             [% IF (saved1) %]
                 var rtable = $("#table_reports").dataTable($.extend(true, {}, dataTablesDefaults, {
                     'iDisplayLength': [% Koha.Preference('NumSavedReports') %],
-- 
2.1.4