<?php
include '../connection/includecon.php';


$day=$_REQUEST["day"];
$month=$_REQUEST["month"];
$year=$_REQUEST["year"];
$emp_id=$_REQUEST["emp_id"];
$date = $year.'-'.$month.'-'.$day;


		 $sql = "select * from tbl_emp_attendance where emp_id = '$emp_id' and date_ = '$date'";
	$result = $objhr->viewdata($sql);
	if($result->num_rows > 0){
		
					$rows = $result->fetch_assoc();
					if($rows['status']=='1'){
					 $sql2 = "update tbl_emp_attendance set status='0' where emp_id = '$emp_id' and date_ = '$date'";
	$result2 = $objhr->updation($sql2);
	 $array[]='0';
					}else{
					$sql3 = "update tbl_emp_attendance set status='1' where emp_id = '$emp_id' and date_ = '$date'";
	$result3 = $objhr->updation($sql3);
	 $array[]='1';
					}
					}else{
						$sql3 = "INSERT INTO `tbl_emp_attendance` (`emp_id`, `present_type_id`, `date_`, `status`) VALUES ('$emp_id', '1', '$date', '1');";
	$result3 = $objhr->insertion($sql3);
	 $array[]='1';
					
					}
					
					

			
			
	
		 echo json_encode($array);

?>