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