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 620-625
elsif ($op eq 'export'){
Link Here
|
620 |
my $format = $input->param('format'); |
621 |
my $format = $input->param('format'); |
621 |
my $reportname = $input->param('reportname'); |
622 |
my $reportname = $input->param('reportname'); |
622 |
my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ; |
623 |
my $reportfilename = $reportname ? "$reportname-reportresults.$format" : "reportresults.$format" ; |
|
|
624 |
my $hr = HTML::Restrict->new(); |
623 |
|
625 |
|
624 |
($sql, undef) = $report->prep_report( \@param_names, \@sql_params ); |
626 |
($sql, undef) = $report->prep_report( \@param_names, \@sql_params ); |
625 |
my ( $sth, $q_errors ) = execute_query( { sql => $sql, report_id => $report_id } ); |
627 |
my ( $sth, $q_errors ) = execute_query( { sql => $sql, report_id => $report_id } ); |
Lines 628-636
elsif ($op eq 'export'){
Link Here
|
628 |
if ($format eq 'tab') { |
630 |
if ($format eq 'tab') { |
629 |
$type = 'application/octet-stream'; |
631 |
$type = 'application/octet-stream'; |
630 |
$content .= join("\t", header_cell_values($sth)) . "\n"; |
632 |
$content .= join("\t", header_cell_values($sth)) . "\n"; |
631 |
$content = Encode::decode('UTF-8', $content); |
633 |
$content = $hr->process(Encode::decode('UTF-8', $content)); |
632 |
while (my $row = $sth->fetchrow_arrayref()) { |
634 |
while (my $row = $sth->fetchrow_arrayref()) { |
633 |
$content .= join("\t", map { $_ // '' } @$row) . "\n"; |
635 |
$content .= join("\t", $hr->process(@$row)) . "\n"; |
634 |
} |
636 |
} |
635 |
} else { |
637 |
} else { |
636 |
if ( $format eq 'csv' ) { |
638 |
if ( $format eq 'csv' ) { |
Lines 639-651
elsif ($op eq 'export'){
Link Here
|
639 |
my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter}); |
641 |
my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter}); |
640 |
$csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag(); |
642 |
$csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag(); |
641 |
if ($csv->combine(header_cell_values($sth))) { |
643 |
if ($csv->combine(header_cell_values($sth))) { |
642 |
$content .= Encode::decode('UTF-8', $csv->string()) . "\n"; |
644 |
$content .= $hr->process(Encode::decode('UTF-8', $csv->string())) . "\n"; |
|
|
645 |
|
643 |
} else { |
646 |
} else { |
644 |
push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ; |
647 |
push @$q_errors, { combine => 'HEADER ROW: ' . $csv->error_diag() } ; |
645 |
} |
648 |
} |
646 |
while (my $row = $sth->fetchrow_arrayref()) { |
649 |
while (my $row = $sth->fetchrow_arrayref()) { |
647 |
if ($csv->combine(@$row)) { |
650 |
if ($csv->combine(@$row)) { |
648 |
$content .= $csv->string() . "\n"; |
651 |
$content .= $hr->process($csv->string()) . "\n"; |
|
|
652 |
|
649 |
} else { |
653 |
} else { |
650 |
push @$q_errors, { combine => $csv->error_diag() } ; |
654 |
push @$q_errors, { combine => $csv->error_diag() } ; |
651 |
} |
655 |
} |
Lines 666-672
elsif ($op eq 'export'){
Link Here
|
666 |
foreach my $sql_row ( @$sql_rows ) { |
670 |
foreach my $sql_row ( @$sql_rows ) { |
667 |
my @content_row; |
671 |
my @content_row; |
668 |
foreach my $sql_cell ( @$sql_row ) { |
672 |
foreach my $sql_cell ( @$sql_row ) { |
669 |
push @content_row, Encode::encode( 'UTF8', $sql_cell ); |
673 |
push @content_row, $hr->process(Encode::encode( 'UTF8', $sql_cell )); |
|
|
674 |
|
670 |
} |
675 |
} |
671 |
push @$ods_content, \@content_row; |
676 |
push @$ods_content, \@content_row; |
672 |
} |
677 |
} |
673 |
- |
|
|