From 088c85d164f7a9d0e95a456e97c5738efbd6e182 Mon Sep 17 00:00:00 2001 From: Ayoub Glizi-Vicioso Date: Fri, 6 Feb 2026 11:17:41 -0500 Subject: [PATCH] Bug 41780: Show firstname if preferred_name is empty To test: BEFORE APPLYING PATCH: 1- Create a new patron(Patrons > +New patron), WITHOUT entering any preferred name, via the staff interface. --> Notice that once added, if you edit the patron you just created, the preferred name field has been automatically filled to match the patron first name. 2- Stay on the patron edit page. 3- Set your patron's preferred name to NULL through this SQL request: --> UPDATE borrowers SET preferred_name = NULL WHERE borrowernumber = [borrowernumber located in the URL]; 4- Reload the edit_form page. --> Notice that the preferred_name field is now empty. --> Note: do not save the form. 5- Return to the patron's main information page. --> Notice that only the surname is displayed. 6- Apply this patch. AFTER APPLYING PATCH: 7- From the main page go to: Patrons > Search --> Search for the patron whose preferred name was set to NULL. 8- Notice that the firstname is now displayed (Note: reload page and clear the cache if needed). 9- Open the 'Edit patron' form and you will see that the preferred name field is now filled to match the firstname. --- koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc | 7 +++++-- .../intranet-tmpl/prog/en/modules/members/moremember.tt | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc index eae649b832..97b7a9f113 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc @@ -76,8 +76,11 @@ ([%- WRAPPER maybe_span field_name='othernames' -%][%- data.othernames | html -%][%- END -%]) [%- END -%] [%- ELSE -%] - [%- UNLESS no_title %][%- WRAPPER maybe_span field_name='patron_title' -%][%- data.title _ ' ' | html -%][%- END -%][%- END -%] - [%- WRAPPER maybe_span field_name='preferred_name' -%][%- data.preferred_name | html %][% END -%] + [%- IF (data.title) %][%- WRAPPER maybe_span field_name='patron_title' -%][%- data.title _ ' ' | html -%][%- END -%][%- END -%] + [%- IF data.preferred_name -%][%- WRAPPER maybe_span field_name='preferred_name' -%][%- data.preferred_name | html %][% END -%][% END -%] + [%- IF !(data.preferred_name) -%] + [%- WRAPPER maybe_span field_name = 'firstname' -%][%- data.firstname |html %][% END -%] + [%- END -%] [%- IF data.middle_name -%][%- WRAPPER maybe_span field_name='middle_name' -%][% ' ' _ data.middle_name | html -%][%- END -%][%- END -%] [%- IF data.othernames -%] [%- WRAPPER maybe_span field_name='othernames' -%][%- ' (' _ data.othernames _ ')' | html -%][%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index cc59617307..0578359a6e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -131,7 +131,7 @@
    - [% IF ( patron.preferred_name && patron.firstname ) %] + [% IF ( patron.preferred_name && patron.firstname && patron.preferred_name != patron.firstname) %]
  1. First name: [% patron.firstname | html %] -- 2.52.0