From 4345a7c1c5ccbd6caed49598421e2a7301972df4 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 5 Apr 2017 04:04:52 +0000 Subject: [PATCH] Bug 3137: HideFieldsAddPatronForm syspref This patches adds a syspref - HideFieldsAddPatronFrom - that controls which fieldsets are hidden by default in the add patron form. To test: 1) Apply patch and refresh page 2) Go to System preferences and confirm HideFieldsAddPatronForm has no fields selected 3) Go to add a patron / edit an existing patron (any patron category). confirm everything still works as expected. 4) Tick some of the fields in the syspref to hide them in the form 5) Go back to add patron form. 6) Confirm these fields are hidden and listed at the top of the page 7) Toggle the checkbox and confirm the hidden fields show or hide as expected. Sponsored-by: Catalyst IT --- ..._3137_-_add_HideFieldsAddPatronForm_syspref.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/patrons.pref | 18 ++++ .../prog/en/modules/members/memberentrygen.tt | 109 +++++++++++++++++++-- 4 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_3137_-_add_HideFieldsAddPatronForm_syspref.sql diff --git a/installer/data/mysql/atomicupdate/bug_3137_-_add_HideFieldsAddPatronForm_syspref.sql b/installer/data/mysql/atomicupdate/bug_3137_-_add_HideFieldsAddPatronForm_syspref.sql new file mode 100644 index 0000000..6ffd585 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_3137_-_add_HideFieldsAddPatronForm_syspref.sql @@ -0,0 +1 @@ +INSERT IGNORE INTO systempreferences (`variable`,`value`,`options`,`explanation`,`type`) VALUES ('HideFieldsAddPatronForm', '', NULL, 'Hide these fields by default when adding new patron. These fields can still be expanded.', 'Multiple'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 7e249b7..893dd94 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -174,6 +174,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('GoogleOAuth2ClientID', '', NULL, 'Client ID for the web app registered with Google', 'Free'), ('GoogleOAuth2ClientSecret', '', NULL, 'Client Secret for the web app registered with Google', 'Free'), ('GoogleOpenIDConnectDomain', '', NULL, 'Restrict Google OpenID Connect to this domain (or subdomains of this domain). Leave blank for all Google domains', 'Free'), +('HideFieldsAddPatronForm', '', NULL, 'Hide these fields by default when adding new patron. These fields can still be expanded.', 'Multiple'), ('hidelostitems','0','','If ON, disables display of\"lost\" items in OPAC.','YesNo'), ('HidePatronName','0','','If this is switched on, patron\'s cardnumber will be shown instead of their name on the holds and catalog screens','YesNo'), ('hide_marc','0',NULL,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)','YesNo'), 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 4a85957..37557f8 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 @@ -1,6 +1,24 @@ Patrons: General: - + - When adding new patrons or editing existing patrons, hide the following fields from the form (can still be expanded later) + - pref: HideFieldsAddPatronForm + multiple: + identity: "Organization/Patron identity" + guarantor: Guarantor information + primary_address: Main address + primary_contact: Contact + alt_address: Alternate address + alt_contact: Alternate contact + lib_mgmt: Library management + lib_setup: Library set-up + login: OPAC/Staff login + flags: "Patron account flags (existing patrons)" + debarments: "Patron restrictions (existing patrons)" + housebound: Housebound roles + additional: Additional attributes and identifiers + messaging: Patron messaging preferences + - - pref: AutoEmailOpacUser choices: yes: Send 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 ff3ef68..28cef30 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -10,6 +10,17 @@ // [% END %] +[% SET fields_to_hide = Koha.Preference('HideFieldsAddPatronForm') %] + +[% IF Koha.Preference('HideFieldsAddPatronForm') %] +

+ Show hidden fields: + [% FOREACH field IN fields_to_hide.split(',') %] + [% SWITCH field %] + [% CASE 'identity' %] Organization/Patron identity | + [% CASE 'guarantor' %] Guarantor information | + [% CASE 'primary_address' %] Main address | + [% CASE 'primary_contact' %] Contact | + [% CASE 'alt_address' %] Alternate address | + [% CASE 'alt_contact' %] Alternate contact | + [% CASE 'lib_mgmt' %] Library management | + [% CASE 'lib_setup' %] Library set-up | + [% CASE 'login' %] OPAC/Staff login | + [% CASE 'flags' %] Patron account flags | + [% CASE 'debarments' %] Patron restrictions | + [% CASE 'housebound' %] Housebound roles | + [% CASE 'additional' %] Additional attributes and identifiers | + [% CASE 'messaging' %] Patron messaging preferences | + [% END %] + [% END %] +

+[% END %]
[% UNLESS ( check_member ) %] @@ -251,9 +287,13 @@ $(document).ready(function() { [% IF ( step_1 ) %] [%UNLESS notitle && nosurname && nofirstname && nodateofbirth && noinitials && noothernames &&nosex %] -
+[% IF fields_to_hide.search('identity') %] +
+[% ELSE %] +
+[% END %] [% IF ( I ) %]Organization [% ELSE %]Patron [% END %]identity -
    +
      [% UNLESS ( I ) %] [% UNLESS notitle %] [% IF Koha.Preference('BorrowersTitles') %] @@ -388,7 +428,11 @@ $(document).ready(function() { [% UNLESS step_6 %] [% END %] -
      + [% IF fields_to_hide.search('guarantor') %] +
      + [% ELSE %] +
      + [% END %] Guarantor information
        [% IF ( P ) %] @@ -484,15 +528,24 @@ $(document).ready(function() { [% END %] [% UNLESS noaddress && noaddress2 && nocity && nostate && nozipcode && nocountry %] +[% IF fields_to_hide.search('primary_address') %] +
        +[% ELSE %] [% IF Koha.Preference( 'AddressFormat' ) %] [% INCLUDE "member-main-address-style-${ Koha.Preference( 'AddressFormat' ) }.inc" %] [% ELSE %] [% INCLUDE 'member-main-address-style-us.inc' %] [% END %] +[% END %] +[% IF fields_to_hide.search('primary_address') %]
        [% END %] [% END # nostreet && nocity etc group%] [% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %] +[% IF fields_to_hide.search('primary_contact') %] +
        +[% ELSE %]
        +[% END %] Contact
          [% UNLESS nophone %]
        1. @@ -577,27 +630,41 @@ $(document).ready(function() { [% IF ( step_6 ) %] [% UNLESS noB_address && noB_address2 && noB_city && noB_zipcode && noB_state && noB_country &&nocontactnote && noB_phone && noB_email %] + [% IF fields_to_hide.search('alt_address') %] +
          + [% ELSE %] [% IF Koha.Preference( 'AddressFormat' ) %] [% INCLUDE "member-alt-address-style-${ Koha.Preference( 'AddressFormat' ) }.inc" %] [% ELSE %] [% INCLUDE 'member-alt-address-style-us.inc' %] [% END %] + [% END %] + [% IF fields_to_hide.search('alt_address') %]
          [% END %] [% END # UNLESS noB_address && noB_city && noB_state && noB_phone && noB_email %] [% END %] [% IF ( step_2 ) %] [% UNLESS noaltcontactsurname && noaltcontactfirstname && noaltcontactaddress1 && noaltcontactaddress2 && noaltcontactaddress3 && noaltcontactstate && noaltcontactzipcode && noaltcontactcountry && noaltcontactphone %] + [% IF fields_to_hide.search('alt_contact') %] +
          + [% ELSE %] [% IF Koha.Preference( 'AddressFormat' ) %] [% INCLUDE "member-alt-contact-style-${ Koha.Preference( 'AddressFormat' ) }.inc" %] [% ELSE %] [% INCLUDE 'member-alt-contact-style-us.inc' %] [% END %] + [% END %] + [% IF fields_to_hide.search('alt_contact') %]
          [% END %] [% END # UNLESS noaltcontactsurname && noaltcontactfirstname etc %] [% END %] [% IF ( step_3 ) %] [% SET autoMemberNum = Koha.Preference('autoMemberNum') %] -
          + [% IF fields_to_hide.search('lib_mgmt') %] +
          + [% ELSE %] +
          + [% END %] Library management
            [% UNLESS nocardnumber %]
          1. @@ -723,7 +790,11 @@ $(document).ready(function() {
          [% UNLESS nodateenrolled && noopacnote && noborrowernotes %] -
          + [% IF fields_to_hide.search('lib_setup') %] +
          + [% ELSE %] +
          + [% END %] Library set-up
            [% UNLESS nodateenrolled %]
          1. @@ -802,7 +873,11 @@ $(document).ready(function() { [% END # hide fieldset %] [% UNLESS nouserid && nopassword %] -
            + [% IF fields_to_hide.search('login') %] +
            + [% ELSE %] +
            + [% END %] OPAC/Staff login
              [% UNLESS nouserid %]
            1. @@ -924,7 +999,11 @@ $(document).ready(function() { [% END # hide fieldset %][% END %] [% UNLESS ( opadd || opduplicate ) %] -
              + [% IF fields_to_hide.search('flags') %] +
              + [% ELSE %] +
              + [% END %] Patron account flags
                [% FOREACH flagloo IN flagloop %] @@ -957,7 +1036,11 @@ $(document).ready(function() {
              + [% IF fields_to_hide.search('restrictions') %] +
              + [% ELSE %]
              + [% END %] Patron restrictions [% IF ( debarments ) %] @@ -1021,7 +1104,11 @@ $(document).ready(function() { [% IF ( step_4 ) %] [% IF Koha.Preference('HouseboundModule') %] +[% IF fields_to_hide.search('housebound') %] +
              +[% ELSE %]
              +[% END %] Housebound roles
              1. @@ -1070,7 +1157,11 @@ $(document).ready(function() {
              [% END # hide fieldset %] [% IF ( ExtendedPatronAttributes ) %][% UNLESS ( no_patron_attribute_types ) %] +[% IF fields_to_hide.search('additional') %] +
              +[% ELSE %]
              +[% END %] Additional attributes and identifiers [% FOREACH pa_loo IN patron_attributes %] @@ -1114,7 +1205,11 @@ $(document).ready(function() { [% END %][% END %][% END %] [% IF ( step_5 ) %][% IF ( EnhancedMessagingPreferences ) %] +[% IF fields_to_hide.search('messaging') %] +
              +[% ELSE %]
              +[% END %] Patron messaging preferences [% IF ( opadd ) %]