From d545f9badfd97795273b8ffaf830c73fe8c40d2c Mon Sep 17 00:00:00 2001 From: Ian Walls Date: Thu, 3 Jun 2010 22:21:13 +0000 Subject: [PATCH] Fixes bug 4850: CheckReserves not respecting BranchItemRules CheckReserves now consults GetBranchItemRules to see if the item has any circulation policies against it's being held. If so, CheckReserves returns ( 0, 0 ). Content-Type: text/plain; charset="utf-8" Note that this only checks for "No Holds Allowed"; options for "From Home Library" and "From Any Library" are not differentiated by this patch. --- C4/Reserves.pm | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 65b97dd..51e4ab3 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -824,15 +824,18 @@ sub CheckReserves { my ( $item, $barcode ) = @_; my $dbh = C4::Context->dbh; my $sth; + my $item_type_control = (C4::Context->preference('item-level_itypes')) ? "items.itype" : "biblioitems.itemtype"; my $select = " SELECT items.biblionumber, items.biblioitemnumber, itemtypes.notforloan, items.notforloan AS itemnotforloan, - items.itemnumber + items.itemnumber, + items.homebranch, + $item_type_control FROM items LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber - LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype + LEFT JOIN itemtypes ON $item_type_control = itemtypes.itemtype "; if ($item) { @@ -844,7 +847,7 @@ sub CheckReserves { $sth->execute($barcode); } # note: we get the itemnumber because we might have started w/ just the barcode. Now we know for sure we have it. - my ( $biblio, $bibitem, $notforloan_per_itemtype, $notforloan_per_item, $itemnumber ) = $sth->fetchrow_array; + my ( $biblio, $bibitem, $notforloan_per_itemtype, $notforloan_per_item, $itemnumber, $homebranch, $itemtype ) = $sth->fetchrow_array; return ( 0, 0 ) unless $itemnumber; # bail if we got nothing. @@ -852,6 +855,10 @@ sub CheckReserves { # execpt where items.notforloan < 0 : This indicates the item is holdable. return ( 0, 0 ) if ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype; + # if circulation policies say "No Holds Allowed" on this item, it cannot be reserved + my $branchitemrule = C4::Circulation::GetBranchItemRule($homebranch, $itemtype); + return ( 0, 0 ) unless ($branchitemrule->{'holdallowed'}); + # Find this item in the reserves my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber ); -- 1.5.6.5