bug 2527: avoid targeting of items on hold shelf

SQL fix to properly ensure that if an item is on
the hold shelf, it will not be used for request
targeting, which applies only to items that are
not already on the hold shelf.

Prior to this fix, when checking out an item on the
hold shelf that fills patron A's hold request, it
was possible for that request to not be marked as
filled if another patron had an item-level request
on the item; the second patron's request was
incorrectly targeted by that item.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
Galen Charlton 2008-08-15 16:38:22 -05:00
parent daa2a04223
commit 8588c7d79e
1 changed files with 9 additions and 5 deletions

View File

@ -162,18 +162,22 @@ sub GetItemsAvailableToFillHoldRequestsForBib {
$items_query .= "JOIN biblioitems USING (biblioitemnumber)
LEFT JOIN itemtypes USING (itemtype) ";
}
$items_query .= "LEFT JOIN reserves USING (itemnumber)
WHERE items.notforloan = 0
$items_query .= "WHERE items.notforloan = 0
AND holdingbranch IS NOT NULL
AND itemlost = 0
AND wthdrawn = 0
AND items.onloan IS NULL
AND (itemtypes.notforloan IS NULL OR itemtypes.notforloan = 0)
AND (priority IS NULL OR priority > 0)
AND found IS NULL
AND itemnumber NOT IN (
SELECT itemnumber
FROM reserves
WHERE biblionumber = ?
AND itemnumber IS NOT NULL
AND (found IS NOT NULL OR priority = 0)
)
AND biblionumber = ?";
my $sth = $dbh->prepare($items_query);
$sth->execute($biblionumber);
$sth->execute($biblionumber, $biblionumber);
my $items = $sth->fetchall_arrayref({});
return [ grep { my @transfers = GetTransfers($_->{itemnumber}); $#transfers == -1; } @$items ];