Bugzilla – Attachment 12362 Details for
Bug 8236
Prevent renewing if overdue or restriction
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Block renewal for overdue documents
0001-Block-renewal-for-overdue-documents.patch (text/plain), 18.86 KB, created by
Koha Team University Lyon 3
on 2012-09-19 16:21:48 UTC
(
hide
)
Description:
Block renewal for overdue documents
Filename:
MIME Type:
Creator:
Koha Team University Lyon 3
Created:
2012-09-19 16:21:48 UTC
Size:
18.86 KB
patch
obsolete
>From a2653380ffc0a052c6b2156e61692a86a1f359f0 Mon Sep 17 00:00:00 2001 >From: Lyon3 Team <koha@univ-lyon3.fr> >Date: Wed, 19 Sep 2012 17:00:34 +0200 >Subject: [PATCH] Block renewal for overdue documents > >If any patron's document is late, renewal can be allowed, blocked on every checked >out items or only on overdue ones. >The renewal remains nevertheless possible for the librarian checking the Override renewal limit >--- > C4/Circulation.pm | 10 ++++------ > C4/ILSDI/Services.pm | 15 +++++++++++++-- > circ/circulation.pl | 11 ++++++++--- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 7 +++++++ > .../en/modules/admin/preferences/circulation.pref | 8 ++++++++ > .../prog/en/modules/circ/circulation.tt | 12 ++++++++++-- > .../prog/en/modules/members/moremember.tt | 7 ++++++- > koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt | 6 +++++- > members/moremember.pl | 12 ++++++++---- > opac/opac-user.pl | 12 ++++++++++-- > 11 files changed, 80 insertions(+), 21 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 40d124b..84bd2c3 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2265,14 +2265,11 @@ already renewed the loan. $error will contain the reason the renewal can not pro > sub CanBookBeRenewed { > > # check renewal status >- my ( $borrowernumber, $itemnumber, $override_limit ) = @_; >+ my ( $borrowernumber, $itemnumber, $override_limit, $overdue, $renewifoverdue) = @_; > my $dbh = C4::Context->dbh; > my $renews = 1; > my $renewokay = 0; >- my $error; >- >- # Look in the issues table for this item, lent to this borrower, >- # and not yet returned. >+ my $error; > > # Look in the issues table for this item, lent to this borrower, > # and not yet returned. >@@ -2314,7 +2311,8 @@ sub CanBookBeRenewed { > if ( my $data1 = $sthcount->fetchrow_hashref ) { > > if ( ( $data1->{renewalsallowed} && $data1->{renewalsallowed} > $data1->{renewals} ) || $override_limit ) { >- $renewokay = 1; >+ $renewokay = ($renewifoverdue eq 'blockitem' and $overdue and !$override_limit)? 0 : 1; >+ $error = 'overdue' unless $renewokay; > } > else { > $error="too_many"; >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 1b7de80..2a48ff2 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -555,10 +555,21 @@ sub RenewLoan { > return { code => 'RecordNotFound' } unless $$item{itemnumber}; > > # Add renewal if possible >- my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber ); >+ my $issue = GetItemIssue($itemnumber); >+ # Check for overdue on this document >+ my $dt_due = $issue->{'date_due'}->truncate( to => 'day' ); >+ my $dt_today = DateTime->now( time_zone => C4::Context->tz() ); >+ my $overdue = 1 if DateTime->compare( $dt_today,$dt_due ) == 1; >+ # Check if any of patron's documents is late >+ my ($memberblocked) = C4::Members::IsMemberBlocked($borrowernumber); >+ # Is renewal allowed on overdue documents ? >+ my $renewifoverdue = C4::Context->preference('RenewIfOverdue'); >+ my $norenewal = 1 if ( $renewifoverdue eq 'blockall' and $memberblocked == -1 ) or ( $renewifoverdue eq 'blockitem' and $ >+overdue ) or $memberblocked == 1;# last to check if patron is restricted >+ >+ my @renewal = $norenewal ? (0,'overdue') : CanBookBeRenewed( $borrowernumber, $itemnumber ); > if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); } > >- my $issue = GetItemIssue($itemnumber); > > # Hashref building > my $out; >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 2047497..f98748a 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -435,6 +435,13 @@ my $displayrelissues; > > our $totalprice = 0; > >+# Check if any of patron's documents is late >+my ($memberblocked) = C4::Members::IsMemberBlocked($borrowernumber); >+# and if renewal is allowed in that case >+my $renewifoverdue = C4::Context->preference('RenewIfOverdue'); >+my $norenewal = 1 if $renewifoverdue eq 'blockall' and $memberblocked == -1; >+$template->param( norenewal => 1 ) if $renewifoverdue ne 'allow'; >+ > sub build_issue_data { > my $issueslist = shift; > my $relatives = shift; >@@ -450,9 +457,7 @@ sub build_issue_data { > $it->{'itemnumber'}, $it->{'borrowernumber'} > ); > $it->{'charge'} = sprintf("%.2f", $it->{'charge'}); >- my ($can_renew, $can_renew_error) = CanBookBeRenewed( >- $it->{'borrowernumber'},$it->{'itemnumber'} >- ); >+ my ($can_renew, $can_renew_error) = $norenewal ? (0, 'overdue') : CanBookBeRenewed( $it->{'borrowernumber'},$it->{'itemnumber'}, undef, $it->{'overdue'}, $renewifoverdue ); > $it->{"renew_error_${can_renew_error}"} = 1 if defined $can_renew_error; > my ( $restype, $reserves, undef ) = CheckReserves( $it->{'itemnumber'} ); > $it->{'can_renew'} = $can_renew; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 49debd2..de75a4f 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -299,6 +299,7 @@ INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanatio > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ILS-DI','0','Enables ILS-DI services at OPAC.','','YesNo'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('ILS-DI:AuthorizedIPs','','.','Restricts usage of ILS-DI to some IPs','Free'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OverduesBlockCirc','noblock','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','noblock|confirmation|block','Choice'); >+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('RenewIfOverdue','allow','If any of patron\'s checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','allow|blockitem|blockall','Choice'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('DisplayMultiPlaceHold','1','Display the ability to place multiple holds or not','','YesNo'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesLocation','1','Use the item location when finding items for the shelf browser.','1','YesNo'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('ShelfBrowserUsesHomeBranch','1','Use the item home branch when finding items for the shelf browser.','1','YesNo'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index c1e64ec..f3e237c 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -5206,6 +5206,13 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.07.00.050"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('RenewIfOverdue','allow','If any of a patron\'s checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','allow|blockitem|blockall','Choice')"); >+ print "Upgrade to $DBversion done (Add system preference BlockRenewal ))\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..43a9b50 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 >@@ -234,6 +234,14 @@ Circulation: > confirmation: Ask for confirmation > - when checking out to a borrower that has overdues outstanding > - >+ - If any of a patron's checked out documents is late, the renewal is >+ - pref: RenewIfOverdue >+ type: choice >+ choices: >+ allow: allowed >+ blockall: blocked on whatever of his checked out documents >+ blockitem: blocked only on the overdue items >+ - > - On checkin route the returned item to > - pref: HomeOrHoldingBranchReturn > type: choice >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..d3586d1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -735,7 +735,7 @@ No patron matched <span class="ex">[% message %]</span> > <td><span style="padding: 0 1em;">[% IF ( todayissue.renewals ) %][% todayissue.renewals %][% ELSE %]0[% END %]</span> > [% IF ( todayissue.can_renew ) %] > <input type="checkbox" name="all_items[]" value="[% todayissue.itemnumber %]" checked="checked" style="display: none;" /> >- [% IF ( todayissue.od ) %] >+ [% IF ( todayissue.od and ! previssue.renew_error_overdue) %] > <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" checked="checked" /> > [% ELSE %] > <input type="checkbox" class="radio" name="items[]" value="[% todayissue.itemnumber %]" /> >@@ -757,6 +757,9 @@ No patron matched <span class="ex">[% message %]</span> > [% IF ( todayissue.renew_error_too_many ) %] > Not renewable > [% END %] >+ [% IF ( todayissue.renew_error_overdue ) %] >+ Renewal not allowed (overdue) >+ [% END %] > [% IF ( todayissue.can_confirm ) %] > </span> > [% END %] >@@ -818,7 +821,7 @@ No patron matched <span class="ex">[% message %]</span> > [% ELSE %] > [% IF ( previssue.can_confirm ) %]<span class="renewals-allowed" style="display: none"> > <input type="checkbox" name="all_items[]" value="[% previssue.itemnumber %]" checked="checked" style="display: none;" /> >- [% IF ( previssue.od ) %] >+ [% IF ( previssue.od and ! previssue.renew_error_overdue ) %] > <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" checked="checked" /> > [% ELSE %] > <input type="checkbox" class="radio" name="items[]" value="[% previssue.itemnumber %]" /> >@@ -832,6 +835,9 @@ No patron matched <span class="ex">[% message %]</span> > [% IF ( previssue.renew_error_too_many ) %] > Not renewable > [% END %] >+ [% IF ( previssue.renew_error_overdue ) %] >+ Renewal not allowed (overdue) >+ [% END %] > [% IF ( previssue.can_confirm ) %] > </span> > [% END %] >@@ -865,7 +871,9 @@ No patron matched <span class="ex">[% message %]</span> > [% END %] > [% END %] > <input type="submit" name="renew_checked" value="Renew or Return checked items" /> >+ [% UNLESS ( norenewal ) %] > <input type="submit" id="renew_all" name="renew_all" value="Renew all" /> >+ [% END %] > </fieldset> > [% END %] > </form> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 27c7a2f..fe64db5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -484,7 +484,7 @@ function validate1(date) { > [% IF ( issueloo.norenew ) %] > [% IF ( issueloo.can_confirm ) %]<span class="renewals-allowed" style="display: none"> > <input type="checkbox" name="all_items[]" value="[% issueloo.itemnumber %]" checked="checked" style="display: none;" /> >- [% IF ( issueloo.od ) %] >+ [% IF ( issueloo.odi and !issueloo.norenew_reason_overdue ) %] > <input type="checkbox" name="items[]" value="[% issueloo.itemnumber %]" checked="checked" /> > [% ELSE %] > <input type="checkbox" name="items[]" value="[% issueloo.itemnumber %]" /> >@@ -492,6 +492,9 @@ function validate1(date) { > </span> > <span class="renewals-disabled"> > [% END %] >+ [% IF ( issueloo.norenew_reason_overdue ) %] >+ Renewal not allowed (overdue) >+ [% END %] > [% IF ( issueloo.norenew_reason_on_reserve ) %] > <a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% issueloo.biblionumber %]">On Hold</a> > [% END %] >@@ -534,7 +537,9 @@ function validate1(date) { > [% END %] > [% END %] > <input type="submit" name="renew_checked" value="Renew or return checked items" /> >+ [% UNLESS ( norenewal ) %] > <input type="submit" id="renew_all" name="renew_all" value="Renew all" /> >+ [% END %] > </fieldset> > [% ELSE %]<p>Patron has nothing checked out.</p> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt >index 9729c7c..8d74c42 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt >@@ -247,8 +247,11 @@ $.tablesorter.addParser({ > [% IF ( OpacRenewalAllowed ) %] > <td>[% IF ( ISSUE.status ) %][% IF ( canrenew ) %]<input type="checkbox" name="item" value="[% ISSUE.itemnumber %]"/> <a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&item=[% ISSUE.itemnumber %]&borrowernumber=[% ISSUE.borrowernumber %]">Renew</a>[% END %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span> > [% ELSE %] >+ [% IF ( ISSUE.norenew_overdue ) %] >+ Renewal not allowed <span class="renewals">(overdue on a document)</span> >+ [% ELSE %] > Not renewable[% IF ( ISSUE.too_many ) %] <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>[% ELSE %][% IF ( ISSUE.on_reserve ) %] <span class="renewals">(On hold)</span>[% END %][% END %] >- [% END %]</td> >+ [% END %][% END %]</td> > [% END %] > [% IF ( OPACFinesTab ) %] > <td>[% IF ( ISSUE.charges ) %]Yes[% ELSE %]No[% END %]</td> >@@ -329,6 +332,7 @@ $.tablesorter.addParser({ > [% IF ( OVERDUE.debarred ) %]Account frozen > [% ELSIF ( OVERDUE.status ) %] > [% IF ( canrenew ) %]<a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&item=[% OVERDUE.itemnumber %]&bornum=[% OVERDUE.borrowernumber %]">Renew</a>[% END %] <span class="renewals">([% OVERDUE.renewsleft %] of [% OVERDUE.renewsallowed %] renewals remaining)</span> >+[% ELSIF ( OVERDUE.norenew_overdue ) %]Renewal not allowed<span class="renewals">(overdue on a document)</span> > [% ELSIF ( OVERDUE.onreserve ) %]On hold > [% ELSE %]No renewals left > [% END %] >diff --git a/members/moremember.pl b/members/moremember.pl >index df7052b..8eb2f24 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -256,6 +256,13 @@ my @borrowers_with_issues; > my $overdues_exist = 0; > my $totalprice = 0; > >+# Check if any of patron's documents is late >+my ($memberblocked)=C4::Members::IsMemberBlocked($borrowernumber); >+# and if renewal is allowed in that case >+my $renewifoverdue = C4::Context->preference('RenewIfOverdue'); >+my $norenewal = 1 if $renewifoverdue eq 'blockall' and $memberblocked == -1; >+$template->param( norenewal => 1 ) if $renewifoverdue ne 'allow'; >+ > my @issuedata = build_issue_data($issue); > my @relissuedata = build_issue_data($relissue); > >@@ -506,10 +513,7 @@ sub build_issue_data { > $row{'itemtype_image'} = $itemtypeinfo->{imageurl}; > > $row{'charge'} = sprintf( "%.2f", $charge ); >- >- my ( $renewokay, $renewerror ) = >- CanBookBeRenewed( $borrowernumber, $issue->{itemnumber}, >- $override_limit ); >+ my ( $renewokay, $renewerror ) = $norenewal ? (0, 'overdue') : CanBookBeRenewed( $borrowernumber, $issue->{itemnumber}, $override_limit, $issue->{overdue}, $renewifoverdue ); > $row{'norenew'} = !$renewokay; > $row{'can_confirm'} = ( !$renewokay && $renewerror ne 'on_reserve' ); > $row{"norenew_reason_$renewerror"} = 1 if $renewerror; >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index a9a6305..0a424de 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -149,6 +149,12 @@ my @overdues; > my @issuedat; > my $itemtypes = GetItemTypes(); > my $issues = GetPendingIssues($borrowernumber); >+ >+# Check if any of patron's documents is late >+my ($memberblocked) = C4::Members::IsMemberBlocked($borrowernumber); >+# and if renewal is allowed in that case >+my $renewifoverdue = C4::Context->preference('RenewIfOverdue'); >+my $norenewal = 1 if $renewifoverdue eq 'blockall' and $memberblocked == -1; > if ($issues){ > foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) { > # check for reserves >@@ -175,14 +181,16 @@ if ($issues){ > $issue->{$publictype} = 1; > > # check if item is renewable >- my ($status,$renewerror) = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} ); >+ my ($status,$renewerror) = $norenewal ? (0, 'overdue') : CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'}, undef, $issue->{'overdue'}, $renewifoverdue); > ($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'}); > if($status && C4::Context->preference("OpacRenewalAllowed")){ > $issue->{'status'} = $status; > } > $issue->{'too_many'} = 1 if $renewerror and $renewerror eq 'too_many'; > $issue->{'on_reserve'} = 1 if $renewerror and $renewerror eq 'on_reserve'; >- >+ $issue->{'norenew_overdue'} = 1 if $renewerror and $renewerror eq 'overdue'; >+ my $oc='/home/kohabac/octest'; >+ open (my $fh,">$oc");print $fh "blop : $issue->{'norenew_overdue'}";close $fh; > if ( $issue->{'overdue'} ) { > push @overdues, $issue; > $overdues_count++; >-- >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 8236
:
10230
|
11958
|
12362
|
12619
|
12727
|
12790
|
12791
|
13510
|
14433
|
17926
|
18071
|
18073
|
18507
|
18729
|
20716
|
20719
|
21163
|
21223
|
22264
|
22275
|
22280
|
34234
|
34322
|
35372
|
36674
|
36743
|
37407
|
37418
|
37457
|
37458
|
37459
|
41992
|
41993
|
41994
|
42007
|
43628