Lines 40-45
use Koha::Util::OpenDocument qw( generate_ods );
Link Here
|
40 |
use Koha::Notice::Templates; |
40 |
use Koha::Notice::Templates; |
41 |
use Koha::TemplateUtils qw( process_tt ); |
41 |
use Koha::TemplateUtils qw( process_tt ); |
42 |
use C4::ClassSource qw( GetClassSources ); |
42 |
use C4::ClassSource qw( GetClassSources ); |
|
|
43 |
use HTML::Restrict; |
43 |
|
44 |
|
44 |
=head1 NAME |
45 |
=head1 NAME |
45 |
|
46 |
|
Lines 929-934
elsif ($phase eq 'Export'){
Link Here
|
929 |
my $format = $input->param('format'); |
930 |
my $format = $input->param('format'); |
930 |
my $reportname = $input->param('reportname'); |
931 |
my $reportname = $input->param('reportname'); |
931 |
my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ; |
932 |
my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ; |
|
|
933 |
my $hr = HTML::Restrict->new(); |
932 |
|
934 |
|
933 |
($sql, undef) = $report->prep_report( \@param_names, \@sql_params ); |
935 |
($sql, undef) = $report->prep_report( \@param_names, \@sql_params ); |
934 |
my ( $sth, $q_errors ) = execute_query( { sql => $sql, report_id => $report_id } ); |
936 |
my ( $sth, $q_errors ) = execute_query( { sql => $sql, report_id => $report_id } ); |
Lines 937-945
elsif ($phase eq 'Export'){
Link Here
|
937 |
if ($format eq 'tab') { |
939 |
if ($format eq 'tab') { |
938 |
$type = 'application/octet-stream'; |
940 |
$type = 'application/octet-stream'; |
939 |
$content .= join("\t", header_cell_values($sth)) . "\n"; |
941 |
$content .= join("\t", header_cell_values($sth)) . "\n"; |
940 |
$content = Encode::decode('UTF-8', $content); |
942 |
$content = $hr->process(Encode::decode('UTF-8', $content)); |
941 |
while (my $row = $sth->fetchrow_arrayref()) { |
943 |
while (my $row = $sth->fetchrow_arrayref()) { |
942 |
$content .= join("\t", map { $_ // '' } @$row) . "\n"; |
944 |
$content .= join("\t", $hr->process(@$row)) . "\n"; |
943 |
} |
945 |
} |
944 |
} else { |
946 |
} else { |
945 |
if ( $format eq 'csv' ) { |
947 |
if ( $format eq 'csv' ) { |
Lines 948-960
elsif ($phase eq 'Export'){
Link Here
|
948 |
my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter}); |
950 |
my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter}); |
949 |
$csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag(); |
951 |
$csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag(); |
950 |
if ($csv->combine(header_cell_values($sth))) { |
952 |
if ($csv->combine(header_cell_values($sth))) { |
951 |
$content .= Encode::decode('UTF-8', $csv->string()) . "\n"; |
953 |
$content .= $hr->process(Encode::decode('UTF-8', $csv->string())) . "\n"; |
|
|
954 |
|
952 |
} else { |
955 |
} else { |
953 |
push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ; |
956 |
push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ; |
954 |
} |
957 |
} |
955 |
while (my $row = $sth->fetchrow_arrayref()) { |
958 |
while (my $row = $sth->fetchrow_arrayref()) { |
956 |
if ($csv->combine(@$row)) { |
959 |
if ($csv->combine(@$row)) { |
957 |
$content .= $csv->string() . "\n"; |
960 |
$content .= $hr->process($csv->string()) . "\n"; |
|
|
961 |
|
958 |
} else { |
962 |
} else { |
959 |
push @$q_errors, { combine => $csv->error_diag() } ; |
963 |
push @$q_errors, { combine => $csv->error_diag() } ; |
960 |
} |
964 |
} |
Lines 975-981
elsif ($phase eq 'Export'){
Link Here
|
975 |
foreach my $sql_row ( @$sql_rows ) { |
979 |
foreach my $sql_row ( @$sql_rows ) { |
976 |
my @content_row; |
980 |
my @content_row; |
977 |
foreach my $sql_cell ( @$sql_row ) { |
981 |
foreach my $sql_cell ( @$sql_row ) { |
978 |
push @content_row, Encode::encode( 'UTF8', $sql_cell ); |
982 |
push @content_row, $hr->process(Encode::encode( 'UTF8', $sql_cell )); |
|
|
983 |
|
979 |
} |
984 |
} |
980 |
push @$ods_content, \@content_row; |
985 |
push @$ods_content, \@content_row; |
981 |
} |
986 |
} |
982 |
- |
|
|