From d620356fa17a228f687182bd7f41ba1c40a17fdc Mon Sep 17 00:00:00 2001
From: Lucas Gass <lucas@bywatersolutions.com>
Date: Thu, 25 Mar 2021 17:58:04 +0000
Subject: [PATCH] Bug 28034: Make club enrollment tables in to DataTables

To test:
-Add some clubs
-Go to a patron record and enroll them in some clubs but not in others.
-There should be two table under the clubs tab, Clubs currently enrolled in and Clubs not enrolled in
-Neither are DataTables
-Apply patch
-With the same patron check the clubs tab, they should be datatables now
-Make sure all the controls, pagination works good

https://bugs.koha-community.org/show_bug.cgi?id=28033
---
 .../prog/en/modules/clubs/patron-clubs-tab.tt           | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt
index b77ab78a2d..ddfe228327 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt
@@ -3,13 +3,13 @@
 [% IF enrollments %]
     <h4>Clubs currently enrolled in</h4>
 
-    <table>
+    <table id="table_clubenrollments">
         <thead>
             <tr>
                 <th>Name</th>
                 <th>Description</th>
                 <th>Date enrolled</th>
-                [% IF CAN_user_clubs_enroll %]<th>&nbsp;</th>[% END %]
+                [% IF CAN_user_clubs_enroll %]<th class="NoSort">Actions</th>[% END %]
             </tr>
         </thead>
 
@@ -36,12 +36,12 @@
 
     <h4>Clubs not enrolled in</h4>
 
-    <table>
+    <table id="table_clubnoenrollmemnts">
         <thead>
             <tr>
                 <th>Name</th>
                 <th>Description</th>
-                [% IF CAN_user_clubs_enroll %]<th>&nbsp;</th>[% END %]
+                [% IF CAN_user_clubs_enroll %]<th class="NoSort">Actions</th>[% END %]
             </tr>
         </thead>
 
@@ -63,8 +63,15 @@
     </table>
 [% END %]
 
-[% IF CAN_user_clubs_enroll %]
 <script>
+$("#table_clubnoenrollmemnts, #table_clubenrollments").dataTable($.extend(true, {}, dataTablesDefaults, {
+    "columnDefs": [
+        { 'sortable': false, 'targets': [ 'NoSort' ] }
+    ],
+    paginate: true
+}));
+
+[% IF CAN_user_clubs_enroll %]
 function loadEnrollmentForm( id ) {
     $("body").css("cursor", "progress");
     $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber | html %]&id=' + id, function() {
-- 
2.11.0