Lines 186-193
sub GetBasket {
Link Here
|
186 |
|
186 |
|
187 |
=head3 NewBasket |
187 |
=head3 NewBasket |
188 |
|
188 |
|
189 |
$basket = &NewBasket( $booksellerid, $authorizedby, $basketname, |
189 |
$basket = &NewBasket( $booksellerid, $authorizedby, $basketname, |
190 |
$basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace ); |
190 |
$basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace, $is_standing ); |
191 |
|
191 |
|
192 |
Create a new basket in aqbasket table |
192 |
Create a new basket in aqbasket table |
193 |
|
193 |
|
Lines 206-212
The other parameters are optional, see ModBasketHeader for more info on them.
Link Here
|
206 |
sub NewBasket { |
206 |
sub NewBasket { |
207 |
my ( $booksellerid, $authorisedby, $basketname, $basketnote, |
207 |
my ( $booksellerid, $authorisedby, $basketname, $basketnote, |
208 |
$basketbooksellernote, $basketcontractnumber, $deliveryplace, |
208 |
$basketbooksellernote, $basketcontractnumber, $deliveryplace, |
209 |
$billingplace ) = @_; |
209 |
$billingplace, $is_standing ) = @_; |
210 |
my $dbh = C4::Context->dbh; |
210 |
my $dbh = C4::Context->dbh; |
211 |
my $query = |
211 |
my $query = |
212 |
'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) ' |
212 |
'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) ' |
Lines 218-224
sub NewBasket {
Link Here
|
218 |
$basketnote ||= q{}; |
218 |
$basketnote ||= q{}; |
219 |
$basketbooksellernote ||= q{}; |
219 |
$basketbooksellernote ||= q{}; |
220 |
ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote, |
220 |
ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote, |
221 |
$basketcontractnumber, $booksellerid, $deliveryplace, $billingplace ); |
221 |
$basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing ); |
222 |
return $basket; |
222 |
return $basket; |
223 |
} |
223 |
} |
224 |
|
224 |
|
Lines 531-551
Modifies a basket's header.
Link Here
|
531 |
|
531 |
|
532 |
=item C<$billingplace> is the "billingplace" field in the aqbasket table. |
532 |
=item C<$billingplace> is the "billingplace" field in the aqbasket table. |
533 |
|
533 |
|
|
|
534 |
=item C<$is_standing> is the "is_standing" field in the aqbasket table. |
535 |
|
534 |
=back |
536 |
=back |
535 |
|
537 |
|
536 |
=cut |
538 |
=cut |
537 |
|
539 |
|
538 |
sub ModBasketHeader { |
540 |
sub ModBasketHeader { |
539 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace) = @_; |
541 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_; |
540 |
my $query = qq{ |
542 |
my $query = qq{ |
541 |
UPDATE aqbasket |
543 |
UPDATE aqbasket |
542 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=? |
544 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=? |
543 |
WHERE basketno=? |
545 |
WHERE basketno=? |
544 |
}; |
546 |
}; |
545 |
|
547 |
|
546 |
my $dbh = C4::Context->dbh; |
548 |
my $dbh = C4::Context->dbh; |
547 |
my $sth = $dbh->prepare($query); |
549 |
my $sth = $dbh->prepare($query); |
548 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $basketno); |
550 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $basketno); |
549 |
|
551 |
|
550 |
if ( $contractnumber ) { |
552 |
if ( $contractnumber ) { |
551 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
553 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
Lines 1385-1391
sub ModReceiveOrder {
Link Here
|
1385 |
} |
1387 |
} |
1386 |
|
1388 |
|
1387 |
my $result_set = $dbh->selectall_arrayref( |
1389 |
my $result_set = $dbh->selectall_arrayref( |
1388 |
q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?}, |
1390 |
q{SELECT *, aqbasket.is_standing FROM aqorders LEFT JOIN aqbasket USING (basketno) WHERE biblionumber=? AND aqorders.ordernumber=?}, |
1389 |
{ Slice => {} }, $biblionumber, $ordernumber |
1391 |
{ Slice => {} }, $biblionumber, $ordernumber |
1390 |
); |
1392 |
); |
1391 |
|
1393 |
|
Lines 1393-1399
q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?},
Link Here
|
1393 |
my $order = $result_set->[0]; |
1395 |
my $order = $result_set->[0]; |
1394 |
|
1396 |
|
1395 |
my $new_ordernumber = $ordernumber; |
1397 |
my $new_ordernumber = $ordernumber; |
1396 |
if ( $order->{quantity} > $quantrec ) { |
1398 |
if ( $order->{is_standing} || $order->{quantity} > $quantrec ) { |
1397 |
# Split order line in two parts: the first is the original order line |
1399 |
# Split order line in two parts: the first is the original order line |
1398 |
# without received items (the quantity is decreased), |
1400 |
# without received items (the quantity is decreased), |
1399 |
# the second part is a new order line with quantity=quantityrec |
1401 |
# the second part is a new order line with quantity=quantityrec |
Lines 1408-1414
q{SELECT * FROM aqorders WHERE biblionumber=? AND aqorders.ordernumber=?},
Link Here
|
1408 |
my $sth = $dbh->prepare($query); |
1410 |
my $sth = $dbh->prepare($query); |
1409 |
|
1411 |
|
1410 |
$sth->execute( |
1412 |
$sth->execute( |
1411 |
$order->{quantity} - $quantrec, |
1413 |
( $order->{quantity} < $quantrec ? 0 : ( $order->{quantity} - $quantrec ) ), |
1412 |
( defined $order_internalnote ? $order_internalnote : () ), |
1414 |
( defined $order_internalnote ? $order_internalnote : () ), |
1413 |
( defined $order_vendornote ? $order_vendornote : () ), |
1415 |
( defined $order_vendornote ? $order_vendornote : () ), |
1414 |
$ordernumber |
1416 |
$ordernumber |
Lines 1684-1693
sub SearchOrders {
Link Here
|
1684 |
}; |
1686 |
}; |
1685 |
|
1687 |
|
1686 |
if ( $pending or $ordered ) { |
1688 |
if ( $pending or $ordered ) { |
1687 |
$query .= q{ AND (quantity > quantityreceived OR quantityreceived is NULL)}; |
1689 |
$query .= q{ |
1688 |
} |
1690 |
AND ( |
1689 |
if ( $ordered ) { |
1691 |
( aqbasket.is_standing AND aqorders.orderstatus IN ( "new", "ordered", "partial" ) ) |
1690 |
$query .= q{ AND aqorders.orderstatus IN ( "ordered", "partial" )}; |
1692 |
OR ( |
|
|
1693 |
( quantity > quantityreceived OR quantityreceived is NULL ) |
1694 |
}; |
1695 |
|
1696 |
if ( $ordered ) { |
1697 |
$query .= q{ AND aqorders.orderstatus IN ( "ordered", "partial" )}; |
1698 |
} |
1699 |
$query .= q{ |
1700 |
) |
1701 |
) |
1702 |
}; |
1691 |
} |
1703 |
} |
1692 |
|
1704 |
|
1693 |
my $userenv = C4::Context->userenv; |
1705 |
my $userenv = C4::Context->userenv; |