Lines 419-430
sub CanItemBeReserved{
Link Here
|
419 |
my ($borrowernumber, $itemnumber) = @_; |
419 |
my ($borrowernumber, $itemnumber) = @_; |
420 |
|
420 |
|
421 |
my $dbh = C4::Context->dbh; |
421 |
my $dbh = C4::Context->dbh; |
|
|
422 |
my $ruleitemtype; # itemtype of the matching issuing rule |
422 |
my $allowedreserves = 0; |
423 |
my $allowedreserves = 0; |
423 |
|
424 |
|
424 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
425 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
425 |
my $itype = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype"; |
426 |
my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype"; |
426 |
|
427 |
|
427 |
# we retrieve borrowers and items informations # |
428 |
# we retrieve borrowers and items informations |
|
|
429 |
# item->{itype} will come for biblioitems if necessery |
428 |
my $item = GetItem($itemnumber); |
430 |
my $item = GetItem($itemnumber); |
429 |
my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); |
431 |
my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber); |
430 |
|
432 |
|
Lines 450-457
sub CanItemBeReserved{
Link Here
|
450 |
"; |
452 |
"; |
451 |
|
453 |
|
452 |
|
454 |
|
453 |
my $itemtype = $item->{$itype}; |
|
|
454 |
my $categorycode = $borrower->{categorycode}; |
455 |
my $branchcode = ""; |
455 |
my $branchcode = ""; |
456 |
my $branchfield = "reserves.branchcode"; |
456 |
my $branchfield = "reserves.branchcode"; |
457 |
|
457 |
|
Lines 464-488
sub CanItemBeReserved{
Link Here
|
464 |
} |
464 |
} |
465 |
|
465 |
|
466 |
# we retrieve rights |
466 |
# we retrieve rights |
467 |
$sth->execute($categorycode, $itemtype, $branchcode); |
467 |
$sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode); |
468 |
if(my $rights = $sth->fetchrow_hashref()){ |
468 |
if(my $rights = $sth->fetchrow_hashref()){ |
469 |
$itemtype = $rights->{itemtype}; |
469 |
$ruleitemtype = $rights->{itemtype}; |
470 |
$allowedreserves = $rights->{reservesallowed}; |
470 |
$allowedreserves = $rights->{reservesallowed}; |
471 |
}else{ |
471 |
}else{ |
472 |
$itemtype = '*'; |
472 |
$ruleitemtype = '*'; |
473 |
} |
473 |
} |
474 |
|
474 |
|
475 |
# we retrieve count |
475 |
# we retrieve count |
476 |
|
476 |
|
477 |
$querycount .= "AND $branchfield = ?"; |
477 |
$querycount .= "AND $branchfield = ?"; |
478 |
|
478 |
|
479 |
$querycount .= " AND $itype = ?" if ($itemtype ne "*"); |
479 |
$querycount .= " AND $itemtypefield = ?" if ($ruleitemtype ne "*"); |
480 |
my $sthcount = $dbh->prepare($querycount); |
480 |
my $sthcount = $dbh->prepare($querycount); |
481 |
|
481 |
|
482 |
if($itemtype eq "*"){ |
482 |
if($ruleitemtype eq "*"){ |
483 |
$sthcount->execute($borrowernumber, $branchcode); |
483 |
$sthcount->execute($borrowernumber, $branchcode); |
484 |
}else{ |
484 |
}else{ |
485 |
$sthcount->execute($borrowernumber, $branchcode, $itemtype); |
485 |
$sthcount->execute($borrowernumber, $branchcode, $ruleitemtype); |
486 |
} |
486 |
} |
487 |
|
487 |
|
488 |
my $reservecount = "0"; |
488 |
my $reservecount = "0"; |
489 |
- |
|
|