<?php
include("../../db.php");

$mobileEncoded = $_REQUEST['mobile'];
$passwordEncoded = $_REQUEST['password'];

$message = "Unknown Error";
$status = 0;

$dataBody = new StdClass();
if($mobileEncoded != '' && $passwordEncoded != ''){
    $mobile = base64_decode($mobileEncoded);
    $password = base64_decode($passwordEncoded);

    $result = $db->getRow("select * from gps_user where driver_mobile='$mobile' AND password='$password'");
    if($result){
        
        
        $school_code = $result["school_code"];
        
        $project_id = $db->getVal("select project_id from all_school_codes where code='$school_code'");
        
        if(!$project_id){
            $project_id = "";
        }
        
        $result["project_id"] = $project_id;
        
        $status = 1;
        $dataBody = $result;
        $message = "Success";
    }else{
        $message = "Invalid user detail! Please check and try again";
    }
}else{
    $message = "Mobile number and password required";
}

echo json_encode(array("status"=>$status,"data"=>$dataBody,"message"=>$message));