<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="../css/main.css" rel="stylesheet" type="text/css" />
<?php
include ("../navigation/header.php");
$page_name = "AD-tracking";
include ("../navigation/access.php");

if ($permission_num==1) {
	include ("../navigation/admin_sidebar.php");
?>
<?php
include('../include/period_select_date.php');	
	
$table_name2 = $_SESSION['db_prefix']."_tracking_hr";
$tracking_query = "SELECT * FROM $table_name2 WHERE entry_date >= '".$start."' AND entry_date <= '".$end."' ";
$tracking_result = mySQL_query($tracking_query);
$tracking_num = mysql_num_rows($tracking_result);
?>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<!--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, "desc" ]],
					"aoColumns": [
								{"iDataSort": 5},
                              	{"bSortable": true},
                             	{"bSortable": true},
								{"bSortable": true},
								{"bSortable": true},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>

</head>
<?php include('../include/tooltip.php');?>
<body>

<div class="main_frame">
  <div class="page_head_frame">
     <label class="label_page_head">HR tracking</label></td>
  </div>
        <br />
<br />
<br />
<br />
<div class="page_middle_frame">
<?php
$page='tracking_HR.php';
include('../include/period_select_block.php');
?>
<div class="page_inside_frame">
<table width="659" id="scroll_table" class="data_display"  >
  <thead>
  <tr>
    <th>date</th>
    <th>time</th>
    <th>user</th>
    <th>action</th>
    <th>details</th>
    <th>&nbsp;</th>
  </tr>
  </thead>
<?php 

$i=0;

while ($i<$tracking_num) {
    $b0  =  mysql_result($tracking_result, $i, "action_id");
	$b1 =  mysql_result($tracking_result, $i, "entry_date");
	$b2 =  mysql_result($tracking_result, $i, "user");
	$b3 =  mysql_result($tracking_result, $i, "action");
	$d1 =  mysql_result($tracking_result, $i, "details_1");
	$d2 =  mysql_result($tracking_result, $i, "details_2");
	$d3 =  mysql_result($tracking_result, $i, "details_3");
	$d4 =  mysql_result($tracking_result, $i, "details_4");
	
	$action='';
	$details='';
	switch ($b3) {
    case 20:
	    $action = 'New employee';
        $table_name = $_SESSION['db_prefix']."_employee";
		$name_query = "SELECT emp_first_name, emp_last_name FROM $table_name WHERE emp_no = '".$d1."' ";
		$name_result = mySQL_query($name_query);
		$emp_name = mysql_result($name_result, 0, "emp_first_name").' '.mysql_result($name_result, 0, "emp_last_name");
		$TT = "'Click here for details on ".$emp_name."'";
        $details='New employee: <b><a href="../hr_module/employee_details.php?emp_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$emp_name.'</a></b> ';
        break;
		
	case 21:
	    $action = 'Edit employee';
        $table_name = $_SESSION['db_prefix']."_employee";
		$name_query = "SELECT emp_first_name, emp_last_name FROM $table_name WHERE emp_id = '".$d1."' ";
		$name_result = mySQL_query($name_query);
		$emp_name = mysql_result($name_result, 0, "emp_first_name").' '.mysql_result($name_result, 0, "emp_last_name");
		$TT = "'Click here for details on ".$emp_name."'";
        $details= $d4.' for: <b><a href="../hr_module/employee_details.php?emp_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$emp_name.'</a></b> edited from: '.$d2.' to: '.$d3;
        break;
		
	case 22:
	    $action = 'Overtime';
        $table_name = $_SESSION['db_prefix']."_employee";
		$name_query = "SELECT emp_first_name, emp_last_name FROM $table_name WHERE emp_id = '".$d1."' ";
		$name_result = mySQL_query($name_query);
		$emp_name = mysql_result($name_result, 0, "emp_first_name").' '.mysql_result($name_result, 0, "emp_last_name");
		$TT = "'Click here for details on ".$emp_name."'";
        $details= $d3.'hr and '.$d4.'min overtime at '.$d2.'% for: <b><a href="../hr_module/employee_details.php?emp_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$emp_name.'</a></b>';
        break;	

	
	case 23:
	    $action = 'Warning';
        $table_name = $_SESSION['db_prefix']."_employee";
		$name_query = "SELECT emp_first_name, emp_last_name FROM $table_name WHERE emp_id = '".$d1."' ";
		$name_result = mySQL_query($name_query);
		$emp_name = mysql_result($name_result, 0, "emp_first_name").' '.mysql_result($name_result, 0, "emp_last_name");
		$TT = "'Click here for details on ".$emp_name."'";
		$TT2= "'Click here for details on this warning.'";
		$details= 'Warning to <b><a href="../hr_module/employee_details.php?emp_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$emp_name.'</a></b> for <b><a href="../hr_module/warning_details.php?warning_id='.$d4.'" onMouseover="ddrivetip('.$TT2.', 175)"; onMouseout="hideddrivetip()">'.$d3.'</a></b> given by '.$d2;
        break;
		
	case 24:
	    $action = 'Return item';
        $table_name = $_SESSION['db_prefix']."_employee";
		$name_query = "SELECT emp_first_name, emp_last_name FROM $table_name WHERE emp_id = '".$d1."' ";
		$name_result = mySQL_query($name_query);
		$emp_name = mysql_result($name_result, 0, "emp_first_name").' '.mysql_result($name_result, 0, "emp_last_name");
		$table_name = $_SESSION['db_prefix']."_store_items";
		$name_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$d2."'  ";
		$name_result = mySQL_query($name_query);
		$item_name = mysql_result($name_result, 0, "item_name");
		$TT = "'Click here for details on ".$emp_name."'";
		$TT2= "'Click here for details on this warning.'";
		$details= '<b>'.$item_name.'</b> was returned by <b><a href="../hr_module/employee_details.php?emp_id='.$d1.'" onMouseover="ddrivetip('.$TT.', 250)"; onMouseout="hideddrivetip()">'.$emp_name.'</a></b>';
        break;		
	
	}
?>

  <tr>
    <td width="66" align="left"><?php echo date("d-m-Y", strtotime($b1 )) ?></td>
    <td width="46" align="left"><?php echo date("H:i", strtotime($b1 ))  ?></td>
    <td width="49" align="left"><?php echo $b2 ?></td>
    <td width="71" align="left"><?php echo $action ?></td>
    <td width="376" align="left"><?php echo $details ?></td>
    <td width="23" align="left"><?php echo $b1 ?></td>
    </tr>
  <?php
  $i++;
}
?>

</table>
</div>
</div>
</div>
</body>
<?php } else {
$_SESSION['denied_return'] = "admin_module/user_list.php";	
    include ("../navigation/admin_sidebar.php");?>
	<body onLoad="accessdenied(); return false">
<?php }
?>
<?php include ('../navigation/side_bar.php'); ?>
</html>