Lines 62-68
BEGIN {
Link Here
|
62 |
&GetLateOrders &GetOrderFromItemnumber |
62 |
&GetLateOrders &GetOrderFromItemnumber |
63 |
&SearchOrders &GetHistory &GetRecentAcqui |
63 |
&SearchOrders &GetHistory &GetRecentAcqui |
64 |
&ModReceiveOrder &CancelReceipt |
64 |
&ModReceiveOrder &CancelReceipt |
65 |
&GetCancelledOrders &TransferOrder |
65 |
&TransferOrder |
66 |
&GetLastOrderNotReceivedFromSubscriptionid &GetLastOrderReceivedFromSubscriptionid |
66 |
&GetLastOrderNotReceivedFromSubscriptionid &GetLastOrderReceivedFromSubscriptionid |
67 |
&ModItemOrder |
67 |
&ModItemOrder |
68 |
|
68 |
|
Lines 1032-1074
sub GetBasketgroups {
Link Here
|
1032 |
|
1032 |
|
1033 |
=head3 GetOrders |
1033 |
=head3 GetOrders |
1034 |
|
1034 |
|
1035 |
@orders = &GetOrders($basketnumber, $orderby); |
1035 |
@orders = &GetOrders( $basketno, { orderby => 'biblio.title', cancelled => 0|1 } ); |
1036 |
|
1036 |
|
1037 |
Looks up the pending (non-cancelled) orders with the given basket |
1037 |
Looks up the pending (non-cancelled) orders with the given basket |
1038 |
number. If C<$booksellerID> is non-empty, only orders from that seller |
1038 |
number. |
1039 |
are returned. |
|
|
1040 |
|
1039 |
|
1041 |
return : |
1040 |
If cancelled is set, only cancelled orders will be returned. |
1042 |
C<&basket> returns a two-element array. C<@orders> is an array of |
|
|
1043 |
references-to-hash, whose keys are the fields from the aqorders, |
1044 |
biblio, and biblioitems tables in the Koha database. |
1045 |
|
1041 |
|
1046 |
=cut |
1042 |
=cut |
1047 |
|
1043 |
|
1048 |
sub GetOrders { |
1044 |
sub GetOrders { |
1049 |
my ( $basketno, $orderby ) = @_; |
1045 |
my ( $basketno, $params ) = @_; |
|
|
1046 |
|
1050 |
return () unless $basketno; |
1047 |
return () unless $basketno; |
|
|
1048 |
|
1049 |
my $orderby = $params->{orderby}; |
1050 |
my $cancelled = $params->{cancelled} || 0; |
1051 |
|
1051 |
my $dbh = C4::Context->dbh; |
1052 |
my $dbh = C4::Context->dbh; |
1052 |
my $query =" |
1053 |
my $query = q| |
1053 |
SELECT biblio.*,biblioitems.*, |
1054 |
SELECT biblio.*,biblioitems.*, |
1054 |
aqorders.*, |
1055 |
aqorders.*, |
1055 |
aqbudgets.*, |
1056 |
aqbudgets.*, |
|
|
1057 |
|; |
1058 |
$query .= $cancelled |
1059 |
? q| |
1060 |
aqorders_transfers.ordernumber_from AS transferred_to, |
1061 |
aqorders_transfers.timestamp AS transferred_to_timestamp |
1062 |
| |
1063 |
: q| |
1056 |
aqorders_transfers.ordernumber_from AS transferred_from, |
1064 |
aqorders_transfers.ordernumber_from AS transferred_from, |
1057 |
aqorders_transfers.timestamp AS transferred_from_timestamp |
1065 |
aqorders_transfers.timestamp AS transferred_from_timestamp |
|
|
1066 |
|; |
1067 |
$query .= q| |
1058 |
FROM aqorders |
1068 |
FROM aqorders |
1059 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
1069 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
1060 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
1070 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
1061 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
1071 |
LEFT JOIN biblioitems ON biblioitems.biblionumber =biblio.biblionumber |
|
|
1072 |
|; |
1073 |
$query .= $cancelled |
1074 |
? q| |
1075 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_from = aqorders.ordernumber |
1076 |
| |
1077 |
: q| |
1062 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_to = aqorders.ordernumber |
1078 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_to = aqorders.ordernumber |
|
|
1079 |
|
1080 |
|; |
1081 |
$query .= q| |
1063 |
WHERE basketno=? |
1082 |
WHERE basketno=? |
|
|
1083 |
|; |
1084 |
|
1085 |
if ($cancelled) { |
1086 |
$orderby ||= q|biblioitems.publishercode, biblio.title|; |
1087 |
$query .= q| |
1088 |
AND (datecancellationprinted IS NOT NULL |
1089 |
AND datecancellationprinted <> '0000-00-00') |
1090 |
|; |
1091 |
} |
1092 |
else { |
1093 |
$orderby ||= |
1094 |
q|aqorders.datecancellationprinted desc, aqorders.timestamp desc|; |
1095 |
$query .= q| |
1064 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
1096 |
AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') |
1065 |
"; |
1097 |
|; |
|
|
1098 |
} |
1066 |
|
1099 |
|
1067 |
$orderby = "biblioitems.publishercode,biblio.title" unless $orderby; |
|
|
1068 |
$query .= " ORDER BY $orderby"; |
1100 |
$query .= " ORDER BY $orderby"; |
1069 |
my $result_set = |
1101 |
my $orders = |
1070 |
$dbh->selectall_arrayref( $query, { Slice => {} }, $basketno ); |
1102 |
$dbh->selectall_arrayref( $query, { Slice => {} }, $basketno ); |
1071 |
return @{$result_set}; |
1103 |
return @{$orders}; |
1072 |
|
1104 |
|
1073 |
} |
1105 |
} |
1074 |
|
1106 |
|
Lines 1304-1354
sub ModItemOrder {
Link Here
|
1304 |
|
1336 |
|
1305 |
#------------------------------------------------------------# |
1337 |
#------------------------------------------------------------# |
1306 |
|
1338 |
|
1307 |
=head3 GetCancelledOrders |
|
|
1308 |
|
1309 |
my @orders = GetCancelledOrders($basketno, $orderby); |
1310 |
|
1311 |
Returns cancelled orders for a basket |
1312 |
|
1313 |
=cut |
1314 |
|
1315 |
sub GetCancelledOrders { |
1316 |
my ( $basketno, $orderby ) = @_; |
1317 |
|
1318 |
return () unless $basketno; |
1319 |
|
1320 |
my $dbh = C4::Context->dbh; |
1321 |
my $query = " |
1322 |
SELECT |
1323 |
biblio.*, |
1324 |
biblioitems.*, |
1325 |
aqorders.*, |
1326 |
aqbudgets.*, |
1327 |
aqorders_transfers.ordernumber_to AS transferred_to, |
1328 |
aqorders_transfers.timestamp AS transferred_to_timestamp |
1329 |
FROM aqorders |
1330 |
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id |
1331 |
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber |
1332 |
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber |
1333 |
LEFT JOIN aqorders_transfers ON aqorders_transfers.ordernumber_from = aqorders.ordernumber |
1334 |
WHERE basketno = ? |
1335 |
AND (datecancellationprinted IS NOT NULL |
1336 |
AND datecancellationprinted <> '0000-00-00') |
1337 |
"; |
1338 |
|
1339 |
$orderby = "aqorders.datecancellationprinted desc, aqorders.timestamp desc" |
1340 |
unless $orderby; |
1341 |
$query .= " ORDER BY $orderby"; |
1342 |
my $sth = $dbh->prepare($query); |
1343 |
$sth->execute($basketno); |
1344 |
my $results = $sth->fetchall_arrayref( {} ); |
1345 |
|
1346 |
return @$results; |
1347 |
} |
1348 |
|
1349 |
|
1350 |
#------------------------------------------------------------# |
1351 |
|
1352 |
=head3 ModReceiveOrder |
1339 |
=head3 ModReceiveOrder |
1353 |
|
1340 |
|
1354 |
&ModReceiveOrder({ |
1341 |
&ModReceiveOrder({ |