Lines 1280-1309
Returns a reference-to-hash describing the last order received for a subscriptio
Link Here
|
1280 |
|
1280 |
|
1281 |
sub GetLastOrderReceivedFromSubscriptionid { |
1281 |
sub GetLastOrderReceivedFromSubscriptionid { |
1282 |
my ( $subscriptionid ) = @_; |
1282 |
my ( $subscriptionid ) = @_; |
1283 |
my $dbh = C4::Context->dbh; |
1283 |
my $lastOrderReceived = Koha::Acquisition::Orders->search( |
1284 |
my $query = qq| |
1284 |
{ |
1285 |
SELECT * FROM aqorders |
1285 |
subscriptionid => $subscriptionid, |
1286 |
LEFT JOIN subscription |
1286 |
datereceived => { '!=' => undef } |
1287 |
ON ( aqorders.subscriptionid = subscription.subscriptionid ) |
1287 |
}, |
1288 |
WHERE aqorders.subscriptionid = ? |
1288 |
{ |
1289 |
AND aqorders.datereceived = |
1289 |
order_by => |
1290 |
( |
1290 |
[ { -desc => 'datereceived' }, { -desc => 'ordernumber' } ] |
1291 |
SELECT MAX( aqorders.datereceived ) |
1291 |
} |
1292 |
FROM aqorders |
1292 |
); |
1293 |
LEFT JOIN subscription |
1293 |
return $lastOrderReceived->count ? $lastOrderReceived->next->unblessed : undef; |
1294 |
ON ( aqorders.subscriptionid = subscription.subscriptionid ) |
|
|
1295 |
WHERE aqorders.subscriptionid = ? |
1296 |
AND aqorders.datereceived IS NOT NULL |
1297 |
) |
1298 |
ORDER BY ordernumber DESC |
1299 |
LIMIT 1 |
1300 |
|; |
1301 |
my $result_set = |
1302 |
$dbh->selectall_arrayref( $query, { Slice => {} }, $subscriptionid, $subscriptionid ); |
1303 |
|
1304 |
# result_set assumed to contain 1 match |
1305 |
return $result_set->[0]; |
1306 |
|
1307 |
} |
1294 |
} |
1308 |
|
1295 |
|
1309 |
#------------------------------------------------------------# |
1296 |
#------------------------------------------------------------# |
1310 |
- |
|
|