From 695a11468202612ad232e1568a83afc2ca80beda Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Thu, 3 Mar 2022 12:34:33 +0000
Subject: [PATCH] Bug 30213: Hide Delete (aka Priority) column when user only
 has place_hold permission

This patch changes the way the priority column displays when viewing a
list of holds as a user who doesn't have permission to change hold
priority.

To test:

- Apply the patch and log into the staff interface as a user with
  at least "place_hold" permission.
- Locate a record which can be put on hold and place multiple holds.
- View the list of holds.
- As a user with both "place_hold" and "modify_holds_priority"
  permission, you should see a "Priority" column with <select> fields
  allowing you to change hold priority. You should also see the arrow
  buttons for changing priority.
- As a user with only "place_hold" permission, the "Priority" column
  should show the priority as a number. You should not see the arrow
  buttons.
- In both cases, confirm that all operations work correctly: Changing
  hold date, expiration date, pickup library, suspended status;
  Cancelling holds.
---
 .../prog/en/includes/holds_table.inc          | 49 ++++++++++---------
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc
index fddaad03e3..ee2a3aee2a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc
@@ -4,11 +4,9 @@
 <table class="holds_table">
     <tr>
         <th><input type="checkbox" class="select_hold_all"/></th>
+        <th>Priority</th>
         [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
-            <th>Priority</th>
             <th>&nbsp;</th>
-        [% ELSE %]
-            <th>Delete?</th>
         [% END %]
         <th>Patron</th>
         <th>Notes</th>
@@ -55,30 +53,35 @@
                 <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" />
                 <input type="hidden" name="borrowernumber" value="[% hold.borrowernumber | html %]" />
                 <input type="hidden" name="biblionumber" value="[% hold.biblionumber | html %]" />
-                [% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %]
-                    <select name="rank-request" class="rank-request" data-hold-id="[% hold.reserve_id | html %]">
-                    [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
-                        [% PROCESS priority_dropdown %]
-                    [% ELSE %]
-                        <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
-                    [% END %]
-                        <option value="del">del</option>
-                    </select>
-                [% ELSE %]
-                    <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
-                    <select name="rank-request" class="rank-request" disabled="disabled" data-hold-id="[% hold.reserve_id | html %]">
-                    [% IF ( hold.found ) %]
-                        [% IF ( hold.intransit ) %]
-                            <option value="T" selected="selected">In transit</option>
-                        [% ELSIF (hold.inprocessing) %]
-                            <option value="P" selected="selected">In processing</option>
+                [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
+                    [% IF Koha.Preference('HoldsSplitQueue') == "nothing" && !hold.found %]
+                        <select name="rank-request" class="rank-request" data-hold-id="[% hold.reserve_id | html %]">
+                        [% IF ( CAN_user_reserveforothers_modify_holds_priority ) %]
+                            [% PROCESS priority_dropdown %]
                         [% ELSE %]
-                            <option value="W" selected="selected">Waiting</option>
+                            <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
                         [% END %]
+                            <option value="del">del</option>
+                        </select>
                     [% ELSE %]
-                        <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
+                        <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
+                        <select name="rank-request" class="rank-request" disabled="disabled" data-hold-id="[% hold.reserve_id | html %]">
+                        [% IF ( hold.found ) %]
+                            [% IF ( hold.intransit ) %]
+                                <option value="T" selected="selected">In transit</option>
+                            [% ELSIF (hold.inprocessing) %]
+                                <option value="P" selected="selected">In processing</option>
+                            [% ELSE %]
+                                <option value="W" selected="selected">Waiting</option>
+                            [% END %]
+                        [% ELSE %]
+                            <option value="[% hold.priority | html %]" selected="selected">[% this_priority | html %]</option>
+                        [% END %]
+                        </select>
                     [% END %]
-                    </select>
+                [% ELSE %]
+                    <input type="hidden" name="rank-request" class="rank-request" value="[% hold.priority | html %]" data-hold-id="[% hold.reserve_id | html %]">
+                    [% hold.priority | html %]
                 [% END %]
             </td>
             [%- IF ( CAN_user_reserveforothers_modify_holds_priority ) -%]
-- 
2.20.1