<style type="text/css">
.body_lightbox {
width:100%;
background-color:#e7e7e7;
position:absolute;
left:280px;
top:95px;
padding-left:5px;
padding-right:5px;
border:#666666 solid 3px;
}
table tr.row3 {
  border-bottom: 1px solid #d0d0d0;
}
</style>


<?php



if(isset($_POST['Save']))
{

            $CurrentFinancialYear = date("y")."-".$Prefix_date;
			$year=$_SESSION['financialYearStart'];
			$Afteryear=$_SESSION['financialYearEnd'];
            $prefixcode="RGP";	 
	      $siteCode = $_REQUEST['sitecode'];
	        $site_Code=substr($siteCode,0,3);
              $sql="select * from rgp_tab where branch = '".$_REQUEST['sitecode']."'";
      
	             $result = DB_query($sql,$db);
	              $numrows = DB_num_rows($result);
				  
	 if($numrows>0)
	 {
			
			if($numrows>0)	{ $maxval = $numrows;	}
			else	{ 	$maxval=0;	}
		{
			$strChar = $site_Code."/".$prefixcode."/".$year.$Afteryear."/";
		}
	  }
	  else
	  {
	  	$strChar = $site_Code."/".$prefixcode."/".$year.$Afteryear."/";
	  }
	  
	  
	    $strFinal = $maxval+1;
	    $strBothFinal = $strChar.str_pad($strFinal,6,"0",STR_PAD_LEFT); 
        $data['rgp_no'] = $strBothFinal; 
		$data['branch'] = $_REQUEST['sitecode'];
		$data['store'] = $_REQUEST['store'];
		$data['document_typ']=$_REQUEST['doc_type'];
		$data['date']=FormatDateForSQL($_REQUEST['date']);
		$data['supplier']=$_REQUEST['vendor'];
		$data['remove_date']=FormatDateForSQL($_REQUEST['removedate']);
		$data['expected_date']=FormatDateForSQL($_REQUEST['expected_date']);
		$data['remove_time']=$_REQUEST['removetime'];
		$data['form_no']=$_REQUEST['formname'];
		$data['vehicle_no']=$_REQUEST['vehicle'];
		$data['expected_time']=$_REQUEST['expected_time'];
		$data['appox_value']=$_REQUEST['appox_value'];
		$data['remarks']=$_REQUEST['remarks'];
		$data['created_by']=$_SESSION['UserID'];
		$insertsql=	$s->insertRecord('rgp_tab', $data);
 		$insertResult = DB_query($insertsql,$db,$ErrMsg);
		$Lastreq_id=DB_Last_Insert_ID($db,'rgp_tab',$ErrMsg);
  
        for($i=0;$i<count($_REQUEST['itemdataid']);$i++)
		{
 				if($_REQUEST['itemdataid'][$i]!='' )
				{			
				      
						$data_arr['parent_id']= $Lastreq_id;
						$data_arr['mst_itemid']= $_POST['itemdataid'][$i];
						$data_arr['batch_no']= $_POST['batch_no'][$i];
						$data_arr['stock_qty']= $_REQUEST['stock_qty'][$i];
						$data_arr['job_process']= $_POST['job_process'][$i];
						$data_arr['qty']= $_REQUEST['qty'][$i];
						$data_arr['job_rate']= $_REQUEST['job_rate'][$i];
						$data_arr['jobvalue']= $_REQUEST['job_value'][$i];
						$insertResult=$s->insertRecord('rgp_tab_details',$data_arr);
						$row2=DB_query($insertResult,$db);
						
						 		
					              
					}
								  
						
						
	  }		
     

$s->pageLocation("index.php?route=Inventory/transation/Rgp_index".$rurl);

} 
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h3 align="left"><strong><?php echo $s->getField('modules_form','id',$_REQUEST['frmid'],'frm_name'); ?></strong></h3>
<form name="form1" action="" method="post" >
<fieldset class="bggreen" style="margin-top:10px; padding:5px 0;">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr class="row3">
    <td><strong>Branch</strong></td>
    <td style="width:250px;">
		<?php
		if($_SESSION['AssignedBranch']!='')
	  {	  	
  $ss1="Select loccode, locationname from locations  where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')";
	  	 $site_sql1=DB_query($ss1,$db);
	  }
	  else
	  {
		$ss1="Select loccode,locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."'";
		$site_sql1=DB_query($ss1,$db);
	  }
	  ?>
