<?php
session_start();
	
include_once("../class/class.MySQL.php");
require '../class/resizeImage.php';
$db=new MySQL();


$data="";
$data1="";
$data2="";
$data3="";
$data4="";
$data5="";
$data6="";


if(isset($_POST['recdate']))
{
	
	$data=array();
	$dts = date(('Y-m-d'),strtotime($_POST['recdate']));
	$chk_date=date('Y-m-d',strtotime($_POST['recdate']));
	
	$timerin = $_POST['timepicker_in'];
	$timerout = $_POST['timepicker_out'];
	$eid = $_POST['empid'];
	
	mysql_query("DELETE FROM time where e_id = '$eid' and e_date ='$dts'");
		
	$time1 = strtotime($timerin);
	$time2 = strtotime($timerout);
	
	$diff = $time2 - $time1;
	
	$totalWorkTime = date('H:i:s',strtotime("-6 hours 30 minutes",$diff));
	
	$LogTimeIn =  date("H:i",strtotime($timerin));  
	$dt_frtIn =  date('A', strtotime($timerin));
	
	$LogTimeOut =  date("H:i",strtotime($timerout));  
	$dt_frtOut =  date('A', strtotime($timerout));
	
	mysql_query("INSERT INTO time (e_date,e_id,deviceids,e_in,e_out,e_work,time_in,time_inloc,time_out,time_outloc,total_worked_hours) VALUES ('$dts','$eid','44','$timerin','$timerout','$totalWorkTime','$LogTimeIn','$dt_frtIn','$LogTimeOut','$dt_frtOut','$totalWorkTime')");
	
	
}
?>