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

(-)a/C4/Biblio.pm (-5 / +6 lines)
Lines 3318-3324 sub _koha_modify_biblioitem_nonmarc { Link Here
3318
        cn_suffix       = ?,
3318
        cn_suffix       = ?,
3319
        cn_sort         = ?,
3319
        cn_sort         = ?,
3320
        totalissues     = ?,
3320
        totalissues     = ?,
3321
    ean             = ?
3321
        ean             = ?,
3322
        agerestriction  = ?
3322
        where biblioitemnumber = ?
3323
        where biblioitemnumber = ?
3323
        ";
3324
        ";
3324
    my $sth = $dbh->prepare($query);
3325
    my $sth = $dbh->prepare($query);
Lines 3330-3337 sub _koha_modify_biblioitem_nonmarc { Link Here
3330
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3331
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3331
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3332
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3332
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3333
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3333
    $biblioitem->{'ean'},
3334
        $biblioitem->{'ean'},              $biblioitem->{'agerestriction'},   $biblioitem->{'biblioitemnumber'}
3334
        $biblioitem->{'biblioitemnumber'}
3335
    );
3335
    );
3336
    if ( $dbh->errstr ) {
3336
    if ( $dbh->errstr ) {
3337
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
3337
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
Lines 3383-3389 sub _koha_add_biblioitem { Link Here
3383
        cn_suffix       = ?,
3383
        cn_suffix       = ?,
3384
        cn_sort         = ?,
3384
        cn_sort         = ?,
3385
        totalissues     = ?,
3385
        totalissues     = ?,
3386
    ean             = ?
3386
        ean             = ?,
3387
        agerestriction  = ?
3387
        ";
3388
        ";
3388
    my $sth = $dbh->prepare($query);
3389
    my $sth = $dbh->prepare($query);
3389
    $sth->execute(
3390
    $sth->execute(
Lines 3394-3400 sub _koha_add_biblioitem { Link Here
3394
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3395
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3395
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3396
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3396
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3397
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3397
        $biblioitem->{'totalissues'},      $biblioitem->{'ean'}
3398
        $biblioitem->{'totalissues'},      $biblioitem->{'ean'},              $biblioitem->{'agerestriction'}
3398
    );
3399
    );
3399
    my $bibitemnum = $dbh->{'mysql_insertid'};
3400
    my $bibitemnum = $dbh->{'mysql_insertid'};
3400
3401
(-)a/C4/Circulation.pm (-1 / +61 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 931-936 sub CanBookBeIssued { Link Here
931
            }
939
            }
932
        }
940
        }
933
    }
941
    }
942
    #
943
    # CHECK AGE RESTRICTION
944
    #
945
946
    # get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:"
947
    my $marker = C4::Context->preference('AgeRestrictionMarker' );
948
949
    if ($marker)
950
    {
951
        # Split $value to something like FSK 16 or PEGI 6
952
        my @marker = split /\|/, $marker;
953
        my @values = split ' ', $biblioitem->{'agerestriction'} ;
954
955
        # Search first occurence of one of the markers
956
        my $index = 0;
957
        my $take = -1;
958
        for my $value (@values) {
959
            $index ++;
960
            if (grep {uc($_) eq $value} @marker) {
961
                $take = $index;
962
                last;
963
            }
964
        }
965
        # Index points to the next value
966
        my $restrictionyear = 0;
967
        if (($take <= $#values) && ($take >= 0)){
968
            $restrictionyear += @values[$take];
969
        }
970
971
        if ($restrictionyear > 0) {
972
            if ( $borrower->{'dateofbirth'}  ) {
973
                my @alloweddate =  split /-/,$borrower->{'dateofbirth'} ;
974
                @alloweddate[0] += $restrictionyear;
975
                #Prevent runime eror on leap year (invalid date)
976
                if ((@alloweddate[1] == 2) && (@alloweddate[2] == 29)) {
977
                    @alloweddate[2] = 28;
978
                }
979
980
                my $td = Date_to_Days(Today);
981
                my $ad = Date_to_Days(@alloweddate);
982
983
                if ( Date_to_Days(Today) <  Date_to_Days(@alloweddate) -1  ) {
984
                    if (C4::Context->preference('AgeRestrictionOverride ' )) {
985
                        $needsconfirmation{AGE_RESTRICTION} = "$restrictionyear";
986
                    }
987
                    else {
988
                        $issuingimpossible{AGE_RESTRICTION} = "$restrictionyear";
989
                    }
990
                }
991
            }
992
        }
993
    }
934
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
994
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
935
}
995
}
936
996
(-)a/installer/data/mysql/sysprefs.sql (-1 / +2 lines)
Lines 374-377 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' Link Here
374
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACShowUnusedAuthorities','1','','Show authorities that are not being used in the OPAC.','YesNo');
374
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACShowUnusedAuthorities','1','','Show authorities that are not being used in the OPAC.','YesNo');
375
INSERT INTO systempreferences (variable,value,explanation,type) VALUES('EnableBorrowerFiles','0','If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo');
375
INSERT INTO systempreferences (variable,value,explanation,type) VALUES('EnableBorrowerFiles','0','If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo');
376
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo');
376
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo');
377
377
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
378
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo');
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +12 lines)
Lines 5459-5464 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5459
    SetVersion($DBversion);
