@@ -, +, @@
and "Unit" set to days.
X days before due date.
undefined or current date is X or less days before due date.
the number of allowed renewals is exceeded "Not renewable" is
displayed, no matter what "No renewal before" is set to.
---
C4/Circulation.pm | 26 +++++++++++++++++---
.../prog/en/modules/circ/circulation.tt | 11 ++++++---
.../prog/en/modules/members/moremember.tt | 7 +++++-
3 files changed, 36 insertions(+), 8 deletions(-)
--- a/C4/Circulation.pm
+++ a/C4/Circulation.pm
@@ -2472,7 +2472,7 @@ sub CanBookBeRenewed {
my $dbh = C4::Context->dbh;
my $renews = 1;
- my $renewokay = 0;
+ my $renewokay = 1;
my $error;
my $item = GetItem($itemnumber) or return ( 0, 'no_item' );
@@ -2486,12 +2486,30 @@ sub CanBookBeRenewed {
my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branchcode);
- if ( ( $issuingrule->{renewalsallowed} > $itemissue->{renewals} ) || $override_limit ) {
- $renewokay = 1;
- } else {
+ if ( $issuingrule->{norenewalbefore} ) {
+
+ # Get current time and add norenewalbefore. If this is smaller than date_due, it's too soon for renewal.
+ if (
+ DateTime->now( time_zone => C4::Context->tz() )->add(
+ $issuingrule->{lengthunit} => $issuingrule->{norenewalbefore}
+ ) < $itemissue->{date_due}
+ )
+ {
+ $renewokay = 0;
+ $error = "too_soon";
+ }
+ }
+
+ if ( $issuingrule->{renewalsallowed} <= $itemissue->{renewals} ) {
+ $renewokay = 0;
$error = "too_many";
}
+ if ( $override_limit ) {
+ $renewokay = 1;
+ $error = undef;
+ }
+
my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves( $itemnumber );
if ( $resfound ) { # '' when no hold was found
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
@@ -785,10 +785,15 @@ No patron matched [% message %]
[% END %]
[% IF ( todayissue.renew_error_on_reserve ) %]
On hold
- [% END %]
- [% IF ( todayissue.renew_error_too_many ) %]
- Not renewable
+ [% ELSE %]
+ [% IF ( todayissue.renew_error_too_many ) %]
+ Not renewable
+ [% ELSE %]
+ [% IF ( todayissue.renew_error_too_soon ) %]
+ Not renewable yet
[% END %]
+ [% END %]
+ [% END %]
[% IF ( todayissue.can_confirm ) %]
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
@@ -507,10 +507,15 @@ function validate1(date) {
[% END %]
[% IF ( issueloo.norenew_reason_on_reserve ) %]
On Hold
- [% END %]
+ [% ELSE %]
[% IF ( issueloo.norenew_reason_too_many ) %]
Not renewable
+ [% ELSE %]
+ [% IF ( issueloo.norenew_reason_too_soon ) %]
+ Not renewable yet
+ [% END %]
[% END %]
+ [% END %]
[% IF ( issueloo.can_confirm ) %]
[% END %]
--