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