From 58bb22d95c5763725a25d914860f7650b46e6733 Mon Sep 17 00:00:00 2001
From: Baptiste Wojtkowski <bski@laposte.net>
Date: Wed, 24 Jul 2024 15:52:27 +0200
Subject: [PATCH] Bug 37451 - Remove the ability to delete a restriction due to
 discharge

However it is not possible to remove the discharge, it is possible to remove the suspension associated to the discharge. This can lead to a lot of undesired behaviors when the user asks for another discharge or get suspended for another reason.

Suspension due to discharge should therefore be definitive.

TEST PLAN:
1 - Go to patron -> pick a patron -> go to discharges
2 - Generate a discharge for the patron
3 - Go to check out -> restrictions
4 - There should be a restriction with type discharge that can be
  deleted
5 - Apply patch
6 - There still should be a restriction but the button has been replaced
  by an infobox

Signed-off-by: Shi Yao Wang <shi-yao.wang@inlibro.com>
---
 .../prog/en/includes/patron-restrictions-tab.inc            | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc
index d1a4a64ccd..206e51788e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc
@@ -24,6 +24,7 @@
                         [% PROCESS restriction_type_description restriction_type=restriction.type %]
                     </td>
                     <td>
+                    [% restriction.type.code %]
                         [% IF restriction.comment.search('OVERDUES_PROCESS') %]
                             <span>Restriction added by overdues process [% restriction.comment.remove('OVERDUES_PROCESS ') | $raw %]</span>
                         [% ELSE %]
@@ -41,6 +42,7 @@
                     <td>[% restriction.created | $KohaDates %]</td>
                     [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
                         <td>
+                            [% IF restriction.type.code != "DISCHARGE" %]
                             <form method="post" action="/cgi-bin/koha/members/mod_debarment.pl">
                                 [% INCLUDE 'csrf-token.inc' %]
                                 <input type="hidden" name="op" value="cud-del" />
@@ -48,7 +50,11 @@
                                 <input type="hidden" name="borrower_debarment_id" value="[% restriction.borrower_debarment_id | uri %]" />
                                 <button type="submit" class="remove_restriction btn btn-default btn-xs"><i class="fa fa-trash-can"></i> Remove</button>
                             </form>
+                            [% ELSE %]
+                                <i title="Restrictions due to discharges cannot be cancelled" aria-hidden=true data-placement="right" class="fa fa-info-circle"></i>
+                            [% END %]
                         </td>
+
                     [% END %]
                 </tr>
             [% END %]
-- 
2.34.1