[Koha-patches] [PATCH] Bug Fixing : branch on ordering was not managed.
Henri-Damien LAURENT
henridamien at koha-fr.org
Thu May 22 10:11:53 CEST 2008
Adding Branch Management to NewOrder/ModOrder
Adding Branch retrieval when receiving, so that default branch, when receiving is acquisition branch
This was really needed when not in Independant Branches.
TODO (But not prioritary):
an AJAX *could* select the list of acknowledged budgets when selecting a branch at ordering
and branch *could* be infered from budget selection
If so, we should be able to click on empty value for a wide branch and budget selection.
Let's Be careful though of AJAX loops.
---
C4/Acquisition.pm | 49 +++++++++++++++++---------------
acqui/addorder.pl | 6 ++-
acqui/orderreceive.pl | 1 +
t/lib/KohaTest/Acquisition/NewOrder.pm | 2 +
4 files changed, 33 insertions(+), 25 deletions(-)
diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index c0565a0..56d509b 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -369,7 +369,7 @@ sub GetOrder {
&NewOrder($basket, $biblionumber, $title, $quantity, $listprice,
$booksellerid, $who, $notes, $bookfund, $biblioitemnumber, $rrp,
$ecost, $gst, $budget, $unitprice, $subscription,
- $booksellerinvoicenumber, $purchaseorder);
+ $booksellerinvoicenumber, $purchaseorder,$branch);
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
@@ -397,7 +397,8 @@ sub NewOrder {
$listprice, $booksellerid, $authorisedby, $notes,
$bookfund, $bibitemnum, $rrp, $ecost,
$gst, $budget, $cost, $sub,
- $invoice, $sort1, $sort2, $purchaseorder
+ $invoice, $sort1, $sort2, $purchaseorder,
+ $branch
)
= @_;
@@ -438,7 +439,7 @@ sub NewOrder {
notes, biblioitemnumber, rrp, ecost, gst,
unitprice, subscription, sort1, sort2, budgetdate,
entrydate, purchaseordernumber)
- VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,COALESCE(?,NOW()),NOW(),? )
+ VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,COALESCE(?,NOW()),NOW(),?)
";
my $sth = $dbh->prepare($query);
@@ -453,11 +454,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,branchcode, bookfundid)
+ VALUES (?,?,?)
";
$sth = $dbh->prepare($query);
- $sth->execute( $ordnum, $bookfund );
+ $sth->execute( $ordnum,$branch, $bookfund );
$sth->finish;
return ( $basketno, $ordnum );
}
@@ -468,10 +469,11 @@ sub NewOrder {
=over 4
-&ModOrder($title, $ordernumber, $quantity, $listprice,
- $biblionumber, $basketno, $supplier, $who, $notes,
- $bookfundid, $bibitemnum, $rrp, $ecost, $gst, $budget,
- $unitprice, $booksellerinvoicenumber);
+&ModOrder($title, $ordnum, $quantity, $listprice, $bibnum,
+ $basketno, $supplier, $who, $notes, $bookfund,
+ $bibitemnum, $rrp, $ecost, $gst, $budget,
+ $cost, $invoice, $sort1, $sort2, $purchaseorder,
+ $branch);
Modifies an existing order. Updates the order with order number
C<$ordernumber> and biblionumber C<$biblionumber>. All other arguments
@@ -490,7 +492,8 @@ sub ModOrder {
$title, $ordnum, $quantity, $listprice, $bibnum,
$basketno, $supplier, $who, $notes, $bookfund,
$bibitemnum, $rrp, $ecost, $gst, $budget,
- $cost, $invoice, $sort1, $sort2, $purchaseorder
+ $cost, $invoice, $sort1, $sort2, $purchaseorder,
+ $branch
)
= @_;
my $dbh = C4::Context->dbh;
@@ -518,7 +521,7 @@ sub ModOrder {
";
$sth = $dbh->prepare($query);
- unless ( $sth->execute( $bookfund,$branchcode, $ordnum ) )
+ unless ( $sth->execute( $bookfund,$branch, $ordnum ) )
{ # zero rows affected [Bug 734]
my $query ="
INSERT INTO aqorderbreakdown
@@ -526,7 +529,7 @@ sub ModOrder {
VALUES (?,?,?)
";
$sth = $dbh->prepare($query);
- $sth->execute( $ordnum,$branchcode, $bookfund );
+ $sth->execute( $ordnum,$branch, $bookfund );
}
$sth->finish;
}
@@ -693,13 +696,13 @@ sub SearchOrder {
$query =
"SELECT *,biblio.title
FROM aqorders
- LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
- LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
- LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
- WHERE aqbasket.booksellerid = ?
- AND ((datecancellationprinted is NULL)
- OR (datecancellationprinted = '0000-00-00'))
- AND (("
+ JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
+ JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
+ JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
+ WHERE aqbasket.booksellerid = ?
+ AND ((datecancellationprinted is NULL)
+ OR (datecancellationprinted = '0000-00-00'))
+ AND (("
. (
join( " AND ",
map { "(biblio.title like ? or biblio.title like ?)" } @data )
@@ -711,9 +714,9 @@ sub SearchOrder {
$query =
" SELECT *,biblio.title
FROM aqorders
- LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
- LEFT JOIN aqbasket on aqorders.basketno=aqbasket.basketno
- LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
+ JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
+ JOIN aqbasket on aqorders.basketno=aqbasket.basketno
+ JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber
WHERE ((datecancellationprinted is NULL)
OR (datecancellationprinted = '0000-00-00'))
AND (aqorders.quantityreceived < aqorders.quantity OR aqorders.quantityreceived is NULL)
diff --git a/acqui/addorder.pl b/acqui/addorder.pl
index 7c4bdcd..b2c7580 100755
--- a/acqui/addorder.pl
+++ b/acqui/addorder.pl
@@ -207,7 +207,8 @@ if ( $quantity ne '0' ) {
$biblionumber, $basketno, $booksellerid, $loggedinuser,
$notes, $bookfund, $bibitemnum, $rrp,
$ecost, $gst, $budget, $cost,
- $invoice, $sort1, $sort2, $purchaseorder
+ $invoice, $sort1, $sort2, $purchaseorder,
+ $branch
);
}
else { # else, it's a new line
@@ -216,7 +217,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 5e86eb5..99f3c1f 100755
--- a/acqui/orderreceive.pl
+++ b/acqui/orderreceive.pl
@@ -142,6 +142,7 @@ if ( $count == 1 ) {
foreach my $thisbranch ( sort keys %$branches ) {
my %row = (
value => $thisbranch,
+ selected => $thisbranch eq $results[0]->{'branchcode'},
description => $branches->{$thisbranch}->{'branchname'},
);
push @branchloop, \%row;
diff --git a/t/lib/KohaTest/Acquisition/NewOrder.pm b/t/lib/KohaTest/Acquisition/NewOrder.pm
index bf39d2f..6302a4b 100644
--- a/t/lib/KohaTest/Acquisition/NewOrder.pm
+++ b/t/lib/KohaTest/Acquisition/NewOrder.pm
@@ -45,6 +45,7 @@ sub new_order_no_budget : Test( 4 ) {
undef, # $sort1,
undef, # $sort2,
undef, # $purchaseorder
+ undef, # $branchcode
);
ok( $basketno, "my basket number is $basketno" );
ok( $ordnum, "my order number is $ordnum" );
@@ -92,6 +93,7 @@ sub new_order_set_budget : Test( 4 ) {
undef, # $sort1,
undef, # $sort2,
undef, # $purchaseorder
+ undef, # $branchcode
);
ok( $basketno, "my basket number is $basketno" );
ok( $ordnum, "my order number is $ordnum" );
--
1.5.4.3
More information about the Koha-patches
mailing list