From 3220e7b8cf9618e04161a7ae052efc3ea60ce9c2 Mon Sep 17 00:00:00 2001
From: Fridolin Somers <fridolin.somers@biblibre.com>
Date: Mon, 29 Jul 2024 16:35:55 +0200
Subject: [PATCH] Bug 37512: Add a function to reset login attempts

When using system preference 'FailedLoginAttempts', a patron's account is blocked after X many failed login attempts on the OPAC.

This patch adds, like for "Patron's card has expired" message :
  * a link to reset login attempts to 0
Link is only displayed if libarian has permission to edit patrons.

Reset login attempts to 0 feature uses members/setstatus.pl with
resetloginattempts=y like reregistration=y for an expired patron

To test:
1. Apply BZ25947
2. Change system preference 'FailedLoginAttempts' to a small number, like 2
3. Go to a patron's account and copy their username (while you're there, change the password and add some fines, too)
4. In the OPAC, try to log in with the username and a wrong password 3 times (you might want to use private browsing)
5. Go back to the patron's account details in the staff interface
6. Note that there is a message : "Patron's account has been locked (due to 3 failed login attempts)"
7. Click on the button to reset the login attempts.
8. There is a modal, click on confirm
9. Notice you have been redirected to the account details page.
10. Notice there is no message anymore, notice you can log in again.
11. Repeat 4-9 using the checkout page, notice you are redirected to
    the checkout page

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
---
 .../prog/en/includes/patron_messages.inc      | 204 +++++++++---------
 members/setstatus.pl                          |  12 +-
 2 files changed, 110 insertions(+), 106 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc
index 5d77a92f..28c48d66 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc
@@ -24,11 +24,9 @@
                 <span class="circ-hlt">Expiration:</span>
                 <span>Patron's card expires on [% patron.dateexpiry | $KohaDates %].</span>
                 [% IF ( moremember ) %]
-                    <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=member&amp;reregistration=y">Renew</a> or
-                    <a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;destination=member&amp;borrowernumber=[% patron.borrowernumber | uri %]">Edit details</a>
+                    <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=member&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;destination=member&amp;borrowernumber=[% patron.borrowernumber | uri %]">Edit details</a>
                 [% ELSE %]
-                    <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=circ&amp;reregistration=y">Renew</a> or
-                    <a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;destination=circ&amp;borrowernumber=[% patron.borrowernumber | uri %]">Edit details</a>
+                    <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;destination=circ&amp;borrowernumber=[% patron.borrowernumber | uri %]">Edit details</a>
                 [% END %]
             </li>
         [% END %]
@@ -47,11 +45,9 @@
                     <span>Patron's card expired on [% expiry | $KohaDates %]</span>
                 [% END %]
                 [% IF ( moremember ) %]
-                    <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=member&amp;reregistration=y">Renew</a> or
-                    <a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;destination=member&amp;borrowernumber=[% patron.borrowernumber | uri %]">Edit details</a>
+                    <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=member&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;destination=member&amp;borrowernumber=[% patron.borrowernumber | uri %]">Edit details</a>
                 [% ELSE %]
-                    <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=circ&amp;reregistration=y">Renew</a> or
-                    <a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;destination=circ&amp;borrowernumber=[% patron.borrowernumber | uri %]">Edit details</a>
+                    <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=circ&amp;reregistration=y">Renew</a> or <a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;destination=circ&amp;borrowernumber=[% patron.borrowernumber | uri %]">Edit details</a>
                 [% END %]
             </li>
         [% END %]
@@ -66,7 +62,8 @@
                 [% IF CAN_user_borrowers_edit_borrowers %]
                     <span>
                         <a href="/cgi-bin/koha/members/member-password.pl?member=[% patron.borrowernumber | uri %]">Change password</a>
-                        <span data-bs-toggle="tooltip" title="Resetting password will remove lock on account" data-bs-placement="right" class="fa fa-info-circle"> </span>
+                        <span data-bs-toggle="tooltip" title="Resetting password will remove lock on account" data-bs-placement="right" class="fa fa-info-circle" />
+                        or <a href="/cgi-bin/koha/members/setstatus.pl?borrowernumber=[% patron.borrowernumber | uri %]&amp;destination=circ&amp;resetloginattempts=y">Reset login attempts</a>
                     </span>
                 [% END %]
             </li>
