From 0c20d9ac4571d6024fc07aba61916ee104afae4c Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Fri, 14 Aug 2020 13:59:10 +0000 Subject: [PATCH] Bug 26211: Patron age verification while doing the self-registration. To Test 1. Create the patron category from the staff page for ex: Kid and give age required and age Upperage limit age required 5 yrs and upperage limit 17. 2. Allow category in PatronSelfRegistrationDefaultCategory for online registration from opac. 3. Go to /cgi-bin/koha/opac-memberentry.pl page. 4. Fill the form and give choose date of birth 10/10/1974 and click OK. Now you can able to save the page. 5. Apply the patch. 6. Again go to cgi-bin/koha/opac-memberentry.pl page. 7. Fill the form and give choose date of birth 10/10/1974 and click OK. It will give the error message. Patron's age is incorrect for their category. Ages allowed are 5-17. Signed-off-by: Sam Sowanick Signed-off-by: Katrin Fischer (cherry picked from commit 579389ed324e3b433b961488f61907efb1e6c94e) Signed-off-by: Paul Derscheid --- .../bootstrap/en/modules/opac-memberentry.tt | 3 +++ opac/opac-memberentry.pl | 12 ++++++++++++ 2 files changed, 15 insertions(+) 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 6db0556cfd..cdfb6c94ec 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -115,6 +115,9 @@ [% IF field == "email_match" %]
  • Emails do not match! confirm email address
  • [% END %] + [% IF field == "ERROR_age_limitations" %] +
  • Patron's age is incorrect for their category. Ages allowed are [% age_low | html %]-[% age_high | html %].
  • + [% END %] [% END %] Please correct and resubmit. diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 399d31afa4..11cf05f178 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -532,6 +532,18 @@ sub CheckForInvalidFields { } } + if ( $borrower->{'dateofbirth'} ) { + my $patron = Koha::Patron->new( { dateofbirth => $borrower->{'dateofbirth'} } ); + my $age = $patron->get_age; + my $borrowercategory = Koha::Patron::Categories->find( $borrower->{'categorycode'} ); + my ( $low, $high ) = ( $borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit ); + if ( ( $high && ( $age > $high ) ) or ( $age < $low ) ) { + push @invalidFields, 'ERROR_age_limitations'; + $template->param( age_low => $low); + $template->param( age_high => $high); + } + } + return \@invalidFields; }