Bug 25534: Use the cancelation reasion for the 'X' hold cancelation links
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 19 May 2020 17:25:00 +0000 (13:25 -0400)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 25 Aug 2020 13:07:27 +0000 (15:07 +0200)
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Rebecca Coert <rcoert@arlingtonva.us>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
reserve/request.pl

index dda14d2..92c195b 100644 (file)
         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 %]: {
 
             // 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 ) %]
index 9c8e009..b1e8745 100755 (executable)
@@ -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 );