<? 
session_start();
$brcode=$_SESSION['brcode'];
$hbrcode=$_SESSION['hbrcode'];
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}

include("opendb.php");
$rs=mysqli_query($db,"select max(invno) from veh_trans where brcode='$brcode'")or die(mysqli_error($db));
$p_row=mysqli_fetch_row($rs);
if(strlen($p_row[0])<=0)
  	$pno="001";
else
{
   	$pno=substr($p_row[0],-3)+1;
   	$pno=substr("000".trim($pno),-3);
};
$query="select brman from branch where brcode ='$brcode'";
$rs=mysqli_query($db,$query);
$brw=mysqli_fetch_array($rs);

$query1="select acfrom,acto from acperiod";
$rs1=mysqli_query($db,$query1);
$brw1=mysqli_fetch_array($rs1);

$myear=substr($brw1[0],2,2).substr($brw1[1],2,2);
$pno = $brw[0]."DC".$myear.$pno;


   	
//print $brcode;
$sprint = $_REQUEST['sprint'];
if($sprint)
{ 
    
    $i=0;
	$transno=$_REQUEST['transno'];
	foreach($transno as $a)
	{
 		$transno[$i]=$a; 
 		$i++;
	}
	$i=0;
    $transdate=$_REQUEST['transdate'];
	foreach($transdate as $a)
	{
 		$transdate[$i]=$a; 
 		$i++;
	}
	$i=0;
	$materdtls=$_REQUEST['materdtls'];
	foreach($materdtls as $a)
	{
 		$materdtls[$i]=$a; 
 		$i++;
	}
	$i=0;
    $qty=$_REQUEST['qty'];
	foreach($qty as $a)
	{
 		$qty[$i]=$a; 
 		$i++;
	}
	$i=0;
    $unitprice=$_REQUEST['unitprice'];
	foreach($unitprice as $a)
	{
 		$unitprice[$i]=$a; 
 		$i++;
	}
	$i=0;
    $hsncod=$_REQUEST['hsncod'];
	foreach($hsncod as $a)
	{
 		$hsncod[$i]=$a; 
 		$i++;
	}
	$i=0;
	$gstprc=$_REQUEST['gstprc'];
	foreach($gstprc as $a)
	{
 		$gstprc[$i]=$a; 
 		$i++;
	}
	$i=0;
	$remarks=$_REQUEST['remarks'];
	foreach($remarks as $a)
	{
 		$remarks[$i]=$a; 
 		$i++;
	}
    
    $y = $_REQUEST['y'];
    $d = $_REQUEST['d'];
    $m = $_REQUEST['m'];
    $invno = $_REQUEST['pno'];
    $consignor = $_REQUEST['consignor'];
    $conaddr = $_REQUEST['conaddr'];
    $consignee = $_REQUEST['consignee'];
    $cnsaddr = $_REQUEST['cnsaddr'];
       $refno = $_REQUEST['refno'];
 	$invdate=$y.'-'.$m.'-'.$d;
 	
 	
 	$taxtyp = $_REQUEST['taxtyp'];
 	
 	
 	
 	for($j=0;$j<$i;$j++)
{
    if($qty[$j]>0)
    {
    $netamt =$unitprice[$j]*$qty[$j];
    $cgstamt=0;$sgstamt=0;$igstamt=0;
    if($taxtyp=='INTRASTATE')
 	{
 	$cgstamt=$netamt*($gstprc[$j]/2)/100;
 	$sgstamt=$netamt*($gstprc[$j]/2)/100;
 	}
 	else
 	{
 	    $igstamt=$netamt*$gstprc[$j]/100;
 	}
    
    $amt2   =$netamt+$cgstamt+$sgstamt+$igstamt;
    
 	$sql="insert into veh_trans(invno,cust,custaddr,consignee,consaddr,invdate,config,unit,segment,chasis,brcode,addr,qty,remark,taxp,cgstamt,sgstamt,igstamt,netamt,amt2,type,fin) values('$invno','$consignor','$conaddr','$consignee','$cnsaddr','$transdate[$j]','$materdtls[$j]','$unitprice[$j]','$hsncod[$j]','$da','$brcode','$addr','$qty[$j]','$remarks[$j]','$gstprc[$j]','$cgstamt','$sgstamt','$igstamt','$netamt','$amt2','$taxtyp','$refno')";
    print $sql;
    echo "<br>";
    //print $brcode;
	mysqli_query($db,$sql) or die(mysqli_error($db));
}
}
	print "<script>window.open('ter_printinv_delchln.php?inno=$invno');</script>";
	$cure=mysqli_query($db,"select code,custname from cust_master where code='$cust'");
	$cust_row=mysqli_fetch_row($cure);
	$cust_name=strtoupper($cust_row[1]);
	print "<script>document.location='veh_trans.php'</script>";

} // end save

