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

(-)a/C4/Biblio.pm (-5 / +6 lines)
Lines 3317-3323 sub _koha_modify_biblioitem_nonmarc { Link Here
3317
        cn_suffix       = ?,
3317
        cn_suffix       = ?,
3318
        cn_sort         = ?,
3318
        cn_sort         = ?,
3319
        totalissues     = ?,
3319
        totalissues     = ?,
3320
    ean             = ?
3320
        ean             = ?,
3321
        agerestriction  = ?
3321
        where biblioitemnumber = ?
3322
        where biblioitemnumber = ?
3322
        ";
3323
        ";
3323
    my $sth = $dbh->prepare($query);
3324
    my $sth = $dbh->prepare($query);
Lines 3329-3336 sub _koha_modify_biblioitem_nonmarc { Link Here
3329
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3330
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3330
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3331
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3331
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3332
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3332
    $biblioitem->{'ean'},
3333
        $biblioitem->{'ean'},              $biblioitem->{'agerestriction'},   $biblioitem->{'biblioitemnumber'}
3333
        $biblioitem->{'biblioitemnumber'}
3334
    );
3334
    );
3335
    if ( $dbh->errstr ) {
3335
    if ( $dbh->errstr ) {
3336
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
3336
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
Lines 3382-3388 sub _koha_add_biblioitem { Link Here
3382
        cn_suffix       = ?,
3382
        cn_suffix       = ?,
3383
        cn_sort         = ?,
3383
        cn_sort         = ?,
3384
        totalissues     = ?,
3384
        totalissues     = ?,
3385
    ean             = ?
3385
        ean             = ?,
3386
        agerestriction  = ?
3386
        ";
3387
        ";
3387
    my $sth = $dbh->prepare($query);
3388
    my $sth = $dbh->prepare($query);
3388
    $sth->execute(
3389
    $sth->execute(
Lines 3393-3399 sub _koha_add_biblioitem { Link Here
3393
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3394
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3394
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3395
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3395
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3396
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3396
        $biblioitem->{'totalissues'},      $biblioitem->{'ean'}
3397
        $biblioitem->{'totalissues'},      $biblioitem->{'ean'},              $biblioitem->{'agerestriction'}
3397
    );
3398
    );
3398
    my $bibitemnum = $dbh->{'mysql_insertid'};
3399
    my $bibitemnum = $dbh->{'mysql_insertid'};
3399
3400
(-)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 (+2 lines)
Lines 371-373 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' Link Here
371
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsOpac', '1', NULL , 'Allow holds to be suspended from the OPAC.', 'YesNo');
371
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SuspendHoldsOpac', '1', NULL , 'Allow holds to be suspended from the OPAC.', 'YesNo');
372
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('DefaultLanguageField008','','Fill in the default language for field 008 Range 35-37 (e.g. eng, nor, ger, see <a href="http://www.loc.gov/marc/languages/language_code.html">MARC Code List for Languages</a>)','','Free');
372
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('DefaultLanguageField008','','Fill in the default language for field 008 Range 35-37 (e.g. eng, nor, ger, see <a href="http://www.loc.gov/marc/languages/language_code.html">MARC Code List for Languages</a>)','','Free');
373
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACShowBarcode','0','Show items barcode in holding tab','','YesNo');
373
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACShowBarcode','0','Show items barcode in holding tab','','YesNo');
374
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
375
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 5390-5396 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5390
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OpacNavRight', '', '70|10', 'Show the following HTML in the right hand column of the main page under the main login form', 'Textarea');");
5390
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OpacNavRight', '', '70|10', 'Show the following HTML in the right hand column of the main page under the main login form', 'Textarea');");
5391
    print "Upgrade to $DBversion done (Add customizable OpacNavRight region to the OPAC main page)\n";
5391
    print "Upgrade to $DBversion done (Add customizable OpacNavRight region to the OPAC main page)\n";
5392
    SetVersion ($DBversion);
5392
    SetVersion ($DBversion);
5393
}
5394
5393
5395
$DBversion = "3.09.00.018";
5394
$DBversion = "3.09.00.018";
5396
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5395
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
Lines 5416-5421 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5416
    SetVersion($DBversion);
5415
    SetVersion($DBversion);
5417
}
5416
}
5418
5417
5418
$DBversion = "XXX";
5419
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5420
    # biblioitems changes
5421
    $dbh->do("ALTER TABLE 'biblioitems' ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort'");
5422
    # preferences changes
5423
    $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')");
5424
    $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')");
5425
5426
    print "Upgrade to $DBversion done (Add colum agerestriction to bilioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n";
5427
    SetVersion($DBversion);
5428
}
5429
5419
=head1 FUNCTIONS
5430
=head1 FUNCTIONS
5420
5431
5421
=head2 TableExists($table)
5432
=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. Entry in MARC field like FSK 12 or PEGI 12 would mean: Borrower must be 12 years old. (Empty: Do not apply age restriction.)"
213
        -
214
            - pref: AgeRestrictionOverride
215
              choices:
216
                  yes: Allow
217
                  no: "Don't allow"
218
            - staff to check out an item with age restriction.
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 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