<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--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> 

<?php
include('../include/session.php');
$today = date("Y-m-d");
	
$table_name = $_SESSION['db_prefix']."_sick_records ";
$table_name2 = $_SESSION['db_prefix']."_employee";
$sick_query = "SELECT $table_name.*  FROM $table_name, $table_name2 WHERE $table_name.emp_id = $table_name2.emp_id AND $table_name2.end_employ_date > '".$today."' AND $table_name2.premature_end_date > '".$today."' AND $table_name2.emp_group='E' GROUP BY $table_name.emp_id ORDER BY $table_name.rec_date DESC";
$sick_result = mySQL_query($sick_query);
$sick_num = mysql_num_rows($sick_result);

?>

</head>

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

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

<div class="main_frame">

  <div class="page_head_frame">
      <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Sick records</label></td>
            <td width="253">&nbsp;</td>
            <td width="171" align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
<div class="page_middle_frame">
<div class="page_inside_frame">
<!--jscript-->
<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, "asc" ]],
					"aoColumns": [
					     		{"bSortable": true},
								{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"iDataSort": 5},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
<table width="682" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th>Employee</th>
    <th>Department</th>
    <th>Days</th>
    <th>&nbsp;</th>
    <th>Last recording</th>
    <th>&nbsp;</th>
    </tr>
    </thead>
<?php 

$i=0;
$a3_total=0;
$a6_total=0;
while ($i<$sick_num) {
	$a1 = mysql_result($sick_result, $i, "emp_id");
	$a5 = mysql_result($sick_result, $i, "rec_date");
	
	
    $table_name = $_SESSION['db_prefix']."_sick_records";
	$last_query = "SELECT *  FROM $table_name WHERE emp_id = '".$a1."' ORDER BY sick_id DESC LIMIT 1 ";
	$last_result = mySQL_query($last_query);
	$a2 = mysql_result($last_result, 0, "balance");
	
	
	
	   	$table_name = $_SESSION['db_prefix']."_employee";
    	$employee_query = "SELECT emp_first_name, emp_last_name, department  FROM $table_name WHERE emp_id = $a1 ";
		$employee_result = mySQL_query($employee_query);
        $a1a = mysql_result($employee_result, 0, "emp_first_name")." ".mysql_result($employee_result, 0, "emp_last_name");
		$a3 = mysql_result($employee_result, 0, "department");
		
	$a4='';
	
	$employeeTT = "<label class=tip_text_label>".$a1a."</label><br><label class=tip_click_label>Click for details</label>";  
	
	?>

  <tr>
    <td width="156" align="left"><a href="employee_details.php?emp_id=<?php echo $a1?>" onmouseover="ddrivetip('<?php echo $employeeTT ?>  ', 150)"; onmouseout="hideddrivetip()"><?php echo $a1a ?></a></td>
    <td width="101" align="center"><?php echo $a3 ?>&nbsp;</td>
    <td width="71" align="center"><a href="sick_records.php?emp_id=<?php echo $a1?>&date=" onMouseOver="ddrivetip('Click for personal overview.', 150)"; onMouseOut="hideddrivetip()"><?php echo $a2 ?></a></td>
    <td width="101" align="center"><?php echo $a4 ?>&nbsp;</td>
    <td width="202" align="center"><?php echo date("d-m-Y", strtotime($a5)) ?>&nbsp;</td>
    <td width="23" align="center"><?php echo $a5 ?>&nbsp;</td>
    </tr>
  
  <?php
  $i++;
}
?>
<tfoot>
</tfoot>
</table>
</div>
<div class="page_inside_frame">
<a href="print_sick_records_list.php" title="Manase sick records list print" target="_blank"><input name="print_button" type="button" class="imagebutton" value="Print list"></a>
</div>
</div>
</div>

<?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'); ?>


</body>
</html>