View | Details | Raw Unified | Return to bug 20728
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-53 lines)
Lines 70-76 BEGIN { Link Here
70
        &SearchOrders &GetHistory &GetRecentAcqui
70
        &SearchOrders &GetHistory &GetRecentAcqui
71
        &ModReceiveOrder &CancelReceipt
71
        &ModReceiveOrder &CancelReceipt
72
        &TransferOrder
72
        &TransferOrder
73
        &GetLastOrderNotReceivedFromSubscriptionid &GetLastOrderReceivedFromSubscriptionid
74
        &ModItemOrder
73
        &ModItemOrder
75
74
76
        &GetParcels
75
        &GetParcels
Lines 1247-1303 sub GetOrder { Link Here
1247
    return $result_set->[0];
1246
    return $result_set->[0];
1248
}
1247
}
1249
1248
1250
=head3 GetLastOrderNotReceivedFromSubscriptionid
1251
1252
  $order = &GetLastOrderNotReceivedFromSubscriptionid($subscriptionid);
1253
1254
Returns a reference-to-hash describing the last order not received for a subscription.
1255
1256
=cut
1257
1258
sub GetLastOrderNotReceivedFromSubscriptionid {
1259
    my ( $subscriptionid ) = @_;
1260
    my $dbh                = C4::Context->dbh;
1261
    my $query              = qq|
1262
        SELECT * FROM aqorders
1263
        LEFT JOIN subscription
1264
            ON ( aqorders.subscriptionid = subscription.subscriptionid )
1265
        WHERE aqorders.subscriptionid = ?
1266
            AND aqorders.datereceived IS NULL
1267
        LIMIT 1
1268
    |;
1269
    my $result_set =
1270
      $dbh->selectall_arrayref( $query, { Slice => {} }, $subscriptionid );
1271
1272
    # result_set assumed to contain 1 match
1273
    return $result_set->[0];
1274
}
1275
1276
=head3 GetLastOrderReceivedFromSubscriptionid
1277
1278
  $order = &GetLastOrderReceivedFromSubscriptionid($subscriptionid);
1279
1280
Returns a reference-to-hash describing the last order received for a subscription.
1281
1282
=cut
1283
1284
sub GetLastOrderReceivedFromSubscriptionid {
1285
    my ( $subscriptionid ) = @_;
1286
    my $lastOrderReceived = Koha::Acquisition::Orders->search(
1287
        {
1288
            subscriptionid => $subscriptionid,
1289
            datereceived   => { '!=' => undef }
1290
        },
1291
        {
1292
            order_by =>
1293
              [ { -desc => 'datereceived' }, { -desc => 'ordernumber' } ]
1294
        }
1295
    );
1296
    return $lastOrderReceived->count ? $lastOrderReceived->next->unblessed : undef;
1297
}
1298
1299
#------------------------------------------------------------#
1300
1301
=head3 ModOrder
1249
=head3 ModOrder
1302
1250
1303
  &ModOrder(\%hashref);
1251
  &ModOrder(\%hashref);
1304
- 

Return to bug 20728