?>
<link type="text/css" href="jquery/jquery-ui.min.css" rel="stylesheet" />	
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type="text/javascript" src="jquery/jquery-1.7.min.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery/jquery.jqEasyCharCounter.min.js"></script>
<script type="text/javascript">
function shortkey_tblopen(){
               
               var rowCounts = document.getElementById('myTable').rows.length;
		 if(rowCounts<=1){
		          
			document.getElementById('insrowbttn').click(); 
               }		   					
 		 
 }

</script>
<script type="text/javascript">
 var count1=0;
 var empname=[];

 var cur=1;
 //var partcode=[];
 var partname=[];
 var unitprice=[];
 var qty=[];
 var tot=[];
 var typ=[];
 var cnt=1;

  $(function() {

    $("#transdate1").datepicker({
	dateFormat: "yy-mm-dd"
   });
 });
function insRow(event,i1,id2)
{

var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

var cur_val=i1.value;


switch(keyCode)
{
case 38:
   var row=i1.parentNode.parentNode.rowIndex;
   var col  =i1.parentNode.cellIndex ;
			 
   document.getElementById('myTable').rows[row-1].cells[col].getElementsByTagName("input")[0].focus();
  break;
case 40:
  var row=field.parentNode.parentNode.rowIndex;
  var col  =field.parentNode.cellIndex ;
			 
   document.getElementById('myTable').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();
			
  break;
case 37:
  var row=field.parentNode.parentNode.rowIndex;
  var col  =field.parentNode.cellIndex ;
			 
  document.getElementById('myTable').rows[row].cells[col-1].getElementsByTagName("input")[0].focus();
	
}



if(id2!="insrowbttn")
  {
   var i2=i1.parentNode.parentNode.rowIndex;
   var i3=parseFloat(i2)+parseFloat(1);
   var rowCounts = document.getElementById('myTable').rows.length;
   var rowCounts1= rowCounts-1;
   
  
  }
else
  {
   var i2=0;
   var rowCounts1=0;
  }
//alert(cur);



if(((keyCode == 13) && (i2==rowCounts1))||(cnt==1))
 {
var rowCount = document.getElementById('myTable').rows.length;
var rowcount1=parseFloat(rowCount)+parseFloat(1);
//alert(rowCount);
var x=document.getElementById('myTable').insertRow(rowCount);


if(rowCount>=1)
 {
  document.getElementById('insrowbttn').type='hidden';
 }

var a=x.insertCell(0);
var b1=x.insertCell(1);
var c1=x.insertCell(2);
var d1=x.insertCell(3);	
var e1=x.insertCell(4);
var f1=x.insertCell(5);
var g1=x.insertCell(6);
var h1=x.insertCell(7);
var q1=x.insertCell(8);

var z1=x.insertCell(9);
var w1=x.insertCell(10);
var k;//=this.rowIndex;
var k1;
a.innerHTML=cur;


b1.innerHTML="<input type=text name=transno[] id=transno"+cur+"  class='partcode' value='<? echo $pno ?>' size=15 autocomplete='off' list='partcodelist' onKeydown='return handleEnter(this, event)' readonly>";
c1.innerHTML="<input type=text name=transdate[] id=transdate"+cur+"  class='invoice_date' size=15  autocomplete='off' value=<? echo date('Y-m-d') ?> list='partlist' onKeydown='return handleEnter(this, event)' >"; 
d1.innerHTML="<input type=text name=materdtls[] id=materdtls"+cur+"  class='partname' size=25  autocomplete='off' list='partlist' onKeydown='return handleEnter(this, event)' >"; 

e1.innerHTML="<input type=text name='qty[]' class='xx' id=qty"+cur+" size=4 onKeydown='return handleEnter(this, event)' >";//onKeyup=validnum(this.id)
f1.innerHTML="<input type=text name=unitprice[] id=unitprice"+cur+" size=9 class='unitprice' onfocus='sel(this.id)' onKeydown='return handleEnter(this, event)'>";
g1.innerHTML="<input type=text name=hsncod[] id=hsncod"+cur+" size=9 class='hsncod' onfocus='sel(this.id)' onKeydown='return handleEnter(this, event)' >";

var v="";
v="<select name='gstprc[]' id=gstprc"+cur+" class='gstprc' onKeydown='return handleEnter(this, event)'  >";
v=v+'<option>28</option>';
v=v+'<option>18</option>';
v=v+'<option>0</option>';
h1.innerHTML=v+"</select> "; 

var v1="";
v1="<select name='gstprc1[]' id=gstprc1"+cur+" class='gstprc1' onchange='showregister(this.value,this,this.id)'  onKeydown='return handleEnter(this, event)'  >";
v1=v1+'<option></option>';
v1=v1+'<option>Float</option>';
v1=v1+'<option>Failed</option>';

q1.innerHTML=v1+"</select> "; 

z1.innerHTML="<input type=text id='remarks"+cur+"' name=remarks[] size=15 class='tot' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' onKeyup='insRow(event,this,this.id)'  >";
w1.innerHTML="<input type='button' onClick='delrow(this)' class='del' id=del"+cur+">";
document.getElementById("transdate"+cur).focus();
cur++; 

cnt++;
var table = document.getElementById("myTable");
var row = table.rows[index];
console.log(secondRow.id);
}
if(keyCode == 40)
{
return handleEnter(this, event);
}
if(keyCode == 13)
{

var tbl = document.getElementById('myTable');
   var id3=tbl.rows[i3].cells[0].innerHTML;
document.getElementById("partcode"+id3).focus();
} 

}// end function insrow
</script>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:c1d7bb}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>

