From 83d4456ebabe0f4af7f2bd52127bc19baf045511 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 This patch adds two new system preferences: PatronQuickAdd PatronQuickAddFields When enabled the pref will add a new form to memberentrygen composed of the fields in PatronQuickAddFields and BorrowerMandatoryField. There will be a button allowing a user to switch from the quickadd to the full form. 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 - Enable quick add (do not add any fields) 5 - Only required fields should be displayed 6 - Ensure you can save patron 7 - Verify that subsequent edits use only full form 8 - Verify that data on form submitted is the data saved to patron 9 - Add fields to PatronQuickAddFields 10 - check that fields are present in quick add form 11 - Ensure that you can save patron 12 - Test with various values in both MandatoryBorrowerFields and PatronQuickAddFields Sponsored by: VOKAL (Vermont Organization of Koha Automated Libraries) --- .../bug_3534_add_PatronQuickAdd_sysprefs.sql | 2 + installer/data/mysql/sysprefs.sql | 2 + .../prog/en/modules/admin/preferences/patrons.pref | 7 +++ .../prog/en/modules/members/memberentrygen.tt | 68 +++++++++++++++++++++- 4 files changed, 76 insertions(+), 3 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..5b3af8a --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_3534_add_PatronQuickAdd_sysprefs.sql @@ -0,0 +1,2 @@ +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('PatronQuickAdd', '0', 'Enables the ability to pay fees and fines from the OPAC via PayPal', NULL, 'YesNo'); +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 enabled', NULL, 'Free'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ef4c3f0..92a3d58 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -378,6 +378,8 @@ 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' ), +('PatronQuickAdd', '0', NULL , 'Enables the patron quick add form when entering a new patron. Displays only mandatory fields and fields specified in PatronQuickAddFields', 'YesNo' ), +('PatronQuickAddFields', '', NULL , 'A list of fields separated by "|" to be displayed along with mandatory fields in the patron quick add form if enabled', '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/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 22c2b27..c1c72da 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,13 @@ Patrons: class: integer - results per page in the staff client. - + - pref: PatronQuickAdd + choices: + yes: Use + no: "Don't use" + - "the patron quick add form when entering a new patron. Displays only mandatory fields and fields specified here:" + - pref: PatronQuickAddFields + - - "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 d54c29e..30d584b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -155,6 +155,33 @@ function select_user(borrowernumber, borrower) { hint.html(age_string); } +$(document).ready(function() { + $(".toggle_quick_add").click(function(){ + $(".toggler").toggle(); + return false; + }); + + $(".save_quick_add").click(function(){ + $("#quick_add_form label").each(function () { + var input_label = $(this).attr('for'); + if ( input_label == 'sex-male' || input_label == 'sex-none' ) { return; } + $("#entryform label[for='"+input_label+"']").parent().replaceWith( $(this).parent().clone() ); + if ( $(this).next().is('select') ) { + var cur_sel = $(this).next().val(); + $("#entryform label[for='"+input_label+"']").next().find('option[value="'+cur_sel+'"').prop('selected',true); + } + if ( $(this).next().is('textarea') ) { + var cur_text = $(this).next().val(); + $("#entryform label[for='"+input_label+"']").next().val( cur_text ); + } + }); + $("#quick_add_form input").each(function(){ + var cur_id = $(this).attr('id'); + $('#entryform #' + cur_id).val( $(this).val() ); + }); + $('#entryform input[name="save"]').click(); + }); + }); var MSG_SEPARATOR = _("Separator must be / in field %s"); var MSG_INCORRECT_DAY = _("Invalid day entered in field %s"); @@ -273,7 +300,7 @@ function select_user(borrowernumber, borrower) { [% END %] -[% UNLESS ( check_member ) %]
+[% UNLESS ( check_member ) %] [% END %] @@ -1150,16 +1177,51 @@ function select_user(borrowernumber, borrower) { [% UNLESS ( check_member ) %]
+ [% IF opadd %] + + [% END %] - [% IF ( opadd ) %] + [% IF ( opadd ) %] Cancel [% ELSE %] Cancel [% END %]
[% END %] +
- + +[% IF Koha.Preference('PatronQuickAdd') && opadd && !check_member %] +
+
Quick Add +
    +
+
+ +
+ + + Cancel +
+ +
+ +[% END %] -- 2.1.4