From 54a050646beef40fede6f4b547036b98518e2d08 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 19 Apr 2022 16:20:51 +0100 Subject: [PATCH] Bug 21978: Add support for middle name This patch adds the new 'Middle name' field to the patron record. To test: 1) Apply patches 2) Update database, restart all and clear the browser cache 3) Load a patron in the staff module 4) Confirm you can see and edit the new 'Middle name' field 5) Confirm the new middle name data displays on patron details 6) Confirm the new middle name data displays on patron search results 7) Confirm the new middle name data displays everywhere patron names are displayed. 8) Confirm the new middle name data displays on the OPAC 9) Confirm the 'Middle name' field appears in the OPAC borrower modification screens 10) Edit syspref BorrowerMandatoryFields and BorrowerUnwantedFields to confirm you can make the new field required or hidden 11) Verify that DefaultPatronSearchFields contains the new field if you already had 'firstname' in the field list 12) Enable PatronAutoComplete system preference 13) Type patrons surname into checkout or patron search but don't hit return 14) Confirm the patrons middle name is displayed in the preview --- circ/ysearch.pl | 30 +++++++++++-------- .../prog/en/includes/js-patron-format.inc | 8 +++-- .../prog/en/includes/patron-search.inc | 8 ++--- .../prog/en/includes/patron-title.inc | 11 ++++--- .../prog/en/includes/patronfields.inc | 1 + .../en/modules/admin/preferences/patrons.pref | 2 +- .../prog/en/modules/members/memberentrygen.tt | 17 ++++++++++- .../prog/en/modules/members/members-update.tt | 1 + .../bootstrap/en/includes/patron-title.inc | 2 +- .../bootstrap/en/modules/opac-memberentry.tt | 15 ++++++++-- 10 files changed, 66 insertions(+), 29 deletions(-) diff --git a/circ/ysearch.pl b/circ/ysearch.pl index 3f2650cbeb..33aee174b1 100755 --- a/circ/ysearch.pl +++ b/circ/ysearch.pl @@ -74,26 +74,30 @@ my $borrowers_rs = Koha::Patrons->search_limited( # Get the first 10 results page => 1, rows => 10, - order_by => [ 'surname', 'firstname' ], + order_by => [ 'surname', 'firstname', 'middle_name' ], prefetch => 'branchcode', }, ); my @borrowers; while ( my $b = $borrowers_rs->next ) { + my $name = + $b->middle_name ? $b->firstname . ' ' . $b->middle_name : $b->firstname; push @borrowers, - { borrowernumber => $b->borrowernumber, - surname => $b->surname // '', - firstname => $b->firstname // '', - cardnumber => $b->cardnumber // '', - dateofbirth => format_sqldatetime($b->dateofbirth, undef, undef, 1) // '', - age => $b->get_age // '', - address => $b->address // '', - city => $b->city // '', - zipcode => $b->zipcode // '', - country => $b->country // '', - branchcode => $b->branchcode // '', - branchname => $b->library->branchname // '', + { + borrowernumber => $b->borrowernumber, + surname => $b->surname // '', + firstname => $name // '', + middle_name => $b->middle_name // '', + cardnumber => $b->cardnumber // '', + dateofbirth => format_sqldatetime( $b->dateofbirth, undef, undef, 1 ) // '', + age => $b->get_age // '', + address => $b->address // '', + city => $b->city // '', + zipcode => $b->zipcode // '', + country => $b->country // '', + branchcode => $b->branchcode // '', + branchname => $b->library->branchname // '', }; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc index 0c1daae17f..660d492cfe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc @@ -19,8 +19,12 @@ } var name; - var firstname = escape_str(patron.firstname); - var surname = escape_str(patron.surname); + var firstname = escape_str(patron.firstname); + var surname = escape_str(patron.surname); + + if ( patron.middle_name != null && patron.middle_name != '' ) { + firstname += ' ' + escape_str(patron.middle_name); + } if ( patron.other_name != null && patron.other_name != '' ) { firstname += ' (' + escape_str(patron.other_name) + ')'; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index de738dab2b..7f7615f030 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -61,7 +61,7 @@ + [% IF ( mandatorymiddle_name ) %] + Required + [% END %] + + [% END #/UNLESS nomiddle_name %] [% UNLESS nodateofbirth %]
  • [% IF ( mandatorydateofbirth ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt index 93bb308d9d..cadd9fc2f7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt @@ -19,6 +19,7 @@ [% CASE 'branchcode' %]Home library (branchcode) [% CASE 'surname' %]Surname [% CASE 'firstname' %]First name +[% CASE 'middle_name' %]Middle name [% CASE 'title' %]Title [% CASE 'othernames' %]Other names [% CASE 'initials' %]Initials diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-title.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-title.inc index d77961d713..d34475359d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-title.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-title.inc @@ -4,5 +4,5 @@ [%- IF patron.title -%] [% patron.title | html %] [%- END -%] - [% patron.firstname | html %] [% patron.surname | html %] + [% patron.firstname | html %] [% patron.middle_name | html %] [% patron.surname | html %] [%- END -%] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 4e1a4fd692..6172eb347c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -176,7 +176,7 @@ Guaranteed by [% FOREACH gr IN patron.guarantor_relationships %] [% SET g = gr.guarantor %] - [% g.firstname | html %] [% g.surname | html %] + [% g.firstname | html %] [% g.middle_name %] [% g.surname | html %] [%- IF ! loop.last %], [% END %] [% END %] @@ -193,7 +193,7 @@
    - [% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'dateofbirth' 'initials' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' ] %] + [% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'middle_name' 'dateofbirth' 'initials' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' ] %] [% IF mandatory.defined( field ) %] [% SET required.$field = 'required' %] [% END %] @@ -300,7 +300,7 @@ [% END # / defined 'branchcode' %] [%# Following on one line for translatability %] - [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %] + [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('middle_name') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %]
    @@ -343,6 +343,15 @@
  • [% END %] + [% UNLESS hidden.defined('middle_name') %] +
  • + + + +
    Required
    +
  • + [% END %] + [% UNLESS hidden.defined('dateofbirth') %]
  • -- 2.20.1