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 <mtompset@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
<input type="hidden" name="sql" value="[% sql |html %]" />
<input type="hidden" name="phase" value="Export" />
<input type="submit" name="submit" value="Download" /></fieldset>
+<input type="hidden" name="reportname" value="[% name %]" />
</form>
[% END %]
[% END %]
# 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 );
}
print $input->header(
-type => $type,
- -attachment=>"reportresults.$format"
+ -attachment=> $reportfilename
);
print $content;