From 316c46927b763c25503be880929c3ddd89d080b7 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Thu, 3 Jul 2025 13:00:58 +0300 Subject: [PATCH] Bug 40116: Change classes for existing guarantors in patron form We are currently using classes "new_guarantor_id" and "new_guarantor_relationship" with existing guarantors in patron add/modify form. These classes should mainly be used when new guarantor is added and to ensure their data is not lost when error occurs. Now with previous patch applied using them leads to situation where existing guarantors information is displayed twice (or more times) if error occurs. This patch changes these classes as "guarantor_id" and "guarantor_relationship". To test: 1. Find patron who has a guarantor. 2. Modify their age to be greater than the upperage or under the required age of the patron category. 3. Attempt to save patron. => Notice that guarantor is now displayed twice in "Patron guarantor" section. 4. Apply this patch. 5. Attempt to save the patron again. => Notice that guarantor is no longer duplicated in "Patron guarantor" section. 6. Try to readd same patron as guarantor. => Pop-up "Patron is already a guarantor for this patron" should be displayed. 7. Try to add new guarantor for patron. => New guarantor should be added. 8. Attempt to save the patron. => Neither existing patron or new patron is duplicated. 9. Fix patrons age and attempt to save. => Patron is saved and both guarantors are displayed in their details. Sponsored-by: Koha-Suomi Oy --- .../intranet-tmpl/prog/en/modules/members/memberentrygen.tt | 4 ++-- members/memberentry.pl | 3 +++ 2 files changed, 5 insertions(+), 2 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 494bf3cc37..ed4c99f313 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -489,12 +489,12 @@
  • Guarantor: [% INCLUDE 'patron-title.inc' patron=r.guarantor hide_patron_infos_if_needed=1 %] - +
  • Relationship: [% r.relationship | html %] - +
  • diff --git a/members/memberentry.pl b/members/memberentry.pl index 59bffba29e..6b39df2996 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -560,6 +560,9 @@ if ( ( !$nok ) and $nodouble and ( $op eq 'cud-insert' or $op eq 'cud-save' ) ) delete $newdata{password2}; + delete $newdata{guarantor_id}; + delete $newdata{guarantor_relationship}; + try { $patron->set( \%newdata )->store( { guarantors => \@guarantors } ) if scalar( keys %newdata ) > 1; -- 2.34.1