<?php
include("../include/session.php");
if(!$session->isRadstoneReceptionUser() && !$session->isAdmin()){
	header("Location: ../HR/employeeMenu.php");
}else{
	$empId = mysql_real_escape_string($_POST['empId']);
	$hours = $_POST['hours'];
	$permission = mysql_real_escape_string($_POST['permission']);
	$minutes = $_POST['minutes'];
	$details = mysql_real_escape_string($_POST['details']);
	$absent = mysql_real_escape_string($_POST['absent']);
	$dMonth = date("m");
	$dYear = date("y");
	$dDay = date("d");
	include("../include/db.php");
	
	
	$date = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : "";
	
	$hours = $hours + $minutes;
	
	
	$q = "INSERT INTO timekeeping (empId, hours, permission, details, absent, month, year, day, date) VALUES
	('".$empId."', '".$hours."', '".$permission."', '".$details."', '$absent','".$dMonth."', '".$dYear."', '".$dDay."','".$date."')";
	$result = execsql($q);

	if(!$result){
		echo 'This didnt work';
	}else{
		$return = mysql_real_escape_string($_POST['submitok']);
	if ($return == "Save and New") {
				$cat = mysql_real_escape_string($_POST['cat']);
				header("Location: latecoming.php?date=$date");
			} else {
				header("Location: employeeMenu.php");
			}
	}

//echo 'pewpew';

}
?>