<?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="../query.js"></script>
 <script type="text/javascript">
 function selectall(FormName, FieldName, CheckValue){	
	
	
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
	}
	
function deselectall(FormName, FieldName, CheckValue){	
	
	
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
	}
 </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>>>
			<a href="<?php echo"cFeedback.php";?>">&nbsp;Company Feedback&nbsp;</a>>>
			&nbsp;Inbox&nbsp;
			</div></td>
	</tr>
<tr>
	<td width=280 valign=top>
	<!-----------Inner table 1----------------->
	<?php include("feedbackSide.php")?>
	<!-----------------End inner table 1----------------------->
	</td>
	<td valign=top>
	<!--------------------Inner table 2----------------------->
	<?php
	$per_page=7;

	$query1=mysql_query("SELECT * from inbox where companyID='$user'");
	$total=ceil(mysql_num_rows($query1)/$per_page);

	$page =(isset($_GET['page'])) ? (int) $_GET['page'] :1;
	$start=($page-1)*$per_page;	
	?>
	
	<form name="form1" action="<?php echo "deleteInbox.php";?>" method="POST">
	<table width=800 cellpadding=8 height=410 border=0 > 
	<tr height=25>
		<td colspan=2><h3 id="inbox">Inbox</h3></td>
		<td colspan=3 align=center><input type=button value='Select All' onclick=selectall('form1','checkbox[]',true)>
		  <input type=button value='Deselect All' onclick=deselectall('form1','checkbox[]',false)>&nbsp;&nbsp;&nbsp; 
		  <input type=submit name=delete value=Delete /></td>
		</tr>
	<tr height=20>
		<th></th><th></th><th>From</th><th>Title</th><th>Time</th>
		</tr>
	<?php
	$count=0;
	$query1=mysql_query("SELECT * from inbox where companyID='$user' order by inboxID desc limit $start,$per_page");
	while($display=mysql_fetch_array($query1)){
		$id=$display['inboxID'];
		$date=$display['date'];
		$time=$display['time'];
		$title=$display['title'];
		$content=$display['content'];
		$sendBy=$display['sendBy'];
		$status=$display['status'];
		
		if($status=="unread"){ $pic="letter.gif";}
		if($status=="read"){ $pic="read.png";}
		if($status=="reply"){ $pic="reply.png";}
		
	if($count%2==0){	
		echo "<tr align=center class=menu2 height=20>";
	}else{
		echo "<tr align=center class=menu4 height=20>";
	}
	$count++;
			echo"<td><input type=checkbox name='checkbox[]' value='$id' /></td>
				<td><a href='inboxView.php?id=$id' >
					<img src='icon/$pic' width=30 height=20 border=none /></a></td>
				<td>$sendBy</td>
				<td>$title</td>
				<td>$date&nbsp;&nbsp;&nbsp;$time</td>
			 </tr>";
	}
	
	?>
	<tr></tr>
	</table>
	</form>
	<table>
	<tr>
		<td>
		Page =>
		<?php
			while($i<=$total){
			echo "<a href='inboxFeed.php?page=$i&user=$user#inbox' align=center>$i</a>&nbsp ";
			$i++;
			}
		?>
		</td>
		</tr>
	</table>
	<!----------------------End inner table 2-------------------->
	
	</td>
	</tr>
</table>
<!-----------------------End outer table-------------------------->
</div>



</body>
</html>