@@ -, +, @@ - Choose a branch, a borrower category and an item type, for example 'NYC', 'CHILD' and 'DVD' - Set an issuing rule for 'NYC', CHILD' and 'DVD' with 'Holds allowed' on 10 - Set an issuing rule for 'NYC', CHILD' and all item types with 'Holds allowed' on 0 - Choose an item of a biblio with itemtype 'DVD', that can be reserved, with 'NYC' as homebranch - Choose a borrower with category 'CHILD' - try to reverse the item for the borrower --- C4/Reserves.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -419,12 +419,14 @@ sub CanItemBeReserved{ my ($borrowernumber, $itemnumber) = @_; my $dbh = C4::Context->dbh; + my $ruleitemtype; # itemtype of the matching issuing rule my $allowedreserves = 0; my $controlbranch = C4::Context->preference('ReservesControlBranch'); - my $itype = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype"; + my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype"; - # we retrieve borrowers and items informations # + # we retrieve borrowers and items informations + # item->{itype} will come for biblioitems if necessery my $item = GetItem($itemnumber); my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); @@ -450,8 +452,6 @@ sub CanItemBeReserved{ "; - my $itemtype = $item->{$itype}; - my $categorycode = $borrower->{categorycode}; my $branchcode = ""; my $branchfield = "reserves.branchcode"; @@ -464,25 +464,25 @@ sub CanItemBeReserved{ } # we retrieve rights - $sth->execute($categorycode, $itemtype, $branchcode); + $sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode); if(my $rights = $sth->fetchrow_hashref()){ - $itemtype = $rights->{itemtype}; + $ruleitemtype = $rights->{itemtype}; $allowedreserves = $rights->{reservesallowed}; }else{ - $itemtype = '*'; + $ruleitemtype = '*'; } # we retrieve count $querycount .= "AND $branchfield = ?"; - $querycount .= " AND $itype = ?" if ($itemtype ne "*"); + $querycount .= " AND $itemtypefield = ?" if ($ruleitemtype ne "*"); my $sthcount = $dbh->prepare($querycount); - if($itemtype eq "*"){ + if($ruleitemtype eq "*"){ $sthcount->execute($borrowernumber, $branchcode); }else{ - $sthcount->execute($borrowernumber, $branchcode, $itemtype); + $sthcount->execute($borrowernumber, $branchcode, $ruleitemtype); } my $reservecount = "0"; --