<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/scroll_table.css" />
<link rel="stylesheet" type="text/css" href="../css/tab.css" />


<!--jscript-->
<script language="javascript" src="../jscript/calendar.js"></script> 


<?php
include ("../navigation/header.php");
include('../include/period_select_date.php');

$today = date("Y-m-d");
$firstday = date("Y").'-'.date("m").'-01';
$lastday = date("Y-m-d", mktime(0,0,0,date("m")+1,0,date("Y")));

$emp_id = $_GET['emp_id'];
include('../include/period_select_date.php');

$table_name2 = $_SESSION['db_prefix']."_employee";
$employee_query = "SELECT emp_first_name, emp_last_name, emp_group FROM $table_name2 WHERE emp_id ='".$emp_id."' ";
$employee_result = mySQL_query($employee_query);
$employee_num = mysql_num_rows($employee_result);

$a0 = mysql_result($employee_result, 0, "emp_first_name");
$a1 = mysql_result($employee_result, 0, "emp_last_name");	
$a42 = mysql_result($employee_result, 0, "emp_group");

if ($a42=='E') {
$table_name = $_SESSION['db_prefix']."_time_sheet";
$time_query = "SELECT SUM(check_out_min - check_in_min - lunch_min) AS recorded_time, SUM(time_zone_out - time_zone_in - lunch_period) AS required_time FROM $table_name WHERE emp_id ='".$emp_id."' AND attendance_date >= '".$firstday."' AND attendance_date <= '".$lastday."' ";
$time_result = mySQL_query($time_query);
$time_num = mysql_num_rows($time_result);
$recorded_time = mysql_result($time_result, 0, "recorded_time");
$required_time = mysql_result($time_result, 0, "required_time");
if ($required_time=='') {$required_time = 1;}
$attendance = ($recorded_time / $required_time) * 100;
}
		
	
	
$table_name2 = $_SESSION['db_prefix']."_warnings";
$warning_query = "SELECT warning_id, warning, offence, emp_id, warning_date, exp_date, warning_text FROM $table_name2 WHERE warning_date >= '".$start."' AND warning_date <= '".$end."' AND emp_id = '".$emp_id."' ";
$warning_result = mySQL_query($warning_query);
$warning_num = mysql_num_rows($warning_result);

?>

</head>

<body>
<?php

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

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

<div class="main_frame">
  <div class="page_head_frame">
        <?php if ($a42=='E') { ?>
        <?php $attendance_label = "label_attendance_green" ;
		if ($attendance<96)  { $attendance_label = "label_attendance_orange" ; }
        if ($attendance<92)  { $attendance_label = "label_attendance_red" ; }?>
        <?php } ?>
        <table width="700" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="515"><label class="label_page_head">Employee</label>&nbsp;&nbsp;<label class="label_page_head_2"><?php echo $a0." ".$a1 ?></label></td>
            <td width="165" align="center"><?php if ($a42=='E') { ?>attendance:<br />              <label class="<?php echo $attendance_label ?>"><?php echo number_format($attendance, 2, '.', ',')?> %</label> <?php } ?></td>
            </tr>
        </table>
      </div>
 <br />
<br />
<br />
<br />
<div class="page_middle_frame">

<div class="tab_button_holder_frame">
      <a href="employee_details.php?emp_id=<?php echo $emp_id ?>"><div class="<?php if ($current_page =='employee_details.php') {echo 'tab_button_active'; } else { echo 'tab_button'; }?>"><div align="center">Details</div></div></a>
      <a href="attendance_list.php?emp_id=<?php echo $emp_id ?>&date="><div class="<?php if ($current_page =='attendance_list.php') {echo 'tab_button_active'; } else { echo 'tab_button'; }?>"><div align="center">Attendance</div></div></a>
      <a href="employee_warnings_list.php?emp_id=<?php echo $emp_id ?>&date="><div class="<?php if ($current_page =='employee_warnings_list.php') {echo 'tab_button_active'; } else { echo 'tab_button'; }?>"><div align="center">Discipline</div></div></a>
      <a href="issued_employee_list.php?emp_id=<?php echo $emp_id ?>&date="><div class="<?php if ($current_page =='issued_employee_list.php') {echo 'tab_button_active'; } else { echo 'tab_button'; }?>"><div align="center">Store issues</div></div></a>
     </div>

<div class="tab_middle_frame">      
     
     
<?php
$page='employee_warnings_list.php';
$reference_name='emp_id';
$reference=$emp_id;
$reference_name_2='';
$reference_2='';
$reference_name_3='';
$reference_3='';
include('../include/period_select_block_small.php');
?>

<div class="page_inside_frame" style="width:650px;">
<!--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},
								{"iDataSort": 6},
								{"bVisible": false},
								{"bVisible": false}
								 ]
				} );
			} );
		</script>
<table width="680" id="scroll_table" class="data_display"  >
  <thead>
   <tr>
    <th>date</th>
    <th>employee</th>
    <th>warning</th>
    <th>offence </th>
    <th>exp date</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    </tr>
  </thead>
<?php 

$i=0;

while ($i<$warning_num) {
	$a =  mysql_result($warning_result, $i, "warning_id");
	$a0 = mysql_result($warning_result, $i, "warning_date");
	$a1 = mysql_result($warning_result, $i, "emp_id");
	   	$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");
		$a7 = mysql_result($employee_result, 0, "department");
	$a2 = mysql_result($warning_result, $i, "warning");
	$a3 = mysql_result($warning_result, $i, "offence");
	$a4 = mysql_result($warning_result, $i, "exp_date");
	$a5 = mysql_result($warning_result, $i, "warning_text");
	
	$employeeTT = "<label class=tip_text_label>".$a1a."</label><br><label class=tip_click_label>Click for details</label>";  
	$warningTT = "<label class=tip_text_label>".substr($a5, 0, 350)." ........</label><br><label class=tip_click_label>Click to view warning</label>";  
	?>
    
  
  
  <tr>
    <td width="72" align="left"><?php echo date("d-m-Y", strtotime($a0 )) ?></td>
    <td width="159" 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="96" align="left"><?php echo $a2 ?></td>
    <td width="174" align="left"><a href="warning_details.php?warning_id=<?php echo $a ?> " onMouseover="ddrivetip('<?php echo $warningTT ?>', 250)"; onMouseout="hideddrivetip()"> <?php echo $a3 ?>  </a></td>
    <td width="101" align="left"><?php echo date("d-m-Y", strtotime($a4 )) ?></td>
    <td width="23" align="left"><?php echo $a0 ?></td>
    <td width="23" align="left"><?php echo $a4 ?></td>
    </tr>
  <?php
  $i++;
}
?>

</table>
<div align="left"><label class="label_end">end of list</label></div>
</div>
</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>