From 0844a51c399ffcec37aec4f88c920802f16eafc7 Mon Sep 17 00:00:00 2001 From: kohapreprod Date: Tue, 9 Dec 2014 15:49:06 +0100 Subject: [PATCH] Bug 8236 Renewing policy in overdue or restriction case This patch introduces 2 sysprefs : RestrictionBlockRenewing to allow/block renewal of items when patron is restricted. OverduesBlockRenewing to allow, block only the late ones or block all checked out items Default is "allow" in both case. --- C4/Circulation.pm | 12 +++++++++++- installer/data/mysql/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 14 ++++++++++++++ koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc | 3 +++ koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js | 18 ++++++++++++++++++ .../en/modules/admin/preferences/circulation.pref | 15 +++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 4 ++++ opac/opac-user.pl | 3 +++ 8 files changed, 70 insertions(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index f24f2f7..adc51d1 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2713,7 +2713,6 @@ sub CanBookBeRenewed { $resfound = 0; } } - return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found return ( 1, undef ) if $override_limit; @@ -2725,6 +2724,17 @@ sub CanBookBeRenewed { return ( 0, "too_many" ) if $issuingrule->{renewalsallowed} <= $itemissue->{renewals}; + my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); + my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing'); + my $restricted = Koha::Borrower::Debarments::IsDebarred($borrowernumber); + my $hasoverdues = HasOverdues($borrowernumber); + + if ( $restricted and $restrictionblockrenewing ) { + return ( 0, 'restriction'); + } elsif ( ($hasoverdues and $overduesblockrenewing eq 'block') || ($itemissue->{overdue} and $overduesblockrenewing eq 'blockitem') ) { + return ( 0, 'overdue'); + } + if ( $issuingrule->{norenewalbefore} ) { # Get current time and add norenewalbefore. diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index c3e308f..13013e3 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -326,6 +326,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OverdueNoticeBcc','','','Email address to bcc outgoing overdue notices sent by email','free'), ('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'), ('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'), +('OverduesBlockRenewing','allow','allow|blockitem|block','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','Choice'), ('patronimages','0',NULL,'Enable patron images for the Staff Client','YesNo'), ('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'), ('PatronSelfRegistrationAdditionalInstructions','','','A free text field to display additional instructions to newly self registered patrons.','free'), @@ -357,6 +358,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('ReservesControlBranch','PatronLibrary','ItemHomeLibrary|PatronLibrary','Branch checked for members reservations rights','Choice'), ('ReservesMaxPickUpDelay','7','','Define the Maximum delay to pick up an item on hold','Integer'), ('ReservesNeedReturns','1','','If ON, a hold placed on an item available in this library must be checked-in, otherwise, a hold on a specific item, that is in the library & available is considered available','YesNo'), +('RestrictionBlockRenewing','0',NULL,'If patron is restricted, should renewal be allowed or blocked','YesNo'), ('ReturnBeforeExpiry','0',NULL,'If ON, checkout will be prevented if returndate is after patron card expiry','YesNo'), ('ReturnLog','1',NULL,'If ON, enables the circulation (returns) log','YesNo'), ('ReturnToShelvingCart','0','','If set, when any item is \'checked in\', it\'s location code will be changed to CART.','YesNo'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index cf17e0b..fbc9e6d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -9585,6 +9585,20 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.19.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverduesBlockRenewing','allow','If any of a patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','allow|blockitem|block','Choice')"); + print "Upgrade to $DBversion done (Bug 8236: Add system preference OverduesBlockRenewing)\n"; + SetVersion($DBversion); +} + +$DBversion = "3.19.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('RestrictionBlockRenewing','0','If patron is restricted, should renewal be allowed or blocked',NULL,'YesNo')"); + print "Upgrade to $DBversion done (Bug 8236: Add system preference RestrictionBlockRenewing)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc index 312df74..2846b73 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc @@ -1,5 +1,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js index a135496..0225a00 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/checkouts.js @@ -103,6 +103,10 @@ $(document).ready(function() { content += TOO_MANY_RENEWALS; } else if ( data.error == "on_reserve" ) { content += ON_RESERVE; + } else if ( data.error == "restriction" ) { + content += NOT_RENEWABLE_RESTRICTION; + } else if ( data.error == "overdue" ) { + content += NOT_RENEWABLE_OVERDUE; } else if ( data.error ) { content += data.error; } else { @@ -294,6 +298,20 @@ $(document).ready(function() { span_style = "display: none"; span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "restriction" ) { + content += "" + + NOT_RENEWABLE_RESTRICTION + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; + } else if ( oObj.can_renew_error == "overdue" ) { + content += "" + + NOT_RENEWABLE_OVERDUE + + ""; + + span_style = "display: none"; + span_class = "renewals-allowed"; } else if ( oObj.can_renew_error == "too_soon" ) { content += "" + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) 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 a296bf6..8354e0b 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 @@ -398,6 +398,21 @@ Circulation: yes: Enable no: Disable - the on-site for all cases (Even if a user is debarred, etc.). + - + - When a patron's checked out item is late, + - pref: OverduesBlockRenewing + type: choice + choices: + allow: allow renewing. + blockitem: block renewing only for this item. + block: block renewing for all his items. + - + - If patron is restricted, + - pref: RestrictionBlockRenewing + choices: + yes: Block + no: Allow + - renewing of items. Checkin Policy: - - pref: BlockReturnOfWithdrawnItems diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index f4cbddb..2bca720 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -230,6 +230,8 @@ ([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining) [% ELSIF ( ISSUE.too_many ) %] Not renewable + [% ELSIF ( ISSUE.norenew_overdue ) %] + Not allowed (overdue on a document) [% ELSIF ( ISSUE.auto_renew || ISSUE.auto_too_soon ) %] Automatic renewal ([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining) @@ -463,6 +465,8 @@ Renew [% END %] ([% OVERDUE.renewsleft %] of [% OVERDUE.renewsallowed %] renewals remaining) + [% ELSIF ( OVERDUE.norenew_overdue ) %] + Not allowed(overdue on a document) [% ELSIF ( OVERDUE.onreserve ) %] On hold [% ELSE %] diff --git a/opac/opac-user.pl b/opac/opac-user.pl index ad4f339..96cc137 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -199,6 +199,7 @@ if ($issues){ if ($renewerror) { $issue->{'too_many'} = 1 if $renewerror eq 'too_many'; $issue->{'on_reserve'} = 1 if $renewerror eq 'on_reserve'; + $issue->{'norenew_overdue'} = 1 if $renewerror eq 'overdue'; $issue->{'auto_renew'} = 1 if $renewerror eq 'auto_renew'; $issue->{'auto_too_soon'} = 1 if $renewerror eq 'auto_too_soon'; @@ -245,6 +246,8 @@ if ($issues){ } } } +my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); +$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count); $template->param( ISSUES => \@issuedat ); $template->param( issues_count => $count ); $template->param( canrenew => $canrenew ); -- 1.7.10.4