<!DOCTYPE html>
<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" />
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/show_hide_layers.js"  type="text/javascript"></script>  
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script> 

<?php
include ("../navigation/header.php");
$page_name = "HR-overtime";
include ("../navigation/access.php");
if ($permission_num==1) {
	include ("../navigation/hr_sidebar.php");


require_once('../include/tc_calendar.php');

date_default_timezone_set('Africa/Gaborone');
$entry_date = date("Y-m-d H:i:s", time()); 

$emp_id = $_GET['emp_id'];

$today = date("Y-m-d");
$record_date = strtotime($today);
$d = date("d", $record_date ) ;
$m = date("m", $record_date ) ;
$y = date("Y", $record_date ) ;

$table_name = $_SESSION['db_prefix']."_employee";
$select_query = "SELECT emp_id, emp_first_name, emp_last_name FROM $table_name WHERE end_employ_date > '".$today."' AND premature_end_date > '".$today."' ORDER BY emp_first_name";
	$arrId = array ();
	$arrName = array ();
	$select_result = execsql($select_query);
	$select_num = mysql_num_rows($select_result);
	$a = 0;
	while ($a < $select_num) {
		$arrId[$a] = mysql_result($select_result, $a, "emp_id");
		$arrName[$a] = mysql_result($select_result, $a, "emp_first_name").' '.mysql_result($select_result, $a, "emp_last_name");
		$a++;
	}
	
$table_name = $_SESSION['db_prefix']."_list_overtime";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId1 = array ();
	$arrName1 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId1[$b] = mysql_result($position_result, $b, "item_name");
		$arrName1[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}	
	
	
	
	
if ($emp_id!='') {
$table_name = $_SESSION['db_prefix']."_employee";
$employee_query = "SELECT emp_first_name, emp_last_name FROM $table_name 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"); 	
}
else {
	$employee_name='';
}
?>
<script type="text/javascript">
function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
</script>
</head>


<body onload="<?php if ($emp_id=='') { ?> document.getElementById('hidden_frame').style.display = 'none'; <?php } else { ?> document.getElementById('hidden_frame').style.display = 'block'; <?php } ?>">


<div class="main_frame"  style="height:auto; min-height:570px;">

<div class="page_head_frame">
        <table width="809" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><label class="label_page_head">Overtime recording</label></td>
            </tr>
        </table>
      </div>
        <br /><br />
        <div class="page_middle_frame">
<div class="page_inside_frame"><form name="form1" id="form1" action="overtime_rec.php" method="get"> <label class="label_std">Select employee:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  <select name="employee_select" class="select200" onchange="window.location.href= this.form.employee_select.options[this.form.employee_select.selectedIndex].value" >
    <option value=""></option>
    <?php
        	for ($i = 0; $i < count($arrId); $i++) {
    		echo "<option value=overtime_rec.php?emp_id=".$arrId[$i].">".$arrName[$i]."</option>";
	}
?>
  </select>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</form>
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("user_select","req","Please select user.");
</script></div>
<div class="hidden_frame" id="hidden_frame">
<form action="overtime_rec_save.php" method="GET" name="form2" id="form2">
<div class="page_inside_frame">
  <p>Overtime  for:&nbsp;&nbsp; <?php echo $employee_name; ?>
    
  </p>
  <table width="565"  id="table_display">
    <tr>
      <td width="143" height="29">Overtime date:</td>
      <td width="324"><?php 
				  //instantiate class and set properties
		$myCalendar = new tc_calendar("record_date", true);
		$myCalendar->setIcon("../images/iconCalendar.gif");
		$myCalendar->setDate($d, $m, $y);
		$myCalendar->setYearInterval(2014, 2090);
		//output the calendar
		$myCalendar->writeScript();
?></td>
      </tr>
    <tr>
      <td height="43">Hours 150 / 200 %:&nbsp;&nbsp;
        <label class="star">*</label></td>
      <td>150%:
        <select name="overtime150_select" class="select80"  id="overtime150_select" onChange="document.getElementById('overtime200_select').selectedIndex=0" >
          <option value="0">0</option>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
          <option value="4">4</option>
          <option value="5">5</option>
          <option value="6">6</option>
          <option value="7">7</option>
          <option value="8">8</option>
          <option value="9">9</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
          <option selected="selected"> </option>
        </select>
        hrs
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;200%:
          <select name="overtime200_select"  id="overtime200_select" class="select80" onChange="document.getElementById('overtime150_select').selectedIndex=0" >
            <option value="0">0</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
             <option value="11">11</option>
              <option value="12">12</option>
            <option selected="selected"> </option>
          </select>
          hrs</td>
      </tr>
    <tr>
      <td height="43">Reason:&nbsp;&nbsp;
        <label class="star">*</label></td>
      <td><select name="overtime_reason_select" class="select200"  >
        <option value="  " selected> </option>
        <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
        </select></td>
    </tr>
    <tr>
      <td height="58">Notes:&nbsp;&nbsp;</td>
      <td><textarea name="notes_text" id="notes_text" cols="50" rows="3"></textarea></td>
      </tr>
  </table>
  
</div>
<div class="page_inside_frame">
  <table width="645" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right"><input type="hidden" name="emp_id_text" id="emp_id_text" value="<?php echo $emp_id ?>" />
        <input name="button2" type="button" class="imagebutton" id="button2" onclick="cancel_confirmation(3, '../hr_module/hr_main.php?date=0');" value="Close"/>
        <input name="save_button"  id="save_button" type="submit" class="imagebutton" value="Save &amp; New" onclick="needToConfirm = false; confirmRefresh();" />
        <input name="save_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onclick="needToConfirm = false; confirmRefresh();" /></td>
    </tr>
  </table>
</div>
</form> 
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form2");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("overtime_reason_select","req","- reason.");
  frmvalidator.addValidation("overtime150_select","req","- number of hours.");
  frmvalidator.addValidation("overtime200_select","req","- number of hours.");
  
</script>
</div>     
</div>
</div>





<?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'); ?>
</body>
</html>