Lines 983-1011
sub CanBookBeIssued {
Link Here
|
983 |
} |
983 |
} |
984 |
|
984 |
|
985 |
## CHECK AGE RESTRICTION |
985 |
## CHECK AGE RESTRICTION |
986 |
# get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:" |
986 |
my $agerestriction = $biblioitem->{'agerestriction'}; |
987 |
my $markers = C4::Context->preference('AgeRestrictionMarker'); |
987 |
my ($restriction_age, $daysToAgeRestriction) = GetAgeRestriction( $agerestriction, $borrower ); |
988 |
my $bibvalues = $biblioitem->{'agerestriction'}; |
988 |
if ( $daysToAgeRestriction ) { |
989 |
my $restriction_age = GetAgeRestriction( $bibvalues ); |
989 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
990 |
|
990 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
991 |
if ( $restriction_age > 0 ) { |
991 |
} |
992 |
if ( $borrower->{'dateofbirth'} ) { |
992 |
else { |
993 |
my @alloweddate = split /-/, $borrower->{'dateofbirth'}; |
993 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
994 |
$alloweddate[0] += $restriction_age; |
|
|
995 |
|
996 |
#Prevent runime eror on leap year (invalid date) |
997 |
if ( ( $alloweddate[1] == 2 ) && ( $alloweddate[2] == 29 ) ) { |
998 |
$alloweddate[2] = 28; |
999 |
} |
1000 |
|
1001 |
if ( Date_to_Days(Today) < Date_to_Days(@alloweddate) - 1 ) { |
1002 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
1003 |
$needsconfirmation{AGE_RESTRICTION} = "$bibvalues"; |
1004 |
} |
1005 |
else { |
1006 |
$issuingimpossible{AGE_RESTRICTION} = "$bibvalues"; |
1007 |
} |
1008 |
} |
1009 |
} |
994 |
} |
1010 |
} |
995 |
} |
1011 |
|
996 |
|
Lines 3754-3761
sub IsItemIssued {
Link Here
|
3754 |
return $sth->fetchrow; |
3739 |
return $sth->fetchrow; |
3755 |
} |
3740 |
} |
3756 |
|
3741 |
|
|
|
3742 |
=head2 GetAgeRestriction |
3743 |
|
3744 |
my ($ageRestriction, $daysToAgeRestriction) = GetAgeRestriction($record_restrictions, $borrower); |
3745 |
my ($ageRestriction, $daysToAgeRestriction) = GetAgeRestriction($record_restrictions); |
3746 |
|
3747 |
@PARAM1 the koha.biblioitems.agerestriction value, like K18, PEGI 13, ... |
3748 |
@PARAM2 a borrower-object with koha.borrowers.dateofbirth. (OPTIONAL) |
3749 |
@RETURNS The age restriction age in years and the days to fulfill the age restriction for the given borrower. |
3750 |
Negative days mean the borrower has gone past the age restriction age. |
3751 |
|
3752 |
=cut |
3753 |
|
3757 |
sub GetAgeRestriction { |
3754 |
sub GetAgeRestriction { |
3758 |
my ($record_restrictions) = @_; |
3755 |
my ($record_restrictions, $borrower) = @_; |
3759 |
my $markers = C4::Context->preference('AgeRestrictionMarker'); |
3756 |
my $markers = C4::Context->preference('AgeRestrictionMarker'); |
3760 |
|
3757 |
|
3761 |
# Split $record_restrictions to something like FSK 16 or PEGI 6 |
3758 |
# Split $record_restrictions to something like FSK 16 or PEGI 6 |
Lines 3789-3795
sub GetAgeRestriction {
Link Here
|
3789 |
last if ( $restriction_year > 0 ); |
3786 |
last if ( $restriction_year > 0 ); |
3790 |
} |
3787 |
} |
3791 |
|
3788 |
|
3792 |
return $restriction_year; |
3789 |
#Check if the borrower is age restricted for this material and for how long. |
|
|
3790 |
if ($restriction_year && $borrower) { |
3791 |
if ( $borrower->{'dateofbirth'} ) { |
3792 |
my @alloweddate = split /-/, $borrower->{'dateofbirth'}; |
3793 |
$alloweddate[0] += $restriction_year; |
3794 |
|
3795 |
#Prevent runime eror on leap year (invalid date) |
3796 |
if ( ( $alloweddate[1] == 2 ) && ( $alloweddate[2] == 29 ) ) { |
3797 |
$alloweddate[2] = 28; |
3798 |
} |
3799 |
|
3800 |
#Get how many days the borrower has to reach the age restriction |
3801 |
my $daysToAgeRestriction = Date_to_Days(Today) - Date_to_Days(@alloweddate); |
3802 |
#Negative days means the borrower went past the age restriction age |
3803 |
return ($restriction_year, $daysToAgeRestriction); |
3804 |
} |
3805 |
} |
3806 |
|
3807 |
return ($restriction_year); |
3793 |
} |
3808 |
} |
3794 |
|
3809 |
|
3795 |
1; |
3810 |
1; |