@@ -74,63 +71,61 @@
 
         [% IF ( patron.gonenoaddress ) %]
             <li class="gonenoaddress blocker">
-                <span title="gonenoaddress flag is set in patron record"><span class="circ-hlt">Address:</span> Patron's address flagged as in doubt</span>
-                <a class="btn btn-default btn-xs" href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;borrowernumber=[% patron.borrowernumber | uri %]&amp;step=3#memberentry_account_flags"
-                    ><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a
-                >
+                <span title="gonenoaddress flag is set in patron record"><span class="circ-hlt">Address:</span> Patron's address flagged as in doubt</span> <a class="btn btn-default btn-xs" href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;borrowernumber=[% patron.borrowernumber | uri %]&amp;step=3#memberentry_account_flags"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
             </li>
         [% END %]
 
         [% IF ( patron.lost ) %]
             <li class="lost blocker">
-                <span title="lost flag is set in patron record"><span class="circ-hlt">Lost: </span> Patron's card is flagged as lost</span>
-                <a class="btn btn-default btn-xs" href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;borrowernumber=[% patron.borrowernumber | uri %]&amp;step=3#memberentry_account_flags"
-                    ><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a
-                >
+                <span title="lost flag is set in patron record"><span class="circ-hlt">Lost: </span> Patron's card is flagged as lost</span> <a class="btn btn-default btn-xs" href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&amp;borrowernumber=[% patron.borrowernumber | uri %]&amp;step=3#memberentry_account_flags"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
             </li>
         [% END %]
 
         [% IF ( userdebarred ) %]
             <li class="userdebarred blocker">
                 <span class="circ-hlt"> Restricted since [% debarredsince | $KohaDates %]:</span> Patron's account is restricted
+
                 [% IF ( userdebarreddate ) %]
                     until [% userdebarreddate | $KohaDates %]
                 [% END %]
 
                 [% IF ( debarredcomment ) %]
-                    with the explanation: <br />
+                    with the explanation: <br/>
                     <em>
                         [% IF debarredcomment.search('OVERDUES_PROCESS') %]
                             Restriction added by overdues process [% debarredcomment.remove('OVERDUES_PROCESS ') | $raw | html_line_break %]
                         [% ELSE %]
                             [% FOREACH restriction IN patron.restrictions %]
                                 <div class="[% restriction.type.code | lower | html %]_restriction">
-                                    <span class="restriction_expiration">
-                                        [% IF restriction.expiration %]
-                                            [% restriction.expiration | $KohaDates %]
-                                        [% ELSE %]
-                                            <strong>Indefinite</strong>
-                                        [% END %]
-                                    </span>
-                                    <span class="restriction_detail"> [%- restriction.type.display_text | html -%][%- IF restriction.comment -%]: [%- restriction.comment | html_line_break -%][%- END -%] </span>
+                                <span class="restriction_expiration">
+                                [% IF restriction.expiration %]
+                                    [% restriction.expiration | $KohaDates %]
+                                [% ELSE %]
+                                    <strong>Indefinite</strong>
+                                [% END %]
+                                </span>
+                                <span class="restriction_detail">
+                                [%- restriction.type.display_text | html -%][%- IF restriction.comment -%]: [%- restriction.comment | html_line_break -%][%- END -%]
+                                </span>
                                 </div>
                             [% END %]
-                        [% END %] </em
-                    ><br />
+                        [% END %]
+                    </em><br/>
                 [% END %]
                 <a class="btn btn-xs btn-default" href="#reldebarments-tab" onclick="$('#reldebarments-tab').click()"><i class="fa fa-ban"></i> View restrictions</a>
-            </li>
-            <!-- /.blocker -->
+            </li> <!-- /.blocker -->
         [% END # /IF userdebarred %]
 
         [% IF ( odues ) %]
             <li class="odues blocker">
-                <span class="circ-hlt">Overdues:</span> Patron has ITEMS OVERDUE <a href="#checkouts_panel" onclick="$('#issues-table-load-immediately').click(); $('#issues-table-load-immediately').click();">See highlighted items below </a>
+                <span class="circ-hlt">Overdues:</span>  Patron has ITEMS OVERDUE <a href="#checkouts_panel" onclick="$('#issues-table-load-immediately').click(); $('#issues-table-load-immediately').click();">See highlighted items below </a>
             </li>
         [% END %]
 
         [% IF return_claims.count > ClaimReturnedWarningThreshold %]
-            <li class="return_claims blocker"> <span class="circ-hlt return-claims">Return claims:</span> Patron has [% return_claims.count | html %] RETURN CLAIMS </li>
+            <li class="return_claims blocker">
+                <span class="circ-hlt return-claims">Return claims:</span> Patron has [% return_claims.count | html %] RETURN CLAIMS
+            </li>
         [% END %]
 
         [% IF age_limitations %]
@@ -164,14 +159,16 @@
         [% IF ( charges_guarantees ) %]
             <li class="charges_guarantees">
                 <span class="circ-hlt">Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %].
