From fb049735cf87040792999158ac0c27b00985fc2c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 28 Aug 2020 10:01:04 -0400 Subject: [PATCH] Bug 26282: Allow staff to decide if a hold cancellation notice will be sent when cancelling a hold Bug 25534 adds the option to send hold cancellation notices when a reason was given. It would be nice if you could give a reason but still decide not to send to the patron. Say the patron called and will not be able to pick up numerous holds for some time. You cancel them all with "patron requested cancellation" but don't want to send multiple notices. I could imagine a checkbox next to the reason to activate/deactivate sending the notice. Test Plan: 1) Apply this patch 2) Visit each area in Koha where a hold can be canceled with a reason 3) Note the new 'Notify patron' checkbox 4) Test canceling a hold with and without this checkbox checked 5) Verify leaving it unchecked does not trigger a notice to be sent to the patron Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi Signed-off-by: Josef Moravec --- C4/Reserves.pm | 3 ++- Koha/Hold.pm | 2 +- circ/pendingreserves.pl | 3 ++- .../prog/en/modules/circ/pendingreserves.tt | 3 +++ .../intranet-tmpl/prog/en/modules/reserve/request.tt | 10 ++++++++++ reserve/modrequest.pl | 3 +++ reserve/request.pl | 3 ++- 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 83222dc1c5..372b2d7eed 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1026,6 +1026,7 @@ sub ModReserve { my $borrowernumber = $params->{'borrowernumber'}; my $biblionumber = $params->{'biblionumber'}; my $cancellation_reason = $params->{'cancellation_reason'}; + my $notify_patron = $params->{'notify_patron'}; return if $rank eq "W"; return if $rank eq "n"; @@ -1043,7 +1044,7 @@ sub ModReserve { $hold ||= Koha::Holds->find($reserve_id); if ( $rank eq "del" ) { - $hold->cancel({ cancellation_reason => $cancellation_reason }); + $hold->cancel({ cancellation_reason => $cancellation_reason, notify_patron => $notify_patron }); } elsif ($rank =~ /^\d+/ and $rank > 0) { logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, Dumper($hold->unblessed) ) diff --git a/Koha/Hold.pm b/Koha/Hold.pm index bd5458f494..f9ce87945a 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -518,7 +518,7 @@ sub cancel { $self->cancellation_reason( $params->{cancellation_reason} ); $self->store(); - if ( $params->{cancellation_reason} ) { + if ( $params->{cancellation_reason} && $params->{notify_patron} ) { my $letter = C4::Letters::GetPreparedLetter( module => 'reserves', letter_code => 'HOLD_CANCELLATION', diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index 9310f26bbf..23124bd9aa 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -57,7 +57,8 @@ if ( $op eq 'cancel_reserve' and $reserve_id ) { my $hold = Koha::Holds->find( $reserve_id ); if ( $hold ) { my $cancellation_reason = $input->param('cancellation-reason'); - $hold->cancel({ cancellation_reason => $cancellation_reason }); + my $cancellation_notify_patron = $input->param('cancellation-notify-patron'); + $hold->cancel({ cancellation_reason => $cancellation_reason, notify_patron => $cancellation_notify_patron }); push @messages, { type => 'message', code => 'hold_cancelled' }; } } elsif ( $op =~ m|^mark_as_lost| ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt index fb90eeacdd..3a49ee1f22 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt @@ -198,6 +198,9 @@ [% END %] + + + [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index bddbe802d5..34642b9fa7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -887,6 +887,9 @@ [% END %] + + + [% END %] @@ -1037,6 +1040,9 @@ [% END %] + + + [% END %] @@ -1529,10 +1535,14 @@ let biblionumber = cancel_link.data('biblionumber'); let reserve_id = cancel_link.data('id'); let reason = $("#modal-cancellation-reason").val(); + let notify = $("#modal-cancellation-notify-patron").prop('checked'); let link = `request.pl?action=cancel&borrowernumber=${ borrowernumber }&biblionumber=${ biblionumber }&reserve_id=${ reserve_id }`; if ( reason ) { link += "&cancellation-reason=" + reason } + if ( notify ) { + link += "&cancellation-notify-patron=1"; + } window.location.href = link; return false; }); diff --git a/reserve/modrequest.pl b/reserve/modrequest.pl index f1ab945f2e..9bb80c2341 100755 --- a/reserve/modrequest.pl +++ b/reserve/modrequest.pl @@ -70,6 +70,8 @@ else { undef $itemnumber[$i] if !$itemnumber[$i]; my $suspend_until = $query->param( "suspend_until_" . $reserve_id[$i] ); my $cancellation_reason = $query->param("cancellation-reason"); + my $cancellation_notify_patron = $query->param("cancellation-notify-patron"); + my $params = { rank => $rank[$i], reserve_id => $reserve_id[$i], @@ -78,6 +80,7 @@ else { itemnumber => $itemnumber[$i], defined $suspend_until ? ( suspend_until => $suspend_until ) : (), cancellation_reason => $cancellation_reason, + notify_patron => $cancellation_notify_patron, }; if (C4::Context->preference('AllowHoldDateInFuture')) { $params->{reservedate} = $reservedates[$i] ? dt_from_string($reservedates[$i]) : undef; diff --git a/reserve/request.pl b/reserve/request.pl index bf13c3dfb2..17f52b66ea 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -106,8 +106,9 @@ if ( $action eq 'move' ) { } elsif ( $action eq 'cancel' ) { my $reserve_id = $input->param('reserve_id'); my $cancellation_reason = $input->param("cancellation-reason"); + my $cancellation_notify_patron = $input->param("cancellation-notify-patron"); my $hold = Koha::Holds->find( $reserve_id ); - $hold->cancel({ cancellation_reason => $cancellation_reason }) if $hold; + $hold->cancel({ cancellation_reason => $cancellation_reason, notify_patron => $cancellation_notify_patron }) if $hold; } elsif ( $action eq 'setLowestPriority' ) { my $reserve_id = $input->param('reserve_id'); ToggleLowestPriority( $reserve_id ); -- 2.30.1 (Apple Git-130)