5459
    SetVersion($DBversion);
5460
}
5460
}
5461
5461
5462
$DBversion = "XXX";
5463
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5464
    # biblioitems changes
5465
    $dbh->do("ALTER TABLE biblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5466
    # preferences changes
5467
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|. See: http://wiki.koha-community.org/wiki/Age_restriction',NULL,'free')");
5468
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo')");
5469
5470
    print "Upgrade to $DBversion done (Add colum agerestriction to biblioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n";
5471
    SetVersion($DBversion);
5472
}
5473
5462
=head1 FUNCTIONS
5474
=head1 FUNCTIONS
5463
5475
5464
=head2 TableExists($table)
5476
=head2 TableExists($table)
Lines 5543-5546 sub SetVersion { Link Here
5543
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
5555
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
5544
}
5556
}
5545
exit;
5557
exit;
5546
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+9 lines)
Lines 214-219 Circulation: Link Here
214
                  no: "Prevent"
214
                  no: "Prevent"
215
            - patrons from checking out an item whose rental charge would take them over the limit.
215
            - patrons from checking out an item whose rental charge would take them over the limit.
216
        -
216
        -
217
            - pref: AgeRestrictionMarker
218
            - "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. Entry in MARC field like FSK 12 or PEGI 12 would mean: Borrower must be 12 years old. (Empty: Do not apply age restriction.)"
219
        -
220
            - pref: AgeRestrictionOverride
221
              choices:
222
                  yes: Allow
223
                  no: "Don't allow"
224
            - staff to check out an item with age restriction.
225
        -
217
            - Prevent patrons from checking out books if they have more than
226
            - Prevent patrons from checking out books if they have more than
218
            - pref: noissuescharge
227
            - pref: noissuescharge
219
              class: integer
228
              class: integer
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +8 lines)
Lines 246-251 function validate1(date) { Link Here
246
<h3>Please confirm checkout</h3>
246
<h3>Please confirm checkout</h3>
247
247
248
<ul>
248
<ul>
249
[%IF ( AGE_RESTRICTION ) %]
250
    <li>Age restriction [% AGE_RESTRICTION %]. Check out anyway?</li>
251
[% END %]
252
249
[% IF ( DEBT ) %]
253
[% IF ( DEBT ) %]
250
    <li>The patron has a debt of [% DEBT %]</li>
254
    <li>The patron has a debt of [% DEBT %]</li>
251
[% END %]
255
[% END %]
Lines 397-402 function validate1(date) { Link Here
397
            <li>No more renewals possible</li>
401
            <li>No more renewals possible</li>
398
        [% END %]
402
        [% END %]
399
403
404
        [%IF ( AGE_RESTRICTION ) %]
405
            <li>Age restriction [% AGE_RESTRICTION %].</li>
406
        [% END %]
407
400
        [% IF ( EXPIRED ) %]
408
        [% IF ( EXPIRED ) %]
401
            <li>Patron's card is expired</li>
409
            <li>Patron's card is expired</li>
402
        [% END %]
410
        [% END %]
403
- 

Return to bug 7621