From 78ae7f1df83dc4c802ee858c021dac5379d303a2 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
Date: Mon, 15 Oct 2012 17:25:51 +0200
Subject: [PATCH] Bug 7298: Followup FIX the field list to return in GetOrder

---
 C4/Acquisition.pm          |   17 +++++++++++++----
 acqui/lateorders-export.pl |   16 ++++++++--------
 2 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index 84fb24c..ad8fc0e 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -991,10 +991,19 @@ C<$order> are fields from the biblio, biblioitems, aqorders tables of the Koha d
 sub GetOrder {
     my ($ordernumber) = @_;
     my $dbh      = C4::Context->dbh;
-    my $query = qq{SELECT biblio.*,biblioitems.*,
+    my $query = qq{SELECT
                 aqorders.*,
-                aqbudgets.*,
-                aqbasket.*,
+                biblio.title,
+                biblio.author,
+                aqbasket.basketname,
+                borrowers.branchcode,
+                biblioitems.publicationyear,
+                biblio.copyrightdate,
+                biblioitems.editionstatement,
+                biblioitems.isbn,
+                biblioitems.ean,
+                biblio.seriestitle,
+                biblioitems.publishercode
                 aqorders.rrp              AS unitpricesupplier,
                 aqorders.ecost            AS unitpricelib,
                 aqorders.claims_count     AS claims_count,
@@ -1005,7 +1014,7 @@ sub GetOrder {
                 biblioitems.publishercode AS publisher,
                 ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) AS estimateddeliverydate,
                 DATE(aqbasket.closedate)  AS orderdate,
-                aqorders.quantity - IFNULL(aqorders.quantityreceived,0)                 AS quantity,
+                aqorders.quantity - IFNULL(aqorders.quantityreceived,0)                  AS quantity_to_receive,
                 (aqorders.quantity - IFNULL(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
                 DATEDIFF(CURDATE( ),closedate) AS latesince
                 FROM aqorders LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
diff --git a/acqui/lateorders-export.pl b/acqui/lateorders-export.pl
index e3bf603..f328eac 100755
--- a/acqui/lateorders-export.pl
+++ b/acqui/lateorders-export.pl
@@ -48,14 +48,14 @@ print "ORDER DATE,ESTIMATED DELIVERY DATE,VENDOR,INFORMATION,TOTAL COST,BASKET,C
 for my $ordernumber ( @ordernumbers ) {
     my $order = GetOrder $ordernumber;
     $csv->combine(
-        "(" . $$order{supplierid} . ") " . $$order{orderdate} . " (" . $$order{latesince} . " days)",
-        $$order{estimateddeliverydate},
-        $$order{supplier},
-        $$order{title} . ( $$order{author} ? " Author: $$order{author}" : "" ) . ( $$order{publisher} ? " Published by: $$order{publisher}" : "" ),
-        $$order{unitpricesupplier} . "x" . $$order{quantity} . " = " . $$order{subtotal} . " (" . $$order{budget} . ")",
-        $$order{basketname} . " (" . $$order{basketno} . ")",
-        $$order{claims_count},
-        $$order{claimed_date}
+        "(" . $order->{supplierid} . ") " . $order->{orderdate} . " (" . $order->{latesince} . " days)",
+        $order->{estimateddeliverydate},
+        $order->{supplier},
+        $order->{title} . ( $order->{author} ? " Author: $order->{author}" : "" ) . ( $order->{publisher} ? " Published by: $order->{publisher}" : "" ),
+        $order->{unitpricesupplier} . "x" . $order->{quantity_to_receive} . " = " . $order->{subtotal} . " (" . $order->{budget} . ")",
+        $order->{basketname} . " (" . $order->{basketno} . ")",
+        $order->{claims_count},
+        $order->{claimed_date}
     );
     my $string = $csv->string;
     print $string, "\n";
-- 
1.7.10.4