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 596-616
Modifies a basket's header.
Link Here
|
596 |
|
596 |
|
597 |
=item C<$is_standing> is the "is_standing" field in the aqbasket table. |
597 |
=item C<$is_standing> is the "is_standing" field in the aqbasket table. |
598 |
|
598 |
|
|
|
599 |
=item C<$create_items> should be set to 'ordering', 'receiving' or 'cataloguing' (or undef, in which |
600 |
case the AcqCreateItem syspref takes precedence). |
601 |
|
599 |
=back |
602 |
=back |
600 |
|
603 |
|
601 |
=cut |
604 |
=cut |
602 |
|
605 |
|
603 |
sub ModBasketHeader { |
606 |
sub ModBasketHeader { |
604 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing) = @_; |
607 |
my ($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items) = @_; |
605 |
my $query = qq{ |
608 |
my $query = qq{ |
606 |
UPDATE aqbasket |
609 |
UPDATE aqbasket |
607 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=? |
610 |
SET basketname=?, note=?, booksellernote=?, booksellerid=?, deliveryplace=?, billingplace=?, is_standing=?, create_items=? |
608 |
WHERE basketno=? |
611 |
WHERE basketno=? |
609 |
}; |
612 |
}; |
610 |
|
613 |
|
611 |
my $dbh = C4::Context->dbh; |
614 |
my $dbh = C4::Context->dbh; |
612 |
my $sth = $dbh->prepare($query); |
615 |
my $sth = $dbh->prepare($query); |
613 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $basketno); |
616 |
$sth->execute($basketname, $note, $booksellernote, $booksellerid, $deliveryplace, $billingplace, $is_standing, $create_items || undef, $basketno); |
614 |
|
617 |
|
615 |
if ( $contractnumber ) { |
618 |
if ( $contractnumber ) { |
616 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
619 |
my $query2 ="UPDATE aqbasket SET contractnumber=? WHERE basketno=?"; |
Lines 1585-1590
sub CancelReceipt {
Link Here
|
1585 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1588 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1586 |
|
1589 |
|
1587 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
1590 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
|
|
1591 |
my $basket = Koha::Acquisition::Order->find( $order->{ordernumber} )->basket; |
1588 |
|
1592 |
|
1589 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1593 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1590 |
# The order line has no parent, just mark it as not received |
1594 |
# The order line has no parent, just mark it as not received |
Lines 1645-1651
sub CancelReceipt {
Link Here
|
1645 |
WHERE ordernumber = ? |
1649 |
WHERE ordernumber = ? |
1646 |
|, undef, $parent_ordernumber); |
1650 |
|, undef, $parent_ordernumber); |
1647 |
|
1651 |
|
1648 |
_cancel_items_receipt( $ordernumber, $parent_ordernumber ); |
1652 |
_cancel_items_receipt( $basket->effective_create_items, $ordernumber, $parent_ordernumber ); |
1649 |
# Delete order line |
1653 |
# Delete order line |
1650 |
$query = qq{ |
1654 |
$query = qq{ |
1651 |
DELETE FROM aqorders |
1655 |
DELETE FROM aqorders |
Lines 1656-1662
sub CancelReceipt {
Link Here
|
1656 |
|
1660 |
|
1657 |
} |
1661 |
} |
1658 |
|
1662 |
|
1659 |
if(C4::Context->preference('AcqCreateItem') eq 'ordering') { |
1663 |
if( $basket->effective_create_items eq 'ordering' ) { |
1660 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1664 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1661 |
if ( @affects ) { |
1665 |
if ( @affects ) { |
1662 |
for my $in ( @itemnumbers ) { |
1666 |
for my $in ( @itemnumbers ) { |
Lines 1679-1689
sub CancelReceipt {
Link Here
|
1679 |
} |
1683 |
} |
1680 |
|
1684 |
|
1681 |
sub _cancel_items_receipt { |
1685 |
sub _cancel_items_receipt { |
1682 |
my ( $ordernumber, $parent_ordernumber ) = @_; |
1686 |
my ( $effective_create_items, $ordernumber, $parent_ordernumber ) = @_; |
1683 |
$parent_ordernumber ||= $ordernumber; |
1687 |
$parent_ordernumber ||= $ordernumber; |
1684 |
|
1688 |
|
1685 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1689 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1686 |
if(C4::Context->preference('AcqCreateItem') eq 'receiving') { |
1690 |
if ( $effective_create_items eq 'receiving' ) { |
1687 |
# Remove items that were created at receipt |
1691 |
# Remove items that were created at receipt |
1688 |
my $query = qq{ |
1692 |
my $query = qq{ |
1689 |
DELETE FROM items, aqorders_items |
1693 |
DELETE FROM items, aqorders_items |