diff --git a/circ/circulation.pl b/circ/circulation.pl
index e4c5424564..0a56f80d7c 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -634,6 +634,7 @@ $template->param(
canned_bor_notes_loop => $canned_notes,
debarments => GetDebarments({ borrowernumber => $borrowernumber }),
todaysdate => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ),
+ nopermission => $query->param('nopermission'),
);
output_html_with_http_headers $query, $cookie, $template->output;
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 9e22ed7050..0c1f95b272 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ -117,7 +117,6 @@ $(document).ready(function() {
$(':radio', this).attr('checked', 'true')
}
});
-
});
//]]>
@@ -207,6 +206,10 @@ $(document).ready(function() {
The patron has unpaid charges for holds, rentals etc of [% alert.OTHER_CHARGES %]
[% END %]
+[% IF ( nopermission ) %]
+ Staff members are not allowed to discharge borrowers, nor borrowers to request a discharge.
+[% END %]
+
[% IF ( NEEDSCONFIRMATION ) %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt
index d8f5648c81..23f088dca3 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-discharge.tt
@@ -23,6 +23,9 @@
Discharge
+ [% IF not(Koha.Preference("useDischarge")) %]
+ Discharges have not been enabled. Please contact the library.
+ [% ELSE %]
[% FOR message IN messages %]
[% IF message.code == "unable_to_generate_pdf" %]
@@ -46,6 +49,7 @@
Warning: This request is only valid if you are in good standing with the library. Once the application is made, you can not borrow library materials.
Ask for a discharge
[% END %]
+ [% END %]
diff --git a/members/discharge.pl b/members/discharge.pl
index 466c119773..44f141d819 100755
--- a/members/discharge.pl
+++ b/members/discharge.pl
@@ -41,6 +41,7 @@ use Koha::Borrower::Discharge;
use Koha::DateUtils;
my $input = new CGI;
+
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user({
template_name => 'members/discharge.tt',
query => $input,
@@ -49,7 +50,13 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user({
flagsrequired => { 'borrowers' => '*' },
});
-my $borrowernumber;
+my $borrowernumber = $input->param('borrowernumber');
+
+unless ( C4::Context->preference('useDischarge') ) {
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber&nopermission=1");
+ exit;
+}
+
my $data;
if ( $input->param('borrowernumber') ) {
$borrowernumber = $input->param('borrowernumber');