<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;
}
</style>


<div id="div_id" style="display:none"></div>
<div id="PickedItems" style="display:none"></div>

<?php
if($_REQUEST['Save'])
{

	 $prefix=$s->getField('companies','CompanyId',$_SESSION['ACGCompanyId'],'company_code');
	$prefix_sql=DB_query("Select * from prefix_tbl where prefix_name='".$_REQUEST['frmid']."'",$db);
	$prefix_row=DB_fetch_array($prefix_sql);
	$prefix1=$prefix_row['prefix_code'];
	
	$financial=substr($_SESSION['YearStart'],-2)."-".substr($_SESSION['YearEnd1'],-2);
	  $sql="Select nrgpno from nrgp_challan where branch='".$_REQUEST['sitecode']."' 
	and INSTR(`nrgpno`, '$financial') > 0 order by nrgpno desc limit 0,1";

	$result=DB_query($sql,$db);
	$myrow=DB_fetch_array($result);
	//echo DB_num_rows($result);
	if(DB_num_rows($result)>0)
	{
	//$Reqno=$myrow['Reqno'];
	//$req_part1=substr($Reqno,-4);
         if($prefix!='')
			{
			$ExplBill=explode("/",$myrow['nrgpno']);
			$maxval = $ExplBill[4];
		    }
		    else
		    {
		    $ExplBill=explode("/",$myrow['nrgpno']);
			$maxval = $ExplBill[3];
		    }			
	//$ExplBill=explode("/",$myrow['Reqno']);
	//$maxval = $ExplBill[3];
	//echo $req_part1;
	$req_final=$maxval+1;
	}else
	{
	$req_final="1";
	}
	        if($prefix!='')
			 $string=$prefix."/".$_REQUEST['sitecode']."/".$financial."/".$prefix1."/";
		     else
		     $string=$_REQUEST['sitecode']."/".$financial."/".$prefix1."/";

	//$string=$prefix."/".$_REQUEST['site']."/".$financial."/";
	   $final_string=$string.str_pad($req_final,4,"0",STR_PAD_LEFT);

	$data['branch']=$_REQUEST['sitecode'];
	$data['store']=$_REQUEST['store'];
	$data['nrgpno']=$final_string;
	$data['document_type']=$_REQUEST['doc_type'];
	$data['date']=FormatDateForSQL($_REQUEST['date']);
	$data['supplier']=$_REQUEST['vendor'];
	$data['removal_date']=FormatDateForSQL($_REQUEST['removedate']);
	$data['removal_time']=$_REQUEST['removetime'];
	$data['form_no']=$_REQUEST['formname'];
	$data['vehicle_no']=$_REQUEST['vehicle'];
	$data['remarks']=$_REQUEST['remarks'];
	$data['Created_by']=$_SESSION['UserID'];
	$data['CompanyId']=$_SESSION['ACGCompanyId'];
	$data['Created_date']=date('Y-m-d');
	$data['transaction_time']=date("Y-m-d H:i:s");
	$s->RecordInsert('nrgp_challan', $data);
	$Lastreq_id=DB_Last_Insert_ID($db,'nrgp_challan',$ErrMsg);
	for($i=0;$i<count($_REQUEST['itemdataid']);$i++)
	{
	if($_REQUEST['itemdataid'][$i]!='' ){
	$data1['parant_id']=$Lastreq_id;
	$data1['item_code']= $_REQUEST['itemdataid'][$i];
	$data1['batch_no']= $_REQUEST['batch_no'][$i];
	$data1['stock_qty']= $_REQUEST['stock_qty'][$i];
	$data1['qty']= $_REQUEST['qty'][$i];
	$data1['size_id']= $_REQUEST['sizesp'][$i];
	$data1['grade_id']= $_REQUEST['gradesp'][$i];
	$data1['reason']= $_REQUEST['reason'][$i];
	$s->RecordInsert('nrgp_challan_details', $data1);
	
	                
	
	
	
	
	
	}
	}
	
$s->pageLocation("index.php?route=Inventory/transation/nrgpchallan_index".$rurl);//PAGE REDIRCTION
}
?>





