Bug 20912: (follow-up) Improve test coverage
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / itemtypes.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE AuthorisedValues %]
5 [% USE Price %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Administration &rsaquo; Item types [% IF op == 'add_form' %]&rsaquo;
9   [% IF ( itemtype ) %]
10 Modify item type '[% itemtype.itemtype | html %]'
11   [% ELSE %]
12 Add item type
13   [% END %]
14 [% END %]
15 [% IF op == 'delete_confirm' %]&rsaquo;
16   [% IF ( total ) %]
17 Cannot delete item type '[% itemtype.itemtype | html %]'
18   [% ELSE %]
19 Delete item type '[% itemtype.itemtype | html %]'?
20   [% END %]
21 [% END %]
22 [% IF op == 'delete_confirmed' %]&rsaquo;
23 Data deleted
24 [% END %]
25 </title>
26 [% INCLUDE 'doc-head-close.inc' %]
27 <style>
28         fieldset.rows div.toptabs li { clear:none;margin-right:.5em;padding-bottom:0;width:auto; }
29   fieldset.rows div.toptabs .ui-tabs-nav li.ui-tabs-active {background-color : #F4F8F9; }
30         fieldset.rows .ui-tabs-panel { margin-right : 10px; margin-left : 10px;margin-bottom:10px;}
31   fieldset.rows .ui-tabs-nav { margin-left : 10px; }
32 </style>
33 </head>
34
35 <body id="admin_itemtypes" class="admin">
36 [% INCLUDE 'header.inc' %]
37 [% INCLUDE 'prefs-admin-search.inc' %]
38
39 <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 op == 'add_form' %]
40   [% IF itemtype %]
41 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Modify item type '[% itemtype.itemtype | html %]'
42   [% ELSE %]
43 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Add item type
44   [% END %]
45 [% END %]
46 [% IF op == 'delete_confirm' %]
47   [% IF total %]
48 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Cannot delete item type '[% itemtype.itemtype | html %]'
49   [% ELSE %]
50 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo; Delete item type '[% itemtype.itemtype | html %]'?
51   [% END %]
52 [% END %]
53 [% IF op == 'delete_confirmed' %]
54 <a href="/cgi-bin/koha/admin/itemtypes.pl">Item types</a> &rsaquo;Data deleted
55 [% END %]
56 [% IF op == 'list' %]
57 Item types administration
58 [% END %]</div>
59
60 <div class="main container-fluid">
61     <div class="row">
62         <div class="col-sm-10 col-sm-push-2">
63             <main>
64
65 [% IF op == 'list' %]<div id="toolbar" class="btn-toolbar">
66     <a class="btn btn-default btn-sm" id="newitemtype" href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form"><i class="fa fa-plus"></i> New item type</a>
67 </div>[% END %]
68
69 [% FOREACH m IN messages %]
70     <div class="dialog [% m.type | html %]">
71         [% SWITCH m.code %]
72         [% CASE 'error_on_update' %]
73             An error occurred when updating this item type. Perhaps the value already exists.
74         [% CASE 'error_on_insert' %]
75             An error occurred when inserting this item type. Perhaps the value already exists.
76         [% CASE 'error_on_delete' %]
77             An error occurred when deleting this item type. Check the logs.
78         [% CASE 'success_on_update' %]
79             Item type updated successfully.
80         [% CASE 'success_on_insert' %]
81             Item type inserted successfully.
82         [% CASE 'success_on_delete' %]
83             Item type deleted successfully.
84         [% CASE 'already_exists' %]
85             This item type already exists.
86         [% CASE 'cannot_be_deleted' %]
87             Cannot delete this item type. <p><strong>This record is in use</strong>. Deletion is not possible.</p>
88         [% CASE %]
89             [% m.code | html %]
90         [% END %]
91     </div>
92 [% END %]
93
94
95 [% IF op == 'add_form' %]
96     [% IF itemtype %]
97         <h3>Modify item type</h3>
98     [% ELSE %]
99         <h3>Add item type</h3>
100     [% END %]
101     <form action="/cgi-bin/koha/admin/itemtypes.pl" name="Aform" method="post" id="itemtypeentry">
102         <input type="hidden" name="op" value="add_validate" />
103         <fieldset class="rows">
104             <ol>
105                 [% IF itemtype %]
106                     <li>
107                         <input type="hidden" name="is_a_modif" value="1" />
108                         <span class="label">Item type: </span> <input type="hidden" name="itemtype" value="[% itemtype.itemtype | html %]" />
109                         [% itemtype.itemtype | html %]
110                     </li>
111                 [% ELSE %]
112                     <li>
113                         <label for="itemtype" class="required">Item type: </label>
114                         <input type="text" id="itemtype" name="itemtype" size="10" maxlength="10" required="required" /> <span class="required">Required</span>
115                     </li>
116                 [% END %]
117                 <li>
118                     <label for="description" class="required">Description: </label>
119                     <input type="text" id="description" name="description" size="48" value="[% itemtype.description | html %]" required="required" /> <span class="required">Required</span>
120                     [% IF can_be_translated %]
121                         <a href="/cgi-bin/koha/admin/localization.pl?entity=itemtypes&code=[% itemtype.itemtype | uri %]" title="Translate item type [% itemtype.itemtype | html %]" rel="gb_page_center[600,500]"><i class="fa fa-pencil"></i> Translate into other languages</a>
122                     [% END %]
123                 </li>
124                 <li>
125                     <span class="label">Search category</span>
126                     <select id="searchcategory" name="searchcategory">
127                     <option value="">None</option>
128                         [% FOREACH cat IN searchcategory %]
129                             [% IF cat.authorised_value == itemtype.searchcategory %]
130                                 <option value="[% cat.authorised_value | html %]" selected="selected">
131                                     [% cat.lib | html %]
132                                 </option>
133                             [% ELSE %]
134                                 <option value="[% cat.authorised_value | html %]" >
135                                     [% cat.lib | html %]
136                                 </option>
137                             [% END %]
138                         [% END %]
139                     </select>
140                     <span class="hint">Options are defined as the authorized values for the ITEMTYPECAT category.</span>
141                 </li>
142                 [% IF Koha.Preference('noItemTypeImages') %]
143                     <li>
144                         <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>
145                     </li>
146                 [% END %]
147             </ol>
148             [% UNLESS Koha.Preference('noItemTypeImages') %]
149                 <div id="icons" class="toptabs" style="clear:both">
150                     <h5 style="margin-left:10px;">Choose an icon:</h5>
151                     <ul>
152                         <li><a href="#none">None</a></li>
153                         [% FOREACH imageset IN imagesets %]
154                             [% IF ( imageset.imagesetactive ) %]
155                                 <li class="ui-tabs-active">
156                             [% ELSE %]
157                                 <li>
158                             [% END %]
159                             <a href="#[% imageset.imagesetname | uri %]">[% imageset.imagesetname | html %]</a>
160                             </li>
161                         [% END %]
162                         [% IF itemtype.image_location('intranet').match('^http') %]<li class="ui-tabs-active">[% ELSE %]<li>[% END %]<a href="#remote">Remote image</a></li>
163                     </ul>
164                     <div id="none">
165                         <ul>
166                             <li><label for="noimage">No image: </label><input type="radio" name="image" id="noimage" value="removeImage" /></li>
167                         </ul>
168                         <br class="clear" />
169                     </div>
170
171                     [% FOREACH imageset IN imagesets %]
172                         <div id="[% imageset.imagesetname | html %]">
173                             <ul>
174                                 [% FOREACH image IN imageset.images %]
175                                     <li style="float: none; display: inline-block; clear : none; width: auto;">
176                                         <label>
177                                             [% IF image.StaffImageUrl %]
178                                                 <img src="[% image.StaffImageUrl | html %]" alt="[% image.StaffImageUrl | html %]" title="[% image.StaffImageUrl | html %]" />
179                                             [% END %]
180                                             [% IF image.checked %]
181                                                 <input type="radio" name="image" value="[% image.KohaImage | html %]" checked="checked" />
182                                             [% ELSIF image.KohaImage %] <!-- to delete the radio button if there is no image after -->
183                                                 <input type="radio" name="image" value="[% image.KohaImage | html %]" />
184                                             [% END %]
185                                         </label>
186                                     </li>
187                                 [% END %]
188                             </ul>
189                             <br class="clear" />
190                         </div>
191                     [% END %]
192
193                     <div id="remote">
194                         <ul>
195                             <li>
196                                 <label for="remote_image_check"> Remote image:</label>
197                                 [% IF itemtype.imageurl %]
198                                     <input type="radio" id="remote_image_check" name="image" value="remoteImage" checked="checked" />
199                                 [% ELSE %]
200                                     <input type="radio" id="remote_image_check" name="image" value="remoteImage" />
201                                 [% END %]
202                                 <input type="text" name="remoteImage" size="48" maxlength="200" value="[% itemtype.imageurl | html %]" onmousedown="document.getElementById('remote_image_check').checked = true;" />
203                                 [% IF itemtype.imageurl %]
204                                     <img src="[% itemtype.imageurl | html %]" alt="" />
205                                 [% END %]
206                             </li>
207                         </ul>
208                         <br class="clear" />
209                     </div>
210                 </div>
211             [% END %]
212             <ol class="oladditemtype">
213                 <li>
214                     <label for="hideinopac">Hide in OPAC: </label>
215                     [% IF ( itemtype.hideinopac ) %]
216                         <input type="checkbox" id="hideinopac" name="hideinopac" checked="checked" value="1" />
217                     [% ELSE %]
218                         <input type="checkbox" id="hideinopac" name="hideinopac" value="1" />
219                     [% END %]
220                     <span class="hint">If checked, items of this type will be hidden as filters in OPAC's advanced search.</span>
221                 </li>
222                 <li>
223                     <label for="notforloan">Not for loan: </label>
224                         [% IF itemtype.notforloan %]
225                             <input type="checkbox" id="notforloan" name="notforloan" checked="checked" value="1" />
226                         [% ELSE %]
227                             <input type="checkbox" id="notforloan" name="notforloan" value="1" />
228                         [% END %]
229                         <span class="hint">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.</span>
230                 </li>
231                 <li>
232                     <label for="rentalcharge">Rental charge: </label>
233                     <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price %]" />
234                     <span class="hint">This fee is charged once per checkout/renewal per item</span>
235                 </li>
236                 <li>
237                     <label for="rentalcharge_daily">Daily rental charge: </label>
238                     <input type="text" id="rentalcharge_daily" name="rentalcharge_daily" size="10" value="[% itemtype.rentalcharge_daily | $Price %]" />
239                     <span class="hint">This fee is charged a checkout/renewal time for each day between the checkout/renewal date and due date.</span>
240                 </li>
241                 <li>
242                     <label for="defaultreplacecost">Default replacement cost: </label>
243                     <input type="text" id="defaultreplacecost" name="defaultreplacecost" size="10" value="[% itemtype.defaultreplacecost | html %]" />
244                 </li>
245                 <li>
246                     <label for="processfee">Processing fee (when lost): </label>
247                     <input type="text" id="processfee" name="processfee" size="10" value="[% itemtype.processfee | html %]" />
248                 </li>
249                 <li>
250                     <label for="checkinmsg">Checkin message: </label>
251                     <textarea id="checkinmsg" name="checkinmsg" cols="55" rows="5">[% itemtype.checkinmsg | html %]</textarea>
252                 </li>
253                 <li>
254                     <label for="checkinmsgtype">Checkin message type: </label>
255                     <select type="text" id="checkinmsgtype" name="checkinmsgtype">
256                         [% IF itemtype.checkinmsgtype == 'message' %]
257                             <option value="message" selected="selected">Message</option>
258                         [% ELSE %]
259                             <option value="message">Message</option>
260                         [% END %]
261                         [% IF itemtype.checkinmsgtype == 'alert' %]
262                             <option value="alert" selected="selected">Alert</option>
263                         [% ELSE %]
264                             <option value="alert">Alert</option>
265                         [% END %]
266                     </select>
267                 </li>
268                 <li>
269                     <label for="sip_media_type">SIP media type: </label>
270                     <select id="sip_media_type" name="sip_media_type">
271                         <option value=""></option>
272                         [% FOREACH a IN AuthorisedValues.Get('SIP_MEDIA_TYPE') %]
273                             [% IF a.authorised_value == itemtype.sip_media_type %]
274                                 <option value="[% a.authorised_value | html %]" selected="selected">[% a.lib | html %]</option>
275                             [% ELSE %]
276                                 <option value="[% a.authorised_value | html %]">[% a.lib | html %]</option>
277                             [% END %]
278                         [% END %]
279                     </select>
280                 </li>
281                 <li>
282                     <label for="summary">Summary: </label>
283                    <textarea id="summary" name="summary" cols="55" rows="5">[% itemtype.summary | html %]</textarea>
284                     <p>Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </p>
285                     <p><b>&lt;a href="[856u]"&gt;open site&lt;/a&gt;</b> will show the link just below the title</p>
286                 </li>
287             </ol>
288         </fieldset>
289
290         <fieldset class="action">
291             <input type="submit" value="Save changes" />
292             <a href="/cgi-bin/koha/admin/itemtypes.pl" class="cancel">Cancel</a>
293         </fieldset>
294     </form>
295 [% END %]
296
297 [% IF op == 'delete_confirm' %]
298     <div class="dialog alert">
299         <h3>Delete item type '[% itemtype.itemtype | html %]'?</h3>
300         <table>
301             <tr>
302                 <th scope="row">Item type</th>
303                 <td>[% itemtype.itemtype | html %]</td>
304             </tr>
305             <tr><th scope="row">Description</th><td>[% itemtype.translated_description | html %]</td></tr>
306             [% UNLESS Koha.Preference('noItemTypeImages') %]
307                 <tr>
308                     <th scope="row">Image</th>
309                     <td>
310                         [% SET image_location = itemtype.image_location('intranet') %]
311                         [% IF image_location %]<img src="[% image_location | html %]" alt="" />[% END %]
312                     </td>
313                 </tr>
314             [% END %]
315             <tr><th scope="row">Rental charge</th><td>[% itemtype.rentalcharge | $Price %]</td></tr>
316         </table>
317         <form action="/cgi-bin/koha/admin/itemtypes.pl" method="post">
318             <input type="hidden" name="op" value="delete_confirmed" /><input type="hidden" name="itemtype" value="[% itemtype.itemtype | html %]" />
319             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this item type</button>
320         </form>
321         <form action="/cgi-bin/koha/admin/itemtypes.pl" method="post">
322             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
323         </form>
324     </div>
325 [% END %]
326
327 [% IF op == 'list' %]
328     <h2>Item types administration</h2>
329     [% IF itemtypes %]
330         <table id="table_item_type">
331           <thead>
332             [% UNLESS Koha.Preference('noItemTypeImages') %]<th>Image</th>[% END %]
333             <th>Code</th>
334             <th>Description</th>
335             <th>Search category</th>
336             <th>Not for loan</th>
337             <th>Hide in OPAC</th>
338             <th>Rental charge</th>
339             <th>Daily rental charge</th>
340             <th>Default replacement cost</th>
341             <th>Processing fee (when lost)</th>
342             <th>Checkin message</th>
343             <th>Actions</th>
344           </thead>
345           [% FOREACH itemtype IN itemtypes %]
346             <tr>
347                 [% UNLESS Koha.Preference('noItemTypeImages') %]
348                     <td>
349                         [% SET image_location = itemtype.image_location('intranet') %]
350                         [% IF image_location %]<img src="[% image_location | html %]" alt="" />[% ELSE %]&nbsp;[% END %]
351                     </td>
352                 [% END %]
353             <td>
354               <a href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form&amp;itemtype=[% itemtype.itemtype | uri %]">
355                 [% itemtype.itemtype | html %]
356               </a>
357             </td>
358             <td>
359                 [% IF itemtype.translated_descriptions.size %]
360                     [% itemtype.description | html %] (default)<br/>
361                     [% FOR description IN itemtype.translated_descriptions %]
362                         [% IF description.translation == itemtype.translated_description %]
363                             <b>[% description.translation | html %]</b>
364                         [% ELSE %]
365                             [% description.translation | html %] ([% description.lang | html %])
366                         [% END %]
367                         <br/>
368                     [% END %]
369                 [% ELSE %]
370                     [% itemtype.description | html %]
371                 [% END %]
372             </td>
373             <td>[% itemtype.searchcategory | html %]</td>
374             <td>[% IF ( itemtype.notforloan ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
375             <td>[% IF ( itemtype.hideinopac ) %]Yes[% ELSE %]&nbsp;[% END %]</td>
376             <td>
377             [% UNLESS ( itemtype.notforloan ) %]
378               [% itemtype.rentalcharge | $Price %]
379             [% END %]
380             </td>
381             <td>
382             [% UNLESS ( itemtype.notforloan ) %]
383               [% itemtype.rentalcharge_daily | $Price %]
384             [% END %]
385             </td>
386             <td>[% itemtype.defaultreplacecost | $Price %]</td>
387             <td>[% itemtype.processfee | $Price %]</td>
388             <td>[% itemtype.checkinmsg | html_line_break | $raw %]</td>
389             <td class="actions">
390               <a href="/cgi-bin/koha/admin/itemtypes.pl?op=add_form&amp;itemtype=[% itemtype.itemtype | uri %]" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
391               <a href="/cgi-bin/koha/admin/itemtypes.pl?op=delete_confirm&amp;itemtype=[% itemtype.itemtype | uri %]" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
392             </td>
393           </tr>
394           [% END %]
395         </table>
396     [% ELSE %]
397         <div class="dialog message">There are no itemtypes defined</div>
398     [% END %]
399 [% END %]
400
401             </main>
402         </div> <!-- /.col-sm-10.col-sm-push-2 -->
403
404         <div class="col-sm-2 col-sm-pull-10">
405             <aside>
406                 [% INCLUDE 'admin-menu.inc' %]
407             </aside>
408         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
409      </div> <!-- /.row -->
410
411 [% MACRO jsinclude BLOCK %]
412     [% Asset.js("js/admin-menu.js") | $raw %]
413     [% INCLUDE 'greybox.inc' %]
414     [% INCLUDE 'datatables.inc' %]
415     <script>
416          $(document).ready(function() {
417             $('#icons').tabs();
418             $("#table_item_type").dataTable($.extend(true, {}, dataTablesDefaults, {
419                 "aoColumnDefs": [
420                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
421                 ],
422                 "aaSorting": [[ 2, "asc" ]],
423                 "iDisplayLength": 10,
424                 "sPaginationType": "four_button"
425             }));
426             $( "#itemtypeentry" ).validate({
427                 rules: {
428                     itemtype: { required: true },
429                     description: { required: true },
430                     rentalcharge: { number: true }
431                 }
432             });
433             $("#itemtype").on("blur",function(){
434                 toUC(this);
435             });
436          });
437     </script>
438 [% END %]
439
440 [% INCLUDE 'intranet-bottom.inc' %]