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