Lines 347-355
sub CanBookBeReserved{
Link Here
|
347 |
$canReserve = &CanItemBeReserved($borrowernumber, $itemnumber, $branchcode, $params) |
347 |
$canReserve = &CanItemBeReserved($borrowernumber, $itemnumber, $branchcode, $params) |
348 |
if ($canReserve->{status} eq 'OK') { #We can reserve this Item! } |
348 |
if ($canReserve->{status} eq 'OK') { #We can reserve this Item! } |
349 |
|
349 |
|
350 |
current params are 'ignore_found_holds' - if true holds that have been trapped are not counted |
350 |
current params are: |
|
|
351 |
'ignore_found_holds' - if true holds that have been trapped are not counted |
351 |
toward the patron limit, used by checkHighHolds to avoid counting the hold we will fill with the |
352 |
toward the patron limit, used by checkHighHolds to avoid counting the hold we will fill with the |
352 |
current checkout against the high holds threshold |
353 |
current checkout against the high holds threshold |
|
|
354 |
'ignore_hold_counts' - we use this routine to check if an item can fill a hold - on this case we |
355 |
should not check if there are too many holds as we only csre about reservability |
353 |
|
356 |
|
354 |
@RETURNS { status => OK }, if the Item can be reserved. |
357 |
@RETURNS { status => OK }, if the Item can be reserved. |
355 |
{ status => ageRestricted }, if the Item is age restricted for this borrower. |
358 |
{ status => ageRestricted }, if the Item is age restricted for this borrower. |
Lines 454-460
sub CanItemBeReserved {
Link Here
|
454 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
457 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
455 |
|
458 |
|
456 |
my $holds = Koha::Holds->search($search_params); |
459 |
my $holds = Koha::Holds->search($search_params); |
457 |
if ( defined $holds_per_record && $holds_per_record ne '' |
460 |
if (!$params->{ignore_hold_counts} && defined $holds_per_record && $holds_per_record ne '' |
458 |
&& $holds->count() >= $holds_per_record ) { |
461 |
&& $holds->count() >= $holds_per_record ) { |
459 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
462 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; |
460 |
} |
463 |
} |
Lines 464-470
sub CanItemBeReserved {
Link Here
|
464 |
reservedate => dt_from_string->date |
467 |
reservedate => dt_from_string->date |
465 |
}); |
468 |
}); |
466 |
|
469 |
|
467 |
if ( defined $holds_per_day && $holds_per_day ne '' |
470 |
if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '' |
468 |
&& $today_holds->count() >= $holds_per_day ) |
471 |
&& $today_holds->count() >= $holds_per_day ) |
469 |
{ |
472 |
{ |
470 |
return { status => 'tooManyReservesToday', limit => $holds_per_day }; |
473 |
return { status => 'tooManyReservesToday', limit => $holds_per_day }; |
Lines 497-504
sub CanItemBeReserved {
Link Here
|
497 |
} |
500 |
} |
498 |
|
501 |
|
499 |
# we check if it's ok or not |
502 |
# we check if it's ok or not |
500 |
if ( defined $allowedreserves && $allowedreserves ne '' |
503 |
if ( defined $allowedreserves && $allowedreserves ne '' |
501 |
&& $reservecount >= $allowedreserves ) { |
504 |
&& $reservecount >= $allowedreserves && (!$params->{ignore_hold_counts} || $allowedreserves == 0 ) ) { |
502 |
return { status => 'tooManyReserves', limit => $allowedreserves }; |
505 |
return { status => 'tooManyReserves', limit => $allowedreserves }; |
503 |
} |
506 |
} |
504 |
|
507 |
|
Lines 510-516
sub CanItemBeReserved {
Link Here
|
510 |
rule_name => 'max_holds', |
513 |
rule_name => 'max_holds', |
511 |
} |
514 |
} |
512 |
); |
515 |
); |
513 |
if ( $rule && defined( $rule->rule_value ) && $rule->rule_value ne '' ) { |
516 |
if (!$params->{ignore_hold_counts} && $rule && defined( $rule->rule_value ) && $rule->rule_value ne '' ) { |
514 |
my $total_holds_count = Koha::Holds->search( |
517 |
my $total_holds_count = Koha::Holds->search( |
515 |
{ |
518 |
{ |
516 |
borrowernumber => $borrower->{borrowernumber} |
519 |
borrowernumber => $borrower->{borrowernumber} |