Bug 9437 [Revised] Use DataTables on itemtypes administration page
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / itemtypes.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; Item types [% IF ( add_form ) %]&rsaquo;
3   [% IF ( itemtype ) %]
4 Modify item type '[% itemtype %]'
5   [% ELSE %]
6 Add item type
7   [% END %]
8 [% END %]
9 [% IF ( delete_confirm ) %]&rsaquo; 
10   [% IF ( total ) %]
11 Cannot delete item type '[% itemtype %]'
12   [% ELSE %]
13 Delete item type '[% itemtype %]'?
14   [% END %]
15 [% END %]
16 [% IF ( delete_confirmed ) %]&rsaquo; 
17 Data deleted
18 [% END %]
19 </title>
20 [% INCLUDE 'doc-head-close.inc' %]
21 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
22 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
23 [% INCLUDE 'datatables-strings.inc' %]
24 <script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
25 <script type="text/javascript">
26 //<![CDATA[
27
28 function isNotNull(f,noalert) {
29         if (f.value.length ==0) {
30                 return false;
31         }
32         return true;
33 }
34
35 function toUC(f) {
36         var x=f.value.toUpperCase();
37         f.value=x;
38         return true;
39 }
40
41 function isNum(v,maybenull) {
42 var n = new Number(v.value);
43 if (isNaN(n)) {
44         return false;
45         }
46 if (maybenull==0 && v.value=='') {
47         return false;
48 }
49 return true;
50 }
51
52 function isDate(f) {
53         var t = Date.parse(f.value);
54         if (isNaN(t)) {
55                 return false;
56         }
57 }
58
59 function Check(f) {
60         var ok=1;
61         var _alertString="";
62         var alertString2;
63         if (f.itemtype.value.length==0) {
64                 _alertString += "\n- " + _("Itemtype missing");
65         }
66         if (!(isNotNull(window.document.Aform.description,1))) {
67                 _alertString += "\n- " + _("Description missing");
68         }
69         if ((!isNum(f.rentalcharge,0)) && f.rentalcharge.value.length > 0) {
70                 _alertString += "\n- " + _("Rental charge is not a number");
71         }
72         if (_alertString.length==0) {
73                 document.Aform.submit();
74         } else {
75                 alertString2  = _("Form not submitted because of the following problem(s)");
76                 alertString2 += "\n------------------------------------------------------------------------------------\n";
77                 alertString2 += _alertString;
78                 alert(alertString2);
79         }
80 }
81      $(document).ready(function() {
82         $('#icons').tabs();
83         $("#table_item_type").dataTable($.extend(true, {}, dataTablesDefaults, {
84             "aoColumnDefs": [
85                 { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
86             ],
87             "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
88             "aaSorting": [[ 2, "asc" ]],
89             "iDisplayLength": 10
90         }));
91      });
92 //]]>
93 </script>
94 <style type="text/css">
95         fieldset.rows div.toptabs li { clear:none;margin-right:.5em;padding-bottom:0;width:auto; }
96   fieldset.rows div.toptabs .ui-tabs-nav li.ui-tabs-selected {background-color : #F4F8F9; }
97         fieldset.rows .ui-tabs-panel { margin-right : 10px; margin-left : 10px;margin-bottom:10px;}
98   fieldset.rows .ui-tabs-nav { margin-left : 10px; }
99 </style>
100 </head>
101 <body id="admin_itemtypes" class="admin">
102 [% INCLUDE 'header.inc' %]
103 [% INCLUDE 'cat-search.inc' %]
104
105 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( add_form ) %]
106   [% IF ( itemtype ) %]
107 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Modify item type '[% itemtype %]'
108   [% ELSE %]
109 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Add item type
110   [% END %]
111 [% END %]
112 [% IF ( delete_confirm ) %]
113   [% IF ( total ) %]
114 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Cannot delete item type '[% itemtype %]'
115   [% ELSE %]
116 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Delete item type '[% itemtype %]'?
117   [% END %]
118 [% END %]
119 [% IF ( delete_confirmed ) %]
120 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo;Data deleted
121 [% END %]
122 [% IF ( else ) %]
123 Item types administration
124 [% END %]</div>
125
126 <div id="doc3" class="yui-t2">
127    
128    <div id="bd">
129         <div id="yui-main">
130         <div class="yui-b">
131         
132 [% IF ( else ) %]<div id="toolbar" class="btn-toolbar">
133     <a class="btn btn-small" id="newitemtype" href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form"><i class="icon-plus"></i> New item type</a>
134 </div>[% END %]
135
136 [% IF ( add_form ) %]
137   [% IF ( itemtype ) %]
138       <h3>Modify item type</h3>
139   [% ELSE %]
140       <h3>Add item type</h3>
141   [% END %]
142 <form action="[% script_name %]" name="Aform" method="post">
143   <input type="hidden" name="op" value="add_validate" />
144     <input type="hidden" name="checked" value="0" />
145                 
146     <fieldset class="rows">
147         <ol>
148   [% IF ( itemtype ) %]
149       <li>
150           <span class="label">Item type</span> <input type="hidden" name="itemtype" value="[% itemtype %]" />
151           [% itemtype %]
152      </li>
153   [% ELSE %]
154       <li>
155           <label for="itemtype">Item type</label> <input type="text" id="itemtype" name="itemtype" size="10" maxlength="10" onblur="toUC(this)" class="focus" />
156       </li>
157   [% END %]
158       <li>
159       [% IF ( itemtype ) %]
160           <label for="description">Description</label><input type="text" id="description" name="description" size="48" value="[% description |html %]" class="focus" /></li>
161       [% ELSE %]
162           <label for="description">Description</label><input type="text" id="description" name="description" size="48" value="[% description |html %]" /></li>
163       [% END %]
164      [% IF ( noItemTypeImages ) %]
165          <li><span class="label">Image: </span>Item type images are disabled. To enable them, turn off the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=noItemTypeImages">noItemTypeImages system preference</a></li></ol>
166          [% ELSE %]</ol>
167     <div id="icons" class="toptabs" style="clear:both">
168         <h5 style="margin-left:10px;">Choose an icon:</h5>
169                         <ul>
170           <li><a href="#none">None</a></li>
171                                   [% FOREACH imageset IN imagesets %]
172             [% IF ( imageset.imagesetactive ) %]<li class="ui-tabs-selected">[% ELSE %]<li>[% END %]<a href="#[% imageset.imagesetname %]">[% imageset.imagesetname %]</a></li>
173                                   [% END %]
174                   [% IF ( remote_image ) %]<li class="ui-tabs-selected">[% ELSE %]<li>[% END %]<a href="#remote">Remote image</a></li>
175                         </ul>
176   <div id="none"><ul>
177   <li><label for="noimage">No image: </label><input type="radio" name="image" id="noimage" value="removeImage" /></li>
178   </ul>
179   <br class="clear" /></div>
180
181   [% FOREACH imageset IN imagesets %]
182   <div id="[% imageset.imagesetname %]"><ul>
183   [% FOREACH image IN imageset.images %]
184                         <li style="float: none; display: inline; clear : none; width: auto;">
185             <label> [% IF ( image.StaffImageUrl ) %]
186               <img src="[% image.StaffImageUrl %]" alt="[% image.StaffImageUrl %]" title="[% image.StaffImageUrl %]" />
187         [% ELSE %]
188         [% END %]
189     [% IF ( image.checked ) %]
190               <input type="radio" name="image" value="[% image.KohaImage %]" checked="checked" />
191     [% ELSE %]
192               [% IF ( image.KohaImage ) %] <!-- to delete the radio button if there is no image after -->
193               <input type="radio" name="image" value="[% image.KohaImage %]" />
194               [% END %]
195     [% END %]
196             </label>
197                         </li>
198   [% END %]
199   </ul>
200   <br class="clear" />
201   </div>
202   [% END %]
203 <div id="remote"><ul>
204 <li> <label for="remote_image_check"> Remote image:</label>
205   [% IF ( remote_image ) %]
206             <input type="radio" id="remote_image_check" name="image" value="remoteImage" checked="checked" />
207   [% ELSE %]
208             <input type="radio" id="remote_image_check" name="image" value="remoteImage" />
209   [% END %]<input type="text" name="remoteImage" size="48" maxlength="200" value="[% remote_image %]" onmousedown="document.getElementById('remote_image_check').checked = true;" /> [% IF ( remote_image ) %]
210             <img src="[% remote_image %]" alt="" />
211   [% END %]</li>
212 </ul>
213   <br class="clear" />
214 </div>
215 [% END %]
216 </div>
217 <ol>
218       <li>
219           <label for="notforloan">Not for loan</label>   [% IF ( notforloan ) %]
220                 <input type="checkbox" id="notforloan" name="notforloan" checked="checked" value="1" />
221             [% ELSE %]
222                 <input type="checkbox" id="notforloan" name="notforloan" value="1" />
223             [% END %]
224           (if checked, no item of this type can be issued. If not checked, every item of this type can be issued unless notforloan is set for a specific item)
225         
226       </li>
227       <li>
228           <label for="rentalcharge">Rental charge: </label>
229                   <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% rentalcharge %]" />
230          </li>
231       <li>
232           <label for="summary">Summary: </label>
233          <textarea id="summary" name="summary" cols="55" rows="5">[% summary %]</textarea>
234           <p>Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </p>
235           <p><b>&lt;a href="[856u]"&gt;open site&lt;/a&gt;</b> will show the link just below the title</p>
236       </li>
237           </ol>
238     </fieldset>
239
240     <fieldset class="action">
241       <input type="button" value="Save changes" onclick="Check(this.form)" />
242           <a href="/cgi-bin/koha/admin/itemtypes.pl" class="cancel">Cancel</a>
243     </fieldset>
244 </form>
245 [% END %]
246
247 [% IF ( delete_confirm ) %]
248 [% IF ( total ) %]<div class="dialog message">
249 <h3>Cannot delete item type</h3>
250 <p><strong>This record is used [% total %] times</strong>. Deletion is not possible.</p>
251 [% ELSE %]<div class="dialog alert">
252 <h3>Delete item type '[% itemtype %]'?</h3>
253 [% END %]
254 <table>
255                 <tr>
256                         <th scope="row">Item type</th>
257                         <td>[% itemtype %]</td>
258                 </tr>
259
260         <tr><th scope="row">Description</th><td>[% description %]</td></tr>
261         <tr><th scope="row">Loan length</th><td>[% loanlength %]</td></tr>
262 <tr><th scope="row">Rental charge</th><td>[% rentalcharge %]</td></tr></table>
263                 <form action="[% script_name %]" method="post">
264                 <input type="hidden" name="op" value="delete_confirmed" /><input type="hidden" name="itemtype" value="[% itemtype %]" />[% IF ( total ) %]
265                 </form>
266                 
267                 <form action="[% script_name %]" method="post"><input type="submit" class="approve" value="OK" /></form>
268         [% ELSE %]
269                 <input type="submit" class="approve" value="Delete this Item Type" /></form> <form action="[% script_name %]" method="post"><input type="submit" class="deny" value="Do Not Delete" /></form>
270         [% END %]
271 </div>
272         
273 [% END %]
274
275 [% IF ( else ) %]
276 <h2>Item types administration</h2>
277 [% IF ( loop ) %]
278 <table id="table_item_type">
279   <thead>
280     [% UNLESS ( noItemTypeImages ) %]<th>Image</th>[% END %]
281     <th>Code</th>
282     <th>Description</th>
283     <th>Not for loan</th>
284     <th>Charge</th>
285     <th>Actions</th>
286   </thead>
287   [% FOREACH loo IN loop %]
288     [% UNLESS ( loop.odd ) %]
289   <tr class="highlight">
290     [% ELSE %]
291   <tr>
292     [% END %]
293    [% UNLESS ( noItemTypeImages ) %] <td>[% IF ( loo.imageurl ) %]<img src="[% loo.imageurl %]" alt="" />[% ELSE %]&nbsp;[% END %]</td>[% END %]
294     <td>
295       <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">
296         [% loo.itemtype %]
297       </a>
298     </td>
299     <td>[% loo.description %]</td>
300     <td>[% IF ( loo.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
301     <td>
302     [% UNLESS ( loo.notforloan ) %]
303       [% loo.rentalcharge %]
304     [% END %]
305     </td>
306     <td>
307       <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">Edit</a>
308       <a href="[% loo.script_name %]?op=delete_confirm&amp;itemtype=[% loo.itemtype |html %]">Delete</a>
309     </td>
310   </tr>
311   [% END %]
312 </table>[% ELSE %]
313 <div class="dialog message">There are no itemtypes defined</div>
314 [% END %]
315
316 <div class="pages">[% pagination_bar %]</div>
317
318 [% END %]
319
320
321
322 </div>
323 </div>
324 <div class="yui-b">
325 [% INCLUDE 'admin-menu.inc' %]
326 </div>
327 </div>
328 [% INCLUDE 'intranet-bottom.inc' %]