<script>
var adr=[];
var adr2=[];
var ar1=[];
var config=[];
var model=[];
var rep=[];
var area=[];
var color=[];
var engno=[];
var chasis=[];
var mcode=[];
var cust=[];
function fun1()
{
 	var x=document.f1.config.selectedIndex; 
 	if(x<=0)
   	{
     		document.f1.mcode.value='';
     		document.f1.config.value='';
   	}
 	else
  	{ 
    		document.f1.mcode.value=mcode[document.f1.config.selectedIndex];
  	}
}

   
    
function showregister(str6,r6,str26)
{
    var i=r6.parentNode.parentNode.rowIndex;
    var tbl = document.getElementById('myTable');
    var id1=i;
    if (str6=="")
    {
        document.getElementById("to_new_registerTD").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.f1.remarks.value=xmlhttp.responseText;   
               // document.getElementById("remarks"+id1).value=document.getElementById("mblamt").value;
                
            document.f1.remarks.value=document.getElementById("mblamt").value;

        }
      
    }
    
xmlhttp.open("GET","showtype1.php?cname1="+str,true);
    xmlhttp.send();
}

function valid()
{
 submitOK="true";
 if(document.f1.qty.value<=0 || isNaN(document.f1.qty.value))
 {
   submitOK="false";
   alert('Invalid Quantity');
   document.f1.qty.focus();
 }
 if(document.f1.invno.value.length<=0)
 {
   submitOK="false";
   alert('Invalid Invoice No.');
 }
if(document.f1.cust.value.length<=0)
 {
   submitOK="false";
   alert('Invalid Customer');
 }
 /* if(document.f1.fin.value.length<=0)
 {
   submitOK="false";
   alert('Invalid Financer');
 }

 if(document.f1.formno.value.length<=0)
 {
   submitOK="false";
   alert('Invalid Formno');
 }
*/
 if(document.f1.unit.value.length<=0)
 {
   submitOK="false";
   alert('Invalid unit price');
 }
/*
 if(document.f1.segment.value.length<=0)
 {
   submitOK="false";
   alert('Invalid Segment');
 }
*/
  if(submitOK=="true")
   return true;
  else
   return false;
}

