kohabug 2139 Fixes C4::Aquisition::NewOrder so that it saves the branchcode
authorChris Nighswonger <chris.nighswonger@liblime.com>
Thu, 24 Jul 2008 18:44:19 +0000 (13:44 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 24 Jul 2008 19:54:01 +0000 (14:54 -0500)
&NewOrder did not save the branchcode posted with a new order. This patch adds that param.

Added code to select the branch the order is for in the branch dropdown list on
acqui/orderreceive.pl

Updating POD and tests

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Acquisition.pm
acqui/addorder.pl
acqui/orderreceive.pl
t/lib/KohaTest/Acquisition/NewOrder.pm

index a599fdd..b846ca5 100644 (file)
@@ -370,7 +370,7 @@ sub GetOrder {
   &NewOrder($basket, $biblionumber, $title, $quantity, $listprice,
     $booksellerid, $who, $notes, $bookfund, $biblioitemnumber, $rrp,
     $ecost, $gst, $budget, $unitprice, $subscription,
-    $booksellerinvoicenumber, $purchaseorder);
+    $booksellerinvoicenumber, $purchaseorder, $branchcode);
 
 Adds a new order to the database. Any argument that isn't described
 below is the new value of the field with the same name in the aqorders
@@ -398,7 +398,8 @@ sub NewOrder {
         $listprice, $booksellerid, $authorisedby, $notes,
         $bookfund,  $bibitemnum,   $rrp,          $ecost,
         $gst,       $budget,       $cost,         $sub,
-        $invoice,   $sort1,        $sort2,        $purchaseorder
+        $invoice,   $sort1,        $sort2,        $purchaseorder,
+               $branchcode
       )
       = @_;
 
@@ -454,11 +455,11 @@ sub NewOrder {
     #get ordnum MYSQL dependant, but $dbh->last_insert_id returns null
     my $ordnum = $dbh->{'mysql_insertid'};
     $query = "
-        INSERT INTO aqorderbreakdown (ordernumber,bookfundid)
-        VALUES (?,?)
+        INSERT INTO aqorderbreakdown (ordernumber,bookfundid, branchcode)
+        VALUES (?,?,?)
     ";
     $sth = $dbh->prepare($query);
-    $sth->execute( $ordnum, $bookfund );
+    $sth->execute( $ordnum, $bookfund, $branchcode );
     $sth->finish;
     return ( $basketno, $ordnum );
 }
index a87702c..a9b5f9c 100755 (executable)
@@ -216,7 +216,8 @@ if ( $quantity ne '0' ) {
             $listprice, $booksellerid, $loggedinuser, $notes,
             $bookfund,  $bibitemnum,   $rrp,          $ecost,
             $gst,       $budget,       $cost,         $sub,
-            $invoice,   $sort1,        $sort2,         $purchaseorder
+            $invoice,   $sort1,        $sort2,         $purchaseorder,
+                       $branch
         );
     }
 }
index eaab7ee..313a384 100755 (executable)
@@ -82,6 +82,7 @@ my $gst          = $input->param('gst');
 
 my @results = SearchOrder( $search, $supplierid, $biblionumber, $catview );
 my $count   = scalar @results;
+my $order      = GetOrder($search);
 
 my $bookseller = GetBookSellerFromId( $results[0]->{'booksellerid'} );
 
@@ -144,6 +145,7 @@ if ( $count == 1 ) {
             value      => $thisbranch,
             description => $branches->{$thisbranch}->{'branchname'},
         );
+           $row{'selected'} = 1 if( $thisbranch eq $order->{branchcode}) ;
         push @branchloop, \%row;
     }
 
index bf39d2f..e309b4c 100644 (file)
@@ -44,7 +44,8 @@ sub new_order_no_budget : Test( 4 ) {
                                           $invoice, # $invoice,
                                           undef, # $sort1,
                                           undef, # $sort2,
-                                          undef, # $purchaseorder
+                                          undef, # $purchaseorder,
+                                                                                 undef, # $branchcode
                                      );
     ok( $basketno, "my basket number is $basketno" );
     ok( $ordnum,   "my order number is $ordnum" );
@@ -91,7 +92,8 @@ sub new_order_set_budget : Test( 4 ) {
                                           $invoice, # $invoice,
                                           undef, # $sort1,
                                           undef, # $sort2,
-                                          undef, # $purchaseorder
+                                          undef, # $purchaseorder,
+                                                                                 undef, # $branchcode
                                      );
     ok( $basketno, "my basket number is $basketno" );
     ok( $ordnum,   "my order number is $ordnum" );