From ea4139de3db87f649b980accb43240d88073f79b Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 5 Apr 2017 04:04:52 +0000 Subject: [PATCH] [SIGNED-OFF] 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 update database 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 Signed-off-by: Owen Leonard --- ..._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 1cad43e..1ce05e5 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -180,6 +180,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('GoogleOpenIDConnectDefaultBranch', '','','This branch code will be used to create Google OpenID Connect patrons.','Textarea'), ('GoogleOpenIDConnectDefaultCategory','','','This category code will be used to create Google OpenID Connect patrons.','Textarea'), ('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 ac4946d..95e25fc 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 af75832..be84dc4 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 ) %] @@ -249,9 +285,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') %] @@ -386,7 +426,11 @@ $(document).ready(function() { [% UNLESS step_6 %] [% END %] -
      + [% IF fields_to_hide.search('guarantor') %] +
      + [% ELSE %] +
      + [% END %] Guarantor information
        [% IF ( P ) %] @@ -482,15 +526,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. @@ -575,27 +628,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. @@ -746,7 +813,11 @@ $(document).ready(function() {
          [% UNLESS nodateenrolled && noopacnote && noborrowernotes %] -
          + [% IF fields_to_hide.search('lib_setup') %] +
          + [% ELSE %] +
          + [% END %] Library set-up
            [% UNLESS nodateenrolled %]
          1. @@ -825,7 +896,11 @@ $(document).ready(function() { [% END # hide fieldset %] [% UNLESS nouserid && nopassword %] -
            + [% IF fields_to_hide.search('login') %] +
            + [% ELSE %] +
            + [% END %] OPAC/Staff login
              [% UNLESS nouserid %]
            1. @@ -947,7 +1022,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 %] @@ -980,7 +1059,11 @@ $(document).ready(function() {
              + [% IF fields_to_hide.search('restrictions') %] +
              + [% ELSE %]
              + [% END %] Patron restrictions [% IF ( debarments ) %] @@ -1044,7 +1127,11 @@ $(document).ready(function() { [% IF ( step_4 ) %] [% IF Koha.Preference('HouseboundModule') %] +[% IF fields_to_hide.search('housebound') %] +
              +[% ELSE %]
              +[% END %] Housebound roles
              1. @@ -1093,7 +1180,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 %] @@ -1137,7 +1228,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 ) %]