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