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

$user=$_SESSION['admin'];
$id=$_GET["id"];
//echo "admin success!!!";
				
?>
<html>
<head>
<link href="../header.css" rel="stylesheet" type="text/css"/>
<link type="text/css" rel="stylesheet" href="../overflow.css" />
<link rel="stylesheet" type="text/css" href="../facebox/facebox.css" />
<script language="javascript" src="../jquery.js"></script>
<script language="javascript" src="../facebox/facebox.js"></script>
<script language="javascript">
$(document).ready(function() {
    $('a[rel*=facebox]').facebox();
})
</script>
 
<style type="text/css"> 
div.panel,p.flip
{
margin:0px;
padding:5px;
text-align:center;
background:#e5eecc;
border:solid 1px #c3c3c3;
}
p.flip2,div.panel2,p.flip3,div.panel3
{
margin:0px;
padding:5px;
text-align:left;
background:#FFFFFF;
border:solid 1px #c3c3c3;
}
div.panel
{
height:70px;
display:none;
}
div.panel2,div.panel3
{
height:70px;
}
</style>
</head>
</head>
<body>
<div id="content2">
<!-----------------Outer table--------------->
<table width=1000 border=0 cellspacing=10 cellpadding=3 class=outer >
<tr>
	<td colspan=2>
	<?php include("../head.php");?>
	</td>
	</tr>
<tr>
	<td colspan=2>
			<div class=main>&nbsp;&nbsp;>>
			<a href="<?php echo"../admin.php";?>">&nbsp;Home&nbsp;</a>>>
			<a href="<?php echo"viewAgent.php";?>">&nbsp;Listing Agent&nbsp;</a>>>
			&nbsp;Agent <?php echo $id;?>Company&nbsp;
			</div></td>
	</tr>
<tr>
	<td valign=top colspan=2>
	<!--------------------Inner table 2----------------------->
	<?php
	//set pages per items
	$per_page = 10;
	
	$query1=mysql_query("SELECT * from company where agentID='$id'");

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

	$page =(isset($_GET['page'])) ? (int) $_GET['page'] :1;
	$start=($page-1)*$per_page;
	
	$num = mysql_num_rows($query1);
	?>
	<table align=right>
		<tr><td>Total Sign Company :</td><td><?php echo $num; ?></td></tr>
		</table>
	
	<table class=corners cellspacing=1 cellpadding=10 width=100% align=right>
	<tr>
		<td>
<?php


//display pages
echo "<table align=center width='90%'>";
echo "<tr class=page><td width='10%'>Pages >></td><td>";
	while($i<=$total){
		echo "<a href='vCompany.php?page=$i&id=$id' align=center>$i</a>&nbsp ";
		$i++;
	}
echo "</td></tr>";
echo "</table>";
echo "<br/>";
?>	
<table align=center width=98% cellspacing=5 cellpadding=8>
	<tr class=menu>
		<th>ID</th>
		<th>Company Name</th>
		<th>Class</th>
		<th>Join Date</th>
		<th>Expire Date</th>
		<th>Action</th>
		</tr>
<?php
//load company info	
$count=0;
$query=mysql_query("select * from company where agentID='$id' order by id asc limit $start,$per_page");
if($num==0){
	echo "<tr><td align=center colspan=6>No Data</td></tr>";
}
	while($display=mysql_fetch_array($query)){
		
	$idid=$display['id'];
	$name=$display['cName'];
	$class=$display['class'];
	$address=$display['address'];
	$telNo=$display['telNo'];
	$email=$display['email'];
	$cPerson=$display['cPerson'];
	$rDate=$display['registerDate'];
	$eDate=$display['expireDate'];
	
	date_default_timezone_set ("Singapore"); 
	$ldate=date("d/m/Y", time());
	
	if($count%2==0){
		echo "<tr class=menu2>";
	}else{
		echo "<tr class=menu3>";
	}
	
	$count++;
	echo "<td align=center>".$idid."</td>";
	echo "<td align=center>".$name."</td>";
	echo "<td align=center>".$class."</td>";
	echo "<td align=center>".$rDate."</td>";
	echo "<td align=center>".$eDate."</td>";
	echo "<td align=center width=300>";
	echo "<table>
			<tr class=small><td width=50 align=center>
			<a href='editInfo.php?id=$idid&agent=$id'>
			<img src='../../images/edit.png' width=30 height=30 border=none/><br/><address>Edit</address></a>
			</td>";
	echo "<td align=center width=50><a href='viewProduct.php?id=$idid&agent=$id'>
			<img src='../../images/product.png' width=30 height=30 border=none/><br/><address>Product</address></a></td>";
	echo "<td align=center width=50><a href='updateLisence.php?id=$idid&agent=$id'>
			<img src='../../images/update.png' width=30 height=30 border=none/><br/><address>Update</address></a></td>";
	echo "<td align=center width=50><a href='viewPromote.php?id=$idid&agent=$id'>
			<img src='../../images/update.png' width=30 height=30 border=none/><br/><address>Promotion</address></a></td>";
	echo "<td align=center width=50>
			<a href='active.php?id=$idid' rel='facebox'>
			<img src='../../images/active.gif' width=30 height=30 border=none /><br/>
			<address>active</address></a></td>
			</tr></table>";
	echo "</td></tr>";
	}
	
?>	
	</table>
		</td>
		</tr>
	</table>
	<!----------------------End inner table 2-------------------->
	
	</td>
	</tr>
</table>
<!-----------------------End outer table-------------------------->
</div>


</body>
</html>