<? 
require_once "include/application.php"; 
require_once "include/function.php";

if(!$_SESSION["egoUser"])
	print("<script type='text/javascript'>location.href='index.php'</script>");

if(!$user)$user=$_SESSION["egoUser"];

if($year && $month)	$from="$year-$month-01";
if($toyear && $tomonth)	$to="$toyear-$tomonth-31";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Daily Payout Summary Report</title>
<link rel="stylesheet" type="text/css" href="style.css" >
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	background-color: #FFFFFF;
}

-->
</style>
</head>

<body>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" >
  <tr>
    <td width="1024" height="30" colspan="2" class="TextH2"><strong>      User Log Report </strong></td>
  </tr>
  
  
  <tr>
    <td colspan="2" class="TextH1"><p>User : <? echo $user; ?><br />
      Report Date  : <? echo window_date($from)." - ".window_date($to); ?><br />
      Date Printed : <? echo date("d/m/Y") ?><br />
        <br />
        <br />
      </p>
    </td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="box">
      
      <tr>
        <td width="24%" height="25" bgcolor="#D0E3F6" class="TextH1"><div align="center">DateTime </div></td>
        <td width="28%" bgcolor="#D0E3F6" class="TextH1"><div align="center">Username</div></td>
        <td width="48%" bgcolor="#D0E3F6" class="TextH1"><div align="left">Descriptions</div></td>
        </tr>
      
    

    <?
	if($user=="all")$sql="select * from log left join user on l_user = id where l_id > '0' ";
	else $sql="select * from log left join user on l_user = id where l_user='$user' ";
	if($sReferral){
		if($sType=="Name")$sql.=" and l_user like '%$sReferral%'";			
	}	
	if($position)$sql.=" and position='$position'";
	if($active)$sql.=" and active='$active'";


	if($from && $to)$sql.=" and substring(l_created,1,10) >= '$from' and substring(l_created,1,10) <= '$to'";

	$result=mysql_query($sql) or die(mysql_error());
	while($myrow=MySQL_fetch_array($result,MYSQL_ASSOC))
	{  
		echo "<tr>";
		$datetime = new DateTime($myrow["l_created"]);		
        echo "<td height='25' class='TextH1'> <div align='center'>".$datetime->format('d/m/Y H:i A')."</div></td>";
		echo "<td class='TextH1'><div align='center'>".$myrow["l_user"]."</div></td>";		
		echo "<td class='TextH1'>".$myrow["l_desc"]."</td>";		
     	echo "</tr>";
	}
	?>


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

</table>
</body>
</html>
