Bug 11925: Check ages limits when creating/updating patrons

The check on the ages limits is only done when the dateofbirth field is
mandatory, which does not make any sense.
This check should be done when the field is filled.

Test plan:
1/ Remove the dateofbirth field from the BorrowerMandatoryField pref
2/ Create a patron category for teenager (say between 12-17y)
3/ Try to create a patron in this category outside the range of the ages
limits.
You should not be able to do it.

Signed-off-by: Christopher Brannon <cbrannon@cdalibary.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
Jonathan Druart 2015-04-28 11:45:46 +02:00 committed by Tomas Cohen Arazi
parent de448c0a1e
commit cc393df50f

View file

@ -135,8 +135,6 @@ my @field_check=split(/\|/,$check_BorrowerMandatoryField);
foreach (@field_check) {
$template->param( "mandatory$_" => 1);
}
# we'll need this, later.
my $dateofbirthmandatory = (scalar grep {$_ eq "dateofbirth"} @field_check) ? 1 : 0;
# function to designate unwanted fields
my $check_BorrowerUnwantedField=C4::Context->preference("BorrowerUnwantedField");
@field_check=split(/\|/,$check_BorrowerUnwantedField);
@ -305,7 +303,7 @@ if ($op eq 'save' || $op eq 'insert'){
: ()
}
if ($newdata{dateofbirth} && $dateofbirthmandatory) {
if ( $newdata{dateofbirth} ) {
my $age = GetAge($newdata{dateofbirth});
my $borrowercategory=GetBorrowercategory($newdata{'categorycode'});
my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'});