<?php
include("../session.php");
include("../connect.php");

$user=$_SESSION['agent'];
//echo "admin success!!!";
?>

<html>
<head>
<link href="header.css" rel="stylesheet" type="text/css"/>
<link type="text/css" rel="stylesheet" href="overflow.css" />
<script type="text/javascript" src="jquery.js"></script>
<link rel="stylesheet" type="text/css" href="facebox/facebox.css" />
<script language="javascript" src="facebox/facebox.js"></script>
<script language="javascript">
$(document).ready(function() {
    $('a[rel*=facebox]').facebox();
})
</script>
</head>
<body>
<div id="content2">
<!-----------------Outer table--------------->
<table width=1000 border=0 cellspacing=10 cellpadding=3>
<tr>
	<td colspan=2 >
	<?php include("head.php");?>
	</td>
	</tr>
<tr>
	<td colspan=2>
	<div class=main>&nbsp;&nbsp;>>
			<a href="<?php echo"agent.php";?>">&nbsp;Home&nbsp;</a>>>
			&nbsp;License Report&nbsp;
			</div></td>
	</tr>
<tr>
	<td width=280 valign=top>
	<!-----------Inner table 1----------------->
	<a href="<?php echo"reportSummary.php";?>"><p class=flip id=setting>Summary</p></a>
				
		<?php
		$year=2012;
		$count=0;
		while($year<2030){
			$query=mysql_query("Select * from licensereport where year='$year' and agent='$user'");
			if(mysql_num_rows($query)>0){
				if($count%2==0){
					echo "<a href='licenseYear.php?year=$year'><p class='flipA' id='setting'>$year</a><br/>";
				}else{
					echo "<a href='licenseYear.php?year=$year'><p class='flipB' id='setting'>$year</a><br/>";
				}
			}
			$year++;
			$count++;
		}
		?>
		<?php
			$query=mysql_query("Select * from licensereport where agent='$user'");
			$total = 0;
			while($display=mysql_fetch_array($query)){
		
			$payment=$display['payment'];
			
			$total = $payment + $total;
			}
			
			echo "<p align=center><b>Total Income :</b><br/>RM ".$total."</p>";
		?>
	<!-----------------End inner table 1----------------------->
	</td>
	<td valign=top>
	<!--------------------Inner table 2----------------------->
	<table class=corners cellspacing=1 cellpadding=10 width=98% align=left border=0>
	<tr>
		
<td>
<?php
//set pages per items
	$per_page = 10;
	
	$query1=mysql_query("SELECT * from licenseReport");

	$total=ceil(mysql_num_rows($query1)/$per_page);

	$page =(isset($_GET['page'])) ? (int) $_GET['page'] :1;
	$start=($page-1)*$per_page;
	

//display pages
echo "<table align=center width='90%'>";
echo "<tr class=page><td width='15%'>Pages >></td><td>";
	while($i<=$total){
		echo "<a href='licenseReport.php?page=$i' align=center>$i</a>&nbsp ";
		$i++;
	}
echo "</td></tr>";
echo "</table>";
echo "<br/>";
?>	
<table align=center width=100% cellspacing=5 cellpadding=8>
	<tr class=menu>
		<th>ID</th>
		<th>Company ID</th>
		<th>Renew Time</th>
		<th>Update Year</th>
		<th>Next Expire Date</th>
		<th>Payment Type</th>
		<th>Payment</th>
		<th>Action</th>
		</tr>
<?php
//load company info	
$query=mysql_query("Select * from licensereport where agent='$user' order by licensereport.id asc limit $start,$per_page");
	while($display=mysql_fetch_array($query)){
		
	$idid=$display['id'];
	$companyID=$display['companyID'];
	$day=$display['day'];
	$month=$display['month'];
	$years=$display['year'];
	$date=$display['updateDate'];
	$time=$display['updateTime'];
	$old=$display['oldExpire'];
	$new=$display['newExpire'];
	$year=$display['updateYear'];
	$payment=$display['payment'];
	$ptype=$display['paymentType'];
	
	date_default_timezone_set ("Singapore"); 
	$ldate=date("d/m/Y", time());
	
	echo "<tr class=menu2>";
	echo "<td align=center>".$idid."</td>";
	echo "<td align=center><a href='cDetail.php?id=$companyID&user=$user' rel='facebox'>".$companyID."</a></td>";
	echo "<td align=center>$date</td>";
	echo "<td align=center>".$year."</td>";
	echo "<td align=center>".$new."</td>";
	echo "<td align=center>".$ptype."</td>";
	echo "<td align=center width=100>
			RM $payment
			</td>";
	echo "<td><a href='receipt2.php?id=$idid'>Receipt</a></td>";
	echo "</tr>";
	}
	
?>	
	</table>
		
		</td>
		</tr>
	</table>
	<!----------------------End inner table 2-------------------->
	
	</td>
	</tr>
</table>
<!-----------------------End outer table-------------------------->
</div>



</body>
</html>