MT2116: Addons to the CSV export
[koha.git] / opac / opac-downloadcart.pl
index 241f879..3e7096b 100755 (executable)
@@ -57,21 +57,23 @@ if ($bib_list && $format) {
     my $marcflavour         = C4::Context->preference('marcflavour');
     my $output;
 
-    # retrieve biblios from shelf
-    my $firstpass = 1;
-    foreach my $biblio (@bibs) {
-
-       my $record = GetMarcBiblio($biblio);
-
-       switch ($format) {
-           case "iso2709" { $output .= $record->as_usmarc(); }
-           case "ris"     { $output .= marc2ris($record); }
-           case "bibtex"  { $output .= marc2bibtex($record, $biblio); }
-           # We're in the case of a csv profile (firstpass is used for headers printing) :
-            case /^\d+$/   { $output .= marc2csv($biblio, $format, $firstpass); }
-       }
-        $firstpass = 0;
+    # CSV   
+    if ($format =~ /^\d+$/) {
+
+        $output = marc2csv(\@bibs, $format);
+
+    # Other formats
+    } else {
+       foreach my $biblio (@bibs) {
 
+           my $record = GetMarcBiblio($biblio);
+
+           switch ($format) {
+               case "iso2709" { $output .= $record->as_usmarc(); }
+               case "ris"     { $output .= marc2ris($record); }
+               case "bibtex"  { $output .= marc2bibtex($record, $biblio); }
+           }
+       }
     }
 
     # If it was a CSV export we change the format after the export so the file extension is fine