From 4e773eafac3cd38d1a1399cbefcdbe996058ddf1 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 --- .../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 0000000000..5c522abf3a --- /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 9dd015b99e..5d810938a9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -809,52 +809,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 e37050d1af..276c25fdd5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -245,20 +245,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 04c8c3e655..0bccd017b4 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -606,51 +606,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