From d8f5f216c39dd5acd36da2baab518cf44339192b Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Sun, 1 Mar 2026 20:38:28 +0000 Subject: [PATCH] Bug 41960: Add option to block placing hold when patron has overdues Some libraries may want to block the possibility of placing hold when a patron has overdues. Currently, a patron is blocked when they has mode than maxoutstanding fines or when the account has been debarred (e.g. as a result of having overdues). But there is no possibility to directly block reserves in case of an overdue. Test plan: ========== 1. Check out any book to any user. 2. In ktd --dbshell, change date_due to an earlier date. 3. In a private window, log in as that user (change their password first) and place an order for another book. You will be able to do this despite the overdue items. 4. Apply the patch, updatedatabase, restart_all. 5. Set OverduesBlockHolds to 'Block'. 6. Repeat step 3. You should get the message "Sorry, you cannot place holds. You are not permitted to place holds while you have overdue items on your account." 7. Change OverduesBlockHolds to 'Don't block'. 8. Repeat step 3. You should be able to place an order. Signed-off-by: Roman Dolny --- Koha/Patron.pm | 11 +++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 4 ++++ opac/opac-reserve.pl | 2 ++ 3 files changed, 17 insertions(+) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index c0ef6e292c..7239d95a2d 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1404,6 +1404,8 @@ The following error message codes may be returned: =item * C - Patron has reached the maximum number of allowed holds +=item * C - Patron has overdue items + =back Error messages may include additional payload data with relevant details @@ -1494,6 +1496,15 @@ sub can_place_holds { } } + # check overdues + unless ( $overrides->{overdues} ) { + if ( C4::Context->preference("OverduesBlockHolds") eq 'block' && $self->has_overdues ) { + $result->set_value(0); + $result->add_message( { message => 'overdues', type => 'error' } ); + return $result unless $no_short_circuit; + } + } + return $result; } diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index 630cb96a63..97b1db9a13 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -67,6 +67,10 @@
  • Sorry, you cannot place more than [% too_many_reserves | html %] holds.
  • [% END %] + [% IF ( overdues ) %] +
  • You are not permitted to place holds while you have overdue items on your account.
  • + [% END %] + [% IF ( bad_biblionumber ) %]
  • ERROR: No record found for record ID [% bad_biblionumber | html %].
  • [% END %] diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 892de210c2..5630f9ffc9 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -138,6 +138,8 @@ if ( !$can_place_holds ) { ); } elsif ( $msg->message eq 'hold_limit' ) { $template->param( too_many_reserves => $msg->{payload}->{total_holds} ); + } elsif ( $msg->message eq 'overdues' ) { + $template->param( overdues => 1 ); } else { Koha::Logger->get->warn( sprintf( "Unhandled 'can_place_holds' error code: %s", $msg->message ) ); } -- 2.39.5