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