|
Lines 461-483
sub CanItemBeReserved {
Link Here
|
| 461 |
}; |
461 |
}; |
| 462 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
462 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
| 463 |
|
463 |
|
| 464 |
my $holds = Koha::Holds->search($search_params); |
464 |
my $holds_count = Koha::Holds->count_holds($search_params); |
| 465 |
if ( defined $holds_per_record && $holds_per_record ne '' ){ |
465 |
if ( defined $holds_per_record && $holds_per_record ne '' ){ |
| 466 |
if ( $holds_per_record == 0 ) { |
466 |
if ( $holds_per_record == 0 ) { |
| 467 |
return { status => "noReservesAllowed" }; |
467 |
return { status => "noReservesAllowed" }; |
| 468 |
} |
468 |
} |
| 469 |
if ( !$params->{ignore_hold_counts} && $holds->count() >= $holds_per_record ) { |
469 |
if ( !$params->{ignore_hold_counts} && $holds_count >= $holds_per_record ) { |
| 470 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
470 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
| 471 |
} |
471 |
} |
| 472 |
} |
472 |
} |
| 473 |
|
473 |
|
| 474 |
my $today_holds = Koha::Holds->search({ |
474 |
my $today_holds_count = Koha::Holds->count_holds({ |
| 475 |
borrowernumber => $borrowernumber, |
475 |
borrowernumber => $borrowernumber, |
| 476 |
reservedate => dt_from_string->date |
476 |
reservedate => dt_from_string->date |
| 477 |
}); |
477 |
}); |
| 478 |
|
478 |
|
| 479 |
if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '' |
479 |
if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '' |
| 480 |
&& $today_holds->count() >= $holds_per_day ) |
480 |
&& $today_holds_count >= $holds_per_day ) |
| 481 |
{ |
481 |
{ |
| 482 |
return { status => 'tooManyReservesToday', limit => $holds_per_day }; |
482 |
return { status => 'tooManyReservesToday', limit => $holds_per_day }; |
| 483 |
} |
483 |
} |