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