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