<?php
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$rurl="&modid=".$modid."&frmid=".$frmid;
if($_REQUEST['Save'])
{
$fstatus=true;
  if($_REQUEST['site']=='0')
  {
  	  $msgErr[]="Please Select Branch Name"	;
      $fstatus=false;
  }
  if($_REQUEST['bomno']=='')
  {
  	  $msgErr[]="Please Enter Bom No"	;
      $fstatus=false;
  }	
	    
  if($_REQUEST['Description']=='')
  {
  	  $msgErr[]="Please Enter Descriptions"	;
      $fstatus=false;
  }
   if($_REQUEST['bomtype']=='0')
  {
  	  $msgErr[]="Must Select Bom Type"	;
      $fstatus=false;
  }
   if($_REQUEST['bomlocation']=='0')
  {
  	  $msgErr[]="Must Select Bom Locations"	;
      $fstatus=false;
  }
  if($_REQUEST['prepared_date']=='')
  {
  	  $msgErr[]="Must Entet Prepared Date"	;
      $fstatus=false;
  }
   if($_REQUEST['prepared_by']=='')
  {
  	  $msgErr[]="Please  Entet Prepared By"	;
      $fstatus=false;
  }
   if($_REQUEST['approved_by']=='')
  {
  	  $msgErr[]="Please  Entet Approved By"	;
      $fstatus=false;
  }
  if($_REQUEST['procsstotal']=='')
  {
  	  $msgErr[]="Total Operational Cost "	;
      $fstatus=false;
  }
   if($_REQUEST['overheadcost']=='')
  {
  	  $msgErr[]="Total Overhead Cost";
      $fstatus=false;
  }
   if($_REQUEST['total_qty']=='')
  {
  	  $msgErr[]="Total Raw Material Item Qty";
      $fstatus=false;
  }
  if($_REQUEST['landedprice']=='')
  {
  	  $msgErr[]="Total Raw Material Cost Landed Price";
      $fstatus=false;
  }
   if($_REQUEST['totalamount']=='')
  {
  	  $msgErr[]="Total Production Rate of Bill of Material";
      $fstatus=false;
  }
 	
	if($_REQUEST['part_code']=='')
  {
  	  $msgErr[]="Please Enter Part Code for finished Product Details";
      $fstatus=false;
  } 
  if($_REQUEST['product_name']=='')
  {
  	  $msgErr[]="Please Enter Product Name for finished Product Details";
      $fstatus=false;
  } 
  if($_REQUEST['finished_uom']=='')
  {
  	  $msgErr[]="Please Enter Finished UOM for finished Product Details";
      $fstatus=false;
  } 
  $qtydata=$_REQUEST['itemcode'];
  for($i=0;$i<count($qtydata);$i++)
  {
  if($_REQUEST['itemcode'][$i]=='')
  {
  	  $msgErr[]="Please Select Item Code for Raw Material And Assemble  ";
      $fstatus=false;
  } 	
	
  }
$qtydata1=$_REQUEST['processid'];
  for($i=0;$i<count($qtydata1);$i++)
  {
  if($_REQUEST['processid'][$i]=='0')
  {
  	  $msgErr[]="Please Select Process Name for Process Operational  ";
      $fstatus=false;
  } 	
  if($_REQUEST['procesper'][$i]=='')
  {
  	  $msgErr[]="Please Enter Process Percentage for Process Operational  ";
      $fstatus=false;
  } 	
  if($_REQUEST['procesamt'][$i]=='')
  {
  	  $msgErr[]="Please Enter Process Amount for Process Operational  ";
      $fstatus=false;
  } 	
	
  }
  
  $qtydata2=$_REQUEST['process_overhead'];
  for($i=0;$i<count($qtydata2);$i++)
  {
  if($_REQUEST['process_overhead'][$i]=='0')
  {
  	  $msgErr[]="Please Select Process Name for Overhead Operational  ";
      $fstatus=false;
  } 	
  if($_REQUEST['procesoverper'][$i]=='')
  {
  	  $msgErr[]="Please Enter Process Percentage for Overhead Operational  ";
      $fstatus=false;
  } 	
  if($_REQUEST['procesoveram'][$i]=='')
  {
  	  $msgErr[]="Please Enter Process Amount for Overhead Operational  ";
      $fstatus=false;
  } 	
	
  } 
  
}
if($_REQUEST['Save']!='' and $fstatus)
{   
	    $data=DB_query("select * from bill_material where  bom_type='".$_REQUEST['bomtype']."' and bom_location='".$_REQUEST['bomlocation']."'
	                  and  part_code='".$_REQUEST['part_code']."' and brach_code='".$_REQUEST['site']."'",$db);
		$checkdata=DB_num_rows($data);
		if($checkdata<=0)
		{					   	       
        $insert="insert into bill_material set
                 brach_code='".$_REQUEST['site']."',bom_no='".$_REQUEST['bomno']."',
                 bom_type='".$_REQUEST['bomtype']."',description='".$_REQUEST['Description']."',bom_location='".$_REQUEST['bomlocation']."',
                 revision_no='".$_REQUEST['revisionno']."',revision_date='".FormatDateForSQL($_REQUEST['revisiondate'])."',prepared_date='".FormatDateForSQL($_REQUEST['prepared_date'])."',
                 prepared_by='".$_REQUEST['prepared_by']."',approved_by='".$_REQUEST['approved_by']."',part_code='".$_REQUEST['part_code']."',
                 product_name='".$_REQUEST['product_name']."',uom='".$_REQUEST['finished_uom']."',total_qty='".$_REQUEST['total_qty']."',total_costland_price='".$_REQUEST['landedprice']."',
                 total_operation_cost='".$_REQUEST['procsstotal']."',total_overheadcost='".$_REQUEST['overheadcost']."',total_production_rate='".$_REQUEST['totalamount']."'";
	$ErrMsg = _('An error occurred Record Note Save') . '. ' . _('The error says');
	$query=DB_query($insert,$db,$ErrMsg);
	$Lastreq_id=DB_Last_Insert_ID($db,'bill_material',$ErrMsg);
	$qty=$_REQUEST['itemcode'];
	$qty1=count($qty);
	if($Lastreq_id!='')
				{
					for($i=0;$i<$qty1;$i++)
					 {
					 $insert1="insert into bill_raw_material set bill_material_id='".$Lastreq_id."',
					 		  production_process='".$_REQUEST['product_process'][$i]."',part_code='".$_REQUEST['itemcode'][$i]."'
					 		  ,bom_description='".$_REQUEST['desc'][$i]."', bom_uom='".$_REQUEST['uom'][$i]."'
					 		  ,bom_qty='".$_REQUEST['qty'][$i]."',bom_costlanded_price='".$_REQUEST['costlandprice'][$i]."'
					 		  ,bom_amount='".$_REQUEST['amount'][$i]."',status='0'";
							  $ErrMsg = _('An error occurred Record Note Save') . '. ' . _('The error says');
				      $insertResult2 = DB_query($insert1,$db,$ErrMsg);			 	 		
					
				}
					$qty11=$_REQUEST[procesper];
					$qty2=count($qty11);
					for($i=0;$i<$qty2;$i++)
					 {
					 $insert3="insert into  bom_process_operational set bill_id='".$Lastreq_id."',
	                           process_name='".$_REQUEST['processid'][$i]."',process_per='".$_REQUEST['procesper'][$i]."', 
	                           process_amt='".$_REQUEST['procesamt'][$i]."',total_operational_cost='".$_REQUEST['procsstotal']."',status='0'";
	                            $ErrMsg = _('An error occurred Record Note Save') . '. ' . _('The error says');
				      $insertResult2 = DB_query($insert3,$db,$ErrMsg);
					 }		
					 
					 $qty11=$_REQUEST[procesper];
					$qty2=count($qty11);
					for($i=0;$i<$qty2;$i++)
					 {
					 $insert3="insert into  bill_other_overhead set bill_id='".$Lastreq_id."',
	                           overhead_process='".$_REQUEST['process_overhead'][$i]."',overhead_per='".$_REQUEST['procesoverper'][$i]."', 
	                           overhead_cost='".$_REQUEST['procesoveram'][$i]."',total_overhead_cost='".$_REQUEST['overheadcost']."',status='0'";
	                            $ErrMsg = _('An error occurred Record Note Save') . '. ' . _('The error says');
				      $insertResult2 = DB_query($insert3,$db,$ErrMsg);
					 }		
	
}



}
$s->pageLocation('index.php?route=bill_of_materiallist&modid='.$_REQUEST['modid'].'&frmid='.$_REQUEST['frmid'].$rurl);
}
else {
	  $ErrMsg = _('Priviously occurred Record Note Save') . '. ' . _('The error says');
}



?>



<h2 align="center">Bill Of Material</h2>
<form action="" method="post">
<table width="70%">	
<?php if(count($msgErr)>0){?>
   <tr>
   <td colspan="4"><?php
   for($i=0;$i<count($msgErr);$i++)
   {
     echo "<div class='error'>".$msgErr[$i].'</div>';
   }
    ?></td>
   </tr>
   <?php } ?>	
	</table>	
<table width="25%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC" align="center">
   
  <tr>
    <th>Branch</th>
    <td>
    <select name="site" id="site" style="width:100%" onchange="getdata(this.value);">
    <option value="0">All Branches</option>
     <?php 
		$site_sql = "SELECT prefix,loccode, locationname from locations";
		$site_result = DB_query($site_sql,$db);
		while($site_row = DB_fetch_array($site_result))
		{
		?>
         <option value="<?php echo $site_row['loccode']; ?>" ><?php echo $site_row['locationname']; ?></option>
            <?php } ?>
    </select>
    </td>
  </tr>
</table>

<br/>
<table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC">
  <tr>
    <th>BOM No.</th>
     <td width="27%" id="hotfoil">
      <input type="text" name="bomno" id="bomno" style="width:100%" readonly>
    </td>
    <th>Type Of BOM</th>
    <td>  <select name="bomtype" id="" style="width:100%">
    <option value="0">Select</option>
     <?php 
		$site_sql2 = "SELECT id,bom_type from bom_type";
		$site_result1 = DB_query($site_sql2,$db);
		while($site_row2 = DB_fetch_array($site_result1))
		{
		?>
         <option value="<?php echo $site_row2['id']; ?>" ><?php echo $site_row2['bom_type']; ?></option>
            <?php } ?>
    </select></td>
    <th>Description</th>
    <td><input type="text" name="Description" id="Description" style="width:100%"></td>
  </tr>
  <tr>
    <th>Location Of BOM</th>
    <td> <select name="bomlocation" id="bomlocation" style="width:100%">
    <option value="0">Select</option>
     <?php 
		$site_sql3 = "SELECT id,bom_location from bom_location";
		$site_result2 = DB_query($site_sql3,$db);
		while($site_row2 = DB_fetch_array($site_result2))
		{
		?>
         <option value="<?php echo $site_row2['id']; ?>" ><?php echo $site_row2['bom_location']; ?></option>
            <?php } ?>
    </select></td>
    <th>Revision No.</th>
    <td><input type="text" name="revisionno" id="v" style="width:100%"></td>
    <th>Revision Date</th>
    <td><input type="text" name="revisiondate" id="revisiondate" style="width:100%" class="datepicker"></td>
  </tr>
  <tr>
    <th>Prepared Date</th>
    <td><input type="text" name="prepared_date" id="prepared_date" style="width:100%" class="datepicker"></td>
    <th>Prepared By</th>
    <td><input type="text" name="prepared_by" id="prepared_by" style="width:100%"></td>
    <th>Approved By</th>
    <td><input type="text" name="approved_by" id="approved_by" style="width:100%"></td>
  </tr>
</table>
<br/>
<table width="100%" border="0" cellspacing="2" cellpadding="1"  style="background-color:#FFF; border:solid 1px #CCC" align="center">
  <tr>
    <th colspan="6"><div align="center">Finished Product Details</div></th>
    </tr>
  <tr>
  	 <th>Pick Item</th>
  	 <td><input type="button" name="item_popup" value="Add Items" id="item_popup"  onclick="open_items();" /></td>
  	 
    <th>Part Code</th>
    <td><input type="text" name="part_code" id="part_code" style="width:80%" value=""></td>
    <th>Product Name</th>
    <td><input type="text" name="product_name" id="product_name" style="width:100%" value=""></td>
    <th>UOM</th>
    <td><input type="text" name="finished_uom" id="finished_uom" style="width:100%" value=""></td>
  
  </tr>
</table>
<br/>
<p align="left">
<input type="button" onclick="addRow('dataTable')" value="Add More" />&nbsp;
<input type="button" class="crmbutton small delete"  onclick="deleteRow('dataTable')" value="Delete" />
</p>
<table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC" align="center">
  <tr>
    <th colspan="9"><div align="center">BOM - Raw Material And Assembly Item Details</div></th></tr>
  <tr>
  	<th>&nbsp;</th>
  	<th>Pick Items</th>
     <th>Production Process</th>
    <th>Part Code</th>
    <th>Description</th>
    <th>UOM</th>
    <th>Qty</th>
    <th>Cost Landed Price</th>
    <th>Amount</th>
  </tr>
   <tbody id="dataTable">
  <tr>
  	<td><input type="checkbox" name="chk" /><input type="hidden" value="" id="user_shipping" name="user_shipping[]" /></td>
  	<td><input type="button" name="profile_popup" value="+" id="profile_popup"  onclick="openPopupProfile(this.id)" /></td>
       <td><select name="product_process[]" id="prodcut_process" style="width:100%">
    	<option value="0">---Select </option>
    	<?php $productrow=DB_query("select * from production_process_master",$db);
		while($product_row1=DB_fetch_array($productrow))
		{
			?>
			<option value="<?php echo $product_row1['id']; ?>"><?php echo $product_row1['manuf_process_name'];?></option>
		}
    	
    	<?php } ?>
    	
    </select></td>
    <td><input type="text" name="itemcode[]" id="itemcode" style="width:100%"readonly></td>
    <td><input type="text" name="desc[]" id="desc" style="width:100%" readonly></td>
    <td><input type="text" name="uom[]" id="uom" style="width:100%" readonly></td>
    <td><input type="text" name="qty[]" id="qty" style="width:100%" ></td>
    <td><input type="text" name="costlandprice[]" id="costlandprice" style="width:100%" ></td>
    <td><input type="text" name="amount[]" id="amount" style="width:100%" onfocus="calamount(this)"></td>
  </tr>
   </tbody>
