diff --git a/circ/circulation.pl b/circ/circulation.pl
index 968470e6f1..75dc267041 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -785,6 +785,7 @@ $template->param(
patron_lists_count => $patron_lists_count,
override_high_holds => $override_high_holds,
nopermission => scalar $query->param('nopermission'),
+ noguarantor => scalar $query->param('noguarantor'),
autoswitched => $autoswitched,
logged_in_user => $logged_in_user,
);
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
index 6947a1cd19..be0237ae5d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ -109,6 +109,10 @@
Staff members are not allowed to discharge borrowers, nor borrowers to request a discharge.
[% END %]
+ [% IF ( noguarantor ) %]
+ This patron could not be renewed: they need a guarantor.
+ [% END %]
+
[% IF is_anonymous %]
This is the anonymous patron, so circulation is disabled.
[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
index f0d61473a7..3e224aabde 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
@@ -76,6 +76,10 @@
Unable to delete patron
Insufficient privileges.
[% END %]
+ [% IF ( error == 'CANT_RENEW_CHILD_WITHOUT_GUARANTOR' ) %]
+ Unable to renew patron
+ They must have a guarantor
+ [% END %]
[% END %]
diff --git a/members/setstatus.pl b/members/setstatus.pl
index d789291370..d05498b83f 100755
--- a/members/setstatus.pl
+++ b/members/setstatus.pl
@@ -23,6 +23,7 @@
# along with Koha; if not, see .
use Modern::Perl;
+use Try::Tiny;
use CGI qw ( -utf8 );
use C4::Auth qw( checkauth );
@@ -45,6 +46,8 @@ my $dateexpiry;
my $logged_in_user = Koha::Patrons->find( { userid => $loggedinuserid } );
my $patron = Koha::Patrons->find($borrowernumber);
+my $cannot_renew = '0';
+
# Ideally we should display a warning on the interface if the logged in user is
# not allowed to modify this patron.
# But a librarian is not supposed to hack the system
@@ -52,7 +55,15 @@ if ( $logged_in_user->can_see_patron_infos($patron) ) {
if ( $reregistration eq 'y' ) {
# re-reregistration function to automatic calcul of date expiry
- $dateexpiry = $patron->renew_account;
+ try {
+ $dateexpiry = $patron->renew_account;
+ } catch {
+ if ( ref($_) eq 'Koha::Exceptions::Patron::Relationship::NoGuarantor' ) {
+ $cannot_renew = '1';
+ } else {
+ $_->rethrow();
+ }
+ }
} else {
my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
$sth->execute( $status, $borrowernumber );
@@ -61,13 +72,19 @@ if ( $logged_in_user->can_see_patron_infos($patron) ) {
}
if ( $destination eq "circ" ) {
- if ($dateexpiry) {
+ if ($cannot_renew) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber&noguarantor=1");
+ } elsif ($dateexpiry) {
print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber&was_renewed=1");
} else {
print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
}
} else {
- if ($dateexpiry) {
+ if ($cannot_renew) {
+ print $input->redirect(
+ "/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber&error=CANT_RENEW_CHILD_WITHOUT_GUARANTOR"
+ );
+ } elsif ($dateexpiry) {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber&was_renewed=1");
} else {
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");