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