<select name="sitecode" style="width:100%" id="sitecode"  onchange="showsitename158(this.value)">
	 <option value="0">Select</option>
      <?php 
			while ($myrow=DB_fetch_array($site_sql1))
				{
				  $p='';
				 if($myrow['loccode']==$site)
				 $p='selected';
				
				?>
      <option value="<?php echo $myrow['loccode']; ?>"  <?php  echo $p;?>><?php echo $myrow['locationname'];?></option>
      <?  }	?>
    </select>
	
	
	
		</td>
    <td>RGP No </td>
    <td style="width: 250px;">
    	<input type="text"size="20" style="width:100%" readonly="readonly" value="Auto Generate On Save"/> 		</td>
</tr>

<tr class="row3"> <td><strong>Document Type .</strong></td>
    <td>
      <select name="doc_type" style="width:100%" >
        <option value="0">Select</option>
		<option value="57 F4 Challan">57 F4 Challan</option>
      </select>
    </td>
    <td>Date</td>
    <td><input type="text"size="20" name="date"  style="width:100%" readonly="readonly" class="datepicker" id="date"/>	</td>
</tr>

<tr class="row3">
    <td><strong>Supplier</strong></td>
    <td style="width:250px;">
	
	  <select name="vendor" id="vendor" style="width:100%" >
        <option>Select</option>
		<?php
			$sql="select id  ,vendor_code, vendor_name from suppliers";
			$result = DB_query($sql, $db);
			while($myrow = DB_fetch_array($result))
			{ 
			$p='';
			if($vendor==$myrow['id'])
			$p="selected";
			?>
			 <option  value="<?php echo $myrow['id']; ?>"<?php echo $p;?> ><?php echo str_replace(array("M/s ","M/S"),'',$myrow['vendor_name']); ?></option>
		<?php }
			?>
		
      </select>
		</td>
	
		<?php
		  $timezone = "Asia/Calcutta";
			if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
			  $t=date("g:i a", time()); 
		?>
    <td>Remove Date & Time</td>
    <td style="width:250px;">
    	<div id="dept"><input type="text" id="removedate" name="removedate" size="20" style="width:49%" readonly="readonly" class="datepicker"/>&nbsp;<input  id="roundTimeExample" type="text" class="time" name="removetime"    size="20" style="width:49%" readonly="readonly"  value="<?php echo $t; ?>"/>
    	</div>	</td>
</tr>

<tr class="row3">
    <td><strong>Form No </strong></td>
    <td style="width:250px;"><span style="margin-bottom:15px;">
      <input name="formname" id="formname" type="text" style="width:100%"size="20" />
    </span></td>
    <td>Vehicle No.</td>
    <td> <input type="text"size="20" name="vehicle" id="vehicle"   style="width:100%" />	</td>
</tr>
<tr class="row3" style="border: none;">
<td><strong>Store</strong></td>
<td><div id='hid-Godown-div'>
    	<?php
		      $sql_store12 ="select  id, StoreCode, StoreName from storetype  ";
		 $resultStkLocs12 = DB_query($sql_store12,$db);
		?>
    	<select name="store" style="width:100%" id="store"  >
	<option value="0">Select</option>
      
      <option value="0" >Select</option>
    </select></div></td>
	<td>Expected Return Date</td><td><input type="text" name="expected_date" id="expected_date" class="datepicker"  style="width:100%"/></td>
	
	</tr>
</table> 
</fieldset>

