<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='index.php' </script>";
  return;
}
include("test.php");
include("opendb.php");
$jtype=$_REQUEST['jtype'];
$vatcst=$_REQUEST['vatvl']; 
$jrqry=mysqli_query($db,"select max(invno) from amplcpurchase where brcode='$brcode' and trnstyp='$jtype' and vattyp='$vatcst'");
    if(mysqli_num_rows($jrqry)<1)
    {
	$invno='000001'; 
    }
    else
    {
	$row=mysqli_fetch_array($jrqry);
        $inv=substr($row[0],-6)+1;
	$inv=substr('000000'.$inv,-6);
	if($inv==0)
	{
		$inv='000001'; 
	}
	$invno=$inv; 
    }   
?>
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>AMPLC</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link rel="stylesheet" href="css/form.css" type="text/css" />

<link type="text/css" href="jquery/jquery-ui.min.css" rel="stylesheet" />	
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="cal/jquery-ui1.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">
        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        
</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color:#F2F2F2;

}
th{background-color:steelblue;color:white}
table.form{
font-weight: normal;border:1px;
} 
</style>
<STYLE>
#popup 
{
position: fixed; top: 60%; left: 60%; width: 200px; height: 100px; margin-left: -300px; margin-top: -200px;
  display:none;
}
</STYLE>



<script type="text/javascript">
  $(function() {
    $("#grndt").datepicker({ dateFormat: 'yy-mm-dd' });

  });
  $(function() {
    $("#pbildt" ).datepicker({ dateFormat: 'yy-mm-dd' });

  });
  </script>    





<script>
function fld_active(str){

     if(str!='Insurance'){
        document.getElementById("policereport").disabled=true;
        document.getElementById("fileno").disabled=true;
        document.getElementById("policyexcess").disabled=true;
        document.getElementById("others").disabled=true;
        document.getElementById("depreciation").disabled=true;
        
     }
     else{
        document.getElementById("policereport").disabled=false;
        document.getElementById("fileno").disabled=false;
        document.getElementById("policyexcess").disabled=false;
        document.getElementById("others").disabled=false;
        document.getElementById("depreciation").disabled=false;
        
     }
   


}

