<?php 
session_name('CAKEPHP'); session_start();
$PageSecurity = 11;
include('includes/session.inc');
//include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');
include("includes/function_lib.php");
include('CRM/functions.php');
?>
<?php
	$filter=array();
	if($_REQUEST['empname']!='0')
	{
		$filter[]="id='".$_REQUEST['empname']."'";
		
	}
	 
	if($_REQUEST['site']!='000')
	{
		$filter[]="emp_site='".$_REQUEST['site']."'";
		
	}
	 if(count($filter)>0)
	 {
 
	 	$fdata=implode(" and " ,$filter);
		 echo $GetRecord = "Select * from empmaster where $fdata ";	   
	 }else
	 	 $GetRecord = "Select * from empmaster where 1=1 And CompanyId='".$_SESSION['ACGCompanyId']."'";	   
	 
	 
  
   $ResultData = DB_query($GetRecord,$db);
   

//echo $GetRecord;
    //echo DB_num_rows($ResultData);
    while($RowData = DB_fetch_array($ResultData))
   {
 	
   ?>

<table border="0" cellpadding="0" cellspacing="0"  width="100%">
<tr class="row1">
	<td class="tabledata1">Employee Code: </td>
	<td class="tabledata1">Employee Name: </td>
	<td class="tabledata1">Designation: </td>
	<td class="tabledata1">Unit: </td>
</tr>
<tr class="row1">
	<td>	<input type="text" name="emp_code" value="<?php echo $RowData['emp_code']; ?>">  </td>
	<td>	<input type="text" name="emp_name" value="<?php echo $RowData['emp_name']; ?>" size="50">  </td>
	<td>	

	<select name="designation" id="designation"  > 
	 
	<?php $qdesig=DB_query("select desigcode,designame from desigmaster where desigcode='".$RowData['designation']."'",$db);
		while ($rsdesig=DB_fetch_array($qdesig)){
			
			
	?>
	<option value="<?php echo $rsdesig['desigcode'];?>" <?php echo ($designation==$rsdesig['desigcode']?'selected':'')?>><?php echo $rsdesig['designame'];?></option>
	<?php }?>
	</select>
    </td>
	<td>	
		<select name="emp_site" id="emp_site"  >
 	<?php 
	$site_sql=DB_query("Select loccode,locationname from locations where loccode='".$RowData['emp_site']."'",$db);
	while($site_row=DB_fetch_array($site_sql))
	{
	?>

	<option value="<?php echo $site_row['loccode'];?>"<?php echo ($emp_site==$site_row['loccode']?'selected':'')?>><?php echo $site_row['locationname'];?></option>
	<?php } ?>
	</select>  
      </td>
	 	
</tr>

<tr class="row1">
	<td colspan="4"  valign="top">
		<fieldset><legend> <strong>Leave summary</strong></legend>
			
			
			<!--<div align="right"><a href="<?php //echo $rurl; ?>&empid=<?php //echo $RowData['id'];?>"> Leave Apply</a></div>-->
			<table border="0" width="100%" cellpadding="3" cellspacing="3">
				<tr class="row1">
				<td class="tabledata"><strong>Leave Type</strong></td>
				<td class="tabledata"><strong>Allowed Leave</strong></td>
				<td class="tabledata"><strong>Leave Taken</strong></td>
				<td class="tabledata"><strong>Remaining Leave</strong></td>
				<td class="tabledata"><strong>Detailed View</strong></td>
				</tr>
	<?php 
	     $GetEmpLeave = "Select * from emp_leave where  emp_id='".$RowData['id']."' ";	   
   $ResultEmpLeave = DB_query($GetEmpLeave,$db);
   while($RowEmpLeave=DB_fetch_array($ResultEmpLeave))
   {
   	
  ?>
				<tr class="row1">
				<td><?php
					 echo $s->getField('leavemaster','leavecode',$RowEmpLeave['leave_type'],'leavename');
					  echo "( ".$RowEmpLeave['leave_type']." )";?> </td>
						 <td><?php  echo $RowEmpLeave['leave_days']?> </td>
					<td> <?php echo $leaves= leave_calculation($RowData['id'],$RowEmpLeave['leave_type'])?></td>
					<td><?php echo ($leaves!=0 ? $RowEmpLeave['leave_days']-$leaves:'0');?> </td>
					<td><a href="<?php echo $viewrurl; ?>&empid=<?php echo $RowData['id']; ?>&leave_type=<?php echo $RowEmpLeave['leave_type']?>">View</a></td>
				</tr>
<?php } ?>				
		</table>
		</fieldset>
		
	</td>
	
	
</tr>
   
</table>
<?php }?>