Bugzilla – Attachment 51960 Details for
Bug 3534
Patron quick add form
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 3534 - Patron quick add form
Bug-3534---Patron-quick-add-form.patch (text/plain), 15.98 KB, created by
Marc Véron
on 2016-06-02 07:04:56 UTC
(
hide
)
Description:
Bug 3534 - Patron quick add form
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2016-06-02 07:04:56 UTC
Size:
15.98 KB
patch
obsolete
>From a7bfa5a16a52273de552484be167f4fd08fceddd Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >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 <veron@veron.ch> >--- > .../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 %]<li><a href="/cgi-bin/koha/members/memberentry.pl?op=add&categorycode=[% category.categorycode %]">[% category.description %]</a></li>[% END %] > </ul> > </div> >+ [% IF Koha.Preference('PatronQuickAddFields') || Koha.Preference('BorrowerMandatoryField') %] >+ <div class="btn-group"> >+ <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> Quick add new patron <span class="caret"></span></button> >+ <ul class="dropdown-menu"> >+ [% FOREACH category IN categories %]<li><a href="/cgi-bin/koha/members/memberentry.pl?op=add&categorycode=[% category.categorycode %]&quickadd=true">[% category.description %]</a></li>[% END %] >+ </ul> >+ </div> >+ [% END %] > [% IF CAN_user_tools_manage_patron_lists %] > <a class="btn btn-small" href="/cgi-bin/koha/patron_lists/lists.pl"><i class="fa fa-edit"></i>Patron lists</a> > [% END %] >+ > </div> > [% 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 f7b5706..feafc18 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 aa1de3e..be16f29 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' %] > >-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › > [% IF (firstname || surname ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]</a> ›[% END %] > <strong>[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron ([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</strong> > </div> > [% IF ( opadd ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %] >- >+ > <div id="bd"> > <div id="yui-main"> > <div class="yui-b"> >@@ -69,7 +107,12 @@ $(document).ready(function() { > > [% UNLESS ( no_add ) %] > <h1>[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</h1> >- >+ >+ [% IF quickadd && opadd && !check_member %] >+ <a href="#" class="toggle_quick_add"><i class="fa fa-plus-square"></i> Show full form</a> >+ <a href="#" class="toggle_quick_add" style="display:none"><i class="fa fa-minus-square"></i> Show brief form</a> >+ [% END %] >+ > [% IF ( check_member ) %] > <div class="dialog alert"> > <h3>Duplicate patron record?</h3> >@@ -102,12 +145,12 @@ $(document).ready(function() { > <li id="ERROR_cardnumber">Cardnumber length is incorrect.</li> > [% END %] > [% IF ( ERROR_age_limitations ) %] >- <li id="ERROR_age_limitations">Patron's age is incorrect for their category. >+ <li id="ERROR_age_limitations">Patron's age is incorrect for their category. > Ages allowed are [% age_low %]-[% age_high %].</li> > [% END %] > [% IF ( ERROR_branch ) %] > <li id="ERROR_branch">Library is invalid.</li> >- [% END %] >+ [% END %] > [% IF ( ERROR_dateofbirth ) %] > <li id="ERROR_dateofbirth">Date of birth is invalid.</li> > [% END %] >@@ -140,7 +183,7 @@ $(document).ready(function() { > [% END %] > > >-[% UNLESS ( check_member ) %]<form name="form" id="entryform" action="/cgi-bin/koha/members/memberentry.pl" method="post" autocomplete="off"> >+[% UNLESS ( check_member ) %]<form name="form" id="entryform" action="/cgi-bin/koha/members/memberentry.pl" method="post" autocomplete="off" class="toggler" > > <input type="hidden" name="nodouble" value="[% nodouble %]" /> [% END %] > <!-- field always hidden in different form (1,2,3) --> > <input type="hidden" name="BorrowerMandatoryField" value="[% BorrowerMandatoryField %]" /> >@@ -398,7 +441,7 @@ $(document).ready(function() { > <legend id="contact_lgd">Contact</legend><ol> > [% UNLESS nophone %] > <li> >- [% IF ( mandatoryphone ) %] >+ [% IF ( mandatoryphone ) %] > <label for="phone" class="required"> > [% ELSE %] > <label for="phone"> >@@ -448,7 +491,7 @@ $(document).ready(function() { > [% END %] > [% UNLESS noemailpro %] > <li> >- [% IF ( mandatoryemailpro ) %] >+ [% IF ( mandatoryemailpro ) %] > <label for="emailpro" class="required"> > [% ELSE %] > <label for="emailpro"> >@@ -661,7 +704,7 @@ $(document).ready(function() { > <label for="opacnote" class="required"> > [% ELSE %] > <label for="opacnote"> >- [% END %] >+ [% END %] > OPAC note: </label> > <textarea id="opacnote" name="opacnote" cols="55" rows="5">[% UNLESS opduplicate %][% opacnote %][% END %]</textarea> > <div class="hint">This message appears on this patron's user page in the OPAC</div> >@@ -670,7 +713,7 @@ $(document).ready(function() { > [% END %] > [% UNLESS noborrowernotes %] > <li> >- [% IF ( mandatoryborrowernotes ) %] >+ [% IF ( mandatoryborrowernotes ) %] > <label for="borrowernotes" class="required"> > [% ELSE %] > <label for="borrowernotes"> >@@ -1017,7 +1060,7 @@ $(document).ready(function() { > <button type="submit" name="save" onclick="return check_form_borrowers();"> > <i class="fa fa-save"></i> Save > </button> >- [% IF ( opadd ) %] >+ [% IF ( opadd ) %] > <a class="cancel" href="/cgi-bin/koha/members/member.pl">Cancel</a> > [% ELSE %] > <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Cancel</a> >@@ -1025,8 +1068,40 @@ $(document).ready(function() { > </fieldset> > [% END %] > </fieldset> >+ > </form> >- >+ >+[% IF quickadd && opadd && !check_member %] >+ <form id="quick_add_form" class="toggler"> >+ <fieldset class="rows quick_add"><legend>Quick add</legend> >+ <ol id="quick_add_list"> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="action"> >+ <input type="button" class="save_quick_add" value="Save" /> >+ <a class="cancel" href="/cgi-bin/koha/members/member.pl">Cancel</a> >+ </fieldset> >+ >+ </form> >+ <script> >+ $(document).ready(function () { >+ $("#entryform").hide(); >+ [% q_add_f = Koha.Preference('PatronQuickAddFields').split('\|') %] >+ var qaddfields = "[% FOREACH field IN q_add_f.unique %][% field %] [% END %]"; >+ $("#entryform label").each(function () { >+ var input_label = $(this).attr('for'); >+ if ( input_label == 'sex-female' ) { input_label='sex'; } >+ else if ( input_label == 'btitle' ) { input_label='title'; } >+ if( qaddfields.indexOf( input_label ) != -1 || $(this).attr('class') == 'required' ){ >+ $(this).parent().clone().appendTo("#quick_add_list"); >+ if( input_label == 'password') $("#entryform label[for='password2']").parent().clone().appendTo("#quick_add_list"); >+ } >+ }); >+ $("#quick_add_form").show(); >+ }); >+ </script> >+[% END %] > </div> > </div> > >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 597c68d..aea21c3 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -86,6 +86,7 @@ my $cardnumber = $input->param('cardnumber'); > my $check_member = $input->param('check_member'); > my $nodouble = $input->param('nodouble'); > my $duplicate = $input->param('duplicate'); >+my $quickadd = $input->param('quickadd'); > $nodouble = 1 if ($op eq 'modify' or $op eq 'duplicate'); # FIXME hack to represent fact that if we're > # modifying an existing patron, it ipso facto > # isn't a duplicate. Marking FIXME because this >@@ -144,6 +145,7 @@ foreach (@field_check) { > $template->param( "no$_" => 1); > } > $template->param( "add" => 1 ) if ( $op eq 'add' ); >+$template->param( "quickadd" => 1 ) if ( $quickadd ); > $template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' ); > $template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); > ( $borrower_data = GetMember( 'borrowernumber' => $borrowernumber ) ) if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ); >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 3534
:
1396
|
50090
|
50091
|
50092
|
50093
|
50362
|
50410
|
50413
|
50414
|
50665
|
50666
|
50729
|
51382
|
51389
|
51445
|
51446
|
51960
|
51961
|
52192
|
52584
|
52585
|
52586
|
52934
|
52935
|
52936
|
52937
|
53109
|
53152
|
53171
|
53172
|
53173
|
53174
|
53175
|
84851