function Validate()
{
        var x = document.f1.labour.value;


if(isNaN(x)|| x.indexOf(" ")!=-1)
	{
              			alert("Enter numeric value");
                              document.f1.labour.select();
			return false;
                }


if(document.f1.customer.value=='')
 {
alert('select Customer Name');
document.f1.customer.focus();
return false; 
}

if(document.f1.dt.value.length<=0)
 {
   
alert('Enter date');
document.f1.dt.focus();
return false; 
}

if(document.f1.regno.value.length<=0)
 {
   
alert('Enter RegNo');
document.f1.regno.focus();
return false; 
}



if(document.f1.estd.value.length<=0)
 {
   
   alert('Enter estimate Date');
document.f1.estd.focus();
return false; 
}
if(document.f1.deldt.value.length<=0)
 {
   
   alert('Enter delivery Date');
document.f1.deldt.focus();
return false; 
}
if(document.f1.km.value.length<=0)
 {
   
   alert('Enter Kilometer');
document.f1.km.focus();
return false; 
}

if(document.f1.mobile.value.length<=0)
{
   
alert('Enter Mobile No');
document.f1.mobile.focus();
return false; 
}

if(document.f1.receivedby.value.length<=0)
 {
alert('Enter Received By');
document.f1.receivedby.focus();
return false; 
}

if(document.f1.instype.value=='--SELECT--')
 {
alert('select proper value');
document.f1.instype.focus();
return false; 
}

if(document.f1.work_status.value=='--SELECT--')
 {
alert('select work status');
document.f1.work_status.focus();
return false; 
}








if((document.f1.instype.value=='INSURANCE')&& (document.f1.insurance.value=='--SELECT--'))
 {
alert('Please select insurance company');
document.f1.insurance.focus();
return false; 
}

 var str=document.getElementById("instype").value;
var str1=str.toUpperCase();   
var n=str1.indexOf("INSURANCE");
//alert (n);
 if(n>=0) {
if(document.f1.policereport.value.length<=0)
 {
alert('Enter police report');
document.f1.policereport.focus();
return false; 
}
if(document.f1.fileno.value.length<=0)
{
   
alert('Enter File no');
document.f1.fileno.focus();
return false; 
}
if(document.f1.labour.value.length<=0)
{
   
alert('Enter Labour');
document.f1.labour.focus();
return false; 
}
if(document.f1.policyexcess.value.length<=0)
{
   
alert('Enter Policy excess');
document.f1.policyexcess.focus();
return false; 
}
if(document.f1.depreciation.value.length<=0)
{
   
alert('Enter Depreciation');
document.f1.depreciation.focus();
return false; 
}


}

}


  var rawTags;
   var inputField;
   var  initInputFieldValue;
   var dataList;
    var initNbVirgules ;


 /* ********* below function is to get other values from vehmast as per regno or chasisno ********* */

 function getval(str,val){

    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("txtHint").innerHTML=xmlhttp.responseText;

         if(str=='regno'){

          document.getElementById("chasisno").value=document.getElementById("cno").value;
          document.getElementById("owner").value=document.getElementById("ow").value;
          document.getElementById("customer").value=document.getElementById("ac_ow").value;
	  
         }

      if(str=='chasisno'){

          document.getElementById("regno").value=document.getElementById("rno").value;
          document.getElementById("owner").value=document.getElementById("ow").value;
           document.getElementById("customer").value=document.getElementById("ac_ow").value;
	   
         } 
       document.getElementById("textfield8").value=document.getElementById("tel_ph").value;
       document.getElementById("textfield9").value=document.getElementById("tel_mob").value;
       document.getElementById("textarea").value=document.getElementById("cus_addr").value;
       document.getElementById("textfield10").value=document.getElementById("cus_email").value;
       document.getElementById("make").value=document.getElementById('mk').value;
       document.getElementById("model").value=document.getElementById("mod").value;
          
        
     
      }
    }
xmlhttp.open("GET","getval_gateentry.php?id="+str+"&& val="+val,true);
xmlhttp.send();
}


 function print_preview(gateno){

  window.open('print_serv_order.php?gateno='+gateno);

 }
</script>






<style>
.cont
	{
       background-color:#3b5998;

	//background:url(images/bg-inner.jpg) #e9e0c3 repeat-x;
  	width: 100%;position: absolute ;
	height:99%;
    	/* Optional - just for DIV)*/
    	//border: solid 1px #000000;
	-moz-box-shadow: 0px 5px 5px #888;
	-webkit-box-shadow: 0px 5px 5px #888;
	box-shadow: 0px 5px 10px #888;
}
#pg{
       text-decoration:none;
       text-align: center;
       vertical-align: top;
}
.pgbtn{
      float:left;
margin-left: 10px;
height: 20px;
line-height: 22px;
text-align:center;
background-color:#fbfbfb;
border:1px solid #b7b7b7;
color:#606060;
cursor:pointer;
display:inline-block;
font:bold 12px/100% Arial,sans-serif;
       
}


#msg {
    height:80px auto;
    background-color:grey;
    padding:2px;
    margin-top:0px;
    border-bottom:5px solid white;
    border:5px solid #F8F8FF;
    width:150px auto;
    text_align:center;
    display: none;
    position: fixed; left: 600px; top: 0; 
    z-index: 10;
    opacity: 0.8;
    z-index: 999;
    color:white;
     }
 
  .show_hide {
    display:none;
    }


/*  code below for search button* /


/* reset webkit search input browser style */
input[type=search] {
	outline: none;
}
input[type=search] {
	-webkit-appearance: textfield;
	-webkit-box-sizing: content-box;
	font-family: inherit;
	font-size: 100%;
}
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button {
	display: none; /* remove the search and cancel icon */
}

