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

$user=$_SESSION['agent'];
$month=$_GET["month"];
$year=$_GET["year"];
//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>
<div id="content2">
<body>
<?php
if($month=="jan"){
		$data="select * from licenseReport where year='$year' and month='01' and agent='$user'";
		$report = "January";
	}
	if($month=="feb"){
		$data="select * from licenseReport where year='$year' and month='02' and agent='$user'";
		$report = "February";
	}
	if($month=="mat"){
		$data="select * from licenseReport where year='$year' and month='03' and agent='$user'";
		$report = "March";
	}
	if($month=="apl"){
		$data="select * from licenseReport where year='$year' and month='04' and agent='$user'";
		$report = "April";
	}
	if($month=="may"){
		$data="select * from licenseReport where year='$year' and month='05' and agent='$user'";
		$report = "May";
	}
	if($month=="jun"){
		$data="select * from licenseReport where year='$year' and month='06' and agent='$user'";
		$report = "June";
	}
	if($month=="july"){
		$data="select * from licenseReport where year='$year' and month='07' and agent='$user'";
		$report = "July";
	}
	if($month=="aug"){
		$data="select * from licenseReport where year='$year' and month='08' and agent='$user'";
		$report = "August";
	}
	if($month=="sep"){
		$data="select * from licenseReport where year='$year' and month='09' and agent='$user'";
		$report = "September";
	}
	if($month=="oct"){
		$data="select * from licenseReport where year='$year' and month='10' and agent='$user'";
		$report = "October";
	}
	if($month=="nov"){
		$data="select * from licenseReport where year='$year' and month='11' and agent='$user'";
		$report = "November";
	}
	if($month=="dec"){
		$data="select * from licenseReport where year='$year' and month='12' and agent='$user'";
		$report = "December";
	}
?>
<!-----------------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>>>
			<a href="<?php echo"licenseReport.php";?>">&nbsp;License Report&nbsp;</a>>>
			<a href="<?php echo"licenseYear.php?year=$year";?>">&nbsp;Year <?php echo $year;?>&nbsp;</a>>>
			<a href="<?php echo"licenseMonth.php?year=$year&month=$month";?>">
			&nbsp;<?php echo $report;?>&nbsp;</a>
			</div></td>
	</tr>
<tr>
	<td width=280 valign=top>
	<!-----------Inner table 1----------------->
		<!----->
		<p class="flip" id="setting">
					&nbsp;<?php echo "Year ".$year." $report";?></p>
				
		
		<?php
			$query2=mysql_query($data);
			$total = 0;
			while($display=mysql_fetch_array($query2)){
		
			$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($data);

	$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='licenseMonth.php?page=$i&year=$year&month=$month' 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	
$total=0;
$query=mysql_query($data." order by id asc limit $start,$per_page");
	while($display=mysql_fetch_array($query)){
		
	$idid=$display['id'];
	$companyID=$display['companyID'];
	$day=$display['day'];
	$monthA=$display['month'];
	$years=$display['year'];
	$date=$display['updateDate'];
	$time=$display['updateTime'];
	$old=$display['oldExpire'];
	$new=$display['newExpire'];
	$yearA=$display['updateYear'];
	$payment=$display['payment'];
	$ptype=$display['paymentType'];
	
	$total = $payment + $total;
	
	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' rel='facebox'>".$companyID."</a></td>";
	echo "<td align=center>$date</td>";
	echo "<td align=center>".$yearA."</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='receipt4.php?id=$idid&year=$year&month=$month'>Receipt</a></td>";
	echo "</tr>";
	}
	
?>	
	</table>
	
	
		</td>
		</tr>
	</table>
	<!----------------------End inner table 2-------------------->
	
	</td>
	</tr>
</table>
<!-----------------------End outer table-------------------------->
</div>



</body>
</html>