From 27c80187ba55e801787a591d0d867921617d8339 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 19 May 2020 13:25:00 -0400 Subject: [PATCH] Bug 25534: Use the cancelation reasion for the 'X' hold cancelation links Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Rebecca Coert Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../prog/en/modules/reserve/request.tt | 15 ++++++++++++++- reserve/request.pl | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) 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 dda14d2f85..92c195b732 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -956,6 +956,7 @@ var biblionumber = "[% biblionumber | $raw %]"; var borrowernumber = "[% patron.borrowernumber | $raw %]"; var MSG_CONFIRM_DELETE_HOLD = _("Are you sure you want to cancel this hold?"); + var REASON_LABEL = _("Reason: "); var patron_homebranch = "[% To.json( Branches.GetName( patron.branchcode ) ) | $raw %]"; var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %] [% itemloo.itemnumber | html %]: { @@ -1245,7 +1246,19 @@ // Confirm cancelation of hold $(".cancel-hold").on("click",function(e) { - return confirmDelete(MSG_CONFIRM_DELETE_HOLD); + e.preventDefault; + let msg = MSG_CONFIRM_DELETE_HOLD ; + if ( $("#cancellation-reason").val() ) { + const reason = $("#cancellation-reason option:selected").text(); + msg += "\n\n" + REASON_LABEL + reason; + } + const confirm = confirmDelete(msg); + if ( confirm ) { + let href = $(this).attr('href'); + href += "&cancellation-reason=" + $("#cancellation-reason").val(); + window.location = href; + } + return false; }); [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems ) %] diff --git a/reserve/request.pl b/reserve/request.pl index 9c8e0090d7..b1e8745969 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 $hold = Koha::Holds->find( $reserve_id ); - $hold->cancel if $hold; + $hold->cancel({ cancellation_reason => $cancellation_reason }) if $hold; } elsif ( $action eq 'setLowestPriority' ) { my $reserve_id = $input->param('reserve_id'); ToggleLowestPriority( $reserve_id ); -- 2.39.5