From cef2c5898ea05438f1c47ee7489e6963aeeef5b9 Mon Sep 17 00:00:00 2001
From: Alex Arnaud <alex.arnaud@biblibre.com>
Date: Thu, 15 Sep 2016 14:27:24 +0000
Subject: [PATCH] Bug 17282 - Ability to exclude the last line in report
 results

This patch add a checkbox (exclude last line). This is useful
when this last is the result of a sql rollup which is the sum
of each column and make the chart not consistent
---
 koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc                    | 3 +++
 .../intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt     | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc
index ebb86ad..0ec5a32 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc
@@ -27,6 +27,9 @@
                 </select>
             </div>
 
+            <label for="exclude-last">Exclude last line (Rollup)</label>
+            <input id="exclude-last" name="chart-exclude-last" type="checkbox">
+
             [% column = 1 %]
             <div>
                 [% FOREACH header IN header_row %]
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 d783417..57ec665 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
@@ -878,6 +878,10 @@ canned reports and writing custom SQL reports.</p>
             headers = [% header_row.json %];
             var results = [% results.json %]
 
+            if ($('input[name="chart-exclude-last"]').prop('checked')) {
+                results.splice(-1, 1);
+            }
+
             $('select[name="y"]').each(function( index ) {
                 y_elements.push( $(this).val() );
             });
-- 
2.7.4