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