Bug 38847: Fix error when renewing an expired child patron without a guarantor
This fixes an internal server error when renewing an expired
child patron without a guarantor, when the ChildNeedsGuarantor
is set to "must have".
Test plan:
1. Create or edit a child patron:
- Don't add a guarantor.
- Set the "Expiry date" to a date in the past.
2. Set the ChildNeedsGuarantor system preference to "must have".
3. Refresh or view the patron's check out or details page, and
select the "Renew" link under the attention heading -
this generates an internal server error message.
4. Apply patch.
5. Repeat step 3, you will now get a standard error message
"This patron could not be renewed: they need a guarantor."
6. Add a guarantor for the patron.
7. Repeat step 3, and click "Renew" - the patron is now renewed.
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit b65eb561e9)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
e2b344eba5
commit
43843b47df
|
|
@ -786,6 +786,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,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@
|
|||
<div class="alert alert-warning">Staff members are not allowed to discharge borrowers, nor borrowers to request a discharge.</div>
|
||||
[% END %]
|
||||
|
||||
[% IF ( noguarantor ) %]
|
||||
<div class="alert alert-warning">This patron could not be renewed: they need a guarantor.</div>
|
||||
[% END %]
|
||||
|
||||
[% IF is_anonymous %]
|
||||
<div class="alert alert-warning">This is the anonymous patron, so circulation is disabled.</div>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -81,6 +81,10 @@
|
|||
<h3>Unable to delete patron</h3>
|
||||
<p>Insufficient privileges.</p>
|
||||
[% END %]
|
||||
[% IF ( error == 'CANT_RENEW_CHILD_WITHOUT_GUARANTOR' ) %]
|
||||
<h3>Unable to renew patron</h3>
|
||||
<p>They must have a guarantor</p>
|
||||
[% END %]
|
||||
</div>
|
||||
[% END %]
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
use Try::Tiny;
|
||||
|
||||
use CGI qw ( -utf8 );
|
||||
use C4::Auth qw( checkauth );
|
||||
|
|
@ -47,13 +48,23 @@ 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
|
||||
if ( $logged_in_user->can_see_patron_infos($patron) ) {
|
||||
if ( $reregistration eq 'y' ) {
|
||||
# re-reregistration function to automatic calcul of date expiry
|
||||
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 );
|
||||
|
|
@ -62,13 +73,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");
|
||||
|
|
|
|||
Loading…
Reference in New Issue