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

(-)a/C4/Biblio.pm (-4 / +7 lines)
Lines 3316-3322 sub _koha_modify_biblioitem_nonmarc { Link Here
3316
        cn_item         = ?,
3316
        cn_item         = ?,
3317
        cn_suffix       = ?,
3317
        cn_suffix       = ?,
3318
        cn_sort         = ?,
3318
        cn_sort         = ?,
3319
        totalissues     = ?
3319
        totalissues     = ?,
3320
        agerestriction  = ?
3320
        where biblioitemnumber = ?
3321
        where biblioitemnumber = ?
3321
        ";
3322
        ";
3322
    my $sth = $dbh->prepare($query);
3323
    my $sth = $dbh->prepare($query);
Lines 3328-3334 sub _koha_modify_biblioitem_nonmarc { Link Here
3328
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3329
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3329
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3330
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3330
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3331
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3331
        $biblioitem->{'biblioitemnumber'}
3332
        $biblioitem->{'agerestriction'},   $biblioitem->{'biblioitemnumber'}
3332
    );
3333
    );
3333
    if ( $dbh->errstr ) {
3334
    if ( $dbh->errstr ) {
3334
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
3335
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
Lines 3379-3385 sub _koha_add_biblioitem { Link Here
3379
        cn_item         = ?,
3380
        cn_item         = ?,
3380
        cn_suffix       = ?,
3381
        cn_suffix       = ?,
3381
        cn_sort         = ?,
3382
        cn_sort         = ?,
3382
        totalissues     = ?
3383
        totalissues     = ?,
3384
        agerestriction  = ?
3383
        ";
3385
        ";
3384
    my $sth = $dbh->prepare($query);
3386
    my $sth = $dbh->prepare($query);
3385
    $sth->execute(
3387
    $sth->execute(
Lines 3390-3396 sub _koha_add_biblioitem { Link Here
3390
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3392
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3391
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3393
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3392
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3394
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3393
        $biblioitem->{'totalissues'}
3395
3396
        $biblioitem->{'totalissues'},      $biblioitem->{'agerestriction'} 
3394
    );
3397
    );
3395
    my $bibitemnum = $dbh->{'mysql_insertid'};
3398
    my $bibitemnum = $dbh->{'mysql_insertid'};
3396
3399
(-)a/C4/Circulation.pm (-1 / +63 lines)
Lines 42-48 use Data::Dumper; Link Here
42
use Koha::DateUtils;
42
use Koha::DateUtils;
43
use Koha::Calendar;
43
use Koha::Calendar;
44
use Carp;
44
use Carp;
45
45
use Date::Calc qw(
46
  Today
47
  Today_and_Now
48
  Add_Delta_YM
49
  Add_Delta_DHMS
50
  Date_to_Days
51
  Day_of_Week
52
  Add_Delta_Days    
53
);
46
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
54
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
47
55
48
BEGIN {
56
BEGIN {
Lines 927-932 sub CanBookBeIssued { Link Here
927
            }
935
            }
928
        }
936
        }
929
    }
937
    }
938
939
    #
940
    # CHECK AGE RESTRICTION
941
    #    
942
943
    # get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:"
944
    my $marker = C4::Context->preference('AgeRestrictionMarker' );     
945
    
946
    if ($marker)
947
    {    
948
        # Split $value to something like FSK 16 or PEGI 6	
949
        my @marker = split /\|/, $marker;
950
        my @values = split ' ', $biblioitem->{'agerestriction'} ;
951
952
        # Search first occurence of one of the markers
953
        my $index = 0;
954
        my $take = -1;    
955
        for my $value (@values) {
956
            $index ++;  
957
            if (grep {uc($_) eq $value} @marker) {
958
                $take = $index;
959
                last;
960
            }
961
        }  
962
        # Index points to the next value
963
        my $restrictionyear = 0;
964
        if (($take <= $#values) && ($take >= 0)){
965
            $restrictionyear += @values[$take];
966
        }    
967
        
968
        if ($restrictionyear > 0) {
969
            if ( $borrower->{'dateofbirth'}  ) {        
970
                my @alloweddate =  split /-/,$borrower->{'dateofbirth'} ;    
971
                @alloweddate[0] += $restrictionyear; 
972
                #Prevent runime eror on leap year (invalid date)
973
                if ((@alloweddate[1] == 02) && (@alloweddate[2] == 29)) {
974
                    @alloweddate[2] = 28;
975
                }
976
                
977
                my $td = Date_to_Days(Today);
978
                my $ad = Date_to_Days(@alloweddate);
979
                
980
                if ( Date_to_Days(Today) <  Date_to_Days(@alloweddate) -1  ) { 
981
                    if (C4::Context->preference('AgeRestrictionOverride ' )) {
982
                        $issuingimpossible{AGE_RESTRICTION} = "$restrictionyear";
983
                    }
984
                    else {    
985
                        $needsconfirmation{AGE_RESTRICTION} = "$restrictionyear";
986
                    }
987
                }    
988
            }
989
        }
990
    }
991
930
    return ( \%issuingimpossible, \%needsconfirmation );
992
    return ( \%issuingimpossible, \%needsconfirmation );
931
}
993
}
932
994
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 365-367 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
365
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo');
365
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo');
366
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');
366
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');
367
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice');
367
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice');
368
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
369
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Do not prevent patrons from checking out an item whose age restriction would apply.',NULL,'YesNo');
(-)a/installer/data/mysql/updatedatabase.pl (+12 lines)
Lines 5308-5313 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5308
    SetVersion ($DBversion);
