Bugzilla – Attachment 42252 Details for
Bug 14659
Allow patrons to enter card number and patron category on OPAC registration page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14659: Allow patrons to enter card number and patron category on OPAC registration page
Bug-14659-Allow-patrons-to-enter-card-number-and-p.patch (text/plain), 10.15 KB, created by
Jesse Weaver
on 2015-09-02 22:58:55 UTC
(
hide
)
Description:
Bug 14659: Allow patrons to enter card number and patron category on OPAC registration page
Filename:
MIME Type:
Creator:
Jesse Weaver
Created:
2015-09-02 22:58:55 UTC
Size:
10.15 KB
patch
obsolete
>From 4265d3a1969796ae18402eebd32042b7dc4fe157 Mon Sep 17 00:00:00 2001 >From: Jesse Weaver <pianohacker@gmail.com> >Date: Mon, 31 Aug 2015 17:45:16 -0600 >Subject: [PATCH] Bug 14659: Allow patrons to enter card number and patron > category on OPAC registration page > >Test plan: > 1. Open OPAC self-registration page while logged out. > 2. Note that cardnumber and categorycode are not shown. > 3. Remove cardnumber and categorycode from > PatronSelfRegistrationBorrowerUnwantedField. > 4. Enable autoMemberNum. > 5. Reload self-registration page, note that categorycode now shows. > 6. Disable autoMemberNum. > 7. Reload self-registration page, note that cardnumber now shows. > 8. Try saving a patron with an existing cardnumber; this should fail > and explain why. > 9. Set CardnumberLength, and verify that those length restrictions are > enforced. > 10. Verify that patron can be created with custom categorycode and > cardnumber. >--- > C4/Members.pm | 4 +- > Koha/Template/Plugin/Categories.pm | 15 +++++++ > ...lfRegistrationBorrowerUnwantedField_syspref.sql | 2 + > .../bootstrap/en/modules/opac-memberentry.tt | 52 ++++++++++++++++++++-- > opac/opac-memberentry.pl | 14 +++++- > 5 files changed, 80 insertions(+), 7 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_14659-add_cardnumber_categorycode_PatronSelfRegistrationBorrowerUnwantedField_syspref.sql > >diff --git a/C4/Members.pm b/C4/Members.pm >index 95fb4e7..b029963 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -2466,14 +2466,14 @@ sub GetBorrowersWithEmail { > sub AddMember_Opac { > my ( %borrower ) = @_; > >- $borrower{'categorycode'} = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); >+ $borrower{'categorycode'} //= C4::Context->preference('PatronSelfRegistrationDefaultCategory'); > > my $sr = new String::Random; > $sr->{'A'} = [ 'A'..'Z', 'a'..'z' ]; > my $password = $sr->randpattern("AAAAAAAAAA"); > $borrower{'password'} = $password; > >- $borrower{'cardnumber'} = fixup_cardnumber(); >+ $borrower{'cardnumber'} = fixup_cardnumber( $borrower{'cardnumber'} ); > > my $borrowernumber = AddMember(%borrower); > >diff --git a/Koha/Template/Plugin/Categories.pm b/Koha/Template/Plugin/Categories.pm >index 86630ca..fe8b0d7 100644 >--- a/Koha/Template/Plugin/Categories.pm >+++ b/Koha/Template/Plugin/Categories.pm >@@ -21,6 +21,16 @@ use Template::Plugin; > use base qw( Template::Plugin ); > > use C4::Category; >+use Koha::Database; >+ >+sub GetName { >+ my ( $self, $categorycode ) = @_; >+ >+ my $schema = Koha::Database->new->schema; >+ return $schema->resultset( 'Category' )->search( { >+ categorycode => $categorycode, >+ } )->get_column( 'description' )->next // ''; >+} > > sub all { > my ( $self, $params ) = @_; >@@ -56,6 +66,11 @@ Koha::Template::Plugin::Categories - TT Plugin for categories > In a template, you can get the all categories with > the following TT code: [% Categories.all() %] > >+=head2 GetName >+ >+In a template, you can get the name of a patron category using >+[% Categories.GetName( categorycode ) %]. >+ > =head1 AUTHOR > > Jonathan Druart <jonathan.druart@biblibre.com> >diff --git a/installer/data/mysql/atomicupdate/bug_14659-add_cardnumber_categorycode_PatronSelfRegistrationBorrowerUnwantedField_syspref.sql b/installer/data/mysql/atomicupdate/bug_14659-add_cardnumber_categorycode_PatronSelfRegistrationBorrowerUnwantedField_syspref.sql >new file mode 100644 >index 0000000..47f2515 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_14659-add_cardnumber_categorycode_PatronSelfRegistrationBorrowerUnwantedField_syspref.sql >@@ -0,0 +1,2 @@ >+UPDATE systempreferences SET value = CONCAT_WS('|', IF(value = '', NULL, value), 'cardnumber') WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField' AND value NOT LIKE '%cardnumber%'; >+UPDATE systempreferences SET value = CONCAT_WS('|', IF(value = '', NULL, value), 'categorycode') WHERE variable = 'PatronSelfRegistrationBorrowerUnwantedField' AND value NOT LIKE '%categorycode%'; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >index 4eed652..5cc9580 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -1,3 +1,4 @@ >+[% USE Categories %] > [% USE Koha %] > [% USE KohaDates %] > [% SET userupdateview = 1 %] >@@ -50,7 +51,7 @@ > <div class="alert">You have not filled out all required fields. Please fill in all missing fields and resubmit.</div> > [% END %] > >- [% IF invalid_form_fields %] >+ [% IF invalid_form_fields %] > <div class="alert alert-error"><strong>The following fields contain invalid information:</strong> > <ul> > [% FOREACH field IN invalid_form_fields %] >@@ -63,6 +64,17 @@ > </div> > [% END %] > >+ [% IF cardnumber_wrong_length || cardnumber_already_exists %] >+ <div class="alert alert-error"> >+ [% IF cardnumber_wrong_length %] >+ <strong>The entered <a href="#borrower_cardnumber">card number</a> is the wrong length.</strong> >+ [% ELSIF cardnumber_already_exists %] >+ <strong>The entered <a href="#borrower_cardnumber">card number</a> is already in use.</strong> >+ [% END %] >+ Please correct this and resubmit. >+ </div> >+ [% END %] >+ > [% IF failed_captcha %] > <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div> > [% END %] >@@ -74,10 +86,21 @@ > > <legend id="library_legend">Library</legend> > <ol> >- [% UNLESS hidden.defined('cardnumber') %] >+ [% UNLESS hidden.defined('cardnumber') || Koha.Preference('autoMemberNum') %] > <li> >- <label>Card number:</label> >- [% borrower.cardnumber %] >+ [% IF mandatory.defined('cardnumber') %] >+ <label for="borrower_cardnumber" class="required"> >+ [% ELSE %] >+ <label for="borrower_cardnumber"> >+ [% END %] >+ Library card number: >+ </label> >+ [% IF borrower %] >+ <input type="text" id="borrower_cardnumber" name="borrower_cardnumber" value="[% borrower.cardnumber %]" /> >+ [% IF mandatory.defined('cardnumber') %]<span class="required">Required</span>[% END %] >+ [% ELSE %] >+ [% borrower.cardnumber %] >+ [% END %] > </li> > [% END %] > >@@ -108,6 +131,27 @@ > </select> > </li> > [% END %] >+ >+ [% UNLESS hidden.defined('categorycode') %] >+ <li> >+ <label for="borrower_categorycode"> >+ Category:</label> >+ >+ [% IF borrower %] >+ <select id="borrower_categorycode" name="borrower_categorycode"> >+ [% FOREACH c IN Categories.all() %] >+ [% IF c.categorycode == Koha.Preference('PatronSelfRegistrationDefaultCategory') %] >+ <option value="[% c.categorycode %]" selected="selected">[% c.description %]</option> >+ [% ELSE %] >+ <option value="[% c.categorycode %]">[% c.description %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ [% ELSE %] >+ [% Categories.GetName( borrower.categorycode ) %] >+ [% END %] >+ </li> >+ [% END %] > </ol> > </fieldset> > [% END # / defined 'branchcode' %] >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index f9f9bc7..504b29c 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -77,8 +77,20 @@ if ( $action eq 'create' ) { > > my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action ); > my $invalidformfields = CheckForInvalidFields(\%borrower); >+ my $cardnumber_error_code; >+ if ( !grep { $_ eq 'cardnumber' } @empty_mandatory_fields ) { >+ # No point in checking the cardnumber if it's missing and mandatory, it'll just generate a >+ # spurious length warning. >+ $cardnumber_error_code = checkcardnumber( $borrower{cardnumber}, $borrower{borrowernumber} ); >+ } >+ >+ if ( @empty_mandatory_fields || @$invalidformfields || $cardnumber_error_code ) { >+ if ( $cardnumber_error_code == 1 ) { >+ $template->param( cardnumber_already_exists => 1 ); >+ } elsif ( $cardnumber_error_code == 2 ) { >+ $template->param( cardnumber_wrong_length => 1 ); >+ } > >- if (@empty_mandatory_fields || @$invalidformfields) { > $template->param( > empty_mandatory_fields => \@empty_mandatory_fields, > invalid_form_fields => $invalidformfields, >-- >2.5.0
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 14659
:
42252
|
43042
|
48376
|
48377
|
48480
|
48505
|
48506
|
48507