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