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