<?php
ob_start();
session_start();
include("../include/config.php");
require_once "../include/Database_functions.php";
$i=1;

  ?>
<table  border="0" cellspacing="0" cellpadding="0" class="tableList">
  <tr class="heading">
    <td>No</td>    
    <td>Employee Name</td>    
    <td>Date</td>
	<td>Time In</td>
	<td>Time Out</td>
	<td>Imm Supervisor</td>
    <td>Admin</td>
  </tr>
<?php
$emp_ses_id=$_SESSION['emp_id'];
$typename=$_SESSION['typename'];

if($typename=='SuperAdmin')
{
	  $sq_arr="SELECT a.*,b.e_fname as emp_name
    FROM cf_time_approval a
        LEFT JOIN cf_employee b
            ON b.e_id = a.e_id where 1";
}
else
{
$sq_arr="SELECT a.*,b.e_fname as emp_name
    FROM cf_time_approval a
        LEFT JOIN cf_employee b
            ON b.e_id = a.e_id where b.imm_supr=$emp_ses_id";

}




$query=$sq_arr;


if(isset($_REQUEST['fromdate']) && $_REQUEST['fromdate']!=''){
$from_date=date('Y-m-d',strtotime($_REQUEST['fromdate']));
$sq_arr.=" and   a.e_date >= '$from_date'";
}
if(isset($_REQUEST['todate']) && $_REQUEST['todate']!=''){
$to_date=date('Y-m-d',strtotime($_REQUEST['todate']));
$sq_arr.=" and   a.e_date <= '$to_date'";
}
$sq_arr.=" order by a.e_date desc ";

$function="Searchdate";
include("../paging.php");
 $sq_arr.=" LIMIT $start, $limit";

if(isset($_REQUEST['page'])){
$page=$_REQUEST['page'];
}else{
$page=20;
}


$array=mysql_query($sq_arr);
if($array && mysql_num_rows($array)>0){
$pagecnt=$start;
while($res=mysql_fetch_array($array))
{

$pagecnt++;


  ?> 
  <tr>
    <td><?php echo $pagecnt;?></td>
    <td><?php echo $res['emp_name'];?></td>
    <td><?php echo date('d-m-Y',strtotime($res['e_date']));?></td>
	 <td><?php echo $res['time_in'];?></td>
     <td><?php echo $res['time_out'];?></td>
	 <?php
	
	if($res['imd_status']!=0)
	{
		if($typename=='SubAdmin')
		{
	?>
    <td align="center" class="tr_td_r" ><a href="timesheet-approval.php?approve=imd&id=<?php echo $res['id']; ?>&val=0&otrval=<?php echo $res['HRstatus']; ?>" ><img src="images/ok-green.png" width="20" height="20" title="delete"></a></td>
	<?php
		}
		else
		{
		?>
    <td align="center" class="tr_td_r" ><a href="#" ><img src="images/ok-green.png" width="20" height="20" title="delete"></a></td>
	<?php
		
		}
	}
	else
	{
		if($typename=='SubAdmin')
		{
	?>
	<td align="center" class="tr_td_r" ><a href="timesheet-approval.php?approve=imd&id=<?php echo $res['id']; ?>&val=1&otrval=<?php echo $res['HRstatus']; ?>" ><img src="images/cross-red.png" width="20" height="20"  title="delete"></a></td>
	<?php
		}
		else
		{
		?>
	<td align="center" class="tr_td_r" ><a href="#" ><img src="images/cross-red.png" width="20" height="20"  title="delete"></a></td>
	<?php
		
		}
	}
	?>
	<?php
	
	if($res['HRstatus']!=0)
	{
		if($typename=='SuperAdmin')
		{
	?>
    <td align="center" class="tr_td_r" ><a href="timesheet-approval.php?approve=admin&id=<?php echo $res['id']; ?>&val=0&otrval=<?php echo $res['imd_status']; ?>" ><img src="images/ok-green.png" width="20" height="20"  title="delete"></a></td>
	<?php
		}
		else
		{
	?>
    <td align="center" class="tr_td_r" ><a href="#" ><img src="images/ok-green.png" width="20" height="20"  title="delete"></a></td>
	<?php
		}
	}
	else{
			if($typename=='SuperAdmin')
			{
	?><td align="center" class="tr_td_r" ><a href="timesheet-approval.php?approve=admin&id=<?php echo $res['id']; ?>&val=1&otrval=<?php echo $res['imd_status']; ?>" ><img src="images/cross-red.png" width="20" height="20"  title="delete"></a></td>
	<?php
		}
		else
		{
	?>
<td align="center" class="tr_td_r" ><a href="#" ><img src="images/cross-red.png" width="20" height="20"  title="delete"></a></td>

	<?php
	}
	}
	?>
   
    
   
  </tr>
  <?php 
    }}
  ?>
  </table>
	
	 <div align="right" style="padding-top:10px;"><?=$pagination?></div>
