Bugzilla – Attachment 115696 Details for
Bug 27510
Download the report in HTML format
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27510: Download the report in HTML format
Bug-27510-Download-the-report-in-HTML-format.patch (text/plain), 4.77 KB, created by
Ivan Dziuba
on 2021-01-22 13:40:43 UTC
(
hide
)
Description:
Bug 27510: Download the report in HTML format
Filename:
MIME Type:
Creator:
Ivan Dziuba
Created:
2021-01-22 13:40:43 UTC
Size:
4.77 KB
patch
obsolete
>From aebd6a0016d2bc1b5ca6e02ced49996db0ad0885 Mon Sep 17 00:00:00 2001 >From: Ivan Dziuba <ivan.dziuba@inlibro.com> >Date: Thu, 21 Jan 2021 20:23:27 -0500 >Subject: [PATCH] Bug 27510: Download the report in HTML format > >--- > ...bug_27510_download_report_html_format.perl | 8 +++++ > installer/data/mysql/mandatory/sysprefs.sql | 3 +- > .../admin/preferences/staff_interface.pref | 6 ++++ > reports/guided_reports.pl | 36 +++++++++++++++++++ > 4 files changed, 52 insertions(+), 1 deletion(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_27510_download_report_html_format.perl > >diff --git a/installer/data/mysql/atomicupdate/bug_27510_download_report_html_format.perl b/installer/data/mysql/atomicupdate/bug_27510_download_report_html_format.perl >new file mode 100644 >index 0000000000..643eebe12f >--- /dev/null >+++ b/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"); >+} >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index 7f0afaa594..e9b9a12467 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/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') > ; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref >index 249a783e4f..a5d7f09a79 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref >+++ b/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 >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index aab868ed19..d047c07837 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -39,6 +39,7 @@ use Koha::Libraries; > use Koha::Patron::Categories; > use Koha::SharedContent; > use Koha::Util::OpenDocument; >+use HTML::Table; > > =head1 NAME > >@@ -952,6 +953,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 +1128,34 @@ sub get_prepped_report { > } > return $sql,$headers; > } >+ >+sub _to_html { >+ my ($sth, $input) = @_; >+ my $header_type = "application/x-download"; >+ my $file = $input->param('reportname') . ".html"; >+ my @head = header_cell_values($sth); >+ my $con = join(" ", @head); >+ my $cols = scalar @head; >+ my $h1 = "<h1>" . $input->param('reportname') . "</h1>"; >+ my $css = C4::Context->preference('ReportUserCSS'); >+ if ($css eq ''){ >+ $css = >+ "table, th, td { >+ border: 1px solid black; >+ } >+ table { >+ border-collapse: collapse; >+ }"; >+ } >+ my $content = "<style>" . $css . "</style>"; >+ my $table = HTML::Table->new( >+ -cols => $cols, >+ ); >+ $table->addSectionRow('thead', 0, @head); >+ $table->setSectionRCellsHead('thead', 0, 1); >+ while (my $row = $sth->fetchrow_arrayref()) { >+ $table->addSectionRow( 'tbody', 0, @$row ); >+ } >+ $content .= $h1 . $table; >+ return $content; >+} >-- >2.17.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27510
:
115696
|
115702
|
116079
|
116091
|
116849
|
116850
|
146135
|
146142