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