Merge remote-tracking branch 'origin/new/bug_8062'
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / additem.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Cataloging &rsaquo; [% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %]) &rsaquo; Items</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 <script type="text/javascript">
5 //<![CDATA[
6 $(document).ready(function(){
7     [% IF (popup) %]
8         [% IF (opisadd) %]
9             window.close();
10         [% END %]
11     [% END %]
12                 $("fieldset.rows input").keydown(function(e){ return checkEnter(e); });
13                 /* Inline edit/delete links */
14                 var biblionumber = $("input[name='biblionumber']").attr("value");
15                 $("td").click(function(event){
16                         var $tgt = $(event.target);
17                         if($tgt.is("a")||$tgt.is(":first-child")||$tgt.is(":nth-child(2)")){ return true; } else {
18                         var rowid = $(this).parent().attr("id");
19                         num_rowid = rowid.replace("row","");
20                         $(".linktools").remove();
21                         $(this).append("<span class=\"linktools\"><a href=\"/cgi-bin/koha/cataloguing/additem.pl?op=edititem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber="+num_rowid+"#edititem\">Edit Item</a> <a href=\"/cgi-bin/koha/cataloguing/additem.pl?op=delitem&frameworkcode=[% frameworkcode %]&biblionumber=[% biblionumber %]&itemnumber="+num_rowid+"\" onclick=\"confirm_deletion([% biblionumber %],"+num_rowid+"); return false;\">Delete Item</a></span>");
22                 }
23                 });
24 });
25 function active(numlayer)
26 {
27     for (i=10; i < 11 ; i++ ) {
28         ong = i+"XX";
29             link = "link"+i;
30         if (numlayer==i) {
31             document.getElementById(ong).style.visibility="visible";
32             document.getElementById(link).style.backgroundColor="#11AA11";
33             document.getElementById(link).style.backgroundImage="url([% themelang %]/images/background-mem.gif)";
34         } else {
35             document.getElementById(ong).style.visibility="hidden";
36             document.getElementById(link).style.backgroundColor="#FFFFFF";
37             document.getElementById(link).style.backgroundImage="";
38         }
39     }
40 }
41 function Check(f) {
42     var total_errors=0;
43     $("input[name='mandatory'],select[name='mandatory']").each(function(i){
44         if($(this).val() == 1){
45             var mandatory_field = $("input[name='field_value'],select[name='field_value']").eq(i);
46             if(mandatory_field.val() == ''){
47                 mandatory_field.css("background-color","#FFFFCC");
48                 total_errors++;
49             }
50         }
51     });
52
53     var alertString2;
54     if (total_errors==0) {
55         return true;
56     } else {
57         alertString2  = _("Form not submitted because of the following problem(s)");
58         alertString2 += "\n------------------------------------------------------------------------------------\n";
59         alertString2 += "\n- "+ total_errors+_(" mandatory fields empty (highlighted)");
60         alert(alertString2);
61         return false;
62     }
63 }
64 function CheckMultipleAdd(f) {
65
66     if (!f || isNaN(f) || !parseInt(f) == f || f <= 0) {
67         alert(_("Please enter a number of items to create."));
68         return false;
69     }
70 }
71 function Dopop(link,i) {
72     defaultvalue=document.forms[0].field_value[i].value;
73     newin=window.open(link+"&result="+defaultvalue,"valuebuilder",'width=500,height=400,toolbar=false,scrollbars=yes');
74 }
75
76 function confirm_deletion(biblionumber,itemnumber) {
77         var original = $("#row"+itemnumber).attr("class");
78         $("#row"+itemnumber).attr("class","confirm");
79     var is_confirmed = confirm(_("Are you sure you want to delete this item?"));
80     if (is_confirmed) {
81     window.location = "additem.pl?op=delitem&biblionumber="+biblionumber+"&itemnumber="+itemnumber;
82         } else {
83         $("#row"+itemnumber).attr("class","");
84     }
85 }
86
87 function CloneSubfield(index){
88     var original = document.getElementById(index); //original <div>
89     var clone = original.cloneNode(true);
90     var new_key = CreateKey();
91     var old_id =  original.getAttribute('id');
92     old_id=old_id.substr(12);
93     var new_id  = old_id+new_key;
94
95     // set the attribute for the new 'div' subfields
96     var inputs     = clone.getElementsByTagName('input');
97     var selects    = clone.getElementsByTagName('select');
98     var textareas  = clone.getElementsByTagName('textarea');
99
100     // input
101     var id_input = "";
102     for(var i=0,len=inputs.length; i<len ; i++ ){
103         id_input = inputs[i].getAttribute('id')+new_key;
104         inputs[i].setAttribute('id',id_input);
105         inputs[i].setAttribute('name',inputs[i].getAttribute('name'));
106     }
107
108     // select
109     for(var i=0,len=selects.length; i<len ; i++ ){
110         id_input = selects[i].getAttribute('id')+new_key;
111         selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key);
112         selects[i].setAttribute('name',selects[i].getAttribute('name'));
113     }
114
115     // textarea
116     for(var i=0,len=textareas.length; i<len ; i++ ){
117         id_input = textareas[i].getAttribute('id')+new_key;
118         textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key);
119         textareas[i].setAttribute('name',textareas[i].getAttribute('name'));
120     }
121
122     [% UNLESS ( advancedMARCEditor ) %]
123     // when cloning a subfield, reset its label too.
124     var label = clone.getElementsByTagName('label')[0];
125     label.setAttribute('for',id_input);
126     [% END %]
127
128     // setting a new if for the parent div
129     clone.setAttribute('id',new_id);
130
131     var CloneButtonPlus;
132     try {
133       var spans = clone.getElementsByTagName('span');
134       if(spans.length){
135           for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){
136             if(spans[i].getAttribute('class') == 'buttonPlus'){
137                     CloneButtonPlus = spans[i];
138                     CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + new_id + "')");
139                     var buttonUp = clone.getElementsByTagName('img')[0];
140                     buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
141                 }
142             }
143         }
144     }
145     catch(e){
146         // do nothing if ButtonPlus & CloneButtonPlus don't exist.
147     }
148     // insert this line on the page
149     original.parentNode.insertBefore(clone,original.nextSibling);
150 }
151
152 /**
153  * This function creates a random number
154  */
155 function CreateKey(){
156     return parseInt(Math.random() * 100000);
157 }
158
159 $(document).ready(function() {
160     $("#cataloguing_additem_itemlist  tr").hover(
161         function () {$(this).attr("class","highlight");},
162         function () {$(this).attr("class",""         );}
163     );
164 });
165 //]]>
166 </script>
167 <link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
168 </head>
169 <body id="cat_additem" class="cat">
170 [% INCLUDE 'header.inc' %]
171 <div id="breadcrumbs">
172           <a href="/cgi-bin/koha/mainpage.pl">Home</a>
173  &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>
174  &rsaquo; Edit <a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]">[% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %])</a>
175  &rsaquo; <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]">Items</a>
176 </div>
177
178 <div id="doc3" class="yui-t7">
179
180    <div id="bd">
181         <div id="yui-main">
182
183 <h1>Items for [% title |html %] [% IF ( author ) %] by [% author %][% END %] (Record #[% biblionumber %])</h1>
184
185 [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
186 [% 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 %]
187 [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: item is checked out.</div>[% END %]
188 [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot Delete</strong>: item has a waiting hold.</div>[% END %]
189 [% IF ( not_same_branch ) %]<div class="dialog alert"><strong>Cannot Delete</strong>: The items do not belong to your library.</div>[% END %]
190 [% 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 %]
191
192 <div id="cataloguing_additem_itemlist">
193     [% IF ( item_loop ) %]
194         <div>
195         <table>
196             <tr>
197                 <th colspan="2">&nbsp;</th>
198                 [% FOREACH item_header_loo IN item_header_loop %]
199                     <th>
200                         [% item_header_loo.header_value %]
201                     </th>
202                 [% END %]
203             </tr>
204                 [% FOREACH item_loo IN item_loop %]
205                 <tr id="row[% item_loo.itemnumber %]">
206                     [% IF ( item_loo.nomod ) %] <td colspan="2">&nbsp;</td>[% ELSE %][% IF ( item_loo.hostitemflag ) %]<td><a href="additem.pl?op=edititem&amp;biblionumber=[% item_loo.hostbiblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit in host</a></td>
207 <td><a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delinkitem&amp;biblionumber=[% biblionumber %]&amp;hostitemnumber=[% item_loo.itemnumber %]">Delink</a></td>
208 [% ELSE %]<td><a href="additem.pl?op=edititem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]#edititem">Edit</a></td>
209                     <td>[% IF ( item_loo.countanalytics ) %]<a href="/cgi-bin/koha/catalogue/search.pl?idx=hi&amp;q=% item_loo.itemnumber %]">View analytics</a>[% ELSE %]<a class="delete" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&amp;biblionumber=[% biblionumber %]&amp;itemnumber=[% item_loo.itemnumber %]" onclick="confirm_deletion([% biblionumber %],[% item_loo.itemnumber %]); return false;">Delete</a>[% END %]</td>[% END %][% END %]
210                 [% FOREACH item_valu IN item_loo.item_value %]
211                     <td>[% item_valu.field |html %]</td>
212                 [% END %]
213                 </tr>
214                 [% END %]
215         </table>
216         </div>
217     [% END %]
218 </div>
219 <div class="yui-gf">
220 <div class="yui-u first">
221 [% INCLUDE 'biblio-view-menu.inc' %]
222 </div>
223 <div class="yui-u">
224 <div id="cataloguing_additem_newitem">
225     <form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
226     <input type="hidden" name="op" value="[% op %]" />
227     [% IF (popup) %]
228         <input type="hidden" name="popup" value="1" />
229     [% END %]
230     <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
231     [% IF ( opisadd ) %]
232         <h2 id="additema">Add item</h2>
233     [% ELSE %]
234         <h2 id="edititem">Edit Item #[% itemnumber %][% IF ( barcode ) %] / Barcode [% barcode %][% END %]</h2>
235     [% END %]
236         <fieldset class="rows">
237         <ol>
238         [% FOREACH ite IN item %]
239                <li><div class="subfield_line" style="[% ite.visibility %]" id="subfield[% ite.tag %][% ite.subfield %][% ite.random %]">
240                 [% IF ( ite.mandatory ) %]
241                <label class="required">[% ite.subfield %] - [% ite.marc_lib %]</label>
242                [% ELSE %]
243                <label>[% ite.subfield %] - [% ite.marc_lib %]</label>
244                [% END %]
245                 [% ite.marc_value %]
246                 <input type="hidden" name="tag"       value="[% ite.tag %]" />
247                 <input type="hidden" name="subfield"  value="[% ite.subfield %]" />
248                 <input type="hidden" name="mandatory" value="[% ite.mandatory %]" />
249                 [% IF ( ite.repeatable ) %]
250                     <span class="buttonPlus" onclick="CloneSubfield('subfield[% ite.tag %][% ite.subfield %][% ite.random %]')">+</span>
251                 [% END %]
252                 [% IF ( ite.mandatory ) %] <span class="required">Required</span>[% END %]
253             </div></li>
254         [% END %]
255     </ol>
256     </fieldset>
257     <input type="hidden" name="indicator" value=" " />
258     <input type="hidden" name="indicator" value=" " />
259     <input type="hidden" name="itemnumber" value="[% itemnumber %]" />
260
261 <fieldset class="action">    [% IF ( opisadd ) %]
262     <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
263     <!-- 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 copies
264                 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.
265                 It is a bit tricky, but necessary in the sake of UI correctness.
266     -->
267
268     <input type="submit" name="add_submit" value="Add item" onclick="return Check(this.form)" />
269     <input type="submit" name="add_duplicate_submit" value="Add &amp; Duplicate" onclick="return Check(this.form)" />
270     <input type="submit" name="add_multiple_copies" value="Add Multiple Copies" onclick="javascript:this.nextSibling.style.visibility='visible';document.f.number_of_copies.focus(); return false;" /><span id="add_multiple_copies_span" style="visibility:hidden">
271         <label for="number_of_copies">Number of copies to add : </label>
272         <input type="text" id="number_of_copies" name="number_of_copies" value="" size="2" />
273         <input type="submit" id="add_multiple_copies_submit" name="add_multiple_copies_submit" value="Add" onclick="javascript:return Check(this.form) &amp;&amp; CheckMultipleAdd(this.form.number_of_copies.value);" />
274     </span>
275
276     [% ELSE %]
277     <input type="hidden" name="tag" value="[% itemtagfield %]" />
278     <input type="hidden" name="subfield" value="[% itemtagsubfield %]" />
279     <input type="hidden" name="field_value" value="[% itemnumber %]" />
280     <input type="submit" value="Save Changes" onclick="return Check(this.form)" />
281     [% END %]</fieldset>
282     
283     <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
284     <input type="hidden" name="stickyduedate" value="[% stickyduedate %]" />
285     <input type="hidden" name="barcode" value="[% barcode %]" />
286     <input type="hidden" name="duedatespec" value="[% duedatespec %]" />
287
288
289     </form>
290 </div>
291 </div><!-- /yui-u -->
292 </div><!-- /yui-gf -->
293
294 </div>
295 </div>
296 [% INCLUDE 'intranet-bottom.inc' %]