Bug 26403: Use accounts include in account management pages
[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 [% SET footerjs = 1 %]
6 [% PROCESS 'accounts.inc' %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>
9     [% IF op =='add_form' %]
10        [% IF debit_type.code %]
11            Modify debit type
12        [% ELSE %]
13            New debit type
14        [% END %] &rsaquo; [% END %]
15     Debit types &rsaquo; Administration &rsaquo; Koha
16 </title>
17 [% INCLUDE 'doc-head-close.inc' %]
18 </head>
19
20 <body id="admin_debit_types" class="admin">
21 [% WRAPPER 'header.inc' %]
22     [% INCLUDE 'prefs-admin-search.inc' %]
23 [% END %]
24
25 [% WRAPPER 'sub-header.inc' %]
26     [% WRAPPER breadcrumbs %]
27         [% WRAPPER breadcrumb_item %]
28             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
29         [% END %]
30
31         [% IF op == 'add_form' %]
32             [% WRAPPER breadcrumb_item %]
33                 <a href="/cgi-bin/koha/admin/debit_types.pl">Debit types</a>
34             [% END %]
35             [% WRAPPER breadcrumb_item bc_active= 1 %]
36                 [% IF debit_type.code %]
37                     <span>Modify debit type</span>
38                 [% ELSE %]
39                     <span>New debit type</span>
40                 [% END %]
41             [% END %]
42
43         [% ELSE %]
44             [% WRAPPER breadcrumb_item bc_active= 1 %]
45                 <span>Debit types</span>
46             [% END %]
47         [% END %]
48     [% END #/ WRAPPER breadcrumbs %]
49 [% END #/ WRAPPER sub-header.inc %]
50
51 <div class="main container-fluid">
52     <div class="row">
53         <div class="col-sm-10 col-sm-push-2">
54             <main>
55
56                 [% FOREACH m IN messages %]
57                 <div class="dialog [% m.type | html %]">
58                     [% SWITCH m.code %]
59                     [% CASE 'success_on_saving' %]
60                         <span>Debit type saved successfully</span>
61                     [% CASE 'error_on_saving' %]
62                         <span>An error occurred when saving this debit type</span>
63                     [% CASE 'success_on_archive' %]
64                         <span>Debit type archived successfully</span>
65                     [% CASE 'success_on_restore' %]
66                         <span>Debit type restored successfully</span>
67                     [% CASE %]
68                         <span>[% m.code | html %]</span>
69                     [% END %]
70                 </div>
71                 [% END %]
72
73                 [% IF op == 'add_form' %]
74                     [% IF debit_type %]
75                         <h1>Modify a debit type</h1>
76                     [% ELSE %]
77                         <h1>New debit type</h1>
78                     [% END %]
79
80                     <form action="/cgi-bin/koha/admin/debit_types.pl" name="Aform" method="post" class="validated">
81                         <input type="hidden" name="op" value="add_validate" />
82                         <fieldset class="rows">
83                             <ol>
84                                 <li>
85                                     <label for="code" class="required">Debit type code: </label>
86                                     [% IF debit_type %]
87                                         <strong>[% debit_type.code | html %]</strong>
88                                         <input type="hidden" name="code" value="[% code | html %]" />
89                                     [% ELSE %]
90                                     <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>
91                                     [% END %]
92                                 </li>
93                                 <li>
94                                     <label for="default_amount">Default amount: </label>
95                                     <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"/>
96                                 </li>
97                                 <li>
98                                     <label for="description" class="required">Description: </label>
99                                     [% IF debit_type && debit_type.is_system %]
100                                         <span>[%- PROCESS debit_type_description debit_type = debit_type -%]</span>
101                                     [% ELSE %]
102                                         <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>
103                                     [% END %]
104                                 </li>
105                                 <li>
106                                     <label for="can_be_invoiced">Can be manually invoiced? </label>
107                                     [% IF debit_type.can_be_invoiced %]
108                                         <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" checked="checked" value="1" />
109                                     [% ELSE %]
110                                         <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" value="1" />
111                                     [% END %]
112                                 </li>
113                                 <li>
114                                     <label for="can_be_sold">Can be sold? </label>
115                                     [% IF debit_type.can_be_sold %]
116                                         <input type="checkbox" name="can_be_sold" id="can_be_sold" checked="checked" value="1" />
117                                     [% ELSE %]
118                                         <input type="checkbox" name="can_be_sold" id="can_be_sold" value="1" />
119                                     [% END %]
120                                 </li>
121                                 <li>
122                                     <label for="branches">Libraries limitation: </label>
123                                     <select id="branches" name="branches" multiple size="10">
124                                         <option value="">All libraries</option>
125                                         [% FOREACH branch IN branches_loop %]
126                                         [% IF ( branch.selected ) %]
127                                         <option selected="selected" value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
128                                         [% ELSE %]
129                                         <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
130                                         [% END %]
131                                         [% END %]
132                                     </select>
133                                     <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>
134                                 </li>
135                             </ol>
136                         </fieldset>
137
138                         <fieldset class="action">
139                             <button id="save_debit_type" class="btn btn-primary">Save</button>
140                             <a class="cancel" href="/cgi-bin/koha/admin/debit_types.pl">Cancel</a>
141                         </fieldset>
142                     </form>
143                 [% END %]
144
145                 [% IF op == 'list' %]
146                     <div id="toolbar" class="btn-toolbar">
147                         <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>
148                     </div>
149
150                     <h1>Account debit types</h1>
151                     [% IF debit_types.count %]
152                         <div class="page-section">
153                             <table id="table_debit_types">
154                                 <thead>
155                                     <th>Archived</th>
156                                     <th>System</th>
157                                     <th>Code</th>
158                                     <th>Description</th>
159                                     <th>Default amount</th>
160                                     <th>Available for</th>
161                                     <th>Library limitations</th>
162                                     <th class="noExport">Actions</th>
163                                 </thead>
164                                 <tbody>
165                                     [% FOREACH debit_type IN debit_types %]
166                                     <tr>
167                                         <td>[% debit_type.archived | html %]</td>
168                                         <td>[% debit_type.is_system | html %]</td>
169                                         <td>[% debit_type.code | html %]</td>
170                                         <td>[%- PROCESS debit_type_description debit_type = debit_type -%]</td>
171                                         <td>[% debit_type.default_amount | $Price %]</td>
172                                         <td>[% IF debit_type.can_be_invoiced && debit_type.can_be_sold %]
173                                             <i class="fa fa-id-card-o"></i> Invoicing, <i class="fa fa-shopping-cart"></i> Sale
174                                             [% ELSIF debit_type.can_be_invoiced %]
175                                             <i class="fa fa-id-card-o"></i> Invoicing
176                                             [% ELSIF debit_type.can_be_sold %]
177                                             <i class="fa fa-shopping-cart"></i> Sale
178                                             [% END %]
179                                         </td>
180                                         <td>
181                                             [% IF debit_type.library_limits.count > 0 %]
182                                                 [% library_limits_str = "" %]
183                                                 [% FOREACH library IN debit_type.library_limits %]
184                                                     [%- IF loop.first -%]
185                                                     [% library_limits_str = library.branchname _ " (" _ library.branchcode _ ")" %]
186                                                     [% ELSE %]
187                                                     [% library_limits_str = library_limits_str _ "\n" _ library.branchname _ " (" _ library.branchcode _ ")" %]
188                                                     [% END %]
189                                                 [% END %]
190                                                 <span class="library_limitation" title="[% library_limits_str | html %]">
191                                                     [% IF debit_type.library_limits.count > 1 %]
192                                                         <span>[% debit_type.library_limits.count | html %] library limitations</span>
193                                                     [% ELSE %]
194                                                         <span>[% debit_type.library_limits.count | html %] library limitation</span>
195                                                     [% END %]
196                                             [% ELSE %]
197                                                 <span>No limitation</span>
198                                             [% END %]
199                                         </td>
200                                         <td class="actions">
201                                             [% IF !debit_type.is_system && !debit_type.archived %]
202                                             <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 fa-pencil"></i> Edit</a>
203                                             <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>
204                                             [% ELSIF debit_type.archived %]
205                                             <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>
206                                             [% END %]
207                                         </td>
208                                     </tr>
209                                     [% END %]
210                                 </tbody>
211                             </table>
212                         </div><!-- /.page-section -->
213                     [% ELSE %]
214                         <div class="dialog message">
215                             There are no account debit types defined. <a href="/cgi-bin/koha/admin/debit_types.pl?op=add_form">Create new debit 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 debit types");
236             var txtInactivefilter = _("Show all debit types");
237             var table_debit_types = $("#table_debit_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_debit_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' %]