From 30da39d4f798930c854ddf7425d9f35bad061097 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 --- .../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 2da776f128..e48b476c8a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -951,6 +951,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 %]: { @@ -1237,7 +1238,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 26e40dd685..be6b7d52ac 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.24.2 (Apple Git-127)