From 331305737ba6f559c5116ade34cd3933122914f4 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. --- koha-tmpl/opac-tmpl/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 7acd45a..60cf7c2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -96,6 +96,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 a076cd3..b6e324b 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -474,6 +474,18 @@ sub CheckForInvalidFields { push @invalidFields, 'password_has_whitespaces' if $error eq 'has_whitespaces'; } } + + 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; } -- 2.7.4