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