From f4b82597bc3de88404f9e4e9f249415e9dab5ddd Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Fri, 13 Jun 2025 13:15:57 +0300 Subject: [PATCH] Bug 40116: Do not display "Patron is already a guarantor..." pop-up when error occurs If a yellow error message appears when saving the guaranteed patron, also an extra popup message "Patron is already a guarantor for this patron" will appear on the screen. It should only appear when you try to add the same patron as a guarantor that already is a guarantor for that patron. This happens because js function select_user is triggered every time when guarantor data is send back to front-end. This patch sends nok variable as parameter to this same function so that if error occurs checkin patron guarantors is skipped. To test: 1. Find a patron with Patron guarantor or add first a Patron guarantor (not a Non-patron guarantor) to a juvenile patron and save. 2. Edit again the same patron with guarantor and modify their age to be greater than the upperage or under the required age of the patron category. => Notice that you will get a yellow message "The following fields are wrong. Please fix them..." => Notice that you will also get a pop up notice that says "Patron is already a guarantor for this patron". 3. Apply this patch. 4. Repeat step 2. => Confirm that yellow message box is displayed but "Patron is..." pop-up is not 5. Try to add same patron guarantor as guarantor for guarantee patron again. => Confirm that pop-up is displayed right after attempting to add guarantor. Sponsored-by: Koha-Suomi Oy Signed-off-by: David Flater --- .../intranet-tmpl/prog/en/modules/members/memberentrygen.tt | 2 +- koha-tmpl/intranet-tmpl/prog/js/members.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 361a178107..494bf3cc37 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1779,7 +1779,7 @@ [% IF new_guarantors %] [% FOREACH g IN new_guarantors %] - select_user( '[% g.patron.borrowernumber | html %]', [% To.json( g.patron.unblessed ) | $raw %], '[% g.relationship | html %]' ); + select_user( '[% g.patron.borrowernumber | html %]', [% To.json( g.patron.unblessed ) | $raw %], '[% g.relationship | html %]', [% nok | $raw %] ); [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index a20561cfe0..7429e21859 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -90,12 +90,12 @@ function update_category_code(category_code) { hint.html(hint_string); } -function select_user(borrowernumber, borrower, relationship) { +function select_user(borrowernumber, borrower, relationship, nok) { let is_guarantor = $( `.guarantor-details[data-borrowernumber=${borrowernumber}]` ).length; - if (is_guarantor) { + if (is_guarantor && !nok) { alert("Patron is already a guarantor for this patron"); } else { $("#guarantor_id").val(borrowernumber); -- 2.39.5