Bugzilla – Attachment 9219 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), 10.77 KB, created by
Marc Véron
on 2012-04-16 20:36:55 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-04-16 20:36:55 UTC
Size:
10.77 KB
patch
obsolete
>From 1e1df631ee08a48bd6906ceeb9f7e444060af708 Mon Sep 17 00:00:00 2001 >From: mveron <veron@veron.ch> >Date: Mon, 16 Apr 2012 22:34:12 +0200 >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" > >Test scenario: > >1) >Make sure that you have a column 'agerestriction' in table biblioitems. >This will be handled by updatedatabase.pl. If you want to insert the column using mysql, you can do: >ALTER TABLE biblioitems ADD COLUMN 'agerestriction' VARCHAR(255) DEFAULT NULL AFTER 'cn_sort' > >2) >In the staff client, go to Home . Administration . Koha to MARC mapping and choose biblioitems + OK. >In the field list, the field 'agerestriction' should show up. Edit it and map the field e.g. to 521a > >3) >Go to Home . Administration . System preferences and edit Circulation: AgeRestrictionMarker (add eg.: FSK|PEGI|Age) and AgeRestrictionOverride (Prevent or Don't prevent) > >4) >Create a young patron account e.g. with age < 16 > >5) >Create or edit a biblio with e.g. the value FSK 16 in the field 521a (same field as mapped above) > >6) >Try to check out to young patron > >7) >Chckout should be blocked or issue a warning with override (depending on AgeRestrictionOverride) >--- > C4/Biblio.pm | 10 ++- > C4/Circulation.pm | 64 +++++++++++++++++++- > installer/data/mysql/sysprefs.sql | 2 + > installer/data/mysql/updatedatabase.pl | 11 ++++ > .../en/modules/admin/preferences/circulation.pref | 9 +++ > .../prog/en/modules/circ/circulation.tt | 8 +++ > 6 files changed, 99 insertions(+), 5 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 56cd94e..4172745 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -3270,7 +3270,8 @@ sub _koha_modify_biblioitem_nonmarc { > cn_item = ?, > cn_suffix = ?, > cn_sort = ?, >- totalissues = ? >+ totalissues = ?, >+ agerestriction = ? > where biblioitemnumber = ? > "; > my $sth = $dbh->prepare($query); >@@ -3282,7 +3283,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->{'biblioitemnumber'} >+ $biblioitem->{'agerestriction'}, $biblioitem->{'biblioitemnumber'} > ); > if ( $dbh->errstr ) { > $error .= "ERROR in _koha_modify_biblioitem_nonmarc $query" . $dbh->errstr; >@@ -3333,7 +3334,8 @@ sub _koha_add_biblioitem { > cn_item = ?, > cn_suffix = ?, > cn_sort = ?, >- totalissues = ? >+ totalissues = ?, >+ agerestriction = ? > "; > my $sth = $dbh->prepare($query); > $sth->execute( >@@ -3344,7 +3346,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->{'totalissues'}, $biblioitem->{'agerestriction'} > ); > my $bibitemnum = $dbh->{'mysql_insertid'}; > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 6ca860d..f3cbe18 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -41,7 +41,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 { >@@ -926,6 +934,60 @@ 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] == 02) && (@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 ' )) { >+ $issuingimpossible{AGE_RESTRICTION} = "$restrictionyear"; >+ } >+ else { >+ $needsconfirmation{AGE_RESTRICTION} = "$restrictionyear"; >+ } >+ } >+ } >+ } >+ } >+ > return ( \%issuingimpossible, \%needsconfirmation ); > } > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 7a3731c..dee5080 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -362,3 +362,5 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES(' > INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AutoResumeSuspendedHolds', '1', NULL , 'Allow suspended holds to be automatically resumed by a set date.', 'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo'); >+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,'Do not prevent patrons from checking out an item whose age restriction would apply.',NULL,'YesNo'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 6e7ca1b..575e892 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5198,6 +5198,17 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "XXXX"; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ # biblioitems changes >+ $dbh->do("ALTER TABLE 'biblioitems' 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|',NULL,'free')"); >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Do not prevent patrons from checking out an item whose age restriction would apply.',NULL,'YesNo')"); >+ >+ print "Upgrade to $DBversion done (Add colum agerestriction to bilioitems, add system preferences AgeRestrictionMarker and AgeRestrictionOverride)\n"; >+ SetVersion($DBversion); >+} > > =head1 FUNCTIONS > >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 471aa0e..bc4eb18 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 >@@ -208,6 +208,15 @@ Circulation: > no: "Don't 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. Values e.g. FSK|PEGI|Age| . Entry e.g. in 521a like FSK 12 or PEGI 12 would then mean: Borrower must be 12 years old. (Empty: Do not apply age restriction.)" >+ - >+ - pref: AgeRestrictionOverride >+ choices: >+ yes: Prevent >+ no: "Don't prevent" >+ - patrons from checking out an item whose age restriction would apply. >+ - > - 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 e79cef1..5f9097b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -240,6 +240,10 @@ function refocus(calendar) { > <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 %] >@@ -391,6 +395,10 @@ function refocus(calendar) { > <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