<p align="left" style="padding-left:10px;">
<input type="button" name="profile_popup" value="Pick Items" id="profile_popup" class="search" />&nbsp;
 <input type="button" class="search"   onclick="deleteRowOrder('dataTable')" value="Delete" />  </p>  

    <div id="itemdata">
      <table width="100%" border="1" cellpadding="3" cellspacing="0">
        <tr class="row1">
		<td><strong>S.R.</strong></td>
		 <td></td>
          <td><strong>Part Code</strong></td>
          <td><strong>Part Name</strong></td>
          <td><strong>Unit</strong></td>
          <td  colspan="2"><strong><center>Specification</center></strong></td>
		  <td><strong>Batch No.</strong></td>
		  <td><strong>Stock Qty.</strong></td>
          <td colspan="3" style="text-align:center;"><strong>Qty</strong></td>
          <td><strong>Reason</strong></td>
		  <td><strong>Job Rate</strong></td>
		  <td><strong>Job Value</strong></td>		   
        </tr>
        <tbody id="dataTable">
           <tr class="row1">
            <td><input name="delitem[]" type="checkbox" value="<?php echo $item_row['id'];?>" id="delitem" /></td>
            <td><input  type="hidden"   readonly=""  id="itemdataid_1"  name="itemdataid[]" /></td>
            <td><input type="text" value="" tabindex=""   id="itemcode_1" name="itemcode[]"size="20" 
            	onkeyup="opendata(this.value,this.id)"/></td>
            <td><input type="text" name="desc[]"  id="descriptions_1" size="25"  value=""/></td>
            <td><select name="uom[]" id="uom_1" style="width:50px;">
            	<option value="0">Select</option>
            </select></td>
            <td><select  name="sizesp[]" id="sizesp_1" style="width:90px;"  onchange="showconvac(this.value,this.id);"  >
			   	<option value="0">select</option>
			   	<?php
			     $resultSize=DB_query("select * from size_master",$db);
			     while($rowSize=DB_fetch_array($resultSize))
			     { ?>
			    <option value="<?php echo $rowSize['id']; ?>"><?php echo $rowSize['size']; ?></option>
			     <?php }
			   	 ?>
			   </select>  </td>
			   <td><select  name="gradesp[]" id="gradesp_1" style="width:90px;" >
			   	<option value="0">select</option>
			   	<?php
			      $resultGrade=DB_query("select * from product_grade",$db);
			      while($rowGrade=DB_fetch_array($resultGrade))
			      { ?>
			     <option value="<?php echo $rowGrade['id']; ?>"><?php echo $rowGrade['grade']; ?></option>
			       <?php }
			   	 ?>
   
           </select></td>
            <td><input type="text" name="batch_no[]"  id="batchno_1"  style="width:70px;"   /></td>
			<td><input type="text" name="stock_qty[]"  id="stock_qty_1"  style="width:70px;" /></td>
            <td><input  type="text" name="qty[]"  id="qty" style="width:70px;" onkeyup="chkstockqty(this.id,this.value)"  value=""/></td>
            <td><input  type="hidden" name="confac[]" style="width:50px;"  id="confac_1" value="<?php echo $row['conv_fac']; ?>"   /></td>
    <td width="10%"><input  type="text" name="secondaryqty[]" style="width:70px;"  id="secondary_1" value="<?php echo $secondary_qty; ?>"  readonly /></td>
            <td><select name="job_process[]" id="jobprocess_1" style="width:70px;"  >
			<option value="0">Select</option>
			<?php 
			$sql_process=DB_query("select * from job_work_master",$db);
			while($row1=DB_fetch_array($sql_process))
			{
			?>
			<option value="<?php echo $row1['id']; ?>"><?php echo $row1['jobwork_name']; ?></option>
			<?php } ?>
			</select>
			</td>
           <td><input  type="text" name="job_rate[]"  id="jobrate_1" size="15"    onkeyup="caltotal(this.id)"/></td>
		    <td><input  type="text" name="job_value[]"  id="jobvalue_1" size="15"   /></td>
           
          </tr>
        </tbody>
      </table>
    </div>
 
    <input type="hidden" name="hiditemcount" id="hiditemcount" value="" />
  <input type="hidden"  value="" id="edit_cnt" />
  <input type="hidden" name="" value="1" id="rowcount1" />
  <p style="margin-bottom:15px;"></p>
  <div id="PickedItems" style="display:none"></div>
 


<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
<td><strong>Remarks </strong></td>
<td colspan="3"><textarea name="remarks"  style="width:100%" id="remark"></textarea></td>
</tr>

<tr class="row1">
<td><strong>Expected time</strong></td>
<td style="width:150px;"><input type="text" id="expected_time" name="expected_time"  style="width:100%"  value="" /></td>
<td><strong>Appox. Value </strong></td>
<td style="width:150px;"><input type="text" id="appox_value" name="appox_value"   style="width:100%"  value=""
onfocus="calculateapprox()"  /></td>
</tr>
</table>



<p align="center">
  <input type="submit" name="Save" value="Save"  />
 
  
  
  
</p>
</form>
</div>
</div>

<script language="javascript" type="text/javascript">

