bugfix for 2451 : serial recieve & barcode does exist complaint
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / serials-edit.tmpl
index fb2e4e6..5eb2bd4 100644 (file)
@@ -60,7 +60,6 @@ function Check(f) {
         alert(alertString2);
     }
 }
-<!--TMPL_IF Name="serialsadditems"-->
 function unHideItems(index,labelindex) {
        subfield = document.getElementById(index);
        subfield.style.display = 'block';
@@ -73,7 +72,70 @@ function HideItems(index,labelindex) {
        label = document.getElementById(labelindex);
        label.style.display='block';    
 }
-<!--/TMPL_IF>
+function CloneSubfield(index){
+    var original = document.getElementById(index); //original <div>
+    var clone = original.cloneNode(true);
+    var new_key = CreateKey();
+    var old_id =  original.getAttribute('id');
+    old_id=old_id.substr(12);
+    var new_id  = old_id+new_key;
+    
+    // set the attribute for the new 'div' subfields
+    var inputs     = clone.getElementsByTagName('input');
+    var selects    = clone.getElementsByTagName('select');
+    var textareas  = clone.getElementsByTagName('textarea');
+        
+    // input
+    var id_input = "";
+    for(var i=0,len=inputs.length; i<len ; i++ ){
+        id_input = inputs[i].getAttribute('id')+new_key;
+        inputs[i].setAttribute('id',id_input);
+        inputs[i].setAttribute('name',inputs[i].getAttribute('name'));
+    }
+    
+    // select 
+    for(var i=0,len=selects.length; i<len ; i++ ){
+        id_input = selects[i].getAttribute('id')+new_key;
+        selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key);
+        selects[i].setAttribute('name',selects[i].getAttribute('name'));
+    }
+    
+    // textarea
+    for(var i=0,len=textareas.length; i<len ; i++ ){
+        id_input = textareas[i].getAttribute('id')+new_key;
+        textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key);
+        textareas[i].setAttribute('name',textareas[i].getAttribute('name'));
+    }
+    
+    <!-- TMPL_UNLESS NAME='advancedMARCEditor' -->
+    // when cloning a subfield, reset its label too.
+    var label = clone.getElementsByTagName('label')[0];
+    label.setAttribute('for',id_input);
+    <!-- /TMPL_UNLESS -->
+    
+    // setting a new if for the parent div
+    clone.setAttribute('id',new_id);
+    
+    var CloneButtonPlus;
+    try {
+      var spans = clone.getElementsByTagName('span');
+      if(spans.length){
+          for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){
+            if(spans[i].getAttribute('class') == 'buttonPlus'){
+                    CloneButtonPlus = spans[i];
+                    CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + new_id + "')");
+                    var buttonUp = clone.getElementsByTagName('img')[0];
+                    buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
+                }
+            }
+        }
+    }
+    catch(e){
+        // do nothig if ButtonPlus & CloneButtonPlus don't exist.
+    }
+    // insert this line on the page
+    original.parentNode.insertBefore(clone,original.nextSibling);
+}
 //]]>
 </script>
 </head>