function chkey(abc)
{
 yy=abc.value
 if(yy.indexOf(' ')>-1) 
  {
    alert('Space is not allowed');
    abc.value='';
  }
}

function setadr()
{
  var x= document.f1.cust.selectedIndex ; 
  if(x>0)
    document.f1.addr.value=adr[document.f1.cust.selectedIndex];
  else
    document.f1.addr.value='';
}
function setModel()
{
  var x= document.f1.formno.selectedIndex ; 
  if(x>0)
    {
     document.f1.model.value=model[document.f1.formno.selectedIndex];
     document.f1.rep.value=rep[document.f1.formno.selectedIndex];
     document.f1.area.value=area[document.f1.formno.selectedIndex];
     document.f1.cust.value=cust[document.f1.formno.selectedIndex];
     document.f1.addr.value=adr[document.f1.formno.selectedIndex];

   }
  else
    {
      document.f1.model.value='';
     document.f1.rep.value='';
     document.f1.area.value='';
   }

}
function getamt()
{
var str1;

str1=document.f1.da.value;

 
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("txt1").innerHTML=xmlhttp.responseText;
	
 document.f1.config.value=document.getElementById("drivbatta").value;
document.f1.engno.value=document.getElementById("incrent").value;
 document.f1.unitpr.value=document.getElementById("incrent1").value;

    }
  }
xmlhttp.open("GET","calcdata.php?chsno="+str1,true);
xmlhttp.send();
}
function getaddr(str)
{
    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)
        {
            //alert(xmlhttp.responseText);
            //document.getElementById("txt1").innerHTML=xmlhttp.responseText;
            
            document.f1.conaddr.innerHTML=xmlhttp.responseText;
        }
    }
    //var url="getaddress.php?custnm="+str;
    //alert(url);
    xmlhttp.open("GET","getaddress.php?custnm="+str,true);
    xmlhttp.send();
}
function getaddr1(str2)
{
    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("txt1").innerHTML=xmlhttp.responseText;
	        document.f1.cnsaddr.value=xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET","getaddress1.php?custnm="+str2,true);
    xmlhttp.send();
}
function handleEnter (field, event) {
               
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 


                if (keyCode == 38){
                    var row=field.parentNode.parentNode.rowIndex;
			 var col  =field.parentNode.cellIndex ;
			 
                     document.getElementById('myTable').rows[row-1].cells[col].getElementsByTagName("input")[0].focus();
			
			 
              }

                  if (keyCode == 40){
                    var row=field.parentNode.parentNode.rowIndex;
			 var col  =field.parentNode.cellIndex ;
			 
                     document.getElementById('myTable').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();
			
			 
              }
                     if (keyCode == 37){


                    /* var row=field.parentNode.parentNode.rowIndex;
			 var col  =field.parentNode.cellIndex ;
			 
                     document.getElementById('myTable').rows[row].cells[col-1].getElementsByTagName("input")[0].focus();*/

                   var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i - 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
			
			 
              }
               
                   	 if (keyCode == 46){
			  var i=field.parentNode.parentNode.rowIndex;
			  
                       var r=confirm("Do you want to delete the row?");
			  if (r==true)
 				 {
 					//document.getElementById('myTable').deleteRow(i);
					delrow(field);
                                  document.getElementById('myTable').rows[i].cells[1].getElementsByTagName("input")[0].focus();
                                  
					//var nxt =document.getElementById('myTable').rows[i].cells[0].innerHTML;
					//alert(nxt);
  				 }
			  
        }
                   
		else
		return true;
	}
