<?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" />
<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>
<style> 
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>
<body>
<!-----------------Outer table--------------->
<div id="content2">
<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"viewCompany.php";?>">&nbsp;Listing Company&nbsp;</a>>>
			&nbsp;Company <?php echo "<b>$id</b>";?> Product&nbsp;
			</div></td>
	</tr>
<tr>
	<td valign=top colspan=2>
	<!--------------------Inner table 2----------------------->
	<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 product where companyID='$id' and status!='clear'");

	$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='viewProduct.php?page=$i&id=$id' 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>Product Pic</th>
		<th>Product ID</th>
		<th>Product Name</th>
		<th>Type</th>
		<th>Price</th>
		<th>Status</th>
		<th>Action</th>
		</tr>
<?php
//load company info	
$query=mysql_query("select * from product where companyID='$id' and status!='clear' order by id asc limit $start,$per_page");
	if(mysql_num_rows($query)<1){
		echo "<tr><td colspan=7 align=center>No data</td></tr>";
	}
	while($display=mysql_fetch_array($query)){
		
	$idid=$display['id'];
	$name=$display['pName'];
	$type=$display['type'];
	$type2=$display['type2'];
	$price=$display['price'];
	$productPic=$display['productPic'];
	$status=$display['status'];
	
	date_default_timezone_set ("Singapore"); 
	$ldate=date("d/m/Y", time());
	
	if($type=="Other"){
		$type = $type2;
	}
	
	echo "<form>";
	echo "<tr class=menu2>";
	echo "<td align=center><a href='pDetail.php?user=$user&id=$idid' rel='facebox'>
			<img src='../company/album/".$productPic."' width=50 height=50/></a></td>";
	echo "<td align=center><input type=hidden name='id' value='$idid' />".$idid."</td>";
	echo "<td align=center>".$name."</td>";
	echo "<td align=center>".$type."</td>";
	echo "<td align=center>".$price."</td>";
	echo "<td align=center>".$status."</td>";
	echo "<td align=center>
			<a href='pDetail.php?id=$idid' rel='facebox'>More Detail</a>
			</td>";
	echo "</tr>";
	echo "</form>";
	}
	
?>	
	</table>
		</td>
		</tr>
	</table>
	<!----------------------End inner table 2-------------------->
	
	</td>
	</tr>
</table>
<!-----------------------End outer table-------------------------->
</div>


</body>
</html>