From 8277ae03b2f8ad8a0559d7bb85979afd7eef6194 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 30 Sep 2021 12:43:39 +0000 Subject: [PATCH] Bug 28633: (follow-up) Show legal name and add preferredname to searches This patch adds to the DB update a condition to add 'preferredname' to DefaultPatronSearchFields. It also adjust the koha defaults to include it if the pref is empty The 'firstname' is displayed as 'Legal name' on the details page, with id/class to allow ajusting via JS/CSS PatronAutoComplete/ysearch is updated to use 'effective_name' method To test: 1 - Aply patches and updatedatabase and restart_all 2 - Add a preferredname to a patron 3 - Verify DefaultPatronSearchFields contains 'preferredname' if your pref had firstname Add preferredname if not 4 - Perform checkout and patron search using preferredname, confirm patron is found 5 - On patron's detail page confirm 'Legal name' shows 6 - Remove patron's first name, confirm 'Legal name' is no longer present 7 - Enable PatronAutoComplete system preference 8 - Type patron's surname into Checkout or patron search but don't hit enter 9 - Confirm patron is dsiplayed with 'preferredname' in the preview --- C4/Utils/DataTables/Members.pm | 2 +- circ/ysearch.pl | 2 +- .../{bug_28633.perl => bug_28633.pl} | 18 +++++++++++++----- .../prog/en/includes/patronfields.inc | 2 +- .../en/modules/admin/preferences/patrons.pref | 2 +- .../prog/en/modules/members/moremember.tt | 6 ++++++ 6 files changed, 23 insertions(+), 9 deletions(-) rename installer/data/mysql/atomicupdate/{bug_28633.perl => bug_28633.pl} (56%) diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm index 3d677b8e01..7273b945c4 100644 --- a/C4/Utils/DataTables/Members.pm +++ b/C4/Utils/DataTables/Members.pm @@ -113,7 +113,7 @@ sub search { } my $searchfields = { - standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid', + standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,preferredname,othernames,cardnumber,userid', email => 'email,emailpro,B_email', borrowernumber => 'borrowernumber', phone => 'phone,phonepro,B_phone,altcontactphone,mobile', diff --git a/circ/ysearch.pl b/circ/ysearch.pl index dd04aaf966..b26eba3f18 100755 --- a/circ/ysearch.pl +++ b/circ/ysearch.pl @@ -84,7 +84,7 @@ while ( my $b = $borrowers_rs->next ) { push @borrowers, { borrowernumber => $b->borrowernumber, surname => $b->surname // '', - firstname => $b->firstname // '', + firstname => $b->effective_name // '', cardnumber => $b->cardnumber // '', dateofbirth => format_sqldatetime($b->dateofbirth, undef, undef, 1) // '', age => $b->get_age // '', diff --git a/installer/data/mysql/atomicupdate/bug_28633.perl b/installer/data/mysql/atomicupdate/bug_28633.pl similarity index 56% rename from installer/data/mysql/atomicupdate/bug_28633.perl rename to installer/data/mysql/atomicupdate/bug_28633.pl index 2cb0cbcd8d..251697bb63 100644 --- a/installer/data/mysql/atomicupdate/bug_28633.perl +++ b/installer/data/mysql/atomicupdate/bug_28633.pl @@ -13,7 +13,7 @@ return { COMMENT "patron/borrower's preferred name" AFTER firstname }); - say $out "Add preferred name column to borrowers table"; + say $out "Added preferred name column to borrowers table"; } if( !column_exists( 'deletedborrowers', 'preferredname' ) ) { $dbh->do(q{ @@ -22,7 +22,7 @@ return { COMMENT "patron/borrower's preferred name" AFTER firstname }); - say $out "Add preferred name column to deletedborrowers table"; + say $out "Added preferred name column to deletedborrowers table"; } if( !column_exists( 'borrower_modifications', 'preferredname' ) ) { $dbh->do(q{ @@ -31,9 +31,17 @@ return { COMMENT "patron/borrower's preferred name" AFTER firstname }); - say $out "Add preferred name column to borrower_modifications table"; + say $out "Added preferred name column to borrower_modifications table"; + } + my @default_patron_search_fields = split(',',C4::Context->preference('DefaultPatronSearchFields')); + unless( grep /preferredname/, @default_patron_search_fields ){ + if( grep /firstname/, @default_patron_search_fields ){ + push @default_patron_search_fields,'preferredname'; + C4::Context->set_preference('DefaultPatronSearchFields', join(',',@default_patron_search_fields) ); + say $out "Added preferred name to DefaultPatronSearchFields"; + } else { + say $out "Please add 'preferredname' to DefaultPatronSearchFields if you want it searched by default"; + } } - $dbh->do(q{}); - # Print useful stuff here }, } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc index e9b2680e46..1f5ef69e50 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc @@ -5,7 +5,7 @@ [%- CASE 'cardnumber' -%]Card number [%- CASE 'surname' -%]Surname [%- CASE 'firstname' -%]First name - [%- CASE 'firstname' -%]Preferred name + [%- CASE 'preferredname' -%]Preferred name [%- CASE 'title' -%]Salutation [%- CASE 'othernames' -%]Other name [%- CASE 'initials' -%]Initials 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 5a6f1bd5a4..4e60f8dea6 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 @@ -48,7 +48,7 @@ Patrons: - "Comma separated list defining the default fields to be used during a patron search using the \"standard\" option:" - pref: DefaultPatronSearchFields class: multi - - "If empty Koha will default to \"surname,firstname,othernames,cardnumber,userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page." + - "If empty Koha will default to \"surname,firstname,preferredname,othernames,cardnumber,userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page." - - "Show the following fields from the items database table as columns on the statistics tab on the patron record: " - pref: StatisticsFields 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 ee7558cb06..2c4dbc1503 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -124,6 +124,12 @@
    + [% IF ( patron.preferredname && patron.firstname ) %] + + [% END %] [% IF ( patron.phone ) %]
  1. Primary phone: -- 2.20.1