From a87551980dad680012b7e7d9ea26ad8781383ae9 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Tue, 19 May 2020 13:43:24 -0400
Subject: [PATCH] Bug 25534: Add reason to pendingreserves.pl

---
 circ/pendingreserves.pl                        |  3 ++-
 .../prog/en/modules/circ/pendingreserves.tt    | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl
index 7f2062942a..2886f31e8e 100755
--- a/circ/pendingreserves.pl
+++ b/circ/pendingreserves.pl
@@ -56,7 +56,8 @@ my @messages;
 if ( $op eq 'cancel_reserve' and $reserve_id ) {
     my $hold = Koha::Holds->find( $reserve_id );
     if ( $hold ) {
-        $hold->cancel;
+        my $cancellation_reason = $input->param('cancellation-reasion');
+        $hold->cancel({ cancellation_reason => $cancellation_reason });
         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 1510f81ed9..f09d8aae4c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt
@@ -149,10 +149,24 @@
             <form name="cancelReserve" action="/cgi-bin/koha/circ/pendingreserves.pl" method="post">
                 <input type="hidden" name="op" value="cancel_reserve" />
                 <input type="hidden" name="reserve_id" value="[% reserveloo.reserve_id | html %]" />
+
+                [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
+                [% IF hold_cancellation %]
+                    <div class="form-group">
+                        <label for="cancellation-reason">Cancellation reason</label>
+                        <select class="cancellation-reason" name="cancellation-reason" id="cancellation-reason">
+                            <option value="">No reason given</option>
+                            [% FOREACH reason IN hold_cancellation %]
+                                <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
+                            [% END %]
+                        </select>
+                    </div>
+                [% END %]
+
                 [% IF reserveloo.holdingbranch != reserveloo.homebranch %]
-                    <input type="submit" value="Cancel hold and return to : [% Branches.GetName( reserveloo.homebranch ) | html %]" />
+                    <input class="btn btn-default" type="submit" value="Cancel hold and return to : [% Branches.GetName( reserveloo.homebranch ) | html %]" />
                 [% ELSE %]
-                    <input type="submit" value="Cancel hold" />
+                    <input class="btn btn-default" type="submit" value="Cancel hold" />
                 [% END %]
             </form>
 
-- 
2.24.2 (Apple Git-127)