From 6f699efa29b1c147f05961cb6effd868e51e410a Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 23 Jan 2020 02:38:50 +0000 Subject: [PATCH] Bug 24476: Allow patrons to opt out of auto-renewal To test: 1 - Verify on staff side that patron can be edited to opt in our out of auto renewal 2 - Check out some items to a patron opted in to auto renewal 3 - Ensure the items are checked out and set to autorenew 4 - Login on the opac at the patron 5 - Verify items cannot be renewed as scheduled for auto-renewal 6 - On staff side, opt patron out of auto renewal 7 - Verify on opac items are no longer marked for auto renewal 8 - Run the auto renewal cron job, items are not renewed 9 - Set 'no renewal before' to a setting that would prevent renewal 10 - Verify that opting patron in or out of auto renewal changes only the reason items cannot be renewed 11 - Set 'no renewal before' to a setting that would allow for renewal 12 - Verify that opting patron in/out changes their ability to renew 13 - Verify that when opted out cron does not renew 14 - Verify that when opted in the item is auto renewed 15 - Reset the due date, opt out, verify manual renewal succeeds Signed-off-by: Andrew Signed-off-by: Andrew Fuerste-Henry --- C4/Circulation.pm | 2 +- .../prog/en/modules/circ/circulation.tt | 14 ++++++++--- .../prog/en/modules/members/memberentrygen.tt | 27 ++++++++++++++++++++++ .../prog/en/modules/members/members-update.tt | 1 + .../prog/en/modules/members/moremember-brief.tt | 1 + .../prog/en/modules/members/moremember.tt | 6 +++++ .../bootstrap/en/modules/opac-memberentry.tt | 27 ++++++++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 6 ++--- members/memberentry.pl | 1 + misc/cronjobs/automatic_renewals.pl | 2 +- t/db_dependent/Circulation.t | 2 +- 11 files changed, 80 insertions(+), 9 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index a529b2ebbe..3bc9841065 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2817,7 +2817,7 @@ sub CanBookBeRenewed { # Fallback for automatic renewals: # If norenewalbefore is undef, don't renew before due date. - if ( $issue->auto_renew && !$auto_renew ) { + if ( $issue->auto_renew && !$auto_renew && $patron->autorenew_checkouts ) { my $now = dt_from_string; if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){ $auto_renew = 1; 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 3d13536df8..feb3c3a5e6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -568,15 +568,23 @@
[% IF NEEDSCONFIRMATION %] [% IF auto_renew %] - + [% IF patron.autorenewal %] + + [% ELSE %] + + [% END %] [% ELSE %] [% END %] [% ELSE %] - [% IF auto_renew %] + [% IF ( auto_renew && patron.autorenewal ) %] - [% ELSE %] + [% ELSIF patron.autorenewal %] + [% ELSE %] + [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 2b6a379d71..20ddc76026 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -874,6 +874,33 @@ legend:hover { [% END # /UNLESS nosort2 %] + [% UNLESS noautorenewal %] +
  • + + [% IF ( autorenewal ) %] + + + [% ELSE %] + + + [% END %] +
  • + [% END %] + [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt index 77b368740d..c16e432530 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt @@ -52,6 +52,7 @@ [% CASE 'contacttitle' %]Contact: Title [% CASE 'relationship' %]Contact: Relationship [% CASE 'sex' %]Gender +[% CASE 'autorenewal' %]Auto-renewal [% CASE 'altcontactfirstname' %]Alternate contact: First name [% CASE 'altcontactsurname' %]Alternate contact: Surname [% CASE 'altcontactaddress1' %]Alternate contact: Address diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt index 1c3b2c3b1b..ecac3b7f28 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt @@ -84,6 +84,7 @@
  • Library: [% patron.library.branchname | html %]
  • [% IF ( patron.sort1 ) %]
  • Sort field 1:[% AuthorisedValues.GetByCode('Bsort1', patron.sort1) | html %]
  • [% END %] [% IF ( patron.sort2 ) %]
  • Sort field 2:[% AuthorisedValues.GetByCode('Bsort2', patron.sort2) | html %]
  • [% END %] + [% UNLESS ( patron.autorenewal ) %]
  • Auto renewal: Patron has opted out
  • [% END %]
    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 ab3e89abf7..fbbc2b2be1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -520,6 +520,12 @@ [% AuthorisedValues.GetByCode('Bsort2', patron.sort2) | html %] [% END %] + [% UNLESS ( patron.autorenewal ) %] +
  • + Auto renewal: + Patron has opted out +
  • + [% END %]
  • Username: [% patron.userid | html %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 8761cc88ae..a2bcde4516 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -258,6 +258,33 @@ [% END %]
  • [% END %] + [% UNLESS hidden.defined('autorenewal') %] +
  • + + [% IF ( borrower.autorenewal ) %] + + + + [% ELSE %] + + + [% END %] +
  • + [% END %] [% END # / defined 'branchcode' %] 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 369dbd7dd0..47f10db028 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -330,12 +330,12 @@ [% ELSIF ISSUE.auto_account_expired %] Automatic renewal failed, your account is expired. ([% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining) - [% ELSIF ( ISSUE.auto_renew || ISSUE.auto_too_soon ) %] - Automatic renewal - ([% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining) [% ELSIF ( ISSUE.too_soon ) %] No renewal before [% ISSUE.soonestrenewdate | html %] ([% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining) + [% ELSIF ( ISSUE.auto_renew || ISSUE.auto_too_soon ) %] + Automatic renewal + ([% ISSUE.renewsleft | html %] of [% ISSUE.renewsallowed | html %] renewals remaining) [% ELSIF ( ISSUE.item_denied_renewal ) %] Renewal not allowed [% END %] diff --git a/members/memberentry.pl b/members/memberentry.pl index ed482b9b81..d16dd8ccfe 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -738,6 +738,7 @@ $template->param(no_add => $no_add); $template->param( sort1 => $data{'sort1'}); $template->param( sort2 => $data{'sort2'}); +$template->param( autorenew => $data{'autorenew'}); if ($nok) { foreach my $error (@errors) { diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl index d7bc5a140b..a3bded3aea 100755 --- a/misc/cronjobs/automatic_renewals.pl +++ b/misc/cronjobs/automatic_renewals.pl @@ -80,7 +80,7 @@ GetOptions( pod2usage(0) if $help; cronlogaction(); -my $auto_renews = Koha::Checkouts->search({ auto_renew => 1 }); +my $auto_renews = Koha::Checkouts->search({ auto_renew => 1, 'borrower.autorenewal' => 1 },{ join => 'borrower'}); my %report; $verbose = 1 unless $verbose or $confirm; diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index f0d46df0ed..72dd1d2948 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -274,7 +274,7 @@ Koha::CirculationRules->set_rules( my ( $reused_itemnumber_1, $reused_itemnumber_2 ); subtest "CanBookBeRenewed tests" => sub { - plan tests => 77; + plan tests => 83; C4::Context->set_preference('ItemsDeniedRenewal',''); # Generate test biblio -- 2.11.0