$(document).ready(function(){	
		//var cnt=document.getElementById("count").value;
		$('input[name=profile_popup]').click(function(){
		var tt=this.id;
		var tt1=tt.split("_");
		var tt2=tt1[1];
		var site=document.getElementById("sitecode").value;
             if($('#sitecode').val()=='000')
           {
    	alert('Please select site.');
    	return false;
            }
     if($('#store').val()=='' || $('#store').val()==0)
     {
     	alert('Please select store.');
     	return false;
     }
     
		//var LeaveType=document.getElementById("LeaveType_"+tt2).value;
		$("#PickedItems").dialog({
				title:'Item List',
				modal: true,
				resizable: false,
				width:900,
				height:400,
				closeText: 'fechar',
				draggable: true,
				show: 'fade',
				hide: 'fade',
				dialogClass: 'main-dialog-class',
				buttons: {
					Exit: function()
					{
						$(this).dialog("close");
					}
				}
				
			});
		GetitemListForDirectPO(site);
		});
	});

function GetitemListForDirectPO(str)
{   $('#PickedItems').html('<center><span style="font-size:20px;"><strong>Loading...</strong></span></center>');
   

	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("PickedItems").innerHTML=xmlhttp.responseText;
	}
	}
    
     var store=$('#store').val();

	xmlhttp.open("GET","popup_physical_stock.php?site="+str+"&store="+store,true);
	xmlhttp.send();
}

function getItemsList(obj,id,code,shade,desc,unit,stock,ctr,confac)
{	
	//alert(confac);
var t1=document.getElementById('rowcount1').value +1;	
if(t1=='')
var rowTableCount=1;
else
var rowTableCount=parseInt(t1);
	
   if(obj.checked)
           {           
	   if(rowTableCount >1)
      addRow('dataTable');
            }
	 //alert(window.opener.document.getElementById('dataTable').getElementsByTagName("tr").length);
       
	//alert(rowTableCount);
	var dup='empty';
	var itemcount=rowTableCount;
	var counter=1;
	//alert(itemcount);
	if(document.getElementById("row_id_"+ctr).checked==true)
	{
		  
			for(var i=counter; i<=itemcount; i++)
			{				
					
				if(dup=='empty')
				{
					
				//var data= addRow('dataTable');
						
					if(document.getElementById('itemdataid_'+i))
					{				 
						if(document.getElementById('itemdataid_'+i).value=='')
						{				   		
							document.getElementById('itemdataid_'+i).value = id;
							document.getElementById('itemcode_'+i).value = code;
							document.getElementById('description_'+i).value = shade;
							document.getElementById('uom_'+i).innerHTML = unit;
							document.getElementById('Stockbalance_'+i).value = stock;
							document.getElementById('confac_'+i).value = confac;
							document.getElementById('confactor_'+i).value = confac;
							document.getElementById('rowcount1').value=rowTableCount;
							//document.getElementById('itemdesc_'+i).value = desc;	
							//document.getElementById('price_'+i).value = netrate;
							//document.getElementById('mrpper_'+i).value = mrprate;						
							break;
						}
					}
					else
					{
						continue;
					}
				}
			}
		
	}

	else
	{
		
		
			for(var i=counter; i<=itemcount; i++)
			{
			    if(document.getElementById('itemdataid_'+i))
				{
				if(document.getElementById('itemdataid_'+i).value==document.getElementById("row_id_"+ctr).value)
				{
				   document.getElementById('itemdataid_'+i).value = '';
					document.getElementById('itemcode_'+i).value = '';
					document.getElementById('description_'+i).value = '';
					document.getElementById('uom_'+i).innerHTML = '';
					document.getElementById('stock_qty_'+i).value='';
					document.getElementById('confac_'+i).value = '';
					document.getElementById('confactor_'+i).value = '';
					//document.getElementById('itemdesc_'+i).value = '';	
					//document.getElementById('price_'+i).value = '';
					//document.getElementById('mrpper_'+i).value = '';
				}
				}
			}
		}
	
	
	}