</script>


<style>
input,body,td{font-family:'arial narrow';letter-spacing:1;font-size:13}
th{background-color:green;color:white}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory' onload="shortkey_tblopen();">

<form name='f1' action='<?print $PHP_SELF?>' onSubmit="return valid()">
<table cellspacing=1 cellpadding=1 bgcolor=black>
<tr><td align=center bgcolor='GRAY'><FONT COLOR='IVORY'><B>CUSTOMER DETAILS</TD></TR>
<TR><td align=center bgcolor='ivory'>
<table>
<? /*<tr><td><font color=red>Consignor</td><td>
<? 
$result=mysqli_query($db,"select * from consign_mast where hbrcode='$brcode' order by name asc")or die(mysqli_error($db));
?>
<select name='consignor' onChange='getaddr(this.value)'>
<option>Select One</option>
<?
while($row=mysqli_fetch_array($result))
{
    print "\n<option>$row[name]</option>";
}
?>
</select>
<td>Address </td><td><textarea name='conaddr' cols=40></textarea></td></tr>
<tr>
*/?>
<tr><td><font color=red>Consignee</td><td>
<? $result=mysqli_query($db,"select * from consign_mast  order by name asc")or die(mysqli_error($db));
?>
<select name='consignee' onChange='getaddr1(this.value)'>
<option>Select One</option>
<?
while($row=mysqli_fetch_array($result))
{
    print "\n<option>$row[name]</option>";
}
?>
<td>Address </td><td><textarea name='cnsaddr' cols=40></textarea></td></tr>
<tr>
    
    
    
    <tr>
<tr><td><font color=red>Tax Type</td><td>

<select name='taxtyp'>
<option value='INTRASTATE'>INTRASTATE</option>
<option value='INTERSTATE'>INTERSTATE</option>
</select>
</tr>
<tr><td>Ref: No.</td><td><input type=text name='refno' size='20' ></td></td></tr>
<tr>
    
    
    
    
    
    
</table>
</td></tr>
</table>
<br>
<CENTER>

