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

$user=$_SESSION['admin'];
//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>>>
			&nbsp;Listing Agent&nbsp;
			</div></td>
	</tr>
<tr>
	<td valign=top colspan=2>
	<!--------------------Inner table 2----------------------->
	<form action="<?php echo"searchResult.php";?>" method="POST" >
	<table align=right cellpadding=5 cellspacing=3>
	<tr>
		<td valign=top>
		<b>Search By: </b>
		<select name="searchBy">
		<option value="id">Agent ID</option>
		<option value="cName">Agent Name</option>
		</select> :
		</td>
		<td><input type="text" name="words" /></td>
		<td><input type="submit" value="Search"></td>
		</tr>
	</table>
	</form>
	<table class=corners cellspacing=1 cellpadding=10 width=100% align=right>
	<tr>
		<td>
		<?php
//set pages per items
	$per_page = 10;
	
	$query1=mysql_query("SELECT * from agent");

	$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='80%'>";
echo "<tr class=page><td width='10%'>Pages >></td><td>";
	while($i<=$total){
		echo "<a href='viewAgent.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>Picture</th>
		<th>ID</th>
		<th>Agent Name</th>
		<th>Contact No</th>
		<th>I/C</th>
		<th>Email</th>
		<th>Join Date</th>
		<th>Status</th>
		<th colspan=4>Action</th>
		</tr>
<?php
//load company info	
$count=0;
$query=mysql_query("select * from agent order by agentID asc limit $start,$per_page");
	while($display=mysql_fetch_array($query)){
		
	$idid=$display['agentID'];
	$name=$display['name'];
	$code=$display['countryCode'];
	$cNo=$display['contactNo'];
	$ic=$display['ic'];
	$email=$display['email'];
	$pic=$display['pic'];
	$date=$display['joinDate'];
	$status=$display['status'];
	
	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><img src=upload/$pic width=40 height=40 /></td>";
	echo "<td align=center>".$idid."</td>";
	echo "<td align=center>".$name."</td>";
	echo "<td align=center>(".$code.") ".$cNo."</td>";
	echo "<td align=center>".$ic."</td>";
	echo "<td align=center>".$email."</td>";
	echo "<td align=center>".$date."</td>";
	echo "<td align=center>".$status."</td>";
	echo "<td align=center width=100>";
	echo "<table>
			<tr class=small><td width=50 align=center>
			<a href='editAgent.php?id=$idid'>
			<img src='../../images/edit.png' width=30 height=30 border=none/><br/><address>Edit</address></a>
			</td>
			<td width=50 align=center>
			<a href='vCompany.php?id=$idid'>
			<img src='../../images/edit.png' width=30 height=30 border=none/><br/><address>Company</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>