<?php
include("../config/database.php");
$conct  = new connectionCreat();
$conct->connectToDB();
$conct->selectDB();
$userId  = $_POST['userId'];			     
$sql     = mysql_query("select * from `tbl_sh_driver` where `id`='".$userId."' and `status`=1");
if(mysql_num_rows($sql)>0)
{
	$sqlData = mysql_fetch_array($sql);
	$sqlDriver     = mysql_query("select `id`,`emp_name` from `tbl_emp_driver` where `id`='".$sqlData['driver_id']."'");
    $sqlDriverData = mysql_fetch_array($sqlDriver); 
    
    $driverId = $sqlDriverData['id'];
    $driverName = $sqlDriverData['emp_name'];
    
    $attendanceStatus  = 0;
    $sqlDriverTeam     = mysql_query("select `id` from `tbl_attendence_driver_team` where `emp_id`='".$driverId."' and `date`='".date('Y-m-d')."'");
    if(mysql_num_rows($sqlDriverTeam)>0)
    {
        $attendanceStatus = 1;    
    }
    
	$arr = array("status"=>true, "msg"=>"Login Successfully.", 'userId'=>$sqlData['id'], 'name'=>$sqlData['name'], 'designation'=>$sqlData['designation'], 'driverId'=>$driverId, 'driverName'=>$driverName, 'attendanceStatus'=>$attendanceStatus);		
}
else
{
	$arr = array("status"=>false,"msg"=>"Account Suspended.");
}
echo json_encode($arr);		    	
mysql_close();		
?>