<link rel="stylesheet" href="css/new_mxerp.css">
<br />
<div class="body_contain">
<div class="tab_div">
<h1><strong>NRGP</strong></h1>
<form name="form1" action="" method="post" >
<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr class="row1">
    <td class="tabledata1"><strong>Branch</strong></td>
    <td class="tabledata1" >
	<?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 class="tabledata1">NRGP No </td>
    <td class="tabledata1" >
    	<input type="text"size="20" style="width:100%" readonly="readonly" value="Auto Generate On Save"/> 		</td>
</tr>

<tr  class="row1"> <td class="tabledata1"><strong>Document Type .</strong></td>
    <td class="tabledata1" >
      <select name="doc_type" style="width:100%" >
        <option value="0">Select</option>
		<option value="NRGP Challan">NRGP Challan</option>
      </select>
    </td>
    <td class="tabledata1">Date</td>
    <td class="tabledata1" ><input type="text"size="20" value="<?php echo date('d/m/Y'); ?>" name="date" id="datePick"  style="width:100%" readonly="readonly" />	</td>
</tr>

<tr  class="row1">
    <td class="tabledata1"><strong>Supplier</strong></td>
    <td class="tabledata1">
	<div id="vendorNm">
	  <select name="vendor" id="vendor" style="width:100%" >
        <option>Select</option>
		<?php
			$sql="Select id,vendor_name from suppliers where CompanyId='".$_SESSION['ACGCompanyId']."' AND site IN ('".$_SESSION['AssignedBranch']."')";
			$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>
        </div>
		</td>
	
		<?php
		  $timezone = "Asia/Calcutta";
			if(function_exists('date_default_timezone_set')) date_default_timezone_set($timezone);
			  $t=date("g:i a", time()); 
		?>
    <td class="tabledata1">Remove Date & Time</td>
    <td class="tabledata1" >
    	<div id="dept"><input type="text" id="removeDate" name="removedate" size="20" style="width:49%" readonly="readonly" />&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="row1">
    <td class="tabledata1"><strong>Form No </strong></td>
    <td class="tabledata1" ><span style="margin-bottom:15px;">
      <input name="formname" id="formname" type="text" style="width:100%"size="20" />
    </span></td>
    <td class="tabledata1">Vehicle No.</td>
    <td class="tabledata1" > <input type="text"size="20" name="vehicle" id="vehicle"   style="width:100%" />	</td>
</tr>
<tr  class="row1"><td class="tabledata1"><strong>Store</strong></td>
<td class="tabledata1" ><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>
   
    </select></div></td>
<td colspan="2"></td>

    </tr>

<tr class="row1">
<td class="tabledata1"  colspan="4">
<input type="button" name="profile_popup" value="Pick Items" id="profile_popup" class="search" />	
<input type="button" class="search"   onclick="deleteRow_return('dataTable')" value="Delete" />   </td></tr>
</table>  

      <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><strong>Batch No.</strong></td>
		  <td colspan="2"><strong>Specification</strong></td>
		  <td><strong>Stock Qty.</strong></td>
          <td><strong>Qty</strong></td>
          <td><strong>Reason</strong></td>		   
        </tr>
        <tbody id="dataTable">
       <tr>
         <td ><input name="delitem[]" type="checkbox" value="<?php echo $item_row['id'];?>" id="delitem" /></td>
            <td ><input  type="hidden"   readonly=""  id="itemid"  name="itemdataid[]" /></td>
            <td ><input type="text" value="" tabindex=""   id="itemcode" name="itemcode[]"
			onkeyup="opendata(this.value,this.id)"/>
            </td>
            <td><input type="text" name="desc[]"  id="itemname"   value=""/></td>
            <td><input type="text" name="uom[]" id="Unit" value=""  readonly /> </td>
              <td><input type="text" name="batch_no[]"  id="batchno"    /></td>
              <td><select  name="sizesp[]" id="sizesp_1"     >
   	<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" >
   	<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="stock_qty[]" readonly="true"  id="Stockbalance"    /></td>
            <td><input  type="text" name="qty[]" onkeypress="return isNumberKey(event)"  id="qty" onkeyup="chkstockqty(this.id,this.value)"   value=""/></td>
            <td><select name="reason[]" id="reason" >
			<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>
           
          </tr>
        </tbody>
      </table>
    
    <input type="hidden" name="hiditemcount" id="hiditemcount" value="" />
  <input type="hidden" name="" value="0" id="edit_cnt" />
    <input type="hidden" name="" value="0" id="rowcount1" />
  
  <p style="margin-bottom:15px;"></p>
 
 


