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