<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>
<script language="javascript" src="../jscript/calendar.js"></script>

<?php
include('../include/session.php');
require_once('../include/tc_calendar.php');
$today = date("Y-m-d");
$edit_date = date("Y-m-d");
$edit_date = strtotime($edit_date);
$d = date("d", $edit_date ) ;
$m = date("m", $edit_date ) ;
$y = date("Y", $edit_date ) ;

  
$page = $_GET['page'];

$table_name = $_SESSION['db_prefix']."_permissions";
$view_query = "SELECT access_id  FROM  $table_name  WHERE access_id ='". $_SESSION['access_id']."' AND page_name = 'HR-management' ";
$view_result = mySQL_query($view_query);
$view_num = mysql_num_rows($view_result);
if ($view_num!=0) {
  $management_view='yes';
}
else { 
$management_view='no';
}
  
if ($page=='leave') {
$reference='leave_records.php?date=&emp_id=';  
//$page_name='Leave records.';
$table_name = $_SESSION['db_prefix']."_employee";
$employeeQuery = "SELECT emp_id, emp_first_name, emp_last_name FROM $table_name WHERE end_employ_date > '".$today."' AND premature_end_date > '".$today."' AND emp_group='E'  ORDER BY emp_first_name ASC";
$employeeResult = execsql($employeeQuery);
$employeeNum = mysql_num_rows($employeeResult);
  $w = 0;
  $arrId4 = array ();
  $arrName4 = array ();
  while ($w < $employeeNum) {
    $arrId4[$w] = mysql_result($employeeResult, $w, 'emp_id');
    $arrName4[$w] = mysql_result($employeeResult, $w, 'emp_first_name').' '.mysql_result($employeeResult, $w, 'emp_last_name');
    $w++;
  }
  
if ($management_view=='yes') {
$table_name = $_SESSION['db_prefix']."_employee";
$employeeQuery = "SELECT emp_id, emp_first_name, emp_last_name FROM $table_name WHERE end_employ_date > '".$today."' AND premature_end_date > '".$today."' AND emp_group='M'  ORDER BY emp_first_name ASC";
$employeeResult = execsql($employeeQuery);
$employeeNum = mysql_num_rows($employeeResult);
  $w = 0;
  $arrId5 = array ();
  $arrName5 = array ();
  while ($w < $employeeNum) {
    $arrId5[$w] = mysql_result($employeeResult, $w, 'emp_id');
    $arrName5[$w] = mysql_result($employeeResult, $w, 'emp_first_name').' '.mysql_result($employeeResult, $w, 'emp_last_name');
    $w++;
  }
}
  }


if ($page=='sick') {
$reference='sick_records.php?date=&emp_id=';  
//$page_name='Leave records.';
$table_name = $_SESSION['db_prefix']."_employee";
$employeeQuery = "SELECT emp_id, emp_first_name, emp_last_name FROM $table_name WHERE end_employ_date > '".$today."' AND premature_end_date > '".$today."' AND emp_group='E'  ORDER BY emp_first_name ASC";
$employeeResult = execsql($employeeQuery);
$employeeNum = mysql_num_rows($employeeResult);
  $w = 0;
  $arrId4 = array ();
  $arrName4 = array ();
  while ($w < $employeeNum) {
    $arrId4[$w] = mysql_result($employeeResult, $w, 'emp_id');
    $arrName4[$w] = mysql_result($employeeResult, $w, 'emp_first_name').' '.mysql_result($employeeResult, $w, 'emp_last_name');
    $w++;
  }
  
if ($management_view=='yes') {
$table_name = $_SESSION['db_prefix']."_employee";
$employeeQuery = "SELECT emp_id, emp_first_name, emp_last_name FROM $table_name WHERE end_employ_date > '".$today."' AND premature_end_date > '".$today."' AND emp_group='M'  ORDER BY emp_first_name ASC";
$employeeResult = execsql($employeeQuery);
$employeeNum = mysql_num_rows($employeeResult);
  $w = 0;
  $arrId5 = array ();
  $arrName5 = array ();
  while ($w < $employeeNum) {
    $arrId5[$w] = mysql_result($employeeResult, $w, 'emp_id');
    $arrName5[$w] = mysql_result($employeeResult, $w, 'emp_first_name').' '.mysql_result($employeeResult, $w, 'emp_last_name');
    $w++;
  }
}
}
?>
</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="630" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="385"><label class="label_page_head">Select </label></td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
      </div>
       <br />
<br /><br />
<br />
<br />
<br />

<div class="page_middle_frame"><br />

<?php 
if ($page=='leave') { ?>
<div class="page_inside_frame">
  <label class="label_std" style="font-size:16px;">Individual leave records</label>
  <br />
  <br />
  <form action="" method="get">
  
    <label class="label_std"> Select employee : &nbsp;&nbsp;</label>
    <select name="emp_no_select" autofocus class="select200" id="emp_no_select" onchange="window.location.href= this.form.emp_no_select.options[this.form.emp_no_select.selectedIndex].value"> 
      <option value=" " selected="selected" >&nbsp;</option>
      <?php
      for ($j = 0; $j < count($arrId4); $j++) {
      echo "<option value=".$reference.$arrId4[$j].">".$arrName4[$j]."</option>";  
    }
     ?>
     <?php
      for ($j = 0; $j < count($arrId5); $j++) {
      echo "<option value=".$reference.$arrId5[$j].">".$arrName5[$j]."</option>";  
    }
     ?>
    </select>
  
  </form>
 </div>
<?php } ?>


<?php 
if ($page=='sick') { ?>
<div class="page_inside_frame">
  <label class="label_std" style="font-size:16px;">Individual sick records</label>
  <br />
  <br />
  <form action="" method="get">
  
    <label class="label_std"> Select employee : &nbsp;&nbsp;</label>
    <select name="emp_no_select" autofocus class="select200" id="emp_no_select" onchange="window.location.href= this.form.emp_no_select.options[this.form.emp_no_select.selectedIndex].value"> 
      <option value=" " selected="selected" >&nbsp;</option>
      <?php
      for ($j = 0; $j < count($arrId4); $j++) {
      echo "<option value=".$reference.$arrId4[$j].">".$arrName4[$j]."</option>";  
    }
     ?>
    </select>
  
  </form>
 </div>
<?php } ?>



    
</div>
</div>
<?php include ('../navigation/side_bar.php'); ?>


<?php } else {
    $_SESSION['denied_return'] = "hr_module/hr_main.php?date=";  
    include ("../navigation/hr_sidebar.php");?>
    <?php include ('../navigation/side_bar.php'); ?>
  <body onLoad="accessdenied(); return false">  
  </body>
<?php }
?>

</body>
</html>