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 |
- |
|
|