Bug 6614: Remove newlines from order notes when exporting to CSV
[koha_gimpoz] / C4 / Acquisition.pm
index cd1e670..738fe16 100644 (file)
@@ -233,7 +233,7 @@ sub GetBasketAsCSV {
     my $output; 
 
     # TODO: Translate headers
-    my @headers = qw(contractname ordernumber line entrydate isbn author title publishercode collectiontitle notes quantity rrp);
+    my @headers = qw(contractname ordernumber entrydate isbn author title publishercode collectiontitle notes quantity rrp);
 
     $csv->combine(@headers);                                                                                                        
     $output = $csv->string() . "\n";   
@@ -241,16 +241,17 @@ sub GetBasketAsCSV {
     my @rows;
     foreach my $order (@orders) {
        my @cols;
-       my $bd = GetBiblioData($order->{'biblionumber'});
+       # newlines are not valid characters for Text::CSV combine()
+        $order->{'notes'} =~ s/[\r\n]+//g;
        push(@cols,
                $contract->{'contractname'},
                $order->{'ordernumber'},
                $order->{'entrydate'}, 
                $order->{'isbn'},
-               $bd->{'author'},
-               $bd->{'title'},
-               $bd->{'publishercode'},
-               $bd->{'collectiontitle'},
+               $order->{'author'},
+               $order->{'title'},
+               $order->{'publishercode'},
+               $order->{'collectiontitle'},
                $order->{'notes'},
                $order->{'quantity'},
                $order->{'rrp'},
@@ -258,10 +259,6 @@ sub GetBasketAsCSV {
        push (@rows, \@cols);
     }
 
-    # Sort by publishercode 
-    # TODO: Sort by publishercode then by title
-    @rows = sort { @$a[7] cmp @$b[7] } @rows;
-
     foreach my $row (@rows) {
        $csv->combine(@$row);                                                                                                                    
        $output .= $csv->string() . "\n";