</table>

<table width="70%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC" align="center">
  <tr>
    <th nowrap>Total Raw Material And Assembly Item Qty</th>
    <td><input type="text" name="total_qty" id="total_qty" style="width:100%" onfocus="calqty(this);"></td>
    <th nowrap>Total Cost Landed Price</th>
    <td><input type="text" name="landedprice" id="landedprice" style="width:100%" onfocus="caltotal(this);"></td>
  </tr>
</table>
<br/>
<br/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
    	<p align="left">
<input type="button" onclick="addRow('dataTable1')" value="Add More Process" />&nbsp;
<input type="button" class="crmbutton small delete"  onclick="deleteRow('dataTable1')" value="Delete" />
</p>
    <table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC">
  <tr>
    <th colspan="4">Process Operational Cost</th>
  </tr>
  
  <tr>
    <th scope="col">S. No.</th>
    <th scope="col">Process</th>
    <th scope="col">%</th>
    <th scope="col">Amount</th>
  </tr>
  <tbody id="dataTable1">
  <tr>
    <td><input type="checkbox" name="chk" /><input type="hidden" value="" id="user_shipping" name="user_shipping[]" />
       	
    </td>
    <td><select name="processid[]="process" style="width:100%">
    	<option value="0">---Select </option>
    	<?php       	
    	$productrow=DB_query("select * from production_process_master",$db);
		while($product_row1=DB_fetch_array($productrow))
		{
			?>
			<option value="<?php echo $product_row1['id']; ?>"><?php echo $product_row1['manuf_process_name'];?></option>
		}
    	
    	<?php } ?>
    	
    </select>
    	
    	 </td>
    <td><input type="text" name="procesper[]"   id="procesper"/></td>
    <td><input type="text" name="procesamt[]" id="procesamt" onfocus="calpercentage(this);" />;</td>
  </tr>
