Bugzilla – Attachment 52934 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.50 KB, created by
Nick Clemens (kidclamp)
on 2016-06-28 17:06:00 UTC
(
hide
)
Description:
Bug 3534 - Patron quick add form
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2016-06-28 17:06:00 UTC
Size:
15.50 KB
patch
obsolete
>From aea37a35d4059129d820e2fb9eedaf34eb50ebab 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 | 96 +++++++++++++++++++--- > members/memberentry.pl | 2 + > 6 files changed, 104 insertions(+), 11 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 af42f66..a6582cc 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -383,6 +383,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 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 17eeb5b..7eef3da 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -33,6 +33,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"); >@@ -59,12 +97,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"> >@@ -85,7 +123,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> >@@ -118,12 +161,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 %] >@@ -156,7 +199,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 %]" /> >@@ -430,7 +473,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"> >@@ -480,7 +523,7 @@ $(document).ready(function() { > [% END %] > [% UNLESS noemailpro %] > <li> >- [% IF ( mandatoryemailpro ) %] >+ [% IF ( mandatoryemailpro ) %] > <label for="emailpro" class="required"> > [% ELSE %] > <label for="emailpro"> >@@ -693,7 +736,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> >@@ -702,7 +745,7 @@ $(document).ready(function() { > [% END %] > [% UNLESS noborrowernotes %] > <li> >- [% IF ( mandatoryborrowernotes ) %] >+ [% IF ( mandatoryborrowernotes ) %] > <label for="borrowernotes" class="required"> > [% ELSE %] > <label for="borrowernotes"> >@@ -1044,7 +1087,38 @@ $(document).ready(function() { > [% END %] [% END %] > > </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' ); >-- >2.1.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