<?php require_once '../framework/Vehicle.php'; require_once '../framework/Job.php'; //print_r($_POST); $criteria = trim($_POST['criteria']); $vehicle = trim($_POST['vehicle']); $lattitude = trim($_POST['lattitude']); $longitude = trim($_POST['longitude']); $address = trim($_POST['address']); $city = trim($_POST['city']); //echo "<br>".Vehicle::getIdByNumber($vehicle)."<br>"; $mVehicle = new Vehicle(Vehicle::getIdByNumber($vehicle)); $mVehicle->setLocation($lattitude, $longitude, $address, $city); //not supporting Job feature now!!! //$mJob = new Job($mVehicle->getCurrentJob()); //$mJob->setLocation($lattitude, $longitude); if ($criteria == "location") { $mVehicle->addTrack($lattitude, $longitude, $address); } else { $mVehicle->updateDuration($lattitude, $longitude); }
$error->reason = "VEHICLE ERROR"; $error->message = "No such vehicle exists"; $result->error = $error; } else { if ($mVehicle->getIMEI() == $imei) { $addressInfo = getAddress($lat, $lng); $address = $addressInfo->results[0]->formatted_address; $city = getCity($addressInfo->results[0]); //echo $address." ".$city; if ($city != "" && $mVehicle->getCurrentCity() != $city) { $vehicleId = $mVehicle->getId(); $driver = $mVehicle->getDriver(); Notification::addLocationNotification($driver, $vehicleId, $lat, $lng, $city); } if (isset($_GET['accuracy']) && $_GET['accuracy'] <= 20) { if ($mVehicle->setLocation($lat, $lng, $address, $city) && $mVehicle->addTrack($lat, $lng, $address)) { $setupResponse->status = "SUCCESS"; $setupResponse->request = "location, track"; } } else { if ($mVehicle->setLocation($lat, $lng, $address, $city)) { $setupResponse->status = "SUCCESS"; $setupResponse->request = "location"; } } } else { $setupResponse->status = "FAILURE"; $error = new Error(); $error->reason = "AUTHENTICATION ERROR"; $error->message = "You are not authorized for this action."; $result->error = $error;