Bug 34390: Fix inconsistencies in credit types titles, breadcrumbs, and header
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / credit_types.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Branches %]
4 [% PROCESS 'i18n.inc' %]
5 [% SET footerjs = 1 %]
6 [% PROCESS 'accounts.inc' %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>[% FILTER collapse %]
9     [% IF op =='add_form' %]
10        [% IF credit_type.code %]
11            [% tx("Modify credit type {credit_type}", {credit_type = credit_type.code }) | html %] &rsaquo;
12        [% ELSE %]
13            [% t("New credit type") | html %] &rsaquo;
14        [% END %]
15        [% t("Credit types") | html %]
16     [% ELSE %]
17        [% t("Credit types") | html %]
18     [% END %] &rsaquo;
19     [% t("Administration") | html %] &rsaquo;
20     [% t("Koha") | html %]
21 [% END %]</title>
22 [% INCLUDE 'doc-head-close.inc' %]
23 </head>
24
25 <body id="admin_credit_types" class="admin">
26 [% WRAPPER 'header.inc' %]
27     [% INCLUDE 'prefs-admin-search.inc' %]
28 [% END %]
29
30 [% WRAPPER 'sub-header.inc' %]
31     [% WRAPPER breadcrumbs %]
32         [% WRAPPER breadcrumb_item %]
33             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
34         [% END %]
35
36         [% IF op == 'add_form' %]
37             [% WRAPPER breadcrumb_item %]
38                 <a href="/cgi-bin/koha/admin/credit_types.pl">Credit types</a>
39             [% END %]
40             [% WRAPPER breadcrumb_item bc_active= 1 %]
41                 [% IF credit_type.code %]
42                     [% tx("Modify credit type {credit_type}", {credit_type = credit_type.code }) | html %]
43                 [% ELSE %]
44                     <span>New credit type</span>
45                 [% END %]
46             [% END %]
47
48         [% ELSE %]
49             [% WRAPPER breadcrumb_item bc_active= 1 %]
50                 <span>Credit types</span>
51             [% END %]
52         [% END %]
53     [% END #/ WRAPPER breadcrumbs %]
54 [% END #/ WRAPPER sub-header.inc %]
55
56 <div class="main container-fluid">
57     <div class="row">
58         <div class="col-sm-10 col-sm-push-2">
59             <main>
60
61                 [% FOREACH m IN messages %]
62                 <div class="dialog [% m.type | html %]">
63                     [% SWITCH m.code %]
64                     [% CASE 'success_on_saving' %]
65                         <span>Credit type saved successfully</span>
66                     [% CASE 'error_on_saving' %]
67                         <span>An error occurred when saving this credit type</span>
68                     [% CASE 'success_on_archive' %]
69                         <span>Credit type archived successfully</span>
70                     [% CASE 'success_on_restore' %]
71                         <span>Credit type restored successfully</span>
72                     [% CASE %]
73                         <span>[% m.code | html %]</span>
74                     [% END %]
75                 </div>
76                 [% END %]
77
78                 [% IF op == 'add_form' %]
79                     [% IF credit_type %]
80                         <h1>[% tx("Modify credit type {credit_type}", {credit_type = credit_type.code }) | html %]</h1>
81                     [% ELSE %]
82                         <h1>New credit type</h1>
83                     [% END %]
84
85                     <form action="/cgi-bin/koha/admin/credit_types.pl" name="Aform" method="post" class="validated">
86                         <input type="hidden" name="op" value="add_validate" />
87                         <fieldset class="rows">
88                             <ol>
89                                 <li>
90                                     <label for="code" class="required">Credit type code: </label>
91                                     [% IF credit_type %]
92                                         <strong>[% credit_type.code | html %]</strong>
93                                         <input type="hidden" name="code" value="[% code | html %]" />
94                                     [% ELSE %]
95                                     <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>
96                                     [% END %]
97                                 </li>
98                                 <li>
99                                     <label for="description" class="required">Description: </label>
100                                     [% IF credit_type && credit_type.is_system %]
101                                         <span>[%- PROCESS credit_type_description credit_type = credit_type -%]</span>
102                                     [% ELSE %]
103                                         <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>
104                                     [% END %]
105                                 </li>
106                                 <li>
107                                     <label for="can_be_added_manually">Can be manually added ? </label>
108                                     [% IF credit_type && credit_type.is_system %]
109                                         [% IF credit_type.can_be_added_manually %]<span>Yes</span>[% ELSE %]<span>No</span>[% END %]
110                                     [% ELSIF credit_type.can_be_added_manually %]
111                                         <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" checked="checked" value="1" />
112                                     [% ELSE %]
113                                         <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" value="1" />
114                                     [% END %]
115                                 </li>
116                                 <li>
117                                     <label for="credit_number_enabled">Enable credit number</label>
118                                     [% IF credit_type.credit_number_enabled %]
119                                         <input type="checkbox" name="credit_number_enabled" id="credit_number_enabled" checked="checked" value="1" />
120                                     [% ELSE %]
121                                         <input type="checkbox" name="credit_number_enabled" id="credit_number_enabled" value="1" />
122                                     [% END %]
123                                     <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>
124                                 </li>
125                                 <li>
126                                     <label for="branches">Libraries limitation: </label>
127                                     [% IF credit_type && credit_type.is_system %]
128                                         <span>No library limitation</span>
129                                     [% ELSE %]
130                                         <select id="branches" name="branches" multiple size="10">
131                                             <option value="">All libraries</option>
132                                             [% FOREACH branch IN branches_loop %]
133                                             [% IF ( branch.selected ) %]
134                                             <option selected="selected" value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
135                                             [% ELSE %]
136                                             <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
137                                             [% END %]
138                                             [% END %]
139                                         </select>
140                                         <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>
141                                     [% END %]
142                                 </li>
143                             </ol>
144                         </fieldset>
145
146                         <fieldset class="action">
147                             <button id="save_credit_type" class="btn btn-primary">Save</button>
148                             <a class="cancel" href="/cgi-bin/koha/admin/credit_types.pl">Cancel</a>
149                         </fieldset>
150                     </form>
151                 [% END %]
152
153                 [% IF op == 'list' %]
154                     <div id="toolbar" class="btn-toolbar">
155                         <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>
156                     </div>
157
158                     <h1>Credit types</h1>
159                     [% IF credit_types.count %]
160                         <div class="page-section">
161                             <table id="table_credit_types">
162                                 <thead>
163                                     <th>Archived</th>
164                                     <th>System</th>
165                                     <th>Code</th>
166                                     <th>Description</th>
167                                     <th>Available for</th>
168                                     <th>Credit number enabled</th>
169                                     <th>Library limitations</th>
170                                     <th class="noExport">Actions</th>
171                                 </thead>
172                                 <tbody>
173                                     [% FOREACH credit_type IN credit_types %]
174                                     <tr>
175                                         <td>[% credit_type.archived | html %]</td>
176                                         <td>[% credit_type.is_system | html %]</td>
177                                         <td>[% credit_type.code | html %]</td>
178                                         <td>[%- PROCESS credit_type_description credit_type = credit_type -%]</td>
179                                         <td>[% IF credit_type.can_be_added_manually %]Manual credit[% END %]</td>
180                                         <td>[% IF credit_type.credit_number_enabled %]Yes[% ELSE %]No[% END %]</td>
181                                         <td>
182                                             [% IF credit_type.library_limits.count > 0 %]
183                                                 [% library_limits_str = "" %]
184                                                 [% FOREACH library IN credit_type.library_limits %]
185                                                     [%- IF loop.first -%]
186                                                     [% library_limits_str = library.branchname _ " (" _ library.branchcode _ ")" %]
187                                                     [% ELSE %]
188                                                     [% library_limits_str = library_limits_str _ "\n" _ library.branchname _ " (" _ library.branchcode _ ")" %]
189                                                     [% END %]
190                                                 [% END %]
191                                                 <span class="library_limitation" title="[% library_limits_str | html %]">
192                                                     [% limits_count = credit_type.library_limits.count %]
193                                                     [% tnx('{count} library limitation', '{count} library limitations', limits_count, { count => limits_count }) %]
194                                             [% ELSE %]
195                                                 <span>No library limitation</span>
196                                             [% END %]
197                                         </td>
198                                         <td class="actions">
199                                             [% IF !credit_type.archived %]
200                                                 <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-solid fa-pencil" aria-hidden="true"></i> Edit</a>
201                                             [% END %]
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=archive&amp;code=[% credit_type.code | uri %]"><i class="fa fa-archive"></i> Archive</a>
204                                             [% END %]
205
206                                             [% IF !credit_type.is_system && credit_type.archived %]
207                                                 <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>
208                                             [% END %]
209                                         </td>
210                                     </tr>
211                                     [% END %]
212                                 </tbody>
213                             </table>
214                         </div><!-- /.page-section -->
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' %]