Bugzilla – Attachment 9176 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), 6.80 KB, created by
Marc Véron
on 2012-04-13 12:55:17 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-13 12:55:17 UTC
Size:
6.80 KB
patch
obsolete
>From 9dc4cb99fce800b0e8ee18a06ddc1e771e5991ef Mon Sep 17 00:00:00 2001 >From: mveron <veron@veron.ch> >Date: Fri, 13 Apr 2012 14:52:26 +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) >Edit preferences Circulation: AgeRestrictionField (521), AgeRestrictionSubField (a), AgeRestrictionMarker (FSK|PEGI|Age) and AgeRestrictionOverride (Prevent or Dont prevent) > >2) >Create a young patron account e.g. with age < 16 > >3) >Create or edit a biblio with e.g. the value FSK 16 in the field 521a > >4) >Try to check out to young patron > >5) >Chckout should be blocked or issue a warning with override (depending on AgeRestrictionOverride) >--- > C4/Circulation.pm | 87 ++++++++++++++++++++ > .../en/modules/admin/preferences/circulation.pref | 13 +++ > .../prog/en/modules/circ/circulation.tt | 8 ++ > 3 files changed, 108 insertions(+), 0 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 6ca860d..4b6f632 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -41,6 +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); > >@@ -926,6 +935,84 @@ sub CanBookBeIssued { > } > } > } >+ >+ # >+ # CHECK AGE RESTRICTION ON TITLE >+ # >+ >+ # get $marker from preferences. Could be something like "FSK|PEGI|Alter|Age:" >+ my $marker = C4::Context->preference('AgeRestrictionMarker' ); >+ my $xmlfield = C4::Context->preference('AgeRestrictionField' ); >+ my $xmlsubfield = C4::Context->preference('AgeRestrictionSubField' ); >+ >+ if (($marker) && ($xmlfield)) >+ { >+ my $thesql; >+ if ($xmlsubfield) { >+ $thesql = "SELECT ExtractValue(( SELECT marcxml FROM biblioitems WHERE biblionumber=?), >+ '//datafield[\@tag=\"${xmlfield}\"]/subfield[\@code=\"${xmlsubfield}\"]') AS mycode;"; >+ } else { >+ $thesql = "SELECT ExtractValue(( SELECT marcxml FROM biblioitems WHERE biblionumber=?), >+ '//datafield[\@tag=\"${xmlfield}\"]]') AS mycode;"; >+ } >+ >+ #Hard coded version >+ #my $thesql = "SELECT ExtractValue(( SELECT marcxml FROM biblioitems WHERE biblionumber=?), >+ # '//datafield[\@tag=\"521\"]/subfield[\@code=\"a\"]') AS mycode;"; >+ >+ my $mysth = $dbh->prepare($thesql); >+ $mysth->execute( $item->{'itemnumber'} ); >+ my $iteminfo = $mysth->fetchrow_hashref; >+ $mysth->finish; >+ >+ my $values = uc( $iteminfo->{'mycode'} ); >+ >+ my @marker = split /\|/, $marker; >+ >+ # Split $value Something like FSK 16 or PEGI 6 >+ my @values = split ' ', $values ; >+ >+ # Search first occurence of one of the labels >+ 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 runtime 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/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..ac7c23a 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,19 @@ Circulation: > no: "Don't prevent" > - patrons from checking out an item whose rental charge would take them over the limit. > - >+ - pref: AgeRestrictionField >+ - pref: AgeRestrictionSubField >+ - "Marc field / subfield for age restriction. E.g. 521 a (Empty AgeRestrictionField - Do not apply age restriction)" >+ - >+ - pref: AgeRestrictionMarker >+ - "E.g. FSK|PEGI|Age| (No white space near |). Entry in Marc field e.g. PEGI 6 (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..174b1f6 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