Lines 186-192
sub GetBasket {
Link Here
|
186 |
=head3 NewBasket |
186 |
=head3 NewBasket |
187 |
|
187 |
|
188 |
$basket = &NewBasket( $booksellerid, $authorizedby, $basketname, |
188 |
$basket = &NewBasket( $booksellerid, $authorizedby, $basketname, |
189 |
$basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace, $is_standing ); |
189 |
$basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace, $is_standing, $create_items ); |
190 |
|
190 |
|
191 |
Create a new basket in aqbasket table |
191 |
Create a new basket in aqbasket table |
192 |
|
192 |
|
Lines 205-211
The other parameters are optional, see ModBasketHeader for more info on them.
Link Here
|
205 |
sub NewBasket { |
205 |
sub NewBasket { |
206 |
my ( $booksellerid, $authorisedby, $basketname, $basketnote, |
206 |
my ( $booksellerid, $authorisedby, $basketname, $basketnote, |
207 |
$basketbooksellernote, $basketcontractnumber, $deliveryplace, |
207 |
$basketbooksellernote, $basketcontractnumber, $deliveryplace, |
208 |
$billingplace, $is_standing ) = @_; |
208 |
$billingplace, $is_standing, $create_items ) = @_; |
209 |
my $dbh = C4::Context->dbh; |
209 |
my $dbh = C4::Context->dbh; |
210 |
my $query = |
210 |
my $query = |
211 |
'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) ' |
211 |
'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) ' |
Lines 217-223
sub NewBasket {
Link Here
|
217 |
$basketnote ||= q{}; |
217 |
$basketnote ||= q{}; |
218 |
$basketbooksellernote ||= q{}; |
218 |
$basketbooksellernote ||= q{}; |
219 |
ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote, |
219 |
ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote, |
220 |
$basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing ); |
220 |
$basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items ); |
221 |
return $basket; |
221 |
return $basket; |
222 |
} |
222 |
} |
223 |
|
223 |
|
Lines 532-537
Modifies a basket's header.
Link Here
|
532 |
|
532 |
|
533 |
=item C<$is_standing> is the "is_standing" field in the aqbasket table. |
533 |
=item C<$is_standing> is the "is_standing" field in the aqbasket table. |
534 |
|
534 |
|
|
|
535 |
=item C<$create_items> should be set to 'ordering', 'receiving' or 'cataloguing' (or undef, in which |
536 |
case the AcqCreateItem syspref takes precedence). |
537 |
|
535 |
=back |
538 |
=back |
536 |
|
539 |
|
537 |
=cut |
540 |
=cut |
Lines 540-552
sub ModBasketHeader {
Link Here
|
540 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_; |
543 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_; |
541 |
my $query = qq{ |
544 |
my $query = qq{ |
542 |
UPDATE aqbasket |
545 |
UPDATE aqbasket |
543 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=? |
546 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=?, create_items=? |
544 |
WHERE basketno=? |
547 |
WHERE basketno=? |
545 |
}; |
548 |
}; |
546 |
|
549 |
|
547 |
my $dbh = C4::Context->dbh; |
550 |
my $dbh = C4::Context->dbh; |
548 |
my $sth = $dbh->prepare($query); |
551 |
my $sth = $dbh->prepare($query); |
549 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $basketno); |
552 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items || undef, $basketno); |
550 |
|
553 |
|
551 |
if ( $contractnumber ) { |
554 |
if ( $contractnumber ) { |
552 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
555 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
Lines 1498-1503
sub CancelReceipt {
Link Here
|
1498 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1501 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1499 |
|
1502 |
|
1500 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
1503 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
|
|
1504 |
my $basket = Koha::Acquisition::Order->find( $order->{ordernumber} )->basket; |
1501 |
|
1505 |
|
1502 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1506 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1503 |
# The order line has no parent, just mark it as not received |
1507 |
# The order line has no parent, just mark it as not received |
Lines 1548-1554
sub CancelReceipt {
Link Here
|
1548 |
" receipt"; |
1552 |
" receipt"; |
1549 |
return; |
1553 |
return; |
1550 |
} |
1554 |
} |
1551 |
_cancel_items_receipt( $ordernumber, $parent_ordernumber ); |
1555 |
_cancel_items_receipt( $basket->effective_create_items, $ordernumber, $parent_ordernumber ); |
1552 |
# Delete order line |
1556 |
# Delete order line |
1553 |
$query = qq{ |
1557 |
$query = qq{ |
1554 |
DELETE FROM aqorders |
1558 |
DELETE FROM aqorders |
Lines 1559-1565
sub CancelReceipt {
Link Here
|
1559 |
|
1563 |
|
1560 |
} |
1564 |
} |
1561 |
|
1565 |
|
1562 |
if(C4::Context->preference('AcqCreateItem') eq 'ordering') { |
1566 |
if( $basket->effective_create_items eq 'ordering' ) { |
1563 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1567 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1564 |
if ( @affects ) { |
1568 |
if ( @affects ) { |
1565 |
for my $in ( @itemnumbers ) { |
1569 |
for my $in ( @itemnumbers ) { |
Lines 1582-1592
sub CancelReceipt {
Link Here
|
1582 |
} |
1586 |
} |
1583 |
|
1587 |
|
1584 |
sub _cancel_items_receipt { |
1588 |
sub _cancel_items_receipt { |
1585 |
my ( $ordernumber, $parent_ordernumber ) = @_; |
1589 |
my ( $effective_create_items, $ordernumber, $parent_ordernumber ) = @_; |
1586 |
$parent_ordernumber ||= $ordernumber; |
1590 |
$parent_ordernumber ||= $ordernumber; |
1587 |
|
1591 |
|
1588 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1592 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1589 |
if(C4::Context->preference('AcqCreateItem') eq 'receiving') { |
1593 |
if ( $effective_create_items eq 'receiving' ) { |
1590 |
# Remove items that were created at receipt |
1594 |
# Remove items that were created at receipt |
1591 |
my $query = qq{ |
1595 |
my $query = qq{ |
1592 |
DELETE FROM items, aqorders_items |
1596 |
DELETE FROM items, aqorders_items |