/* search input field */
input[type=search] {
	background: #ededed url(images/search-icon.png) no-repeat 9px center;
	border: solid 1px #ccc;
	padding: 9px 10px 9px 32px;
	width: 45px;
	
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	border-radius: 10em;
	
	-webkit-transition: all .5s;
	-moz-transition: all .5s;
	transition: all .5s;
}
input[type=search]:focus {
	width: 130px;
	background-color: #fff;
	border-color: #6dcff6;
	
	-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
	-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
	box-shadow: 0 0 5px rgba(109,207,246,.5);
}

/* placeholder */
input[type=search]:-moz-placeholder {
	color: #999;
}
input[type=search]::-webkit-input-placeholder {
	color: #999;
}

#reg_sea_bttn{

       background-color: #fff;
	border-color: #6dcff6;
	
	-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
	-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
	box-shadow: 0 0 5px rgba(109,207,246,.5);
      border: solid 1px #ccc;
	padding: 9px 10px 9px 2px;
	width: 30px;
	
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	border-radius: 10em;
	
	-webkit-transition: all .5s;
	-moz-transition: all .5s;
	transition: all .5s;
       outline: none;
        -webkit-appearance: textfield;
	-webkit-box-sizing: content-box;
	font-family: inherit;
	font-size: 100%;

 }






	
</style>
<body bgcolor="#0033FF">
<div class='cont'>

<?php include('includes/top.php'); ?>

<table class="container"><tr><td>


<script type="text/javascript">

function pgnfn(str){
            document.getElementById('pgbtn'+str).style.background = "#ccc";
            document.f1.entrydate.focus();
}
</script>
<?
$xx=$_GET['id']+1;
?>
<body onload='pgnfn(<? echo $xx;?>)'>




<link href="css1/xp.css" type="text/css" rel="stylesheet" media="print,screen"  />


<?

$tbl="gateentry";
//mysqli_query($db,"drop table $tbl");


mysqli_query($db,"CREATE TABLE $tbl (gateno double(10,2) default 0,jcno double(10,2) default 0,vehiclename varchar(200),model varchar(20),regno varchar(20),chasisno varchar(50),policereport varchar(100),
instype varchar(20),insurance varchar(200),labour double(10,2) default 0,receivedby varchar(200),entrydate datetime,duedate date, brcode varchar(20),colour varchar(20),customer varchar(200),
owner varchar(200),address varchar(250),license varchar(200),remarks varchar(100),telephone varchar(100),mobile varchar(100),email varchar(100),fileno varchar(50),jobtype varchar(20),
policyexcess double(10,2),others double(10,2),depreciation double(10,2),estdate datetime,jvno varchar(100),invno int(10),kms  double(10,2),del_dt datetime,work_status varchar(100),model_det varchar(100),
adv_amt double(10,2),depr_tot double(10,2),depr_scratch double(10,2),team varchar(50))");

//	mysqli_query($db,"delete from $tbl");


if($sv)
{

$remarks='';
$i=0;

foreach($comp as $a)
{
  
  $comp[$i]=$a;
  $remarks.=$comp[$i]."*";
  $i++;
 }



$entrydate2=explode(' ',$dt);
$entrydate1=explode('-',$entrydate2[0]);
$entrydate=$entrydate1[2].'-'.$entrydate1[1].'-'.$entrydate1[0].' '.$entrydate2[1];

$estdate2=explode(' ',$estd);
$estdate1=explode('-',$estdate2[0]);
$estdate=$estdate1[2].'-'.$estdate1[1].'-'.$estdate1[0].' '.$estdate2[1];



$del_dt2=explode(' ',$deldt);
$del_dt1=explode('-',$del_dt2[0]);
$del_dt=$del_dt1[2].'-'.$del_dt1[1].'-'.$del_dt1[0].' '.$del_dt2[1];
 

  $sel=mysqli_query($db,"select * from  amplcpurchase where jcno='$jcno' and brcode='$brcode'");
  if (mysqli_num_rows($sel)<=0)
    {
         $jcno=$jcno;
    }
    else{
         $jcmax=mysqli_query($db,"select max(jcno) from gateentry where brcode='$brcode'");
         $row3=mysqli_fetch_array($jcmax);
         $jcno=$row3[0]+1;
    }
    //echo $jcno;

  $sql="insert into $tbl values('$gateno','$jcno','$make','$model','$regno','$chasisno','$policereport','$instype','$insurance','$labour','$receivedby','$entrydate',
'$duedate','$brcode','$colour','$customer','$owner','$address','$license','$remarks','$telephone','$mobile','$email','$fileno','$jobtype','$policyexcess','$others','$depreciation','$estdate','','0','$km','$del_dt','$work_status','$model_det','$adv_amt','$depr_tot','$depr_scratch','$team','','0','$entrydate','$entrydate','','0','0','0000-00-00')";
  //mysqli_query($db,$sql) or die(mysqli_error($db));



