Bug 34571: Remove use of "onclick" for ExpandField in cataloguing editors
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / additem.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE Branches %]
5 [% USE KohaDates %]
6 [% USE Price %]
7 [% USE TablesSettings %]
8 [% PROCESS 'i18n.inc' %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Items &rsaquo; [% biblio.title | html %] [% IF ( biblio.author ) %] by [% biblio.author | html %][% END %] (Record #[% biblio.biblionumber | html %]) &rsaquo; Cataloging &rsaquo; Koha</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 [% Asset.css("css/addbiblio.css") | $raw %]
13 [% INCLUDE 'datatables.inc' %]
14 <script>
15     [% IF Koha.Preference('CreateAVFromCataloguing') && CAN_user_parameters_manage_auth_values %]
16         var auth_values_creation = 1;
17     [% ELSE %]
18         var auth_values_creation = 0;
19     [% END %]
20 </script>
21 [% INCLUDE 'select2.inc' %]
22 [% Asset.js("js/cataloging.js") | $raw %]
23 [% INCLUDE 'columns_settings.inc' %]
24 [% Asset.js("js/browser.js") | $raw %]
25 [% INCLUDE 'calendar.inc' %]
26 [% INCLUDE 'str/cataloging_additem.inc' %]
27 [% Asset.js("js/cataloging_additem.js") | $raw %]
28     <script>
29         var has_item_groups = "[% item_groups.size | html %]";
30     </script>
31 </head>
32
33 <body id="cat_additem" class="cat">
34 [% WRAPPER 'header.inc' %]
35     [% INCLUDE 'cataloging-search.inc' %]
36 [% END %]
37
38 [% WRAPPER 'sub-header.inc' %]
39     [% WRAPPER breadcrumbs %]
40         [% WRAPPER breadcrumb_item %]
41             <a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
42         [% END %]
43         [% WRAPPER breadcrumb_item %]
44             <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblio.biblionumber | uri %]">
45                 [% IF ( biblio.author ) %]
46                     [% tx('Edit {title} by {author}', { title = biblio.title, author = biblio.author }) | html %] ([% tp('Bibliographic record number', 'Record #') | html %] [% biblio.biblionumber | html %])
47                 [% ELSE %]
48                     [% tx('Edit {title}', title = biblio.title) | html %] ([% tp('Bibliographic record number', 'Record #') | html %] [% biblio.biblionumber | html %])
49                 [% END %]
50             </a>
51         [% END %]
52         [% WRAPPER breadcrumb_item bc_active= 1 %]
53             [%  tp('Items attached to a bibliographic record', 'Items') | html %]
54         [% END %]
55     [% END #/ WRAPPER breadcrumbs %]
56 [% END #/ WRAPPER sub-header.inc %]
57
58 <div class="main container-fluid">
59     <div class="row">
60         <div class="col-sm-12">
61             <main>
62                 [% IF item_doesnt_exist %]
63                     <div class="dialog alert">
64                         <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblio.biblionumber | uri %]">Add a new item</a> or <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]#holdings">go to the records holdings</a>.
65                     </div>
66                 [% END %]
67                 [% INCLUDE 'blocking_errors.inc' %]
68 <h1>Items for [% biblio.title | html %] [% IF ( biblio.author ) %] by [% biblio.author | html %][% END %] (Record #[% biblio.biblionumber | html %])</h1>
69
70 [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
71 [% IF ( no_next_barcode ) %]<div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div>[% END %]
72 [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
73 [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot delete</strong>: item has a waiting hold.</div>[% END %]
74 [% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot delete</strong>: The items do not belong to your library.</div>[% END %]
75 [% IF ( linked_analytics ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item has linked <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]&amp;analyze=1">analytics.</a>.</div>[% END %]
76 [% IF last_item_for_hold %]<div class="dialog alert"><strong>Cannot delete</strong>: Last item for bibliographic record with biblio-level hold on it.</div>[% END %]
77 [% IF item_not_found %]<div class="dialog alert"><strong>Cannot delete</strong>: Item not found.</div>[% END %]
78
79 <div id="cataloguing_additem_itemlist">
80     [% IF items %]
81         [% SET date_fields = [ 'dateaccessioned', 'onloan', 'datelastseen', 'datelastborrowed', 'replacementpricedate' ] %]
82         <div class="page-section">
83             <table id="itemst">
84             <thead>
85                 <tr>
86                     <th class="NoSort">&nbsp;</th>
87                     [% FOREACH item_header IN item_header_loop %]
88                         <th data-colname="[% item_header.attribute | html %]">
89                             [% item_header.header_value | html %]
90                         </th>
91                     [% END %]
92                 </tr>
93             </thead>
94             <tbody>
95                     [% FOREACH item IN items %]
96                         [% SET can_be_edited = ! ( Koha.Preference('IndependentBranches') && ! logged_in_user.is_superlibrarian && item.homebranch != Branches.GetLoggedInBranchname() ) %]
97                         [% IF item.itemnumber == itemnumber%]
98                             [% UNLESS can_be_edited %]
99                             <tr id="row[% item.itemnumber | html %]" class="active">
100                             [% ELSE %]
101                                 <tr id="row[% item.itemnumber | html %]" class="active editable">
102                             [% END %]
103                         [% ELSE %]
104                             [% UNLESS can_be_edited %]
105                             <tr id="row[% item.itemnumber | html %]">
106                             [% ELSE %]
107                                 <tr id="row[% item.itemnumber | html %]" class="editable">
108                             [% END %]
109                         [% END %]
110                         [% UNLESS can_be_edited %]
111                         <td>&nbsp;</td>
112                         [% ELSE %]
113                         <td>
114                             <div class="btn-group dropup">
115                             <a class="btn btn-default btn-xs dropdown-toggle" id="itemactions[% item.itemnumber | html %]" role="button" data-toggle="dropdown" href="#">
116                                 Actions <b class="caret"></b>
117                             </a>
118                             <ul class="dropdown-menu" role="menu" aria-labelledby="itemactions[% item.itemnumber | html %]">
119
120                             [% IF item.biblionumber != biblio.biblionumber %] [%# Host item %]
121                                 <li><a href="additem.pl?op=edititem&amp;biblionumber=[% item.biblionumber | uri %]&amp;itemnumber=[% item.itemnumber | uri %]#edititem">Edit in host</a> &nbsp; <a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&amp;biblionumber=[% biblio.biblionumber | html %]&amp;hostitemnumber=[% item.itemnumber | html %]&amp;searchid=[% searchid | html %]">Delink</a></li>
122                             [% ELSE %]
123                                 [% UNLESS item.nomod %]
124                                     <li><a href="additem.pl?op=edititem&amp;biblionumber=[% biblio.biblionumber | uri %]&amp;itemnumber=[% item.itemnumber | uri %]&amp;searchid=[% searchid | uri %]#edititem">Edit</a></li>
125                                 [% END %]
126                                 <li><a href="additem.pl?op=dupeitem&amp;biblionumber=[% biblio.biblionumber | uri %]&amp;itemnumber=[% item.itemnumber | uri %]&amp;searchid=[% searchid | uri %]#additema">Duplicate</a></li>
127                                 <li class="print_label"><a href="/cgi-bin/koha/labels/label-edit-batch.pl?op=add&amp;number_type=itemnumber&amp;number_list=[% item.itemnumber | uri %]" target="_blank" >Print label</a></li>
128                                 [% UNLESS item.nomod %]
129                                     <li><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&amp;biblionumber=[% item.biblionumber | html %]&amp;itemnumber=[% item.itemnumber | html %]&amp;searchid=[% searchid | html %]" onclick="return confirm_deletion();">Delete</a></li>
130                                 [% END %]
131                             [% END %]
132                                 [% IF ( OPACBaseURL ) %]
133                                     <li class="view-in-opac"><a target="_blank" href="[% Koha.Preference('OPACBaseURL') | url %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% item.biblionumber | uri %]">OPAC view</a></li>
134                                 [% END %]
135                             </ul>
136                             </div>
137                         </td>
138                         [% END %]
139                     [% FOREACH header IN item_header_loop %]
140                         [% SET attribute = header.attribute %]
141                         [% SET can_mod = item.nomod ? "nomod" : "canmod" %]
142                         [% IF header.attribute AND date_fields.grep('^' _ attribute _ '$').size %]
143                             [% IF header.attribute == 'datelastseen' %]
144                                 <td class="[% can_mod | html %]" data-order="[% item.$attribute | html %]">[% item.$attribute | $KohaDates with_hours => 1 %]</td>
145                             [% ELSE %]
146                                 <td class="[% can_mod | html %]" data-order="[% item.$attribute | html %]">[% item.$attribute | $KohaDates %]</td>
147                             [% END %]
148                         [% ELSIF ( item.$attribute && ( attribute == 'price' || attribute == 'replacementprice' ) ) %]
149                             <td class="[% can_mod | html %]" data-order="[% item.$attribute | html %]">[% item.$attribute | $Price %]</td>
150                         [% ELSE %]
151                             <td class="[% can_mod | html %]">[% item.$attribute | html %]</td>
152                         [% END %]
153                     [% END %]
154                     </tr>
155                     [% END %]
156             </tbody>
157             </table>
158         </div> <!-- /.page-section -->
159     [% END %]
160
161 <div class="row">
162     <div class="col-sm-2">
163         [% INCLUDE 'biblio-view-menu.inc' %]
164     </div>
165     <div class="col-sm-10">
166
167 <div id="cataloguing_additem_newitem" class="item_edit_form page-section">
168     <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblio.biblionumber | html %]" name="f">
169     <input type="hidden" name="op" value="[% op | html %]" />
170     [% IF (popup) %]
171         <input type="hidden" name="popup" value="1" />
172     [% END %]
173     <input type="hidden" name="biblionumber" value="[% biblio.biblionumber | html %]" />
174     [% IF op != 'saveitem' %]
175         <h2 id="additema">Add item [% IF (circborrowernumber) %]<em>(fast cataloging)</em>[% END %]</h2>
176     [% ELSE %]
177         <h2 id="edititem">Edit item #[% itemnumber | html %][% IF ( barcode ) %] / Barcode [% barcode | html %][% END %]</h2>
178     [% END %]
179
180     [% IF item_templates.owned.count || item_templates.shared.count %]
181         <div id="item-template-toolbar" class="btn-toolbar">
182             <div class="btn-group">
183                 <select name="template_id" id="template_id" class="select2" style="width: 20em">
184                     <option value="0" selected="selected">Do not use template</option>
185                     <optgroup label="My templates">
186                         [% FOREACH t IN item_templates.owned %]
187                             [% IF t.id == template_id %]
188                                 <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
189                             [% ELSE %]
190                                 <option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
191                             [% END %]
192                         [% END %]
193                     </optgroup>
194                     <optgroup label="Shared templates">
195                         [% FOREACH t IN item_templates.shared %]
196                             [% IF t.id == template_id %]
197                                 [% IF CAN_user_editcatalogue_manage_item_editor_templates %]
198                                     <option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
199                                 [% ELSE %]
200                                     <option data-editor="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
201                                 [% END %]
202                             [% ELSE %]
203                                 [% IF CAN_user_editcatalogue_manage_item_editor_templates %]
204                                     <option data-editor="1" value="[% t.id | html %]">[% t.name | html %]</option>
205                                 [% ELSE %]
206                                     <option data-editor="0" value="[% t.id | html %]">[% t.name | html %]</option>
207                                 [% END %]
208                             [% END %]
209                         [% END %]
210                     </optgroup>
211                 </select>
212             </div>
213             <div class="btn-group">
214                 <button type="submit" id="load_template_submit" name="load_template_submit" value="1"><i class="fa-solid fa-table-list"></i> Apply template</button>
215             </div>
216             <div class="btn-group">
217                 <label for="use_template_for_session">
218                     [% IF use_template_for_session %]
219                         <input type="checkbox" id="use_template_for_session" name="use_template_for_session" checked="checked">
220                     [% ELSE %]
221                         <input type="checkbox" id="use_template_for_session" name="use_template_for_session">
222                     [% END %]
223                 For session</label>
224             </div>
225
226             <div class="btn-group">
227                 <button type="submit" id="unload_template_submit" name="unload_template_submit" value="1"><i class="fa fa-eraser"></i> Clear template</button>
228             </div>
229
230             <div class="btn-group">
231                 <button type="submit" id="delete_template_submit" name="delete_template_submit" value="1" disabled><i class="fa fa-trash-can"></i> Delete template</button>
232             </div>
233         </div>
234     [% END %]
235
236         <fieldset class="rows">
237         [% PROCESS subfields_for_item subfields => subfields %]
238     </fieldset>
239     [% IF op != 'add_item' %]
240         <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
241     [% END %]
242
243 [% IF item_groups.size && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %]
244     <fieldset class="rows">
245         <legend><i class="fa fa-plus"></i> Add to item group</legend>
246         [% FOREACH ig IN item_groups %]
247             <input type="hidden" id="item-group-[% ig.id | html %]" value="[% ig.description | html %]" />
248         [% END %]
249         <p>
250             <label for="select_item_group">Options: </label>
251             <select name="item_group" id="item-group-add-or-create-form-select">
252                 <optgroup label="Use existing item group">
253                     [% FOREACH ig IN item_groups %]
254                         <option value="[% ig.id | html %]">[% ig.description | html %]</option>
255                     [% END %]
256                 </optgroup>
257                 <optgroup label="Other options">
258                     <option id="item-group-add-or-create-form-no-add" value="">Do not add to item group</option>
259                     <option value="create">Create new item group</option>
260                 </optgroup>
261             </select>
262         </p>
263
264         <p id="item-group-add-or-create-form-description-block">
265             <label for="item_group_description" class="required">Name: </label>
266             <input name="item_group_description" id="item-group-add-or-create-form-description" type="text" size="30" class="required" />
267             <span class="required">Required</span>
268         </p>
269     </fieldset>
270 [% END %]
271
272 <fieldset class="action">    [% IF op != 'saveitem' %]
273     <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
274     <!-- Note : We use here a false submit button because we have several submit buttons and we don't want the user to believe they validated the adding of multiple items
275                 when pressing the enter key, while in fact it is the first submit button that is validated, in our case the "add (single) item" button.
276                 It is a bit tricky, but necessary in the sake of UI correctness.
277     -->
278     <span id="addsingle">
279         <input type="submit" name="add_submit" value="Add item" onclick="return Check(this.form)" />
280         <input type="submit" name="add_duplicate_submit" value="Add &amp; duplicate" onclick="return Check(this.form)" />
281     </span>
282     <span id="addmultiple">
283         <input type="button" name="add_multiple_copies" id="add_multiple_copies" value="Add multiple copies of this item" />
284     </span>
285     <fieldset id="add_multiple_copies_span">
286         <label for="number_of_copies">Number of copies of this item to add: </label>
287         <input type="text" id="number_of_copies" name="number_of_copies" value="" size="2" maxlength="3" />
288         <input type="submit" id="add_multiple_copies_submit" name="add_multiple_copies_submit" value="Add" onclick="javascript:return Check(this.form) && CheckMultipleAdd(this.form.number_of_copies.value);" /> <a href="#" id="cancel_add_multiple" class="cancel">Cancel</a>
289         <div class="hint"><p>Maximum currently set to 1000. The barcode you enter will be incremented for each additional item.</p></div>
290     </fieldset>
291
292     <span id="savetemplate">
293         <input type="button" name="save_as_template" id="save_as_template" value="Save as template" />
294     </span>
295     <fieldset id="save_as_template_span">
296         <legend>Save template</legend>
297         <div class="btn-group">
298             <select name="replace_template_id" id="replace_template_id" class="select2" style="width: 20em">
299                 <option value="0" selected="selected">Save as new template</option>
300                 <optgroup label="Update existing template">
301                     [% FOREACH t IN item_templates.owned %]
302                         <option data-editor="1" data-shared="[% t.is_shared | html %]" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
303                     [% END %]
304                     [% IF CAN_user_editcatalogue_manage_item_editor_templates && item_templates.shared.count %]
305                         <optgroup label="Update shared template">
306                             [% FOREACH t IN item_templates.shared %]
307                                 <option data-editor="1" data-shared="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
308                             [% END %]
309                         </optgroup>
310                     [% END %]
311                 </optgroup>
312             </select>
313         </div>
314
315         <div class="btn-group">
316             <span id="template_name_block">
317                 <label for="template_name" class="required">Template name: </label>
318                 <input type="text" id="template_name" name="template_name" class="required"/>
319                 <span class="required">Required</span>
320             </span>
321         </div>
322
323         <div class="btn-group">
324             <label for="template_is_shared">
325                 <input type="checkbox" id="template_is_shared" name="template_is_shared"/>
326                 Share template
327             </label>
328         </div>
329
330         <div class="btn-group">
331             <input type="submit" id="save_as_template_submit" name="save_as_template_submit" value="Save" onclick="javascript:return CheckTemplateForm(this.form);" />
332             <a href="#" id="cancel_save_as_template" class="cancel">Cancel</a>
333         </div>
334     </fieldset>
335
336     [% ELSE %]
337     [% IF op != 'add_item' %]
338         <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
339     [% END %]
340     <input type="submit" value="Save changes" onclick="return Check(this.form)">
341     <input type="button" id="addnewitem" value="Add a new item">
342     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]">Cancel</a>
343     [% END %]</fieldset>
344
345     [%# Fields for fast cataloging %]
346     <input type="hidden" name="circborrowernumber" value="[% circborrowernumber | html %]" />
347     <input type="hidden" name="stickyduedate" value="[% stickyduedate | html %]" />
348     <input type="hidden" name="barcode" value="[% barcode | html %]" />
349     <input type="hidden" name="duedatespec" value="[% duedatespec | html %]" />
350     [%# End fields for fast cataloging %]
351
352
353     </form>
354
355     [% INCLUDE 'modals/cataloguing_create_av.inc' %]
356
357                             </div> <!-- /#cataloguing_additem_newitem -->
358                         </div> <!-- /.col-sm-10 -->
359                     </div> <!-- /.row -->
360                 </div> <!-- /#cataloguing_additem_itemlist -->
361             </main>
362         </div> <!-- /.col-sm-12 -->
363     </div> <!-- /.row -->
364
365 [% MACRO jsinclude BLOCK %]
366 [% END %]
367
368 [% INCLUDE 'intranet-bottom.inc' %]