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