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