-                [% IF noissues %]
-                    <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
-                [% END %]
+                    [% IF noissues %]
+                        <span class="circ-hlt">Checkouts are BLOCKED because fine balance is OVER THE LIMIT.</span>
+                    [% END %]
             </li>
         [% END %]
 
         [% IF ( credits ) %]
-            <li class="credits"> <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %]of <span class="credit"><strong>[% creditsamount | $Price %]</strong></span>[% END %] </li>
+            <li class="credits">
+                <span class="circ-hlt">Credits:</span> Patron has a credit[% IF ( creditsamount ) %] of <span class="credit"><strong>[% creditsamount | $Price %]</strong></span>[% END %]
+            </li>
         [% END %]
         [% IF (noissues && CAN_user_circulate_force_checkout && !moremember) %]
             <li>
@@ -181,6 +178,7 @@
             </li>
         [% END %]
     </ul>
+
 [% END # /F ( has_modifications || warndeparture... %]
 
 [% IF waiting_recalls.count %]
@@ -202,11 +200,15 @@
                     [% IF ( w.pickup_library_id == logged_in_branchcode  ) %]
                         <li>
                             <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% w.biblio_id | uri %]">[% w.biblio.title | html %]</a>
-                            ([% ItemTypes.GetDescription( w.item.effective_itemtype ) | html %]), [% IF ( w.biblio.author ) %]by [% w.biblio.author | html %][% END %]
-                            [% IF ( w.item.itemcallnumber ) %][[% w.item.itemcallnumber | html %]][% END %]
+                            ([% ItemTypes.GetDescription( w.item.effective_itemtype ) | html %]),
+                            [% IF ( w.biblio.author ) %] by [% w.biblio.author | html %] [% END %]
+                            [% IF ( w.item.itemcallnumber ) %] [[% w.item.itemcallnumber | html %]] [% END %]
                             <span>Recall placed on [% w.created_date | $KohaDates %].</span>
                             <br />
-                            <strong class="waitinghere"> [% SET expires_on = w.expiration_date %] Waiting here [% IF expires_on %]until [% expires_on | $KohaDates %][% END %] </strong>
+                            <strong class="waitinghere">
+                                [% SET expires_on = w.expiration_date %]
+                                Waiting here [% IF expires_on %] until [% expires_on | $KohaDates %] [% END %]
+                            </strong>
                         </li>
                     [% END %]
                 [% END %]
@@ -220,11 +222,15 @@
                     [% IF ( w.pickup_library_id != logged_in_branchcode  ) %]
                         <li>
                             <a href="/cgi-bin/koha/recalls/request.pl?biblionumber=[% w.biblio_id | uri %]">[% w.biblio.title | html %]</a>
-                            ([% ItemTypes.GetDescription( w.item.effective_itemtype ) | html %]), [% IF ( w.biblio.author ) %]by [% w.biblio.author | html %][% END %]
-                            [% IF ( w.item.itemcallnumber ) %][[% w.item.itemcallnumber | html %]][% END %]
+                            ([% ItemTypes.GetDescription( w.item.effective_itemtype ) | html %]),
+                            [% IF ( w.biblio.author ) %] by [% w.biblio.author | html %] [% END %]
+                            [% IF ( w.item.itemcallnumber ) %] [[% w.item.itemcallnumber | html %]] [% END %]
                             <span>Recall placed on [% w.created_date | $KohaDates %].</span>
                             <br />
-                            <strong> [% SET expires_on = w.expiration_date %] Waiting at [% Branches.GetName( w.pickup_library_id ) | html %] [% IF expires_on %]until [% expires_on | $KohaDates %][% END %] </strong>
+                            <strong>
+                                [% SET expires_on = w.expiration_date %]
+                                Waiting at [% Branches.GetName( w.pickup_library_id ) | html %] [% IF expires_on %] until [% expires_on | $KohaDates %] [% END %]
+                            </strong>
                         </li>
                     [% END %]
                 [% END %]
