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

(-)a/C4/Biblio.pm (-4 / +6 lines)
Lines 3270-3276 sub _koha_modify_biblioitem_nonmarc { Link Here
3270
        cn_item         = ?,
3270
        cn_item         = ?,
3271
        cn_suffix       = ?,
3271
        cn_suffix       = ?,
3272
        cn_sort         = ?,
3272
        cn_sort         = ?,
3273
        totalissues     = ?
3273
        totalissues     = ?,
3274
        agerestriction  = ?
3274
        where biblioitemnumber = ?
3275
        where biblioitemnumber = ?
3275
        ";
3276
        ";
3276
    my $sth = $dbh->prepare($query);
3277
    my $sth = $dbh->prepare($query);
Lines 3282-3288 sub _koha_modify_biblioitem_nonmarc { Link Here
3282
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3283
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3283
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3284
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3284
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3285
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3285
        $biblioitem->{'biblioitemnumber'}
3286
        $biblioitem->{'agerestriction'},   $biblioitem->{'biblioitemnumber'}
3286
    );
3287
    );
3287
    if ( $dbh->errstr ) {
3288
    if ( $dbh->errstr ) {
3288
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
3289
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
Lines 3333-3339 sub _koha_add_biblioitem { Link Here
3333
        cn_item         = ?,
3334
        cn_item         = ?,
3334
        cn_suffix       = ?,
3335
        cn_suffix       = ?,
3335
        cn_sort         = ?,
3336
        cn_sort         = ?,
3336
        totalissues     = ?
3337
        totalissues     = ?,
3338
        agerestriction  = ?
3337
        ";
3339
        ";
3338
    my $sth = $dbh->prepare($query);
3340
    my $sth = $dbh->prepare($query);
3339
    $sth->execute(
3341
    $sth->execute(
Lines 3344-3350 sub _koha_add_biblioitem { Link Here
3344
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3346
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3345
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3347
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3346
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3348
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3347
        $biblioitem->{'totalissues'}
3349
        $biblioitem->{'totalissues'},      $biblioitem->{'agerestriction'}
3348
    );
3350
    );
3349
    my $bibitemnum = $dbh->{'mysql_insertid'};
3351
    my $bibitemnum = $dbh->{'mysql_insertid'};
3350
3352
(-)a/C4/Circulation.pm (-1 / +63 lines)
Lines 41-47 use Data::Dumper; Link Here
41
use Koha::DateUtils;
41
use Koha::DateUtils;
42
use Koha::Calendar;
42
use Koha::Calendar;
43
use Carp;
43
use Carp;
44
44
use Date::Calc qw(
45
  Today
46
  Today_and_Now
47
  Add_Delta_YM
48
  Add_Delta_DHMS
49
  Date_to_Days
50
  Day_of_Week
51
  Add_Delta_Days    
52
);
45
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
53
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
46
54
47
BEGIN {
55
BEGIN {
Lines 926-931 sub CanBookBeIssued { Link Here
926
            }
934
            }
927
        }
935
        }
928
    }
936
    }
937
938
    #
939
    # CHECK AGE RESTRICTION
940
    #    
941
942
    # get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:"
943
    my $marker = C4::Context->preference('AgeRestrictionMarker' );     
944
    
945
    if ($marker)
946
    {    
947
        # Split $value to something like FSK 16 or PEGI 6	
948
        my @marker = split /\|/, $marker;
949
        my @values = split ' ', $biblioitem->{'agerestriction'} ;
950
951
        # Search first occurence of one of the markers
952
        my $index = 0;
953
        my $take = -1;    
954
        for my $value (@values) {
955
            $index ++;  
956
            if (grep {uc($_) eq $value} @marker) {
957
                $take = $index;
958
                last;
959
            }
960
        }  
961
        # Index points to the next value
962
        my $restrictionyear = 0;
963
        if (($take <= $#values) && ($take >= 0)){
964
            $restrictionyear += @values[$take];
965
        }    
966
        
967
        if ($restrictionyear > 0) {
968
            if ( $borrower->{'dateofbirth'}  ) {        
969
                my @alloweddate =  split /-/,$borrower->{'dateofbirth'} ;    
970
                @alloweddate[0] += $restrictionyear; 
971
                #Prevent runime eror on leap year (invalid date)
972
                if ((@alloweddate[1] == 02) && (@alloweddate[2] == 29)) {
973
                    @alloweddate[2] = 28;
974
                }
975
                
976
                my $td = Date_to_Days(Today);
977
                my $ad = Date_to_Days(@alloweddate);
978
                
979
                if ( Date_to_Days(Today) <  Date_to_Days(@alloweddate) -1  ) { 
980
                    if (C4::Context->preference('AgeRestrictionOverride ' )) {
981
                        $issuingimpossible{AGE_RESTRICTION} = "$restrictionyear";
982
                    }
983
                    else {    
984
                        $needsconfirmation{AGE_RESTRICTION} = "$restrictionyear";
985
                    }
986
                }    
987
            }
988
        }
989
    }
990
929
    return ( \%issuingimpossible, \%needsconfirmation );
991
    return ( \%issuingimpossible, \%needsconfirmation );
930
}
992
}
931
993
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 362-364 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES(' Link Here
362
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AutoResumeSuspendedHolds',  '1', NULL ,  'Allow suspended holds to be automatically resumed by a set date.',  'YesNo');
362
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AutoResumeSuspendedHolds',  '1', NULL ,  'Allow suspended holds to be automatically resumed by a set date.',  'YesNo');
363
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice');
363
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice');
364
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');
364
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('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
366
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 (+11 lines)
Lines 5198-5203 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5198
    SetVersion($DBversion);
5198
    SetVersion($DBversion);
5199
}
5199
}
5200
5200
5201
$DBversion = "XXXX";
5202
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5203
    # biblioitems changes
5204
    $dbh->do("ALTER TABLE 'biblioitems' ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort'");
5205
    # preferences changes
5206
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free')");
5207
    $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')");
5208
5209
    print "Upgrade to $DBversion done (Add colum agerestriction to bilioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n";
5210
    SetVersion($DBversion);
5211
}
5201
5212
5202
=head1 FUNCTIONS
5213
=head1 FUNCTIONS
5203
5214
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+9 lines)
Lines 208-213 Circulation: Link Here
208
                  no: "Don't prevent"
208
                  no: "Don't 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 240-245 function refocus(calendar) { Link Here
240
<h3>Please confirm checkout</h3>
240
<h3>Please confirm checkout</h3>
241
241
242
<ul>
242
<ul>
243
[%IF ( AGE_RESTRICTION ) %]
244
    <li>Age restriction [% AGE_RESTRICTION %]. Check out anyway?</li>
245
[% END %]
246
243
[% IF ( DEBT ) %]
247
[% IF ( DEBT ) %]
244
    <li>The patron has a debt of [% DEBT %]</li>
248
    <li>The patron has a debt of [% DEBT %]</li>
245
[% END %]
249
[% END %]
Lines 391-396 function refocus(calendar) { Link Here
391
            <li>No more renewals possible</li>
395
            <li>No more renewals possible</li>
392
        [% END %]
396
        [% END %]
393
397
398
        [%IF ( AGE_RESTRICTION ) %]
399
            <li>Age restriction [% AGE_RESTRICTION %].</li>
400
        [% END %]
401
394
        [% IF ( EXPIRED ) %]
402
        [% IF ( EXPIRED ) %]
395
            <li>Patron's card is expired</li>
403
            <li>Patron's card is expired</li>
396
        [% END %]
404
        [% END %]
397
- 

Return to bug 7621