Lines 55-61
BEGIN {
Link Here
|
55 |
&GetOrderNumber &GetLateOrders &GetOrderFromItemnumber |
55 |
&GetOrderNumber &GetLateOrders &GetOrderFromItemnumber |
56 |
&SearchOrder &GetHistory &GetRecentAcqui |
56 |
&SearchOrder &GetHistory &GetRecentAcqui |
57 |
&ModReceiveOrder &ModOrderBiblioitemNumber |
57 |
&ModReceiveOrder &ModOrderBiblioitemNumber |
58 |
&GetCancelledOrders |
58 |
&GetCancelledOrders &TransferOrder |
59 |
|
59 |
|
60 |
&NewOrderItem &ModOrderItem |
60 |
&NewOrderItem &ModOrderItem |
61 |
|
61 |
|
Lines 1295-1300
sub DelOrder {
Link Here
|
1295 |
|
1295 |
|
1296 |
} |
1296 |
} |
1297 |
|
1297 |
|
|
|
1298 |
=head3 TransferOrder |
1299 |
|
1300 |
my $newordernumber = TransferOrder($ordernumber, $basketno); |
1301 |
|
1302 |
Transfer an order line to a basket. |
1303 |
Mark $ordernumber as cancelled with an internal note 'Cancelled and transfered |
1304 |
to BOOKSELLER on DATE' and create new order with internal note |
1305 |
'Transfered from BOOKSELLER on DATE'. |
1306 |
Move all attached items to the new order. |
1307 |
Received orders cannot be transfered. |
1308 |
Return the ordernumber of created order. |
1309 |
|
1310 |
=cut |
1311 |
|
1312 |
sub TransferOrder { |
1313 |
my ($ordernumber, $basketno) = @_; |
1314 |
|
1315 |
return unless $ordernumber or $basketno; |
1316 |
|
1317 |
my $order = GetOrder( $ordernumber ); |
1318 |
return if $order->{datereceived}; |
1319 |
|
1320 |
my $today = C4::Dates->new()->output("iso"); |
1321 |
my $query = qq{ |
1322 |
SELECT aqbooksellers.name |
1323 |
FROM aqorders |
1324 |
LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno |
1325 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
1326 |
WHERE aqorders.ordernumber = ? |
1327 |
}; |
1328 |
my $dbh = C4::Context->dbh; |
1329 |
my $sth = $dbh->prepare($query); |
1330 |
$sth->execute($ordernumber); |
1331 |
my ($booksellerfromname) = $sth->fetchrow_array; |
1332 |
|
1333 |
$query = qq{ |
1334 |
SELECT aqbooksellers.name |
1335 |
FROM aqbasket |
1336 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
1337 |
WHERE aqbasket.basketno = ? |
1338 |
}; |
1339 |
$sth = $dbh->prepare($query); |
1340 |
$sth->execute($basketno); |
1341 |
my ($booksellertoname) = $sth->fetchrow_array; |
1342 |
|
1343 |
$query = qq{ |
1344 |
UPDATE aqorders |
1345 |
SET datecancellationprinted = CAST(NOW() AS date), |
1346 |
internalnotes = ? |
1347 |
WHERE ordernumber = ? |
1348 |
}; |
1349 |
$sth = $dbh->prepare($query); |
1350 |
$sth->execute("Cancelled and transfered to $booksellertoname on $today", $ordernumber); |
1351 |
|
1352 |
delete $order->{'ordernumber'}; |
1353 |
$order->{'basketno'} = $basketno; |
1354 |
$order->{'internalnotes'} = "Transfered from $booksellerfromname on $today"; |
1355 |
my $newordernumber; |
1356 |
(undef, $newordernumber) = NewOrder($order); |
1357 |
|
1358 |
$query = qq{ |
1359 |
UPDATE aqorders_items |
1360 |
SET ordernumber = ? |
1361 |
WHERE ordernumber = ? |
1362 |
}; |
1363 |
$sth = $dbh->prepare($query); |
1364 |
$sth->execute($newordernumber, $ordernumber); |
1365 |
|
1366 |
return $newordernumber; |
1367 |
} |
1368 |
|
1298 |
=head2 FUNCTIONS ABOUT PARCELS |
1369 |
=head2 FUNCTIONS ABOUT PARCELS |
1299 |
|
1370 |
|
1300 |
=cut |
1371 |
=cut |