@@ -252,12 +258,18 @@
                     [% IF ( w.branch.branchcode == logged_in_branchcode  ) %]
                         <li>
                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% w.biblio.biblionumber | uri %]">[% w.biblio.title | html %]</a>
-                            ([% ItemTypes.GetDescription( w.item.effective_itemtype ) | html %]), [% IF ( w.biblio.author ) %]by [% w.biblio.author | html %][% END %]
-                            [% IF ( w.item.itemcallnumber ) %][[% w.item.itemcallnumber | html %]][% END %]
+                            ([% ItemTypes.GetDescription( w.item.effective_itemtype ) | html %]),
+                            [% IF ( w.biblio.author ) %] by [% w.biblio.author | html %] [% END %]
+                            [% IF ( w.item.itemcallnumber ) %] [[% w.item.itemcallnumber | html %]] [% END %]
                             <span class="holddate">Hold placed on [% w.reservedate | $KohaDates %].</span>
                             <br />
-                            <strong class="waitinghere"> [% SET expires_on = w.expirationdate %] Waiting here [% IF expires_on %]until [% expires_on | $KohaDates %][% END %]. </strong>
-                            <strong class="waitingsince"> Waiting here since [% w.waitingdate | $KohaDates %]. </strong>
+                            <strong class="waitinghere">
+                                [% SET expires_on = w.expirationdate %]
+                                Waiting here [% IF expires_on %] until [% expires_on | $KohaDates %][% END %].
+                            </strong>
+                            <strong class="waitingsince">
+                                Waiting here since [% w.waitingdate | $KohaDates %].
+                            </strong>
                         </li>
                     [% END %]
                 [% END %]
@@ -271,11 +283,15 @@
                     [% IF ( w.branch.branchcode != logged_in_branchcode  ) %]
                         <li>
                             <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% w.biblio.biblionumber | uri %]">[% w.biblio.title | html %]</a>
-                            ([% ItemTypes.GetDescription( w.item.effective_itemtype ) | html %]), [% IF ( w.biblio.author ) %]by [% w.biblio.author | html %][% END %]
-                            [% IF ( w.item.itemcallnumber ) %][[% w.item.itemcallnumber | html %]][% END %]
+                            ([% ItemTypes.GetDescription( w.item.effective_itemtype ) | html %]),
+                            [% IF ( w.biblio.author ) %] by [% w.biblio.author | html %] [% END %]
+                            [% IF ( w.item.itemcallnumber ) %] [[% w.item.itemcallnumber | html %]] [% END %]
                             <span>Hold placed on [% w.reservedate | $KohaDates %].</span>
                             <br />
-                            <strong> [% SET expires_on = w.expirationdate %] Waiting at [% w.branch.branchname | html %] [% IF expires_on %]until [% expires_on | $KohaDates %][% END %] </strong>
+                            <strong>
+                                [% SET expires_on = w.expirationdate %]
+                                Waiting at [% w.branch.branchname | html %] [% IF expires_on %] until [% expires_on | $KohaDates %] [% END %]
+                            </strong>
                         </li>
                     [% END %]
                 [% END %]
@@ -290,23 +306,25 @@
         <div id="curbside_pickups" class="circmessage">
             <h4>Curbside pickups scheduled here</h4>
             <ul>
