Bug 34571: Remove use of "onclick" for ExpandField in cataloguing editors
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / clubs / patron-clubs-tab.tt
1 [% USE KohaDates %]
2
3 [% IF enrollments %]
4     <h4>Clubs currently enrolled in</h4>
5
6     <table id="table_clubenrollments">
7         <thead>
8             <tr>
9                 <th>Name</th>
10                 <th>Description</th>
11                 <th>Date enrolled</th>
12                 [% IF CAN_user_clubs_enroll %]<th class="NoSort">Actions</th>[% END %]
13             </tr>
14         </thead>
15
16         <tbody>
17             [% FOREACH e IN enrollments %]
18                 <tr>
19                     <td>[% e.club.name | html %]</td>
20                     <td>[% e.club.description | html %]</td>
21                     <td>[% e.date_enrolled | $KohaDates %]</td>
22                     [% IF CAN_user_clubs_enroll %]
23                         <td>
24                             <button class="btn btn-xs btn-default" onclick="loadEnrollmentForm([% e.club.id | html %],[% e.id | html %])">
25                                 <i class="fa-solid fa-pencil"></i> Modify enrollment
26                             </button>
27                             <button class="btn btn-xs btn-default" onclick="cancelEnrollment( [% e.id | html %] )">
28                                 <i class="fa fa-times"></i> Cancel enrollment
29                             </button>
30                         </td>
31                     [% END %]
32                 </tr>
33             [% END %]
34         </tbody>
35     </table>
36 [% END %]
37
38 [% IF clubs %]
39
40     <h4>Clubs not enrolled in</h4>
41
42     <table id="table_clubnoenrollmemnts">
43         <thead>
44             <tr>
45                 <th>Name</th>
46                 <th>Description</th>
47                 [% IF CAN_user_clubs_enroll %]<th class="NoSort">Actions</th>[% END %]
48             </tr>
49         </thead>
50
51         <tbody>
52             [% FOREACH c IN clubs %]
53                 <tr>
54                     <td>[% c.name | html %]</td>
55                     <td>[% c.description | html %]</td>
56                     [% IF CAN_user_clubs_enroll %]
57                         <td class="action">
58                             <button class="btn btn-xs btn-default" onclick="loadEnrollmentForm([% c.id | html %])">
59                                 <i class="fa fa-plus"></i> Enroll
60                             </button>
61                         </td>
62                     [% END %]
63                 </tr>
64             [% END %]
65         </tbody>
66     </table>
67 [% END %]
68
69 <script>
70 $("#table_clubnoenrollmemnts, #table_clubenrollments").dataTable($.extend(true, {}, dataTablesDefaults, {
71     "columnDefs": [
72         { 'sortable': false, 'targets': [ 'NoSort' ] }
73     ],
74     paginate: true
75 }));
76
77 [% IF CAN_user_clubs_enroll %]
78 function loadEnrollmentForm( id, enrollent_id = 0 ) {
79     $("body").css("cursor", "progress");
80     $('#clubs_panel').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber | html %]&id=' + id +'&enrollent_id='+ enrollent_id, function() {
81         $("body").css("cursor", "default");
82     });
83
84     return false;
85 }
86
87 function cancelEnrollment( id ) {
88     $("body").css("cursor", "progress");
89     $.ajax({
90         type: "POST",
91         url: '/cgi-bin/koha/svc/club/cancel_enrollment',
92         data: { id: id },
93         success: function( data ) {
94             if ( data.success ) {
95                 $('#clubs_panel').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber | html %]', function() {
96                     $("body").css("cursor", "default");
97                 });
98             } else {
99                 alert(_("Unable to cancel enrollment!"));
100             }
101         },
102         dataType: 'json'
103     });
104     return false;
105 }
106 </script>
107 [% END %]