Lines 939-949
sub GetOrders {
Link Here
|
939 |
SELECT biblio.*,biblioitems.*, |
939 |
SELECT biblio.*,biblioitems.*, |
940 |
aqorders.*, |
940 |
aqorders.*, |
941 |
aqbudgets.*, |
941 |
aqbudgets.*, |
942 |
biblio.title |
942 |
biblio.title, |
|
|
943 |
aqorders_transfers.ordernumber_from AS transferred_from, |
944 |
aqorders_transfers.timestamp AS transferred_from_timestamp |
943 |
FROM aqorders |
945 |
FROM aqorders |
944 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
946 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
945 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
947 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
946 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
948 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
|
|
949 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_to = aqorders.ordernumber |
947 |
WHERE basketno=? |
950 |
WHERE basketno=? |
948 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
951 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
949 |
"; |
952 |
"; |
Lines 1265-1275
sub GetCancelledOrders {
Link Here
|
1265 |
|
1268 |
|
1266 |
my $dbh = C4::Context->dbh; |
1269 |
my $dbh = C4::Context->dbh; |
1267 |
my $query = " |
1270 |
my $query = " |
1268 |
SELECT biblio.*, biblioitems.*, aqorders.*, aqbudgets.* |
1271 |
SELECT |
|
|
1272 |
biblio.*, |
1273 |
biblioitems.*, |
1274 |
aqorders.*, |
1275 |
aqbudgets.*, |
1276 |
aqorders_transfers.ordernumber_to AS transferred_to, |
1277 |
aqorders_transfers.timestamp AS transferred_to_timestamp |
1269 |
FROM aqorders |
1278 |
FROM aqorders |
1270 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
1279 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
1271 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
1280 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
1272 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber |
1281 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber |
|
|
1282 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_from = aqorders.ordernumber |
1273 |
WHERE basketno = ? |
1283 |
WHERE basketno = ? |
1274 |
AND (datecancellationprinted IS NOT NULL |
1284 |
AND (datecancellationprinted IS NOT NULL |
1275 |
AND datecancellationprinted <> '0000-00-00') |
1285 |
AND datecancellationprinted <> '0000-00-00') |
Lines 1617-1658
sub TransferOrder {
Link Here
|
1617 |
|
1627 |
|
1618 |
my $order = GetOrder( $ordernumber ); |
1628 |
my $order = GetOrder( $ordernumber ); |
1619 |
return if $order->{datereceived}; |
1629 |
return if $order->{datereceived}; |
|
|
1630 |
my $basket = GetBasket($basketno); |
1631 |
return unless $basket; |
1620 |
|
1632 |
|
1621 |
my $today = C4::Dates->new()->output("iso"); |
|
|
1622 |
my $query = qq{ |
1623 |
SELECT aqbooksellers.name |
1624 |
FROM aqorders |
1625 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
1626 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
1627 |
WHERE aqorders.ordernumber = ? |
1628 |
}; |
1629 |
my $dbh = C4::Context->dbh; |
1633 |
my $dbh = C4::Context->dbh; |
1630 |
my $sth = $dbh->prepare($query); |
1634 |
my ($query, $sth, $rv); |
1631 |
$sth->execute($ordernumber); |
|
|
1632 |
my ($booksellerfromname) = $sth->fetchrow_array; |
1633 |
|
1634 |
$query = qq{ |
1635 |
SELECT aqbooksellers.name |
1636 |
FROM aqbasket |
1637 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
1638 |
WHERE aqbasket.basketno = ? |
1639 |
}; |
1640 |
$sth = $dbh->prepare($query); |
1641 |
$sth->execute($basketno); |
1642 |
my ($booksellertoname) = $sth->fetchrow_array; |
1643 |
|
1635 |
|
1644 |
$query = qq{ |
1636 |
$query = qq{ |
1645 |
UPDATE aqorders |
1637 |
UPDATE aqorders |
1646 |
SET datecancellationprinted = CAST(NOW() AS date), |
1638 |
SET datecancellationprinted = CAST(NOW() AS date) |
1647 |
internalnotes = ? |
|
|
1648 |
WHERE ordernumber = ? |
1639 |
WHERE ordernumber = ? |
1649 |
}; |
1640 |
}; |
1650 |
$sth = $dbh->prepare($query); |
1641 |
$sth = $dbh->prepare($query); |
1651 |
$sth->execute("Cancelled and transfered to $booksellertoname on $today", $ordernumber); |
1642 |
$rv = $sth->execute($ordernumber); |
1652 |
|
1643 |
|
1653 |
delete $order->{'ordernumber'}; |
1644 |
delete $order->{'ordernumber'}; |
1654 |
$order->{'basketno'} = $basketno; |
1645 |
$order->{'basketno'} = $basketno; |
1655 |
$order->{'internalnotes'} = "Transfered from $booksellerfromname on $today"; |
|
|
1656 |
my $newordernumber; |
1646 |
my $newordernumber; |
1657 |
(undef, $newordernumber) = NewOrder($order); |
1647 |
(undef, $newordernumber) = NewOrder($order); |
1658 |
|
1648 |
|
Lines 1664-1669
sub TransferOrder {
Link Here
|
1664 |
$sth = $dbh->prepare($query); |
1654 |
$sth = $dbh->prepare($query); |
1665 |
$sth->execute($newordernumber, $ordernumber); |
1655 |
$sth->execute($newordernumber, $ordernumber); |
1666 |
|
1656 |
|
|
|
1657 |
$query = q{ |
1658 |
INSERT INTO aqorders_transfers (ordernumber_from, ordernumber_to) |
1659 |
VALUES (?, ?) |
1660 |
}; |
1661 |
$sth = $dbh->prepare($query); |
1662 |
$sth->execute($ordernumber, $newordernumber); |
1663 |
|
1667 |
return $newordernumber; |
1664 |
return $newordernumber; |
1668 |
} |
1665 |
} |
1669 |
|
1666 |
|