@@ -, +, @@
new field required or hidden
---
Koha/Patron.pm | 13 ++++++++++
installer/data/mysql/kohastructure.sql | 3 +++
koha-tmpl/intranet-tmpl/prog/en/columns.def | 1 +
.../prog/en/includes/patron-title.inc | 13 ++++++++--
.../prog/en/includes/patronfields.inc | 1 +
.../modules/admin/preferences/borrowers.json | 1 +
.../prog/en/modules/members/memberentrygen.tt | 17 ++++++++++++-
.../prog/en/modules/members/members-update.tt | 1 +
.../prog/en/modules/members/moremember.tt | 2 +-
.../bootstrap/en/includes/patron-title.inc | 2 +-
.../bootstrap/en/modules/opac-memberentry.tt | 15 ++++++++---
t/db_dependent/Koha/Patron.t | 25 ++++++++++++++++++-
12 files changed, 85 insertions(+), 9 deletions(-)
--- a/Koha/Patron.pm
+++ a/Koha/Patron.pm
@@ -102,6 +102,19 @@ sub new {
return $class->SUPER::new($params);
}
+=head3 effective_name
+
+Return the preferred name for a patron, or their firstname if no
+preferred name is set
+
+=cut
+
+sub effective_name {
+ my ( $self ) = @_;
+
+ return $self->preferredname || $self->firstname;
+}
+
=head3 fixup_cardnumber
Autogenerate next cardnumber from highest value found in database
--- a/installer/data/mysql/kohastructure.sql
+++ a/installer/data/mysql/kohastructure.sql
@@ -1229,6 +1229,7 @@ CREATE TABLE `borrower_modifications` (
`cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
+ `preferredname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name',
`title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
@@ -1347,6 +1348,7 @@ CREATE TABLE `borrowers` (
`cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
`surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
`firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
+ `preferredname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name',
`title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
`othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
`initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
@@ -2354,6 +2356,7 @@ CREATE TABLE `deletedborrowers` (
`cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
`surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
`firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
+ `preferredname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name',
`title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
`othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
`initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
--- a/koha-tmpl/intranet-tmpl/prog/en/columns.def
+++ a/koha-tmpl/intranet-tmpl/prog/en/columns.def
@@ -2,6 +2,7 @@
Salutation
Surname
First name
+Preferred name
Date of birth
Initials
Other name
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc
@@ -7,6 +7,8 @@
[%- SET data.surname = patron.surname -%]
[%- SET data.othernames = patron.othernames -%]
[%- SET data.firstname = patron.firstname -%]
+ [%- SET data.preferredname = patron.preferredname -%]
+ [%- SET data.effective_name = patron.effective_name -%]
[%- SET data.cardnumber = patron.cardnumber -%]
[%- SET data.borrowernumber = patron.borrowernumber -%]
[%- SET data.title = patron.title -%]
@@ -15,6 +17,8 @@
[%- SET data.surname = borrower.surname -%]
[%- SET data.othernames = borrower.othernames -%]
[%- SET data.firstname = borrower.firstname -%]
+ [%- SET data.preferredname = borrower.preferredname -%]
+ [%- SET data.effective_name = borrower.effective_name -%]
[%- SET data.cardnumber = borrower.cardnumber -%]
[%- SET data.borrowernumber = borrower.borrowernumber -%]
[%- SET data.title = borrower.title -%]
@@ -23,10 +27,15 @@
[%- SET data.surname = surname -%]
[%- SET data.othernames = othernames -%]
[%- SET data.firstname = firstname -%]
+ [%- SET data.preferredname = preferredname -%]
+ [%- SET data.effective_name = effective_name -%]
[%- SET data.cardnumber = cardnumber -%]
[%- SET data.borrowernumber = borrowernumber -%]
[%- SET data.title = title -%]
[%- END -%]
+[%- UNLESS data.effective_name -%]
+ [%- SET data.effective_name = data.preferredname || data.firstname -%]
+[%- END -%]
[%# Parameter no_html - if 1, the html tags are NOT generated %]
[%- IF no_title %][% SET data.title = "" %][% END -%]
[%- IF data.title %]
@@ -60,9 +69,9 @@
[%- IF data.category_type == 'I' -%]
[%- data.surname | html %] [% IF data.othernames %] ([% data.othernames | html %])[% END -%]
[%- ELSIF invert_name -%]
- [% data.title | $raw %][%- data.surname | html %][% IF ( data.firstname ) %], [% data.firstname | html %][% END %][% IF data.othernames %] ([% data.othernames | html %]) [% END -%]
+ [% data.title | $raw %][%- data.surname | html %][% IF ( data.effective_name ) %], [% data.effective_name | html %][% END %][% IF data.othernames %] ([% data.othernames | html %]) [% END -%]
[%- ELSE -%]
- [% data.title | $raw %][%- data.firstname | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END %] [% data.surname | html -%]
+ [% data.title | $raw %][%- data.effective_name | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END %] [% data.surname | html -%]
[%- END -%]
[%- IF display_cardnumber AND data.cardnumber %] ([% data.cardnumber | html %])[% END -%]
[%- ELSIF display_cardnumber -%]
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc
@@ -5,6 +5,7 @@
[%- CASE 'cardnumber' -%]Card number
[%- CASE 'surname' -%]Surname
[%- CASE 'firstname' -%]First name
+ [%- CASE 'firstname' -%]Preferred name
[%- CASE 'title' -%]Salutation
[%- CASE 'othernames' -%]Other name
[%- CASE 'initials' -%]Initials
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/borrowers.json
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/borrowers.json
@@ -2,6 +2,7 @@
"cardnumber": "cardnumber",
"surname": "surname",
"firstname": "firstname",
+ "preferredname": "preferredname",
"title": "title",
"othernames": "othernames",
"initials": "initials",
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
@@ -264,7 +264,7 @@ legend:hover {
[% END %]
[% IF ( step_1 ) %]
- [% UNLESS notitle && nosurname && nofirstname && nodateofbirth && noinitials && noothernames &&nosex %]
+ [% UNLESS notitle && nosurname && nofirstname && nopreferredname && nodateofbirth && noinitials && noothernames &&nosex %]