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

<!--style sheets--> 
<link rel="stylesheet" type="text/css" href="../css/print.css" />
<script type="text/javascript" src="../jscript/tablesort.js"></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);

$report_name='Employees sick records';
include('../include/print_report_header.php');
?>

</head>

<body   onload="window.print();" onFocus="window.close();">

<div class="print_standard_frame">       
      
<table width="665" id="print_tableprint"  class="sortable-onload-0 rowstyle-alt no-arrow ">
  <thead>
  <tr>
    <th class="sortable-text">Employee</th>
    <th>Department</th>
    <th>Days</th>
    <th>&nbsp;</th>
    <th>Last recording</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="left"><?php echo $a3 ?>&nbsp;</td>
    <td width="71" align="right"><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="left"><?php echo date("d-m-Y", strtotime($a5)) ?>&nbsp;</td>
    </tr>
  
  <?php
  $i++;
}
?>
<tfoot>
</tfoot>
</table>
</div>

</body>
</html>