<?php
session_start();
ob_start();

require("../includes/config.php");
require("../includes/dbcon.php");
if($_SESSION['uid']==""){	
	header("location:index.php");
	exit();
}

$enrolleeOfficerQuery = mysql_query("select * from enrollee_eo where eo_id=".$_SESSION['uid']);
while($enrolleeOfficerValue = mysql_fetch_array($enrolleeOfficerQuery))
{
	$enrollee_id=$enrolleeOfficerValue['enrollee_id'];

	$enrolleeQuery = mysql_query("select * from enrollee where current_status_code!=3 and activFlag=1 and enrollee_id=".$enrollee_id." order by curDate");
	$i = 0;
	while($enrolleeValue = mysql_fetch_array($enrolleeQuery))
	{
		$enrollee_id=$enrolleeValue['enrollee_id'];
		$enrolleeName=$enrolleeValue['fisrt_name']." ".$enrolleeValue['middle_name']." ".$enrolleeValue['last_name'];
		$currentStatus=$enrolleeValue['current_status_code'];
		
		$statusQuery = mysql_query("select * from status where status_id=".$currentStatus);
		$statusValue = mysql_fetch_array($statusQuery);
		$status=$statusValue['status']; 	

		$enrolleeDocQuery = mysql_query("select * from enrollee_documents where enrollee_id=".$enrollee_id);
		$enrolleeDocValue = mysql_fetch_array($enrolleeDocQuery);
		$docId=$enrolleeDocValue['document_id']; 
		
		if($docId)
		{		
			$docDetailsQuery = mysql_query("select * from documents where document_is=".$docId);
			$docDetailsValue = mysql_fetch_array($docDetailsQuery);
			$docLink=$docDetailsValue['document_link'];
		}

		$assoArr[$i]=array('eId'=>$enrollee_id,
						'Name'=>$enrolleeName,
						'Status'=>$currentStatus,
						'docLink'=>$docLink,
						'status'=>$status);
		$i++;
	}
}
//print count($assoArr);
ob_end_flush();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../style/design.css" rel="stylesheet" type="text/css" />

<style type="text/css">
<!--
.style1 {font-size: 0.8em}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>:::   User List Page   :::</title>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td align="center" valign="top">
<?php
include_once("includes/header.php");
?>
	<table width="50%" border="0" align="center" cellpadding="0" cellspacing="0">	 
	 <tr>
	   <td width="30%" valign="top">
		<div class="bodySubHeader">
		<span class="bsht03">User List</span>		
		</div>
		</td>
	 </tr> 
	</table>	

	<table width="50%" border="0" align="center" cellpadding="0" cellspacing="0" class="DarkLightBox">	 
	 <?php
		if(count($assoArr)>0)
		{
	 ?>
	 <tr>
	   <td height="30" align="left" valign="top" colspan="3">
			<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">		 
				<tr>			
					<td align="left" valign="top" class="whyJoinThree" width="30%"><b>Photo</b></td>		
					<td align="left" valign="top" class="whyJoinThree" width="40%"><b>Name</b></td>
					<td align="center" valign="top" class="whyJoinThree" width="10%"><b>Status</b></td>
					<td align="right" valign="top" class="whyJoinThree" width="20%"><b>Action</b></td>
				</tr>
				<tr>			
					<td align="center" valign="top" colspan="4"><hr></td>
				</tr>
			</table>
	   </td>
	 </tr>
	 <?php
			foreach($assoArr as $key=>$val)
			{			
	 ?>

	 <tr>
	   <td height="30" align="left" valign="top" colspan="3">
			<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">		 
				<tr>			
					<td align="left" valign="top" class="whyJoinThree" width="30%"><img src=".<?=$val['docLink']?>" alt="<?=$val['Name']?>" title="<?=$val['Name']?>" border="1"></td>		
					<td align="left" valign="top" class="whyJoinThree" width="40%"><?=$val['Name']?></td>
					<td align="left" valign="top" class="whyJoinThree" width="10%"><?=$val['status']?></td>
					<td align="right" valign="top" class="whyJoinThree" width="20%"><a href="userNda.php?eId=<?=$val['eId']?>" target="_blank">Go</a></td>
				</tr>
			</table>
	   </td>
	 </tr>
	 <tr>
	   <td height="30" align="left" valign="top" colspan="3" class="TopMenu2">&nbsp;</td>
	 </tr>
	 <?php
			}
		}
		else
		{
			$err_msg="Sorry !!!  No Enrollee is assigned to You right now."
	 ?>
	  <tr>
	   <td height="30" align="center" valign="top" colspan="3" class="ErrorMessage"> <strong><?=$err_msg?> </strong></td>	   
	 </tr>
	<?php
		}
	?>

	
	</table>
<?php
include_once("../includes/footer.php");
?>
		</td>
	</tr>
</table>
</body>
</html>