Bug 34913: DataTables upgrade: Update CSS and option names
[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 [% PROCESS 'i18n.inc' %]
7 [% SET footerjs = 1 %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>[% FILTER collapse %]
10     [% t("Patron clubs") | html %] &rsaquo;
11     [% t("Tools") | html %] &rsaquo;
12     [% t("Koha") | html %]
13 [% END %]</title>
14 [% INCLUDE 'doc-head-close.inc' %]
15
16 </head>
17
18 <body id="clubs_clubs" class="clubs">
19 [% WRAPPER 'header.inc' %]
20     [% INCLUDE 'cat-search.inc' %]
21 [% END %]
22
23 [% WRAPPER 'sub-header.inc' %]
24     [% WRAPPER breadcrumbs %]
25         [% WRAPPER breadcrumb_item %]
26             <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
27         [% END %]
28         [% WRAPPER breadcrumb_item bc_active= 1 %]
29             <span>Patron clubs</span>
30         [% END %]
31     [% END #/ WRAPPER breadcrumbs %]
32 [% END #/ WRAPPER sub-header.inc %]
33
34 <div class="main container-fluid">
35     <div class="row">
36         <div class="col-sm-10 col-sm-push-2">
37             <main>
38
39                 <h1>Patron clubs</h1>
40
41                 [% IF club_template %]
42                     <div class="dialog message">
43                         [% IF stored == 'updated' %]
44                             <p>Club template <em>[% club_template.name | html %]</em> was updated.</p>
45                         [% ELSE %]
46                             <p>Club template <em>[% club_template.name | html %]</em> was saved.</p>
47                         [% END %]
48                     </div>
49                 [% ELSIF club %]
50                     <div class="dialog message">
51                         [% IF stored == 'updated' %]
52                             <p>Club <em>[% club.name | html %]</em> was updated.</p>
53                         [% ELSE %]
54                             <p>Club <em>[% club.name | html %]</em> was saved.</p>
55                         [% END %]
56                     </div>
57                 [% END %]
58
59                 <h3>Club templates</h3>
60
61                 [% IF CAN_user_clubs_edit_templates %]
62                     <div class="btn-toolbar">
63                         <div class="btn-group">
64                             <a class="btn btn-default" href="templates-add-modify.pl"><i class="fa fa-plus"></i> New club template</a>
65                         </div>
66                     </div>
67                 [% END %]
68
69                 [% IF club_templates.count %]
70                     <div class="page-section">
71                         <table id="club-templates-table">
72                             <thead>
73                                 <tr>
74                                     <th>Name</th>
75                                     <th>Description</th>
76                                     <th>Public enrollment</th>
77                                     <th>Email required</th>
78                                     <th>Library</th>
79                                     <th class="noExport">Actions</th>
80                                 </tr>
81                             </thead>
82                             <tbody>
83                                 [% FOREACH t IN club_templates %]
84                                     <tr>
85                                         <td>[% t.name | html %]</td>
86                                         <td>[% t.description | html %]</td>
87                                         <td>
88                                             [% IF t.is_enrollable_from_opac %]
89                                                 <span>Yes</span>
90                                             [% ELSE %]
91                                                 <span>No</span>
92                                             [% END %]
93                                         </td>
94                                         <td>
95                                             [% IF t.is_email_required %]
96                                                 <span>Yes</span>
97                                             [% ELSE %]
98                                                 <span>No</span>
99                                             [% END %]
100                                         </td>
101                                         <td>[% Branches.GetName( t.branchcode ) | html %]</td>
102                                         <td class="actions">
103                                             [% IF CAN_user_clubs_edit_templates %]
104                                                 <a class="btn btn-xs btn-default" style="white-space:nowrap"  href="/cgi-bin/koha/clubs/templates-add-modify.pl?id=[% t.id | html %]">
105                                                     <i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit
106                                                 </a>
107                                                 <a class="btn btn-xs btn-default delete_template" href="#" data-id="[% t.id | html %]" data-name="[% t.name | html %]">
108                                                     <i class="fa fa-trash-can"></i> Delete
109                                                 </a>
110                                             [% END %]
111                                         </td>
112                                     </tr>
113                                 [% END %]
114                             </tbody>
115                         </table>
116                     </div> <!-- /.page-section -->
117                 [% ELSE %]
118                     <div class="dialog message">No club templates defined.</div>
119                 [% END %]
120
121                 <h3>Clubs</h3>
122
123                 [% IF CAN_user_clubs_edit_clubs %]
124                     <div class="btn-toolbar">
125                         <div class="btn-group">
126                             [% IF club_templates.count %]
127                                 <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button>
128                             [% ELSE %]
129                                 <button disabled="disabled" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> New club <span class="caret"></span></button>
130                             [% END %]
131                             <ul class="dropdown-menu">
132                                 [% FOREACH t IN club_templates %]
133                                     <li><a href="/cgi-bin/koha/clubs/clubs-add-modify.pl?club_template_id=[% t.id | uri %]">[% t.name | html %]</a></li>
134                                 [% END %]
135                             </ul>
136                         </div>
137                     </div>
138                 [% END %]
139
140                 [% IF clubs.count %]
141                     <div class="page-section">
142                         [% INCLUDE 'clubs-table.inc' %]
143                     </div> <!-- /.page-section -->
144                 [% ELSE %]
145                     [% IF club_templates.count %]
146                         <div class="dialog message">No clubs defined.</div>
147                     [% ELSE %]
148                         <div class="dialog message">No clubs defined. A club template must be defined before a club can be defined.</div>
149                     [% END %]
150                 [% END %]
151
152             </main>
153         </div> <!-- /.col-sm-10.col-sm-push-2 -->
154
155         <div class="col-sm-2 col-sm-pull-10">
156             <aside>
157                 [% INCLUDE 'tools-menu.inc' %]
158             </aside>
159         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
160      </div> <!-- /.row -->
161
162 [% MACRO jsinclude BLOCK %]
163     [% INCLUDE 'datatables.inc' %]
164     [% Asset.js("js/tools-menu.js") | $raw %]
165     <script>
166         $(document).ready(function() {
167             tTable = $('#club-templates-table').dataTable($.extend(true, {}, dataTablesDefaults, {
168                 "pagingType": "full",
169                 "dom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
170                 "columnDefs": [
171                     { "targets": [ -1 ], "orderable": false, "searchable":  false },
172                 ]
173             } ));
174
175             cTable = $('#clubs-table').dataTable($.extend(true, {}, dataTablesDefaults, {
176                 "pagingType": "full",
177                 "dom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
178                 "columnDefs": [
179                     { "targets": [ -1 ], "orderable": false, "searchable":  false },
180                 ]
181             } ));
182
183             $("body").on("click", ".delete_club", function(e){
184                 e.preventDefault();
185                 var club_id = $(this).data("id");
186                 var club_name = $(this).data("name");
187                 ConfirmDeleteClub( club_id, club_name );
188             });
189
190             $("body").on("click", ".delete_template", function(e){
191                 e.preventDefault();
192                 var template_id = $(this).data("id");
193                 var template_name = $(this).data("name");
194                 ConfirmDeleteTemplate( template_id, template_name );
195             });
196
197             $("body").on("click", ".club_hold_search", function(e){
198                 e.preventDefault;
199                 var club_id = $(this).data("id");
200                 SearchToHold( club_id );
201             });
202         });
203
204         function ConfirmDeleteTemplate( id, name ) {
205             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) ) ) {
206                 $.ajax({
207                     type: "POST",
208                     url: '/cgi-bin/koha/svc/club/template/delete',
209                     data: { id: id },
210                     success: function( data ) {
211                         if ( data.success ) {
212                             location.reload();
213                         } else {
214                             alert(_("Unable to delete template!"));
215                         }
216                     },
217                     dataType: 'json'
218                 });
219             }
220         }
221
222         function ConfirmDeleteClub( id, name ) {
223             if ( confirm( _("Are you sure you want to delete the club %s? This will cancel all patron enrollments in this club." ).format(name) ) ) {
224                 $.ajax({
225                     type: "POST",
226                     url: '/cgi-bin/koha/svc/club/delete',
227                     data: { id: id },
228                     success: function( data ) {
229                         if ( data.success ) {
230                             location.reload();
231                         } else {
232                             alert(_("Unable to delete club!"));
233                         }
234                     },
235                     dataType: 'json'
236                 });
237             }
238         }
239
240         function SearchToHold(club_id) {
241             var date = new Date();
242             date.setTime(date.getTime() + (10 * 60 * 1000));
243             Cookies.set("holdforclub", club_id, { path: "/", expires: date, sameSite: 'Lax'  });
244             location.href="/cgi-bin/koha/catalogue/search.pl";
245         }
246     </script>
247 [% END %]
248
249 [% INCLUDE 'intranet-bottom.inc' %]