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 544-564
Modifies a basket's header.
Link Here
|
544 |
|
544 |
|
545 |
=item C<$is_standing> is the "is_standing" field in the aqbasket table. |
545 |
=item C<$is_standing> is the "is_standing" field in the aqbasket table. |
546 |
|
546 |
|
|
|
547 |
=item C<$create_items> should be set to 'ordering', 'receiving' or 'cataloguing' (or undef, in which |
548 |
case the AcqCreateItem syspref takes precedence). |
549 |
|
547 |
=back |
550 |
=back |
548 |
|
551 |
|
549 |
=cut |
552 |
=cut |
550 |
|
553 |
|
551 |
sub ModBasketHeader { |
554 |
sub ModBasketHeader { |
552 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_; |
555 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items) = @_; |
553 |
my $query = qq{ |
556 |
my $query = qq{ |
554 |
UPDATE aqbasket |
557 |
UPDATE aqbasket |
555 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=? |
558 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=?, create_items=? |
556 |
WHERE basketno=? |
559 |
WHERE basketno=? |
557 |
}; |
560 |
}; |
558 |
|
561 |
|
559 |
my $dbh = C4::Context->dbh; |
562 |
my $dbh = C4::Context->dbh; |
560 |
my $sth = $dbh->prepare($query); |
563 |
my $sth = $dbh->prepare($query); |
561 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $basketno); |
564 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items || undef, $basketno); |
562 |
|
565 |
|
563 |
if ( $contractnumber ) { |
566 |
if ( $contractnumber ) { |
564 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
567 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
Lines 1530-1535
sub CancelReceipt {
Link Here
|
1530 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1533 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1531 |
|
1534 |
|
1532 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
1535 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
|
|
1536 |
my $basket = Koha::Acquisition::Order->find( $order->{ordernumber} )->basket; |
1533 |
|
1537 |
|
1534 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1538 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1535 |
# The order line has no parent, just mark it as not received |
1539 |
# The order line has no parent, just mark it as not received |
Lines 1590-1596
sub CancelReceipt {
Link Here
|
1590 |
WHERE ordernumber = ? |
1594 |
WHERE ordernumber = ? |
1591 |
|, undef, $parent_ordernumber); |
1595 |
|, undef, $parent_ordernumber); |
1592 |
|
1596 |
|
1593 |
_cancel_items_receipt( $ordernumber, $parent_ordernumber ); |
1597 |
_cancel_items_receipt( $basket->effective_create_items, $ordernumber, $parent_ordernumber ); |
1594 |
# Delete order line |
1598 |
# Delete order line |
1595 |
$query = qq{ |
1599 |
$query = qq{ |
1596 |
DELETE FROM aqorders |
1600 |
DELETE FROM aqorders |
Lines 1601-1607
sub CancelReceipt {
Link Here
|
1601 |
|
1605 |
|
1602 |
} |
1606 |
} |
1603 |
|
1607 |
|
1604 |
if(C4::Context->preference('AcqCreateItem') eq 'ordering') { |
1608 |
if( $basket->effective_create_items eq 'ordering' ) { |
1605 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1609 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1606 |
if ( @affects ) { |
1610 |
if ( @affects ) { |
1607 |
for my $in ( @itemnumbers ) { |
1611 |
for my $in ( @itemnumbers ) { |
Lines 1624-1634
sub CancelReceipt {
Link Here
|
1624 |
} |
1628 |
} |
1625 |
|
1629 |
|
1626 |
sub _cancel_items_receipt { |
1630 |
sub _cancel_items_receipt { |
1627 |
my ( $ordernumber, $parent_ordernumber ) = @_; |
1631 |
my ( $effective_create_items, $ordernumber, $parent_ordernumber ) = @_; |
1628 |
$parent_ordernumber ||= $ordernumber; |
1632 |
$parent_ordernumber ||= $ordernumber; |
1629 |
|
1633 |
|
1630 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1634 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1631 |
if(C4::Context->preference('AcqCreateItem') eq 'receiving') { |
1635 |
if ( $effective_create_items eq 'receiving' ) { |
1632 |
# Remove items that were created at receipt |
1636 |
# Remove items that were created at receipt |
1633 |
my $query = qq{ |
1637 |
my $query = qq{ |
1634 |
DELETE FROM items, aqorders_items |
1638 |
DELETE FROM items, aqorders_items |