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