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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc (+3 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
                    [% FOREACH pluginexport IN pluginexports %]
101
                    <li><a id="[% pluginexport.shortname | html %]" href="/cgi-bin/koha/reports/guided_reports.pl?reports=1&phase=Export&amp;format=[% pluginexport.shortname | uri %]&amp;plugin=[% pluginexport.pluginclass | uri %]&amp;report_id=[% id | html %]&amp;reportname=[% name |uri %][% PROCESS params %]">[% pluginexport.name | html %] (.[% pluginexport.shortname | html %])</a></li>
102
                    [% END %]
100
                    [% IF (results.json) %]
103
                    [% IF (results.json) %]
101
                        <li><a id="download-chart" href="#">Chart (.svg)</a></li>
104
                        <li><a id="download-chart" href="#">Chart (.svg)</a></li>
102
                    [% END %]
105
                    [% END %]
(-)a/reports/guided_reports.pl (-2 / +39 lines)
Lines 91-96 elsif ($session and not $input->param('clear_filters')) { Link Here
91
    $filter = $session->param('report_filter');
91
    $filter = $session->param('report_filter');
92
}
92
}
93
93
94
if (($phase eq 'Run this report' || $phase eq 'Export') &&
95
    C4::Context->preference('UseKohaPlugins') && C4::Context->config('enable_plugins')) {
96
    my @plugins = Koha::Plugins->new()->GetPlugins({ method => 'sql_report_get_export_formats' });
97
    my @exportformats;
98
    foreach my $plugin (@plugins) {
99
        my @formats = @{ $plugin->sql_report_get_export_formats() };
100
        foreach my $format (@formats) {
101
            $format->{'pluginclass'} = $plugin->{'class'};
102
            push(@exportformats, $format);
103
        }
104
    }
105
    $template->param( 'pluginexports' => \@exportformats );
106
}
107
94
my $op = $input->param('op') || q||;
108
my $op = $input->param('op') || q||;
95
109
96
my @errors = ();
110
my @errors = ();
Lines 891-902 elsif ($phase eq 'Export'){ Link Here
891
    my $format         = $input->param('format');
905
    my $format         = $input->param('format');
892
    my $reportname     = $input->param('reportname');
906
    my $reportname     = $input->param('reportname');
893
    my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ;
907
    my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ;
908
    my $pluginclass    = $input->param('plugin') || '';
894
909
895
    ($sql, undef) = get_prepped_report( $sql, \@param_names, \@sql_params );
910
    ($sql, undef) = get_prepped_report( $sql, \@param_names, \@sql_params );
896
	my ($sth, $q_errors) = execute_query($sql);
911
	my ($sth, $q_errors) = execute_query($sql);
897
    unless ($q_errors and @$q_errors) {
912
    unless ($q_errors and @$q_errors) {
898
        my ( $type, $content );
913
        my ( $type, $content );
899
        if ($format eq 'tab') {
914
        if ($pluginclass =~ /Koha::Plugin::/ && C4::Context->preference('UseKohaPlugins') && C4::Context->config('enable_plugins')) {
915
            my $pluginexported = 0;
916
            my @plugins = Koha::Plugins->new()->GetPlugins({ method => 'sql_report_get_export_formats', class => $pluginclass });
917
            foreach my $plugin (@plugins) {
918
                my @exportformats = @{ $plugin->sql_report_get_export_formats() };
919
                foreach my $exportformat (@exportformats) {
920
                    next if ($exportformat->{'shortname'} ne $format);
921
                    my @headers = header_cell_values($sth);
922
                    my $sql_rows = $sth->fetchall_arrayref();
923
                    my ($plugcontent, $error) = $plugin->sql_report_process_data($format, \@headers, $sql_rows);
924
                    if ($error) {
925
                        push(@$q_errors, { pluginerr => $error });
926
                    } else {
927
                        $type = $exportformat->{'type'};
928
                        $content = $plugcontent;
929
                        $pluginexported = 1;
930
                    }
931
                }
932
            }
933
            if (!$pluginexported) {
934
                # Should not happen unless you edit url params manually, or plugin is buggy
935
                push(@$q_errors, { pluginerr => 'Unknown plugin or plugin output format' });
936
            }
937
        } elsif ($format eq 'tab') {
900
            $type = 'application/octet-stream';
938
            $type = 'application/octet-stream';
901
            $content .= join("\t", header_cell_values($sth)) . "\n";
939
            $content .= join("\t", header_cell_values($sth)) . "\n";
902
            $content = Encode::decode('UTF-8', $content);
940
            $content = Encode::decode('UTF-8', $content);
903
- 

Return to bug 24724