|
Lines 31-37
use CGI qw ( -utf8 );
Link Here
|
| 31 |
use Text::CSV_XS; |
31 |
use Text::CSV_XS; |
| 32 |
use C4::Auth qw( get_template_and_user ); |
32 |
use C4::Auth qw( get_template_and_user ); |
| 33 |
use C4::Output qw( output_html_with_http_headers ); |
33 |
use C4::Output qw( output_html_with_http_headers ); |
| 34 |
|
34 |
use Text::CSV::Encoded; |
| 35 |
use Koha::AuthorisedValues; |
35 |
use Koha::AuthorisedValues; |
| 36 |
use Koha::CsvProfiles; |
36 |
use Koha::CsvProfiles; |
| 37 |
|
37 |
|
|
Lines 60-66
if ( $op eq 'export' ) {
Link Here
|
| 60 |
my $csv_profile = Koha::CsvProfiles->find( $csv_profile_id ); |
60 |
my $csv_profile = Koha::CsvProfiles->find( $csv_profile_id ); |
| 61 |
die "There is no valid csv profile given" unless $csv_profile; |
61 |
die "There is no valid csv profile given" unless $csv_profile; |
| 62 |
|
62 |
|
| 63 |
my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$csv_profile->csv_separator,'binary'=>1}); |
|
|
| 64 |
my $csv_profile_content = $csv_profile->content; |
63 |
my $csv_profile_content = $csv_profile->content; |
| 65 |
my ( @headers, @fields ); |
64 |
my ( @headers, @fields ); |
| 66 |
while ( $csv_profile_content =~ / |
65 |
while ( $csv_profile_content =~ / |
|
Lines 89-99
if ( $op eq 'export' ) {
Link Here
|
| 89 |
} |
88 |
} |
| 90 |
push @rows, \@row; |
89 |
push @rows, \@row; |
| 91 |
} |
90 |
} |
| 92 |
my $content = join( $csv_profile->csv_separator, @headers ) . "\n"; |
91 |
my $delimiter = $csv_profile->csv_separator; |
|
|
92 |
$delimiter = "\t" if $delimiter eq "\\t"; |
| 93 |
|
| 94 |
my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter}); |
| 95 |
$csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag(); |
| 96 |
$csv->combine(@headers); |
| 97 |
my $content .= Encode::decode('UTF-8', $csv->string()) . "\n"; |
| 93 |
for my $row ( @rows ) { |
98 |
for my $row ( @rows ) { |
| 94 |
$csv->combine(@$row); |
99 |
$csv->combine(@$row); |
| 95 |
my $string = $csv->string; |
100 |
$content .= $csv->string . "\n"; |
| 96 |
$content .= $string . "\n"; |
|
|
| 97 |
} |
101 |
} |
| 98 |
print $query->header( |
102 |
print $query->header( |
| 99 |
-type => 'text/csv', |
103 |
-type => 'text/csv', |
| 100 |
- |
|
|