<table width="100%" border="1" cellpadding="3" cellspacing="0">
<tr  class="row1">
<td class="tabledata1"><strong>Remarks </strong></td>
<td colspan="3"><textarea name="remarks"  style="width:100%" id="remark"></textarea></td>
</tr>
</table>
<p align="center">
  <input type="submit" name="Save" value="Save"   class="search"/>
 
  
  
  
</p>
</form>
</div>
</div>
<script type="text/javascript">
//$.noConflict();
$(function() {
$("#datePick,#removeDate").datepicker({ dateFormat: 'dd/mm/yy', 
    minDate:'0'});
});

function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : event.keyCode;
          if (charCode != 46 && charCode > 31 
            && (charCode < 48 || charCode > 57))
             return false;

          return true;
       } 
</script>
<script type="text/javascript" language="javascript">
//$.noConflict();
$(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;
	    var store=document.getElementById("store").value;
	    var date1=document.getElementById("datePick").value;
		//var LeaveType=document.getElementById("LeaveType_"+tt2).value;

       if(site=='0' && date1=='')
       {
       alert("Plz select Site First");
       return false
       }
       if($('#store').val()=='' || $('#store').val()==0)
       {
       	alert('Please select store.');
       	return false;
       }
       else
      {

		$("#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,store,date1);
	}
		});
	});
	
	function GetitemListForDirectPO(str,store,date1)
{
	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;
	}
	}

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

function getItemsList(id,code,shade,desc,ctr,current)
{  
	
  var dup='empty';
	var itemcount=parseInt(document.getElementById('rowcount1').value)+1;
	
	var edit_cnt=document.getElementById('edit_cnt').value;
	//alert(edit_cnt);
	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;
	}
	
	
	
	
	//alert(counter);
//IF WE CHECK THE CHECK BOX FOR SELECT ANY ITEM***********************START HERE******************************************
	if(document.getElementById("row_id_"+ctr).checked==true)
	{
	    
       
		if(document.getElementById('itemid') && document.getElementById('itemid').value=='')
		{
			if(edit_cnt=='')
			{
				var counter=0;
			}
		
			for(var j=0; j<counter; j++)
			{
           alert(document.getElementById('itemid1_'+j));
           if(document.getElementById('itemid1_'+j))
            {
				if(document.getElementById('itemid1_'+j).value==id)
				{
					alert("Duplicate Value"); 
					document.getElementById("row_id_"+ctr).checked=false;
					var dup = "dup";
					break;
				}
            }
			}
			
			if(dup=='empty')
			{	
				
				document.getElementById('itemid').value = id;
				document.getElementById('itemcode').value = code;
				document.getElementById('itemname').value = shade;	
				document.getElementById('Unit').value =desc ;		
				document.getElementById('Stockbalance').value =current ;					
				//document.getElementById('instrumentname').value = desc;	
				
				
			}
		} 
		
		else
		{
		
		
			for(var i=counter; i<=itemcount; i++)
			{			
				if(edit_cnt=='')
				{
					var counter=0;
				}
				for(var j=0; j<counter; j++)
				{}
				if(document.getElementById('itemid'))
				{
				if(document.getElementById('itemid').value==id)
				{
					alert("Duplicate Value");
					document.getElementById("row_id_"+ctr).checked=false;
					break;
				}
				}
				if(document.getElementById('itemid1_'+i))
				{
				if(document.getElementById('itemid_'+i).value==id)
				{
					alert("Duplicate Value"); 
					document.getElementById("row_id_"+ctr).checked=false;
					break;
				}
				}
				
				if(dup=='empty')
				{
				if(!document.getElementById('itemid_'+i))
				{						
				var data= addRow('dataTable');	
				}
					if(document.getElementById('itemid_'+i))
					{	
					
					if(document.getElementById('itemid_'+i).value=='')
					{	
						document.getElementById('itemid_'+i).value = id;
						document.getElementById('itemcode_'+i).value = code;
						document.getElementById('itemname_'+i).value = shade;
						document.getElementById('Unit_'+i).value =desc ;		
				         document.getElementById('Stockbalance_'+i).value =current ;
						//document.getElementById('instrumentname_'+i).value = desc;	
												
						break;
					}
					}
					else
					{
						continue;
					}
				}
			}
		}
	}
	
