View | Details | Raw Unified | Return to bug 17492
Collapse All | Expand All

(-)a/Koha/Patron.pm (+18 lines)
Lines 568-573 sub get_age { Link Here
568
    return $age;
568
    return $age;
569
}
569
}
570
570
571
=head3 is_category_valid
572
573
my $is_valid = $patron->is_category_valid
574
575
Return 1 if patron's age is between allowed limits, returns 0 if it's not.
576
577
=cut
578
579
sub is_category_valid {
580
    my ($self) = @_;
581
    my $age = $self->get_age;
582
583
    my $patroncategory = $self->category;
584
    my ($low,$high) = ($patroncategory->dateofbirthrequired, $patroncategory->upperagelimit);
585
586
    return (($high && ($age > $high)) or ($age < $low)) ? 0 : 1;
587
}
588
571
=head3 account
589
=head3 account
572
590
573
my $account = $patron->account
591
my $account = $patron->account
(-)a/circ/circulation.pl (-7 / +3 lines)
Lines 304-317 if ($patron) { Link Here
304
    }
304
    }
305
305
306
    # Calculate and display patron's age
306
    # Calculate and display patron's age
307
    my $age = $patron->get_age;
307
    if ( !$patron->is_category_valid ) {
308
309
    my $patroncategory = $patron->category;
310
    my ($low,$high) = ($patroncategory->dateofbirthrequired, $patroncategory->upperagelimit);
311
    if (($high && ($age > $high)) or ($age < $low)) {
312
        $template->param( age_limitations => 1 );
308
        $template->param( age_limitations => 1 );
313
        $template->param( age_low => $low );
309
        $template->param( age_low => $patron->category->dateofbirthrequired );
314
        $template->param( age_high => $high );
310
        $template->param( age_high => $patron->category->upperagelimit );
315
    }
311
    }
316
312
317
}
313
}
(-)a/members/moremember.pl (-13 / +4 lines)
Lines 246-265 my $overdues_exist = 0; Link Here
246
my $totalprice = 0;
246
my $totalprice = 0;
247
247
248
# Calculate and display patron's age
248
# Calculate and display patron's age
249
my $age;
249
if ( !$patron->is_category_valid ) {
250
if ( $data->{dateofbirth} ) {
251
    $age = Koha::Patron->new({ dateofbirth => $data->{dateofbirth} })->get_age;
252
    $template->param( age => $age );
253
}
254
255
# Check patron's category against age
256
my $patroncategory = Koha::Patron::Categories->find($data->{ 'categorycode' });
257
my ($low,$high) = ($patroncategory->dateofbirthrequired, $patroncategory->upperagelimit);
258
if (($high && ($age > $high)) or ($age < $low)) {
259
    $template->param( age_limitations => 1 );
250
    $template->param( age_limitations => 1 );
260
    $template->param( age_low => $low );
251
    $template->param( age_low => $patron->category->dateofbirthrequired );
261
    $template->param( age_high => $high );
252
    $template->param( age_high => $patron->category->upperagelimit );
262
}
253
}
254
$template->param( age => $patron->get_age );
263
255
264
256
265
### ###############################################################################
257
### ###############################################################################
266
- 

Return to bug 17492