Bug 27846: admin folder
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / credit_types.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Branches %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Administration &rsaquo;
7     [% IF op =='add_form' %]
8        Credit types &rsaquo;
9        [% IF credit_type.code %]
10            Modify credit type
11        [% ELSE %]
12            New credit type
13        [% END %]
14     [% ELSE %]
15        Credit types
16     [% END %]
17 </title>
18 [% INCLUDE 'doc-head-close.inc' %]
19 </head>
20
21 <body id="admin_credit_types" class="admin">
22 [% INCLUDE 'header.inc' %]
23 [% INCLUDE 'prefs-admin-search.inc' %]
24
25 <nav aria-label="Breadcrumb" class="breadcrumb">
26     <ol>
27         <li>
28             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
29         </li>
30         <li>
31             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
32         </li>
33
34         [% IF op == 'add_form' %]
35             <li>
36                 <a href="/cgi-bin/koha/admin/credit_types.pl">Credit types</a>
37             </li>
38             <li>
39                 <a href="#" aria-current="page">
40                     [% IF credit_type.code %]
41                         Modify credit type
42                     [% ELSE %]
43                         New credit type
44                     [% END %]
45                 </a>
46             </li>
47
48         [% ELSE %]
49             <li>
50                 <a href="#" aria-current="page">
51                     Credit types
52                 </a>
53             </li>
54         [% END %]
55     </ol>
56 </nav>
57
58 <div class="main container-fluid">
59     <div class="row">
60         <div class="col-sm-10 col-sm-push-2">
61             <main>
62
63                 [% FOREACH m IN messages %]
64                 <div class="dialog [% m.type | html %]">
65                     [% SWITCH m.code %]
66                     [% CASE 'success_on_saving' %]
67                         Credit type saved successfully.
68                     [% CASE 'error_on_saving' %]
69                         An error occurred when saving this credit type.
70                     [% CASE 'success_on_archive' %]
71                         Credit type archived successfully.
72                     [% CASE 'success_on_restore' %]
73                         Credit type restored successfully.
74                     [% CASE %]
75                         [% m.code | html %]
76                     [% END %]
77                 </div>
78                 [% END %]
79
80                 [% IF op == 'add_form' %]
81                     [% IF credit_type %]
82                         <h3>Modify a credit type</h3>
83                     [% ELSE %]
84                         <h3>New credit type</h3>
85                     [% END %]
86
87                     <form action="/cgi-bin/koha/admin/credit_types.pl" name="Aform" method="post" class="validated">
88                         <input type="hidden" name="op" value="add_validate" />
89                         <fieldset class="rows">
90                             <ol>
91                                 <li>
92                                     <label for="code" class="required">Credit type code: </label>
93                                     [% IF credit_type %]
94                                         <strong>[% credit_type.code | html %]</strong>
95                                         <input type="hidden" name="code" value="[% code | html %]" />
96                                     [% ELSE %]
97                                     <input type="text" name="code" id="code" size="80" maxlength="64" class="required focus" required="required"><span class="required">Required. Maximum length is 64 letters</span>
98                                     [% END %]
99                                 </li>
100                                 <li>
101                                     <label for="description" class="required">Description: </label>
102                                     [% IF credit_type && credit_type.is_system %]
103                                         <span>[% credit_type.description | html %]</span>
104                                     [% ELSE %]
105                                         <input type="text" name="description" id="description" required="required" class="required" size="80" maxlength="100" value="[% credit_type.description | html %]" /> <span class="required">Required</span>
106                                     [% END %]
107                                 </li>
108                                 <li>
109                                     <label for="can_be_added_manually">Can be manually added ? </label>
110                                     [% IF credit_type && credit_type.is_system %]
111                                         [% IF credit_type.can_be_added_manually %]Yes[% ELSE %]No[% END %]
112                                     [% ELSIF credit_type.can_be_added_manually %]
113                                         <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" checked="checked" value="1" />
114                                     [% ELSE %]
115                                         <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" value="1" />
116                                     [% END %]
117                                 </li>
118                                 <li>
119                                     <label for="credit_number_enabled">Enable credit number</label>
120                                     [% IF credit_type.credit_number_enabled %]
121                                         <input type="checkbox" name="credit_number_enabled" id="credit_number_enabled" checked="checked" value="1" />
122                                     [% ELSE %]
123                                         <input type="checkbox" name="credit_number_enabled" id="credit_number_enabled" value="1" />
124                                     [% END %]
125                                     <span>Enable automatic generation of credit number (see <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=AutoCreditNumber">AutoCreditNumber</a>)</span>
126                                 </li>
127                                 <li>
128                                     <label for="branches">Libraries limitation: </label>
129                                     [% IF credit_type && credit_type.is_system %]
130                                         No library limitation
131                                     [% ELSE %]
132                                         <select id="branches" name="branches" multiple size="10">
133                                             <option value="">All libraries</option>
134                                             [% FOREACH branch IN branches_loop %]
135                                             [% IF ( branch.selected ) %]
136                                             <option selected="selected" value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
137                                             [% ELSE %]
138                                             <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
139                                             [% END %]
140                                             [% END %]
141                                         </select>
142                                         <span>Select 'All libraries' if this credit type should be available at all libraries. Otherwise select libraries you want to associate credit type with.</span>
143                                     [% END %]
144                                 </li>
145                             </ol>
146                         </fieldset>
147
148                         <fieldset class="action">
149                             <button id="save_credit_type" class="btn btn-default">Save</button>
150                             <a class="cancel" href="/cgi-bin/koha/admin/credit_types.pl">Cancel</a>
151                         </fieldset>
152                     </form>
153                 [% END %]
154
155                 [% IF op == 'list' %]
156                     <div id="toolbar" class="btn-toolbar">
157                         <a class="btn btn-default" id="newcredittype" href="/cgi-bin/koha/admin/credit_types.pl?op=add_form"><i class="fa fa-plus"></i> New credit type</a>
158                     </div>
159
160                     <h3>Account credit types</h3>
161                     [% IF credit_types.count %]
162                         <table id="table_credit_types">
163                             <thead>
164                                 <th>Archived</th>
165                                 <th>System</th>
166                                 <th>Code</th>
167                                 <th>Description</th>
168                                 <th>Available for</th>
169                                 <th>Credit number enabled</th>
170                                 <th>Library limitations</th>
171                                 <th class="noExport">Actions</th>
172                             </thead>
173                             <tbody>
174                                 [% FOREACH credit_type IN credit_types %]
175                                 <tr>
176                                     <td>[% credit_type.archived | html %]</td>
177                                     <td>[% credit_type.is_system | html %]</td>
178                                     <td>[% credit_type.code | html %]</td>
179                                     <td>[% credit_type.description | html %]</td>
180                                     <td>[% IF credit_type.can_be_added_manually %]Manual credit[% END %]</td>
181                                     <td>[% IF credit_type.credit_number_enabled %]Yes[% ELSE %]No[% END %]</td>
182                                     <td>
183                                         [% IF credit_type.library_limits.count > 0 %]
184                                             [% library_limits_str = "" %]
185                                             [% FOREACH library IN credit_type.library_limits %]
186                                                 [%- IF loop.first -%]
187                                                 [% library_limits_str = library.branchname _ " (" _ library.branchcode _ ")" %]
188                                                 [% ELSE %]
189                                                 [% library_limits_str = library_limits_str _ "\n" _ library.branchname _ " (" _ library.branchcode _ ")" %]
190                                                 [% END %]
191                                             [% END %]
192                                             <span class="library_limitation" title="[% library_limits_str | html %]">
193                                                 [% limits_count = credit_type.library_limits.count %]
194                                                 [% tnx('{count} library limitation', '{count} library limitations', limits_count, { count => limits_count }) %]
195                                         [% ELSE %]
196                                             No limitation
197                                         [% END %]
198                                     </td>
199                                     <td class="actions">
200                                         [% IF !credit_type.archived %]
201                                             <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/credit_types.pl?op=add_form&amp;code=[% credit_type.code | uri %]&type=credit"><i class="fa fa-pencil"></i> Edit</a>
202                                         [% END %]
203                                         [% IF !credit_type.is_system && !credit_type.archived %]
204                                             <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/credit_types.pl?op=archive&amp;code=[% credit_type.code | uri %]"><i class="fa fa-archive"></i> Archive</a>
205                                         [% END %]
206
207                                         [% IF !credit_type.is_system && credit_type.archived %]
208                                             <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/credit_types.pl?op=unarchive&amp;code=[% credit_type.code | uri %]"><i class="fa fa-undo"></i> Restore</a>
209                                         [% END %]
210                                     </td>
211                                 </tr>
212                                 [% END %]
213                             </tbody>
214                         </table>
215                     [% ELSE %]
216                         <div class="dialog message">
217                             There are no account credit types defined.
218                             <a href="/cgi-bin/koha/admin/credit_types.pl?op=add_form">Create new credit type</a>
219                         </div>
220                     [% END %]
221                 [% END %]
222             </main>
223         </div> <!-- /.col-sm-10.col-sm-push-2 -->
224
225         <div class="col-sm-2 col-sm-pull-10">
226             <aside>
227                 [% INCLUDE 'admin-menu.inc' %]
228             </aside>
229         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
230     </div> <!-- /.row -->
231
232 [% MACRO jsinclude BLOCK %]
233     [% Asset.js("js/admin-menu.js") | $raw %]
234     [% INCLUDE 'datatables.inc' %]
235
236     <script>
237         $(document).ready(function() {
238             var txtActivefilter = _("Filter system credit types");
239             var txtInactivefilter = _("Show all credit types");
240             var table_credit_types = $("#table_credit_types").dataTable($.extend(true, {}, dataTablesDefaults, {
241                 "aoColumnDefs": [
242                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
243                     { "aTargets": [ 0, 1 ], "bSortable": false, "bVisible": false },
244                 ],
245                 "aaSorting": [[ 0, "asc" ],[ 2, "asc" ]],
246                 "sDom": 'C<"top pager"ilpfB><"#filter_s">tr<"bottom pager"ip>',
247                 "iDisplayLength": 20,
248                 "sPaginationType": "full_numbers"
249             }));
250             $("#filter_s").html('<p><a href="#" id="filter_system"><i class="fa fa-filter"></i> '+txtActivefilter+'</a>');
251             $('#filter_system').click(function(e) {
252                 e.preventDefault();
253                 if ($(this).hasClass('filtered')) {
254                     var filteredValue = '';
255                     $(this).html('<i class="fa fa-filter"></i> '+txtActivefilter);
256                 } else { //Not filtered. Let's do it!
257                     var filteredValue = '0';
258                     $(this).html('<i class="fa fa-filter"></i> '+txtInactivefilter);
259                 }
260                 table_credit_types.fnFilter(filteredValue, 1, false, false);
261                 $(this).toggleClass('filtered');
262             });
263
264             //Start filtered
265             $('#filter_system').click();
266         });
267     </script>
268 [% END %]
269
270 [% INCLUDE 'intranet-bottom.inc' %]