Bug 17842: Simplify the code
[koha-ffzg.git] / basket / downloadcart.pl
index 0690da5..487e9c6 100755 (executable)
@@ -28,7 +28,6 @@ use C4::Items;
 use C4::Output;
 use C4::Record;
 use C4::Ris;
-use C4::Csv;
 
 use Koha::CsvProfiles;
 
@@ -66,11 +65,15 @@ if ($bib_list && $format) {
 
         foreach my $biblio (@bibs) {
 
-            my $record = GetMarcBiblio($biblio, 1);
+            my $record = GetMarcBiblio({
+                biblionumber => $biblio,
+                embed_items  => 1 });
             next unless $record;
 
             if ($format eq 'iso2709') {
-                $output .= $record->as_usmarc();
+                #NOTE: If we don't explicitly UTF-8 encode the output,
+                #the browser will guess the encoding, and it won't always choose UTF-8.
+                $output .= encode("UTF-8", $record->as_usmarc()) // q{};
             }
             elsif ($format eq 'ris') {
                 $output .= marc2ris($record);
@@ -91,7 +94,7 @@ if ($bib_list && $format) {
     print $output;
 
 } else { 
-    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);
+    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ]);
     $template->param(bib_list => $bib_list); 
     output_html_with_http_headers $query, $cookie, $template->output;
 }