 <?
 session_start();
 include("opendb.php");
 include("test.php");
 if(strlen($user)<=0)
	{
  	print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  	return;
	}



			
                             $sql=mysqli_query($db,"select count(jcno) from gateentry where entrydate between '$st_dt' and '$end_dt' and jcno>0 and brcode='$brcode' and receivedby='$receivedby' ");
                             $qry=mysqli_query($db,"select * from gateentry where entrydate between '$st_dt' and '$end_dt' and jcno>0 and brcode='$brcode' and receivedby='$receivedby'");

                             $sql1=mysqli_query($db,"select sum(jcardserv.servamt) from jcardserv INNER JOIN gateentry ON jcardserv.jcno=gateentry.jcno where gateentry.inv_date between '$st_dt' and '$end_dt ' and jcardserv.jcno>'0' and gateentry.receivedby='$receivedby' and jcardserv.brcode='$brcode'");
                            
                            
             
             
      $ro=mysqli_fetch_row($sql);  
     $ro1=mysqli_fetch_row($sql1);




    
 ?>
<table class='tbl' id='tbl'  align='center' width='100%' border='1' bgcolor='white'>
<tr><th colspan='5'>Gate entry details</th></tr>


<tr><td COLSPAN='2'>No. of vehicle:</td><td COLSPAN='2'><?echo $ro[0]; ?></td></tr>
<tr><td COLSPAN='2'>Sum Of Labour:</td><td COLSPAN='2'><?echo $ro1[0]; ?></td></tr>
<tr><td COLSPAN='2'>Received by:</td><td COLSPAN='2'><?echo $receivedby; ?></td></tr>


<tr><th>JCNO</th><th>REGNO</th><th>DATE</th><th>LABOUR</th></tr>

<?

	while($row=mysqli_fetch_array($qry))
	{
             $qry1=mysqli_query($db,"select sum(jcardserv.servamt) from jcardserv INNER JOIN gateentry ON jcardserv.jcno=gateentry.jcno where gateentry.inv_date between '$st_dt' and '$end_dt ' and jcardserv.jcno>'0' and gateentry.receivedby='$receivedby' and jcardserv.brcode='$brcode' and jcardserv.jcno='$row[jcno]'");
		//echo "select sum(jcardserv.servamt) from jcardserv INNER JOIN gateentry ON jcardserv.jcno=gateentry.jcno where gateentry.inv_date between '$st_dt' and '$end_dt ' and jcardserv.jcno>'0' and gateentry.receivedby='$receivedby' and jcardserv.brcode='$brcode'";
$row1=mysqli_fetch_row($qry1);
             print "<tr><td>$row[jcno]</td><td>$row[regno]</td><td>".dateandtimetoHtml($row[entrydate])."</td><td>$row1[0]</td></tr>";
	}
?>
<tr><th colspan='4' height='10'></th></tr></table>