5308
    SetVersion ($DBversion);
5309
}
5309
}
5310
5310
5311
$DBversion = "XXXX";
5312
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5313
    # biblioitems changes
5314
    $dbh->do("ALTER TABLE 'biblioitems' ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort'");
5315
    # preferences changes
5316
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free')");
5317
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Do not prevent patrons from checking out an item whose age restriction would apply.',NULL,'YesNo')");
5318
5319
    print "Upgrade to $DBversion done (Add colum agerestriction to bilioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n";
5320
    SetVersion($DBversion);
5321
}
5322
5311
=head1 FUNCTIONS
5323
=head1 FUNCTIONS
5312
5324
5313
=head2 TableExists($table)
5325
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+9 lines)
Lines 208-213 Circulation: Link Here
208
                  no: "Prevent"
208
                  no: "Prevent"
209
            - patrons from checking out an item whose rental charge would take them over the limit.
209
            - patrons from checking out an item whose rental charge would take them over the limit.
210
        -
210
        -
211
            - pref: AgeRestrictionMarker
212
            - "E.g. FSK|PEGI|Age| (No white space near |). Entry in MARC field (e.g. 521a) as defined for agerestriction in Koha to MARC mapping. Values e.g. FSK|PEGI|Age| . Entry e.g. in 521a like FSK 12 or PEGI 12 would then mean: Borrower must be 12 years old. (Empty: Do not apply age restriction.)"
213
        -
214
            - pref: AgeRestrictionOverride
215
              choices:
216
                  yes: Prevent
217
                  no: "Don't prevent"
218
            - patrons from checking out an item whose age restriction would apply.
219
        -
211
            - Prevent patrons from checking out books if they have more than
220
            - Prevent patrons from checking out books if they have more than
212
            - pref: noissuescharge
221
            - pref: noissuescharge
213
              class: integer
222
              class: integer
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +8 lines)
Lines 241-246 function refocus(calendar) { Link Here
241
<h3>Please confirm checkout</h3>
241
<h3>Please confirm checkout</h3>
242
242
243
<ul>
243
<ul>
244
[%IF ( AGE_RESTRICTION ) %]
245
    <li>Age restriction [% AGE_RESTRICTION %]. Check out anyway?</li>
246
[% END %]
247
244
[% IF ( DEBT ) %]
248
[% IF ( DEBT ) %]
245
    <li>The patron has a debt of [% DEBT %]</li>
249
    <li>The patron has a debt of [% DEBT %]</li>
246
[% END %]
250
[% END %]
Lines 392-397 function refocus(calendar) { Link Here
392
            <li>No more renewals possible</li>
396
            <li>No more renewals possible</li>
393
        [% END %]
397
        [% END %]
394
398
399
        [%IF ( AGE_RESTRICTION ) %]
400
            <li>Age restriction [% AGE_RESTRICTION %].</li>
401
        [% END %]
402
395
        [% IF ( EXPIRED ) %]
403
        [% IF ( EXPIRED ) %]
396
            <li>Patron's card is expired</li>
404
            <li>Patron's card is expired</li>
397
        [% END %]
405
        [% END %]
398
- 

Return to bug 7621