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