Bug 13618: Add html filters to all the variables
[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 id="doc3" class="yui-t2">
20    <div id="bd">
21         <div id="yui-main">
22             <div class="yui-b">
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 | html %]">[% 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 | html %]">
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 | html %]">
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 | html %]">
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             </div> <!-- /.yui-b -->
218         </div> <!-- /.yui-main -->
219         <div class="yui-b noprint">
220             [% INCLUDE 'tools-menu.inc' %]
221         </div>
222     </div> <!-- /#bd -->
223
224 [% MACRO jsinclude BLOCK %]
225     [% INCLUDE 'datatables.inc' %]
226     [% Asset.js("js/tools-menu.js") | $raw %]
227     <script type="text/javascript">
228         $(document).ready(function() {
229             tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, {
230                 "sPaginationType": "four_button",
231                 "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
232                 "aoColumnDefs": [
233                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
234                 ]
235             } ));
236
237             cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
238                 "sPaginationType": "four_button",
239                 "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
240                 "aoColumnDefs": [
241                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
242                 ]
243             } ));
244         });
245
246         function ConfirmDeleteTemplate( id, name, a ) {
247             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) ) ) {
248                 $.ajax({
249                     type: "POST",
250                     url: '/cgi-bin/koha/svc/club/template/delete',
251                     data: { id: id },
252                     success: function( data ) {
253                         if ( data.success ) {
254                             location.reload();
255                         } else {
256                             alert(_("Unable to delete template!"));
257                         }
258                     },
259                     dataType: 'json'
260                 });
261             }
262         }
263
264         function ConfirmDeleteClub( id, name, a ) {
265             if ( confirm( _("Are you sure you want to delete the club %s? This will cancel all patron enrollments in this club." ).format(name) ) ) {
266                 $.ajax({
267                     type: "POST",
268                     url: '/cgi-bin/koha/svc/club/delete',
269                     data: { id: id },
270                     success: function( data ) {
271                         if ( data.success ) {
272                             location.reload();
273                         } else {
274                             alert(_("Unable to delete club!"));
275                         }
276                     },
277                     dataType: 'json'
278                 });
279             }
280         }
281     </script>
282 [% END %]
283
284 [% INCLUDE 'intranet-bottom.inc' %]