<table cellspacing=1 cellpadding=1 bgcolor=green style="border-collapse:collapse;" width='100%'>
<tr  bgColor='c1d7bb'><td align=center>
<table border=1 cellspacing=1 cellpadding=2 style="border-collapse:collapse;" width='100%'>
<tr bgColor='c1d7bb'><td colspan=7 align=center bgcolor='green'>
<font color='ivory'><STRONG>TRANSFER NO. (Trans No:
<?

print $pno.')';
?>
<input type=hidden name='pno' value='<?print $pno?>'>
</TD></TR>
<tr>
</tr>


<tr><td colspan='6'>      
<input type="button" id='insrowbttn' onclick="insRow(event,this,this.id)" style="color:#6B6B6B;font-weight:bold;font-size:15px;" value="+">
<br>
<table border=1 id="myTable" class='tble1' width=100%>
<tr class='trcls'><td>Sl No.</td><td>Transfer No.</td><td>Transfer Date</td><td>Material</td><td>Qty</td><td>Unit Price</td><td>Hsncode</td><td>GST %</td><td>Remarks</td><td>  </td><td>Del</td></tr>
</table>







<tr><th colspan=6  bgcolor='green'> 

<input type=submit  value=' SAVE AND PRINT BILL ' name='sprint'>

<input type=button value='  CANCEL  ' onClick=history.back(1)></th></tr>
</table>
</form>
</td></tr>
</table>
</center>
<br>
<script>
function calc()
{
/*
qty=parseInt(document.f1.qty.value);
document.f1.amt2.value=(document.f1.unit.value-document.f1.disc.value)*qty;
 //net=parseFloat(document.f1.netamt.value);
 amt=(document.f1.amt2.value* 14.5)/100; 
 document.f1.tax.value=parseFloat(amt).toFixed(2);
var netamt2=parseFloat(document.f1.amt2.value)+parseFloat(document.f1.tax.value);
document.f1.netamt.value=netamt2.toFixed(0);

 //var tax=parseFloat(document.f1.amt2.value)*parseFloat(document.f1.taxp.value)/100;
// document.f1.tax.value=(net-amt).toFixed(2);
 //document.f1.tax.value=(tax).toFixed(2);
 //var cessper=parseFloat(document.f1.cessp.value).toFixed(0);
// var ces_amt=parseFloat((document.f1.tax.value*cessper)/100);
 //document.f1.cessamt.value=ces_amt.toFixed(2);
*/

/*
document.f1.netamt.value=(document.f1.unit.value-document.f1.disc.value);
 net=parseFloat(document.f1.netamt.value);
 amt=(net*100)/112.5; 
 document.f1.amt2.value=parseFloat(amt.toFixed(2));

 tax=parseFloat(document.f1.amt2.value)*parseFloat(document.f1.taxp.value)/100;
 document.f1.tax.value=(net-amt).toFixed(2);
*/



//old

qty=parseInt(document.f1.qty.value);
document.f1.netamt.value=(document.f1.unit.value-document.f1.disc.value)*qty;
 net=parseFloat(document.f1.netamt.value);
 amt=(net* 100)/114.5; 
 document.f1.amt2.value=parseFloat(amt).toFixed(2);

 tax=parseFloat(document.f1.amt2.value)*parseFloat(document.f1.taxp.value)/100;
// document.f1.tax.value=(net-amt).toFixed(2);
 document.f1.tax.value=(tax).toFixed(2);
 var cessper=parseFloat(document.f1.cessp.value).toFixed(0);
 var ces_amt=parseFloat((document.f1.tax.value*cessper)/100);
 document.f1.cessamt.value=ces_amt.toFixed(2);

/*
document.f1.netamt.value=(document.f1.unit.value-document.f1.disc.value);
 net=parseFloat(document.f1.netamt.value);
 amt=(net*100)/112.5; 
 document.f1.amt2.value=parseFloat(amt.toFixed(2));

 tax=parseFloat(document.f1.amt2.value)*parseFloat(document.f1.taxp.value)/100;
 document.f1.tax.value=(net-amt).toFixed(2);
*/
}

function calcKA()
{
var tx_red=1+parseFloat(document.f1.taxp.value)/100;
qty=parseInt(document.f1.qty.value);
document.f1.netamt.value=(document.f1.unit.value-document.f1.disc.value)*qty;
 net=parseFloat(document.f1.netamt.value);
// amt=(net/1.135); 
   amt=(net/tx_red); 
 document.f1.amt2.value=parseFloat(amt).toFixed(2);

 tax=parseFloat(document.f1.amt2.value)*parseFloat(document.f1.taxp.value)/100;
// document.f1.tax.value=(net-amt).toFixed(2);
 document.f1.tax.value=(tax).toFixed(2);
 var cessper=parseFloat(document.f1.cessp.value).toFixed(0);
 var ces_amt=parseFloat((document.f1.tax.value*cessper)/100);
 document.f1.cessamt.value=ces_amt.toFixed(2);
  document.f1.tax.value=parseFloat(tax).toFixed(2);

/*
document.f1.netamt.value=(document.f1.unit.value-document.f1.disc.value);
 net=parseFloat(document.f1.netamt.value);
 amt=(net*100)/114; 
 document.f1.amt2.value=parseFloat(amt.toFixed(2));

 tax=parseFloat(document.f1.amt2.value)*parseFloat(document.f1.taxp.value)/100;
 document.f1.tax.value=(net-amt).toFixed(2);
*/
}
</script>