$re=mysqli_query($db,"select * from vehmaster where regno='$regno' and chasisno='$chasisno'");
if (mysqli_num_rows($re)<=0)
{

  $sql="insert into vehmaster values('$regno','$chasisno','$make','$model','$colour','$owner','$address','$mobile','$telephone','$customer')";
  //mysqli_query($db,$sql) or die(mysqli_error($db));

}

//mysqli_query($db,"insert into jcworking_status values('','$jcno','$regno','$work_status','$entrydate','$entrydate','$remarks','$brcode','$team')");
// print"<script>window.open('print_serv_order.php?gateno=$gateno');</script>"; 

}



if($del)
{
  //mysqli_query($db,"delete from machmaster where code='$code'");
}
?>

<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-latest.js"></script>
<body background="back_ground.jpg">
<form name='f1' action='<?print $PHP_SELF?>'  method='post'> 

<br>
<table class="container" bgcolor="#0033FF"><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;"> </font>
<br>
<center>
<body bgcolor="#0033FF">


<? $query=mysqli_query($db,"select trnstyp from transactmast where trnsid='$jtype'");
$rw=mysqli_fetch_array($query);
 ?>


<form action="" method="get" name='f1' >
<table width="100%" border="1" cellpadding="1" cellspacing="1" align="center" class='form'>
  <tr>
    <td colspan="7" bgcolor="#666"><h3 style="color:#fff"><strong><? echo $rw[0]; ?></strong></h3></td>
    </tr>
  <tr>
    <td width="135">SAP Invoice No.</td>

<?
 $jcres=mysqli_query($db,"select max(gateno) from gateentry where brcode='$brcode'");
 $jcrow=mysqli_fetch_row($jcres);
 if($jcrow[0]<=0)
   $gateno=1;
 else
  $gateno=($jcrow[0]+1);
?>

    <td colspan="4"><input name="grnno"  type="text" id="grnno"   this.focus() size="20" value='<?print $invno?>'  onkeypress="return handleEnter(this, event)"/></td>
    <td width="164">Entry Date</td>

<?
 $jcres=mysqli_query($db,"select max(jcno) from gateentry where brcode='$brcode'");
 $jcrow=mysqli_fetch_row($jcres);
 if($jcrow[0]<=0)
   $jcno=1;
 else
  $jcno=($jcrow[0]+1);
?>
    <td width="327"><input  name="grndt" type="text" id="grndt" size="20" value='<? echo date('Y-m-d') ?>'  onkeypress="return handleEnter(this, event)"/></td>
   
   
  </tr>
<?
if(($jtype=='CS')||($jtype=='JC')||($jtype=='SR'))
{
$pmpqr="select acname from customer where brcode='$brcode' order by acname asc";
}
if(($jtype=='PR')||($jtype=='PV'))
{
$pmpqr="select supname from sup_master where branch='$brcode' order by supname asc";
}

$pmprs=mysqli_query($db,$pmpqr);

?>



<tr><td>customer</td><td colspan="4"><select name="supnm" id="supnm" onkeypress="return handleEnter(this, event)" style="width:345px;" >
      <option>--SELECT--</option>
<? while($pmrow=mysqli_fetch_array($pmprs))
{
?>
  <option value="<? echo $pmrow[0] ?>"><? echo $pmrow[0] ?></option>
<?
 }
 ?>
    </select>

</td>


   
   
 <td width="164">spares</td>
    <td width="327">

<select name="sparfrtn" id="sparfrtn" onkeypress="return handleEnter(this, event)" style="width:150px;" >
      <option>--SELECT--</option>
