|
Lines 412-426
sub CanItemBeReserved {
Link Here
|
| 412 |
|
412 |
|
| 413 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
413 |
my $controlbranch = C4::Context->preference('ReservesControlBranch'); |
| 414 |
|
414 |
|
| 415 |
my $querycount = q{ |
|
|
| 416 |
SELECT count(*) AS count |
| 417 |
FROM reserves |
| 418 |
LEFT JOIN items USING (itemnumber) |
| 419 |
LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber) |
| 420 |
LEFT JOIN borrowers USING (borrowernumber) |
| 421 |
WHERE borrowernumber = ? |
| 422 |
}; |
| 423 |
|
| 424 |
my $reserves_control_branch; |
415 |
my $reserves_control_branch; |
| 425 |
my $branchfield = "reserves.branchcode"; |
416 |
my $branchfield = "reserves.branchcode"; |
| 426 |
|
417 |
|
|
Lines 482-520
sub CanItemBeReserved {
Link Here
|
| 482 |
return { status => 'tooManyReservesToday', limit => $holds_per_day } if $today_holds->count() >= $holds_per_day; |
473 |
return { status => 'tooManyReservesToday', limit => $holds_per_day } if $today_holds->count() >= $holds_per_day; |
| 483 |
} |
474 |
} |
| 484 |
|
475 |
|
| 485 |
# we retrieve count |
|
|
| 486 |
|
| 487 |
$querycount .= "AND ( $branchfield = ? OR $branchfield IS NULL )"; |
| 488 |
|
| 489 |
# If using item-level itypes, fall back to the record |
| 490 |
# level itemtype if the hold has no associated item |
| 491 |
$querycount .= |
| 492 |
C4::Context->preference('item-level_itypes') |
| 493 |
? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" |
| 494 |
: " AND biblioitems.itemtype = ?" |
| 495 |
if defined $ruleitemtype; |
| 496 |
|
| 497 |
my $sthcount = $dbh->prepare($querycount); |
| 498 |
|
| 499 |
if ( defined $ruleitemtype ) { |
| 500 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); |
| 501 |
} |
| 502 |
else { |
| 503 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch ); |
| 504 |
} |
| 505 |
|
| 506 |
my $reservecount = "0"; |
| 507 |
if ( my $rowcount = $sthcount->fetchrow_hashref() ) { |
| 508 |
$reservecount = $rowcount->{count}; |
| 509 |
} |
| 510 |
|
| 511 |
# we check if it's ok or not |
476 |
# we check if it's ok or not |
| 512 |
if ( defined $allowedreserves && $allowedreserves ne '' ){ |
477 |
if ( defined $allowedreserves && $allowedreserves ne '' ){ |
| 513 |
if( $allowedreserves == 0 ){ |
478 |
if( $allowedreserves == 0 ){ |
| 514 |
return { status => 'noReservesAllowed' }; |
479 |
return { status => 'noReservesAllowed' }; |
| 515 |
} |
480 |
} |
| 516 |
if ( !$params->{ignore_hold_counts} && $reservecount >= $allowedreserves ) { |
481 |
if ( !$params->{ignore_hold_counts} ) { |
| 517 |
return { status => 'tooManyReserves', limit => $allowedreserves }; |
482 |
# we retrieve count |
|
|
483 |
my $querycount = q{ |
| 484 |
SELECT count(*) AS count |
| 485 |
FROM reserves |
| 486 |
LEFT JOIN items USING (itemnumber) |
| 487 |
LEFT JOIN biblioitems ON (reserves.biblionumber=biblioitems.biblionumber) |
| 488 |
LEFT JOIN borrowers USING (borrowernumber) |
| 489 |
WHERE borrowernumber = ? |
| 490 |
}; |
| 491 |
$querycount .= "AND ( $branchfield = ? OR $branchfield IS NULL )"; |
| 492 |
|
| 493 |
# If using item-level itypes, fall back to the record |
| 494 |
# level itemtype if the hold has no associated item |
| 495 |
$querycount .= |
| 496 |
C4::Context->preference('item-level_itypes') |
| 497 |
? " AND COALESCE( items.itype, biblioitems.itemtype ) = ?" |
| 498 |
: " AND biblioitems.itemtype = ?" |
| 499 |
if defined $ruleitemtype; |
| 500 |
|
| 501 |
my $sthcount = $dbh->prepare($querycount); |
| 502 |
|
| 503 |
if ( defined $ruleitemtype ) { |
| 504 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch, $ruleitemtype ); |
| 505 |
} |
| 506 |
else { |
| 507 |
$sthcount->execute( $patron->borrowernumber, $reserves_control_branch ); |
| 508 |
} |
| 509 |
|
| 510 |
my $reservecount = "0"; |
| 511 |
if ( my $rowcount = $sthcount->fetchrow_hashref() ) { |
| 512 |
$reservecount = $rowcount->{count}; |
| 513 |
} |
| 514 |
|
| 515 |
return { status => 'tooManyReserves', limit => $allowedreserves } if $reservecount >= $allowedreserves; |
| 518 |
} |
516 |
} |
| 519 |
} |
517 |
} |
| 520 |
|
518 |
|
| 521 |
- |
|
|