-                [% FOR cp IN curbside_pickups %]
-                    <li
-                        >On [% cp.scheduled_pickup_datetime | $KohaDates %]:
-                        [% SWITCH cp.status %]
-                        [% CASE 'to-be-staged' %]
-                            <a href="/cgi-bin/koha/circ/curbside_pickups.pl?tab=to-be-staged"> To be staged</a>
-                        [% CASE 'staged-and-ready' %]
-                            <a href="/cgi-bin/koha/circ/curbside_pickups.pl?tab=staged-and-ready"> Staged and ready</a>
-                        [% CASE 'patron-is-outside' %]
-                            <a href="/cgi-bin/koha/circ/curbside_pickups.pl?tab=patron-is-outside"> Patron is outside!</a>
-                        [% CASE 'delivered' %]
-                            <a href="/cgi-bin/koha/circ/curbside_pickups.pl?tab=delivered-today"> Delivered</a>
-                        [% CASE %]
-                            <span>Unknown status "[% cp.status | html %]"</span>
-                        [% END %]
-                    </li>
-                [% END %]
+            [% FOR cp IN curbside_pickups %]
+                <li>On [% cp.scheduled_pickup_datetime | $KohaDates %]:
+                    [% SWITCH cp.status %]
+                    [% CASE 'to-be-staged' %]
+                        <a href="/cgi-bin/koha/circ/curbside_pickups.pl?tab=to-be-staged">
+                        To be staged</a>
+                    [% CASE 'staged-and-ready' %]
+                        <a href="/cgi-bin/koha/circ/curbside_pickups.pl?tab=staged-and-ready">
+                        Staged and ready</a>
+                    [% CASE 'patron-is-outside' %]
+                        <a href="/cgi-bin/koha/circ/curbside_pickups.pl?tab=patron-is-outside">
+                        Patron is outside!</a>
+                    [% CASE 'delivered' %]
+                        <a href="/cgi-bin/koha/circ/curbside_pickups.pl?tab=delivered-today">
+                        Delivered</a>
+                    [% CASE %]<span>Unknown status "[% cp.status | html %]"</span>
+                    [% END %]
+                </li>
+            [% END %]
             </ul>
         </div>
     [% END %]
@@ -317,11 +335,12 @@
         <h4>Notes</h4>
         <ul>
             <li>
-                <span class="circ-hlt"> [% patron.borrowernotes | $raw | html_line_break %] </span>
+                <span class="circ-hlt">
+                    [% patron.borrowernotes | $raw | html_line_break %]
+                </span>
             </li>
         </ul>
-    </div>
-    <!-- /#circnotes -->
+    </div> <!-- /#circnotes -->
 [% END # /IF patron.borrowernotes %]
 
 [% IF ( patron_messages ) %]
@@ -338,11 +357,7 @@
                         [% patron_message.message_date | $KohaDates %]
                         [% Branches.GetName( patron_message.branchcode ) | html %]
                         [% IF patron_message.manager_id %]
-                            (
-                            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron_message.manager_id | uri %]"
-                                >[% patron_message.get_column('manager_firstname') | html %] [% patron_message.get_column('manager_surname') | html %]</a
-                            >
-                            )
+                            ( <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron_message.manager_id | uri %]">[% patron_message.get_column('manager_firstname') | html %] [% patron_message.get_column('manager_surname') | html %]</a> )
                         [% END %]
                         <em>"[% patron_message.message | html | html_line_break %]"</em>
                         [% IF patron_message.patron_read_date %]
@@ -351,36 +366,22 @@
                     </span>
                     [% IF patron_message.branchcode == Branches.GetLoggedInBranchcode OR Koha.Preference('AllowAllMessageDeletion') %]
                         [% IF moremember %]
-                            <a
-                                id="#edit_message_form_[% patron_message.message_id | html %]"
-                                class="btn btn-link edit_message"
-                                href="#edit_message_form_[% patron_message.message_id | uri %]"
-                                data-bs-target="#edit_message_form_[% patron_message.message_id | html %]"
-                                data-bs-toggle="modal"
-                                ><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a
-                            >
+                            <a id="#edit_message_form_[% patron_message.message_id | html %]" class="btn btn-link edit_message" href="#edit_message_form_[% patron_message.message_id | uri %]" data-bs-target="#edit_message_form_[% patron_message.message_id | html %]" data-bs-toggle="modal"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
                             <form action="/cgi-bin/koha/circ/del_message.pl" method="post">
                                 [% INCLUDE 'csrf-token.inc' %]
-                                <input type="hidden" name="op" value="cud-delete" />
-                                <input type="hidden" name="message_id" value="[% patron_message.message_id | html %]" />
-                                <input type="hidden" name="borrowernumber" value="[% patron_message.borrowernumber | html %]" />
-                                <input type="hidden" name="from" value="moremember" />
+                                <input type="hidden" name="op" value="cud-delete">
+                                <input type="hidden" name="message_id" value="[% patron_message.message_id | html %]">
+                                <input type="hidden" name="borrowernumber" value="[% patron_message.borrowernumber | html %]">
+                                <input type="hidden" name="from" value="moremember">
                                 <button type="submit" class="btn btn-link delete_message"><i class="fa fa-trash-can"></i> Delete</button>
                             </form>
                         [% ELSE %]
