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 <sam.sowanick@corvallisoregon.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 579389ed32)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Amit Gupta 2020-08-14 13:59:10 +00:00 committed by Paul Derscheid
parent d8ad5d8637
commit 0c20d9ac45
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
2 changed files with 15 additions and 0 deletions

View File

@ -115,6 +115,9 @@
[% IF field == "email_match" %]
<li>Emails do not match! <a href="#borrower_repeat_email">confirm email address</a></li>
[% END %]
[% IF field == "ERROR_age_limitations" %]
<li>Patron's age is incorrect for their category. Ages allowed are [% age_low | html %]-[% age_high | html %].</li>
[% END %]
[% END %]
</ul>
<span>Please correct and resubmit.</span>

View File

@ -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;
}