Lines 33-39
use C4::Record;
Link Here
|
33 |
my $query = new CGI; |
33 |
my $query = new CGI; |
34 |
|
34 |
|
35 |
my $clean; |
35 |
my $clean; |
36 |
my $output_format; |
|
|
37 |
my $dont_export_items; |
36 |
my $dont_export_items; |
38 |
my $deleted_barcodes; |
37 |
my $deleted_barcodes; |
39 |
my $timestamp; |
38 |
my $timestamp; |
Lines 44-54
my $op = $query->param("op") || '';
Link Here
|
44 |
my $filename = $query->param("filename") || 'koha.mrc'; |
43 |
my $filename = $query->param("filename") || 'koha.mrc'; |
45 |
my $dbh = C4::Context->dbh; |
44 |
my $dbh = C4::Context->dbh; |
46 |
my $marcflavour = C4::Context->preference("marcflavour"); |
45 |
my $marcflavour = C4::Context->preference("marcflavour"); |
47 |
my $format = $query->param("format") || 'iso2709'; |
46 |
my $output_format = $query->param("output_format") || 'iso2709'; |
48 |
|
47 |
|
49 |
# Checks if the script is called from commandline |
48 |
# Checks if the script is called from commandline |
50 |
my $commandline = not defined $ENV{GATEWAY_INTERFACE}; |
49 |
my $commandline = not defined $ENV{GATEWAY_INTERFACE}; |
51 |
|
50 |
|
|
|
51 |
|
52 |
# @biblionumbers is only use for csv export from circulation.pl |
53 |
my @biblionumbers = uniq $query->param("biblionumbers"); |
54 |
|
52 |
if ( $commandline ) { |
55 |
if ( $commandline ) { |
53 |
|
56 |
|
54 |
# Getting parameters |
57 |
# Getting parameters |
Lines 94-100
_USAGE_
Link Here
|
94 |
} |
97 |
} |
95 |
|
98 |
|
96 |
# Default parameters values : |
99 |
# Default parameters values : |
97 |
$output_format ||= 'marc'; |
100 |
$output_format ||= 'iso2709'; |
98 |
$timestamp ||= ''; |
101 |
$timestamp ||= ''; |
99 |
$dont_export_items ||= 0; |
102 |
$dont_export_items ||= 0; |
100 |
$deleted_barcodes ||= 0; |
103 |
$deleted_barcodes ||= 0; |
Lines 142-151
if ( C4::Context->preference("IndependentBranches")
Link Here
|
142 |
my $backupdir = C4::Context->config('backupdir'); |
145 |
my $backupdir = C4::Context->config('backupdir'); |
143 |
|
146 |
|
144 |
if ( $op eq "export" ) { |
147 |
if ( $op eq "export" ) { |
145 |
if ( $format eq "iso2709" or $format eq "xml" ) { |
148 |
if ( |
|
|
149 |
$output_format eq "iso2709" |
150 |
or $output_format eq "xml" |
151 |
or ( |
152 |
$output_format eq 'csv' |
153 |
and not @biblionumbers |
154 |
) |
155 |
) { |
146 |
my $charset = 'utf-8'; |
156 |
my $charset = 'utf-8'; |
147 |
my $mimetype = 'application/octet-stream'; |
157 |
my $mimetype = 'application/octet-stream'; |
148 |
binmode STDOUT, ':encoding(UTF-8)'; |
158 |
|
|
|
159 |
binmode STDOUT, ':encoding(UTF-8)' |
160 |
if $filename =~ m/\.gz$/ |
161 |
or $filename =~ m/\.bz2$/; |
162 |
|
149 |
if ( $filename =~ m/\.gz$/ ) { |
163 |
if ( $filename =~ m/\.gz$/ ) { |
150 |
$mimetype = 'application/x-gzip'; |
164 |
$mimetype = 'application/x-gzip'; |
151 |
$charset = ''; |
165 |
$charset = ''; |
Lines 159-170
if ( $op eq "export" ) {
Link Here
|
159 |
print $query->header( |
173 |
print $query->header( |
160 |
-type => $mimetype, |
174 |
-type => $mimetype, |
161 |
-charset => $charset, |
175 |
-charset => $charset, |
162 |
-attachment => $filename |
176 |
-attachment => $filename, |
163 |
) unless ($commandline); |
177 |
) unless ($commandline); |
164 |
|
178 |
|
165 |
$record_type = $query->param("record_type") unless ($commandline); |
179 |
$record_type = $query->param("record_type") unless ($commandline); |
166 |
$output_format = $query->param("output_format") || 'marc' |
|
|
167 |
unless ($commandline); |
168 |
my $export_remove_fields = $query->param("export_remove_fields"); |
180 |
my $export_remove_fields = $query->param("export_remove_fields"); |
169 |
my @biblionumbers = $query->param("biblionumbers"); |
181 |
my @biblionumbers = $query->param("biblionumbers"); |
170 |
my @itemnumbers = $query->param("itemnumbers"); |
182 |
my @itemnumbers = $query->param("itemnumbers"); |
Lines 415-421
if ( $op eq "export" ) {
Link Here
|
415 |
print MARC::File::XML::record($record); |
427 |
print MARC::File::XML::record($record); |
416 |
print "\n"; |
428 |
print "\n"; |
417 |
} |
429 |
} |
418 |
else { |
430 |
elsif ( $output_format eq 'iso2709' ) { |
419 |
my (@result_build_tag) = MARC::File::USMARC::_build_tag_directory($record); |
431 |
my (@result_build_tag) = MARC::File::USMARC::_build_tag_directory($record); |
420 |
if ($result_build_tag[2] > 99999) { |
432 |
if ($result_build_tag[2] > 99999) { |
421 |
warn "record (number $recordid) length ".$result_build_tag[2]." is larger than the MARC spec allows (99999 bytes)"; |
433 |
warn "record (number $recordid) length ".$result_build_tag[2]." is larger than the MARC spec allows (99999 bytes)"; |
Lines 429-443
if ( $op eq "export" ) {
Link Here
|
429 |
print MARC::File::XML::footer(); |
441 |
print MARC::File::XML::footer(); |
430 |
print "\n"; |
442 |
print "\n"; |
431 |
} |
443 |
} |
|
|
444 |
if ( $output_format eq 'csv' ) { |
445 |
my $csv_profile_id = $query->param('csv_profile') |
446 |
|| GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ); |
447 |
my $output = |
448 |
marc2csv( \@recordids, |
449 |
$csv_profile_id ); |
450 |
|
451 |
print $output; |
452 |
} |
432 |
|
453 |
|
433 |
exit; |
454 |
exit; |
434 |
} |
455 |
} |
435 |
elsif ( $format eq "csv" ) { |
456 |
elsif ( $output_format eq "csv" ) { |
436 |
my @biblionumbers = uniq $query->param("biblionumbers"); |
|
|
437 |
my @itemnumbers = $query->param("itemnumbers"); |
457 |
my @itemnumbers = $query->param("itemnumbers"); |
|
|
458 |
my $csv_profile_id = $query->param('csv_profile') || GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ); |
438 |
my $output = |
459 |
my $output = |
439 |
marc2csv( \@biblionumbers, |
460 |
marc2csv( \@biblionumbers, |
440 |
GetCsvProfileId( C4::Context->preference('ExportWithCsvProfile') ), |
461 |
$csv_profile_id, |
441 |
\@itemnumbers, ); |
462 |
\@itemnumbers, ); |
442 |
print $query->header( |
463 |
print $query->header( |
443 |
-type => 'application/octet-stream', |
464 |
-type => 'application/octet-stream', |
Lines 511-516
else {
Link Here
|
511 |
itemtypeloop => \@itemtypesloop, |
532 |
itemtypeloop => \@itemtypesloop, |
512 |
authtypeloop => \@authtypesloop, |
533 |
authtypeloop => \@authtypesloop, |
513 |
export_remove_fields => C4::Context->preference("ExportRemoveFields"), |
534 |
export_remove_fields => C4::Context->preference("ExportRemoveFields"), |
|
|
535 |
csv_profiles => C4::Csv::GetCsvProfiles('marc'), |
514 |
); |
536 |
); |
515 |
|
537 |
|
516 |
output_html_with_http_headers $query, $cookie, $template->output; |
538 |
output_html_with_http_headers $query, $cookie, $template->output; |
517 |
- |
|
|