<!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('../include/session.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']."_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';
}


$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++;
  }
}
  
$table_name = $_SESSION['db_prefix']."_list_sick_reason";
    $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='';
}
?>
</head>

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

<?php
include ("../navigation/header.php");
$page_name = "HR-leave";
include ("../navigation/access.php");
if ($permission_num==1) {
  include ("../navigation/hr_sidebar.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">Sick days adjustments</label></td>
            </tr>
        </table>
      </div>
        <br /><br />
        <div class="page_middle_frame">
<div class="page_inside_frame"><form name="form1" id="form1" action="sick_adjust.php" method="get"> <label class="label_std">Select employee:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
  <select name="employee_select" class="selectbox200" onchange="window.location.href= this.form.employee_select.options[this.form.employee_select.selectedIndex].value" >
    <option value=""></option>
    <?php
          for ($i = 0; $i < count($arrId4); $i++) {
        echo "<option value=sick_adjust.php?emp_id=".$arrId4[$i].">".$arrName4[$i]."</option>";
  }
?>
   <?php
   if ($management_view=='yes') {
      for ($j = 0; $j < count($arrId5); $j++) {
      echo "<option value=sick_adjust.php?emp_id=".$reference.$arrId5[$j].">".$arrName5[$j]."</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="sick_adjust_save.php" method="GET" name="form2" id="form2">
<div class="page_inside_frame">
  <p>Leave adjustment for:&nbsp;&nbsp; <?php echo $employee_name; ?>
    
    <br>
    <br>
    <img src="../images/exclamation_mark_green_small.png" width="10" height="16"> Only make recordings on official sick days.</p>
  <table width="565"  id="table_display">
    <tr>
      <td width="143">Record 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(1990, 2099);
    //output the calendar
    $myCalendar->writeScript();
?></td>
      </tr>
    <tr>
      <td>No of days:</td>
      <td><select name="sick_days1_select"  id="sick_days1_select" class="select_no_arrow" style="width:50px;">
        <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 value="13">13</option>
        <option value="14">14</option>
        <option value="15">15</option>
        <option value=" " selected="selected"> </option>
        
        </select>
        <img src="../images/black_dot.png" width="8" height="8">
<select name="sick_days2_select" id="sick_days2_select" class="select_no_arrow" style="width:50px;">
  <option value="00">00</option>
          <option value="25">25</option>
          <option value="50">50</option>
          <option value="75">75</option>
          
      </select></td>
      </tr>
    <tr>
      <td>Add / Subtract:</td>
      <td>
        <label>
          <input type="radio" name="add_subtract_radio" value="+" id="add_subtract_radio_0">
          add</label>
        
        <label>
          <input type="radio" name="add_subtract_radio" value="-" id="add_subtract_radio_1">
          subtract</label>
        
        </p></td>
      </tr>
    <tr>
      <td>Reason:</td>
      <td><select name="sick_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>Notes:</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("leave_days1_select","req","- no of leave days.");
  frmvalidator.addValidation("add_subtract_radio","selone","- select add or subtract.");
  frmvalidator.addValidation("leave_reason_select","req","- reason.");
  
</script>
</div>     
</div>
</div>



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

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

</body>
</html>