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 1526-1531
sub CancelReceipt {
Link Here
|
1526 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1529 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1527 |
|
1530 |
|
1528 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
1531 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
|
|
1532 |
my $basket = Koha::Acquisition::Order->find( $order->{ordernumber} )->basket; |
1529 |
|
1533 |
|
1530 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1534 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1531 |
# The order line has no parent, just mark it as not received |
1535 |
# The order line has no parent, just mark it as not received |
Lines 1586-1592
sub CancelReceipt {
Link Here
|
1586 |
WHERE ordernumber = ? |
1590 |
WHERE ordernumber = ? |
1587 |
|, undef, $parent_ordernumber); |
1591 |
|, undef, $parent_ordernumber); |
1588 |
|
1592 |
|
1589 |
_cancel_items_receipt( $ordernumber, $parent_ordernumber ); |
1593 |
_cancel_items_receipt( $basket->effective_create_items, $ordernumber, $parent_ordernumber ); |
1590 |
# Delete order line |
1594 |
# Delete order line |
1591 |
$query = qq{ |
1595 |
$query = qq{ |
1592 |
DELETE FROM aqorders |
1596 |
DELETE FROM aqorders |
Lines 1597-1603
sub CancelReceipt {
Link Here
|
1597 |
|
1601 |
|
1598 |
} |
1602 |
} |
1599 |
|
1603 |
|
1600 |
if(C4::Context->preference('AcqCreateItem') eq 'ordering') { |
1604 |
if( $basket->effective_create_items eq 'ordering' ) { |
1601 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1605 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1602 |
if ( @affects ) { |
1606 |
if ( @affects ) { |
1603 |
for my $in ( @itemnumbers ) { |
1607 |
for my $in ( @itemnumbers ) { |
Lines 1620-1630
sub CancelReceipt {
Link Here
|
1620 |
} |
1624 |
} |
1621 |
|
1625 |
|
1622 |
sub _cancel_items_receipt { |
1626 |
sub _cancel_items_receipt { |
1623 |
my ( $ordernumber, $parent_ordernumber ) = @_; |
1627 |
my ( $effective_create_items, $ordernumber, $parent_ordernumber ) = @_; |
1624 |
$parent_ordernumber ||= $ordernumber; |
1628 |
$parent_ordernumber ||= $ordernumber; |
1625 |
|
1629 |
|
1626 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1630 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1627 |
if(C4::Context->preference('AcqCreateItem') eq 'receiving') { |
1631 |
if ( $effective_create_items eq 'receiving' ) { |
1628 |
# Remove items that were created at receipt |
1632 |
# Remove items that were created at receipt |
1629 |
my $query = qq{ |
1633 |
my $query = qq{ |
1630 |
DELETE FROM items, aqorders_items |
1634 |
DELETE FROM items, aqorders_items |