Bug 23049: Account types configuration - Admin page
[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        [% IF op == 'delete_confirm' %]
17            Debit types &rsaquo; Confirm deletion of debit type
18        [% ELSE %]
19            Debit types
20        [% END %]
21     [% END %]
22 </title>
23 [% INCLUDE 'doc-head-close.inc' %]
24 </head>
25
26 <body id="admin_debit_types" class="admin">
27 [% INCLUDE 'header.inc' %]
28 [% INCLUDE 'prefs-admin-search.inc' %]
29
30 <div id="breadcrumbs">
31     <a href="/cgi-bin/koha/mainpage.pl">Home</a>
32 &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
33 &rsaquo; <a href="/cgi-bin/koha/admin/debit_types.pl">Debit types</a>
34 [% IF op == 'add_form' %]
35 &rsaquo; [% IF debit_type.code %]Modify[% ELSE %]New[% END %] debit type
36 [% ELSIF op == 'delete_confirm' %]
37 &rsaquo; Confirm deletion of debit type
38 [% END %]
39 </div>
40
41 <div class="main container-fluid">
42     <div class="row">
43         <div class="col-sm-10 col-sm-push-2">
44             <main>
45
46                 [% FOREACH m IN messages %]
47                 <div class="dialog [% m.type | html %]">
48                     [% SWITCH m.code %]
49                     [% CASE 'error_on_saving' %]
50                         An error occurred when saving this debit type.
51                     [% CASE 'error_on_delete' %]
52                         An error occurred when deleting this debit type. Check the logs.
53                     [% CASE 'success_on_saving' %]
54                         Debit type saved successfully.
55                     [% CASE 'success_on_delete' %]
56                         Debit type deleted successfully.
57                     [% CASE %]
58                         [% m.code | html %]
59                     [% END %]
60                 </div>
61                 [% END %]
62
63                 [% IF op == 'add_form' %]
64                     [% IF debit_type %]
65                         <h3>Modify a debit type</h3>
66                     [% ELSE %]
67                         <h3>New debit type</h3>
68                     [% END %]
69
70                     <form action="/cgi-bin/koha/admin/debit_types.pl" name="Aform" method="post" class="validated">
71                         <input type="hidden" name="op" value="add_validate" />
72                         <fieldset class="rows">
73                             <ol>
74                                 <li>
75                                     <label for="code" class="required">Debit type code: </label>
76                                     [% IF debit_type %]
77                                         <strong>[% debit_type.code | html %]</strong>
78                                         <input type="hidden" name="code" value="[% code | html %]" />
79                                     [% ELSE %]
80                                     <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>
81                                     [% END %]
82                                 </li>
83                                 <li>
84                                     <label for="default_amount">Default amount: </label>
85                                     <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"/>
86                                 </li>
87                                 <li>
88                                     <label for="description" class="required">Description: </label>
89                                     <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>
90                                 </li>
91                                 <li>
92                                     <label for="can_be_added_manually">Can be added manually? </label>
93                                     [% IF debit_type.can_be_added_manually %]
94                                         <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" checked="checked" value="1" />
95                                     [% ELSE %]
96                                         <input type="checkbox" name="can_be_added_manually" id="can_be_added_manually" value="1" />
97                                     [% END %]
98                                 </li>
99                                 <li>
100                                     <label for="branches">Libraries limitation: </label>
101                                     <select id="branches" name="branches" multiple size="10">
102                                         <option value="">All libraries</option>
103                                         [% FOREACH branch IN branches_loop %]
104                                         [% IF ( branch.selected ) %]
105                                         <option selected="selected" value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
106                                         [% ELSE %]
107                                         <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option>
108                                         [% END %]
109                                         [% END %]
110                                     </select>
111                                     <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>
112                                 </li>
113                             </ol>
114                         </fieldset>
115
116                         <fieldset class="action">
117                             <button id="save_debit_type" class="btn btn-default"><i class="fa fa-save"></i> Save</button>
118                             <a class="cancel btn-link" href="/cgi-bin/koha/admin/debit_types.pl"><i class="fa fa-times"></i> Cancel</a>
119                         </fieldset>
120                     </form>
121                 [% END %]
122
123                 [% IF op == 'delete_confirm' %]
124                     <div class="dialog alert">
125                         <h3>Delete debit type "[% debit_type.description | html %]?"</h3>
126                         <table>
127                             <tr><th>Debit type code</th>
128                                 <td>[% debit_type.code | html %]</td>
129                             </tr>
130                             <tr><th>Debit type description</th>
131                                 <td>[% debit_type.description | html %]</td>
132                             </tr>
133                         </table>
134                         <form action="/cgi-bin/koha/admin/debit_types.pl" method="post">
135                             <input type="hidden" name="op" value="delete_confirmed" />
136                             <input type="hidden" name="code" value="[% debit_type.code | html %]" />
137                             <button type="submit" class="btn btn-default approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
138                         </form>
139                         <form action="/cgi-bin/koha/admin/debit_types.pl" method="get">
140                             <button type=submit" class="btn btn-default deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
141                         </form>
142                     </div>
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                     <h3>Account debit types</h3>
151                     [% IF debit_types.count %]
152                         <table id="table_debit_types">
153                             <thead>
154                                 <th>Code</th>
155                                 <th>Description</th>
156                                 <th>Default amount</th>
157                                 <th>Can be added manually</th>
158                                 <th>Library limitations</th>
159                                 <th>Actions</th>
160                             </thead>
161                             <tbody>
162                                 [% FOREACH debit_type IN debit_types %]
163                                 <tr>
164                                     <td>[% debit_type.code | html %]</td>
165                                     <td>[% debit_type.description | html %]</td>
166                                     <td>[% debit_type.default_amount | $Price %]</td>
167                                     <td>[% IF debit_type.can_be_added_manually %]Yes[% ELSE %]No[% END %]</td>
168                                     <td>
169                                         [% IF debit_type.library_limits.count > 0 %]
170                                             [% library_limits_str = "" %]
171                                             [% FOREACH library IN debit_type.library_limits %]
172                                                 [%- IF loop.first -%]
173                                                 [% library_limits_str = library.branchname _ " (" _ library.branchcode _ ")" %]
174                                                 [% ELSE %]
175                                                 [% library_limits_str = library_limits_str _ "\n" _ library.branchname _ " (" _ library.branchcode _ ")" %]
176                                                 [% END %]
177                                             [% END %]
178                                             <span class="library_limitation" title="[% library_limits_str | html %]">
179                                                 [% IF debit_type.library_limits.count > 1 %]
180                                                     [% debit_type.library_limits.count | html %] library limitations
181                                                 [% ELSE %]
182                                                     [% debit_type.library_limits.count | html %] library limitation
183                                                 [% END %]
184                                         [% ELSE %]
185                                             No limitation
186                                         [% END %]
187                                     </td>
188                                     <td class="actions">
189                                         [% IF !debit_type.is_system %]
190                                         <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/debit_types.pl?op=add_form&amp;code=[% debit_type.code | uri %]"><i class="fa fa-pencil"></i> Edit</a>
191                                         <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/debit_types.pl?op=delete_confirm&amp;code=[% debit_type.code | uri %]"><i class="fa fa-trash"></i> Delete</a>
192                                         [% END %]
193                                     </td>
194                                 </tr>
195                                 [% END %]
196                             </tbody>
197                         </table>
198                     [% ELSE %]
199                         <div class="dialog message">
200                             There are no account debit types defined. <a href="/cgi-bin/koha/admin/debit_types.pl?op=add_form">Create new debit type</a>
201                         </div>
202                     [% END %]
203                 [% END %]
204             </main>
205         </div> <!-- /.col-sm-10.col-sm-push-2 -->
206
207         <div class="col-sm-2 col-sm-pull-10">
208             <aside>
209                 [% INCLUDE 'admin-menu.inc' %]
210             </aside>
211         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
212     </div> <!-- /.row -->
213
214 [% MACRO jsinclude BLOCK %]
215     [% Asset.js("js/admin-menu.js") | $raw %]
216     [% INCLUDE 'datatables.inc' %]
217
218     <script>
219         $(document).ready(function() {
220             $("#table_debit_types").dataTable($.extend(true, {}, dataTablesDefaults, {
221                 "aoColumnDefs": [
222                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
223                 ],
224                 "aaSorting": [[ 1, "asc" ]],
225                 "iDisplayLength": 10,
226                 "sPaginationType": "full_numbers"
227             }));
228         });
229     </script>
230 [% END %]
231
232 [% INCLUDE 'intranet-bottom.inc' %]