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