Bug 20538: Remove the need of writing [% KOHA_VERSION %] everywhere
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / additem.tt
1 [% USE Asset %]
2 [% USE Koha %]
3 [% USE ColumnsSettings %]
4
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Cataloging &rsaquo; [% title |html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber %]) &rsaquo; Items</title>
7 [% Asset.css("css/datatables.css") %]
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% INCLUDE 'datatables.inc' %]
10 [% Asset.js("js/cataloging.js") %]
11 [% INCLUDE 'columns_settings.inc' %]
12 [% INCLUDE 'browser-strings.inc' %]
13 [% Asset.js("js/browser.js") %]
14 <script type="text/javascript">
15 //<![CDATA[
16     var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10));
17     browser.show();
18
19 $(document).ready(function(){
20
21     // Remove the onclick event defined in browser.js,
22     // otherwise the deletion confirmation will not work correctly
23     $('a[href*="biblionumber="]').off('click');
24
25     [% IF (popup) %]
26         [% IF (opisadd) %]
27             window.close();
28         [% END %]
29     [% END %]
30             $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
31             /* Inline edit/delete links */
32             var biblionumber = $("input[name='biblionumber']").attr("value");
33             $("tr.editable").each(function(){
34                 $(this).find("td:not(:first)").on('click', function(){
35                     var rowid = $(this).parent().attr("id");
36                     num_rowid = rowid.replace("row","");
37                     $(".linktools").remove();
38                     var edit_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber='+num_rowid+'&searchid=[% searchid %]#edititem"></a>');
39                     $(edit_link).text(_("Edit item"));
40                     var delete_link = $('<a href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber='+num_rowid+'&searchid=[% searchid %]"></a>');
41                     $(delete_link).text(_("Delete item"));
42                     $(delete_link).on('click', function(e) {
43                         return confirm_deletion();
44                     });
45                     var tools_node = $('<span class="linktools"></span>');
46                     $(tools_node).append(edit_link);
47                     $(tools_node).append(delete_link);
48                     $(this).append(tools_node);
49                 });
50             });
51
52     $("#addnewitem").click(function(){
53         if ( confirm(_("Are you sure you want to add a new item? Any changes made on this page will be lost.")) ){
54             window.location.href = "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]";
55         }
56     });
57
58     var columns_settings = [% ColumnsSettings.GetColumns( 'cataloguing', 'additem', 'itemst', 'json' ) %]
59     // Skip the first column
60     columns_settings.unshift( { cannot_be_toggled: "1" } );
61
62     var itemst = KohaTable("itemst", {
63         "aoColumnDefs": [
64           { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
65         ],
66         'bPaginate': false,
67         'bInfo': false,
68         "bAutoWidth": false,
69         "bKohaColumnsUseNames": true
70     }, columns_settings);
71
72     var multiCopyControl = $("#add_multiple_copies_span");
73     var addMultipleBlock = $("#addmultiple");
74     var addSingleBlock = $("#addsingle");
75     multiCopyControl.hide();
76     $("#add_multiple_copies").on("click",function(e){
77         e.preventDefault;
78         addMultipleBlock.toggle();
79         addSingleBlock.toggle();
80         multiCopyControl.toggle();
81         $('body,html').animate({ scrollTop: $('body').height() }, 100);
82     });
83     $("#cancel_add_multiple").on("click",function(e){
84         e.preventDefault();
85         addMultipleBlock.toggle();
86         addSingleBlock.toggle();
87         multiCopyControl.toggle();
88     });
89 });
90
91 function Check(f) {
92     var total_errors = CheckMandatorySubfields(f);
93     if (total_errors==0) {
94         // Explanation about this line:
95         // In case of limited edition permission, we have to prevent user from modifying some fields.
96         // But there is no such thing as readonly attribute for select elements.
97         // So we use disabled instead. But disabled prevent values from being passed through the form at submit.
98         // So we "un-disable" the elements just before submitting.
99         // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that.
100         $("select[name=field_value]").prop('disabled', false);
101         return true;
102     } else {
103         var alertString2 = _("Form not submitted because of the following problem(s)");
104         alertString2 += "\n------------------------------------------------------------------------------------\n";
105         alertString2 += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors);
106         alert(alertString2);
107         return false;
108     }
109     return true;
110 }
111 function CheckMultipleAdd(f) {
112
113     if (!f || isNaN(f) || !parseInt(f) == f || f <= 0) {
114         alert(_("Please enter a number of items to create."));
115         return false;
116     }
117     <!-- Add a soft-limit of 99 with a reminder about potential data entry error -->
118     if (f>99) {
119         return confirm(_("You are about to add %s items. Continue?").format(f));
120     }
121 }
122 function Dopop(link,i) {
123     defaultvalue=document.forms[0].field_value[i].value;
124     newin=window.open(link+"&result="+defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes');
125 }
126
127 function confirm_deletion() {
128     return confirm(_("Are you sure you want to delete this item?"));
129 }
130
131 //]]>
132 </script>
133 [% Asset.css("css/addbiblio.css") %]
134
135 [% INCLUDE 'select2.inc' %]
136 <script type="text/javascript">
137   $(document).ready(function() {
138     $('.subfield_line select').select2();
139   });
140 </script>
141
142 [% IF ( bidi ) %]
143    [% Asset.css("css/right-to-left.css") %]
144 [% END %]
145 </head>
146 <body id="cat_additem" class="cat">
147 [% INCLUDE 'header.inc' %]
148 [% INCLUDE 'cataloging-search.inc' %]
149
150 <div id="breadcrumbs">
151           <a href="/cgi-bin/koha/mainpage.pl">Home</a>
152  &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
153  &rsaquo; Edit <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]">[% title |html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber %])</a>
154  &rsaquo; <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]">Items</a>
155 </div>
156
157 <div id="doc3" class="yui-t7">
158
159    <div id="bd">
160         <div id="yui-main">
161
162 <h1>Items for [% title |html %] [% IF ( author ) %] by [% author | html %][% END %] (Record #[% biblionumber %])</h1>
163
164 [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
165 [% 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 %]
166 [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
167 [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot delete</strong>: item has a waiting hold.</div>[% END %]
168 [% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot delete</strong>: The items do not belong to your library.</div>[% END %]
169 [% IF ( linked_analytics ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item has linked <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]&amp;analyze=1">analytics.</a>.</div>[% END %]
170
171 <div id="cataloguing_additem_itemlist">
172     [% IF ( item_loop ) %]
173         <div>
174         <table id="itemst">
175           <thead>
176             <tr>
177                 <th>&nbsp;</th>
178                 [% FOREACH item_header IN item_header_loop %]
179                     [% IF item_header.column_name %]
180                         <th data-colname="[% item_header.column_name %]">
181                     [% ELSE %]
182                         <th>
183                     [% END %]
184                         [% item_header.header_value %]
185                     </th>
186                 [% END %]
187             </tr>
188           </thead>
189           <tbody>
190                 [% FOREACH item_loo IN item_loop %]
191                     [% IF ( item_loo.itemnumber == itemnumber) %]
192                         [% IF item_loo.nomod %]
193                            <tr id="row[% item_loo.itemnumber %]" class="active">
194                         [% ELSE %]
195                             <tr id="row[% item_loo.itemnumber %]" class="active editable">
196                         [% END %]
197                     [% ELSE %]
198                         [% IF item_loo.nomod %]
199                            <tr id="row[% item_loo.itemnumber %]">
200                         [% ELSE %]
201                             <tr id="row[% item_loo.itemnumber %]" class="editable">
202                         [% END %]
203                     [% END %]
204                     [% IF ( item_loo.nomod ) %]
205                       <td>&nbsp;</td>
206                     [% ELSE %]
207                       <td>
208                           <div class="dropdown">
209                           <a class="btn btn-default btn-xs dropdown-toggle" id="itemactions[% item_loo.itemnumber %]" role="button" data-toggle="dropdown" href="#">
210                               Actions <b class="caret"></b>
211                           </a>
212                           <ul class="dropdown-menu" role="menu" aria-labelledby="itemactions[% item_loo.itemnumber %]">
213
214                         [% IF ( item_loo.hostitemflag ) %]
215                               <li><a href="additem.pl?op=edititem&amp;biblionumber=[% item_loo.hostbiblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit in host</a> &nbsp; <a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&amp;biblionumber=[% biblionumber %]&amp;hostitemnumber=[% item_loo.itemnumber %]&amp;searchid=[% searchid %]">Delink</a></li>
216                         [% ELSE %]
217                               <li><a href="additem.pl?op=edititem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]&amp;searchid=[% searchid %]#edititem">Edit</a></li>
218                               <li><a href="additem.pl?op=dupeitem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]&amp;searchid=[% searchid %]#additema">Duplicate</a></li>
219                               <li class="print_label"><a href="/cgi-bin/koha/labels/label-edit-batch.pl?op=add&amp;number_type=itemnumber&amp;number_list=[% item_loo.itemnumber %]" target="_blank" >Print Label</a></li>
220                           [% IF ( item_loo.countanalytics ) %]
221                               <li><a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&amp;q=% item_loo.itemnumber %]">View analytics</a></li>
222                           [% ELSE %]
223                               <li><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]&amp;searchid=[% searchid %]" onclick="return confirm_deletion();">Delete</a></li>
224                           [% END %]
225                         [% END %]
226                             [% IF ( OPACBaseURL ) %]
227                                 <li class="view-in-opac"><a target="_blank" href="[% Koha.Preference('OPACBaseURL') %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]">OPAC view</a></li>
228                             [% END %]
229                           </ul>
230                           </div>
231                       </td>
232                     [% END %]
233                 [% FOREACH item_valu IN item_loo.item_value %]
234                     <td>[% item_valu.field |html %]</td>
235                 [% END %]
236                 </tr>
237                 [% END %]
238           </tbody>
239         </table>
240         </div>
241     [% END %]
242 </div>
243 <div class="yui-gf">
244 <div class="yui-u first">
245 [% INCLUDE 'biblio-view-menu.inc' %]
246 </div>
247 <div class="yui-u">
248 <div id="cataloguing_additem_newitem">
249     <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
250     <input type="hidden" name="op" value="[% op %]" />
251     [% IF (popup) %]
252         <input type="hidden" name="popup" value="1" />
253     [% END %]
254     <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
255     [% IF ( opisadd ) %]
256         <h2 id="additema">Add item [% IF (circborrowernumber) %]<em>(fast cataloging)</em>[% END %]</h2>
257     [% ELSE %]
258         <h2 id="edititem">Edit Item #[% itemnumber %][% IF ( barcode ) %] / Barcode [% barcode %][% END %]</h2>
259     [% END %]
260         <fieldset class="rows">
261         <ol>
262         [% FOREACH ite IN item %]
263                <li><div class="subfield_line" style="[% ite.visibility %]" id="subfield[% ite.tag %][% ite.subfield %][% ite.random %]">
264                 [% IF ( ite.mandatory ) %]
265                <label class="required">[% ite.subfield %] - [% ite.marc_lib %]</label>
266                [% ELSE %]
267                <label>[% ite.subfield %] - [% ite.marc_lib %]</label>
268                [% END %]
269
270                 [% SET mv = ite.marc_value %]
271                 [% IF ( mv.type == 'hidden' ) %]
272                     <input type="hidden" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]">
273                 [% ELSIF ( mv.type == 'select' ) %]
274                     [% IF ( mv.readonly ) %]
275                         <select name="field_value" id="[%- mv.id -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
276                     [% ELSE %]
277                         <select name="field_value" id="[%- mv.id -%]" size="1" class="input_marceditor">
278                     [% END %]
279                     [% FOREACH aval IN mv.values %]
280                         [% IF aval == mv.default %]
281                         <option value="[%- aval -%]" selected="selected">[%- mv.labels.$aval -%]</option>
282                         [% ELSE %]
283                         <option value="[%- aval -%]">[%- mv.labels.$aval -%]</option>
284                         [% END %]
285                     [% END %]
286                     </select>
287                 [% ELSIF ( mv.type == 'text_auth' ) %]
288                     [% IF mv.readonly %]
289                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" readonly="readonly" />
290                     [% ELSE %]
291                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
292                         [% SET dopop = "Dopop('/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=\"${mv.authtypecode}\"&index=${mv.id}','${mv.id}')" %]
293                         <a href="#" class="buttonDot"  onclick="[%- dopop -%]; return false;" title="Tag editor">...</a>
294                     [% END %]
295                 [% ELSIF ( mv.type == 'text_plugin' ) %]
296                     [% IF mv.readonly %]
297                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" readonly="readonly" />
298                     [% ELSE %]
299                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
300                         [% IF ( mv.nopopup ) %]
301                             <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="No popup">...</a>
302                         [% ELSE  %]
303                             <a href="#" id="buttonDot_[%- mv.id -%]" class="[%- mv.class -%]" title="Tag editor">...</a>
304                         [% END %]
305                         [%- mv.javascript -%]
306                     [% END %]
307                 [% ELSIF ( mv.type == 'text' ) %]
308                     [% IF mv.readonly %]
309                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" readonly="readonly" />
310                     [% ELSE %]
311                         <input type="text" id="[%- mv.id -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
312                     [% END %]
313                 [% ELSIF ( mv.type == 'textarea' ) %]
314                     [% IF mv.readonly %]
315                         <textarea id="[%- mv.id -%]" name="field_value" class="input_marceditor" rows="5" cols="64" readonly="readonly" >[% mv.value %]</textarea>
316                     [% ELSE %]
317                         <textarea id="[%- mv.id -%]" name="field_value" class="input_marceditor" rows="5" cols="64" >[% mv.value %]</textarea>
318                     [% END %]
319                 [% END %]
320
321                 <input type="hidden" name="tag"       value="[% ite.tag %]" />
322                 <input type="hidden" name="subfield"  value="[% ite.subfield %]" />
323                 <input type="hidden" name="mandatory" value="[% ite.mandatory %]" />
324                 [% IF ( ite.repeatable ) %]
325                     <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode); return false;">
326                         <img src="[% interface %]/[% theme %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
327                     </a>
328                 [% END %]
329                 [% IF ( ite.mandatory ) %] <span class="required">Required</span>[% END %]
330             </div></li>
331         [% END %]
332     </ol>
333     </fieldset>
334     <input type="hidden" name="indicator" value=" " />
335     <input type="hidden" name="indicator" value=" " />
336     <input type="hidden" name="itemnumber" value="[% itemnumber %]" />
337
338 <fieldset class="action">    [% IF ( opisadd ) %]
339     <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
340     <!-- 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
341                 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.
342                 It is a bit tricky, but necessary in the sake of UI correctness.
343     -->
344     <span id="addsingle">
345         <input type="submit" name="add_submit" value="Add item" onclick="return Check(this.form)" />
346         <input type="submit" name="add_duplicate_submit" value="Add &amp; duplicate" onclick="return Check(this.form)" />
347     </span>
348     <span id="addmultiple">
349         <input type="button" name="add_multiple_copies" id="add_multiple_copies" value="Add multiple copies of this item" />
350     </span>
351     <fieldset id="add_multiple_copies_span">
352         <label for="number_of_copies">Number of copies of this item to add: </label>
353         <input type="text" id="number_of_copies" name="number_of_copies" value="" size="2" />
354         <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>
355         <div class="hint"><p>The barcode you enter will be incremented for each additional item.</p></div>
356     </fieldset>
357
358     [% ELSE %]
359     <input type="hidden" name="tag" value="[% itemtagfield %]" />
360     <input type="hidden" name="subfield" value="[% itemtagsubfield %]" />
361     <input type="hidden" name="field_value" value="[% itemnumber %]" />
362     <input type="submit" value="Save changes" onclick="return Check(this.form)">
363     <input type="button" id="addnewitem" value="Add a new item">
364     <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]">Cancel</a>
365     [% END %]</fieldset>
366     
367     [%# Fields for fast cataloging %]
368     <input type="hidden" name="circborrowernumber" value="[% circborrowernumber %]" />
369     <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
370     <input type="hidden" name="barcode" value="[% barcode %]" />
371     <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
372     [%# End fields for fast cataloging %]
373
374
375     </form>
376 </div>
377 </div><!-- /yui-u -->
378 </div><!-- /yui-gf -->
379
380 </div>
381 </div>
382 [% INCLUDE 'intranet-bottom.inc' %]