function addRow(tableID) 
{

	if(document)
	var table = document.getElementById(tableID);
	var rowCount = table.rows.length;
	var rowCount = table.rows.length;
	if(document.getElementById("hiditemcount").value=='')
	r =rowCount+1;
	else
	{
	var t=document.getElementById("edit_cnt").value;
	var t1=document.getElementById("hiditemcount").value;
	r=parseInt(t1);
	r1=parseInt(t1)+1;
	}
	var row1=document.getElementById("rowcount1").value;
	var rr=parseInt(row1)+1;
	document.getElementById("rowcount1").value=rr;
	var row = table.insertRow(rowCount);
	document.getElementById("hiditemcount").value=rr;
	document.getElementById("edit_cnt").value=rr;
	var colCount = table.rows[0].cells.length;
	for(var i=0; i<colCount; i++) {		
	var newcell = row.insertCell(i);
	//newcell.style.background='#e7e7e7';
	newcell.className='tabledata';
	newcell.innerHTML = table.rows[0].cells[i].innerHTML;
	//alert(newcell.childNodes[0].type);
	switch(newcell.childNodes[0].type) 
	{
	case "text":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+rr;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
	break;		
	case "hidden":
	newcell.childNodes[0].value = "";
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+rr;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
	break;
	case "button":
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+rr;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
	break;
	case "checkbox":
	newcell.childNodes[0].checked = false;
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+rr;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
	break;
	case "select-one":
	newcell.childNodes[0].selectedIndex = 0;
	var nod_id = newcell.childNodes[0].id.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+rr;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
	break;	
	}
		//document.getElementById("stock_perunit_"+rowCount).value=1;
	}
		//document.getElementById(countid).innerHTML=rowCount;

	}

/*function opendata(str,id)
{
var store=document.getElementById("store").value;
  var sitecode=document.getElementById("sitecode").value;
  var date=document.getElementById("date").value;

	if(document.getElementById("sitecode").value=='000')
	{
		alert("You Must Select The Site First");
		document.getElementById("sitecode").focus();
		return false;
	}
 
 if (str.length == 0)
    {    	
     document.getElementById("lightbox").innerHTML="";
     document.getElementById("lightbox").style.border="0px";
      return;
    }	
	
	

var xmlhttp;
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("lightbox").style.display='block';	
	document.getElementById("lightbox").innerHTML=xmlhttp.responseText;
	
   // document.getElementById("textitem").innerHTML=data[1];
	
    }
  }
   xmlhttp.open("GET","showpopup1.php?site="+str+"&data="+id+"&store="+store+"&site1="+sitecode+"&date="+date,true);

  //xmlhttp.open("GET","showpopup1.php?site="+str+"&data="+id,true);
	xmlhttp.send();


	
	
}
function getItemsList1(id,code,shade,rate,ctr,stock)
{ 
     
	 var ctr1=ctr.split("_");
    var i=ctr1[1]
	var itemcount=parseInt(document.getElementById('hiditemcount').value)+1;
	
	var edit_cnt=document.getElementById('edit_cnt').value;
	if(edit_cnt==''){var counter=1;} else if(edit_cnt>itemcount){var counter=edit_cnt;
	var itemcount=parseFloat(counter)+parseFloat(itemcount);
	} else  {var counter=edit_cnt;}
	  
	
	if(ctr1[1]==undefined)
	{
	//if(document.getElementById('itemdataid').value=='')
	//{
	
	document.getElementById('itemdataid').value = id;
	document.getElementById('itemcode').value = code;
	document.getElementById('descriptions').value = shade;
	document.getElementById('uom').value = rate;
	document.getElementById('stock_qty').value = stock;
	//}
	}
	else
	{
	//if(document.getElementById('itemdataid_'+i).value=='')
	//{		
	document.getElementById('itemdataid_'+i).value = id;
	document.getElementById('itemcode_'+i).value = code;
	document.getElementById('descriptions_'+i).value = shade;
	document.getElementById('uom_'+i).value = rate;
	document.getElementById('stock_qty_'+i).value = stock;
	//}	
	}	
document.getElementById("lightbox").style.display='none';

	//var data= addRow('dataTable')
	
}
function hidedata()
{
document.getElementById("lightbox").style.display='none';
}*/
 
 function deleteRowOrder(tableID) 
{
	try 
	{
		var table = document.getElementById(tableID);
		//alert(table);
		var rowCount = table.rows.length;
		//alert(rowCount);
		for(var i=0; i<rowCount; i++) 
			{
				var row = table.rows[i];
				var chkbox = row.cells[0].childNodes[0];
				if(null != chkbox && true == chkbox.checked) 
				{
					if(rowCount <= 1) 
					{
						alert("Cannot delete all the rows.");
						break;
					}
				table.deleteRow(i);
				rowCount--;
				i--;
				}
				
			}
	document.getElementById("hiditemcount").value=parseInt(rowCount)-1;		
	}
	catch(e) 
	{
		alert(e);
	}

}