</table>
	<br/>
	
	<table width="70%" border="0" cellspacing="0" cellpadding="0" style="background-color:#FFF; border:solid 1px #CCC">
    	<tr><th>Total Operational Cost</th><td><input type="text" name="procsstotal" id="procsstotal" style="width:100%" onfocus="operationcost(this);"></td></tr>
    </table>
	</td>
    <td>&nbsp;</td>
    <td>
  <p align="left">
<input type="button" onclick="addRow('dataTable2')" value="Add More Process" />&nbsp;
<input type="button" class="crmbutton small delete"  onclick="deleteRow('dataTable2')" value="Delete" />
</p>
    <table width="100%" border="0" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC">
  <tr>
    <th colspan="4">Other Overhead Cost</th>
  </tr>
  <tr>
    <th>S. No.</th>
    <th>Process</th>
    <th>%</th>
    <th>Amount</th>
  </tr>
   <tbody id="dataTable2">
  <tr>
    <td><input type="checkbox" name="chk" /><input type="hidden" value="" id="user_shipping" name="user_shipping[]" />
       	
    </td>
    <td><select name="process_overhead[]="process" style="width:100%">
    	<option value="0">---Select </option>
    	<?php       	
    	$productrow=DB_query("select * from production_process_master",$db);
		while($product_row1=DB_fetch_array($productrow))
		{
			?>
			<option value="<?php echo $product_row1['id']; ?>"><?php echo $product_row1['manuf_process_name'];?></option>
		}
    	
    	<?php } ?>
    	
    </select>
    	
    	 </td>
    <td><input type="text" name="procesoverper[]"  id="procesoverper" /></td>
    <td><input type="text" name="procesoveram[]" id="procesoveram"   onfocus="caloverpercentage(this)"/>;</td>
  </tr>
    </table>
    <br/>
    <table width="70%" border="0" cellspacing="0" cellpadding="0" style="background-color:#FFF; border:solid 1px #CCC" align="right">
    	<tr>
    	  <th>Total Overhead Cost</th>
    	  <td><input type="text" name="overheadcost" id="overheadcost" style="width:100%" onfocus="overheadcostcal(this);"></td></tr>
    </table>
    </td>
  </tr>
