Lines 48-53
my $output_format = $query->param("format") || $query->param("output_format") ||
Link Here
|
48 |
# Checks if the script is called from commandline |
48 |
# Checks if the script is called from commandline |
49 |
my $commandline = not defined $ENV{GATEWAY_INTERFACE}; |
49 |
my $commandline = not defined $ENV{GATEWAY_INTERFACE}; |
50 |
|
50 |
|
|
|
51 |
|
52 |
# @biblionumbers is only use for csv export from circulation.pl |
53 |
my @biblionumbers = uniq $query->param("biblionumbers"); |
54 |
|
51 |
if ( $commandline ) { |
55 |
if ( $commandline ) { |
52 |
|
56 |
|
53 |
# Getting parameters |
57 |
# Getting parameters |
Lines 145-154
if ( C4::Context->preference("IndependentBranches")
Link Here
|
145 |
my $backupdir = C4::Context->config('backupdir'); |
149 |
my $backupdir = C4::Context->config('backupdir'); |
146 |
|
150 |
|
147 |
if ( $op eq "export" ) { |
151 |
if ( $op eq "export" ) { |
148 |
if ( $output_format eq "iso2709" or $output_format eq "xml" ) { |
152 |
if ( |
|
|
153 |
$output_format eq "iso2709" |
154 |
or $output_format eq "xml" |
155 |
or ( |
156 |
$output_format eq 'csv' |
157 |
and not @biblionumbers |
158 |
) |
159 |
) { |
149 |
my $charset = 'utf-8'; |
160 |
my $charset = 'utf-8'; |
150 |
my $mimetype = 'application/octet-stream'; |
161 |
my $mimetype = 'application/octet-stream'; |
151 |
binmode STDOUT, ':encoding(UTF-8)'; |
162 |
|
|
|
163 |
binmode STDOUT, ':encoding(UTF-8)' |
164 |
if $filename =~ m/\.gz$/ |
165 |
or $filename =~ m/\.bz2$/; |
166 |
|
152 |
if ( $filename =~ m/\.gz$/ ) { |
167 |
if ( $filename =~ m/\.gz$/ ) { |
153 |
$mimetype = 'application/x-gzip'; |
168 |
$mimetype = 'application/x-gzip'; |
154 |
$charset = ''; |
169 |
$charset = ''; |
Lines 162-168
if ( $op eq "export" ) {
Link Here
|
162 |
print $query->header( |
177 |
print $query->header( |
163 |
-type => $mimetype, |
178 |
-type => $mimetype, |
164 |
-charset => $charset, |
179 |
-charset => $charset, |
165 |
-attachment => $filename |
180 |
-attachment => $filename, |
166 |
) unless ($commandline); |
181 |
) unless ($commandline); |
167 |
|
182 |
|
168 |
$record_type = $query->param("record_type") unless ($commandline); |
183 |
$record_type = $query->param("record_type") unless ($commandline); |
Lines 416-422
if ( $op eq "export" ) {
Link Here
|
416 |
print MARC::File::XML::record($record); |
431 |
print MARC::File::XML::record($record); |
417 |
print "\n"; |
432 |
print "\n"; |
418 |
} |
433 |
} |
419 |
else { |
434 |
elsif ( $output_format eq 'iso2709' ) { |
420 |
my $errorcount_on_decode = eval { scalar(MARC::File::USMARC->decode( $record->as_usmarc )->warnings()) }; |
435 |
my $errorcount_on_decode = eval { scalar(MARC::File::USMARC->decode( $record->as_usmarc )->warnings()) }; |
421 |
if ($errorcount_on_decode or $@){ |
436 |
if ($errorcount_on_decode or $@){ |
422 |
warn $@ if $@; |
437 |
warn $@ if $@; |
Lines 431-445
if ( $op eq "export" ) {
Link Here
|
431 |
print MARC::File::XML::footer(); |
446 |
print MARC::File::XML::footer(); |
432 |
print "\n"; |
447 |
print "\n"; |
433 |
} |
448 |
} |
|
|
449 |
if ( $output_format eq 'csv' ) { |
450 |
my $csv_profile_id = $query->param('csv_profile') |
451 |
|| GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ); |
452 |
my $output = |
453 |
marc2csv( \@recordids, |
454 |
$csv_profile_id ); |
455 |
|
456 |
print $output; |
457 |
} |
434 |
|
458 |
|
435 |
exit; |
459 |
exit; |
436 |
} |
460 |
} |
437 |
elsif ( $output_format eq "csv" ) { |
461 |
elsif ( $output_format eq "csv" ) { |
438 |
my @biblionumbers = uniq $query->param("biblionumbers"); |
462 |
my @biblionumbers = uniq $query->param("biblionumbers"); |
439 |
my @itemnumbers = $query->param("itemnumbers"); |
463 |
my @itemnumbers = $query->param("itemnumbers"); |
|
|
464 |
my $csv_profile_id = $query->param('csv_profile') || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ); |
440 |
my $output = |
465 |
my $output = |
441 |
marc2csv( \@biblionumbers, |
466 |
marc2csv( \@biblionumbers, |
442 |
GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ), |
467 |
$csv_profile_id, |
443 |
\@itemnumbers, ); |
468 |
\@itemnumbers, ); |
444 |
print $query->header( |
469 |
print $query->header( |
445 |
-type => 'application/octet-stream', |
470 |
-type => 'application/octet-stream', |
Lines 513-518
else {
Link Here
|
513 |
itemtypeloop => \@itemtypesloop, |
538 |
itemtypeloop => \@itemtypesloop, |
514 |
authtypeloop => \@authtypesloop, |
539 |
authtypeloop => \@authtypesloop, |
515 |
export_remove_fields => C4::Context->preference("ExportRemoveFields"), |
540 |
export_remove_fields => C4::Context->preference("ExportRemoveFields"), |
|
|
541 |
csv_profiles => C4::Csv::GetCsvProfiles('marc'), |
516 |
); |
542 |
); |
517 |
|
543 |
|
518 |
output_html_with_http_headers $query, $cookie, $template->output; |
544 |
output_html_with_http_headers $query, $cookie, $template->output; |
519 |
- |
|
|