@@ -, +, @@
---
...bug_27510_download_report_html_format.perl | 8 +++
installer/data/mysql/mandatory/sysprefs.sql | 3 +-
.../prog/en/includes/reports-toolbar.inc | 1 +
.../admin/preferences/staff_interface.pref | 6 ++
reports/guided_reports.pl | 58 +++++++++++++++++++
5 files changed, 75 insertions(+), 1 deletion(-)
create mode 100644 installer/data/mysql/atomicupdate/bug_27510_download_report_html_format.perl
--- a/installer/data/mysql/atomicupdate/bug_27510_download_report_html_format.perl
+++ a/installer/data/mysql/atomicupdate/bug_27510_download_report_html_format.perl
@@ -0,0 +1,8 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+ # you can use $dbh here like:
+ $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReportUserCSS','',NULL,'','free')});
+
+ # Always end with this (adjust the bug info)
+ NewVersion( $DBversion, 27510, "Download the report in HTML format");
+}
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ a/installer/data/mysql/mandatory/sysprefs.sql
@@ -722,5 +722,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on intranet','Free'),
('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'),
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
-('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo')
+('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
+('ReportUserCSS','',NULL,'Add CSS to be included on the report in HTML format.','free')
;
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc
@@ -97,6 +97,7 @@
[% PROCESS 'delimiter_text.inc' %]
Tab separated text
Open Document Spreadsheet
+ Document HTML
[% IF (results.json) %]
Chart (.svg)
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref
@@ -181,3 +181,9 @@ Staff interface:
yes: Show
no: "Don't show"
- a search field pulldown for 'Search the catalog' boxes.
+ -
+ - "Include the following CSS on the report in HTML format:"
+ - pref: ReportUserCSS
+ type: textarea
+ syntax: css
+ class: code
--- a/reports/guided_reports.pl
+++ a/reports/guided_reports.pl
@@ -39,6 +39,8 @@ use Koha::Libraries;
use Koha::Patron::Categories;
use Koha::SharedContent;
use Koha::Util::OpenDocument;
+use HTML::Table;
+use utf8;
=head1 NAME
@@ -952,6 +954,10 @@ elsif ($phase eq 'Export'){
$content .= $_ while <$ods_fh>;
unlink $ods_filepath;
}
+ elsif ( $format eq 'html' ) {
+ $type = 'text/html';
+ $content = _to_html($sth, $input);
+ }
}
print $input->header(
-type => $type,
@@ -1123,3 +1129,55 @@ sub get_prepped_report {
}
return $sql,$headers;
}
+
+sub _to_html {
+ my ($sth, $input) = @_;
+ my $header_type = "application/x-download";
+ my $rep_name = $input->param('reportname');
+ my $file = $rep_name . ".html";
+ my $html_start =
+ "
+
+
+
+
+ $rep_name - Koha";
+ my $html_end =
+ "\n
+ \n";
+ my $h1 = "\n" . $input->param('reportname') . "
";
+ my @head = header_cell_values($sth);
+ my $con = join(" ", @head);
+ my $cols = scalar @head;
+
+ my $css = C4::Context->preference('ReportUserCSS');
+ if ($css eq ''){
+ $css =
+ "\ntable, th, td {
+ border: 1px solid black;
+ }
+ table {
+ border-collapse: collapse;
+ }";
+ }
+ my $content = $html_start;
+ $content .=
+ "\n" .
+ "\n
+ \n";
+ my $table = HTML::Table->new(
+ -cols => $cols,
+ );
+ $table->addSectionRow('thead', 0, @head);
+ $table->setSectionRCellsHead('thead', 0, 1);
+ while (my $row = $sth->fetchrow_arrayref()) {
+ my $tmp_str = join ('*replace*', @$row);
+ $tmp_str = Encode::encode_utf8($tmp_str);
+ my @tmp_arr = split (/\*replace\*/, $tmp_str);
+ $table->addSectionRow( 'tbody', 0, @tmp_arr);
+ }
+ $content .= $h1 . $table . $html_end;
+ return $content;
+}
--