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

(-)a/C4/HoldsQueue.pm (-8 / +9 lines)
Lines 314-321 sub GetItemsAvailableToFillHoldRequestsForBib { Link Here
314
    my ($biblionumber, $branches_to_use) = @_;
314
    my ($biblionumber, $branches_to_use) = @_;
315
315
316
    my $dbh = C4::Context->dbh;
316
    my $dbh = C4::Context->dbh;
317
    my $items_query = "SELECT itemnumber, homebranch, holdingbranch, itemtypes.itemtype AS itype
317
    my $items_query = "SELECT items.itemnumber, homebranch, holdingbranch, itemtypes.itemtype AS itype
318
                       FROM items ";
318
                       FROM items
319
                       LEFT JOIN branchtransfers ON items.itemnumber = branchtransfers.itemnumber AND 
320
                           branchtransfers.datearrived IS NULL AND branchtransfers.datecancelled IS NULL ";
319
321
320
    if (C4::Context->preference('item-level_itypes')) {
322
    if (C4::Context->preference('item-level_itypes')) {
321
        $items_query .=   "LEFT JOIN itemtypes ON (itemtypes.itemtype = items.itype) ";
323
        $items_query .=   "LEFT JOIN itemtypes ON (itemtypes.itemtype = items.itype) ";
Lines 330-343 sub GetItemsAvailableToFillHoldRequestsForBib { Link Here
330
    $items_query .= "  AND damaged = 0" unless C4::Context->preference('AllowHoldsOnDamagedItems');
332
    $items_query .= "  AND damaged = 0" unless C4::Context->preference('AllowHoldsOnDamagedItems');
331
    $items_query .= "  AND items.onloan IS NULL
333
    $items_query .= "  AND items.onloan IS NULL
332
                       AND (itemtypes.notforloan IS NULL OR itemtypes.notforloan = 0)
334
                       AND (itemtypes.notforloan IS NULL OR itemtypes.notforloan = 0)
333
                       AND itemnumber NOT IN (
335
                       AND items.itemnumber NOT IN (
334
                           SELECT itemnumber
336
                           SELECT itemnumber
335
                           FROM reserves
337
                           FROM reserves
336
                           WHERE biblionumber = ?
338
                           WHERE biblionumber = ?
337
                           AND itemnumber IS NOT NULL
339
                           AND itemnumber IS NOT NULL
338
                           AND (found IS NOT NULL OR priority = 0)
340
                           AND (found IS NOT NULL OR priority = 0)
339
                        )
341
                        )
340
                       AND items.biblionumber = ?";
342
                       AND items.biblionumber = ?
343
                       AND branchtransfers.itemnumber IS NULL ";
341
344
342
    my @params = ($biblionumber, $biblionumber);
345
    my @params = ($biblionumber, $biblionumber);
343
    if ($branches_to_use && @$branches_to_use) {
346
    if ($branches_to_use && @$branches_to_use) {
Lines 347-359 sub GetItemsAvailableToFillHoldRequestsForBib { Link Here
347
    my $sth = $dbh->prepare($items_query);
350
    my $sth = $dbh->prepare($items_query);
348
    $sth->execute(@params);
351
    $sth->execute(@params);
349
352
350
    my $itm = $sth->fetchall_arrayref({});
353
    my $items = $sth->fetchall_arrayref({});
351
    my @items = grep { ! scalar C4::Circulation::GetTransfers($_->{itemnumber}) } @$itm;
352
    return [ grep {
354
    return [ grep {
353
        my $rule = C4::Circulation::GetBranchItemRule($_->{homebranch}, $_->{itype});
355
        my $rule = C4::Circulation::GetBranchItemRule($_->{homebranch}, $_->{itype});
354
        $_->{holdallowed} = $rule->{holdallowed};
356
        $_->{holdallowed} = $rule->{holdallowed};
355
        $_->{hold_fulfillment_policy} = $rule->{hold_fulfillment_policy};
357
        $_->{hold_fulfillment_policy} = $rule->{hold_fulfillment_policy};
356
    } @items ];
358
    } @$items ];
357
}
359
}
358
360
359
=head2 _checkHoldPolicy
361
=head2 _checkHoldPolicy
360
- 

Return to bug 30580