Bug 12461 - Add patron clubs feature
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / clubs / clubs.tt
1 [% USE Branches %]
2 [% USE Koha %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Tools &rsaquo; Patron clubs</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6
7 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
8 [% INCLUDE 'datatables.inc' %]
9
10 <script type="text/javascript">
11 //<![CDATA[
12     $(document).ready(function() {
13         tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, {
14             "sPaginationType": "four_button",
15             "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
16             "aoColumnDefs": [
17                     { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
18             ]
19         } ));
20
21         cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
22             "sPaginationType": "four_button",
23             "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
24             "aoColumnDefs": [
25                     { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
26             ]
27         } ));
28     });
29
30     function ConfirmDeleteTemplate( id, name, a ) {
31         if ( confirm( _("Are you sure you want to delete the club template %s?" ).format(name) ) ) {
32             $.ajax({
33                 type: "POST",
34                 url: '/cgi-bin/koha/svc/club/template/delete',
35                 data: { id: id },
36                 success: function( data ) {
37                     if ( data.success ) {
38                         tTable.fnDeleteRow(a.closest("tr")[0]);
39                     } else {
40                         alert(_("Unable to delete template!"));
41                     }
42                 },
43                 dataType: 'json'
44             });
45         }
46     }
47
48     function ConfirmDeleteClub( id, name, a ) {
49         if ( confirm( _("Are you sure you want to delete the club %s?" ).format(name) ) ) {
50             $.ajax({
51                 type: "POST",
52                 url: '/cgi-bin/koha/svc/club/delete',
53                 data: { id: id },
54                 success: function( data ) {
55                     if ( data.success ) {
56                         cTable.fnDeleteRow(a.closest("tr")[0]);
57                     } else {
58                         alert(_("Unable to delete club!"));
59                     }
60                 },
61                 dataType: 'json'
62             });
63         }
64     }
65 //]]>
66 </script>
67
68 </head>
69
70 <body id="clubs_clubs" class="clubs">
71 [% INCLUDE 'header.inc' %]
72 [% INCLUDE 'cat-search.inc' %]
73 <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>
74
75 <div id="doc3" class="yui-t2">
76    <div id="bd">
77         <div id="yui-main">
78             <div class="yui-b">
79                 <h1>Patron clubs</h1>
80
81                 [% IF club_template %]
82                     <div class="dialog message">
83                         [% IF stored == 'updated' %]
84                             <p>Club template <i>[% club_template.name %]</i> was updated.</p>
85                         [% ELSE %]
86                             <p>Club template <i>[% club_template.name %]</i> was saved.</p>
87                         [% END %]
88                     </div>
89                 [% ELSIF club %]
90                     <div class="dialog message">
91                         [% IF stored == 'updated' %]
92                             <p>Club <i>[% club.name %]</i> was updated.</p>
93                         [% ELSE %]
94                             <p>Club <i>[% club.name %]</i> was saved.</p>
95                         [% END %]
96                     </div>
97                 [% END %]
98
99                 <h3>Club templates</h3>
100
101                 [% IF CAN_user_clubs_edit_templates %]
102                     <div class="btn-toolbar">
103                         <div class="btn-group">
104                             <a class="btn btn-default" href="templates-add-modify.pl"><i class="fa fa-plus"></i> New club template</a>
105                         </div>
106                     </div>
107                 [% END %]
108
109                 <table id="club-templates-table">
110                     <thead>
111                         <tr>
112                             <th>Name</th>
113                             <th>Description</th>
114                             <th>Public enrollment</th>
115                             <th>Email required</th>
116                             <th>Library</th>
117                             <th>&nbsp;</th>
118                             <th>&nbsp;</th>
119                         </tr>
120                     </thead>
121
122                     <tbody>
123                         [% IF club_templates %]
124                             [% FOREACH t IN club_templates %]
125                                 <tr>
126                                     <td>[% t.name %]</td>
127                                     <td>[% t.description %]</td>
128                                     <td>
129                                         [% IF t.is_enrollable_from_opac %]
130                                             Yes
131                                         [% ELSE %]
132                                             No
133                                         [% END %]
134                                     </td>
135                                     <td>
136                                         [% IF t.is_email_required %]
137                                             Yes
138                                         [% ELSE %]
139                                             No
140                                         [% END %]
141                                     </td>
142                                     <td>[% Branches.GetName( t.branchcode ) %]</td>
143                                     <td>
144                                         [% IF CAN_user_clubs_edit_templates %]
145                                             <a class="btn btn-default" style="white-space:nowrap"  href="templates-add-modify.pl?id=[% t.id %]">
146                                                 <i class="fa fa-edit"></i> Edit
147                                             </a>
148                                         [% END %]
149                                     </td>
150                                     <td>
151                                         [% IF CAN_user_clubs_edit_templates %]
152                                             <a class="btn btn-default" href="#" onclick='ConfirmDeleteTemplate([% t.id %], "[% t.name | html %]", $(this) ); return false;'>
153                                                 <i class="fa fa-trash"></i> Delete
154                                             </a>
155                                         [% END %]
156                                     </td>
157                                 </tr>
158                             [% END %]
159                         [% ELSE %]
160                             <tr>
161                                 <td colspan="7">
162                                     No club templates defined.
163                                 </td>
164                             </td>
165                         [% END %]
166                     </tbody>
167                 </table>
168
169                 <h3>Clubs</h3>
170
171                 [% IF CAN_user_clubs_edit_clubs %]
172                     <div class="btn-toolbar">
173                         <div class="btn-group">
174                             <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button>
175                             <ul class="dropdown-menu">
176                                 [% FOREACH t IN club_templates %]
177                                     <li><a href="/cgi-bin/koha/clubs/clubs-add-modify.pl?club_template_id=[% t.id %]">[% t.name %]</a></li>
178                                 [% END %]
179                             </ul>
180                         </div>
181                     </div>
182                 [% END %]
183
184                 <table id="clubs-table">
185                     <thead>
186                         <tr>
187                             <th>Name</th>
188                             <th>Template</th>
189                             <th>Description</th>
190                             <th>Public enrollment</th>
191                             <th>Email required</th>
192                             <th>Library</th>
193                             <th>&nbsp;</th>
194                             <th>&nbsp;</th>
195                         </tr>
196                     </thead>
197
198                     <tbody>
199                         [% IF clubs %]
200                             [% FOREACH c IN clubs %]
201                                 <tr>
202                                     <td>[% c.name %]</td>
203                                     <td>[% c.club_template.name %]</td>
204                                     <td>[% c.description %]</td>
205                                     <td>
206                                         [% IF c.club_template.is_enrollable_from_opac %]
207                                             Yes
208                                         [% ELSE %]
209                                             No
210                                         [% END %]
211                                     </td>
212                                     <td>
213                                         [% IF c.club_template.is_email_required %]
214                                             Yes
215                                         [% ELSE %]
216                                             No
217                                         [% END %]
218                                     </td>
219                                     <td>[% Branches.GetName( c.branchcode ) %]</td>
220                                     <td>
221                                         [% IF CAN_user_clubs_edit_clubs %]
222                                             <a class="btn btn-default" style="white-space:nowrap" href="clubs-add-modify.pl?id=[% c.id %]">
223                                                 <i class="fa fa-edit"></i> Edit
224                                             </a>
225                                         [% END %]
226                                     </td>
227                                     <td>
228                                         [% IF CAN_user_clubs_edit_clubs %]
229                                             <a class="btn btn-default" href="#" onclick='ConfirmDeleteClub([% c.id %], "[% c.name | html %]", $(this) ); return false;'>
230                                                 <i class="fa fa-trash"></i> Delete
231                                             </a>
232                                         [% END %]
233                                     </td>
234                                 </tr>
235                             [% END %]
236                         [% ELSE %]
237                             <tr>
238                                 <td colspan="8">
239                                     No club templates defined.
240                                 </td>
241                             </td>
242                         [% END %]
243                     </tbody>
244                 </table>
245             </div>
246         </div>
247         <div class="yui-b noprint">
248             [% INCLUDE 'tools-menu.inc' %]
249         </div>
250     </div>
251 </div>
252 [% INCLUDE 'intranet-bottom.inc' %]