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