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 / +65 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 $markers = C4::Context->preference('AgeRestrictionMarker' );
948
    my $bibvalues = $biblioitem->{'agerestriction'};
949
    if (($markers)&&($bibvalues))
950
    {
951
        # Split $bibvalues to something like FSK 16 or PEGI 6
952
        my @values = split ' ', $bibvalues;
953
954
        # Search first occurence of one of the markers
955
        my @markers = split /\|/, $markers;
956
        my $index = 0;
957
        my $take = -1;
958
        for my $value (@values) {
959
            $index ++;
960
            for my $marker (@markers) {
961
                $marker =~ s/^\s+//; #remove leading spaces
962
                $marker =~ s/\s+$//; #remove trailing spaces
963
                if (uc($marker) eq uc($value)) {
964
                    $take = $index;
965
                    last;
966
                }
967
            }
968
            if ($take > -1) {
969
                last;
970
            }
971
        }
972
        # Index points to the next value
973
        my $restrictionyear = 0;
974
        if (($take <= $#values) && ($take >= 0)){
975
            $restrictionyear += @values[$take];
976
        }
977
978
        if ($restrictionyear > 0) {
979
            if ( $borrower->{'dateofbirth'}  ) {
980
                my @alloweddate =  split /-/,$borrower->{'dateofbirth'} ;
981
                @alloweddate[0] += $restrictionyear;
982
                #Prevent runime eror on leap year (invalid date)
983
                if ((@alloweddate[1] == 2) && (@alloweddate[2] == 29)) {
984
                    @alloweddate[2] = 28;
985
                }
986
987
                if ( Date_to_Days(Today) <  Date_to_Days(@alloweddate) -1  ) {
988
                    if (C4::Context->preference('AgeRestrictionOverride' )) {
989
                        $needsconfirmation{AGE_RESTRICTION} = "$bibvalues";
990
                    }
991
                    else {
992
                        $issuingimpossible{AGE_RESTRICTION} = "$bibvalues";
993
                    }
994
                }
995
            }
996
        }
997
    }
934
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
998
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
935
}
999
}
936
1000
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 178-183 CREATE TABLE `biblioitems` ( -- information related to bibliographic records in Link Here
178
  `cn_item` varchar(10) default NULL,
178
  `cn_item` varchar(10) default NULL,
179
  `cn_suffix` varchar(10) default NULL,
179
  `cn_suffix` varchar(10) default NULL,
180
  `cn_sort` varchar(30) default NULL,
180
  `cn_sort` varchar(30) default NULL,
181
  `agerestriction` varchar(255) default NULL,
181
  `totalissues` int(10),
182
  `totalissues` int(10),
182
  `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
183
  `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
183
  PRIMARY KEY  (`biblioitemnumber`),
184
  PRIMARY KEY  (`biblioitemnumber`),
Lines 650-655 CREATE TABLE `deletedbiblioitems` ( -- information about bibliographic records t Link Here
650
  `cn_item` varchar(10) default NULL,
651
  `cn_item` varchar(10) default NULL,
651
  `cn_suffix` varchar(10) default NULL,
652
  `cn_suffix` varchar(10) default NULL,
652
  `cn_sort` varchar(30) default NULL,
653
  `cn_sort` varchar(30) default NULL,
654
  `agerestriction` varchar(255) default NULL,
653
  `totalissues` int(10),
655
  `totalissues` int(10),
654
  `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
656
  `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML
655
  PRIMARY KEY  (`biblioitemnumber`),
657
  PRIMARY KEY  (`biblioitemnumber`),
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 375-377 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( Link Here
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
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IntranetSlipPrinterJS','','Use this JavaScript for printing slips. Define at least function printThenClose(). For use e.g. with Firefox PlugIn jsPrintSetup, see http://jsprintsetup.mozdev.org/','','Free');
377
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('IntranetSlipPrinterJS','','Use this JavaScript for printing slips. Define at least function printThenClose(). For use e.g. with Firefox PlugIn jsPrintSetup, see http://jsprintsetup.mozdev.org/','','Free');
378
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
379
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 / +10 lines)
Lines 5533-5538 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5533
    die("Failed to add reserve_id to reserves tables, please refresh the page to try again.") unless ( $row->{'count'} );
5533
    die("Failed to add reserve_id to reserves tables, please refresh the page to try again.") unless ( $row->{'count'} );
5534
5534
5535
    print "Upgrade to $DBversion done (add reserve_id to reserves & old_reserves tables)\n";
5535
    print "Upgrade to $DBversion done (add reserve_id to reserves & old_reserves tables)\n";
5536
$DBversion = "XXX";
5537
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5538
    # biblioitems changes
5539
    $dbh->do("ALTER TABLE biblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5540
    $dbh->do("ALTER TABLE deletedbiblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5541
    # preferences changes
5542
    $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')");
5543
    $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')");
5544
5545
    print "Upgrade to $DBversion done (Add colum agerestriction to biblioitems and deletedbiblioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n";
5536
    SetVersion($DBversion);
5546
    SetVersion($DBversion);
5537
}
5547
}
5538
5548
Lines 5620-5623 sub SetVersion { Link Here
5620
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
5630
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
5621
}
5631
}
5622
exit;
5632
exit;
5623
(-)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