<option value='14.5'>14.5</option>
<option value='5.5'>5.5</option>
<option value='5'>5</option>
</select>
</td>
  </tr>
  <tr>
<td>LUBRICANT</td>
    <td colspan="4">
<select name="lubfrtn" id="lubfrtn" onkeypress="return handleEnter(this, event)" style="width:150px;" >
<option>--SELECT--</option>
<option value='14.5'>14.5</option>
<option value='5.5'>5.5</option>
<option value='5'>5</option>
</select>
</td>
    
<td width="164">tax</td>
    <td width="327"><select name="taxfrtn" id="taxfrtn" onkeypress="return handleEnter(this, event)" style="width:150px;" >
<option>--SELECT--</option>
<option value='14.5'>14.5</option>
<option value='5.5'>5.5</option>
<option value='5'>5</option>
</select></td>


  </tr>
  <tr>
<td >Labour</td>
    <td colspan="4"><input name="labamt" type="text" id="labamt" size="20"  onkeypress="return handleEnter(this, event)" class="labamt" onKeyup='calamt(this.value,this,this.id)' /></td>


<td >servicetax</td>
 <td colspan="4">

<input name="srvtx" type="text" id="srvtx" size="20"  onkeypress="return handleEnter(this, event)" onKeyup='calamt(this.value,this,this.id)' class="srvtx"/></td>
    

</tr>
<tr>
    

<td>sbc</td>
   <td colspan="4">
<input name="sbc" type="text" id="sbc" size="20" class='sbc' onKeyPress="return handleEnter(this, event)" onKeyup='calamt(this.value,this,this.id)' />


</td>




<td >KKCESS</td>
 <td colspan="4">

<input name="kkcs" type="text" id="kkcs" size="20"  onkeypress="return handleEnter(this, event)" class="kkcs"/></td>
 
    
</tr>
 
<tr>
<td >others/handling</td>
 <td colspan="4">

<input name="others" type="text" id="others" size="20"  onkeypress="return handleEnter(this, event)" class="others" onKeyup='calamt(this.value,this,this.id)' /></td>
 <td >round off</td>
    <td colspan="4"><input name="roundof" type="text" id="roundof" size="20"  onkeypress="return handleEnter(this, event)" onKeyup='calamt(this.value,this,this.id)' class="roundof"/></td>   

</tr> 
 <tr>



<td >Total</td>
 <td colspan="8">
<input name="ntamt" type="text" id="ntamt" size="20"  onkeypress="return handleEnter(this, event)" class="ntamt"/></td>
</tr> 

<tr><td colspan=8 align=center bgcolor='lightsteelblue'>
<input type=submit value='Save' name='sv' onclick="return Validate()"> 
</td></tr>




</table>
</form>
<br><br>


<?



if(!isset($_GET['id'])){
     $_GET['id']=0;
  }
if($search_bttn){

  $fldnm='regno';
  $fldval=$sea_reg;
 if($sea_jcno !=''){

  $fldnm='jcno';
  $fldval=$sea_jcno;

 }
  $qry=mysqli_query($db,"select count(*) from gateentry where brcode='$brcode' and $fldnm='$fldval' ");
}
else{
$qry=mysqli_query($db,"select count(*) from gateentry where brcode='$brcode'");
 }



$qry1=mysqli_fetch_array($qry);
$cnt=$qry1[0];


if($search_bttn){
 $rowcnt=$cnt;
}
else{

$rowcnt=50;

}

$pgno=floor($cnt/$rowcnt);
if(($cnt%$rowcnt)>0){
   $pgno=$pgno+1;
}
print "<table align='center' id='pagen' width='100%'><tr>";

  if($pgno>6){
      
     if($_GET['id']>0)
        $m=$_GET['id']-1;
     else
        $m=$_GET['id'];
      
  }
