<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php
include ("../navigation/header.php");
$page_name = "HR-main";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/hr_sidebar.php");

include('../include/period_select_date.php');

$emp_id = $_GET['emp_id'];

$table_name = $_SESSION['db_prefix']."_time_sheet";
if ($emp_id == '') {
$display_query = "SELECT * FROM $table_name WHERE attendance_status = 'absent' AND attendance_date > '".$start."' AND attendance_date < '".$end."'";
}
else {
$display_query = "SELECT * FROM $table_name WHERE emp_id = '".$emp_id."' AND attendance_status = 'absent' AND attendance_date >= '".$start."' AND attendance_date <= '".$end."'";
}

$display_result = mySQL_query($display_query);
$display_num = mysql_num_rows($display_result);

	
?>
<!--style sheets-->
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<!--jscript-->
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script> 

<!--style sheets-->
<link href="../css/main.css" rel="stylesheet" type="text/css">  
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 

</head>


<body>

<div class="main_frame">
   <div class="page_head_frame">
      <table width="650" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Absent per period</label></td>
            <td width="253">&nbsp;</td>
            <td width="171" align="right">&nbsp;</td>
          </tr>
        </table>
   </div>
      
  <div class="page_middle_frame">
<?php 
$page='absent_list.php';
$reference_name='emp_id';
$reference=$emp_id;
include('../include/period_select_block.php');
?>
  

<div class="page_inside_frame">
<script type="text/javascript" language="javascript" src="../jscript/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#scroll_table').dataTable( {
					"sScrollY": "500px",
					"bPaginate": false,
					"bScrollCollapse": true,
					"aaSorting": [[ 0, "desc" ]],
					"aoColumns": [
								{"iDataSort": 6},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
<table width="640" class="data_display" id="scroll_table" >
  <thead>
    <tr>
      <td width="61">Date</td>
      <td width="56">Emp no</td>
      <td width="141">Name</td>
      <td width="35">Zone</td>
      <td width="68" align="center">Permission</td>
      <td width="210" align="center">Reason</td>
      <td width="23" align="center">&nbsp;</td>
      </tr>
  </thead>
    <?php 
	
	$p=0;
	while ($p<$display_num) {
		$emp_no = mysql_result($display_result, $p, "emp_no");
			$table_name2 = $_SESSION['db_prefix']."_employee";
			$employee_query = "SELECT emp_id, emp_first_name, emp_last_name, time_zone FROM $table_name2 WHERE emp_no ='".$emp_no."' ";
			
			$employee_result = mySQL_query($employee_query);
			$employee_num = mysql_num_rows($employee_result);	
			$employee_name = mysql_result($employee_result, 0, "emp_first_name").' '.mysql_result($employee_result, 0, "emp_last_name"); 
			$emp_id = mysql_result($employee_result, 0, "emp_id");
			$time_zone = mysql_result($employee_result, 0, "time_zone");
			
		$attendance_date = mysql_result($display_result, $p, "attendance_date");
		$attendance_status = mysql_result($display_result, $p, "attendance_status");
		$time_zone = mysql_result($display_result, $p, "time_zone");
		$check_in = mysql_result($display_result, $p, "check_in");
		
		
		$late_permission = mysql_result($display_result, $p, "late_permission");
		$late_reason = mysql_result($display_result, $p, "late_reason");
		
		$employee_TT = $employee_name.'<br>Click for details';
				
		$check_in_display = '<font color=black>'.date("H:i", strtotime($check_in)) . '</font>';
				
	?>	
		
	<tr>
      <td width="61"><?php echo date("d-m-Y", strtotime($attendance_date)) ?></td>
      <td width="56"><?php echo $emp_no ?></td>
      <td width="141"><a href="employee_details.php?emp_id=<?php echo $emp_id?> " onMouseover="ddrivetip('<?php echo $employee_TT?>', 150)"; onMouseout="hideddrivetip()"><?php echo $employee_name ?></a></td>
      <td width="35" align="center"><?php echo $time_zone ?></td>
      <td width="68" align="center"><?php echo $late_permission ?>&nbsp;</td>
      <td width="210" align="left"><?php echo $late_reason ?>&nbsp;</td>
      <td width="23" align="center"><?php echo $attendance_date ?>&nbsp;</td>
      </tr>	
		
		
	<?php	
	$p++;
	}
	?>
  </table>
</div>
</div>
</div>

</body>
<?php } else {
$_SESSION['denied_return'] = "hr_module/hr_main.php?date=";	
include ("../navigation/hr_sidebar.php");?>
	<body onload="accessdenied(); return false">
	</body>
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>
</html>