<?
session_start();
include_once('includes/top.php');
include("opendb.php");
include("test.php");

?>
<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
	th{background-color:lightsteelblue;color:black}
	td{font-size:12}
.right{text-align:right};
</style>

<center>
<h3>VEHICLE IN/OUT REPORT </H3>
<?
if(isset($_POST['show']))
{
$y2=$_REQUEST['y2'];    
$m2=$_REQUEST['m2'];
$d2=$_REQUEST['d2'];
$y1=$_REQUEST['y1'];    
$m1=$_REQUEST['m1'];
$d1=$_REQUEST['d1'];
$br1=$_REQUEST['branch1'];
$dt = $y2."-".$m2."-".$d2;
$df = $y1."-".$m1."-".$d1;
$re=mysqli_query($db,"select * from vehinout where brcode='$br1' and indate >= '$df' and indate <= '$dt' and outdate!='0000-00-00' order by indate");
print "<table bgcolor='steelblue' border=1 cellspacing=1 cellpadding=2>";
print "<th>Slno<th>In No<th>Regno<th>customer<th>mob</th><th>InDate<th>Intime<th>Out Date<th>Out Time <th>Days<th>Remarks<th>Branch";
$brna=getbrname($br1);
$i=1;
$ss=1;
$toutqty=0;
$tamt=0;
while($row=mysqli_fetch_array($re))
{ 
    
    $dtin=$row[indate];
    $dtout=$row[outdate];
//print $rr[1];
$sq="select to_days('$dtout')-to_days('$dtin')";
$dtre=mysqli_query($db,$sq)or die(mysqli_error($db));
$dtrow=mysqli_fetch_row($dtre);

    if($i%2==0)
        print "\n<tr bgcolor='aliceblue'>";
    else
        print "\n<tr bgcolor='white'>";
    print "\n<td>$ss</td><td>$row[slno]</td><td>$row[regno]</td><td> $row[customer]</td><td>$row[contactno]</td><td>".datetohtml($row[indate])."</td>";
    print "<td>$row[intime] $row[inttype]</td><td>".datetohtml($row[outdate])."</td>";
    print "<td>$row[outtime] $row[outttype]</td>";
    
    print "<td>$dtrow[0]</td><td align=right>$row[remarks] </td><td align=center>$brna </td></tr>";
    
    $i++;
       $ss++;
    
}
?>

</table>
<?}?>
<form action='<?Print $PHP_SELF?>' method='post'>
<table  class="container">
<tr><td>Date from </td><td>dd <input type=text name='d1' size=2 value='01'>
mm <input type=text name='m1' size=2 value='04'>
yy <input type=text name='y1' size=4 value='<?print date("Y")?>'></td></tr>

<tr><td align=right>to </td><td>dd <input type=text name='d2' size=2 value='<?print date("d")?>'>
mm <input type=text name='m2' size=2 value='<?print date("m")?>'>
yy <input type=text name='y2' size=4 value='<?print date("Y")?>'>
</td></tr>
<tr><td>Branch</td><td><select name='branch1'>
    
    
    <?$rebr=mysqli_query($db,"select brcode from branch where  brstate='KERALA' order by brcode");

while($rowbr=mysqli_fetch_array($rebr))
{
print"<option>$rowbr[0]</option>";
}

?>
   </select> 
    
</td></tr>
<tr><td colspan=2 align=center bgcolor='lightsteelblue'><input type=submit value='Show' name='show'></td></tr>


</table>



