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