From 8c56d440d3f2404676ea7e1007f6d4b94d15aaac 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. --- Koha/Patron.pm | 9 +++++++++ koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 4 ++++ opac/opac-reserve.pl | 2 ++ 3 files changed, 15 insertions(+) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index c0ef6e292c..f7d79907d5 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1494,6 +1494,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