Lines 1266-1274
sub CanBookBeIssued {
Link Here
|
1266 |
|
1266 |
|
1267 |
## CHECK AGE RESTRICTION |
1267 |
## CHECK AGE RESTRICTION |
1268 |
my $agerestriction = $biblioitem->agerestriction; |
1268 |
my $agerestriction = $biblioitem->agerestriction; |
1269 |
my ( $restriction_age, $daysToAgeRestriction ) = |
1269 |
my $restriction_age = GetAgeRestriction( $agerestriction ); |
1270 |
GetAgeRestriction( $agerestriction, $patron->unblessed ); |
1270 |
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) { |
1271 |
if ( $daysToAgeRestriction && $daysToAgeRestriction > 0 ) { |
|
|
1272 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1271 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1273 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1272 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
1274 |
} |
1273 |
} |
Lines 4421-4441
sub IsItemIssued {
Link Here
|
4421 |
|
4420 |
|
4422 |
=head2 GetAgeRestriction |
4421 |
=head2 GetAgeRestriction |
4423 |
|
4422 |
|
4424 |
my ($ageRestriction, $daysToAgeRestriction) = GetAgeRestriction($record_restrictions, $borrower); |
4423 |
my $ageRestriction = GetAgeRestriction($record_restrictions); |
4425 |
my ($ageRestriction, $daysToAgeRestriction) = GetAgeRestriction($record_restrictions); |
|
|
4426 |
|
4427 |
if($daysToAgeRestriction <= 0) { #Borrower is allowed to access this material, as they are older or as old as the agerestriction } |
4428 |
if($daysToAgeRestriction > 0) { #Borrower is this many days from meeting the agerestriction } |
4429 |
|
4424 |
|
4430 |
@PARAM1 the koha.biblioitems.agerestriction value, like K18, PEGI 13, ... |
4425 |
@PARAM1 the koha.biblioitems.agerestriction value, like K18, PEGI 13, ... |
4431 |
@PARAM2 a borrower-object with koha.borrowers.dateofbirth. (OPTIONAL) |
4426 |
@RETURNS The age restriction age in years. |
4432 |
@RETURNS The age restriction age in years and the days to fulfill the age restriction for the given borrower. |
|
|
4433 |
Negative days mean the borrower has gone past the age restriction age. |
4434 |
|
4427 |
|
4435 |
=cut |
4428 |
=cut |
4436 |
|
4429 |
|
4437 |
sub GetAgeRestriction { |
4430 |
sub GetAgeRestriction { |
4438 |
my ($record_restrictions, $borrower) = @_; |
4431 |
my ($record_restrictions) = @_; |
4439 |
my $markers = C4::Context->preference('AgeRestrictionMarker'); |
4432 |
my $markers = C4::Context->preference('AgeRestrictionMarker'); |
4440 |
|
4433 |
|
4441 |
return unless $record_restrictions; |
4434 |
return unless $record_restrictions; |
Lines 4470-4495
sub GetAgeRestriction {
Link Here
|
4470 |
last if ( $restriction_year > 0 ); |
4463 |
last if ( $restriction_year > 0 ); |
4471 |
} |
4464 |
} |
4472 |
|
4465 |
|
4473 |
#Check if the borrower is age restricted for this material and for how long. |
4466 |
return $restriction_year; |
4474 |
if ($restriction_year && $borrower) { |
|
|
4475 |
if ( $borrower->{'dateofbirth'} ) { |
4476 |
my @alloweddate = split /-/, $borrower->{'dateofbirth'}; |
4477 |
$alloweddate[0] += $restriction_year; |
4478 |
|
4479 |
#Prevent runime eror on leap year (invalid date) |
4480 |
if ( ( $alloweddate[1] == 2 ) && ( $alloweddate[2] == 29 ) ) { |
4481 |
$alloweddate[2] = 28; |
4482 |
} |
4483 |
|
4484 |
#Get how many days the borrower has to reach the age restriction |
4485 |
my @Today = split /-/, dt_from_string()->ymd(); |
4486 |
my $daysToAgeRestriction = Date_to_Days(@alloweddate) - Date_to_Days(@Today); |
4487 |
#Negative days means the borrower went past the age restriction age |
4488 |
return ($restriction_year, $daysToAgeRestriction); |
4489 |
} |
4490 |
} |
4491 |
|
4492 |
return ($restriction_year); |
4493 |
} |
4467 |
} |
4494 |
|
4468 |
|
4495 |
|
4469 |
|