From c414c11d64d2071b3b8ee597807ddd939de0c6ed Mon Sep 17 00:00:00 2001 From: Ian Walls Date: Wed, 20 Jul 2011 11:41:12 -0400 Subject: [PATCH] Bug 6613: CSV basket export columns misaligned Removes 'line' heading, since it does not correspond to any existing field name, and it pushes the fields over by one ('ordernumber' is used to denote the ordernumber). This patch also optimizes the GetBasketAsCSV subroutine a bit; it removes an unnecessary call to GetBiblioData, since the order information retrieved from GetOrders already contains every field in koha.biblio and koha.biblioitems This patch also removes the explicit sort done by publishercode, since the information returned by GetOrders is already ORDER BY'ed, first by publishercode, then by title (there was a FIXME note in GetBasketAsCSV to do this, but it's already done, so... :) ) To Test: 1. Create a basket with at least three orders: one from one publishercode, and two from another 2. Be sure to leave out any "\n" in your Order Notes, lest you fall prey to bug 6614! 3. Export the basket 4. You should see the orders sorted first by publishercode, then by title 5. Columns should line up correct all the way through Signed-off-by: Chris Cormack --- C4/Acquisition.pm | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index cd1e6706f7..09cb39ced2 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -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,15 @@ sub GetBasketAsCSV { my @rows; foreach my $order (@orders) { my @cols; - my $bd = GetBiblioData($order->{'biblionumber'}); 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 +257,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"; -- 2.39.2