From 172c8cd87264e958b90f629dc9f57138739c784b Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 4 Mar 2016 21:34:07 +0000 Subject: [PATCH] Bug 3534 - Patron quick add form MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a new system preference: PatronQuickAddFields When either this pref or BorrowerMandatoryField is populated this will add a new dropdown to the bew patron toolbar. When a category is chosen from this dropdown the fields in PatronQuickAddFields and BorrowerMandatoryField will be displayed. There will be a button allowing a user to switch from the quickadd to the full form and fields will be copied between the forms when toggling. The Quick add will only be displayed on add of a new patron, future edits should display the full form. Test plan: 1 - Apply patch 2 - run updatedatabase.pl 3 - Add a new patron and ensure nothing has changed 4 - Populate either PatronQuickAddFields or BorrowerMandatory fields and note the new button for adding a patron 5 - Click the Quick add and choose a type 6 - Only required or quick add fields should be displayed 7 - Verify toggling forms copies information 8 - Ensure you cannot save patron without filling required fields (quick add fields should be optional) 9 - Ensure you can save patron with fields filled out 10 - Ensure that a duplicate patron brings up the duplicate/add new buttons with full form displayed 11 - Verify that subsequent edits use only full form 12 - Verify that data on form submitted is the data saved to patron 13 - Test with various values in both MandatoryBorrowerFields and PatronQuickAddFields Sponsored by: VOKAL (Vermont Organization of Koha Automated Libraries) Followed test plan, works as expected. Re-tested together with followup, works as expected (2016-06-02) Signed-off-by: Marc VĂ©ron --- .../bug_3534_add_PatronQuickAdd_sysprefs.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../prog/en/includes/patron-toolbar.inc | 10 +++ .../prog/en/modules/admin/preferences/patrons.pref | 5 ++ .../prog/en/modules/members/memberentrygen.tt | 99 +++++++++++++++++++--- members/memberentry.pl | 2 + 6 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_3534_add_PatronQuickAdd_sysprefs.sql diff --git a/installer/data/mysql/atomicupdate/bug_3534_add_PatronQuickAdd_sysprefs.sql b/installer/data/mysql/atomicupdate/bug_3534_add_PatronQuickAdd_sysprefs.sql new file mode 100644 index 0000000..b210b0d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_3534_add_PatronQuickAdd_sysprefs.sql @@ -0,0 +1 @@ +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronQuickAddFields', '', 'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if chosen at patron entry', NULL, 'Free'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 2b95c99..ac60777 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -381,6 +381,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('PatronSelfRegistrationVerifyByEmail','0',NULL,'If enabled, any patron attempting to register themselves via the OPAC will be required to verify themselves via email to activate his or her account.','YesNo'), ('PatronsPerPage','20','20','Number of Patrons Per Page displayed by default','Integer'), ('EnablePayPalOpacPayments', '0', NULL , 'Enables the ability to pay fees and fines from the OPAC via PayPal', 'YesNo' ), +('PatronQuickAddFields', '', NULL , 'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if chosen at patron entry', 'Free' ), ('PayPalChargeDescription', 'Koha fee payment', NULL , 'This preference defines what the user will see the charge listed as in PayPal', 'Free'), ('PayPalPwd', '', NULL , 'Your PayPal API password', 'Free'), ('PayPalSandboxMode', '1', NULL , 'If enabled, the system will use PayPal''s sandbox server for testing, rather than the production server.', 'YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc index 88c477f..0ad0308 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc @@ -1,4 +1,5 @@ [% USE Categories %] +[% USE Koha %] [% SET categories = Categories.all %] [% UNLESS ( no_add ) %] @@ -9,8 +10,17 @@ [% FOREACH category IN categories %]
  • [% category.description %]
  • [% END %] + [% IF Koha.Preference('PatronQuickAddFields') || Koha.Preference('BorrowerMandatoryField') %] +
    + + +
    + [% END %] [% IF CAN_user_tools_manage_patron_lists %] Patron lists [% END %] + [% END %] 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 4dc43db..61c1bd6 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 @@ -100,6 +100,11 @@ Patrons: class: integer - results per page in the staff client. - + - pref: PatronQuickAddFields + class: multi + - (separate columns with |) + - "add these fields to the patron quick add form when entering a new patron. Displays only mandatory fields and fields specified here" + - - "Use the SMS::Send::" - pref: SMSSendDriver - driver to send SMS messages. 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 12c1e83..d78acaf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -17,6 +17,44 @@ $(document).ready(function() { [% END %] }); +$(document).ready(function() { + + var toggle_quick_add = $(".toggle_quick_add"); + $(toggle_quick_add).click(function(e){ + toggle_quick_add.toggle(); + e.preventDefault(); + var toggle_to = ''; + var toggle_from = ''; + if( $("#entryform:visible").length ) { + toggle_to = "#quick_add_form label"; + toggle_from = "#entryform label"; + } else { + toggle_to="#entryform label"; + toggle_from = "#quick_add_form label"; + } + $(toggle_from).each(function() { + var input_label = $(this).attr('for'); + if ( input_label == 'sex-male' || input_label == 'sex-none' || input_label == 'sex-female' ) { + $(toggle_to+"[for='"+input_label+"']").next().prop('checked', $(this).next().prop('checked') ); + return; + } + if( $(this).next().val() != '' ) { $(toggle_to+"[for='"+input_label+"']").next().val( $(this).next().val() );} + }); + + $(".toggler").toggle(); + }); + + $(".save_quick_add").click(function(){ + $("#quick_add_form").validate(); + if( $("#quick_add_form").valid()){ + $('.toggle_quick_add').click(); + $('#entryform button[name="save"]').click(); + } + else {return false;} + }); + +}); + var MSG_SEPARATOR = _("Separator must be / in field %s"); var MSG_INCORRECT_DAY = _("Invalid day entered in field %s"); var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s"); @@ -43,12 +81,12 @@ $(document).ready(function() { [% INCLUDE 'header.inc' %] [% INCLUDE 'patron-search.inc' %] -