<?
session_start();
include("../opendb.php");
include("../test.php");
include("includes/top.php");
$brcode = $_SESSION['brcode'];
?>
<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>LOG REPORT</H3>
<?
if(isset($_POST['show']))
{
$y2=$_REQUEST['y2'];    
$m2=$_REQUEST['m2'];
$d2=$_REQUEST['d2'];
$y1=$_REQUEST['y1'];    
$m1=$_REQUEST['m1'];
$d1=$_REQUEST['d1'];
$dt = $y2."-".$m2."-".$d2." 23:59:00";
$df = $y1."-".$m1."-".$d1;
$re=mysqli_query($db,"select * from log where brcode='$brcode' and date >= '$df' and date <= '$dt' order by date");
print "<h2>LOG Report from $d1-$m1-$y1 to $d2-$m2-$y2</h2>";
$brres=mysqli_query($db,"select * from branch where brcode='$brcode'");
$brrow=mysqli_fetch_array($brres);
print "<h3>".$brrow[1]."</H3>"; 
print "<table cellspacing=1 cellpadding=2 border = '1'>";
print "<th>Sl No<th>Username <th>Date & Time<th>Action";
$i=1;
while($row=mysqli_fetch_array($re))
{ 
    print "\n<tr><td align='right'>".$i++."</td><td>".strtoupper($row['user'])."</td><td>".implode('-', array_reverse(explode('-', substr($row['date'],0,10))))." ".substr($row['date'],-8)."</td><td>$row[action]</td>";
}
?>

</table>
<?}?>
<form action='<?Print $PHP_SELF?>' method='post'>
<table class=noprint>
<tr><td>Date from </td><td>dd <input type=text name='d1' size=2 value='<?print date("d")?>'>
mm <input type=text name='m1' size=2 value='<?print date("m")?>'>
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 colspan=2 align=center bgcolor='lightsteelblue'><input type=submit value='Show' name='show'></td></tr>
</table>



