|
Lines 48-99
my $shelfid = $query->param('shelfid');
Link Here
|
| 48 |
my $format = $query->param('format'); |
48 |
my $format = $query->param('format'); |
| 49 |
my $dbh = C4::Context->dbh; |
49 |
my $dbh = C4::Context->dbh; |
| 50 |
|
50 |
|
| 51 |
if ($shelfid && $format) { |
51 |
if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $shelfid, 'view' ) ) { |
| 52 |
|
|
|
| 53 |
my @shelf = GetShelf($shelfid); |
| 54 |
my ($items, $totitems) = GetShelfContents($shelfid); |
| 55 |
my $marcflavour = C4::Context->preference('marcflavour'); |
| 56 |
my $output; |
| 57 |
|
| 58 |
# CSV |
| 59 |
if ($format =~ /^\d+$/) { |
| 60 |
my @biblios; |
| 61 |
foreach (@$items) { |
| 62 |
push @biblios, $_->{biblionumber}; |
| 63 |
} |
| 64 |
$output = marc2csv(\@biblios, $format); |
| 65 |
|
| 66 |
# Other formats |
| 67 |
} else { |
| 68 |
foreach my $biblio (@$items) { |
| 69 |
my $biblionumber = $biblio->{biblionumber}; |
| 70 |
|
52 |
|
| 71 |
my $record = GetMarcBiblio($biblionumber, 1); |
53 |
if ($shelfid && $format) { |
| 72 |
next unless $record; |
|
|
| 73 |
|
54 |
|
| 74 |
if ($format eq 'iso2709') { |
55 |
my @shelf = GetShelf($shelfid); |
| 75 |
$output .= $record->as_usmarc(); |
56 |
my ($items, $totitems) = GetShelfContents($shelfid); |
| 76 |
} |
57 |
my $marcflavour = C4::Context->preference('marcflavour'); |
| 77 |
elsif ($format eq 'ris' ) { |
58 |
my $output; |
| 78 |
$output .= marc2ris($record); |
59 |
|
|
|
60 |
# CSV |
| 61 |
if ($format =~ /^\d+$/) { |
| 62 |
my @biblios; |
| 63 |
foreach (@$items) { |
| 64 |
push @biblios, $_->{biblionumber}; |
| 79 |
} |
65 |
} |
| 80 |
elsif ($format eq 'bibtex') { |
66 |
$output = marc2csv(\@biblios, $format); |
| 81 |
$output .= marc2bibtex($record, $biblionumber); |
67 |
|
|
|
68 |
# Other formats |
| 69 |
} else { |
| 70 |
foreach my $biblio (@$items) { |
| 71 |
my $biblionumber = $biblio->{biblionumber}; |
| 72 |
|
| 73 |
my $record = GetMarcBiblio($biblionumber, 1); |
| 74 |
next unless $record; |
| 75 |
|
| 76 |
if ($format eq 'iso2709') { |
| 77 |
$output .= $record->as_usmarc(); |
| 78 |
} |
| 79 |
elsif ($format eq 'ris' ) { |
| 80 |
$output .= marc2ris($record); |
| 81 |
} |
| 82 |
elsif ($format eq 'bibtex') { |
| 83 |
$output .= marc2bibtex($record, $biblionumber); |
| 84 |
} |
| 82 |
} |
85 |
} |
| 83 |
} |
86 |
} |
| 84 |
} |
|
|
| 85 |
|
87 |
|
| 86 |
# If it was a CSV export we change the format after the export so the file extension is fine |
88 |
# If it was a CSV export we change the format after the export so the file extension is fine |
| 87 |
$format = "csv" if ($format =~ m/^\d+$/); |
89 |
$format = "csv" if ($format =~ m/^\d+$/); |
|
|
90 |
|
| 91 |
print $query->header( |
| 92 |
-type => 'application/octet-stream', |
| 93 |
-'Content-Transfer-Encoding' => 'binary', |
| 94 |
-attachment=>"shelf.$format"); |
| 95 |
print $output; |
| 88 |
|
96 |
|
| 89 |
print $query->header( |
97 |
} else { |
| 90 |
-type => 'application/octet-stream', |
98 |
$template->param(csv_profiles => GetCsvProfilesLoop()); |
| 91 |
-'Content-Transfer-Encoding' => 'binary', |
99 |
$template->param(shelfid => $shelfid); |
| 92 |
-attachment=>"shelf.$format"); |
100 |
output_html_with_http_headers $query, $cookie, $template->output; |
| 93 |
print $output; |
101 |
} |
| 94 |
|
102 |
|
| 95 |
} else { |
103 |
} else { |
| 96 |
$template->param(csv_profiles => GetCsvProfilesLoop()); |
104 |
$template->param(invalidlist => 1); |
| 97 |
$template->param(shelfid => $shelfid); |
|
|
| 98 |
output_html_with_http_headers $query, $cookie, $template->output; |
105 |
output_html_with_http_headers $query, $cookie, $template->output; |
| 99 |
} |
106 |
} |