Bug 19216: Fix broken table in OPAC for when club doesn't allow public enrolment
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / clubs / clubs-tab.tt
blob0b8fcaaaecfb17a1cab17d5ec8824b6b9899820d
1 [% USE KohaDates %]
3 [% IF enrollments %]
5     <h4>Clubs currently enrolled in</h4>
7     <table id="clubs-table-enrolled" class="table table-bordered table-striped">
8         <thead>
9             <tr>
10                 <th>Name</th>
11                 <th>Description</th>
12                 <th>Date enrolled</th>
13                 <th>&nbsp;</th>
14             </tr>
15         </thead>
17         <tbody>
18             [% FOREACH e IN enrollments %]
19                 <tr>
20                     <td>[% e.club.name %]</td>
21                     <td>[% e.club.description %]</td>
22                     <td>[% e.date_enrolled | $KohaDates %]</td>
23                     <td>
24                         [% IF e.club.club_template.is_enrollable_from_opac %]
25                             <button class="btn btn-xs btn-default" onclick="cancelEnrollment( [% e.id %] )">
26                                 <i class="icon-remove"></i> Cancel enrollment
27                             </button>
28                         [% ELSE %]
29                             Contact your library to be disenrolled from this club.
30                         [% END %]
31                     </td>
32                 </tr>
33             [% END %]
34         </tbody>
35     </table>
36 [% END %]
38 [% IF clubs %]
40     <h4>Clubs you can enroll in</h4>
42     <table id="clubs-table-unenrolled" class="table table-bordered table-striped">
43         <thead>
44             <tr>
45                 <th>Name</th>
46                 <th>Description</th>
47                 <th>&nbsp;</th>
48             </tr>
49         </thead>
51         <tbody>
52             [% FOREACH c IN clubs %]
53                 <tr>
54                     <td>[% c.name %]</td>
55                     <td>[% c.description %]</td>
56                     <td>
57                         [% IF !c.club_template.is_email_required || ( c.club_template.is_email_required && borrower.first_valid_email_address ) %]
58                             <button class="btn btn-xs btn-default" onclick="loadEnrollmentForm([% c.id %])">
59                                 <i class="icon-plus"></i> Enroll
60                             </button>
61                         [% ELSE %]
62                             <span class="hint">You must have an email address to enroll</span>
63                         [% END %]
64                     </td>
65                 </tr>
66             [% END %]
67         </tbody>
68     </table>
69 [% END %]
71 <script type="text/javascript">
72 function loadEnrollmentForm( id ) {
73     $("body").css("cursor", "progress");
74     $('#opac-user-clubs').load('/cgi-bin/koha/clubs/enroll.pl?borrowernumber=[% borrower.borrowernumber %]&id=' + id, function() {
75         $("body").css("cursor", "default");
76     });
78     return false;
81 function cancelEnrollment( id ) {
82     $("body").css("cursor", "progress");
83     $.ajax({
84         type: "POST",
85         url: '/cgi-bin/koha/svc/club/cancel_enrollment',
86         data: { id: id },
87         success: function( data ) {
88             if ( data.success ) {
89                 $('#opac-user-clubs').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrower.borrowernumber %]', function() {
90                     $("body").css("cursor", "default");
91                 });
92             } else {
93                 alert(_("Unable to cancel enrollment!"));
94             }
95         },
96         dataType: 'json'
97     });
98     return false;
100 </script>