//IF WE CHECK THE CHECK BOX FOR SELECT ANY ITEM***********************END HERE******************************************


//IF WE UNCHECK THE CHECK BOX FOR DESELECT ANY ITEM***********************START HERE******************************************
	else
	{
		if(document.getElementById('itemid').value==document.getElementById("row_id_"+ctr).value)
		{
			document.getElementById('itemid').value = '';
			document.getElementById('itemcode').value = '';
			document.getElementById('itemname').value = '';
			document.getElementById('Unit').value = '';		
				document.getElementById('Stockbalance').value = '';
			//document.getElementById('instrumentname').value = '';
		}
		else
		{
			for(var i=counter; i<itemcount; i++)
			{
				if(document.getElementById('itemid_'+i).value==document.getElementById("row_id_"+ctr).value)
				{
					document.getElementById('itemid_'+i).value = '';
					document.getElementById('itemcode_'+i).value = '';
					document.getElementById('itemname_'+i).value = '';
					document.getElementById('Unit_'+i).value = '';		
				document.getElementById('Stockbalance_'+i).value = '';
					//document.getElementById('instrumentname_'+i).value = '';
				}
			}
		}
	}
//IF WE UNCHECK THE CHECK BOX FOR DESELECT ANY ITEM***********************END HERE******************************************
}
function deleteRow_return(tableID) 
	{
		
	 if($('#dataTable').find('input[type="checkbox"][name="delitem[]"]:checked').length > 0)	
         {
		try 
		{
			var table = document.getElementById(tableID);
			//alert(table);
			var rowCount = table.rows.length;
			
			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--;
					}
				}

		}
		catch(e) 
		{
			alert(e);
		}
   }
   else
   	alert('Please select at least one row for delete.');
	}
	

function addRow(tableID) 
{
		
	var table = document.getElementById(tableID);
	var rowCount = table.rows.length;
	var row = table.insertRow(rowCount);
	document.getElementById("hiditemcount").value=rowCount;
	var row1=document.getElementById("rowcount1").value;
	var rr=parseInt(row1)+1;
	document.getElementById("rowcount1").value=rr;
	document.getElementById("edit_cnt").value=rr;
	var colCount = table.rows[0].cells.length;
	for(var i=0; i<colCount; i++) {	
	//var newCount=parseInt(rowCount)+parseInt(edit_cnt)-1;
	var newCount=parseInt(rowCount);
	var newcell = row.insertCell(i);
	//newcell.style.background='#e7e7e7';
	//newcell.className='tabledata';
	$('.datepicker').removeClass('hasDatepicker').datepicker({ dateFormat: 'dd/mm/yy',changeMonth: true, changeYear: true,yearRange: '-80:+20'});
	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.split("_");
	if(!isNaN(nod_id[1]))
	newcell.childNodes[0].id = nod_id[0]+'_'+rr;
	else
	newcell.childNodes[0].id = nod_id[0]+'_'+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]+'_'+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]+'_'+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]+'_'+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]+'_'+rr;
	
	break;	
	}
		//document.getElementById("stock_perunit_"+rowCount).value=1;
	}
	
	
}





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=(rowCount);		}
	catch(e) 
	{
	alert(e);
	}
}



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

function opendata(str,id)
{
 
 if(document.getElementById("sitecode").value=='000')
	{
		alert("You Must Select The Site First");
		document.getElementById("sitecode").focus();
		return false;
	}
	 if(document.getElementById("store").value=='')
	{
		alert("You Must Select The Store First");
		document.getElementById("store").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];
	
    }
  }
  var store=document.getElementById("store").value;
  var sitecode=document.getElementById("sitecode").value;
  var date=document.getElementById("date").value;

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


	
	
}

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 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("Stockbalance").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("Stockbalance_"+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'];
     document.getElementById("vendorNm").innerHTML=data['3'];
	
    }
  }
  xmlhttp.open("GET","GoDownIssueSlip_etp.php?site="+str,true);
	xmlhttp.send();

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

	
}

</script>
