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