Lines 83-90
BEGIN {
Link Here
|
83 |
&DelInvoice |
83 |
&DelInvoice |
84 |
&MergeInvoices |
84 |
&MergeInvoices |
85 |
|
85 |
|
86 |
&GetItemnumbersFromOrder |
|
|
87 |
|
88 |
&AddClaim |
86 |
&AddClaim |
89 |
&GetBiblioCountByBasketno |
87 |
&GetBiblioCountByBasketno |
90 |
|
88 |
|
Lines 120-147
sub GetOrderFromItemnumber {
Link Here
|
120 |
|
118 |
|
121 |
} |
119 |
} |
122 |
|
120 |
|
123 |
# Returns the itemnumber(s) associated with the ordernumber given in parameter |
|
|
124 |
sub GetItemnumbersFromOrder { |
125 |
my ($ordernumber) = @_; |
126 |
my $dbh = C4::Context->dbh; |
127 |
my $query = "SELECT itemnumber FROM aqorders_items WHERE ordernumber=?"; |
128 |
my $sth = $dbh->prepare($query); |
129 |
$sth->execute($ordernumber); |
130 |
my @tab; |
131 |
|
132 |
while (my $order = $sth->fetchrow_hashref) { |
133 |
push @tab, $order->{'itemnumber'}; |
134 |
} |
135 |
|
136 |
return @tab; |
137 |
|
138 |
} |
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
=head1 NAME |
121 |
=head1 NAME |
146 |
|
122 |
|
147 |
C4::Acquisition - Koha functions for dealing with orders and acquisitions |
123 |
C4::Acquisition - Koha functions for dealing with orders and acquisitions |
Lines 1591-1598
sub CancelReceipt {
Link Here
|
1591 |
|
1567 |
|
1592 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1568 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1593 |
|
1569 |
|
1594 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
|
|
1595 |
my $order_obj = Koha::Acquisition::Orders->find( $ordernumber ); # FIXME rewrite all this subroutine using this object |
1570 |
my $order_obj = Koha::Acquisition::Orders->find( $ordernumber ); # FIXME rewrite all this subroutine using this object |
|
|
1571 |
my @itemnumbers = $order_obj->items->get_column('itemnumber'); |
1596 |
|
1572 |
|
1597 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1573 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1598 |
# The order line has no parent, just mark it as not received |
1574 |
# The order line has no parent, just mark it as not received |
Lines 1668-1674
sub CancelReceipt {
Link Here
|
1668 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1644 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1669 |
if ( @affects ) { |
1645 |
if ( @affects ) { |
1670 |
for my $in ( @itemnumbers ) { |
1646 |
for my $in ( @itemnumbers ) { |
1671 |
my $item = Koha::Items->find( $in ); |
1647 |
my $item = Koha::Items->find( $in ); # FIXME We do not need that, we already have Koha::Items from $order_obj->items |
1672 |
my $biblio = $item->biblio; |
1648 |
my $biblio = $item->biblio; |
1673 |
my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $biblio->frameworkcode ); |
1649 |
my ( $itemfield ) = GetMarcFromKohaField( 'items.itemnumber', $biblio->frameworkcode ); |
1674 |
my $item_marc = C4::Items::GetMarcItem( $biblio->biblionumber, $in ); |
1650 |
my $item_marc = C4::Items::GetMarcItem( $biblio->biblionumber, $in ); |
Lines 1690-1696
sub _cancel_items_receipt {
Link Here
|
1690 |
my ( $order, $parent_ordernumber ) = @_; |
1666 |
my ( $order, $parent_ordernumber ) = @_; |
1691 |
$parent_ordernumber ||= $order->ordernumber; |
1667 |
$parent_ordernumber ||= $order->ordernumber; |
1692 |
|
1668 |
|
1693 |
my @itemnumbers = GetItemnumbersFromOrder($order->ordernumber); # FIXME Must be $order->items |
1669 |
my $items = $order->items; |
1694 |
if ( $order->basket->effective_create_items eq 'receiving' ) { |
1670 |
if ( $order->basket->effective_create_items eq 'receiving' ) { |
1695 |
# Remove items that were created at receipt |
1671 |
# Remove items that were created at receipt |
1696 |
my $query = qq{ |
1672 |
my $query = qq{ |
Lines 1700-1712
sub _cancel_items_receipt {
Link Here
|
1700 |
}; |
1676 |
}; |
1701 |
my $dbh = C4::Context->dbh; |
1677 |
my $dbh = C4::Context->dbh; |
1702 |
my $sth = $dbh->prepare($query); |
1678 |
my $sth = $dbh->prepare($query); |
1703 |
foreach my $itemnumber (@itemnumbers) { |
1679 |
while ( my $item = $items->next ) { |
1704 |
$sth->execute($itemnumber, $itemnumber); |
1680 |
$sth->execute($item->itemnumber, $item->itemnumber); |
1705 |
} |
1681 |
} |
1706 |
} else { |
1682 |
} else { |
1707 |
# Update items |
1683 |
# Update items |
1708 |
foreach my $itemnumber (@itemnumbers) { |
1684 |
while ( my $item = $items->next ) { |
1709 |
ModItemOrder($itemnumber, $parent_ordernumber); |
1685 |
ModItemOrder($item->itemnumber, $parent_ordernumber); |
1710 |
} |
1686 |
} |
1711 |
} |
1687 |
} |
1712 |
} |
1688 |
} |
Lines 1910-1918
sub DelOrder {
Link Here
|
1910 |
} |
1886 |
} |
1911 |
$sth->finish; |
1887 |
$sth->finish; |
1912 |
|
1888 |
|
1913 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
1889 |
my $order = Koha::Acquisition::Orders->find($ordernumber); |
1914 |
foreach my $itemnumber (@itemnumbers){ |
1890 |
my $items = $order->items; |
1915 |
my $delcheck = C4::Items::DelItemCheck( $bibnum, $itemnumber ); |
1891 |
while ( my $item = $items->next ) { # Should be moved to Koha::Acquisition::Order->delete |
|
|
1892 |
my $delcheck = C4::Items::DelItemCheck( $bibnum, $item->itemnumber ); |
1916 |
|
1893 |
|
1917 |
if($delcheck != 1) { |
1894 |
if($delcheck != 1) { |
1918 |
$error->{'delitem'} = 1; |
1895 |
$error->{'delitem'} = 1; |