-
- $rightsquery .= " ORDER BY categorycode DESC, itemtype DESC, branchcode DESC";
-
- my $sthrights = $dbh->prepare($rightsquery);
- $sthrights->execute(@args);
-
- if(my $row = $sthrights->fetchrow_hashref()){
- $reservesrights = $row->{reservesallowed};
- }
-
- @args = ();
- # we count how many reserves the borrower have
- my $countquery = "SELECT count(*) as count
- FROM reserves
- LEFT JOIN items USING (itemnumber)
- LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber)
- LEFT JOIN borrowers USING (borrowernumber)
- WHERE borrowernumber = ?
- ";
- push @args, $borrowernumber;
-
- if(not $itype){
- $countquery .= "AND itemtype = ?";
- push @args, $biblio->{itemtype};
- }
-
- if($controlbranch eq "PatronLibrary"){
- $countquery .= " AND borrowers.branchcode = ? ";
- push @args, $borrower->{branchcode};
- }
-
- my $sthcount = $dbh->prepare($countquery);
- $sthcount->execute(@args);
-
- if(my $row = $sthcount->fetchrow_hashref()){
- $reservescount = $row->{count};
- }
-
- if($reservescount < $reservesrights){
- return 1;
- }else{
- return 0;
- }
-