From af970db232aa022876a10597c80ae7b42a15d93e Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Thu, 24 Jul 2008 13:44:19 -0500 Subject: [PATCH] kohabug 2139 Fixes C4::Aquisition::NewOrder so that it saves the branchcode &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 Signed-off-by: Joshua Ferraro --- C4/Acquisition.pm | 11 ++++++----- acqui/addorder.pl | 3 ++- acqui/orderreceive.pl | 2 ++ t/lib/KohaTest/Acquisition/NewOrder.pm | 6 ++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index a599fdd216..b846ca5a57 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -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 ); } diff --git a/acqui/addorder.pl b/acqui/addorder.pl index a87702c373..a9b5f9cd48 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -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 ); } } diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index eaab7ee2dc..313a3847e0 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -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; } diff --git a/t/lib/KohaTest/Acquisition/NewOrder.pm b/t/lib/KohaTest/Acquisition/NewOrder.pm index bf39d2f9ff..e309b4cca1 100644 --- a/t/lib/KohaTest/Acquisition/NewOrder.pm +++ b/t/lib/KohaTest/Acquisition/NewOrder.pm @@ -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" ); -- 2.39.5