$nxtid=$_GET['id']+2;
$nxtval=$_GET['id']+1;
$prvid=$_GET['id']-2;
$prval=$_GET['id']-1;
$flg=1;
for($i=$m;$i<$pgno;$i++){
    $j=$i+1;
     
    if(($flg==1)&& ($_GET['id']>0)){
       print "<td><a href='gateentry2.php?id=$prval' id='pg'><input type='button' class='pgbtn' id='pgbtn".$prvid."' value='Previous' /></a></td>";
    }

    if(($_GET['id']==2) && ($flg==1)){
       print "<td><a href='gateentry2.php?id=0' id='pg'><input type='button' class='pgbtn' id='pgbtn1' value='1' /></a></td>";
    }

    if(($_GET['id']>=3) && ($flg==1)) {
       print "<td><a href='gateentry2.php?id=0' id='pg'><input type='button' class='pgbtn' id='pgbtn1' value='1' /></a></td><td>...</td>";
    }

    if($flg<5){
       print "<td><a href='gateentry2.php?id=$i' id='pg'><input type='button' class='pgbtn' id='pgbtn".$j."' value='".$j."' /></a></td>";
    }

    if($flg==5){
       print "<td>.</td><td>.</td><td>.</td>"; 
       $i=$pgno-2; 
    }

    if($flg==6){  
 	  
       print "<td><a href='gateentry2.php?id=$i' id='pg'><input type='button' class='pgbtn' id='pgbtn".$j."' value='".$j."' /></a></td>";
 	print "<td><a href='gateentry2.php?id=$nxtval' id='pg'><input type='button' class='pgbtn' id='pgbtn".$nxtid."' value='Next' /></a></td>";  
    }
  
    $flg++;
}


print "<td width='480'></td><td width='400' align='right' id='sea_td'><form name='f2' action='gateentry2.php' method='post'><input type='search' name='sea_reg' placeholder='Search By Regno'>&nbsp;<input type='search' name='sea_jcno' placeholder='Search By Jcno'><input type='submit' value='Go' id='reg_sea_bttn' name='search_bttn'/></form></td></tr></table>";
?>



<?



$lmt1=$_GET['id']*$rowcnt;
$k=$lmt1+1;

if($search_bttn){

  $fldnm='regno';
  $fldval=$sea_reg;

 if($sea_jcno !=''){

  $fldnm='jcno';
  $fldval=$sea_jcno;

 }
 

 $result=mysqli_query($db,"select * from  amplcpurchase where brcode='$brcode' and $fldnm='$fldval' and trnstyp='$jtype'  order by invdate desc limit $lmt1,$rowcnt");

}

else{
$result=mysqli_query($db,"select * from  amplcpurchase where brcode='$brcode' and trnstyp='$jtype' order by invdate desc limit $lmt1,$rowcnt ");
}
?>

<table cellspacing=1 cellpadding=5 class='report'>
    <th>No.

    <th>InvoiceNo
    <th>Date
    <th>Supplier/Customer
    <th>BillNo
    <th>BillDate
    <th>0% Schedule
<th> Bearing Schedule 5%
<th> spares Schedule 14.50%
 <th> batterySchedule 14.50%
 <th> lube schedule before tax
 <th> discount
 <th> Others
 <th> Total
 <th> Action
<?

while($row=mysqli_fetch_array($result))
{
?>

  <form action=''><input type=hidden name='jcno' value=<? echo $row[id] ?>>
   <tr>
    <td ><? echo $k++;?></td>
    <td><?print $row[invno]?></td>
    <td ><?print $row[invdate]?></td>
    <td ><?print $row[customer]?></td>
    <td ><?print $row[vehno]?></td>
    <td ><?print $row[bildt]?></td>
<td ><?print $row[zerprc]?></td>
<td ><?print $row[fiveprc]?></td>
<td ><?print $row[frtntx]?></td>
<td ><?print $row[frtntx]?></td>
<td ><?print $row[lubamt]?></td>
<td ><?print $row[discount]?></td>
<td ><?print $row[others]?></td>
<td ><?print $row[total]?></td>
    <td ><input type=submit value='Edit' name='edit'><input type=button value='Print' name='print' onclick="print_preview('<?print $row[0]; ?>')"></td>
  </tr>
</form>
<? 
}

?>


 </table>


