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