function caltotal(str)
{

var id=str.split("_");
var i=id[1];
if(id[1]==undefined)
{
var jobvalue1= parseFloat(document.getElementById("qty").value)*parseFloat(document.getElementById("jobrate").value);
document.getElementById("jobvalue").value=jobvalue1.toFixed(2);

}
else
{
var jobvalue1= parseFloat(document.getElementById("qty_"+i).value)*parseFloat(document.getElementById("jobrate_"+i).value);
document.getElementById("jobvalue_"+i).value=jobvalue1.toFixed(2);
}


}


function calculateTotalExcise()
{
	alert("jobvalue");
	var rete=document.getElementById("jobvalue").value;
	alert(rete);
}

/*function addRow(tableID) 
{	
	if(document)
		var table = document.getElementById(tableID);
		
		var rowCount = table.rows.length;
		var row = table.insertRow(rowCount);
		document.getElementById("hiditemcount").value=rowCount;
		var colCount = table.rows[0].cells.length;
		for(var i=0; i<colCount; i++) {	 
            
			var newcell = row.insertCell(i);
           	//newcell.style.background='#e7e7e7';
			//  newcell.className='tabledata';
			   newcell.innerHTML = table.rows[0].cells[i].innerHTML;
				switch(newcell.childNodes[0].type) 
				{
				case "text":
					newcell.childNodes[0].value = "";
					var nod_id = newcell.childNodes[0].id;

					newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
										
				break;

				case "hidden":

					newcell.childNodes[0].value = "";

					var nod_id_hidden = newcell.childNodes[0].id;

					newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;

				break;

				case "button":

					var nod_id = newcell.childNodes[0].id;

					newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;

				break;

				case "checkbox":

				newcell.childNodes[0].checked = false;
				var nod_id_chk = newcell.childNodes[0].id;
				newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
				

				break;

				case "select-one":
				
				newcell.childNodes[0].selectedIndex = 0;
				var nod_id = newcell.childNodes[0].id;
				newcell.childNodes[0].id = newcell.childNodes[0].id+'_'+rowCount;
				break;	
			}
		}
	}
 
 */
 function calculateapprox()
{
	var totalBasic=0;
	var first_row=document.getElementById("jobvalue").value;
	if(first_row==''){first_row=0;}
	var cnt=document.getElementById("hiditemcount").value;
	var newcount=parseInt(cnt)+1;
	for(var i=1;i<newcount;i++)
	{
	 	var totalBasic1=document.getElementById("jobvalue_"+i).value;
	 	var totalBasic=(parseFloat(totalBasic)+parseFloat(totalBasic1)).toFixed(2);
	}
	  document.getElementById("appox_value").value=parseFloat(totalBasic)+parseFloat(first_row);
}
 
function chkstockqty(str,value)
{

	var id=str.split("_");
	var i=id[1];
	if(id[1]==undefined)
	{
		var StockQty=parseFloat(document.getElementById("stock_qty").value);
		var Qty=parseFloat(document.getElementById("qty").value);
		if(Qty>StockQty)
		{
			alert("You Can't Take Grater Ammount Than Available Stock");
			document.getElementById("qty").value='';
			document.getElementById("qty").focus();
			return false;
		}
	}
	else
	{
		var StockQty1=parseFloat(document.getElementById("stock_qty_"+i).value);
		var Qty1=parseFloat(document.getElementById("qty_"+i).value);
		if(Qty1>StockQty1)
		{
			alert("You Can't Take Greater Qty Than Available Stock");
			document.getElementById("qty_"+i).value='';
			document.getElementById("qty_"+i).focus();
			return false;
		}
	}
}

function showsitename158(str)
{

var xmlhttp;
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)
    {
	var data=xmlhttp.responseText.split("__");	
	
	document.getElementById("hid-Godown-div").innerHTML=data[0];
    document.getElementById("empdta").innerHTML=data[1];
	
    }
  }
  xmlhttp.open("GET","GoDownIssueSlip.php?site="+str,true);
	xmlhttp.send();

//xmlhttp.open("GET","getSort.php?s="+str+"&cat="+cat,true);

	
}

 
</script>
