From 9cb1fe10d7ec9aa37f0f9fa691bf55cbed08959a Mon Sep 17 00:00:00 2001
From: =?utf8?q?Marc=20V=C3=A9ron?=
Date: Sun, 19 Apr 2015 18:40:09 +0200
Subject: [PATCH] Bug 14013 - Use name of a saved report as part of the file
name for download
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
This patch propoeses the name of a saved report as part of the download file name.
To test:
- Apply patch
- Got to Home > Reports > Guided reports wizard > Saved reports (or create a new report from sql)
- Run a saved report
- Download the report (as csv, tab, ods)
Result: The downlaod file name proposed should be prepended by the report name, separated with a -
- Bonus test: Try to downlaod saved reports which have special character in their name.
NOTE: Used "ñ/â is N/A" as a report name. The /'s were translated
to underscored, but the letters were as expected.
Signed-off-by: Mark Tompsett
Signed-off-by: Jonathan Druart
Signed-off-by: Tomas Cohen Arazi
---
.../prog/en/modules/reports/guided_reports_start.tt | 1 +
reports/guided_reports.pl | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
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 d2420a022d..d77824d883 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
@@ -841,6 +841,7 @@ canned reports and writing custom SQL reports.
+
[% END %]
[% END %]
diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl
index d90adfbeb3..366a12de1d 100755
--- a/reports/guided_reports.pl
+++ b/reports/guided_reports.pl
@@ -797,6 +797,8 @@ elsif ($phase eq 'Export'){
# export results to tab separated text or CSV
my $sql = $input->param('sql'); # FIXME: use sql from saved report ID#, not new user-supplied SQL!
my $format = $input->param('format');
+ my $reportname = $input->param('reportname');
+ my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ;
my ($sth, $q_errors) = execute_query($sql);
unless ($q_errors and @$q_errors) {
my ( $type, $content );
@@ -870,7 +872,7 @@ elsif ($phase eq 'Export'){
}
print $input->header(
-type => $type,
- -attachment=>"reportresults.$format"
+ -attachment=> $reportfilename
);
print $content;
--
2.39.2