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

(-)a/C4/Biblio.pm (-5 / +6 lines)
Lines 3319-3325 sub _koha_modify_biblioitem_nonmarc { Link Here
3319
        cn_suffix       = ?,
3319
        cn_suffix       = ?,
3320
        cn_sort         = ?,
3320
        cn_sort         = ?,
3321
        totalissues     = ?,
3321
        totalissues     = ?,
3322
    ean             = ?
3322
        ean             = ?,
3323
        agerestriction  = ?
3323
        where biblioitemnumber = ?
3324
        where biblioitemnumber = ?
3324
        ";
3325
        ";
3325
    my $sth = $dbh->prepare($query);
3326
    my $sth = $dbh->prepare($query);
Lines 3331-3338 sub _koha_modify_biblioitem_nonmarc { Link Here
3331
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3332
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3332
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3333
        $biblioitem->{'lccn'},             $biblioitem->{'url'},              $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'},
3333
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3334
        $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},        $cn_sort,                               $biblioitem->{'totalissues'},
3334
    $biblioitem->{'ean'},
3335
        $biblioitem->{'ean'},              $biblioitem->{'agerestriction'},   $biblioitem->{'biblioitemnumber'}
3335
        $biblioitem->{'biblioitemnumber'}
3336
    );
3336
    );
3337
    if ( $dbh->errstr ) {
3337
    if ( $dbh->errstr ) {
3338
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
3338
        $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr;
Lines 3384-3390 sub _koha_add_biblioitem { Link Here
3384
        cn_suffix       = ?,
3384
        cn_suffix       = ?,
3385
        cn_sort         = ?,
3385
        cn_sort         = ?,
3386
        totalissues     = ?,
3386
        totalissues     = ?,
3387
    ean             = ?
3387
        ean             = ?,
3388
        agerestriction  = ?
3388
        ";
3389
        ";
3389
    my $sth = $dbh->prepare($query);
3390
    my $sth = $dbh->prepare($query);
3390
    $sth->execute(
3391
    $sth->execute(
Lines 3395-3401 sub _koha_add_biblioitem { Link Here
3395
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3396
        $biblioitem->{'pages'},            $biblioitem->{'bnotes'},           $biblioitem->{'size'},                  $biblioitem->{'place'},
3396
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3397
        $biblioitem->{'lccn'},             $biblioitem->{'marc'},             $biblioitem->{'url'},                   $biblioitem->{'biblioitems.cn_source'},
3397
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3398
        $biblioitem->{'cn_class'},         $biblioitem->{'cn_item'},          $biblioitem->{'cn_suffix'},             $cn_sort,
3398
        $biblioitem->{'totalissues'},      $biblioitem->{'ean'}
3399
        $biblioitem->{'totalissues'},      $biblioitem->{'ean'},              $biblioitem->{'agerestriction'}
3399
    );
3400
    );
3400
    my $bibitemnum = $dbh->{'mysql_insertid'};
3401
    my $bibitemnum = $dbh->{'mysql_insertid'};
3401
3402
(-)a/C4/Circulation.pm (-1 / +65 lines)
Lines 44-50 use Data::Dumper; Link Here
44
use Koha::DateUtils;
44
use Koha::DateUtils;
45
use Koha::Calendar;
45
use Koha::Calendar;
46
use Carp;
46
use Carp;
47
47
use Date::Calc qw(
48
  Today
49
  Today_and_Now
50
  Add_Delta_YM
51
  Add_Delta_DHMS
52
  Date_to_Days
53
  Day_of_Week
54
  Add_Delta_Days
55
);
48
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
56
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
49
57
50
BEGIN {
58
BEGIN {
Lines 941-946 sub CanBookBeIssued { Link Here
941
            }
949
            }
942
        }
950
        }
943
    }
951
    }
952
    #
953
    # CHECK AGE RESTRICTION
954
    #
955
956
    # get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:"
957
    my $markers = C4::Context->preference('AgeRestrictionMarker' );
958
    my $bibvalues = $biblioitem->{'agerestriction'};
959
    if (($markers)&&($bibvalues))
960
    {
961
        # Split $bibvalues to something like FSK 16 or PEGI 6
962
        my @values = split ' ', $bibvalues;
963
964
        # Search first occurence of one of the markers
965
        my @markers = split /\|/, $markers;
966
        my $index = 0;
967
        my $take = -1;
968
        for my $value (@values) {
969
            $index ++;
970
            for my $marker (@markers) {
971
                $marker =~ s/^\s+//; #remove leading spaces
972
                $marker =~ s/\s+$//; #remove trailing spaces
973
                if (uc($marker) eq uc($value)) {
974
                    $take = $index;
975
                    last;
976
                }
977
            }
978
            if ($take > -1) {
979
                last;
980
            }
981
        }
982
        # Index points to the next value
983
        my $restrictionyear = 0;
984
        if (($take <= $#values) && ($take >= 0)){
985
            $restrictionyear += @values[$take];
986
        }
987
988
        if ($restrictionyear > 0) {
989
            if ( $borrower->{'dateofbirth'}  ) {
990
                my @alloweddate =  split /-/,$borrower->{'dateofbirth'} ;
991
                @alloweddate[0] += $restrictionyear;
992
                #Prevent runime eror on leap year (invalid date)
993
                if ((@alloweddate[1] == 2) && (@alloweddate[2] == 29)) {
994
                    @alloweddate[2] = 28;
995
                }
996
997
                if ( Date_to_Days(Today) <  Date_to_Days(@alloweddate) -1  ) {
998
                    if (C4::Context->preference('AgeRestrictionOverride' )) {
999
                        $needsconfirmation{AGE_RESTRICTION} = "$bibvalues";
1000
                    }
1001
                    else {
1002
                        $issuingimpossible{AGE_RESTRICTION} = "$bibvalues";
1003
                    }
1004
                }
1005
            }
1006
        }
1007
    }
944
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
1008
    return ( \%issuingimpossible, \%needsconfirmation, \%alerts );
945
}
1009
}
946
1010
(-)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 374-376 INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( Link Here
374
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');
374
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,options,type) VALUES('UpdateTotalIssuesOnCirc','0','Whether to update the totalissues field in the biblio on each circ.',NULL,'YesNo');
375
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('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');
376
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('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 / +13 lines)
Lines 5635-5640 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5635
    SetVersion($DBversion);
5635
    SetVersion($DBversion);
5636
}
5636
}
5637
5637
5638
$DBversion = "XXX";
5639
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5640
    # biblioitems changes
