<!--Notice: (c)2013 This page is part of the management program for Tlhomeso Timbers, Gaborone, 
and developed by Customized Software (Pty) Ltd, Gaborone, Botswana. 
Customized Software holds the copyright on the source code on this and all other pages in the 
management program. For more info contact Customized Software on email: info@bwcustomized.com-->

<?php
include ("../include/session.php");


$emp_id = $_GET['emp_id'];
$status = $_GET['status'];

echo 'status:'.$status;

$w_min = 0;
$l_min = 0;


if ($status=="U") {
	$permission="no";
	$clock_in="";
	$clock_out="";
	$reason="unknown";
	$checked=2;
	
}

if ($status=="A") {
	$permission = $_GET['permission_group'];
	$time_keeping = $_GET['time_keeping'];
	$reason = $_GET['reason_select'];
	$clock_in = 0;
	$clock_out = 0;
	$checked=1;
	
	
}


if ($status=="P") {
$permission="";
$clock_in = 420;
$clock_out = 0;
$w_min = 0;
$reason = "";
$checked=1;

}

if ($status=="L") {
$permission = $_GET['permission_group'];
$hours = $_GET['hours_select'];
$min = $_GET['min_select'];
$reason = $_GET['reason_select'];
$clock_in = ($hours*60)+$min;
$l_min = $clock_in - 420;
$clock_out = 0;
$checked=1;

$table_name = $_SESSION['db_prefix']."_time_record";

  include('../include/employee_late_alert.php');


}



     

if ($status=='S') {
		$table_name = $_SESSION['db_prefix']."_sick_leave";
        $leave_query = "INSERT INTO $table_name (emp_id, date, paid ) VALUES (' ".$emp_id    ." ' ,' ".$_SESSION['record_date']  ."' ,'sick')  ";
        execsql($leave_query);
		$clock_in = 0;
		$clock_out = 0;
		$w_min = 540;
		$reason="sick leave";
		$permission="yes";
		$checked=1;
}


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



$table_name = $_SESSION['db_prefix']."_time_record";
$check_query = "UPDATE $table_name SET status = '".$status."',  reason = '".$reason."', permission = '".$permission."', checked = '".$checked."',  clock_in = '".$clock_in."', clock_out = '".$clock_out."', l_min = '".$l_min."', type = 'N', entry_time = '".$entry_time."', entry_by = '".$_SESSION['username']."' WHERE emp_id = '". $emp_id  ."' AND date = '". $_SESSION['record_date'] ."'";
$check_result = mySQL_query($check_query);
//echo $check_query;
if ($_SESSION['set'] == 0) {
	$location='timeWizbase.php?p=3&s=3';
}
if ($_SESSION['set'] == 1) {
	$location='add_timeWizbase.php?p=3&s=3';
}
?>

<script language="javascript" type="text/javascript">
        <!--
		 window.location="<?php echo $location?>";
        -->
       </script>