View | Details | Raw Unified | Return to bug 27510
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_27510_download_report_html_format.perl (+8 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    # you can use $dbh here like:
4
    $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReportUserCSS','',NULL,'','free')});
5
6
    # Always end with this (adjust the bug info)
7
    NewVersion( $DBversion, 27510, "Download the report in HTML format");
8
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-1 / +2 lines)
Lines 722-726 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
722
('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on intranet','Free'),
722
('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages display on intranet','Free'),
723
('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'),
723
('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'),
724
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
724
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
725
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo')
725
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
726
('ReportUserCSS','',NULL,'Add CSS to be included on the report in HTML format.','free')
726
;
727
;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc (+1 lines)
Lines 97-102 Link Here
97
                    <li><a id="csv" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=csv&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">[% PROCESS 'delimiter_text.inc' %]</a></li>
97
                    <li><a id="csv" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=csv&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">[% PROCESS 'delimiter_text.inc' %]</a></li>
98
                    <li><a id="tab" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=tab&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">Tab separated text</a></li>
98
                    <li><a id="tab" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=tab&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">Tab separated text</a></li>
99
                    <li><a id="ods" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=ods&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">Open Document Spreadsheet</a></li>
99
                    <li><a id="ods" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=ods&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">Open Document Spreadsheet</a></li>
100
                    <li><a id="html" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=html&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %]">Document HTML</a></li>
100
                    [% IF (results.json) %]
101
                    [% IF (results.json) %]
101
                        <li><a id="download-chart" href="#">Chart (.svg)</a></li>
102
                        <li><a id="download-chart" href="#">Chart (.svg)</a></li>
102
                    [% END %]
103
                    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_interface.pref (+6 lines)
Lines 181-183 Staff interface: Link Here
181
                  yes: Show
181
                  yes: Show
182
                  no: "Don't show"
182
                  no: "Don't show"
183
            - a search field pulldown for 'Search the catalog' boxes.
183
            - a search field pulldown for 'Search the catalog' boxes.
184
        -
185
            - "Include the following CSS on the report in HTML format:"
186
            - pref: ReportUserCSS
187
              type: textarea
188
              syntax: css
189
              class: code
(-)a/reports/guided_reports.pl (-1 / +58 lines)
Lines 39-44 use Koha::Libraries; Link Here
39
use Koha::Patron::Categories;
39
use Koha::Patron::Categories;
40
use Koha::SharedContent;
40
use Koha::SharedContent;
41
use Koha::Util::OpenDocument;
41
use Koha::Util::OpenDocument;
42
use HTML::Table;
43
use utf8; 
42
44
43
=head1 NAME
45
=head1 NAME
44
46
Lines 952-957 elsif ($phase eq 'Export'){ Link Here
952
                $content .= $_ while <$ods_fh>;
954
                $content .= $_ while <$ods_fh>;
953
                unlink $ods_filepath;
955
                unlink $ods_filepath;
954
            }
956
            }
957
            elsif ( $format eq 'html' ) {
958
                $type = 'text/html';
959
                $content = _to_html($sth, $input);
960
            }
955
        }
961
        }
956
        print $input->header(
962
        print $input->header(
957
            -type => $type,
963
            -type => $type,
Lines 1123-1125 sub get_prepped_report { Link Here
1123
    }
1129
    }
1124
    return $sql,$headers;
1130
    return $sql,$headers;
1125
}
1131
}
1126
- 
1132
1133
sub _to_html {
1134
    my ($sth, $input) = @_;
1135
    my $header_type = "application/x-download";
1136
    my $rep_name = $input->param('reportname');
1137
    my $file = $rep_name . ".html";
1138
    my $html_start = 
1139
        "<!DOCTYPE html>
1140
        <html>
1141
        <head>
1142
        <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
1143
        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
1144
        <title>$rep_name - Koha</title>";
1145
    my $html_end =  
1146
        "\n</body>
1147
        \n</html>";
1148
    my $h1 = "\n<h1>" . $input->param('reportname') . "</h1>";
1149
    my @head = header_cell_values($sth);
1150
    my $con = join(" ", @head);
1151
    my $cols = scalar @head;
1152
    
1153
    my $css = C4::Context->preference('ReportUserCSS');
1154
    if ($css eq ''){
1155
        $css =
1156
            "\ntable, th, td {
1157
                border: 1px solid black;
1158
            }
1159
            table {
1160
                border-collapse: collapse;
1161
            }";
1162
    }
1163
    my $content = $html_start;
1164
    $content .= 
1165
        "\n<style>"  . 
1166
            $css     . 
1167
        "\n</style>" .
1168
        "\n</head>
1169
         \n<body>";
1170
    my $table = HTML::Table->new(
1171
        -cols => $cols,
1172
    );
1173
    $table->addSectionRow('thead', 0, @head);
1174
    $table->setSectionRCellsHead('thead', 0, 1);
1175
    while (my $row = $sth->fetchrow_arrayref()) {
1176
        my $tmp_str = join ('*replace*', @$row);
1177
        $tmp_str = Encode::encode_utf8($tmp_str);
1178
        my @tmp_arr = split (/\*replace\*/, $tmp_str);
1179
        $table->addSectionRow( 'tbody', 0, @tmp_arr);
1180
    }
1181
    $content .= $h1 . $table . $html_end;
1182
    return $content;
1183
}

Return to bug 27510