Bug 26703: admin folder
[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>
8     [% IF op =='add_form' %]
9        [% IF debit_type.code %]
10            Modify debit type
11        [% ELSE %]
12            New debit type
13        [% END %] &rsaquo; [% END %]
14     Debit types &rsaquo; Administration &rsaquo; Koha
15 </title>
16 [% INCLUDE 'doc-head-close.inc' %]
17 </head>
18
19 <body id="admin_debit_types" class="admin">
20 [% INCLUDE 'header.inc' %]
21 [% INCLUDE 'prefs-admin-search.inc' %]
22
23 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
24     <ol>
25         <li>
26             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
27         </li>
28         <li>
29             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
30         </li>
31
32         [% IF op == 'add_form' %]
33             <li>
34                 <a href="/cgi-bin/koha/admin/debit_types.pl">Debit types</a>
35             </li>
36             <li>
37                 <a href="#" aria-current="page">
38                     [% IF debit_type.code %]
39                         Modify
40                     [% ELSE %]
41                         New
42                     [% END %] debit type
43                 </a>
44             </li>
45
46         [% ELSE %]
47             <li>
48                 <a href="#" aria-current="page">
49                     Debit types
50                 </a>
51             </li>
52         [% END %]
53     </ol>
54 </nav>
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                         Debit type saved successfully.
66                     [% CASE 'error_on_saving' %]
67                         An error occurred when saving this debit type.
68                     [% CASE 'success_on_archive' %]
69                         Debit type archived successfully.
70                     [% CASE 'success_on_restore' %]
71                         Debit type restored successfully.
72                     [% CASE %]
73                         [% m.code | html %]
74                     [% END %]
75                 </div>
76                 [% END %]
77
78                 [% IF op == 'add_form' %]
79                     [% IF debit_type %]
80                         <h3>Modify a debit type</h3>
81                     [% ELSE %]
82                         <h3>New debit type</h3>
83                     [% END %]
84
85                     <form action="/cgi-bin/koha/admin/debit_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">Debit type code: </label>
91                                     [% IF debit_type %]
92                                         <strong>[% debit_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="default_amount">Default amount: </label>
100                                     <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"/>
101                                 </li>
102                                 <li>
103                                     <label for="description" class="required">Description: </label>
104                                     <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>
105                                 </li>
106                                 <li>
107                                     <label for="can_be_invoiced">Can be manually invoiced? </label>
108                                     [% IF debit_type.can_be_invoiced %]
109                                         <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" checked="checked" value="1" />
110                                     [% ELSE %]
111                                         <input type="checkbox" name="can_be_invoiced" id="can_be_invoiced" value="1" />
112                                     [% END %]
113                                 </li>
114                                 <li>
115                                     <label for="can_be_sold">Can be sold? </label>
116                                     [% IF debit_type.can_be_sold %]
117                                         <input type="checkbox" name="can_be_sold" id="can_be_sold" checked="checked" value="1" />
118                                     [% ELSE %]
119                                         <input type="checkbox" name="can_be_sold" id="can_be_sold" value="1" />
120                                     [% END %]
121                                 </li>
122                                 <li>
123                                     <label for="branches">Libraries limitation: </label>
124                                     <select id="branches" name="branches" multiple size="10">
125                                         <option value="">All libraries</option>
126                                         [% FOREACH branch IN branches_loop %]
127                                         [% IF ( branch.selected ) %]
128                                         <option selected="selected" value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
129                                         [% ELSE %]
130                                         <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
131                                         [% END %]
132                                         [% END %]
133                                     </select>
134                                     <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>
135                                 </li>
136                             </ol>
137                         </fieldset>
138
139                         <fieldset class="action">
140                             <button id="save_debit_type" class="btn btn-default">Save</button>
141                             <a class="cancel" href="/cgi-bin/koha/admin/debit_types.pl">Cancel</a>
142                         </fieldset>
143                     </form>
144                 [% END %]
145
146                 [% IF op == 'list' %]
147                     <div id="toolbar" class="btn-toolbar">
148                         <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>
149                     </div>
150
151                     <h3>Account debit types</h3>
152                     [% IF debit_types.count %]
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>[% debit_type.description | html %]</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                                                     [% debit_type.library_limits.count | html %] library limitations
193                                                 [% ELSE %]
194                                                     [% debit_type.library_limits.count | html %] library limitation
195                                                 [% END %]
196                                         [% ELSE %]
197                                             No limitation
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                     [% ELSE %]
213                         <div class="dialog message">
214                             There are no account debit types defined. <a href="/cgi-bin/koha/admin/debit_types.pl?op=add_form">Create new debit type</a>
215                         </div>
216                     [% END %]
217                 [% END %]
218             </main>
219         </div> <!-- /.col-sm-10.col-sm-push-2 -->
220
221         <div class="col-sm-2 col-sm-pull-10">
222             <aside>
223                 [% INCLUDE 'admin-menu.inc' %]
224             </aside>
225         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
226     </div> <!-- /.row -->
227
228 [% MACRO jsinclude BLOCK %]
229     [% Asset.js("js/admin-menu.js") | $raw %]
230     [% INCLUDE 'datatables.inc' %]
231
232     <script>
233         $(document).ready(function() {
234             var txtActivefilter = _("Filter system debit types");
235             var txtInactivefilter = _("Show all debit types");
236             var table_debit_types = $("#table_debit_types").dataTable($.extend(true, {}, dataTablesDefaults, {
237                 "aoColumnDefs": [
238                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
239                     { "aTargets": [ 0, 1 ], "bSortable": false, "bVisible": false },
240                 ],
241                 "aaSorting": [[ 0, "asc" ],[ 2, "asc" ]],
242                 "sDom": 'C<"top pager"ilpfB><"#filter_s">tr<"bottom pager"ip>',
243                 "iDisplayLength": 20,
244                 "sPaginationType": "full_numbers"
245             }));
246             $("#filter_s").html('<p><a href="#" id="filter_system"><i class="fa fa-filter"></i> '+txtActivefilter+'</a>');
247             $('#filter_system').click(function(e) {
248                 e.preventDefault();
249                 if ($(this).hasClass('filtered')) {
250                     var filteredValue = '';
251                     $(this).html('<i class="fa fa-filter"></i> '+txtActivefilter);
252                 } else { //Not filtered. Let's do it!
253                     var filteredValue = '0';
254                     $(this).html('<i class="fa fa-filter"></i> '+txtInactivefilter);
255                 }
256                 table_debit_types.fnFilter(filteredValue, 1, false, false);
257                 $(this).toggleClass('filtered');
258             });
259
260             //Start filtered
261             $('#filter_system').click();
262         });
263     </script>
264 [% END %]
265
266 [% INCLUDE 'intranet-bottom.inc' %]