Lines 23-29
use strict;
Link Here
|
23 |
use warnings; |
23 |
use warnings; |
24 |
|
24 |
|
25 |
use C4::Context; |
25 |
use C4::Context; |
26 |
use C4::Circulation qw( GetTransfers GetBranchItemRule ); |
26 |
use C4::Circulation qw( GetBranchItemRule ); |
27 |
use Koha::DateUtils qw( dt_from_string ); |
27 |
use Koha::DateUtils qw( dt_from_string ); |
28 |
use Koha::Items; |
28 |
use Koha::Items; |
29 |
use Koha::Patrons; |
29 |
use Koha::Patrons; |
Lines 314-320
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 |
|
319 |
|
320 |
if (C4::Context->preference('item-level_itypes')) { |
320 |
if (C4::Context->preference('item-level_itypes')) { |
Lines 323-336
sub GetItemsAvailableToFillHoldRequestsForBib {
Link Here
|
323 |
$items_query .= "JOIN biblioitems USING (biblioitemnumber) |
323 |
$items_query .= "JOIN biblioitems USING (biblioitemnumber) |
324 |
LEFT JOIN itemtypes USING (itemtype) "; |
324 |
LEFT JOIN itemtypes USING (itemtype) "; |
325 |
} |
325 |
} |
326 |
$items_query .= "WHERE items.notforloan = 0 |
326 |
$items_query .= " LEFT JOIN branchtransfers ON (items.itemnumber = branchtransfers.itemnumber)"; |
|
|
327 |
$items_query .= " WHERE items.notforloan = 0 |
327 |
AND holdingbranch IS NOT NULL |
328 |
AND holdingbranch IS NOT NULL |
328 |
AND itemlost = 0 |
329 |
AND itemlost = 0 |
329 |
AND withdrawn = 0"; |
330 |
AND withdrawn = 0"; |
|
|
331 |
$items_query .= " AND branchtransfers.datearrived IS NULL |
332 |
AND branchtransfers.datecancelled IS NULL"; |
330 |
$items_query .= " AND damaged = 0" unless C4::Context->preference('AllowHoldsOnDamagedItems'); |
333 |
$items_query .= " AND damaged = 0" unless C4::Context->preference('AllowHoldsOnDamagedItems'); |
331 |
$items_query .= " AND items.onloan IS NULL |
334 |
$items_query .= " AND items.onloan IS NULL |
332 |
AND (itemtypes.notforloan IS NULL OR itemtypes.notforloan = 0) |
335 |
AND (itemtypes.notforloan IS NULL OR itemtypes.notforloan = 0) |
333 |
AND itemnumber NOT IN ( |
336 |
AND items.itemnumber NOT IN ( |
334 |
SELECT itemnumber |
337 |
SELECT itemnumber |
335 |
FROM reserves |
338 |
FROM reserves |
336 |
WHERE biblionumber = ? |
339 |
WHERE biblionumber = ? |
Lines 348-359
sub GetItemsAvailableToFillHoldRequestsForBib {
Link Here
|
348 |
$sth->execute(@params); |
351 |
$sth->execute(@params); |
349 |
|
352 |
|
350 |
my $itm = $sth->fetchall_arrayref({}); |
353 |
my $itm = $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 |
} @{$itm} ]; |
357 |
} |
359 |
} |
358 |
|
360 |
|
359 |
=head2 _checkHoldPolicy |
361 |
=head2 _checkHoldPolicy |
360 |
- |
|
|