@@ -96,17 +158,19 @@ function HideItems(index,labelindex) {
     <ul>
     <!--TMPL_LOOP Name="subscriptions"-->
     
-       <li><a href="serials-collection.pl?subscriptionid=<!-- TMPL_VAR name="subscriptionid" -->" title="serial Collection for <!--TMPL_VAR Name="bibliotitle"-->">Serial collection</a></li>
+       <li><a href="serials-collection.pl?subscriptionid=<!-- TMPL_VAR name="subscriptionid" -->" title="serial collection for <!--TMPL_VAR Name="bibliotitle"-->">Serial collection</a></li>
        <li><a href="subscription-detail.pl?subscriptionid=<!-- TMPL_VAR name="subscriptionid" -->" title="detail of the subscription">Subscription #<!-- TMPL_VAR name="subscriptionid" --></a></li>
         <!--TMPL_IF name="abouttoexpire"--><a href="#" onclick="javascript:popup(<!--TMPL_VAR Name="subscriptionid"-->)">Renew <!--TMPL_VAR Name="subscriptionid"--></a>
         <!--/TMPL_IF-->
-        <!--TMPL_IF name="subscriptionexpired"--><a href="#" onclick="javascript:popup(<!--TMPL_VAR Name="subscriptionid"-->)">Renew <!--TMPL_VAR Name="subscriptionid"--></a>
-        <!--/TMPL_IF-->
       <!--/TMPL_LOOP-->
     <li><a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->" title="go to <!-- TMPL_VAR name="bibliotitle" -->">Show Biblio</a></li></ul>
 </div>
-<!--TMPL_IF Name="barcode_not_unique" -->
-Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
+<!--TMPL_IF Name="Errors" -->
+<div class="dialog alert">
+<ul>
+<!--TMPL_IF name="barcode_not_unique"--><li>Error : Barcode Not Unique For <!--TMPL_LOOP Name="errseq"-->serialseq <!--TMPL_VAR Name="serialseq"--><br/><!--/TMPL_LOOP --></li><!--/TMPL_IF-->
+</ul>
+</div>
 <!--/TMPL_IF -->
 
  <input type="hidden" name="op" value="serialchangestatus" />
@@ -114,7 +178,7 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
        <tr>
                <th>Numbered</th>
                <th>Published on</th>
-               <th>planned for</th>
+               <th>Expected on</th>
                <th>Status</th>
                <th>Notes</th>
        </tr>
@@ -139,10 +203,14 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
               <input type="hidden" name="status" id="status<!-- TMPL_VAR NAME="num" -->" value="1">
               <select name="status" size="1"  disabled="disabled">
             <!--TMPL_ELSE-->
-              <select name="status" size="1" id="status<!-- TMPL_VAR NAME="num" -->" onchange="if (this.value==2){unHideItems('items'+<!-- TMPL_VAR NAME="subscriptionid" -->+<!-- TMPL_VAR NAME="serialid" -->,'label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')}" >
+              <!--TMPL_IF Name="serialsadditems"-->
+              <select name="status" size="1" id="status<!-- TMPL_VAR NAME="num" -->" onchange="if (this.value==2){unHideItems('items'+<!-- TMPL_VAR NAME="subscriptionid" -->+<!-- TMPL_VAR NAME="serialid" -->,'label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')} else { HideItems('items'+<!-- TMPL_VAR NAME="subscriptionid" -->+<!-- TMPL_VAR NAME="serialid" -->,'label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')}" >
+               <!--TMPL_ELSE -->
+              <select name="status" size="1" id="status<!-- TMPL_VAR NAME="num" -->" >
+               <!--/TMPL_IF--> 
             <!--/TMPL_IF-->
   <!--TMPL_IF name="status1" -->
-                    <option value="1" selected="selected">Waited</option>
+                    <option value="1" selected="selected">Expected</option>
   <!-- /TMPL_IF -->
   <!--TMPL_IF name="status2" -->
                     <option value="2" selected="selected">Arrived</option>
@@ -185,27 +253,31 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
   <!--TMPL_IF Name="serialsadditems"-->
           <tr>
           <td colspan="5">
-      <a id="label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->" style="color: grey; font-size: 80%; cursor: se-resize;"  onclick="unHideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')">
-             Items   </a>
+      <a id="label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->" style="color: grey; font-size: 80%; cursor: pointer;"  onclick="unHideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')">
+             Click to add item</a>
         <fieldset style="display:none;" id="items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->">
-        <legend><a style="cursor: se-resize;"  onclick="HideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')">
-                Items</a>
+        <legend><a style="cursor: pointer;"  onclick="HideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')">
+                Item</a>
         </legend>
           <div id="cataloguing_additem_itemlist">
         <!-- TMPL_LOOP NAME="items" -->
         <div id="item<!-- TMPL_VAR NAME="serialid" --><!-- TMPL_VAR NAME="countitems" -->" class="items">
         <!-- TMPL_LOOP NAME="iteminformation" -->
-        <p>
-        <div id="subfield<!-- TMPL_VAR NAME="serialid" --><!-- TMPL_VAR NAME="countitems" --><!-- TMPL_VAR NAME="countsubfield" -->" class="subfield">                <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>
+               <div name="line" class="subfield_line" style="<!-- TMPL_VAR NAME='hidden' -->;" id="subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
+                              
+                <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>
                 <!-- TMPL_VAR NAME="marc_value" -->
                 <input type="hidden" name="itemid" value="<!-- TMPL_VAR NAME="itemid" -->" />
                 <input type="hidden" name="kohafield" value="<!-- TMPL_VAR NAME="kohafield" -->" />
                 <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
                 <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
                 <input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
+                <!-- TMPL_IF NAME="ITEM_SUBFIELDS_ARE_NOT_REPEATABLE" -->
+                    <span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
+                <!-- /TMPL_IF -->
+        
             </div>
-         </p>
-        <!-- /tmpl_loop -->
+        <!-- /tmpl_loop --><!-- /iteminformation -->
         
         <input type="hidden" name="moditem" value="" /> 
         <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="itemtagfield" -->" />
@@ -215,7 +287,7 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
         <input type="hidden" name="itemid" value="<!-- TMPL_VAR NAME="itemid" -->" />
         <input type="hidden" name="field_value" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
         </div>
-        <!--/TMPL_LOOP-->
+        <!--/TMPL_LOOP--> <!-- /items -->
         </div>
         </fieldset>
     </td>
@@ -232,7 +304,7 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
             <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
             <input type="hidden" name="itemcount" value="<!-- TMPL_VAR name="issuesatonce" -->" />
             <input type="hidden" name="user" value="<!-- TMPL_VAR name="librarian" -->" />
-            <b>Subs. <!-- TMPL_VAR name="subscriptionid" --></b> New Issue <input type="text" name="serialseq" value="" size="20" maxlength="100" onchange="if (this.value!=''){unHideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!-- TMPL_VAR NAME="serialid" -->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')} else {HideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!-- TMPL_VAR NAME="serialid" -->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')}" />
+            Supplemental Issue <input type="text" name="serialseq" value="" size="20" maxlength="100" onchange="if (this.value!=''){unHideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!-- TMPL_VAR NAME="serialid" -->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')} else {HideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!-- TMPL_VAR NAME="serialid" -->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')}" />
         </td>
         <td>
             <input type="text" name="publisheddate" value="<!-- TMPL_VAR name="publisheddate" -->" size="10" maxlength="15" />
@@ -242,8 +314,9 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
         </td>
         <td>
             <select name="status" size="1" id="addstatus<!-- TMPL_VAR NAME="num" -->">
+                    <option value="">----</option>
   <!--TMPL_IF name="status1" -->
-                    <option value="1" selected="selected">Waited</option>
+                    <option value="1" selected="selected">Expected</option>
   <!-- /TMPL_IF -->
   <!--TMPL_IF name="status2" -->
                     <option value="2" selected="selected">Arrived</option>
@@ -285,25 +358,28 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
   <!--TMPL_IF Name="serialsadditems"-->
           <tr>
           <td colspan="5">
-      <a id="label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->" style="color: grey; font-size: 80%; cursor: se-resize;"  onclick="unHideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')">
-             Item</a>
+      <a id="label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->" style="color: grey; font-size: 80%; cursor: pointer;"  onclick="unHideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')">
+             Click to add item</a>
         <fieldset style="display:none;" id="items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->">
-        <legend><a style="cursor: se-resize;"  onclick="HideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')">
+        <legend><a style="cursor: pointer;"  onclick="HideItems('items<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->','label<!-- TMPL_VAR NAME="subscriptionid" --><!--TMPL_VAR Name="serialid"-->')">
                 Item</a>
         </legend>
           <div id="cataloguing_additem_itemlist">
         <div id="item<!-- TMPL_VAR NAME="serialid" --><!-- TMPL_VAR NAME="countitems" -->" class="items">
         <!-- TMPL_LOOP NAME="iteminformation" -->
-        <p>
-        <div id="subfield<!-- TMPL_VAR NAME="serialid" --><!-- TMPL_VAR NAME="countitems" --><!-- TMPL_VAR NAME="countsubfield" -->" class="subfield">                <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>
+               <div name="line" class="subfield_line" style="<!-- TMPL_VAR NAME='hidden' -->;" id="subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
+   
+                <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>
                 <!-- TMPL_VAR NAME="marc_value" -->
                 <input type="hidden" name="itemid" value="<!-- TMPL_VAR NAME="itemid" -->" />
                 <input type="hidden" name="kohafield" value="<!-- TMPL_VAR NAME="kohafield" -->" />
                 <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
                 <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
                 <input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
+                <!-- TMPL_IF NAME="ITEM_SUBFIELDS_ARE_NOT_REPEATABLE" -->
+                    <span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='serialid' --><!-- TMPL_VAR NAME='countitems' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
+                <!-- /TMPL_IF -->
         </div>
-        </p>
         <!-- /tmpl_loop -->
         
         <input type="hidden" name="moditem" value="" /> 
@@ -333,4 +409,4 @@ Error : Barcode Not Unique For serialseq <!--TMPL_VAR Name="errserialseq"-->
 <!-- TMPL_INCLUDE NAME="serials-menu.inc" -->
 </div>
 </div>
-<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
\ No newline at end of file
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->