<!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");
	
$emp_id = $_GET['emp_id'];

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



$table_name = $_SESSION['db_prefix']."_overtime_records";
if ($emp_id=='') {
$display_query = "SELECT * FROM $table_name WHERE overtime_date BETWEEN '".$start."' AND '".$end."' ";
}
else {
$display_query = "SELECT * FROM $table_name WHERE overtime_date BETWEEN '".$start."' AND '".$end."' AND emp_id = '".$emp_id."' ";
}
$display_result = mySQL_query($display_query);
$display_num = mysql_num_rows($display_result);

	
	
?>
<!--jscript-->
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/tooltip.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" />



</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">Overtime 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='overtime_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="670" class="data_display" id="scroll_table" >
  <thead>
    <tr>
      <td width="66">Date</td>
      <td width="146">Name</td>
      <td width="41" align="center">150%</td>
      <td width="41" align="center">200%</td>
      <td width="116" align="center">Reason</td>
      <td width="205" align="center">Notes</td>
      <td width="23">&nbsp;</td>
    </tr>
  </thead>
    <?php 
	
	$p=0;
	$tot_150='';
	$tot_200='';
	
	while ($p<$display_num) {
		$emp_id = mysql_result($display_result, $p, "emp_id");
			$table_name2 = $_SESSION['db_prefix']."_employee";
			$employee_query = "SELECT emp_first_name, emp_last_name, time_zone FROM $table_name2 WHERE emp_id ='".$emp_id."' ";
			
			$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"); 
						
			
		$overtime_date = mysql_result($display_result, $p, "overtime_date");
		$overtime_hours_150 = mysql_result($display_result, $p, "overtime_hours_150");
		$overtime_hours_200 = mysql_result($display_result, $p, "overtime_hours_200");
		$reason = mysql_result($display_result, $p, "reason");
		$notes = mysql_result($display_result, $p, "notes");
					
		$employee_TT = $employee_name.'<br>Click for details';
		
		$tot_150=$tot_150+$overtime_hours_150;	
		$tot_200=$tot_200+$overtime_hours_200;	
						
	?>	
		
	<tr>
      <td width="66"><?php echo date("d-m-Y", strtotime($overtime_date)) ?></td>
      <td width="146"><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="41" align="center"><?php echo $overtime_hours_150 ?></td>
      <td width="41" align="center"><?php echo $overtime_hours_200 ?></td>
      <td width="116" align="left"><?php echo $reason; ?></td>
      <td width="205" align="left"><?php echo $notes;?></td>
      <td width="23"><?php echo $overtime_date ?></td>
    </tr>
	<?php	
	$p++;
	}
	?>
    <tfoot>
    <tr>
	  <td>&nbsp;</td>
	  <td align="right">Totals:&nbsp;</td>
	  <td align="center"><?php echo $tot_150 ?>&nbsp;</td>
	  <td align="center"><?php echo $tot_200 ?></td>
	  <td align="left">&nbsp;</td>
	  <td align="left">&nbsp;</td>
	  <td>&nbsp;</td>
	</tr>	
    </tfoot>
  </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>