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