<datalist id="htmlListTags"></datalist>
<div id='txtHint'></div>
</body>
</html>


</td></tr></table>

<script>


  var cur=2;
  var comp=[];
  

  function add_comp(){
 
     
     var rowCount = document.getElementById('comp_table').rows.length;
     var x=document.getElementById('comp_table').insertRow(rowCount);
     var a=x.insertCell(0);
     var b=x.insertCell(1);
     var dd=x.insertCell(2);
     a.innerHTML=cur;
     b.innerHTML="<input type='text'  name=comp[] id=comp"+cur+"  class='comp'  placeholder='Complaints..'/>";  
     dd.innerHTML="<input onClick='delrow(this)'  value='X' type='button' class='del' >";
     cur++;

  }

 function delrow(r)
{
 var i=r.parentNode.parentNode.rowIndex;
 document.getElementById('comp_table').deleteRow(i); 
 }  
function calamt(str,r,qid)
{
   
    var fvtx=document.getElementById("fivebfrtx").value-document.getElementById("discnt").value;

    document.getElementById("fivetax").value=parseFloat(fvtx*(5/100)).toFixed(2);
    
    if(document.getElementById("sprfrtn").value>0)
        {
        var frtnvl=document.getElementById("sprfrtn").value-document.getElementById("discnt").value;
        document.getElementById("fourteentax").value=parseFloat(frtnvl*(14.5/100)).toFixed(2);
        }
    

    if(document.getElementById("btryfrtn").value>0)
        {
        var btfrtn=document.getElementById("btryfrtn").value-document.getElementById("discnt").value;
        document.getElementById("fourteentax").value=parseFloat(btfrtn*(14.5/100)).toFixed(2);
        }
     if(document.getElementById("lubamt").value>0)
     {
     var lubvl=document.getElementById("lubamt").value-document.getElementById("discnt").value;
     document.getElementById("lubtx").value=parseFloat((lubvl)*(document.getElementById("vatcst").value/100)).toFixed(2);
     }

if(document.getElementById("zerobfrtx").value=='')
{
document.getElementById("zerobfrtx").value=0;
}
if(document.getElementById("fivebfrtx").value=='')
{
document.getElementById("fivebfrtx").value=0;
}
if(document.getElementById("fivetax").value=='')
{
document.getElementById("fivetax").value=0;
}
if(document.getElementById("sprfrtn").value=='')
{
document.getElementById("sprfrtn").value=0;
}
if(document.getElementById("fourteentax").value=='')
{
document.getElementById("fourteentax").value=0;
}
if(document.getElementById("btryfrtn").value=='')
{
document.getElementById("btryfrtn").value=0;
}
if(document.getElementById("lubamt").value=='')
{
document.getElementById("lubamt").value=0;
}
if(document.getElementById("lubtx").value=='')
{
document.getElementById("lubtx").value=0;
}
if(document.getElementById("discnt").value=='')
{
document.getElementById("discnt").value=0;
}
if(document.getElementById("others").value=='')
{
document.getElementById("others").value=0;
}
if(document.getElementById("roundof").value=='')
{
document.getElementById("roundof").value=0;
}
  var netamt=parseFloat(document.getElementById("zerobfrtx").value)+parseFloat(document.getElementById("fivebfrtx").value)+parseFloat(document.getElementById("fivetax").value)+parseFloat(document.getElementById("sprfrtn").value)+parseFloat(document.getElementById("fourteentax").value)+parseFloat(document.getElementById("btryfrtn").value)+parseFloat(document.getElementById("lubamt").value)+parseFloat(document.getElementById("lubtx").value)-parseFloat(document.getElementById("discnt").value)+parseFloat(document.getElementById("others").value)+parseFloat(document.getElementById("roundof").value);


document.getElementById("ntamt").value=netamt.toFixed(2); 
//var netamt=Math.round(document.getElementById("ntamt"+id1).value);
//var rondofvl= netamt-document.getElementById("ntamt"+id1).value;

 //document.getElementById("roundof"+id1).value=Math.abs(rondofvl).toFixed(2);     
}
</script>
<style>
.comp{
  width:250px;
  }
</style>

