From d6d49d46814579b13994cf855fcc164b8fadbd92 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 24 Feb 2023 20:55:25 +0000 Subject: [PATCH] Bug 31498: Make primary_contact_method values configurable This patch makes the primary_contact_method field configurable by tying the values to the new CONTACT_METHODS authorized value. To test: 1. Apply patch, updatedatabase, and restart_all 2. Now to go edit or create a new patron and check the 'Main contact method' dropdown. The values should be the same as they were previuosly. ( Primary phone, Secondary phone, Other phone, Primary email, Secondary email, and Fax ) 3. Try editing some patrons and changing these values, making sure they save correctly. 4. Go to the patron detail tab and make sure the correct values are displaying under 'Main contact method'. 5. Go to the OPAC and trying saving and changing the values on both the self registratin form and the modification form. 6. Now go to Administration > Authorized values > CONTACT_METHODS. Add some new CONTACT_METHODS. 7. With some ew values added try going through steps 3, 4, and 5 again. Make sure everything is displaying and saving correctly. 8. Make sure you can still hide and make required the primary_contact_method via these system prefs: BorrowerUnwantedField, PatronSelfModificationBorrowerUnwantedField, PatronSelfRegistrationBorrowerUnwantedField BorrowerMandatoryField, PatronSelfRegistrationBorrowerMandatoryField Signed-off-by: Christopher Brannon Signed-off-by: Aleisha Amohia --- .../bug_31498_add_primary_contact_av.pl | 31 ++++++++++ .../prog/en/modules/members/memberentrygen.tt | 59 ++++--------------- .../prog/en/modules/members/moremember.tt | 15 +---- .../bootstrap/en/modules/opac-memberentry.tt | 54 ++++------------- 4 files changed, 56 insertions(+), 103 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_31498_add_primary_contact_av.pl diff --git a/installer/data/mysql/atomicupdate/bug_31498_add_primary_contact_av.pl b/installer/data/mysql/atomicupdate/bug_31498_add_primary_contact_av.pl new file mode 100755 index 00000000000..5c522abf3a6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_31498_add_primary_contact_av.pl @@ -0,0 +1,31 @@ +use Modern::Perl; + +return { + bug_number => "31498", + description => "Add CONTACT_METHODS authorized value category", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + $dbh->do(q{ + INSERT IGNORE INTO authorised_value_categories (category_name, is_system) + VALUES + ('CONTACT_METHODS', 1) + }); + + say $out "Added CONTACT_METHODS authorized value category"; + + $dbh->do(q{ + INSERT IGNORE INTO authorised_values (category, authorised_value, lib) + VALUES + ('CONTACT_METHODS', 'phone', 'Primary phone'), + ('CONTACT_METHODS', 'phonepro', 'Secondary phone'), + ('CONTACT_METHODS', 'mobile', 'Other phone'), + ('CONTACT_METHODS', 'email', 'Primary email'), + ('CONTACT_METHODS', 'emailpro', 'Secondary email'), + ('CONTACT_METHODS', 'fax', 'Fax') + }); + + say $out "Add values to CONTACT_METHODS"; + }, +}; 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 3461e6fb9d5..e2b6daea95c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -795,52 +795,19 @@ legend:hover { - - + [% SET contact_methods = AuthorisedValues.GetAuthValueDropbox('CONTACT_METHODS') %] + [% IF contact_methods.count %] + + [% END %] [% IF mandatoryprimary_contact_method %] Required [% 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 e43206e9877..db1a4a8c2ea 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -243,20 +243,7 @@ [% IF ( patron.primary_contact_method ) %]
  • Main contact method: - [% SWITCH patron.primary_contact_method %] - [% CASE 'phone' %] - Primary phone - [% CASE 'phonepro' %] - Secondary phone - [% CASE 'mobile' %] - Other phone - [% CASE 'email' %] - Primary email - [% CASE 'emailpro' %] - Secondary email - [% CASE 'fax' %] - Fax - [% END %] + [% AuthorisedValues.GetByCode('CONTACT_METHODS', patron.primary_contact_method) | 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 a21d631d5ab..f4c4f018725 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -636,51 +636,19 @@ [% END %] - - [% UNLESS hidden.defined('phone') %] - [% IF ( borrower.primary_contact_method == 'phone' ) %] - - [% ELSE %] - - [% END %] - [% END %] - [% UNLESS hidden.defined('phonepro') %] - [% IF ( borrower.primary_contact_method == 'phonepro' ) %] - - [% ELSE %] - - [% END %] - [% END %] - [% UNLESS hidden.defined('mobile') %] - [% IF ( borrower.primary_contact_method == 'mobile' ) %] - - [% ELSE %] - - [% END %] - [% END %] - [% UNLESS hidden.defined('email') %] - [% IF ( borrower.primary_contact_method == 'email' ) %] - - [% ELSE %] - - [% END %] - [% END %] - [% UNLESS hidden.defined('emailpro') %] - [% IF ( borrower.primary_contact_method == 'emailpro' ) %] - - [% ELSE %] - - [% END %] - [% END %] - [% UNLESS hidden.defined('fax') %] - [% IF ( borrower.primary_contact_method == 'fax' ) %] - - [% ELSE %] - + [% FOR contact_method IN contact_methods %] + [% IF contact_method.authorised_value == patron.primary_contact_method %] + + [% ELSE %] + + [% END %] [% END %] - [% END %] - + + [% END %] [% IF ( mandatory.defined('primary_contact_method') ) %]Required[% END %] [% END %] -- 2.30.2