From d143496de3f242b9ce5716cebc7899b195bcb0e0 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Tue, 2 Jan 2024 20:11:28 +0000
Subject: [PATCH] Bug 35648: Allow sorting of patron categories in Overdue
 notice/status triggers

This patch adds a basic DataTables configuration to the table of patron
categories on the Overdue notice/status triggers page. The table can be
sorted by patron category and can be filtered.

To test, apply the patch and go to Tools -> Overdue notice/status
triggers.

- Confirm that the table of patron categories is sorted by default by
   patron category
- Other columns should not be sortable
- You should see a search field above the table which works to filter by
  patron category.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
---
 .../prog/en/modules/tools/overduerules.tt      | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt
index ccb1ae7465d..3cfd0939f7c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt
@@ -84,13 +84,13 @@
                         [% WRAPPER tab_panels %]
                             [% FOR tab IN tabs %]
                                 [% WRAPPER tab_panel tabname=tab.id %]
-                                    <table>
+                                    <table class="overduerulest" id="overduerulest-[% tab.id | html %]">
                                         <thead>
                                             <tr>
-                                            <th>&nbsp;</th>
-                                            <th scope="col">Delay</th>
-                                            <th scope="col">Letter</th>
-                                            <th scope="col">Restrict</th>
+                                            <th>Patron category</th>
+                                            <th class="NoSort" scope="col">Delay</th>
+                                            <th class="NoSort" scope="col">Letter</th>
+                                            <th class="NoSort" scope="col">Restrict</th>
                                                 [% FOREACH mtt IN message_transport_types %]
                                                     [% NEXT IF mtt == 'itiva' AND !Koha.Preference('TalkingTechItivaPhoneNotification') %]
                                                     [% NEXT IF mtt == 'phone' AND !Koha.Preference('PhoneNotification') %]
@@ -177,6 +177,7 @@
 
 [% MACRO jsinclude BLOCK %]
     [% Asset.js("js/tools-menu.js") | $raw %]
+    [% INCLUDE 'datatables.inc' %]
     <script>
         var tab_map = { "0" : _("First"), "1" : _("Second"), "2" : _("Third")};
         $(document).ready(function() {
@@ -190,6 +191,13 @@
             if( $("#rulestabs .tab-pane.active").length < 1 ){
                 $("#rulestabs a:first").tab("show");
             }
+            $(".overduerulest").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "aoColumnDefs": [
+                    { "targets": [ "NoSort" ], "orderable": false, "searchable": false },
+                ],
+                "dom": '<"top pager"f>rt<"clear">',
+                "paginate": false,
+            }));
         });
     </script>
 [% END %]
-- 
2.30.2