</table>
<br>
<table width="45%" cellspacing="2" cellpadding="1" style="background-color:#FFF; border:solid 1px #CCC" align="center">
<tr>
<th>Total Production Rate Of Bill Of Material</th>
<td><input type="text" name="totalamount" id="totalamount" style="width:100%" onfocus="totalamountcal(this);"></td>
</tr>
</table>
<p align="center"><input type="submit" value="Save" name="Save" /></p>
</form>
<script language="javascript" type="text/javascript">
function open_items()
{
	window.open("bill_finishproduct.php?action=add&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>","item_popup_window","height=500,width=900,toolbar=no,menubar=no,dependent=yes,resizable =yes, scrollbars=yes");
}


function openPopupProfile(i)
{ 
		window.open("pickrawmaterial.php?rowcount="+i,"profiles_popup_window","height=425,width=640,toolbar=no,menubar=no,dependent=yes,resizable=yes");
}

function calamount(obj)
{      var amount='';
	      var rowCount = document.getElementById('dataTable').rows.length;
	      var arr = obj.id.split("_");
	     var rowx1=0;
	   if (arr[1]==undefined)
	   {
	    var nm='';
	    var t=document.getElementById('costlandprice').value;
	    
         var k=document.getElementById('qty').value;
        var amount=t*k;
        document.getElementById('amount').value=amount;
       }
	 else
	 {
	 var nm='_'+arr[1];
	 }
	  for(var i=1;i<rowCount;i++)
	{   var t=document.getElementById('costlandprice'+nm).value;
	    
         var k=document.getElementById('qty'+nm).value;
        var amount=t*k;
        document.getElementById('amount'+nm).value=amount;
		}
}
function caltotal(str)
{    	 var rowCount = document.getElementById('dataTable').rows.length;
         var obj2=document.getElementById('amount').value;
	     var obj=document.getElementById('amount');
	     var arr = obj.id.split("_");
	     var rowx1=0;
	    if (arr[1]==undefined)
	   {
	    var nm='';
	   }
	   else
	 {
	 var nm='_'+arr[1];
	 }
	 for(var i=1;i<rowCount;i++)
	{
		rowx1=parseInt(document.getElementById('amount_'+i).value)+parseInt(rowx1);
	
    }
    rowx1=parseInt(rowx1)+parseInt(obj2)
   document.getElementById('landedprice').value=rowx1;
   }
   function calqty(str)
    {    	
	var rowCount = document.getElementById('dataTable').rows.length;
	 var obj1=document.getElementById('qty').value;
	 				
    var obj=document.getElementById('qty');
	     var arr = obj.id.split("_");
	     var rowx1=0;
	   if (arr[1]==undefined)
	   {
	    var nm='';
	   }
	   else
	 {
	 var nm='_'+arr[1];
	 }
    for(var i=1;i<rowCount;i++)
	{  
		
	rowx1=parseInt(document.getElementById('qty_'+i).value)+parseInt(rowx1) ;
   }
   rowx1=parseInt(rowx1)+parseInt(obj1)
   document.getElementById('total_qty').value=rowx1;
   }
   
   function calpercentage(str1)
   {
   	    var t=document.getElementById('landedprice').value;   	     
   	    var rowCount = document.getElementById('dataTable1').rows.length;
   	       var arr = str1.id.split("_");
   	    
	     var rowx1=0;
	   if (arr[1]==undefined)
	   {
	     var nm='';	    
	     var k=document.getElementById('procesper').value;
         var amount=parseInt(t)*parseInt(k);
         var amount1=parseInt(amount)/100;       
        document.getElementById('procesamt').value=amount1;
       }
	 else
	 {
	 var nm='_'+arr[1];
	 }
	 
	  for(var i=1;i<rowCount;i++)
	{   
		var k=document.getElementById('procesper'+nm).value;
	    var amount=parseInt(t)*parseInt(k);
        var amount1=parseInt(amount)/100;
        document.getElementById('procesamt'+nm).value=amount1;
		}
   	
   }
   function caloverpercentage(str1)
   {
   	    var t=document.getElementById('landedprice').value;   	     
   	    var rowCount = document.getElementById('dataTable2').rows.length;
   	       var arr = str1.id.split("_");
   	    
	     var rowx1=0;
	   if (arr[1]==undefined)
	   {
	     var nm='';	    
	     var k=document.getElementById('procesoverper').value;
         var amount=parseInt(t)*parseInt(k);
         var amount1=parseInt(amount)/100;       
        document.getElementById('procesoveram').value=amount1;
       }
	 else
	 {
	 var nm='_'+arr[1];
	 }
	 
	  for(var i=1;i<rowCount;i++)
	{   
		var k=document.getElementById('procesoverper'+nm).value;
	    var amount=parseInt(t)*parseInt(k);
        var amount1=parseInt(amount)/100;
        document.getElementById('procesoveram'+nm).value=amount1;
		}
   	
   }
   function operationcost(str)
   {
   	var rowCount = document.getElementById('dataTable1').rows.length;
         var obj2=document.getElementById('procesamt').value;
	     var obj=document.getElementById('procesamt');
	     var arr = obj.id.split("_");
	     var rowx1=0;
	    if (arr[1]==undefined)
	   {
	    var nm='';
	   }
	   else
	 {
	 var nm='_'+arr[1];
	 }
	 for(var i=1;i<rowCount;i++)
	{
		rowx1=parseInt(document.getElementById('procesamt_'+i).value)+parseInt(rowx1);
	
    }
    rowx1=parseInt(rowx1)+parseInt(obj2)
   document.getElementById('procsstotal').value=rowx1;
   	
   }
   function overheadcostcal(str)
   {
   	var rowCount = document.getElementById('dataTable2').rows.length;
         var obj2=document.getElementById('procesoveram').value;
	     var obj=document.getElementById('procesoveram');
	     var arr = obj.id.split("_");
	     var rowx1=0;
	    if (arr[1]==undefined)
	   {
	    var nm='';
	   }
	   else
	 {
	 var nm='_'+arr[1];
	 }
	 for(var i=1;i<rowCount;i++)
	{
		rowx1=parseInt(document.getElementById('procesoveram_'+i).value)+parseInt(rowx1);
	
    }
    rowx1=parseInt(rowx1)+parseInt(obj2)
   document.getElementById('overheadcost').value=rowx1;
   	
   }
  
   function totalamountcal(str)
   {
   	var t=  document.getElementById('procsstotal').value;
   	var k= document.getElementById('overheadcost').value;
   	var j=document.getElementById('landedprice').value;
   	var amount=parseInt(t)+parseInt(k)+parseInt(j);
   	document.getElementById('totalamount').value=amount;
      }
   
function getdata(bom) 
{	 
	
if (bom.length==0)
  {
  document.getElementById("hotfoil").innerHTML="";
   return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("hotfoil").innerHTML=xmlhttp.responseText;
      }
  }
 
xmlhttp.open("GET","get_entryslip_jobcard.php?bom1="+bom,true);
xmlhttp.send();
}

</script>