<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--style sheets-->
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<!--jscript-->
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/cancel_confirmation.js"  type="text/javascript"></script> 
<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/confirm_exit.js"  type="text/javascript"></script>    


<?php 
include ("../navigation/header.php");
$page_name = "HR-time recording";

$page_name = "HR-time recording";
include ("../navigation/access.php");
$today = date("Y-m-d");
$recording_date = $_GET['recording_date'];


$table_name = $_SESSION['db_prefix']."_employee";
$employee_query = "SELECT emp_id, emp_no, emp_first_name, emp_last_name, time_zone FROM $table_name WHERE time_keeping = 'yes' ORDER BY emp_no ASC ";
$employee_result = mySQL_query($employee_query);
$employee_num = mysql_num_rows($employee_result);

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

$table_name = $_SESSION['db_prefix']."_list_absent";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
	$arrId2 = array ();
	$arrName2 = array ();
	$position_result = execsql($position_query);
	if ($position_result!="") {
	$position_num = mysql_num_rows($position_result);
	$b = 0;
	while ($b < $position_num) {
		$arrId2[$b] = mysql_result($position_result, $b, "item_name");
		$arrName2[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
	}
	}	
?>
</head>

<body><br>
<?php 
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><label class="label_page_head">Time in recording for <?php echo date("l, d-m-Y", strtotime($recording_date)) ?></label></td>
          </tr>
        </table>
      </div>
<div class="page_middle_frame">
<form action="time_in_recording_save.php" method="post" name="form1">
<div class="page_inside_frame">
<table width="693" id="table_details_display">
  <tr>
    <td width="67">Emp no</td>
    <td width="188">Name</td>
    <td width="77">&nbsp;P &nbsp;&nbsp;&nbsp;&nbsp;L&nbsp;&nbsp; &nbsp;A</td>
    <td><img src="../images/info_orange.png" width="16" height="16"><label class="label_std" style="font-size:10px;">P=present&nbsp;&nbsp;L=late&nbsp;&nbsp;A=absent</label></td>
    </tr>
<?php 
$i=0;
while ($i<$employee_num) {
	$emp_id = mysql_result($employee_result, $i, "emp_id");
	$emp_no = mysql_result($employee_result, $i, "emp_no");
	$emp_first_name = mysql_result($employee_result, $i, "emp_first_name");
	$emp_last_name = mysql_result($employee_result, $i, "emp_last_name");
	$time_zone = mysql_result($employee_result, $i, "time_zone");

?>
  <tr>
    <td><?php echo $emp_no ?>
      <input type="hidden" name="emp_no_text<?php echo $i ?>" id="emp_no_text<?php echo $i ?>" value="<?php echo $emp_no ?>">
      <input type="hidden" name="emp_id_text<?php echo $i ?>" id="emp_id_text<?php echo $i ?>" value="<?php echo $emp_id ?>"></td>
    <td><?php echo $emp_first_name.' '.$emp_last_name ?><input name="emp_name_text<?php echo $i ?>" id="emp_name_text<?php echo $i ?>" type="hidden" value="<?php echo $emp_first_name.' '.$emp_last_name ?>"> <input type="hidden" name="time_zone_text<?php echo $i ?>" id="time_zone_text<?php echo $i ?>" value="<?php echo $time_zone ?>"></td>
    <td><input type="checkbox" name="in_time_checkbox<?php echo $i ?>" id="in_time_checkbox<?php echo $i ?>"  
    onClick="
    document.getElementById('in_time_checkbox<?php echo $i ?>').checked=true;
    document.getElementById('late_div<?php echo $i ?>').hidden=true; 
    document.getElementById('late_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('l-permission_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('late_select<?php echo $i ?>').selectedIndex=-1;
    document.getElementById('late_checkbox<?php echo $i ?>').disabled=false;
    document.getElementById('absent_div<?php echo $i ?>').hidden=true; 
    document.getElementById('absent_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('a-permission_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('absent_select<?php echo $i ?>').selectedIndex=-1;
    document.getElementById('absent_checkbox<?php echo $i ?>').disabled=false;
    document.getElementById('status_text<?php echo $i ?>'). value = 'present'; 
    ">
      
      <input type="checkbox" name="late_checkbox<?php echo $i ?>" id="late_checkbox<?php echo $i ?>" 
    onClick="
    document.getElementById('late_div<?php echo $i ?>').hidden=false; 
    document.getElementById('in_time_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('late_checkbox<?php echo $i ?>').disabled=false;
    document.getElementById('late_checkbox<?php echo $i ?>').checked=true;
    document.getElementById('absent_div<?php echo $i ?>').hidden=true; 
    document.getElementById('absent_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('a-permission_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('absent_select<?php echo $i ?>').selectedIndex=-1;
    document.getElementById('absent_checkbox<?php echo $i ?>').disabled=false; 
    document.getElementById('status_text<?php echo $i ?>'). value = 'late';  
    ">
      <input type="checkbox" name="absent_checkbox<?php echo $i ?>" id="absent_checkbox<?php echo $i ?>" 
    onClick="
    document.getElementById('absent_div<?php echo $i ?>').hidden=false; 
    document.getElementById('in_time_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('absent_checkbox<?php echo $i ?>').disabled=false;
    document.getElementById('absent_checkbox<?php echo $i ?>').checked=true;
    document.getElementById('late_div<?php echo $i ?>').hidden=true; 
    document.getElementById('late_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('l-permission_checkbox<?php echo $i ?>').checked=false; 
    document.getElementById('late_select<?php echo $i ?>').selectedIndex=-1;
    document.getElementById('late_checkbox<?php echo $i ?>').disabled=false;
    document.getElementById('status_text<?php echo $i ?>'). value = 'absent';  
    
    ">
    <input name="status_text<?php echo $i ?>" id="status_text<?php echo $i ?>" type="hidden" value="">
   </td>
    <td width="341">
      <div id='late_div<?php echo $i ?>' hidden="true;">
        <select name="hour_select<?php echo $i ?>" id="hour_select<?php echo $i ?>">
          <option value="07">07</option>
          <option value="08">08</option>
          <option value="09">09</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
        </select>
        <select name="min_select<?php echo $i ?>" id="min_select<?php echo $i ?>">
        <?php 
		$m=0;
		while ($m<10) {
		?>
		<option value="<?php echo '0'.$m ?>"><?php echo '0'.$m ?></option>	
        <?php
		$m++;
		}
		
		
		while ($m<60) {
		?>
		<option value="<?php echo $m ?>"><?php echo $m ?></option>	
        <?php
		$m++;
		}
		?>
        </select>
        <select name="late_select<?php echo $i ?>" id="late_select<?php echo $i ?>" class="select160" >
          <option value=" " selected> </option>
          <?php
        	for ($j = 0; $j < count($arrId1); $j++) {
    		echo "<option value=" . "\"" . $arrId1[$j] . "\"" . ">" . $arrName1[$j] . "</option>";
	}
?>
          </select>
        perm: 
        <input type="checkbox" name="l-permission_checkbox<?php echo $i ?>" id="l-permission_checkbox<?php echo $i ?>">
        </div>
      
      <div id='absent_div<?php echo $i ?>' hidden="true;">
        <select name="absent_select<?php echo $i ?>" id="absent_select<?php echo $i ?>" class="select160" onClick="document.getElementById('absent_div<?php echo $i ?>').hidden=false; document.getElementById('in_time_checkbox<?php echo $i ?>').checked=false; document.getElementById('late_checkbox<?php echo $i ?>').checked=false; "  >
          <option value=" " selected> </option>
          <?php
        	for ($j = 0; $j < count($arrId2); $j++) {
    		echo "<option value=" . "\"" . $arrId2[$j] . "\"" . ">" . $arrName2[$j] . "</option>";
	}
?>
          </select>
        perm: 
        <input type="checkbox" name="a-permission_checkbox<?php echo $i ?>" id="a-permission_checkbox<?php echo $i ?>" value="yes">
        </div>
      
    </td>
    </tr>
<?php
$i++;
}
?>
</table>
<input name="line_num" type="hidden" value="<?php echo $i ?>">
<input name="recording_date" type="hidden" value="<?php echo $recording_date ?>">

</div>
<div class="page_inside_frame">
  <table width="645" border="0">
    <tr>
      <td width="20"></td>
      <td width="615" align="right"><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_close_button"  id="save_close_button" type="submit" class="imagebutton" value="Save &amp; Close" onclick="needToConfirm = false; confirmRefresh();" /></td>
    </tr>
  </table>
</div>
</form>
<!--form validation-->
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
     
  for (i = 0; i < 50; i++) {
	
	frmvalidator.addValidation("status_text"+i,"req","- status "+document.getElementById('emp_name_text'+i).value+".");
	
}	
  </script>
</div>
</div>

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

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


</html>