View | Details | Raw Unified | Return to bug 9532
Collapse All | Expand All

(-)a/C4/Reserves.pm (-11 / +10 lines)
Lines 463-474 sub CanItemBeReserved{ Link Here
463
    my ($borrowernumber, $itemnumber) = @_;
463
    my ($borrowernumber, $itemnumber) = @_;
464
    
464
    
465
    my $dbh             = C4::Context->dbh;
465
    my $dbh             = C4::Context->dbh;
466
    my $ruleitemtype; # itemtype of the matching issuing rule
466
    my $allowedreserves = 0;
467
    my $allowedreserves = 0;
467
            
468
            
468
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
469
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
469
    my $itype         = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
470
    my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
470
471
471
    # we retrieve borrowers and items informations #
472
    # we retrieve borrowers and items informations
473
    # item->{itype} will come for biblioitems if necessery
472
    my $item     = GetItem($itemnumber);
474
    my $item     = GetItem($itemnumber);
473
    my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber);     
475
    my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber);     
474
    
476
    
Lines 494-501 sub CanItemBeReserved{ Link Here
494
                                ";
496
                                ";
495
    
497
    
496
    
498
    
497
    my $itemtype     = $item->{$itype};
498
    my $categorycode = $borrower->{categorycode};
499
    my $branchcode   = "";
499
    my $branchcode   = "";
500
    my $branchfield  = "reserves.branchcode";
500
    my $branchfield  = "reserves.branchcode";
501
    
501
    
Lines 508-532 sub CanItemBeReserved{ Link Here
508
    }
508
    }
509
    
509
    
510
    # we retrieve rights 
510
    # we retrieve rights 
511
    $sth->execute($categorycode, $itemtype, $branchcode);
511
    $sth->execute($borrower->{'categorycode'}, $item->{'itype'}, $branchcode);
512
    if(my $rights = $sth->fetchrow_hashref()){
512
    if(my $rights = $sth->fetchrow_hashref()){
513
        $itemtype        = $rights->{itemtype};
513
        $ruleitemtype    = $rights->{itemtype};
514
        $allowedreserves = $rights->{reservesallowed}; 
514
        $allowedreserves = $rights->{reservesallowed}; 
515
    }else{
515
    }else{
516
        $itemtype = '*';
516
        $ruleitemtype = '*';
517
    }
517
    }
518
    
518
    
519
    # we retrieve count
519
    # we retrieve count
520
    
520
    
521
    $querycount .= "AND $branchfield = ?";
521
    $querycount .= "AND $branchfield = ?";
522
    
522
    
523
    $querycount .= " AND $itype = ?" if ($itemtype ne "*");
523
    $querycount .= " AND $itemtypefield = ?" if ($ruleitemtype ne "*");
524
    my $sthcount = $dbh->prepare($querycount);
524
    my $sthcount = $dbh->prepare($querycount);
525
    
525
    
526
    if($itemtype eq "*"){
526
    if($ruleitemtype eq "*"){
527
        $sthcount->execute($borrowernumber, $branchcode);
527
        $sthcount->execute($borrowernumber, $branchcode);
528
    }else{
528
    }else{
529
        $sthcount->execute($borrowernumber, $branchcode, $itemtype);
529
        $sthcount->execute($borrowernumber, $branchcode, $ruleitemtype);
530
    }
530
    }
531
    
531
    
532
    my $reservecount = "0";
532
    my $reservecount = "0";
533
- 

Return to bug 9532