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

<!--jscript-->
<script type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>  
<?php
include ("../navigation/header.php");
require_once('../include/tc_calendar.php');

$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 = $con->query($view_query);
$view_num = mysqli_num_rows($view_result);
if ($view_num!=0) {
	$management_view='yes';
}
else {
$management_view='no';
}




$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'];
	
if ($page=='employee') {
$reference='employee_details_edit.php?edit=0&emp_id=';	
$page_name='Edit employee.';
$table_name = $_SESSION['db_prefix']."_employee";
$employee_query = "SELECT emp_id, emp_first_name, emp_last_name FROM $table_name WHERE emp_group='E'  ORDER BY emp_first_name ASC";
$employee_result = $con->query($employee_query);
	$w = 0;
	$arrId4 = array ();
	$arrName4 = array ();
	while($row = $employee_result->fetch_assoc()) {
	$arrId4[$w] = $row["emp_id"];
	$arrName4[$w] = $row["emp_first_name"].' '.$row["emp_last_name"];
	$w++;
	}

if ($management_view=='yes') {
$table_name = $_SESSION['db_prefix']."_employee";
$employee_query = "SELECT emp_id, emp_first_name, emp_last_name FROM $table_name WHERE emp_group='M'  ORDER BY emp_first_name ASC";
$employee_result = $con->query($employee_query);
	$w = 0;
	$arrId5 = array ();
	$arrName5 = array ();
	while($row = $employee_result->fetch_assoc()) {
	$arrId5[$w] = $row["emp_id"];
	$arrName5[$w] = $row["emp_first_name"].' '.$row["emp_last_name"];
	$w++;
	}
}

}

if ($page=='time_record') {
$reference='edit_time_record.php?date=';
$page_name='Edit time record';
}
?>
</head>

<?php include('../include/wait.php') ?>

<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');">

<?php

$page_name = "HR-edit employee";
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 to edit</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=='employee') { ?>
<div class="page_inside_frame">
  <label class="label_std" style="font-size:16px;"><?php echo $page_name?></label>
  <br />
  <br />
  <form action="" method="get">
  
    <label class="label_std"> Select <?php echo $page_name?> to edit : &nbsp;&nbsp;</label>
    <select name="emp_no_select" autofocus class="selectbox300" 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
	 if ($management_view=='yes') {
    	for ($j = 0; $j < count($arrId5); $j++) {
			echo "<option value=".$reference.$arrId5[$j].">".$arrName5[$j]."</option>";	
		}
	 }
     ?>
    </select>
  
  </form>
  <br />
  <br />
<br />
<br />
<br />
</div>
<?php } ?>


<?php if ($page=='time_record') { ?>
	 
             <div class="page_inside_frame">
             <form id="form1" name="form1" method="get" action="edit_time_record.php">
                <table width="670" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                  <td width="226"><label class="label_std">Select date to edit the time recording: </label></td>
                  <td><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("attendance_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setYearInterval(2010, 2020);
		//output the calendar
		$myCalendar->writeScript();
?> &nbsp;&nbsp;&nbsp;
                    <input type="hidden" name="edit" id="edit" value="0"/>                    &nbsp;&nbsp;
                    <input name="date"  id="date" type="hidden" value="0" />
                      <input name="continue_button" type="submit" class="imagebutton" id="continue_button"  value="Continue"  onClick="MM_showHideLayers('wait','','show');"/>
                    </td>
                  </tr>
              </table>
              </form><br />
<br />
<br />
<br />
<br />

              </div>   
             
            <br />
            
            <?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>