|
Lines 981-1009
sub CanBookBeIssued {
Link Here
|
| 981 |
} |
981 |
} |
| 982 |
|
982 |
|
| 983 |
## CHECK AGE RESTRICTION |
983 |
## CHECK AGE RESTRICTION |
| 984 |
# get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:" |
984 |
my $agerestriction = $biblioitem->{'agerestriction'}; |
| 985 |
my $markers = C4::Context->preference('AgeRestrictionMarker'); |
985 |
my ($restriction_age, $daysToAgeRestriction) = GetAgeRestriction( $agerestriction, $borrower ); |
| 986 |
my $bibvalues = $biblioitem->{'agerestriction'}; |
986 |
if ( $daysToAgeRestriction ) { |
| 987 |
my $restriction_age = GetAgeRestriction( $bibvalues ); |
987 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
| 988 |
|
988 |
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction"; |
| 989 |
if ( $restriction_age > 0 ) { |
989 |
} |
| 990 |
if ( $borrower->{'dateofbirth'} ) { |
990 |
else { |
| 991 |
my @alloweddate = split /-/, $borrower->{'dateofbirth'}; |
991 |
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction"; |
| 992 |
$alloweddate[0] += $restriction_age; |
|
|
| 993 |
|
| 994 |
#Prevent runime eror on leap year (invalid date) |
| 995 |
if ( ( $alloweddate[1] == 2 ) && ( $alloweddate[2] == 29 ) ) { |
| 996 |
$alloweddate[2] = 28; |
| 997 |
} |
| 998 |
|
| 999 |
if ( Date_to_Days(Today) < Date_to_Days(@alloweddate) - 1 ) { |
| 1000 |
if ( C4::Context->preference('AgeRestrictionOverride') ) { |
| 1001 |
$needsconfirmation{AGE_RESTRICTION} = "$bibvalues"; |
| 1002 |
} |
| 1003 |
else { |
| 1004 |
$issuingimpossible{AGE_RESTRICTION} = "$bibvalues"; |
| 1005 |
} |
| 1006 |
} |
| 1007 |
} |
992 |
} |
| 1008 |
} |
993 |
} |
| 1009 |
|
994 |
|
|
Lines 3737-3744
sub IsItemIssued {
Link Here
|
| 3737 |
return $sth->fetchrow; |
3722 |
return $sth->fetchrow; |
| 3738 |
} |
3723 |
} |
| 3739 |
|
3724 |
|
|
|
3725 |
=head2 GetAgeRestriction |
| 3726 |
|
| 3727 |
my ($ageRestriction, $daysToAgeRestriction) = GetAgeRestriction($record_restrictions, $borrower); |
| 3728 |
my ($ageRestriction, $daysToAgeRestriction) = GetAgeRestriction($record_restrictions); |
| 3729 |
|
| 3730 |
if($daysToAgeRestriction <= 0) { #Borrower is allowed to access this material, as he is older or as old as the agerestriction } |
| 3731 |
if($daysToAgeRestriction > 0) { #Borrower is this many days from meeting the agerestriction } |
| 3732 |
|
| 3733 |
@PARAM1 the koha.biblioitems.agerestriction value, like K18, PEGI 13, ... |
| 3734 |
@PARAM2 a borrower-object with koha.borrowers.dateofbirth. (OPTIONAL) |
| 3735 |
@RETURNS The age restriction age in years and the days to fulfill the age restriction for the given borrower. |
| 3736 |
Negative days mean the borrower has gone past the age restriction age. |
| 3737 |
|
| 3738 |
=cut |
| 3739 |
|
| 3740 |
sub GetAgeRestriction { |
3740 |
sub GetAgeRestriction { |
| 3741 |
my ($record_restrictions) = @_; |
3741 |
my ($record_restrictions, $borrower) = @_; |
| 3742 |
my $markers = C4::Context->preference('AgeRestrictionMarker'); |
3742 |
my $markers = C4::Context->preference('AgeRestrictionMarker'); |
| 3743 |
|
3743 |
|
| 3744 |
# Split $record_restrictions to something like FSK 16 or PEGI 6 |
3744 |
# Split $record_restrictions to something like FSK 16 or PEGI 6 |
|
Lines 3772-3778
sub GetAgeRestriction {
Link Here
|
| 3772 |
last if ( $restriction_year > 0 ); |
3772 |
last if ( $restriction_year > 0 ); |
| 3773 |
} |
3773 |
} |
| 3774 |
|
3774 |
|
| 3775 |
return $restriction_year; |
3775 |
#Check if the borrower is age restricted for this material and for how long. |
|
|
3776 |
if ($restriction_year && $borrower) { |
| 3777 |
if ( $borrower->{'dateofbirth'} ) { |
| 3778 |
my @alloweddate = split /-/, $borrower->{'dateofbirth'}; |
| 3779 |
$alloweddate[0] += $restriction_year; |
| 3780 |
|
| 3781 |
#Prevent runime eror on leap year (invalid date) |
| 3782 |
if ( ( $alloweddate[1] == 2 ) && ( $alloweddate[2] == 29 ) ) { |
| 3783 |
$alloweddate[2] = 28; |
| 3784 |
} |
| 3785 |
|
| 3786 |
#Get how many days the borrower has to reach the age restriction |
| 3787 |
my $daysToAgeRestriction = Date_to_Days(@alloweddate) - Date_to_Days(Today); |
| 3788 |
#Negative days means the borrower went past the age restriction age |
| 3789 |
return ($restriction_year, $daysToAgeRestriction); |
| 3790 |
} |
| 3791 |
} |
| 3792 |
|
| 3793 |
return ($restriction_year); |
| 3776 |
} |
3794 |
} |
| 3777 |
|
3795 |
|
| 3778 |
1; |
3796 |
1; |