-                            <a
-                                id="#edit_message_form_[% patron_message.message_id | html %]"
-                                class="btn btn-link edit_message"
-                                href="#edit_message_form_[% patron_message.message_id | uri %]"
-                                data-bs-target="#edit_message_form_[% patron_message.message_id | html %]"
-                                data-bs-toggle="modal"
-                                ><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a
-                            >
+                            <a id="#edit_message_form_[% patron_message.message_id | html %]" class="btn btn-link edit_message" href="#edit_message_form_[% patron_message.message_id | uri %]" data-bs-target="#edit_message_form_[% patron_message.message_id | html %]" data-bs-toggle="modal"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
                             <form action="/cgi-bin/koha/circ/del_message.pl" method="post">
                                 [% INCLUDE 'csrf-token.inc' %]
-                                <input type="hidden" name="op" value="cud-delete" />
-                                <input type="hidden" name="message_id" value="[% patron_message.message_id | html %]" />
-                                <input type="hidden" name="borrowernumber" value="[% patron_message.borrowernumber | html %]" />
+                                <input type="hidden" name="op" value="cud-delete">
+                                <input type="hidden" name="message_id" value="[% patron_message.message_id | html %]">
+                                <input type="hidden" name="borrowernumber" value="[% patron_message.borrowernumber | html %]">
                                 <button type="submit" class="btn btn-link delete_message"><i class="fa fa-trash-can"></i> Delete</button>
                             </form>
                         [% END %]
@@ -389,8 +390,7 @@
             [% END %]
         </ul>
         <a id="addnewmessageLabel" data-bs-target="#add_message_form" class="btn btn-link" data-bs-toggle="modal"><i class="fa fa-plus"></i> Add a new message</a>
-    </div>
-    <!-- /#messages -->
+    </div> <!-- /#messages -->
 
     [% FOREACH pm IN patron_messages %]
         <div id="edit_message_form_[% pm.message_id | html %]" class="modal" tabindex="-1" aria-labelledby="#edit_message_form_[% patron_message.message_id | html %]" aria-hidden="true">
@@ -398,8 +398,8 @@
                 <div class="modal-content">
                     <form method="post" action="/cgi-bin/koha/circ/add_message.pl" id="edit_message_form" name="message_f">
                         [% INCLUDE 'csrf-token.inc' %]
-                        <input type="hidden" name="op" value="cud-edit_message" />
-                        <input type="hidden" name="message_id" value="[% pm.message_id | html %]" />
+                        <input type="hidden" name="op" value="cud-edit_message">
+                        <input type="hidden" name="message_id" value="[% pm.message_id | html %]"/>
                         <div class="modal-header">
                             <h1 class="modal-title">Edit message</h1>
                         </div>
@@ -423,7 +423,7 @@
                                 </label>
                             </div>
                             <div class="form-group">
-                                <textarea rows="3" class="modal-textarea" name="borrower_message" id="edit_borrower_message">[% pm.message | html %]</textarea>
+                                <textarea rows="3" class="modal-textarea" name="borrower_message" id="edit_borrower_message" >[% pm.message | html %]</textarea>
                             </div>
                         </div>
                         <div class="modal-footer">
diff --git a/members/setstatus.pl b/members/setstatus.pl
index d05498b8..0d7957d9 100755
--- a/members/setstatus.pl
+++ b/members/setstatus.pl
@@ -35,10 +35,11 @@ my $input = CGI->new;
 
 my ($loggedinuserid) = checkauth( $input, 0, { borrowers => 'edit_borrowers' }, 'intranet' );
 
-my $destination    = $input->param("destination") || '';
-my $borrowernumber = $input->param('borrowernumber');
-my $status         = $input->param('status');
-my $reregistration = $input->param('reregistration') || '';
+my $destination        = $input->param("destination") || '';
+my $borrowernumber     = $input->param('borrowernumber');
+my $status             = $input->param('status');
+my $reregistration     = $input->param('reregistration')     || '';
+my $resetloginattempts = $input->param('resetloginattempts') || '';
 
 my $dbh = C4::Context->dbh;
 my $dateexpiry;
@@ -64,6 +65,9 @@ if ( $logged_in_user->can_see_patron_infos($patron) ) {
                 $_->rethrow();
             }
         }
+        $dateexpiry = $patron->renew_account;
+    } elsif ( $resetloginattempts eq 'y' ) {
+        $patron->login_attempts(0)->store;
     } else {
         my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
         $sth->execute( $status, $borrowernumber );
-- 
2.30.2