From 6a11eed59e1c5d0944b37c09ebbf772b29e22247 Mon Sep 17 00:00:00 2001
From: Lucas Gass <lucas@bywatersolutions.com>
Date: Mon, 19 Dec 2022 20:40:57 +0000
Subject: [PATCH] Bug 31890: Add surname to PrefillGuaranteeField system pref

To test:
1. Apply patch and restart_all
2. Find the system preference PrefillGuaranteeField
3. Look for the Surname option and add it
4. Go to a patron account and add a gaurantee
5. See that the surname is properly populated for the gaurantor's surname field

Note:
This patch replaces borrower_data.surname with patron.surname. There seems to be a mismatch here so I filed Bug 32458.
---
 .../prog/en/modules/admin/preferences/patrons.pref            | 1 +
 .../intranet-tmpl/prog/en/modules/members/memberentrygen.tt   | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
index fd91a8576af..5493243816e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
@@ -301,6 +301,7 @@ Patrons:
          - "When adding a guarantee to a guarantor patron fill the following fields in the guarantee's member entry form from the guarantors record:"
          - pref: PrefillGuaranteeField
            multiple:
+               surname: "Surname"
                B_streettype: "Alternate address - Street type"
                B_address: "Alternate address - Address"
                B_address2: "Alternate address - Address 2"
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 48f62ddd528..5f2ffbb508b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
@@ -318,9 +318,9 @@ legend:hover {
                                                     [% END %]
 
                                                     [% IF ( uppercasesurnames ) %]
-                                                        <input style="text-transform:uppercase;" type="text" id="surname" name="surname" size="20"  value="[% borrower_data.surname | html %]" />
+                                                        <input style="text-transform:uppercase;" type="text" id="surname" name="surname" size="20"  value="[% patron.surname | html %]" />
                                                     [% ELSE %]
-                                                        <input type="text" id="surname" name="surname" size="20"  value="[% borrower_data.surname | html %]" />
+                                                        <input type="text" id="surname" name="surname" size="20"  value="[% patron.surname | html %]" />
                                                     [% END %]
                                                     [% IF ( mandatorysurname ) %]
                                                         <span class="required">Required</span>
-- 
2.30.2