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

(-)a/C4/HoldsQueue.pm (-7 / +8 lines)
Lines 24-30 use warnings; Link Here
24
24
25
use C4::Context;
25
use C4::Context;
26
use C4::Search;
26
use C4::Search;
27
use C4::Circulation qw( GetTransfers GetBranchItemRule );
27
use C4::Circulation qw( GetBranchItemRule );
28
use Koha::DateUtils qw( dt_from_string );
28
use Koha::DateUtils qw( dt_from_string );
29
use Koha::Items;
29
use Koha::Items;
30
use Koha::Patrons;
30
use Koha::Patrons;
Lines 321-327 sub GetItemsAvailableToFillHoldRequestsForBib { Link Here
321
    my ($biblionumber, $branches_to_use) = @_;
321
    my ($biblionumber, $branches_to_use) = @_;
322
322
323
    my $dbh = C4::Context->dbh;
323
    my $dbh = C4::Context->dbh;
324
    my $items_query = "SELECT itemnumber, homebranch, holdingbranch, itemtypes.itemtype AS itype
324
    my $items_query = "SELECT items.itemnumber, homebranch, holdingbranch, itemtypes.itemtype AS itype
325
                       FROM items ";
325
                       FROM items ";
326
326
327
    if (C4::Context->preference('item-level_itypes')) {
327
    if (C4::Context->preference('item-level_itypes')) {
Lines 330-343 sub GetItemsAvailableToFillHoldRequestsForBib { Link Here
330
        $items_query .=   "JOIN biblioitems USING (biblioitemnumber)
330
        $items_query .=   "JOIN biblioitems USING (biblioitemnumber)
331
                           LEFT JOIN itemtypes USING (itemtype) ";
331
                           LEFT JOIN itemtypes USING (itemtype) ";
332
    }
332
    }
333
    $items_query .=   "WHERE items.notforloan = 0
333
    $items_query .=  " LEFT JOIN branchtransfers ON (items.itemnumber = branchtransfers.itemnumber)";
334
    $items_query .=  " WHERE items.notforloan = 0
334
                       AND holdingbranch IS NOT NULL
335
                       AND holdingbranch IS NOT NULL
335
                       AND itemlost = 0
336
                       AND itemlost = 0
336
                       AND withdrawn = 0";
337
                       AND withdrawn = 0";
338
    $items_query .= "  AND branchtransfers.datearrived IS NULL
339
                       AND branchtransfers.datecancelled IS NULL";
337
    $items_query .= "  AND damaged = 0" unless C4::Context->preference('AllowHoldsOnDamagedItems');
340
    $items_query .= "  AND damaged = 0" unless C4::Context->preference('AllowHoldsOnDamagedItems');
338
    $items_query .= "  AND items.onloan IS NULL
341
    $items_query .= "  AND items.onloan IS NULL
339
                       AND (itemtypes.notforloan IS NULL OR itemtypes.notforloan = 0)
342
                       AND (itemtypes.notforloan IS NULL OR itemtypes.notforloan = 0)
340
                       AND itemnumber NOT IN (
343
                       AND items.itemnumber NOT IN (
341
                           SELECT itemnumber
344
                           SELECT itemnumber
342
                           FROM reserves
345
                           FROM reserves
343
                           WHERE biblionumber = ?
346
                           WHERE biblionumber = ?
Lines 355-366 sub GetItemsAvailableToFillHoldRequestsForBib { Link Here
355
    $sth->execute(@params);
358
    $sth->execute(@params);
356
359
357
    my $itm = $sth->fetchall_arrayref({});
360
    my $itm = $sth->fetchall_arrayref({});
358
    my @items = grep { ! scalar GetTransfers($_->{itemnumber}) } @$itm;
359
    return [ grep {
361
    return [ grep {
360
        my $rule = GetBranchItemRule($_->{homebranch}, $_->{itype});
362
        my $rule = GetBranchItemRule($_->{homebranch}, $_->{itype});
361
        $_->{holdallowed} = $rule->{holdallowed};
363
        $_->{holdallowed} = $rule->{holdallowed};
362
        $_->{hold_fulfillment_policy} = $rule->{hold_fulfillment_policy};
364
        $_->{hold_fulfillment_policy} = $rule->{hold_fulfillment_policy};
363
    } @items ];
365
    } @{$itm} ];
364
}
366
}
365
367
366
=head2 _checkHoldPolicy
368
=head2 _checkHoldPolicy
367
- 

Return to bug 24295