5641
    $dbh->do("ALTER TABLE biblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5642
    $dbh->do("ALTER TABLE deletedbiblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort");
5643
    # preferences changes
5644
    $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')");
5645
    $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')");
5646
5647
    print "Upgrade to $DBversion done (Add colum agerestriction to biblioitems and deletedbiblioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n";
5648
    SetVersion($DBversion);
5649
}
5650
5638
=head1 FUNCTIONS
5651
=head1 FUNCTIONS
5639
5652
5640
=head2 TableExists($table)
5653
=head2 TableExists($table)
Lines 5719-5722 sub SetVersion { Link Here
5719
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
5732
    C4::Context::clear_syspref_cache(); # invalidate cached preferences
5720
}
5733
}
5721
exit;
5734
exit;
5722
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+9 lines)
Lines 215-220 Circulation: Link Here
215
                  no: "Prevent"
215
                  no: "Prevent"
216
            - patrons from checking out an item whose rental charge would take them over the limit.
216
            - patrons from checking out an item whose rental charge would take them over the limit.
217
        -
217
        -
218
            - pref: AgeRestrictionMarker
219
            - "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.)"
220
        -
221
            - pref: AgeRestrictionOverride
222
              choices:
223
                  yes: Allow
224
                  no: "Don't allow"
225
            - staff to check out an item with age restriction.
226
        -
218
            - Prevent patrons from checking out books if they have more than
227
            - Prevent patrons from checking out books if they have more than
219
            - pref: noissuescharge
228
            - pref: noissuescharge
220
              class: integer
229
              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