Lines 190-196
sub GetBasket {
Link Here
|
190 |
=head3 NewBasket |
190 |
=head3 NewBasket |
191 |
|
191 |
|
192 |
$basket = &NewBasket( $booksellerid, $authorizedby, $basketname, |
192 |
$basket = &NewBasket( $booksellerid, $authorizedby, $basketname, |
193 |
$basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace, $is_standing ); |
193 |
$basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace, $is_standing, $create_items ); |
194 |
|
194 |
|
195 |
Create a new basket in aqbasket table |
195 |
Create a new basket in aqbasket table |
196 |
|
196 |
|
Lines 209-215
The other parameters are optional, see ModBasketHeader for more info on them.
Link Here
|
209 |
sub NewBasket { |
209 |
sub NewBasket { |
210 |
my ( $booksellerid, $authorisedby, $basketname, $basketnote, |
210 |
my ( $booksellerid, $authorisedby, $basketname, $basketnote, |
211 |
$basketbooksellernote, $basketcontractnumber, $deliveryplace, |
211 |
$basketbooksellernote, $basketcontractnumber, $deliveryplace, |
212 |
$billingplace, $is_standing ) = @_; |
212 |
$billingplace, $is_standing, $create_items ) = @_; |
213 |
my $dbh = C4::Context->dbh; |
213 |
my $dbh = C4::Context->dbh; |
214 |
my $query = |
214 |
my $query = |
215 |
'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) ' |
215 |
'INSERT INTO aqbasket (creationdate,booksellerid,authorisedby) ' |
Lines 221-227
sub NewBasket {
Link Here
|
221 |
$basketnote ||= q{}; |
221 |
$basketnote ||= q{}; |
222 |
$basketbooksellernote ||= q{}; |
222 |
$basketbooksellernote ||= q{}; |
223 |
ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote, |
223 |
ModBasketHeader( $basket, $basketname, $basketnote, $basketbooksellernote, |
224 |
$basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing ); |
224 |
$basketcontractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items ); |
225 |
return $basket; |
225 |
return $basket; |
226 |
} |
226 |
} |
227 |
|
227 |
|
Lines 598-618
Modifies a basket's header.
Link Here
|
598 |
|
598 |
|
599 |
=item C<$is_standing> is the "is_standing" field in the aqbasket table. |
599 |
=item C<$is_standing> is the "is_standing" field in the aqbasket table. |
600 |
|
600 |
|
|
|
601 |
=item C<$create_items> should be set to 'ordering', 'receiving' or 'cataloguing' (or undef, in which |
602 |
case the AcqCreateItem syspref takes precedence). |
603 |
|
601 |
=back |
604 |
=back |
602 |
|
605 |
|
603 |
=cut |
606 |
=cut |
604 |
|
607 |
|
605 |
sub ModBasketHeader { |
608 |
sub ModBasketHeader { |
606 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_; |
609 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items) = @_; |
607 |
my $query = qq{ |
610 |
my $query = qq{ |
608 |
UPDATE aqbasket |
611 |
UPDATE aqbasket |
609 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=? |
612 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=?, create_items=? |
610 |
WHERE basketno=? |
613 |
WHERE basketno=? |
611 |
}; |
614 |
}; |
612 |
|
615 |
|
613 |
my $dbh = C4::Context->dbh; |
616 |
my $dbh = C4::Context->dbh; |
614 |
my $sth = $dbh->prepare($query); |
617 |
my $sth = $dbh->prepare($query); |
615 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $basketno); |
618 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items || undef, $basketno); |
616 |
|
619 |
|
617 |
if ( $contractnumber ) { |
620 |
if ( $contractnumber ) { |
618 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
621 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
Lines 1587-1592
sub CancelReceipt {
Link Here
|
1587 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1590 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1588 |
|
1591 |
|
1589 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
1592 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
|
|
1593 |
my $basket = Koha::Acquisition::Order->find( $order->{ordernumber} )->basket; |
1590 |
|
1594 |
|
1591 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1595 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1592 |
# The order line has no parent, just mark it as not received |
1596 |
# The order line has no parent, just mark it as not received |
Lines 1647-1653
sub CancelReceipt {
Link Here
|
1647 |
WHERE ordernumber = ? |
1651 |
WHERE ordernumber = ? |
1648 |
|, undef, $parent_ordernumber); |
1652 |
|, undef, $parent_ordernumber); |
1649 |
|
1653 |
|
1650 |
_cancel_items_receipt( $ordernumber, $parent_ordernumber ); |
1654 |
_cancel_items_receipt( $basket->effective_create_items, $ordernumber, $parent_ordernumber ); |
1651 |
# Delete order line |
1655 |
# Delete order line |
1652 |
$query = qq{ |
1656 |
$query = qq{ |
1653 |
DELETE FROM aqorders |
1657 |
DELETE FROM aqorders |
Lines 1658-1664
sub CancelReceipt {
Link Here
|
1658 |
|
1662 |
|
1659 |
} |
1663 |
} |
1660 |
|
1664 |
|
1661 |
if(C4::Context->preference('AcqCreateItem') eq 'ordering') { |
1665 |
if( $basket->effective_create_items eq 'ordering' ) { |
1662 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1666 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1663 |
if ( @affects ) { |
1667 |
if ( @affects ) { |
1664 |
for my $in ( @itemnumbers ) { |
1668 |
for my $in ( @itemnumbers ) { |
Lines 1681-1691
sub CancelReceipt {
Link Here
|
1681 |
} |
1685 |
} |
1682 |
|
1686 |
|
1683 |
sub _cancel_items_receipt { |
1687 |
sub _cancel_items_receipt { |
1684 |
my ( $ordernumber, $parent_ordernumber ) = @_; |
1688 |
my ( $effective_create_items, $ordernumber, $parent_ordernumber ) = @_; |
1685 |
$parent_ordernumber ||= $ordernumber; |
1689 |
$parent_ordernumber ||= $ordernumber; |
1686 |
|
1690 |
|
1687 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1691 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1688 |
if(C4::Context->preference('AcqCreateItem') eq 'receiving') { |
1692 |
if ( $effective_create_items eq 'receiving' ) { |
1689 |
# Remove items that were created at receipt |
1693 |
# Remove items that were created at receipt |
1690 |
my $query = qq{ |
1694 |
my $query = qq{ |
1691 |
DELETE FROM items, aqorders_items |
1695 |
DELETE FROM items, aqorders_items |