Bugzilla – Attachment 10859 Details for
Bug 7621
Circulation: Match age restriction of title with borrower's age without using categories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories
BUG-7621-ENH-Circulation-Match-age-restriction-of-.patch (text/plain), 11.65 KB, created by
Marc Véron
on 2012-07-15 08:07:48 UTC
(
hide
)
Description:
BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2012-07-15 08:07:48 UTC
Size:
11.65 KB
patch
obsolete
>From ea8d4411f836382ce6bd187cbeb840285e41dba5 Mon Sep 17 00:00:00 2001 >From: Mason James <mtj@kohaaloha.com> >Date: Fri, 6 Jul 2012 10:59:48 +1200 >Subject: [PATCH] BUG 7621 [ENH] Circulation: Match age restriction of title with borrower's age without using categories >Content-Type: text/plain; charset="utf-8" > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > >New version implementing Paul's advice. >See Wiki http://wiki.koha-community.org/wiki/Age_restrictiotion > >REBASED to Koha version: 3.09.00.025 >Comparision part changed in C4/Circulation.pm >--- > C4/Biblio.pm | 11 ++-- > C4/Circulation.pm | 62 +++++++++++++++++++- > installer/data/mysql/kohastructure.sql | 2 + > installer/data/mysql/sysprefs.sql | 2 + > installer/data/mysql/updatedatabase.pl | 13 ++++- > .../en/modules/admin/preferences/circulation.pref | 9 +++ > .../prog/en/modules/circ/circulation.tt | 8 +++ > 7 files changed, 100 insertions(+), 7 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index f8ba099..d800482 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -3318,7 +3318,8 @@ sub _koha_modify_biblioitem_nonmarc { > cn_suffix = ?, > cn_sort = ?, > totalissues = ?, >- ean = ? >+ ean = ?, >+ agerestriction = ? > where biblioitemnumber = ? > "; > my $sth = $dbh->prepare($query); >@@ -3330,8 +3331,7 @@ sub _koha_modify_biblioitem_nonmarc { > $biblioitem->{'pages'}, $biblioitem->{'bnotes'}, $biblioitem->{'size'}, $biblioitem->{'place'}, > $biblioitem->{'lccn'}, $biblioitem->{'url'}, $biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'}, > $biblioitem->{'cn_item'}, $biblioitem->{'cn_suffix'}, $cn_sort, $biblioitem->{'totalissues'}, >- $biblioitem->{'ean'}, >- $biblioitem->{'biblioitemnumber'} >+ $biblioitem->{'ean'}, $biblioitem->{'agerestriction'}, $biblioitem->{'biblioitemnumber'} > ); > if ( $dbh->errstr ) { > $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr; >@@ -3383,7 +3383,8 @@ sub _koha_add_biblioitem { > cn_suffix = ?, > cn_sort = ?, > totalissues = ?, >- ean = ? >+ ean = ?, >+ agerestriction = ? > "; > my $sth = $dbh->prepare($query); > $sth->execute( >@@ -3394,7 +3395,7 @@ sub _koha_add_biblioitem { > $biblioitem->{'pages'}, $biblioitem->{'bnotes'}, $biblioitem->{'size'}, $biblioitem->{'place'}, > $biblioitem->{'lccn'}, $biblioitem->{'marc'}, $biblioitem->{'url'}, $biblioitem->{'biblioitems.cn_source'}, > $biblioitem->{'cn_class'}, $biblioitem->{'cn_item'}, $biblioitem->{'cn_suffix'}, $cn_sort, >- $biblioitem->{'totalissues'}, $biblioitem->{'ean'} >+ $biblioitem->{'totalissues'}, $biblioitem->{'ean'}, $biblioitem->{'agerestriction'} > ); > my $bibitemnum = $dbh->{'mysql_insertid'}; > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index efb720b..55f8988 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -42,7 +42,15 @@ use Data::Dumper; > use Koha::DateUtils; > use Koha::Calendar; > use Carp; >- >+use Date::Calc qw( >+ Today >+ Today_and_Now >+ Add_Delta_YM >+ Add_Delta_DHMS >+ Date_to_Days >+ Day_of_Week >+ Add_Delta_Days >+); > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > > BEGIN { >@@ -931,6 +939,58 @@ sub CanBookBeIssued { > } > } > } >+ # >+ # CHECK AGE RESTRICTION >+ # >+ >+ # get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:" >+ my $marker = C4::Context->preference('AgeRestrictionMarker' ); >+ >+ if ($marker) >+ { >+ # Split $value to something like FSK 16 or PEGI 6 >+ my @marker = split /\|/, $marker; >+ my @values = split ' ', $biblioitem->{'agerestriction'} ; >+ >+ # Search first occurence of one of the markers >+ my $index = 0; >+ my $take = -1; >+ for my $value (@values) { >+ $index ++; >+ if (grep {uc($_) eq $value} @marker) { >+ $take = $index; >+ last; >+ } >+ } >+ # Index points to the next value >+ my $restrictionyear = 0; >+ if (($take <= $#values) && ($take >= 0)){ >+ $restrictionyear += @values[$take]; >+ } >+ >+ if ($restrictionyear > 0) { >+ if ( $borrower->{'dateofbirth'} ) { >+ my @alloweddate = split /-/,$borrower->{'dateofbirth'} ; >+ @alloweddate[0] += $restrictionyear; >+ #Prevent runime eror on leap year (invalid date) >+ if ((@alloweddate[1] == 2) && (@alloweddate[2] == 29)) { >+ @alloweddate[2] = 28; >+ } >+ >+ my $td = Date_to_Days(Today); >+ my $ad = Date_to_Days(@alloweddate); >+ >+ if ( Date_to_Days(Today) < Date_to_Days(@alloweddate) -1 ) { >+ if (C4::Context->preference('AgeRestrictionOverride ' )) { >+ $needsconfirmation{AGE_RESTRICTION} = "$restrictionyear"; >+ } >+ else { >+ $issuingimpossible{AGE_RESTRICTION} = "$restrictionyear"; >+ } >+ } >+ } >+ } >+ } > return ( \%issuingimpossible, \%needsconfirmation, \%alerts ); > } > >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 3b9827a..39985a9 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -178,6 +178,7 @@ CREATE TABLE `biblioitems` ( -- information related to bibliographic records in > `cn_item` varchar(10) default NULL, > `cn_suffix` varchar(10) default NULL, > `cn_sort` varchar(30) default NULL, >+ `agerestriction` varchar(255) default NULL, > `totalissues` int(10), > `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML > PRIMARY KEY (`biblioitemnumber`), >@@ -650,6 +651,7 @@ CREATE TABLE `deletedbiblioitems` ( -- information about bibliographic records t > `cn_item` varchar(10) default NULL, > `cn_suffix` varchar(10) default NULL, > `cn_sort` varchar(30) default NULL, >+ `agerestriction` varchar(255) default NULL, > `totalissues` int(10), > `marcxml` longtext NOT NULL, -- full bibliographic MARC record in MARCXML > PRIMARY KEY (`biblioitemnumber`), >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 7009155..3056804 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -375,3 +375,5 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ( > 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'); > 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'); > 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'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index bb96644..20647ff 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5533,6 +5533,18 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > die("Failed to add reserve_id to reserves tables, please refresh the page to try again.") unless ( $row->{'count'} ); > > print "Upgrade to $DBversion done (add reserve_id to reserves & old_reserves tables)\n"; >+ >+$DBversion = "XXX"; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ # biblioitems changes >+ $dbh->do("ALTER TABLE biblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort"); >+ $dbh->do("ALTER TABLE deletedbiblioitems ADD COLUMN agerestriction VARCHAR(255) DEFAULT NULL AFTER cn_sort"); >+ # preferences changes >+ $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')"); >+ $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')"); >+ >+ print "Upgrade to $DBversion done (Add colum agerestriction to biblioitems and deletedbiblioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n"; >+ > SetVersion($DBversion); > } > >@@ -5620,4 +5632,3 @@ sub SetVersion { > C4::Context::clear_syspref_cache(); # invalidate cached preferences > } > exit; >- >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index e07fc0d..f0d0e3c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -214,6 +214,15 @@ Circulation: > no: "Prevent" > - patrons from checking out an item whose rental charge would take them over the limit. > - >+ - pref: AgeRestrictionMarker >+ - "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.)" >+ - >+ - pref: AgeRestrictionOverride >+ choices: >+ yes: Allow >+ no: "Don't allow" >+ - staff to check out an item with age restriction. >+ - > - Prevent patrons from checking out books if they have more than > - pref: noissuescharge > class: integer >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 2743c5f..083593f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -246,6 +246,10 @@ function validate1(date) { > <h3>Please confirm checkout</h3> > > <ul> >+[%IF ( AGE_RESTRICTION ) %] >+ <li>Age restriction [% AGE_RESTRICTION %]. Check out anyway?</li> >+[% END %] >+ > [% IF ( DEBT ) %] > <li>The patron has a debt of [% DEBT %]</li> > [% END %] >@@ -397,6 +401,10 @@ function validate1(date) { > <li>No more renewals possible</li> > [% END %] > >+ [%IF ( AGE_RESTRICTION ) %] >+ <li>Age restriction [% AGE_RESTRICTION %].</li> >+ [% END %] >+ > [% IF ( EXPIRED ) %] > <li>Patron's card is expired</li> > [% END %] >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7621
:
9176
|
9219
|
9979
|
10072
|
10136
|
10141
|
10142
|
10143
|
10144
|
10395
|
10550
|
10650
|
10657
|
10658
|
10859
|
10866
|
10896
|
11130
|
11550
|
11938
|
11939
|
12132
|
12133
|
12547
|
12558
|
12559
|
12563