<?php
include("../config/database.php");
$conct  = new connectionCreat();
$conct->connectToDB();
$conct->selectDB();
$userId   = $_POST['userId'];	
$driverId = $_POST['driverId'];			     
$date     = date('Y-m-d', strtotime($_POST['date']));
$aType    = $_POST['attendanceType'];
$remark   = $_POST['remark'];
$sqlDriverTeam = mysql_query("select `id` from `tbl_attendence_driver_team` where `emp_id`='".$driverId."' and `date`='".$date."'");
if(mysql_num_rows($sqlDriverTeam)>0)
{
    $arr = array('status'=>false, 'msg'=>"Attendance Already Marked.");			
}
else
{
    $sqlDriver     = mysql_query("select `state` from `tbl_emp_driver` where `id`='".$driverId."'");
    $sqlDriverData = mysql_fetch_array($sqlDriver); 
    
    mysql_query("insert into `tbl_attendence_driver_team` SET `emp_id`='".$driverId."', `state`='".$sqlDriverData['state']."', `date`='".$date."', `mark`='".$aType."', `sh_id`='".$userId."', `remark`='".$remark."'");    
    $arr = array('status'=>true, 'msg'=>"Attendance Mark Successfully.");
}
echo json_encode($arr);		    	
mysql_close();		
?>

