Bug 21467: (QA follow-up) Fix filter and variable declaration in .t
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / clubs / clubs.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE Branches %]
5 [% USE Koha %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Tools &rsaquo; Patron clubs</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10
11 [% Asset.css("css/datatables.css") | $raw %]
12 </head>
13
14 <body id="clubs_clubs" class="clubs">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'cat-search.inc' %]
17 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Patron clubs</div>
18
19 <div class="main container-fluid">
20     <div class="row">
21         <div class="col-sm-10 col-sm-push-2">
22             <main>
23
24                 <h1>Patron clubs</h1>
25
26                 [% IF club_template %]
27                     <div class="dialog message">
28                         [% IF stored == 'updated' %]
29                             <p>Club template <i>[% club_template.name | html %]</i> was updated.</p>
30                         [% ELSE %]
31                             <p>Club template <i>[% club_template.name | html %]</i> was saved.</p>
32                         [% END %]
33                     </div>
34                 [% ELSIF club %]
35                     <div class="dialog message">
36                         [% IF stored == 'updated' %]
37                             <p>Club <i>[% club.name | html %]</i> was updated.</p>
38                         [% ELSE %]
39                             <p>Club <i>[% club.name | html %]</i> was saved.</p>
40                         [% END %]
41                     </div>
42                 [% END %]
43
44                 <h3>Club templates</h3>
45
46                 [% IF CAN_user_clubs_edit_templates %]
47                     <div class="btn-toolbar">
48                         <div class="btn-group">
49                             <a class="btn btn-sm btn-default" href="templates-add-modify.pl"><i class="fa fa-plus"></i> New club template</a>
50                         </div>
51                     </div>
52                 [% END %]
53
54                 [% IF club_templates %]
55                     <table id="club-templates-table">
56                         <thead>
57                             <tr>
58                                 <th>Name</th>
59                                 <th>Description</th>
60                                 <th>Public enrollment</th>
61                                 <th>Email required</th>
62                                 <th>Library</th>
63                                 <th>Actions</th>
64                             </tr>
65                         </thead>
66                         <tbody>
67                             [% FOREACH t IN club_templates %]
68                                 <tr>
69                                     <td>[% t.name | html %]</td>
70                                     <td>[% t.description | html %]</td>
71                                     <td>
72                                         [% IF t.is_enrollable_from_opac %]
73                                             Yes
74                                         [% ELSE %]
75                                             No
76                                         [% END %]
77                                     </td>
78                                     <td>
79                                         [% IF t.is_email_required %]
80                                             Yes
81                                         [% ELSE %]
82                                             No
83                                         [% END %]
84                                     </td>
85                                     <td>[% Branches.GetName( t.branchcode ) | html %]</td>
86                                     <td class="actions">
87                                         [% IF CAN_user_clubs_edit_templates %]
88                                             <a class="btn btn-xs btn-default" style="white-space:nowrap"  href="/cgi-bin/koha/clubs/templates-add-modify.pl?id=[% t.id | html %]">
89                                                 <i class="fa fa-pencil"></i> Edit
90                                             </a>
91                                             <a class="btn btn-xs btn-default" href="#" onclick='ConfirmDeleteTemplate([% t.id | html %], "[% t.name | html %]", $(this) ); return false;'>
92                                                 <i class="fa fa-trash"></i> Delete
93                                             </a>
94                                         [% END %]
95                                     </td>
96                                 </tr>
97                             [% END %]
98                         </tbody>
99                     </table>
100                 [% ELSE %]
101                     <div class="dialog message">No club templates defined.</div>
102                 [% END %]
103
104                 <h3>Clubs</h3>
105
106                 [% IF CAN_user_clubs_edit_clubs %]
107                     <div class="btn-toolbar">
108                         <div class="btn-group">
109                             [% IF club_templates %]
110                                 <button class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button>
111                             [% ELSE %]
112                                 <button disabled="disabled" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button>
113                             [% END %]
114                             <ul class="dropdown-menu">
115                                 [% FOREACH t IN club_templates %]
116                                     <li><a href="/cgi-bin/koha/clubs/clubs-add-modify.pl?club_template_id=[% t.id | uri %]">[% t.name | html %]</a></li>
117                                 [% END %]
118                             </ul>
119                         </div>
120                     </div>
121                 [% END %]
122
123                 [% IF clubs %]
124                     <table id="clubs-table">
125                         <thead>
126                             <tr>
127                                 <th>Name</th>
128                                 <th>Template</th>
129                                 <th>Description</th>
130                                 <th>Public enrollment</th>
131                                 <th>Email required</th>
132                                 <th>Library</th>
133                                 <th>Start date</th>
134                                 <th>End date</th>
135                                 <th>Enrolled patrons</th>
136                                 <th>&nbsp;</th>
137                             </tr>
138                         </thead>
139                         <tbody>
140                             [% FOREACH c IN clubs %]
141                                 <tr>
142                                     <td>[% c.name | html %]</td>
143                                     <td>[% c.club_template.name | html %]</td>
144                                     <td>[% c.description | html %]</td>
145                                     <td>
146                                         [% IF c.club_template.is_enrollable_from_opac %]
147                                             Yes
148                                         [% ELSE %]
149                                             No
150                                         [% END %]
151                                     </td>
152                                     <td>
153                                         [% IF c.club_template.is_email_required %]
154                                             Yes
155                                         [% ELSE %]
156                                             No
157                                         [% END %]
158                                     </td>
159                                     <td>[% Branches.GetName( c.branchcode ) | html %]</td>
160                                     <td>
161                                         [% IF c.date_start %]
162                                             [% c.date_start | $KohaDates %]
163                                         [% END %]
164                                     </td>
165                                     <td>
166                                         [% IF c.date_end %]
167                                             [% c.date_end | $KohaDates %]
168                                         [% END %]
169                                     </td>
170                                     <td>
171                                         [% c.club_enrollments.count | html %]
172                                     </td>
173                                     <td class="actions">
174                                         <div class="dropdown">
175                                             <a class="btn btn-default btn-xs dropdown-toggle" id="clubactions[% c.id | html %]" role="button" data-toggle="dropdown" href="#">
176                                                 Actions <b class="caret"></b>
177                                             </a>
178                                             <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="clubactions[% c.id | html %]">
179                                                 [% IF ( c.club_enrollments.count ) %]
180                                                     <li>
181                                                         <a href="club-enrollments.pl?id=[% c.id | uri %]">
182                                                             <i class="fa fa-list-ul"></i> Enrollments
183                                                         </a>
184                                                     </li>
185                                                 [% ELSE %]
186                                                     <li class="disabled">
187                                                         <a href="club-enrollments.pl?id=[% c.id | uri %]">
188                                                             <i class="fa fa-list-ul"></i> Enrollments
189                                                         </a>
190                                                     </li>
191                                                 [% END %]
192                                                 [% IF CAN_user_clubs_edit_clubs %]
193                                                     <li>
194                                                         <a href="clubs-add-modify.pl?id=[% c.id | uri %]">
195                                                             <i class="fa fa-pencil"></i> Edit
196                                                         </a>
197                                                     </li>
198                                                     <li>
199                                                         <a href="#" onclick='ConfirmDeleteClub([% c.id | html %], "[% c.name | html %]", $(this) ); return false;'>
200                                                             <i class="fa fa-trash"></i> Delete
201                                                         </a>
202                                                     </li>
203                                                 [% END %]
204                                             </ul>
205                                         </div>
206                                     </td>
207                                 </tr>
208                             [% END %]
209                         </tbody>
210                     </table> <!-- /.clubs-table -->
211                 [% ELSE %]
212                     [% IF club_templates %]
213                         <div class="dialog message">No clubs defined.</div>
214                     [% ELSE %]
215                         <div class="dialog message">No clubs defined. A club template must be defined before a club can be defined.</div>
216                     [% END %]
217                 [% END %]
218
219             </main>
220         </div> <!-- /.col-sm-10.col-sm-push-2 -->
221
222         <div class="col-sm-2 col-sm-pull-10">
223             <aside>
224                 [% INCLUDE 'tools-menu.inc' %]
225             </aside>
226         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
227      </div> <!-- /.row -->
228
229 [% MACRO jsinclude BLOCK %]
230     [% INCLUDE 'datatables.inc' %]
231     [% Asset.js("js/tools-menu.js") | $raw %]
232     <script>
233         $(document).ready(function() {
234             tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, {
235                 "sPaginationType": "four_button",
236                 "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
237                 "aoColumnDefs": [
238                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
239                 ]
240             } ));
241
242             cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
243                 "sPaginationType": "four_button",
244                 "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
245                 "aoColumnDefs": [
246                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
247                 ]
248             } ));
249         });
250
251         function ConfirmDeleteTemplate( id, name, a ) {
252             if ( confirm( _("Are you sure you want to delete the club template %s? This will delete all clubs using this template and cancel patron enrollments" ).format(name) ) ) {
253                 $.ajax({
254                     type: "POST",
255                     url: '/cgi-bin/koha/svc/club/template/delete',
256                     data: { id: id },
257                     success: function( data ) {
258                         if ( data.success ) {
259                             location.reload();
260                         } else {
261                             alert(_("Unable to delete template!"));
262                         }
263                     },
264                     dataType: 'json'
265                 });
266             }
267         }
268
269         function ConfirmDeleteClub( id, name, a ) {
270             if ( confirm( _("Are you sure you want to delete the club %s? This will cancel all patron enrollments in this club." ).format(name) ) ) {
271                 $.ajax({
272                     type: "POST",
273                     url: '/cgi-bin/koha/svc/club/delete',
274                     data: { id: id },
275                     success: function( data ) {
276                         if ( data.success ) {
277                             location.reload();
278                         } else {
279                             alert(_("Unable to delete club!"));
280                         }
281                     },
282                     dataType: 'json'
283                 });
284             }
285         }
286     </script>
287 [% END %]
288
289 [% INCLUDE 'intranet-bottom.inc' %]