<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function get_calender_events() { $params = array(); /*Get current date*/ $current_date = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key = "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...
<?php
//WP Search in API
define ('DB_USER', 'root');
define ('DB_PASSWORD', '');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'cabcouk_db1');
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME);
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
$terms = $_REQUEST[ 's' ];
$exploded = explode( ' ', $terms );
if( $exploded === FALSE || count( $exploded ) == 0 )
$exploded = array( 0 => $terms );
$where = '';
foreach( $exploded as $tag ) :
$where .= "
AND (
(wp_posts.post_title LIKE '%$tag%')
OR (wp_posts.post_content LIKE '%$tag%')
OR EXISTS (
SELECT * FROM wp_postmeta
WHERE post_id = wp_posts.ID
AND (";
$where .= " (meta_value RLIKE '[[:<:]]".$tag."[[:>:]]' AND meta_key IN('map_location','post-code')) ";
$where .= ")
)
OR EXISTS (
SELECT * FROM wp_terms
INNER JOIN wp_term_taxonomy
ON wp_term_taxonomy.term_id = wp_terms.term_id
INNER JOIN wp_term_relationships
ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
WHERE (
taxonomy = 'post_tag'
OR taxonomy = 'category'
)
AND object_id = wp_posts.ID
AND wp_terms.name LIKE '%$tag%'
)
)";
endforeach;
$rs= "select id,post_title from wp_posts WHERE 1 $where AND post_type='post' ORDER BY id DESC";
$result = mysqli_query($con,$rs);
$data = mysqli_num_rows($result);
$responses = array();
if($data != 0) {
while($results = mysqli_fetch_assoc($result))
{
$id = $results['id'];
$post_title = $results['post_title'];
$rs1= "select * from wp_postmeta WHERE post_id=$id";
$result1 = mysqli_query($con,$rs1);
$data1 = mysqli_num_rows($result1);
if($data1 != 0) {
while($results1 = mysqli_fetch_assoc($result1))
{
if($results1['meta_key']=="phone-no"){
$phone_no=$results1['meta_value'];
}
if($results1['meta_key']=="post-code"){
$post_code=$results1['meta_value'];
}
if($results1['meta_key']=="images"){
$image=$results1['meta_value'];
}
}
}
$temp = explode(",",$image);
$responses[] = array(
'id' => $id,
'title' => $post_title,
'phone_no' => $phone_no,
'post_code' => $post_code,
'image' => $temp[0] ,
);
}
$phone_no="";
$post_code="";
$image="";
$success = array(
'status' => 1,
'Response' => $responses,
);
echo json_encode($success);
}
//echo $rs;
/*
echo "<hr>";
$query= "SELECT * FROM wp_posts INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.meta_id WHERE 1 $where AND post_type='post'";
echo $query;
*/
?>
**************************************
<?php
/* File : Taxi.Rest.inc.php
* Author : CSS
*/
class TAXIREST {
public $_allow = array();
public $_content_type = "application/json";
public $_request = array();
private $_method = "";
private $_code = 200;
public function __construct(){
$this->apiinputs();
}
public function get_api_referer(){
return $_SERVER['HTTP_REFERER'];
}
public function api_response($data,$status){
$this->_code = ($status)?$status:200;
$this->set_api_headers();
echo $data;
exit;
}
private function get_api_status_message(){
$status = array(
100 => 'Continue',
101 => 'Switching Protocols',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
306 => '(Unused)',
307 => 'Temporary Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported');
return ($status[$this->_code])?$status[$this->_code]:$status[500];
}
public function get_api_request_method(){
return $_SERVER['REQUEST_METHOD'];
}
private function apiinputs(){
switch($this->get_api_request_method()){
case "POST":
$this->_request = $this->cleanApiInputs($_POST);
break;
case "GET":
case "DELETE":
$this->_request = $this->cleanApiInputs($_GET);
break;
case "PUT":
parse_str(file_get_contents("php://input"),$this->_request);
$this->_request = $this->cleanApiInputs($this->_request);
break;
default:
$this->api_response('',406);
break;
}
}
private function cleanApiInputs($data){
$clean_input = array();
if(is_array($data)){
foreach($data as $k => $v){
$clean_input[$k] = $this->cleanApiInputs($v);
}
}else{
if(get_magic_quotes_gpc()){
$data = trim(stripslashes($data));
}
$data = strip_tags($data);
$clean_input = trim($data);
}
return $clean_input;
}
private function set_api_headers(){
//echo "AAA".$this->get_api_status_message();
header("HTTP/1.1 ".$this->_code." ".$this->get_api_status_message());
header("Content-Type:".$this->_content_type);
}
}
?>
***********************
<?php
ob_start();
//error_reporting(-1);
// Same as error_reporting(E_ALL);
//ini_set('error_reporting', E_ALL);
/*
$a = fopen("driv.txt","w");
foreach($_REQUEST as $k=>$v)
{
if(is_array($v))
{
foreach($v as $kk=>$vv)
{
if(is_array($vv))
{
foreach($vv as $kkk=>$vvv)
{
fwrite($a,$k."===".$kk."===".$kkk."==".$vvv."\n");
}
}
else
{
fwrite($a,$k."===".$kk."==".$vv."\n");
}
}
}
else
{
fwrite($a,$k."==".$v."\n");
}
}
fclose($a);
*/
require_once("Taxi.Rest.inc.php");
function checkEmail($email)
{
$result = TRUE;
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email))
{
$result = FALSE;
}
return $result;
}
class API extends TAXIREST {
public $data = "";
const DB_SERVER = "localhost";
const DB_USER = "uetsa";
const DB_PASSWORD = "lkjerw@qw";
const DB = "tax_poi";
/* const DB_SERVER = "localhost";
const DB_USER = "opuye";
const DB_PASSWORD = "jhg*2qwvfg";
const DB = "tasi_app";*/
private $db = NULL;
public function __construct(){
parent::__construct(); // Init parent contructor
$this->dbConnect(); // Initiate Database connection
}
/*
* Database connection
*/
private function dbConnect(){
$this->db = mysql_connect(self::DB_SERVER,self::DB_USER,self::DB_PASSWORD);
if($this->db)
mysql_select_db(self::DB,$this->db);
}
/*
* Public method for access api.
* This method dynmically call the method based on the query string
*
*/
public function processApi(){
$func = strtolower(trim(str_replace("/","",$_REQUEST['rquest'])));
if((int)method_exists($this,$func) > 0)
{
$this->$func();
}
else
{
$this->api_response('',404);
}
}
/*
* Simple Driver Registeraton API
* Driver Registeraton must be POST method
* fname : <Driver First Name>
* lname : <Driver Last Name>
* username : <Driver Username>
* password : <Driver Password>
* emailid : <Driver Email ID>
* phone_no : <Driver Phone No>
* driver_noplate : <Driver No Plate>
* lat : <Driver Lat>
* lng : <Driver Lng>
* lic_no : <Driver LicNo>
* lic_exp_date : <Driver Lic Exp Date>
* tc : <Terms & Condition>
* payoption : <Payment Option>
* cofexpiry : <cofexpiry>
* regoexpiry : <regoexpiry>
* licencecardexpiry : <licencecardexpiry>
* vtid : <vtid>
* veh_no : <veh_no>
* made : <made>
* taxifleetname : <taxifleetname>
* taxifleetnumber : <taxifleetnumber>
* API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/driverregisteration/
*/
private function driverregisteration(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$fname = $this->_request['fname'];
if($fname=="")
{
array_push($arr,"Please Enter First Name.");
}
$lname = $this->_request['lname'];
if($lname=="")
{
array_push($arr,"Please Enter Last Name.");
}
$username = $this->_request['username'];
if($username=="")
{
array_push($arr,"Please Enter Username.");
}
$password = $this->_request['password'];
if($password=="")
{
array_push($arr,"Please Enter Password.");
}
$emailid = $this->_request['emailid'];
if($emailid=="")
{
array_push($arr,"Please Enter Email ID.");
}
$phone_no = $this->_request['phone_no'];
if($phone_no=="")
{
array_push($arr,"Please Enter Phone NO.");
}
$driver_noplate = $this->_request['driver_noplate'];
if($driver_noplate=="")
{
array_push($arr,"Please Enter driver no plate.");
}
$lat = $this->_request['lat'];
if($lat=="")
{
array_push($arr,"Please Enter Lat.");
}
$lng = $this->_request['lng'];
if($lng=="")
{
array_push($arr,"Please Enter Lng.");
}
$lic_no = $this->_request['lic_no'];
$lic_exp_date = $this->_request['lic_exp_date'];
$tc = $this->_request['tc'];
if($tc!="1")
{
array_push($arr,"Please Select Terms & Condition");
}
$payoption = $this->_request['payoption'];
if($payoption=="")
{
array_push($arr,"Please Enter Payment Option.");
}
$cofexpiry = $this->_request['cofexpiry'];
$regoexpiry = $this->_request['regoexpiry'];
$licencecardexpiry = $this->_request['licencecardexpiry'];
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle TaxiType.");
}
$veh_no = $this->_request['veh_no'];
if($veh_no=="")
{
array_push($arr,"Please Enter Vehical Number.");
}
$modelno= $this->_request['modelno'];
if($modelno=="")
{
array_push($arr,"Please Enter Model Number.");
}
$made = $this->_request['made'];
if($made=="")
{
array_push($arr,"Please Enter Made.");
}
$taxifleetname = $this->_request['taxifleetname'];
if($taxifleetname=="")
{
array_push($arr,"Please Enter taxi fleet name.");
}
$taxifleetnumber = $this->_request['taxifleetnumber'];
if($taxifleetnumber=="")
{
array_push($arr,"Please Enter taxi fleet number.");
}
if(count($arr)==0)
{
$squery = mysql_query("select * from tbl_driver_master where username='".$username."'", $this->db);
if(mysql_num_rows($squery) > 0){
$error = array("status" => "false", "msg" => 'This username Already Exist.' );
$this->api_response($this->json($error), 400);
exit;
}
else
{
$action_date=date("Y-m-d H:i:s");
$is_activate=0;
$is_deleted=0;
$insert_sql = "insert into tbl_driver_master (fname, lname, username, password, emailid, phone_no, driver_noplate, lat, lng, lic_no, lic_exp_date, action_date, is_activate, is_deleted, tc, payoption,cofexpiry,regoexpiry,licencecardexpiry) values ('".$fname."', '".$lname."', '".$username."', '".$password."', '".$emailid."', '".$phone_no."', '".$driver_noplate."', '".$lat."', '".$lng."', '".$lic_no."', '".$lic_exp_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."','".$tc."','".$payoption."','".$cofexpiry."','".$regoexpiry."','".$licencecardexpiry."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
/*******Eddited bY punam******/
if($insert_id > 0)
{
$is_activate=1;
$sql_res = mysql_query("SELECT price_per_min,price_per_km,min_price FROM `tbl_vehicle_type_master` WHERE vtid = '".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$price_per_km = $result_res["price_per_km"];
$price_per_min = $result_res["price_per_min"];
$min_price = $result_res["min_price"];
}
}
$insert_vehicle_sql = "insert into tbl_vehicle_master (did, veh_no, vtid, price_per_km,price_per_min, min_price, action_date, is_activate, is_deleted,modelno,made,taxifleetname,taxifleetnumber) values ('".$insert_id."', '".$veh_no."', '".$vtid."', '".$price_per_km."', '".$price_per_min."', '".$min_price."', '".$action_date."', '".$is_activate."', '".$is_deleted."', '".$modelno."', '".$made."', '".$taxifleetname."', '".$taxifleetnumber."')";
$vehicae_sql = mysql_query($insert_vehicle_sql, $this->db);
}
/***************/
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE did = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
// Mail
$body1 = "<font face=verdana size=2>";
$body1 .= "Dear ".$fname.". Your account has been created for Driver and your login details as<br><br>";
$body1 .= "User Name: ".$username."<br>";
$body1 .= "Password: ".$password."<br><br><br>your request has been processed/accepted, to become Ezygo partner please bring the following original documents to Ezygo office for the app activation";
$body1 .= "</font>";
$emsubject = "Welcome to Ezygo.";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($emailid, $emsubject, $body1, $headers);
$params=array();
$params['FNAME']=$fname;
$params['LNAME']=$lname;
storeAddress_driver($emailid,$params);
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Driver By DID API
* Get Driver By DID POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getdriverbydid/
*/
private function getdriverbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE did = '".$did."' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get All Drivers API
* Get All Drivers POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getalldriver/
*/
private function getalldriver(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Delete Driver By DID API
* Get All Drivers POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/deletedriverbydid/
*/
private function deletedriverbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_driver_master set is_deleted='1', action_date='".$action_date."' where did='".$did."'";
$sql = mysql_query($update_sql, $this->db);
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE did='".$did."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit Driver By DID API
* Edit Driver By DID must be POST method
* did : <Driver ID>
* fname : <Driver First Name>
* lname : <Driver Last Name>
* username : <Driver Username>
* password : <Driver Password>
* emailid : <Driver Email ID>
* phone_no : <Driver Phone No>
* driver_noplate : <Driver No Plate>
* deviceid : <Driver DeviceId>
* lat : <Driver Lat>
* lng : <Driver Lng>
* lic_no : <Driver LicNo>
* lic_exp_date : <Driver Lic Exp Date>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editdriverbydid/
*/
private function editdriverbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
$fname = $this->_request['fname'];
if($fname=="")
{
array_push($arr,"Please Enter First Name.");
}
$lname = $this->_request['lname'];
if($lname=="")
{
array_push($arr,"Please Enter Last Name.");
}
$username = $this->_request['username'];
if($username=="")
{
array_push($arr,"Please Enter Username.");
}
$password = $this->_request['password'];
if($password=="")
{
array_push($arr,"Please Enter Password.");
}
$emailid = $this->_request['emailid'];
if($emailid=="")
{
array_push($arr,"Please Enter Email ID.");
}
$phone_no = $this->_request['phone_no'];
if($phone_no=="")
{
array_push($arr,"Please Enter Phone NO.");
}
$driver_noplate = $this->_request['driver_noplate'];
if($driver_noplate=="")
{
array_push($arr,"Please Enter Driver No Plate.");
}
$deviceid = $this->_request['deviceid'];
if($deviceid=="")
{
array_push($arr,"Please Enter DeviceId.");
}
$lat = $this->_request['lat'];
if($lat=="")
{
array_push($arr,"Please Enter Lat.");
}
$lng = $this->_request['lng'];
if($lng=="")
{
array_push($arr,"Please Enter Lng.");
}
$lic_no = $this->_request['lic_no'];
$lic_exp_date = $this->_request['lic_exp_date'];
$payoption = $this->_request['payoption'];
if($payoption=="")
{
array_push($arr,"Please Enter Payment Option.");
}
if(count($arr)==0)
{
/*$squery = mysql_query("select * from tbl_driver_master where username='".$username."' and did='".$did."'", $this->db);
if(mysql_num_rows($squery) > 0){
$error = array("status" => "false", "msg" => 'This username Already Exist.' );
$this->api_response($this->json($error), 400);
exit;
}
else
{*/
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_driver_master set fname='".$fname."', lname='".$lname."', username='".$username."', password='".$password."', emailid='".$emailid."', phone_no='".$phone_no."', driver_noplate='".$driver_noplate."', deviceid='".$deviceid."', lat='".$lat."', lng='".$lng."', lic_no='".$lic_no."', lic_exp_date='".$lic_exp_date."', action_date='".$action_date."',payoption='".$payoption."' where did='".$did."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
//$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE did = '$did'", $this->db);
$sql_res = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE dm.did = '$did'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
//}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit Lat LNG By DID API
* Edit LAT LNG By DID POST method
* did : <Driver ID>
* lat : <Driver LAT>
* lng : <Driver LNG>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editlatlngbydid/
*/
private function editlatlngbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$lat = $this->_request['lat'];
if($lat=="")
{
array_push($arr,"Please Enter Driver LAT.");
}
$lng = $this->_request['lng'];
if($lng=="")
{
array_push($arr,"Please Enter Driver LNG.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_driver_master set lat='".$lat."', lng='".$lng."', action_date='".$action_date."' where did='".$did."'";
$sql = mysql_query($update_sql, $this->db);
$data=array();
$sql_res = mysql_query("SELECT did,lat,lng FROM tbl_driver_master WHERE did='".$did."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit LAT LNG By DeviceId API
* Edit Lat LNG By DeviceId POST method
* deviceid : <Driver DeviceId>
* lat : <Driver LAT>
* lng : <Driver LNG>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editlatlngbydeviceid/
*/
private function editlatlngbydeviceid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$deviceid = $this->_request['deviceid'];
if($deviceid=="")
{
array_push($arr,"Please Enter Driver DeviceId.");
}
$lat = $this->_request['lat'];
if($lat=="")
{
array_push($arr,"Please Enter Driver LAT.");
}
$lng = $this->_request['lng'];
if($lng=="")
{
array_push($arr,"Please Enter Driver LNG.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_driver_master set lat='".$lat."', lng='".$lng."', action_date='".$action_date."' where deviceid='".$deviceid."'";
$sql = mysql_query($update_sql, $this->db);
$data=array();
$sql_res = mysql_query("SELECT deviceid,lat,lng FROM tbl_driver_master WHERE deviceid='".$deviceid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Driver LOGIN API
* Driver Login must be POST method
* username : <Driver username>
* password : <Driver password>
* API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/driverlogin/
*/
private function driverlogin(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$username = $this->_request['username'];
$password = $this->_request['password'];
// Input validations
if(!empty($username) || !empty($password)){
$sql = mysql_query("SELECT * FROM tbl_driver_master WHERE username = '$username' AND password = '".$password."'", $this->db);
//$sql = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE username = '$username' AND password = '".$password."'", $this->db);
if(mysql_num_rows($sql) > 0){
$res=array();
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
if($result["is_activate"]==1)
{
/*$sql1 = mysql_query("SELECT * FROM tbl_driver_master WHERE did = '".$result["did"]."'", $this->db);
$result1 = mysql_fetch_array($sql1,MYSQL_ASSOC);
$res[]=$result1;
$sql2 = mysql_query("SELECT * FROM tbl_vehicle_master WHERE did = '".$result["did"]."'", $this->db);
$result2 = mysql_fetch_array($sql2,MYSQL_ASSOC);
$res[]=$result2;*/
$sql_res_veh = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE dm.did = '".$result["did"]."'", $this->db);
$result2 = mysql_fetch_array($sql_res_veh,MYSQL_ASSOC);
$res[]=$result2;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$success = array("status" => "false", "items" => "Driver is Inactive, Please contact to Administrator");
$this->api_response($this->json($success), 200);
}
}
else
{
$error = array("status" => "false", "msg" => "Invalid Username or Password");
$this->api_response($this->json($error), 400);
}
}
$error = array("status" => "false", "msg" => "Invalid Username or Password");
$this->api_response($this->json($error), 400);
}
/*
* Simple Driver Forget Password API
* Driver Forget Password must be POST method
* username : <Driver username>
* API URL : http://dev9.edreamz3.com/taxiapp/api/driverforgetpassword/
*/
private function driverforgetpassword(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$email = $this->_request['email'];
if(!empty($email) && checkEmail($email)){
$sql = mysql_query("SELECT * FROM tbl_driver_master WHERE emailid = '".$email."'", $this->db);
if(mysql_num_rows($sql) > 0){
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
$length =10;
$conso=array("b","c","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","x","y","z");
$vocal=array("5","8","7","9","6");
$password="";
srand ((double)microtime()*1000000);
$max = $length/2;
for($i=1; $i<=$max; $i++)
{
$password.=$conso[rand(0,19)];
$password.=$vocal[rand(0,4)];
}
$newpass = $password;
$body1 = "<font face=verdana size=2>";
$body1 .= "Your New Password<br><br>";
$body1 .= "EMAIL-ID: ".$email."<br>";
$body1 .= "PASSWORD: ".$newpass."<br>";
$body1 .= "</font>";
$emsubject = "Your New Password.";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($email, $emsubject, $body1, $headers))
{
$del_sql = mysql_query("update tbl_driver_master set password='".$newpass."' where emailid='".$email."'", $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE emailid = '$email' AND password = '".$newpass."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
}
else
{
$error = array("status" => "false", "msg" => "Message delivery failed...");
$this->api_response($this->json($error), 400);
}
$this->api_response($this->json($result), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => "Invalid Email");
$this->api_response($this->json($error), 400);
}
}
$error = array("status" => "false", "msg" => "Invalid Email");
$this->api_response($this->json($error), 400);
}
/*
* Simple Get all details of customer as current or advance booking
* Get all details of customer as current or advance booking must be POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallcustomerbooking/
*/
private function getallcustomerbooking(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
if(count($arr)==0)
{
$ss="SELECT * FROM tbl_taxi_booking WHERE booking_time > '".$timenow."' and is_activate = 1 and is_deleted=0 ";
$sql_res_booking = mysql_query("SELECT * FROM tbl_taxi_booking WHERE booking_time > '".$timenow."' and is_activate = 1 and is_deleted=0 ", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Droped Booking Status API
* Droped Booking Status must be POST method
* did : <Driver ID>
* driving_date : <Driving Date>
* API URL : http://dev9.edreamz3.com/taxiapp/api/dailydriverworkinghrs/
*/
private function dailydriverworkinghrs(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$driving_date = $this->_request['driving_date'];
if($driving_date=="")
{
array_push($arr,"Please Enter Driving Date.");
}
else{
$driving_date=date('Y-m-d', strtotime($driving_date));
}
if(count($arr)==0)
{
$res=array();
$workinghrs=0;
$sql_res = mysql_query("SELECT tbid FROM tbl_taxi_booking_status WHERE did = '$did' and collected_date like '$driving_date%'", $this->db);
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$sql_booking= mysql_query("SELECT traveling_time FROM tbl_taxi_booking WHERE tbid = '".$result_res['tbid']."'", $this->db);
$result_boking = mysql_fetch_array($sql_booking,MYSQL_ASSOC);
$workinghrs=$workinghrs+$result_boking['traveling_time'];
}
$workinghrs1=floor($workinghrs/60);
$workinghrs2=$workinghrs-($workinghrs1*60);
$res[]['workinghrs']=$workinghrs1.":".$workinghrs2;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ DRIVER API END ###################################
################################ Vehicle API Start ###################################
/*
* Simple Vehicle Registeraton API
* Vehicle Registeraton must be POST method
* vtid : <Vehicle TaxiType>
* did : <Driver ID>
* price_per_km : <Driver PricePerKm>
* price_per_min : <Driver PricePerMin>
* min_price : <Driver MinFare>
* veh_no : <Vehicle Number>
* color : <Vehicle Color>
* photo : <Vehicle Photo>
* API URL : http://dev9.edreamz3.com/taxiapp/api/vehicalregisteration/
*/
private function vehicalregisteration(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle TaxiType.");
}
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
/*$price_per_km = $this->_request['price_per_km'];
if($price_per_km=="")
{
array_push($arr,"Please Enter Driver Price Per Km.");
}
$price_per_min = $this->_request['price_per_min'];
if($price_per_min=="")
{
array_push($arr,"Please Enter Driver Price Per Min.");
}
$min_price = $this->_request['min_price'];
if($min_price=="")
{
array_push($arr,"Please Enter Driver Min Price.");
}*/
$veh_no = $this->_request['veh_no'];
$color = $this->_request['color'];
$photo = $this->_request['photo'];
$modelno = $this->_request['modelno'];
if($modelno=="")
{
array_push($arr,"Please Enter Model Number.");
}
$made = $this->_request['made'];
if($made=="")
{
array_push($arr,"Please Enter Made.");
}
$taxifleetname = $this->_request['taxifleetname'];
if($taxifleetname=="")
{
array_push($arr,"Please Enter Taxi Fleet Name.");
}
$taxifleetnumber = $this->_request['taxifleetnumber'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$sql_res = mysql_query("SELECT price_per_min,price_per_km,min_price FROM `tbl_vehicle_type_master` WHERE vtid = '".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$price_per_km = $result_res["price_per_km"];
$price_per_min = $result_res["price_per_min"];
$min_price = $result_res["min_price"];
}
}
$insert_vehicle_sql = "insert into tbl_vehicle_master (did, veh_no, vtid, price_per_km, price_per_min, min_price, action_date, is_activate, is_deleted,modelno,made,taxifleetname,taxifleetnumber) values ('".$did."', '".$veh_no."', '".$vtid."', '".$price_per_km."', '".$price_per_min."', '".$min_price."', '".$action_date."', '".$is_activate."', '".$is_deleted."', '".$modelno."', '".$made."', '".$taxifleetname."', '".$taxifleetnumber."')";
//$insert_vehicle_sql = "insert into tbl_vehicle_master (did, veh_no, vtid, action_date, is_activate, is_deleted,modelno,made,taxifleetname,taxifleetnumber) values ('".$did."', '".$veh_no."', '".$vtid."', '".$action_date."', '".$is_activate."', '".$is_deleted."', '".$modelno."', '".$made."', '".$taxifleetname."', '".$taxifleetnumber."')";
$vehicae_sql = mysql_query($insert_vehicle_sql, $this->db);
$vid=mysql_insert_id();
$res=array();
$sql_res_veh = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE vid = '$vid'", $this->db);
$result_res_veh = mysql_fetch_array($sql_res_veh,MYSQL_ASSOC);
$res[]=$result_res_veh;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get All Vehicle By DID API
* Get Driver By DID POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallvehicalbydid/
*/
private function getallvehicalbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tbl_vehicle_master.*, CONCAT_WS(' ',tbl_driver_master.fname,tbl_driver_master.lname) as name FROM tbl_driver_master,tbl_vehicle_master WHERE tbl_driver_master.did = '".$did."' and tbl_driver_master.did =tbl_vehicle_master.did ", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get All Vehicle By VTID API
* Get Driver By VTID POST method
* vtid : <Vehicle TypeID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallvehicalbyvtid/
*/
private function getallvehicalbyvtid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle TypeID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tbl_vehicle_master*, CONCAT_WS(' ',tbl_driver_master.fname,tbl_driver_master.lname) as name FROM tbl_driver_master,tbl_vehicle_master WHERE tbl_driver_master.vtid = '".$vtid."' and tbl_driver_master.did =tbl_vehicle_master.did ", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit Vehicle By VID API
* Edit Vehicle By VID must be POST method
* vid : <Vehicle ID>
* vtid : <Vehicle TaxiType>
* did : <Driver ID>
* price_per_km : <Driver PricePerKm>
* price_per_min : <Driver PricePerMin>
* min_price : <Driver MinFare>
* veh_no : <Vehicle Number>
* color : <Vehicle Color>
* photo : <Vehicle Photo>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editvehiclebyvid/
*/
private function editvehiclebyvid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$vid = $this->_request['vid'];
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle TaxiType.");
}
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
/*$price_per_km = $this->_request['price_per_km'];
if($price_per_km=="")
{
array_push($arr,"Please Enter Driver Price Per Km.");
}
$price_per_min = $this->_request['price_per_min'];
if($price_per_min=="")
{
array_push($arr,"Please Enter Driver Price Per Min.");
}
$min_price = $this->_request['min_price'];
if($min_price=="")
{
array_push($arr,"Please Enter Driver Min Price.");
}*/
$veh_no = $this->_request['veh_no'];
$color = $this->_request['color'];
$photo = $this->_request['photo'];
$modelno = $this->_request['modelno'];
if($modelno=="")
{
array_push($arr,"Please Enter Model Number.");
}
$made = $this->_request['made'];
if($made=="")
{
array_push($arr,"Please Enter Made.");
}
$taxifleetname = $this->_request['taxifleetname'];
if($taxifleetname=="")
{
array_push($arr,"Please Enter Taxi Fleet Name.");
}
$taxifleetnumber = $this->_request['taxifleetnumber'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$sql_res = mysql_query("SELECT price_per_min,price_per_km,min_price FROM `tbl_vehicle_type_master` WHERE vtid = '".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$price_per_km = $result_res["price_per_km"];
$price_per_min = $result_res["price_per_min"];
$min_price = $result_res["min_price"];
}
}
$update_sql = "update tbl_vehicle_master set did='".$did."', veh_no='".$veh_no."', vtid='".$vtid."', price_per_km='".$price_per_km."', price_per_min='".$price_per_min."', min_price='".$min_price."', action_date='".$action_date."',modelno='".$modelno."',made='".$made."',taxifleetname='".$taxifleetname."',taxifleetnumber='".$taxifleetnumber."' where vid='".$vid."'";
//$update_sql = "update tbl_vehicle_master set did='".$did."', veh_no='".$veh_no."', vtid='".$vtid."', action_date='".$action_date."',modelno='".$modelno."',made='".$made."',taxifleetname='".$taxifleetname."',taxifleetnumber='".$taxifleetnumber."' where vid='".$vid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res_veh = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE vid = '$vid'", $this->db);
$result_res_veh = mysql_fetch_array($sql_res_veh,MYSQL_ASSOC);
$res[]=$result_res_veh;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Vehicle API END ###################################
################################ BOOKING STATUS API Start ###################################
/*
* Simple Reg Booking Status API
* Reg Booking Status must be POST method
* did : <Driver ID>
* tbid : <Booking ID>
* status : <Booking Status Declined/Accepted>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerbookingstatus/
*/
private function registerbookingstatus(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID");
}
$status = $this->_request['status'];
if($status=="")
{
array_push($arr,"Please Enter Booking Status.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_taxi_booking_status (did, tbid, status, status_date, action_date, is_activate, is_deleted) values ('".$did."', '".$tbid."', '".$status."', '".$action_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// http://ezygo.co.nz/ftpserver/taxiapp/api/registerbookingstatuspush/
private function registerbookingstatuspush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID");
}
$status = $this->_request['status'];
if($status=="")
{
array_push($arr,"Please Enter Booking Status.");
}
$pushmsg = "";
$cid="";
//$sql_res = mysql_query("SELECT dm.did,dm.fname,dm.lname,tb.cid FROM tbl_driver_master dm inner join tbl_taxi_booking_status bs on bs.did=dm.did inner join tbl_taxi_booking tb on tb.tbid = bs.tbid WHERE bs.did = '".$did."' and bs.tbid= '".$tbid."'", $this->db);
$sql_res = mysql_query("SELECT dm.did, dm.fname, dm.lname, tb.cid, vm.modelno, vm.made FROM tbl_driver_master dm INNER JOIN tbl_taxi_booking_status bs ON bs.did = dm.did INNER JOIN tbl_taxi_booking tb ON tb.tbid = bs.tbid INNER JOIN tbl_vehicle_master vm ON vm.did = dm.did WHERE bs.did = '".$did."' and bs.tbid= '".$tbid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Driver Name: ".$result_res["fname"]." ".$result_res["lname"]." Phone No: ".$result_res["phone_no"]." Taxi Number Plate: ".$result_res["driver_noplate"]." Model Number: ".$result_res["modelno"]." Made: ".$result_res["made"];
$cid = $result_res["cid"];
}
}
$resp=array();
if($status=="Accepted")
{
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $cid,
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Booking Accepted"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_exec($curl);
}
}
/*
* Simple Collected Booking Status API
* Collected Booking Status must be POST method
* tbsid : <Booking Status ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/collectedbookingstatus/
*/
private function collectedbookingstatus(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter Booking Status ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking_status set status='Collected', collected_date='".$action_date."', action_date='".$action_date."' where tbsid='".$tbsid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '$tbsid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Droped Booking Status API
* Droped Booking Status must be POST method
* tbsid : <Booking Status ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/dropedbookingstatus/
*/
private function dropedbookingstatus(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter Booking Status ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking_status set status='Completed', droped_date='".$action_date."', action_date='".$action_date."' where tbsid='".$tbsid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '$tbsid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$collected_date=$result_res['collected_date'];
$droped_date=$result_res['droped_date'];
$traveling_time=round(abs(strtotime($droped_date) - strtotime($collected_date)) / 60,2);
$sql_driver = mysql_query("SELECT total_drive FROM tbl_driver_master WHERE did = '".$result_res['did']."'", $this->db);
$result_driver = mysql_fetch_array($sql_driver,MYSQL_ASSOC);
$total_drive=(int)$result_driver['total_drive'];
$new_total_drive=$total_drive+$traveling_time;
$update_bo = "update tbl_taxi_booking set status='Completed', traveling_time='".$traveling_time."' where tbid='".$result_res['tbid']."'";
$sql_bo = mysql_query($update_bo, $this->db);
$update_dr = "update tbl_driver_master set total_drive='".$new_total_drive."' where did='".$result_res['did']."'";
$sql_dr = mysql_query($update_dr, $this->db);
$msg = array();
$msg["str"] = "Dropped Successfully";
$success = array("status" => "true", "msg" => $msg );
$this->api_response($this->json($success), 200);
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// API URL : http://dev9.edreamz3.com/taxiapp/api/dropedbookingstatuspush/
private function dropedbookingstatuspush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter Booking Status ID.");
}
$pushmsg = "";
$sql_res = mysql_query("SELECT dm.did, dm.fname as dfname, dm.lname as dlname, cm.cid, cm.fname as cfname, cm.lname as clname, tb.booking_from, tb.booking_to FROM tbl_driver_master dm, tbl_taxi_booking tb, tbl_taxi_booking_status bs, tbl_customer_master cm where dm.did=bs.did and bs.tbid=tb.tbid and tb.cid=cm.cid AND bs.status = 'Completed' and bs.tbsid= '".$tbsid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$pushmsgdriver = "Passenger Name: ".$result_res["cfname"]." ".$result_res["clname"]." From: ".$result_res["booking_from"]." To: ".$result_res["booking_to"]." is over";
$APPLICATION_ID = "mALjhLoXULLHOoXR1n6K4pDOhZzKicjfyXMplpzK";
$REST_API_KEY = "sU9RWrGuumdHGHIKOvAosCBk1GRRWXywLoO4EQTV";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'did' => $result_res["did"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsgdriver",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Dropped"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
$pushmsgcustomer = "Driver Name: ".$result_res["dfname"]." ".$result_res["dlname"]." From: ".$result_res["booking_from"]." To: ".$result_res["booking_to"]." is over";
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $result_res["cid"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsgcustomer",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>""),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_exec($curl);
}
/*
* Simple Droped Booking Status API
* Droped Booking Status must be POST method
* tbsid : <Booking Status ID>
* booking_to : <booking_to>
* booking_to_lat : <booking_to_lat>
* booking_to_lng : <booking_to_lng>
* API URL : http://dev9.edreamz3.com/taxiapp/api/dropedbookingstatusfixed/
*/
private function dropedbookingstatusfixed(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter Booking Status ID.");
}
$booking_to = $this->_request['booking_to'];
$booking_to_lat = $this->_request['booking_to_lat'];
$booking_to_lng = $this->_request['booking_to_lng'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking_status set status='Completed', droped_date='".$action_date."', action_date='".$action_date."' where tbsid='".$tbsid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '$tbsid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$collected_date=$result_res['collected_date'];
$droped_date=$result_res['droped_date'];
$traveling_time=round(abs(strtotime($droped_date) - strtotime($collected_date)) / 60,2);
$sql_driver = mysql_query("SELECT total_drive FROM tbl_driver_master WHERE did = '".$result_res['did']."'", $this->db);
$result_driver = mysql_fetch_array($sql_driver,MYSQL_ASSOC);
$total_drive=(int)$result_driver['total_drive'];
$new_total_drive=$total_drive+$traveling_time;
$update_bo = "update tbl_taxi_booking set status='Completed', traveling_time='".$traveling_time."',booking_to='".$booking_to."',booking_to_lat='".$booking_to_lat."',booking_to_lng='".$booking_to_lng."' where booking_type='FixedAdvance' and tbid='".$result_res['tbid']."'";
$sql_bo = mysql_query($update_bo, $this->db);
$update_dr = "update tbl_driver_master set total_drive='".$new_total_drive."' where did='".$result_res['did']."'";
$sql_dr = mysql_query($update_dr, $this->db);
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// API URL : http://dev9.edreamz3.com/taxiapp/api/advancebookingpush/
private function advancebookingpush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$pushmsg = "";
date_default_timezone_set('NZ');
$rem1hr = $date=date("Y-m-d H:i", strtotime('1 hour'));
$rem1hr1 .= $rem1hr.":00";
$rem1hr2 .= $rem1hr.":59";
//$sql_res = mysql_query("SELECT dm.did, dm.fname as dfname, dm.lname as dlname, cm.cid, cm.fname as cfname, cm.lname as clname, tb.booking_from, tb.booking_to, tb.booking_time FROM tbl_driver_master dm, tbl_taxi_booking tb, tbl_taxi_booking_status bs, tbl_customer_master cm where dm.did=bs.did and bs.tbid=tb.tbid and tb.cid=cm.cid and bs.tbsid= '".$tbsid."'", $this->db);
$sql_res = mysql_query("SELECT dm.did, dm.fname AS dfname, dm.lname AS dlname, cm.cid, cm.fname AS cfname, cm.lname AS clname, tb.booking_from, tb.booking_to, tb.booking_time FROM tbl_taxi_booking tb INNER JOIN tbl_customer_master cm ON tb.cid = cm.cid INNER JOIN tbl_taxi_booking_status tbs ON tbs.tbid = tb.tbid INNER JOIN tbl_driver_master dm ON dm.did = tbs.did AND tb.booking_time >= '".$rem1hr1."' and tb.booking_time <= '".$rem1hr2."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$pushmsgdriver = "Passenger Name: ".$result_res["cfname"]." ".$result_res["clname"]." From: ".$result_res["booking_from"]." To: ".$result_res["booking_to"]." At: ".$result_res["booking_time"]." journey will start after 1 hour.";
$APPLICATION_ID = "mALjhLoXULLHOoXR1n6K4pDOhZzKicjfyXMplpzK";
$REST_API_KEY = "sU9RWrGuumdHGHIKOvAosCBk1GRRWXywLoO4EQTV";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'did' => $result_res["did"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsgdriver",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Advance Booking"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
$pushmsgcustomer = "Driver Name: ".$result_res["dfname"]." ".$result_res["dlname"]." From: ".$result_res["booking_from"]." To: ".$result_res["booking_to"]." At: ".$result_res["booking_time"]." journey will start after 1 hour.";
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $result_res["cid"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsgcustomer",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Advance Booking"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
}
//}
//}
/*
* Simple Get all Pending Booking
* Get all Pending Booking must be POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallpendingbooking/
*/
private function getallpendingbooking(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$sql_res_booking = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid not in (select tbid from tbl_taxi_booking_status) and is_activate = 1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Get all New Booking
* Get all New Booking must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallnewbookingbydid/
*/
private function getallnewbookingbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
date_default_timezone_set('NZ');
$timenow1=date("Y-m-d H:i:s");
$timenow=$date=date("Y-m-d H:i:s", strtotime('-15 minutes'));
$ss = "SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.booking_time > '".$timenow."' and tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did!='".$did."' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0";
//$sql_res_booking = mysql_query("SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.booking_time > '".$timenow."' and tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did!='".$did."' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0", $this->db);
$sql_res_booking = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid not in ( select tbid from tbl_taxi_booking_status where status='Accepted' OR status ='Collected' OR status='Completed' or (status='Declined' AND did ='".$did."')) and booking_time >= '".$timenow."' and is_activate = 1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
$dt = array();
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$x= array();
$x['CT'] = $timenow1;
$x['-15 T'] = $timenow;
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $x );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Get all Accepted Booking
* Get all Accepted Booking must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallacceptbookingbydid/
*/
private function getallacceptbookingbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$ss = "SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did='".$did."' and tbl_taxi_booking_status.status='Accepted' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0";
$sql_res_booking = mysql_query("SELECT tbl_taxi_booking.*,tbl_taxi_booking_status.tbsid,tbl_taxi_booking_status.status FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did='".$did."' and tbl_taxi_booking_status.status='Accepted' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0 ORDER BY tbid DESC ", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Get all Booking History
* Get all Booking History must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallbookinghistorybydid/
*/
private function getallbookinghistorybydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$driving_date = $this->_request['driving_date'];
if($driving_date=="")
{
array_push($arr,"Please Enter Driving Date.");
}
else{
$driving_date=date('Y-m-d', strtotime($driving_date));
}
if(count($arr)==0)
{
$ss = "SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did='".$did."' and tbl_taxi_booking_status.status='Completed' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0";
$sql_res_booking = mysql_query("SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did='".$did."' and tbl_taxi_booking_status.status='Completed' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0 ORDER BY tbid DESC", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
//$res1=array();
$workinghrs=0;
$sql_res = mysql_query("SELECT tbid FROM tbl_taxi_booking_status WHERE did = '$did' and collected_date like '$driving_date%'", $this->db);
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$sql_booking= mysql_query("SELECT traveling_time FROM tbl_taxi_booking WHERE tbid = '".$result_res['tbid']."'", $this->db);
$result_boking = mysql_fetch_array($sql_booking,MYSQL_ASSOC);
$workinghrs=$workinghrs+$result_boking['traveling_time'];
}
$workinghrs1=floor($workinghrs/60);
$workinghrs2=$workinghrs-($workinghrs1*60);
//$res1[]['workinghrs']=$workinghrs1.":".$workinghrs2;
$res1 = $workinghrs1.":".$workinghrs2;
$success = array("status" => "true", "items" => $resall, "dailydriverworkinghrs" => $res1);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Get All Advance Booking By Passenger
* Get All Advance Booking By Passenger must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getadvancebookingbypassenger/
*/
private function getadvancebookingbypassenger(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$timenow=date("Y-m-d H:i:s");
$ss = "SELECT * FROM tbl_taxi_booking WHERE booking_time > '".$timenow."' and cid='".$cid."' and booking_type='Advance' or booking_type='FixedAdvance' and is_activate = 1 and is_deleted=0";
$sql_res_booking = mysql_query("SELECT * FROM tbl_taxi_booking WHERE booking_time > '".$timenow."' and cid='".$cid."' and (booking_type='Advance' or booking_type='FixedAdvance') and is_activate = 1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$res[]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Cancel the Advance Booking By Passenger API
* Cancel the Advance Booking By Passenger must be POST method
* tbid : <Booking ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/cancelbookingbypassenger/
*/
private function cancelbookingbypassenger(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking set is_activate=0, action_date='".$action_date."' where tbid='".$tbid."'";
$sql = mysql_query($update_sql, $this->db);
$update_status = "update tbl_taxi_booking_status set is_activate=0, action_date='".$action_date."' where tbid='".$tbid."'";
$status = mysql_query($update_status, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid = '$tbid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['booking'][]=$result_res;
$sql_status = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbid = '$tbid'", $this->db);
if(mysql_num_rows($sql_status)>0)
{
$result_status = mysql_fetch_array($sql_status,MYSQL_ASSOC);
$res['booking_status'][]=$result_status;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get all past booking destinations By Passenger
* Get all past booking destinations By Passenger must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallpastbookingbypassenger/
*/
private function getallpastbookingbypassenger(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$timenow=date("Y-m-d H:i:s");
$ss = "SELECT tbid, cid, booking_to, booking_to_lat, booking_to_lng FROM tbl_taxi_booking WHERE cid='".$cid."'";
$sql_res_booking = mysql_query("SELECT tbid, cid, booking_to, booking_to_lat, booking_to_lng FROM tbl_taxi_booking WHERE cid='".$cid."'", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$res[]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
################################ BOOKING STATUS API END ###################################
################################ INVITE FRIEND API Start ###################################
/*
* Simple Reg Invite Friend API
* Reg INVITE FRIEND must be POST method
* cid : <Customer ID>
* femailid : <Friend Email ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerinvitefriend/
*/
private function registerinvitefriend(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$femailid = $this->_request['femailid'];
if($femailid=="")
{
array_push($arr,"Please Enter Friend Email ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_invite_friends (cid, femailid, action_date, is_activate, is_deleted) values ('".$cid."', '".$femailid."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_invite_friends WHERE ifid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ INVITE FRIEND API END ###################################
################################ Customer Credit API Start ###################################
/*
* Simple Reg Customer Credit API
* Reg Customer Credit must be POST method
* cid : <Customer ID>
* credit : <Customer Credit>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registercustomercredit/
*/
private function registercustomercredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$credit = $this->_request['credit'];
if($credit=="")
{
array_push($arr,"Please Enter Customer Credit.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_credit_master (cid, credit, action_date, is_activate, is_deleted) values ('".$cid."', '".$credit."', '".$action_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_credit_master WHERE crid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Customer Credit API
* Get Customer Credit must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getcustomercredit/
*/
private function getcustomercredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$sql_res = mysql_query("SELECT * FROM tbl_credit_master WHERE cid = '$cid' and is_activate=1 and is_deleted=0", $this->db);
$res=array();
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit Customer Credit API
* Edit Customer Credit must be POST method
* crid : <Customer Credit ID>
* cid : <Customer ID>
* credit : <Customer Credit>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editcustomercredit/
*/
private function editcustomercredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$crid = $this->_request['crid'];
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$credit = $this->_request['credit'];
if($credit=="")
{
array_push($arr,"Please Enter Customer Credit.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_credit_master set cid='".$cid."',credit='".$credit."' where crid='".$crid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_credit_master WHERE crid = '$crid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Customer Credit API END ###################################
################################ SURPLUS API Start ###################################
/*
* Simple Get Surplus API
* Get Surplus must be POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getsurplus/
*/
private function getsurplus(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_surplus_master WHERE is_activate=1 and is_deleted=0", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
################################ SURPLUS API END ###################################
################################ Booking Payment API Start ###################################
/*
* Simple Reg Booking Payment API
* Reg Booking Payment must be POST method
* tbid : <Taxi Booking ID>
* did : <Driver ID>
* cid : <Customer ID>
* oid : <Offer ID>
* spid : <Sur Plus ID>
* pcid : <Promo Code ID>
* crid : <Credit ID>
* paymode : <Payment Mode>
* total_km : <Total KM>
* total_min : <Total Min>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerbookingpayment/
*/
private function registerbookingpayment(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$action_date=date("Y-m-d H:i:s");
$action_dt=date("Y-m-d");
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID.");
}
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$oid = (int)$this->_request['oid'];
$spid = (int)$this->_request['spid'];
$pcid = (int)$this->_request['pcid'];
$crid = (int)$this->_request['crid'];
$paymode = $this->_request['paymode'];
if($paymode=="")
{
array_push($arr,"Please Enter Payment Mode.");
}
$total_km = $this->_request['total_km'];
if($total_km=="")
{
array_push($arr,"Please Enter Total KM.");
}
$total_km =(float) $this->_request['total_km'];
$total_min = $this->_request['total_min'];
if($total_min=="")
{
array_push($arr,"Please Enter Total Min.");
}
$total_min = (float)$this->_request['total_min'];
$driver_query=mysql_query("SELECT price_per_km, price_per_min, min_price FROM tbl_vehicle_master WHERE did = '$did'", $this->db);
$result_driver = mysql_fetch_array($driver_query,MYSQL_ASSOC);
$price_per_km=(float)$result_driver['price_per_km'];
$price_per_min=(float)$result_driver['price_per_min'];
$min_price=(float)$result_driver['min_price'];
$total_fare = ($total_km*$price_per_km)+($total_min*$price_per_min)+$min_price;
$total_fare = number_format($total_fare, 2, '.', '');
if($oid!='' || $oid>0)
{
$query_offer=mysql_query("SELECT offer FROM tbl_offer_master WHERE oid = '$oid' and validfrom <= '$action_dt' and validto >= '$action_dt'", $this->db);
if(mysql_num_rows($query_offer)>0)
{
$result_offer = mysql_fetch_array($query_offer,MYSQL_ASSOC);
$offer_discount_rate=(float)$result_offer['offer'];
$offer_discount=$total_fare*$offer_discount_rate/100;
}
else
{
array_push($arr,"Please Enter Valid Offer ID.");
}
}
if($spid!='' || $spid>0)
{
$query_sur=mysql_query("SELECT surplusper,surplusfix FROM tbl_surplus_master WHERE spid = '$spid'", $this->db);
if(mysql_num_rows($query_sur)>0)
{
$result_sur= mysql_fetch_array($query_sur,MYSQL_ASSOC);
$surplusper=(float)$result_sur['surplusper'];
$surplusfix=(float)$result_sur['surplusfix'];
if($surplusfix=='' || $surplusfix=='0.00')
{
$surplus_added=$total_fare*$surplusper/100;
}
else
{
$surplus_added=$surplusfix;
}
}
else
{
array_push($arr,"Please Enter Valid Sur Plus ID.");
}
}
if($pcid!='' || $pcid>0)
{
$query_promo=mysql_query("SELECT discount FROM tbl_promocode WHERE pcid = '$pcid' and validfrom <= '$action_dt' and validto>= '$action_dt'", $this->db);
if(mysql_num_rows($query_promo)>0)
{
$result_promo = mysql_fetch_array($query_promo,MYSQL_ASSOC);
$promo_discount=(float)$result_promo['discount'];
}
else
{
array_push($arr,"Please Enter Valid Promo Code ID.==== SELECT discount FROM tbl_promocode WHERE pcid = '$pcid' and (validfrom >= '$action_dt' and validto<= '$action_dt')");
}
}
if($crid!='' || $crid>0)
{
$query_credit=mysql_query("SELECT credit FROM tbl_credit_master WHERE crid = '$crid'", $this->db);
if(mysql_num_rows($query_credit)>0)
{
$result_credit = mysql_fetch_array($query_credit,MYSQL_ASSOC);
$credit_discount=(float)$result_credit['credit'];
}
else
{
array_push($arr,"Please Enter Valid Credit ID.");
}
}
$final_total = $total_fare-$offer_discount-$promo_discount-$credit_discount+$surplus_added;
$final_total = number_format($final_total, 2, '.', '');
$query_goloyal=mysql_query("SELECT * FROM tbl_goloyal WHERE tbid = '$tbid' and is_activate=1", $this->db);
if(mysql_num_rows($query_goloyal)>0)
{
$paymode = "Go Loyal";
}
if(count($arr)==0)
{
$is_activate=1;
$is_deleted=0;
$pay_dt=date("Y-m-d H:i:s");
$insert_sql = "insert into tbl_taxi_booking_payment (tbid, did, cid, oid, spid, pcid, crid, paymode, total_km, total_min, total_fare, final_total, pay_dt, action_date, is_activate, is_deleted) values ('".$tbid."', '".$did."', '".$cid."', '".$oid."', '".$spid."', '".$pcid."', '".$crid."', '".$paymode."', '".$total_km."', '".$total_min."', '".$total_fare."', '".$final_total."', '".$pay_dt."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
// Invoice
$sql_res_db = mysql_query("SELECT total_km, total_min,final_total,did,cid FROM tbl_taxi_booking_payment WHERE tbid = '$tbid' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_db) > 0)
{
while($result_res_db = mysql_fetch_array($sql_res_db,MYSQL_ASSOC))
{
$sql_res_b = mysql_query("SELECT collected_date,droped_date FROM tbl_taxi_booking_status WHERE tbid = '$tbid' and status='Completed' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_b) > 0)
{
$total_km = $result_res_db["total_km"];
$total_min = $result_res_db["total_min"];
$final_total = $result_res_db["final_total"];
$result_res_b = mysql_fetch_array($sql_res_b,MYSQL_ASSOC);
$collected_date = stripslashes($result_res_b["collected_date"]);
$droped_date = stripslashes($result_res_b["droped_date"]);
$did = $result_res_db["did"];
$sql_res_d = mysql_query("SELECT fname,lname,emailid FROM tbl_driver_master WHERE did='".$did."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_d = mysql_fetch_array($sql_res_d,MYSQL_ASSOC);
$drivername = stripslashes($result_res_d["fname"]." ".$result_res_d["lname"]);
$driveremail = stripslashes($result_res_d["emailid"]);
$cid = $result_res_db["cid"];
$sql_res_c = mysql_query("SELECT fname,lname,phone_no,emailid FROM tbl_customer_master WHERE cid='".$cid."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_c = mysql_fetch_array($sql_res_c,MYSQL_ASSOC);
$pasgname = stripslashes($result_res_c["fname"]." ".$result_res_c["lname"]);
$pasgmobile = stripslashes($result_res_c["phone_no"]);
$pasgemail = stripslashes($result_res_c["emailid"]);
$sql_res_tb = mysql_query("SELECT booking_from_lat,booking_from_lng,booking_from,booking_to_lat,booking_to_lng,booking_to,booking_time FROM tbl_taxi_booking WHERE tbid='".$tbid."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_tb = mysql_fetch_array($sql_res_tb,MYSQL_ASSOC);
$booking_from_lat = stripslashes($result_res_tb["booking_from_lat"]);
$booking_from_lng = stripslashes($result_res_tb["booking_from_lng"]);
$booking_to_lat = stripslashes($result_res_tb["booking_to_lat"]);
$booking_to_lng = stripslashes($result_res_tb["booking_to_lng"]);
$booking_from = stripslashes($result_res_tb["booking_from"]);
$booking_to = stripslashes($result_res_tb["booking_to"]);
$booking_time = stripslashes($result_res_tb["booking_time"]);
$body1 = "<font face=verdana size=2>";
$body1 .= "<strong>Driver Name:</strong> ".$drivername."<br/>";
$body1 .= "<strong>Booking Date Time:</strong> ".$booking_time."<br/>";
$body1 .= "<strong>Passenger Name:</strong> ".$pasgname."<br/>";
$body1 .= "<strong>Passenger Mob:</strong> ".$pasgmobile."<br/>";
$body1 .= "<strong>Booking From:</strong> ".$booking_from."<br/>";
$body1 .= "<strong>Booking To:</strong> ".$booking_to."<br/>";
$body1 .= "<strong>Collected Time:</strong> ".$collected_date."<br/>";
$body1 .= "<strong>Dropped Time:</strong> ".$droped_date."<br/>";
$body1 .= "<strong>Total KM:</strong> ".$total_km."<br/>";
$body1 .= "<strong>Total Time in minutes:</strong> ".$total_min."<br/>";
$body1 .= "<strong>Total Fare:</strong> ".$final_total."<br/>";
$map = 'https://maps.googleapis.com/maps/api/staticmap?path=color:0xff0000ff%7Cweight:5%7C'.$booking_from_lat.','.$booking_from_lng.'%7C'.$booking_to_lat.','.$booking_to_lng.'&size=512x512';
$body1 .= "<strong>View Road Map of Travel:</strong> <a href=\"".$map."\">Click Here</a><br/>";
$body1 .= "</font>";
$emsubject = "Passenger Receipt from EZYGO.CO.NZ";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
//$driveremail = "corpsoftsol@gmail.com";
mail($driveremail, $emsubject, $body1, $headers);
mail($pasgemail, $emsubject, $body1, $headers);
//echo $driveremail;
//echo "SENT";
}
}
}
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_payment WHERE pid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]." ";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Booking Payment API END ###################################
################################ Driver Rating API Start ###################################
/*
* Simple Reg Driver Rating API
* Reg Driver Rating must be POST method
* did : <Driver ID>
* cid : <Customer ID>
* rating : <rating>
* rdt : <rating Date>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerdriverrating/
*/
private function registerdriverrating(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$rating = $this->_request['rating'];
if($rating=="")
{
array_push($arr,"Please Enter Rating.");
}
$rdt = $this->_request['rdt'];
if($rdt=="")
{
array_push($arr,"Please Enter Rating date.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_driver_rating (did, cid, rating, rdt, action_date, is_activate, is_deleted) values ('".$did."', '".$cid."', '".$rating."', '".$rdt."', '".$action_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_rating WHERE drid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Driver Rating by DID API
* Get Driver Rating by DID must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getdriverratingbydid/
*/
private function getdriverratingbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT tbl_driver_rating.*, CONCAT_WS(' ',tbl_customer_master.fname,tbl_customer_master.lname) as name FROM tbl_driver_rating,tbl_customer_master WHERE did = '$did' and tbl_driver_rating.cid=tbl_customer_master.cid and is_activate=1 and is_deleted=0", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Driver Rating API END ###################################
################################ Driver Feedback API Start ###################################
/*
* Simple Reg Driver Feedback API
* Reg Driver Feedback must be POST method
* did : <Driver ID>
* cid : <Customer ID>
* feedback : <Feedback>
* fdt : <Feedback Date>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerdriverfeedback/
*/
private function registerdriverfeedback(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$feedback = $this->_request['feedback'];
if($feedback=="")
{
array_push($arr,"Please Enter Feedback.");
}
$fdt = $this->_request['fdt'];
if($fdt=="")
{
array_push($arr,"Please Enter Feedback date.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_driver_feedback (did, cid, feedback, fdt, action_date, is_activate, is_deleted) values ('".$did."', '".$cid."', '".$feedback."', '".$fdt."', '".$action_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_feedback WHERE fid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Driver Feedback by DID API
* Get Driver Feedback by DID must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getdriverfeedbackbydid/
*/
private function getdriverfeedbackbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT tbl_driver_feedback.*, CONCAT_WS(' ',tbl_customer_master.fname,tbl_customer_master.lname) as name FROM tbl_driver_feedback,tbl_customer_master WHERE did = '$did' and tbl_driver_feedback.cid=tbl_customer_master.cid and is_activate=1 and is_deleted=0", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Driver Feedback API END ###################################
################################ PASSENGER API Start ###################################
/*
* Simple Passenger LOGIN API
* Passenger Login must be POST method
* username : <Passenger username>
* password : <Passenger password>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengerlogin/
*/
private function passengerlogin(){
// Cross validation if the request method is POST else it will return "Not Acceptable" status
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$username = $this->_request['username'];
$password = $this->_request['password'];
// Input validations
if(!empty($username) || !empty($password)){
$sql = mysql_query("SELECT * FROM tbl_customer_master WHERE username = '$username' AND password = '".$password."'", $this->db);
if(mysql_num_rows($sql) > 0){
$res=array();
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
$res[]=$result;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => "Invalid Username or Password1");
$this->api_response($this->json($error), 400);
}
}
$error = array("status" => "false", "msg" => "Invalid Username or Password2");
$this->api_response($this->json($error), 200);
}
/*
* Simple Passenger Forget Password API
* Passenger Forget Password must be POST method
* email : <USER Email>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengerforgetpassword/
*/
private function passengerforgetpassword(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$email = $this->_request['email'];
if(!empty($email) && checkEmail($email)){
$sql = mysql_query("SELECT * FROM tbl_customer_master WHERE emailid = '".$email."'", $this->db);
if(mysql_num_rows($sql) > 0){
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
$length =10;
$conso=array("b","c","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","x","y","z");
$vocal=array("5","8","7","9","6");
$password="";
srand ((double)microtime()*1000000);
$max = $length/2;
for($i=1; $i<=$max; $i++)
{
$password.=$conso[rand(0,19)];
$password.=$vocal[rand(0,4)];
}
$newpass = $password;
$body1 = "<font face=verdana size=2>";
$body1 .= "Your New Password<br><br>";
$body1 .= "EMAIL-ID: ".$email."<br>";
$body1 .= "PASSWORD: ".$newpass."<br>";
$body1 .= "</font>";
$emsubject = "Your New Password.";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($email, $emsubject, $body1, $headers))
{
$del_sql = mysql_query("update tbl_customer_master set password='".$newpass."' where emailid='".$email."'", $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE emailid = '$email' AND password = '".$newpass."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
}
else
{
$error = array("status" => "false", "msg" => "Message delivery failed...");
$this->api_response($this->json($error), 200);
}
$this->api_response($this->json($result), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => "Invalid Email");
$this->api_response($this->json($error), 200);
}
}
$error = array("status" => "false", "msg" => "Invalid Email");
$this->api_response($this->json($error), 200);
}
/*
* Simple Passenger Registeraton API
* Passenger Registeraton must be POST method
* fname : <Passenger First Name>
* lname : <Passenger Last Name>
* username : <Passenger Username>
* password : <Passenger Password>
* emailid : <Passenger Email>
* phone_no : <Passenger Contact Number>
* deviceid : <Passenger Device ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengerregisteration/
*/
private function passengerregisteration(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$fname = $this->_request['fname'];
if($fname=="")
{
array_push($arr,"Please Enter First Name.");
}
$lname = $this->_request['lname'];
if($lname=="")
{
array_push($arr,"Please Enter Last Name.");
}
$username = $this->_request['username'];
if($username=="")
{
array_push($arr,"Please Enter Username.");
}
$password = $this->_request['password'];
if($password=="")
{
array_push($arr,"Please Enter Password.");
}
$emailid = $this->_request['emailid'];
if($emailid=="")
{
array_push($arr,"Please Enter Email.");
}
else
{
if (!checkEmail($emailid))
{
array_push($arr,"Please Enter Valid Email.");
}
}
$phone_no = $this->_request['phone_no'];
if($phone_no=="")
{
array_push($arr,"Please Enter Contact Number.");
}
$deviceid = $this->_request['deviceid'];
if($deviceid=="")
{
array_push($arr,"Please Enter Device ID.");
}
if(count($arr)==0)
{
$squery = mysql_query("select * from tbl_customer_master where username='".$username."' or emailid='".$emailid."'", $this->db);
if(mysql_num_rows($squery) > 0){
$error = array("status" => "false", "msg" => 'This username or Email Already Exist.' );
$this->api_response($this->json($error), 200);
exit;
//array_push($arr, "This username/Email Already Exist.");
}
else
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_customer_master (fname, lname, username, password, emailid, phone_no, deviceid, action_date, is_activate, is_deleted) values ('".$fname."', '".$lname."', '".$username."', '".$password."', '".$emailid."', '".$phone_no."', '".$deviceid."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
//echo $insert_sql;
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
// Mail
$body1 = "<font face=verdana size=2>";
$body1 .= "Dear ".$fname.". Your account has been created for Passenger and your login details as<br><br>";
$body1 .= "EMAIL-ID: ".$emailid."<br>";
$body1 .= "PASSWORD: ".$password."<br>";
$body1 .= "</font>";
$emsubject = "Welcome to Ezygo.";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($emailid, $emsubject, $body1, $headers);
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 200);
exit;
}
}
/*
* Simple Passenger Edit Registeraton API
* Passenger Registeraton must be POST method
* cid : <Passenger ID>
* fname : <Passenger First Name>
* lname : <Passenger Last Name>
* password : <Passenger Password>
* emailid : <Passenger Email>
* phone_no : <Passenger Contact Number>
* deviceid : <Passenger Device ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengereditprofile/
*/
private function passengereditprofile(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
$fname = $this->_request['fname'];
if($fname=="")
{
array_push($arr,"Please Enter First Name.");
}
$lname = $this->_request['lname'];
if($lname=="")
{
array_push($arr,"Please Enter Last Name.");
}
$password = $this->_request['password'];
if($password=="")
{
array_push($arr,"Please Enter Password.");
}
$emailid = $this->_request['emailid'];
if($emailid=="")
{
array_push($arr,"Please Enter Email.");
}
else
{
if (!checkEmail($emailid))
{
array_push($arr,"Please Enter Valid Email.");
}
}
$phone_no = $this->_request['phone_no'];
if($phone_no=="")
{
array_push($arr,"Please Enter Contact Number.");
}
if(count($arr)==0)
{
$squery = mysql_query("select * from tbl_customer_master where emailid='".$emailid."' and cid!='".$cid."'" , $this->db);
if(mysql_num_rows($squery) > 0){
$error = array("status" => "false", "msg" => 'This Email Already Exist.' );
$this->api_response($this->json($error), 400);
exit;
}
else
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$update_sql = "update tbl_customer_master set fname='".$fname."', lname='".$lname."', emailid='".$emailid."', password='".$password."', phone_no='".$phone_no."', deviceid='".$deviceid."' where cid='".$cid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Passenger Edit Payment Method API
* Passenger Edit Payment Method must be POST method
* cid : <Passenger ID>
* payment_method : <Passenger Payment method>
* cashstatus : <Passenger Cash Status>
* credit_card_no : <Passenger Credit Card No>
* exp_date : <Passenger Credit Card Expiary Date>
* cvv : <Passenger Credit Card CVV>
* paypal : <Passenger Paypal email>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengerpaymentmethod/
*/
private function passengerpaymentmethod(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$strr="";
$cid = $this->_request['cid'];
$payment_method = $this->_request['payment_method'];
if($payment_method!=''){$strr.="payment_method='".$payment_method."', ";}
$cashstatus = $this->_request['cashstatus'];
if($cashstatus!=''){$strr.="cashstatus='".$cashstatus."', ";}
$credit_card_no = $this->_request['credit_card_no'];
if($credit_card_no!=''){$strr.="credit_card_no='".$credit_card_no."', ";}
$exp_date = $this->_request['exp_date'];
if($exp_date!=''){$strr.="exp_date='".$exp_date."', ";}
$cvv = $this->_request['cvv'];
if($cvv!=''){$strr.="cvv='".$cvv."', ";}
$paypal = $this->_request['paypal'];
if($paypal!=''){$strr.="paypal='".$paypal."', ";}
$strr=substr($strr,0,-2);
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$update_sql = "update tbl_customer_master set ".$strr." where cid='".$cid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Customer Add Address API
* Customer Add Address must be POST method
* cid : <Customer ID>
* add_cat : <Customer Home/Office>
* street : <Customer Street>
* city : <Customer City>
* state : <Customer State>
* postcode : <Customer Post Code>
* API URL : http://dev9.edreamz3.com/taxiapp/api/customeraddress/
*/
private function customeraddress(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$add_cat = $this->_request['add_cat'];
if($add_cat=="")
{
array_push($arr,"Please Enter Customer Home/Office.");
}
$street = $this->_request['street'];
if($street=="")
{
//array_push($arr,"Please Enter Street.");
}
$city = $this->_request['city'];
if($city=="")
{
//array_push($arr,"Please Enter City.");
}
$state = $this->_request['state'];
if($state=="")
{
//array_push($arr,"Please Enter State.");
}
$postcode = $this->_request['postcode'];
if($postcode=="")
{
//array_push($arr,"Please Enter Post Code.");
}
$address = $this->_request['address'];
/*$address = "";
if ($street!="") {$address = $address.$street;}
if ($city!="") {$address = $address.",".$city;}
if ($state!="") {$address = $address.",".$state;}
if ($postcode!="") {$address = $address.",".$postcode;}*/
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_customer_address_master (cid, add_cat, street, city, state, postcode, action_date, is_activate, is_deleted,address) values ('".$cid."', '".$add_cat."', '".$street."', '".$city."', '".$state."', '".$postcode."', '".$action_date."', '".$is_activate."', '".$is_deleted."','".$address."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
//$sql_res = mysql_query("SELECT caid, cid, add_cat, CONCAT_WS(',',street,city,state,postcode) as address FROM tbl_customer_address_master WHERE caid = '$insert_id'", $this->db);
$res=array();
$sql_res = mysql_query("SELECT caid, cid, add_cat, address FROM tbl_customer_address_master WHERE caid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Customer Edit Address API
* Customer Edit Address must be POST method
* caid : <Customer Address ID>
* cid : <Customer ID>
* cid : <Customer ID>
* add_cat : <Customer Home/Office>
* street : <Customer Street>
* city : <Customer City>
* state : <Customer State>
* postcode : <Customer Post Code>
* API URL : http://dev9.edreamz3.com/taxiapp/api/customereditaddress/
*/
private function customereditaddress(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$caid = $this->_request['caid'];
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$add_cat = $this->_request['add_cat'];
if($add_cat=="")
{
array_push($arr,"Please Enter Customer Home/Office.");
}
$street = $this->_request['street'];
if($street=="")
{
//array_push($arr,"Please Enter Street.");
}
$city = $this->_request['city'];
if($city=="")
{
//array_push($arr,"Please Enter City.");
}
$state = $this->_request['state'];
if($state=="")
{
//array_push($arr,"Please Enter State.");
}
$postcode = $this->_request['postcode'];
if($postcode=="")
{
//array_push($arr,"Please Enter Post Code.");
}
$address = $this->_request['address'];
/*$address = "";
if ($street!="") {$address = $address.$street;}
if ($city!="") {$address = $address.",".$city;}
if ($state!="") {$address = $address.",".$state;}
if ($postcode!="") {$address = $address.",".$postcode;} */
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_customer_address_master set cid='".$cid."', add_cat='".$add_cat."', street='".$street."', city='".$city."', state='".$state."', postcode='".$postcode."', action_date='".$action_date."', address='".$address."' where caid='".$caid."'";
$sql = mysql_query($update_sql, $this->db);
//$sql_res = mysql_query("SELECT caid, cid, add_cat, CONCAT_WS(',',street,city,state,postcode) as address FROM tbl_customer_address_master WHERE caid = '".$caid."'", $this->db);
$res=array();
$sql_res = mysql_query("SELECT caid, cid, add_cat, address FROM tbl_customer_address_master WHERE caid = '".$caid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple get API for Home/Office Address info From cid
* get API for Home/Office Address info From cid must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getaddressbycid/
*/
private function getaddressbycid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer Id.");
}
if(count($arr)==0)
{
$data=array();
//$sql_res = mysql_query("SELECT caid, add_cat, CONCAT_WS(',',street,city,state,postcode) as address FROM tbl_customer_address_master WHERE cid = '".$cid."'", $this->db);
$sql_res = mysql_query("SELECT caid, add_cat, address FROM tbl_customer_address_master WHERE cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple get the selected payment method From cid
* get the selected payment method From cid must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getpaymentmethodbycid/
*/
private function getpaymentmethodbycid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer Id.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT cid, payment_method, cashstatus, credit_card_no, exp_date, cvv, paypal FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ PASSENGER API End ###################################
/*
* Simple Get Fair Estimate API
* Get Fair Estimate must be POST method
* did : <Driver ID>
* distance : <Tarvel Distance>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getfairestimate/
*/
private function getfairestimate(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$did =(int) $this->_request['did'];
$from = urlencode($this->_request['from']);
$to = urlencode($this->_request['to']);
//$from = file_get_contents($from);
//$to = file_get_contents($to);
//$distance = (float)$this->_request['distance'];
$url = 'https://maps.googleapis.com/maps/api/distancematrix/json?origins='.$from.'&destinations='.$to.'&departure_time=now&traffic_model=best_guess&key=AIzaSyBj2Y63SxN6m0XXbFLyLTbRfDgCC_orFh0';
$data = json_decode(file_get_contents($url), true);
$dist1 = $data["rows"][0]["elements"][0]["distance"]["text"];
$dur1 = $data["rows"][0]["elements"][0]["duration"]["text"];
$durtraf1 = $data["rows"][0]["elements"][0]["duration_in_traffic"]["text"];
$dist = current(explode(' ', $dist1));
$dur = current(explode(' ', $dur1));
$durtraf = current(explode(' ', $durtraf1));
$sql = mysql_query("SELECT vid, did, price_per_km, price_per_min, min_price FROM tbl_vehicle_master WHERE did = '$did'", $this->db);
if(mysql_num_rows($sql) > 0){
$res1=array();
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
$min_price=(float)$result['min_price'];
$price_per_km=(float)$result['price_per_km'];
$total_dist=(float)$price_per_km*$dist; //6.6*1.95
$price_per_min=(float)$result['price_per_min'];
$total_min=(float)$price_per_min*$dur;//22*0.35
$total_traffic_min=(float)$price_per_min*$durtraf;//22*0.35
//$result['distance']=$distance;
//$result['total_fair']=number_format($total_fair,2);
$total_fair=$total_dist+$total_min+$min_price;
$total_traffic_fair=$total_dist+$total_traffic_min+$min_price;
$res1['price_per_km']=$price_per_km;
$res1['total_fair']=number_format($total_fair,2);
$res1['total_traffic_fair']=number_format($total_traffic_fair,2);
$res[]=$res1;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
}
else
{
$error = array("status" => "false", "msg" => "Invalid Driver Id");
$this->api_response($this->json($error), 400);
}
}
################################ BOOKING API Start ###################################
/*
* Simple Add Booking API
* Add Booking must be POST method
* cid : <Customer ID>
* vtid : <Vehicle Type ID>
* booking_type : <Booking Type Current/Advance>
* booking_from_lat : <Booking From Address Lat>
* booking_from_lng : <Booking From Address Lng>
* booking_from : <Booking From Address>
* booking_to_lat : <Booking To Address Lat>
* booking_to_lng : <Booking To Address Lng>
* booking_to : <Booking To Address>
* noofpass : <Number Of Passenger>
* booking_time : <Booking Time>
* notes : <Booking Notes>
* API URL : http://dev9.edreamz3.com/taxiapp/api/addbooking/
*/
private function addbooking(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle Type ID");
}
$booking_type = $this->_request['booking_type'];
if($booking_type=="")
{
array_push($arr,"Please Enter Booking Type Current/Advance.");
}
$booking_from_lat = $this->_request['booking_from_lat'];
if($booking_from_lat=="")
{
array_push($arr,"Please Enter Booking From Address Lat.");
}
$booking_from_lng = $this->_request['booking_from_lng'];
if($booking_from_lng=="")
{
array_push($arr,"Please Enter Booking From Address Lng.");
}
$booking_from = $this->_request['booking_from'];
if($booking_from=="")
{
array_push($arr,"Please Enter Booking From Address.");
}
$booking_to = $this->_request['booking_to'];
if($booking_to=="")
{
//array_push($arr,"Please Enter Booking To Address.");
}
$booking_to_lat = $this->_request['booking_to_lat'];
$booking_to_lng = $this->_request['booking_to_lng'];
if($booking_from_lat!='' && $booking_from_lng!='' && $booking_to_lat!='' && $booking_to_lng!='')
{
$distance=0;
$theta = $booking_from_lng - $booking_to_lng;
$dist = sin(deg2rad($booking_from_lat)) * sin(deg2rad($booking_to_lat)) + cos(deg2rad($booking_from_lat)) * cos(deg2rad($booking_to_lat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$distance = $miles * 1.609344; // KM
}
else{
$distance="";
}
//Vijay
/*$pushmsg = "";
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Passenger Name: ".$result_res["fname"]." ".$result_res["lname"]." From: ".$booking_from." To: ".$booking_to;
}
}
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$dlat = $result_res["lat"];
$dlng = $result_res["lng"];
$theta = $booking_from_lng - $dlng;
$dist = sin(deg2rad($booking_from_lat)) * sin(deg2rad($dlat)) + cos(deg2rad($booking_from_lat)) * cos(deg2rad($dlat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
$km = round($km,0);
if ($km<=5)
{
$APPLICATION_ID = "fo0mnigXyvaOPvn2KCls3e5u2IZoFunpaohFizzC";
$REST_API_KEY = "q6ty6gEz5XmAJTefUD3bX1ArqKaGhIoVHBTxWg9Z";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'did' => $result_res["did"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
curl_close($curl);
}
}
}*/
$noofpass = $this->_request['noofpass'];
if($noofpass=="")
{
//array_push($arr,"Please Enter Number Of Passenger.");
}
$booking_time = $this->_request['booking_time'];
date_default_timezone_set('NZ');
$booking_time=date("Y-m-d H:i:s");
/*$user_tz = 'NZ';
$schedule_date = new DateTime($booking_time, new DateTimeZone($user_tz) );
$schedule_date->setTimeZone(new DateTimeZone('UTC'));
$booking_time = $schedule_date->format('Y-m-d H:i:s');*/
$notes = $this->_request['notes'];
$fixedfare = $this->_request['fixedfare'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_taxi_booking (cid, vtid, booking_type, booking_from_lat, booking_from_lng, booking_from, booking_to_lat, booking_to_lng, booking_to, distance, noofpass, booking_time, notes,fixedfare, action_date, is_activate, is_deleted) values ('".$cid."', '".$vtid."', '".$booking_type."', '".$booking_from_lat."', '".$booking_from_lng."', '".$booking_from."', '".$booking_to_lat."', '".$booking_to_lng."', '".$booking_to."', '".$distance."', '".$noofpass."', '".$booking_time."', '".$notes."', '".$fixedfare."' ,'".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
//$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid = '$insert_id'", $this->db);
$sql_res = mysql_query("SELECT tb. * , (SELECT COUNT( * ) FROM tbl_taxi_booking_payment WHERE cid='$cid') AS cnt FROM tbl_taxi_booking tb WHERE tbid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
// Credit
$crflag="false";
$res1=array();
$action_dt=date("Y-m-d");
$sql_res1 = mysql_query("SELECT oid, offer_reason, offer, validfrom, validto FROM `tbl_offer_master` WHERE is_activate =1 AND is_deleted =0 and validfrom <= '$action_dt' and validto >= '$action_dt'", $this->db);
if(mysql_num_rows($sql_res1) > 0)
{
$result_res1 = mysql_fetch_array($sql_res1,MYSQL_ASSOC);
$res1[]=$result_res1;
$crflag="true";
}
$success = array("status" => "true", "items" => $res,"creditstatus" => $crflag, "credititems" => $res1);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/addbookingpush/
private function addbookingpush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$booking_from_lat = $this->_request['booking_from_lat'];
if($booking_from_lat=="")
{
array_push($arr,"Please Enter Booking From Address Lat.");
}
$booking_from_lng = $this->_request['booking_from_lng'];
if($booking_from_lng=="")
{
array_push($arr,"Please Enter Booking From Address Lng.");
}
$booking_from = $this->_request['booking_from'];
$booking_to = $this->_request['booking_to'];
$pushmsg = "";
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Passenger Name: ".$result_res["fname"]." ".$result_res["lname"]." From: ".$booking_from." To: ".$booking_to." Contact Number: ".$phone_no;
}
}
//$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
$sql_res = mysql_query("SELECT *, ( 6371 * ACOS( COS( RADIANS( '".$booking_from_lat."' ) ) * COS( RADIANS( Lat ) ) * COS( RADIANS( Lng ) - RADIANS( '".$booking_from_lng."' ) ) + SIN( RADIANS( '".$booking_from_lat."' ) ) * SIN( RADIANS( Lat ) ) )) AS distance FROM tbl_driver_master HAVING distance <5 ORDER BY distance", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$did = $result_res["did"];
/*$dlat = $result_res["lat"];
$dlng = $result_res["lng"];
$theta = $booking_from_lng - $dlng;
$dist = sin(deg2rad($booking_from_lat)) * sin(deg2rad($dlat)) + cos(deg2rad($booking_from_lat)) * cos(deg2rad($dlat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
$km = round($km,0);
if ($km<=5)
{*/
$APPLICATION_ID = "mALjhLoXULLHOoXR1n6K4pDOhZzKicjfyXMplpzK";
$REST_API_KEY = "sU9RWrGuumdHGHIKOvAosCBk1GRRWXywLoO4EQTV";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'did' => $did,
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"New Booking"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_exec($curl);
//}
}
}
}
/*
* Simple Edit Booking API
* Edit Booking must be POST method
* tbid : <Booking ID>
* cid : <Customer ID>
* vtid : <Vehicle Type ID>
* booking_type : <Booking Type Current/Advance>
* booking_from_lat : <Booking From Address Lat>
* booking_from_lng : <Booking From Address Lng>
* booking_from : <Booking From Address>
* booking_to_lat : <Booking To Address Lat>
* booking_to_lng : <Booking To Address Lng>
* booking_to : <Booking To Address>
* noofpass : <Number Of Passenger>
* booking_time : <Booking Time>
* notes : <Booking Notes>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editbooking/
*/
private function editbooking(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle Type ID");
}
$booking_type = $this->_request['booking_type'];
if($booking_type=="")
{
array_push($arr,"Please Enter Booking Type Current/Advance.");
}
$booking_from_lat = $this->_request['booking_from_lat'];
if($booking_from_lat=="")
{
array_push($arr,"Please Enter Booking From Address Lat.");
}
$booking_from_lng = $this->_request['booking_from_lng'];
if($booking_from_lng=="")
{
array_push($arr,"Please Enter Booking From Address Lng.");
}
$booking_from = $this->_request['booking_from'];
if($booking_from=="")
{
array_push($arr,"Please Enter Booking From Address.");
}
$booking_to = $this->_request['booking_to'];
if($booking_to=="")
{
//array_push($arr,"Please Enter Booking To Address.");
}
$booking_to_lat = $this->_request['booking_to_lat'];
$booking_to_lng = $this->_request['booking_to_lng'];
if($booking_from_lat!='' && $booking_from_lng!='' && $booking_to_lat!='' && $booking_to_lng!='')
{
$distance=0;
$theta = $booking_from_lng - $booking_to_lng;
$dist = sin(deg2rad($booking_from_lat)) * sin(deg2rad($booking_to_lat)) + cos(deg2rad($booking_from_lat)) * cos(deg2rad($booking_to_lat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$distance = $miles * 1.609344;
}
else{
$distance="";
}
$noofpass = $this->_request['noofpass'];
if($noofpass=="")
{
//array_push($arr,"Please Enter Number Of Passenger.");
}
$booking_time = $this->_request['booking_time'];
if($booking_time=="")
{
array_push($arr,"Please Enter Booking Time.");
}
$notes = $this->_request['notes'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking set cid='".$cid."', vtid='".$vtid."', booking_type='".$booking_type."', booking_from_lat='".$booking_from_lat."', booking_from_lng='".$booking_from_lng."', booking_from='".$booking_from."', booking_to_lat='".$booking_to_lat."', booking_to_lng='".$booking_to_lng."', booking_to='".$booking_to."', distance='".$distance."', noofpass='".$noofpass."', booking_time='".$booking_time."', notes='".$notes."', action_date='".$action_date."' where tbid='".$tbid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid = '".$tbid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ BOOKING API End ###################################
/*
* Simple Get vtid API
* Get vtid must be POST method
* vtype : <Vehicle Type>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getvtidbyvtype/
*/
private function getvtidbyvtype(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$vtype = $this->_request['vtype'];
if($vtype=="")
{
array_push($arr,"Please Enter Vehicle Type.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_vehicle_type_master WHERE vtype = '".$vtype."' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get nearby drivers API
* Get Get nearby drivers POST method
* lat : <Latitude>
* lng : <Longitude>
* vtid : <Vehicle Type Id>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallnearbydrivers/
*/
private function getallnearbydrivers(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$lat = $this->_request['lat'];
$lng = $this->_request['lng'];
$vtid = $this->_request['vtid'];
if($lat=="")
{
array_push($arr,"Please Enter Latitude.");
}
if($lng=="")
{
array_push($arr,"Please Enter Longitude.");
}
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle Type Id.");
}
if(count($arr)==0)
{
$data=array();
//$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
$sql_res = mysql_query("SELECT tbl_driver_master.* FROM tbl_driver_master, tbl_vehicle_master WHERE tbl_driver_master.is_activate=1 and tbl_driver_master.is_deleted=0 and tbl_driver_master.did=tbl_vehicle_master.did and tbl_vehicle_master.vtid='".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$found=0;
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$dlat = $result_res["lat"];
$dlng = $result_res["lng"];
$theta = $lng - $dlng;
$dist = sin(deg2rad($lat)) * sin(deg2rad($dlat)) + cos(deg2rad($lat)) * cos(deg2rad($dlat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
$km = round($km,0);
//echo $km."<br/>";
if ($km<=5)
{
$found=$found+1;
$res[]=$result_res;
}
}
if ($found>0)
{
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Records Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else
{
$error = array("status" => "false", "msg" => 'No Records Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
$msg="";
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple get nearest driver API
* get nearest driver POST method
* lat : <Latitude>
* lng : <Longitude>
* vtid : <Vehicle Type Id>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getnearestdriver/
*/
private function getnearestdriver(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$lat = $this->_request['lat'];
$lng = $this->_request['lng'];
$vtid = $this->_request['vtid'];
if($lat=="")
{
array_push($arr,"Please Enter Latitude.");
}
if($lng=="")
{
array_push($arr,"Please Enter Longitude.");
}
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle Type Id.");
}
if(count($arr)==0)
{
$data=array();
//$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
$sql_res = mysql_query("SELECT tbl_driver_master.* FROM tbl_driver_master, tbl_vehicle_master WHERE tbl_driver_master.is_activate=1 and tbl_driver_master.is_deleted=0 and tbl_driver_master.did=tbl_vehicle_master.did and tbl_vehicle_master.vtid='".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$nkm=99999;
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$dlat = $result_res["lat"];
$dlng = $result_res["lng"];
$theta = $lng - $dlng;
$dist = sin(deg2rad($lat)) * sin(deg2rad($dlat)) + cos(deg2rad($lat)) * cos(deg2rad($dlat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
//$km = round($km,0);
//echo $km."<br/>";
//if ($km<=1)
// Vijay Code Start
$speed=40;
$time=$km/40*60;
$rkm = round($km,1);
$rtime = round($time,0);
$result_res["time"]=$rtime." min";
$result_res["distance"]=$rkm." km";
// Vijay Code End
if ($km<$nkm)
{
$nkm=$km;
$resvvvv=$result_res;
}
}
if ($nkm!=99999)
{
$success = array("status" => "true", "items" => $resvvvv);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Records Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else
{
$error = array("status" => "false", "msg" => 'No Records Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
$msg="";
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple get time and distance according to the passenger's current location API
* get time and distance according to the passenger's current location POST method
* passenger_lat : <Passenger Latitude>
* passenger_lng : <Passenger Longitude>
* driver_lat : <Driver Latitude>
* driver_lng : <Driver Longitude>
* API URL : http://dev9.edreamz3.com/taxiapp/api/gettimedistance/
*/
private function gettimedistance(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$passenger_lat = $this->_request['passenger_lat'];
$passenger_lng = $this->_request['passenger_lng'];
$driver_lat = $this->_request['driver_lat'];
$driver_lng = $this->_request['driver_lng'];
if($passenger_lat=="")
{
array_push($arr,"Please Enter Passenger Latitude.");
}
if($passenger_lng=="")
{
array_push($arr,"Please Enter Passenger Longitude.");
}
if($driver_lat=="")
{
array_push($arr,"Please Enter Driver Latitude.");
}
if($driver_lng=="")
{
array_push($arr,"Please Enter Driver Longitude.");
}
if(count($arr)==0)
{
$res=array();
$theta = $passenger_lng - $driver_lng;
$dist = sin(deg2rad($passenger_lat)) * sin(deg2rad($driver_lat)) + cos(deg2rad($passenger_lat)) * cos(deg2rad($driver_lat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
//$km = round($km,0);
$speed=40;
$time=$km/40*60;
$rkm = round($km,1);
$rtime = round($time,0);
$res["time"]=$rtime." min";
$res["distance"]=$rkm." km";
$success = array("status" => "true", "items" => $res );
$this->api_response($this->json($success), 200);
exit;
}
else{
$msg="";
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get vtid API
* Get vtid must be POST method
* cid : <customer id>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getpassfav/
*/
private function getpassfav(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer Id.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tb.* FROM tbl_taxi_booking tb inner join tbl_taxi_booking_status bs on tb.tbid = bs.tbid WHERE bs.status='Completed' and tb.cid = '".$cid."'", $this->db);
//$sql_res = mysql_query("SELECT * from tbl_customer_master where cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get vtid API
* Get vtid must be POST method
* cid : <customer id>
* API URL : http://dev7.edreamz2.com/taxiapp/api/estfare/
*/
private function estfare(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
$min = $this->_request['min'];
$km = $this->_request['km'];
if($did=="")
{
array_push($arr,"Please Enter Driver Id.");
}
if($min=="")
{
array_push($arr,"Please Enter Min.");
}
if($km=="")
{
array_push($arr,"Please Enter KM.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT price_per_min,price_per_km,min_price FROM `tbl_vehicle_master` WHERE did = '".$did."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res = "";
//$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
//$res[] = ($result_res["price_per_min"] * $min) + ($result_res["price_per_km"] * $km);
$res = (($result_res["price_per_min"] * $min) + ($result_res["price_per_km"] * $km))+$result_res["min_price"];
//$res[]=$result_res;
}
$success = array("status" => "true", "items" => "".$res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
private function getallcust(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM `tbl_customer_master` WHERE is_activate='1' and is_deleted='0'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
######################################## EMERGENCY NO #################################
/*
* Simple Get All Emergency No API
* Get All Emergency No POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallemergencyno/
*/
private function getallemergencyno(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_emergency WHERE is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
######################################## EMERGENCY NO END #################################
######################################## Favorite Destination #################################
/*
* Simple Add Favorite Destination API
* Add Favorite Destination POST method
* tbid : <Taxi Booking ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/addfavoritedestination/
*/
private function addfavoritedestination(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
if($tbid=="" || $tbid==0)
{
array_push($arr,"Please Enter Booking ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$fvdt=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_favorite_destination (tbid, fvdt, action_date, is_activate, is_deleted) values ('".$tbid."', '".$fvdt."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_favorite_destination WHERE fdid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Favorite Destination By cid API
* Get Get Favorite Destination By cid POST method
* cid : <Taxi Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getfavoritedestinationbycid/
*/
private function getfavoritedestinationbycid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tb.tbid,tb.booking_to,tb.booking_to_lat,tb.booking_to_lng FROM tbl_favorite_destination fd inner join tbl_taxi_booking tb on tb.tbid = fd.tbid and tb.cid ='$cid'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get All Destination By cid API
* Get Get All Destination By cid POST method
* cid : <Taxi Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getalldestinationbycid/
*/
private function getalldestinationbycid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tbid,booking_to,booking_to_lat,booking_to_lng FROM tbl_taxi_booking where tbid not in (SELECT tbid from tbl_favorite_destination) and cid ='$cid'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
######################################## Favorite Destination END #################################
######################################## Go Loyal #################################
/*
* Simple Add Go Loyal API
* Add Go Loyal POST method
* tbid : <Taxi Booking ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/addgoloyal/
*/
private function addgoloyal(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
if($tbid=="" || $tbid==0)
{
array_push($arr,"Please Enter Booking ID.");
}
$sql_cid = mysql_query("SELECT cid FROM tbl_taxi_booking WHERE tbid='$tbid' and cid in (select cid from tbl_taxi_booking_payment) ", $this->db);
if(mysql_num_rows($sql_cid) < 0)
{
array_push($arr,"Passenger should not completed his first trip.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$gldt=date("Y-m-d H:i:s");
$is_activate=0;
$is_deleted=0;
$insert_sql = "insert into tbl_goloyal (tbid, gldt, action_date, is_activate, is_deleted) values ('".$tbid."', '".$gldt."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_goloyal WHERE glid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
######################################## Go Loyal END #################################
/*
* Simple Add Go Loyal API
* Add Go getfixedfarecharges method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getfixedfarecharges/
*/
private function getfixedfarecharges(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$data=array();
$sql_res = mysql_query("SELECT fixedfare FROM tbl_fixedfarecharge WHERE is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get booking payment count API
* cid : <customer id>
* API URL : http://dev7.edreamz2.com/taxiapp/api/getbookingpaymentcnt/
*/
private function getbookingpaymentcnt(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer Id.");
}
if(count($arr)==0)
{
$data=array();
$action_dt=date("Y-m-d");
$sql_res = mysql_query("SELECT offer, (SELECT COUNT( * ) FROM `tbl_taxi_booking_payment` WHERE cid = '$cid' ) AS cnt FROM `tbl_offer_master` WHERE is_activate =1 AND is_deleted =0 and validfrom <= '$action_dt' and validto >= '$action_dt'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallvtype/
*/
private function getallvtype(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_vehicle_type_master where is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// Cancel Booking By Driver
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/cancelbookingbydid/
private function cancelbookingbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter tbsid.");
}
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter did");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking_status set status='Canceled', droped_date='".$action_date."' where tbsid = '".$tbsid."' and did = '".$did."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '".$tbsid."' and did = '".$did."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// Cancel Booking By Driver Push
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/cancelbookingbydidpush/
private function cancelbookingbydidpush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter tbsid.");
}
if(count($arr)==0)
{
$res=array();
$pushmsg = "";
$cid="";
$sql_res = mysql_query("SELECT tb.cid,dm.fname, dm.lname, dm.phone_no, dm.driver_noplate, tb.booking_from, tb.booking_to FROM `tbl_driver_master` dm INNER JOIN `tbl_vehicle_master` vm ON vm.did = dm.did INNER JOIN `tbl_taxi_booking_status` bs ON bs.did = dm.did INNER JOIN `tbl_taxi_booking` tb ON tb.tbid = bs.tbid WHERE bs.status = 'Canceled' AND bs.tbsid = '".$tbsid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Booking Cancelled By Driver Name: ".$result_res["fname"]." ".$result_res["lname"]." Phone No: ".$result_res["phone_no"]." Taxi Number Plate: ".$result_res["driver_noplate"]." Booking From: ".$result_res["booking_from"]." Booking To: ".$result_res["booking_to"];
$cid = $result_res["cid"];
}
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $cid,
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Booking Cancelled"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($curl))
$success = array("status" => "true", "msg" => "Push Send");
else
$success = array("status" => "false", "msg" => "Push Fail");
$this->api_response($this->json($success), 200);
exit;
}
else
{
$msg = "Push Not Send";
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// All Current Booking of Driver
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/currentbookingdrivers/
private function currentbookingdrivers(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter cid");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT dm.fname, dm.lname, dm.phone_no, dm.driver_noplate, vm.made, vm.modelno FROM `tbl_driver_master` dm INNER JOIN `tbl_vehicle_master` vm ON vm.did = dm.did INNER JOIN `tbl_taxi_booking_status` bs ON bs.did = dm.did INNER JOIN `tbl_taxi_booking` tb ON tb.tbid = bs.tbid WHERE bs.status = 'Accepted' AND tb.cid='".$cid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// All Current Booking of Passenger
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/currentbookingpassengers/
private function currentbookingpassengers(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter did");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT cm.fname, cm.lname, cm.phone_no, tb.booking_from, tb.booking_to FROM `tbl_customer_master` cm INNER JOIN `tbl_taxi_booking` tb ON cm.cid = tb.cid INNER JOIN `tbl_taxi_booking_status` bs ON bs.tbid = tb.tbid WHERE bs.did ='".$did."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// Terms & Condition
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/termscond/
private function termscond(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT term FROM tbl_term WHERE is_activate =1 AND is_deleted =0", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// All Current Booking of Passenger
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/goloyalcredit/
private function goloyalcredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Cid");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT tb.booking_from, tb.booking_to, tb.booking_time, tbp.total_km, tbp.total_min, tbp.total_fare, tbp.final_total FROM tbl_taxi_booking tb INNER JOIN tbl_taxi_booking_payment tbp ON tb.tbid = tbp.tbid INNER JOIN tbl_customer_master cm ON cm.cid = tb.cid WHERE cm.cid = '".$cid."' AND tbp.paymode = 'Go Loyal'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/getcredit/
private function getcredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$res=array();
$action_dt=date("Y-m-d");
$sql_res = mysql_query("SELECT oid, offer_reason, offer, validfrom, validto FROM `tbl_offer_master` WHERE is_activate =1 AND is_deleted =0 and validfrom <= '$action_dt' and validto >= '$action_dt'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Payment Receipt to Customer/Driver API
* Send Payment Receipt on Payment Completion to Driver/Customer
* tbid : <Booking ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/paymentreceiptdrivercustomer/
*/
private function paymentreceiptdrivercustomer(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res_db = mysql_query("SELECT total_km, total_min,final_total,did,cid FROM tbl_taxi_booking_payment WHERE tbid='".$tbid."' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_db) > 0)
{
while($result_res_db = mysql_fetch_array($sql_res_db,MYSQL_ASSOC))
{
$sql_res_b = mysql_query("SELECT collected_date,droped_date FROM tbl_taxi_booking_status WHERE tbid='".$tbid."' and status='Completed' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_b) > 0)
{
$total_km = $result_res_db["total_km"];
$total_min = $result_res_db["total_min"];
$final_total = $result_res_db["final_total"];
$result_res_b = mysql_fetch_array($sql_res_b,MYSQL_ASSOC);
$collected_date = stripslashes($result_res_b["collected_date"]);
$droped_date = stripslashes($result_res_b["droped_date"]);
$did = $result_res_db["did"];
$sql_res_d = mysql_query("SELECT fname,lname,emailid FROM tbl_driver_master WHERE did='".$did."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_d = mysql_fetch_array($sql_res_d,MYSQL_ASSOC);
$drivername = stripslashes($result_res_d["fname"]." ".$result_res_d["lname"]);
$driveremail = stripslashes($result_res_d["emailid"]);
$cid = $result_res_db["cid"];
$sql_res_c = mysql_query("SELECT fname,lname,phone_no,emailid FROM tbl_customer_master WHERE cid='".$cid."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_c = mysql_fetch_array($sql_res_c,MYSQL_ASSOC);
$pasgname = stripslashes($result_res_c["fname"]." ".$result_res_c["lname"]);
$pasgmobile = stripslashes($result_res_c["phone_no"]);
$pasgemail = stripslashes($result_res_c["emailid"]);
$sql_res_tb = mysql_query("SELECT booking_from_lat,booking_from_lng,booking_from,booking_to_lat,booking_to_lng,booking_to,booking_time FROM tbl_taxi_booking WHERE tbid='".$tbid."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_tb = mysql_fetch_array($sql_res_tb,MYSQL_ASSOC);
$booking_from_lat = stripslashes($result_res_tb["booking_from_lat"]);
$booking_from_lng = stripslashes($result_res_tb["booking_from_lng"]);
$booking_to_lat = stripslashes($result_res_tb["booking_to_lat"]);
$booking_to_lng = stripslashes($result_res_tb["booking_to_lng"]);
$booking_from = stripslashes($result_res_tb["booking_from"]);
$booking_to = stripslashes($result_res_tb["booking_to"]);
$booking_time = stripslashes($result_res_tb["booking_time"]);
$body1 = "<font face=verdana size=2>";
$body1 .= "<strong>Driver Name:</strong> ".$drivername."<br/>";
$body1 .= "<strong>Booking Date Time:</strong> ".$booking_time."<br/>";
$body1 .= "<strong>Passenger Name:</strong> ".$pasgname."<br/>";
$body1 .= "<strong>Passenger Mob:</strong> ".$pasgmobile."<br/>";
$body1 .= "<strong>Booking From:</strong> ".$booking_from."<br/>";
$body1 .= "<strong>Booking To:</strong> ".$booking_to."<br/>";
$body1 .= "<strong>Collected Time:</strong> ".$collected_date."<br/>";
$body1 .= "<strong>Dropped Time:</strong> ".$droped_date."<br/>";
$body1 .= "<strong>Total KM:</strong> ".$total_km."<br/>";
$body1 .= "<strong>Total Time in minutes:</strong> ".$total_min."<br/>";
$body1 .= "<strong>Total Fare:</strong> ".$final_total."<br/>";
$map = 'https://maps.googleapis.com/maps/api/staticmap?path=color:0xff0000ff%7Cweight:5%7C'.$booking_from_lat.','.$booking_from_lng.'%7C'.$booking_to_lat.','.$booking_to_lng.'&size=512x512';
$body1 .= "<strong>View Road Map of Travel:</strong> <a href=\"".$map."\">Click Here</a><br/>";
$body1 .= "</font>";
$emsubject = "Passenger Receipt from EZYGO.CO.NZ";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
//$driveremail = "corpsoftsol@gmail.com";
mail($driveremail, $emsubject, $body1, $headers);
mail($pasgemail, $emsubject, $body1, $headers);
//echo $driveremail;
//echo "SENT";
}
}
}
}
}
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/paymentconfirm/
private function paymentconfirm(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$pid = $this->_request['pid'];
if($pid=="")
{
array_push($arr,"Please Enter pid.");
}
if(count($arr)==0)
{
$res=array();
$pushmsg = "";
$cid="";
$sql_res = mysql_query("SELECT cid,paymode,total_km,total_min,total_fare from `tbl_taxi_booking_payment` where pid = '".$pid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Payment Done Successfully. Payment Mode: ".$result_res["paymode"].", Total KM: ".$result_res["total_km"].", Total Min: ".$result_res["total_min"].", Total Fare: ".$result_res["total_fare"];
$cid = $result_res["cid"];
}
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $cid,
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Payment Done"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($curl))
$success = array("status" => "true", "msg" => "Push Send");
else
$success = array("status" => "false", "msg" => "Push Fail");
$this->api_response($this->json($success), 200);
exit;
}
else
{
$msg = "Push Not Send";
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Encode array into JSON
*/
private function json($data){
if(is_array($data)){
return json_encode($data);
}
}
}
$api = new API;
$api->processApi();
?>
//WP Search in API
define ('DB_USER', 'root');
define ('DB_PASSWORD', '');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'cabcouk_db1');
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME);
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
$terms = $_REQUEST[ 's' ];
$exploded = explode( ' ', $terms );
if( $exploded === FALSE || count( $exploded ) == 0 )
$exploded = array( 0 => $terms );
$where = '';
foreach( $exploded as $tag ) :
$where .= "
AND (
(wp_posts.post_title LIKE '%$tag%')
OR (wp_posts.post_content LIKE '%$tag%')
OR EXISTS (
SELECT * FROM wp_postmeta
WHERE post_id = wp_posts.ID
AND (";
$where .= " (meta_value RLIKE '[[:<:]]".$tag."[[:>:]]' AND meta_key IN('map_location','post-code')) ";
$where .= ")
)
OR EXISTS (
SELECT * FROM wp_terms
INNER JOIN wp_term_taxonomy
ON wp_term_taxonomy.term_id = wp_terms.term_id
INNER JOIN wp_term_relationships
ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
WHERE (
taxonomy = 'post_tag'
OR taxonomy = 'category'
)
AND object_id = wp_posts.ID
AND wp_terms.name LIKE '%$tag%'
)
)";
endforeach;
$rs= "select id,post_title from wp_posts WHERE 1 $where AND post_type='post' ORDER BY id DESC";
$result = mysqli_query($con,$rs);
$data = mysqli_num_rows($result);
$responses = array();
if($data != 0) {
while($results = mysqli_fetch_assoc($result))
{
$id = $results['id'];
$post_title = $results['post_title'];
$rs1= "select * from wp_postmeta WHERE post_id=$id";
$result1 = mysqli_query($con,$rs1);
$data1 = mysqli_num_rows($result1);
if($data1 != 0) {
while($results1 = mysqli_fetch_assoc($result1))
{
if($results1['meta_key']=="phone-no"){
$phone_no=$results1['meta_value'];
}
if($results1['meta_key']=="post-code"){
$post_code=$results1['meta_value'];
}
if($results1['meta_key']=="images"){
$image=$results1['meta_value'];
}
}
}
$temp = explode(",",$image);
$responses[] = array(
'id' => $id,
'title' => $post_title,
'phone_no' => $phone_no,
'post_code' => $post_code,
'image' => $temp[0] ,
);
}
$phone_no="";
$post_code="";
$image="";
$success = array(
'status' => 1,
'Response' => $responses,
);
echo json_encode($success);
}
//echo $rs;
/*
echo "<hr>";
$query= "SELECT * FROM wp_posts INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.meta_id WHERE 1 $where AND post_type='post'";
echo $query;
*/
?>
**************************************
<?php
/* File : Taxi.Rest.inc.php
* Author : CSS
*/
class TAXIREST {
public $_allow = array();
public $_content_type = "application/json";
public $_request = array();
private $_method = "";
private $_code = 200;
public function __construct(){
$this->apiinputs();
}
public function get_api_referer(){
return $_SERVER['HTTP_REFERER'];
}
public function api_response($data,$status){
$this->_code = ($status)?$status:200;
$this->set_api_headers();
echo $data;
exit;
}
private function get_api_status_message(){
$status = array(
100 => 'Continue',
101 => 'Switching Protocols',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
306 => '(Unused)',
307 => 'Temporary Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported');
return ($status[$this->_code])?$status[$this->_code]:$status[500];
}
public function get_api_request_method(){
return $_SERVER['REQUEST_METHOD'];
}
private function apiinputs(){
switch($this->get_api_request_method()){
case "POST":
$this->_request = $this->cleanApiInputs($_POST);
break;
case "GET":
case "DELETE":
$this->_request = $this->cleanApiInputs($_GET);
break;
case "PUT":
parse_str(file_get_contents("php://input"),$this->_request);
$this->_request = $this->cleanApiInputs($this->_request);
break;
default:
$this->api_response('',406);
break;
}
}
private function cleanApiInputs($data){
$clean_input = array();
if(is_array($data)){
foreach($data as $k => $v){
$clean_input[$k] = $this->cleanApiInputs($v);
}
}else{
if(get_magic_quotes_gpc()){
$data = trim(stripslashes($data));
}
$data = strip_tags($data);
$clean_input = trim($data);
}
return $clean_input;
}
private function set_api_headers(){
//echo "AAA".$this->get_api_status_message();
header("HTTP/1.1 ".$this->_code." ".$this->get_api_status_message());
header("Content-Type:".$this->_content_type);
}
}
?>
***********************
<?php
ob_start();
//error_reporting(-1);
// Same as error_reporting(E_ALL);
//ini_set('error_reporting', E_ALL);
/*
$a = fopen("driv.txt","w");
foreach($_REQUEST as $k=>$v)
{
if(is_array($v))
{
foreach($v as $kk=>$vv)
{
if(is_array($vv))
{
foreach($vv as $kkk=>$vvv)
{
fwrite($a,$k."===".$kk."===".$kkk."==".$vvv."\n");
}
}
else
{
fwrite($a,$k."===".$kk."==".$vv."\n");
}
}
}
else
{
fwrite($a,$k."==".$v."\n");
}
}
fclose($a);
*/
require_once("Taxi.Rest.inc.php");
function checkEmail($email)
{
$result = TRUE;
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email))
{
$result = FALSE;
}
return $result;
}
class API extends TAXIREST {
public $data = "";
const DB_SERVER = "localhost";
const DB_USER = "uetsa";
const DB_PASSWORD = "lkjerw@qw";
const DB = "tax_poi";
/* const DB_SERVER = "localhost";
const DB_USER = "opuye";
const DB_PASSWORD = "jhg*2qwvfg";
const DB = "tasi_app";*/
private $db = NULL;
public function __construct(){
parent::__construct(); // Init parent contructor
$this->dbConnect(); // Initiate Database connection
}
/*
* Database connection
*/
private function dbConnect(){
$this->db = mysql_connect(self::DB_SERVER,self::DB_USER,self::DB_PASSWORD);
if($this->db)
mysql_select_db(self::DB,$this->db);
}
/*
* Public method for access api.
* This method dynmically call the method based on the query string
*
*/
public function processApi(){
$func = strtolower(trim(str_replace("/","",$_REQUEST['rquest'])));
if((int)method_exists($this,$func) > 0)
{
$this->$func();
}
else
{
$this->api_response('',404);
}
}
/*
* Simple Driver Registeraton API
* Driver Registeraton must be POST method
* fname : <Driver First Name>
* lname : <Driver Last Name>
* username : <Driver Username>
* password : <Driver Password>
* emailid : <Driver Email ID>
* phone_no : <Driver Phone No>
* driver_noplate : <Driver No Plate>
* lat : <Driver Lat>
* lng : <Driver Lng>
* lic_no : <Driver LicNo>
* lic_exp_date : <Driver Lic Exp Date>
* tc : <Terms & Condition>
* payoption : <Payment Option>
* cofexpiry : <cofexpiry>
* regoexpiry : <regoexpiry>
* licencecardexpiry : <licencecardexpiry>
* vtid : <vtid>
* veh_no : <veh_no>
* made : <made>
* taxifleetname : <taxifleetname>
* taxifleetnumber : <taxifleetnumber>
* API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/driverregisteration/
*/
private function driverregisteration(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$fname = $this->_request['fname'];
if($fname=="")
{
array_push($arr,"Please Enter First Name.");
}
$lname = $this->_request['lname'];
if($lname=="")
{
array_push($arr,"Please Enter Last Name.");
}
$username = $this->_request['username'];
if($username=="")
{
array_push($arr,"Please Enter Username.");
}
$password = $this->_request['password'];
if($password=="")
{
array_push($arr,"Please Enter Password.");
}
$emailid = $this->_request['emailid'];
if($emailid=="")
{
array_push($arr,"Please Enter Email ID.");
}
$phone_no = $this->_request['phone_no'];
if($phone_no=="")
{
array_push($arr,"Please Enter Phone NO.");
}
$driver_noplate = $this->_request['driver_noplate'];
if($driver_noplate=="")
{
array_push($arr,"Please Enter driver no plate.");
}
$lat = $this->_request['lat'];
if($lat=="")
{
array_push($arr,"Please Enter Lat.");
}
$lng = $this->_request['lng'];
if($lng=="")
{
array_push($arr,"Please Enter Lng.");
}
$lic_no = $this->_request['lic_no'];
$lic_exp_date = $this->_request['lic_exp_date'];
$tc = $this->_request['tc'];
if($tc!="1")
{
array_push($arr,"Please Select Terms & Condition");
}
$payoption = $this->_request['payoption'];
if($payoption=="")
{
array_push($arr,"Please Enter Payment Option.");
}
$cofexpiry = $this->_request['cofexpiry'];
$regoexpiry = $this->_request['regoexpiry'];
$licencecardexpiry = $this->_request['licencecardexpiry'];
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle TaxiType.");
}
$veh_no = $this->_request['veh_no'];
if($veh_no=="")
{
array_push($arr,"Please Enter Vehical Number.");
}
$modelno= $this->_request['modelno'];
if($modelno=="")
{
array_push($arr,"Please Enter Model Number.");
}
$made = $this->_request['made'];
if($made=="")
{
array_push($arr,"Please Enter Made.");
}
$taxifleetname = $this->_request['taxifleetname'];
if($taxifleetname=="")
{
array_push($arr,"Please Enter taxi fleet name.");
}
$taxifleetnumber = $this->_request['taxifleetnumber'];
if($taxifleetnumber=="")
{
array_push($arr,"Please Enter taxi fleet number.");
}
if(count($arr)==0)
{
$squery = mysql_query("select * from tbl_driver_master where username='".$username."'", $this->db);
if(mysql_num_rows($squery) > 0){
$error = array("status" => "false", "msg" => 'This username Already Exist.' );
$this->api_response($this->json($error), 400);
exit;
}
else
{
$action_date=date("Y-m-d H:i:s");
$is_activate=0;
$is_deleted=0;
$insert_sql = "insert into tbl_driver_master (fname, lname, username, password, emailid, phone_no, driver_noplate, lat, lng, lic_no, lic_exp_date, action_date, is_activate, is_deleted, tc, payoption,cofexpiry,regoexpiry,licencecardexpiry) values ('".$fname."', '".$lname."', '".$username."', '".$password."', '".$emailid."', '".$phone_no."', '".$driver_noplate."', '".$lat."', '".$lng."', '".$lic_no."', '".$lic_exp_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."','".$tc."','".$payoption."','".$cofexpiry."','".$regoexpiry."','".$licencecardexpiry."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
/*******Eddited bY punam******/
if($insert_id > 0)
{
$is_activate=1;
$sql_res = mysql_query("SELECT price_per_min,price_per_km,min_price FROM `tbl_vehicle_type_master` WHERE vtid = '".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$price_per_km = $result_res["price_per_km"];
$price_per_min = $result_res["price_per_min"];
$min_price = $result_res["min_price"];
}
}
$insert_vehicle_sql = "insert into tbl_vehicle_master (did, veh_no, vtid, price_per_km,price_per_min, min_price, action_date, is_activate, is_deleted,modelno,made,taxifleetname,taxifleetnumber) values ('".$insert_id."', '".$veh_no."', '".$vtid."', '".$price_per_km."', '".$price_per_min."', '".$min_price."', '".$action_date."', '".$is_activate."', '".$is_deleted."', '".$modelno."', '".$made."', '".$taxifleetname."', '".$taxifleetnumber."')";
$vehicae_sql = mysql_query($insert_vehicle_sql, $this->db);
}
/***************/
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE did = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$body1 = "<font face=verdana size=2>";
$body1 .= "Dear ".$fname.". Your account has been created for Driver and your login details as<br><br>";
$body1 .= "User Name: ".$username."<br>";
$body1 .= "Password: ".$password."<br><br><br>your request has been processed/accepted, to become Ezygo partner please bring the following original documents to Ezygo office for the app activation";
$body1 .= "</font>";
$emsubject = "Welcome to Ezygo.";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($emailid, $emsubject, $body1, $headers);
$params=array();
$params['FNAME']=$fname;
$params['LNAME']=$lname;
storeAddress_driver($emailid,$params);
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Driver By DID API
* Get Driver By DID POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getdriverbydid/
*/
private function getdriverbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE did = '".$did."' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get All Drivers API
* Get All Drivers POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getalldriver/
*/
private function getalldriver(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Delete Driver By DID API
* Get All Drivers POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/deletedriverbydid/
*/
private function deletedriverbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_driver_master set is_deleted='1', action_date='".$action_date."' where did='".$did."'";
$sql = mysql_query($update_sql, $this->db);
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE did='".$did."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit Driver By DID API
* Edit Driver By DID must be POST method
* did : <Driver ID>
* fname : <Driver First Name>
* lname : <Driver Last Name>
* username : <Driver Username>
* password : <Driver Password>
* emailid : <Driver Email ID>
* phone_no : <Driver Phone No>
* driver_noplate : <Driver No Plate>
* deviceid : <Driver DeviceId>
* lat : <Driver Lat>
* lng : <Driver Lng>
* lic_no : <Driver LicNo>
* lic_exp_date : <Driver Lic Exp Date>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editdriverbydid/
*/
private function editdriverbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
$fname = $this->_request['fname'];
if($fname=="")
{
array_push($arr,"Please Enter First Name.");
}
$lname = $this->_request['lname'];
if($lname=="")
{
array_push($arr,"Please Enter Last Name.");
}
$username = $this->_request['username'];
if($username=="")
{
array_push($arr,"Please Enter Username.");
}
$password = $this->_request['password'];
if($password=="")
{
array_push($arr,"Please Enter Password.");
}
$emailid = $this->_request['emailid'];
if($emailid=="")
{
array_push($arr,"Please Enter Email ID.");
}
$phone_no = $this->_request['phone_no'];
if($phone_no=="")
{
array_push($arr,"Please Enter Phone NO.");
}
$driver_noplate = $this->_request['driver_noplate'];
if($driver_noplate=="")
{
array_push($arr,"Please Enter Driver No Plate.");
}
$deviceid = $this->_request['deviceid'];
if($deviceid=="")
{
array_push($arr,"Please Enter DeviceId.");
}
$lat = $this->_request['lat'];
if($lat=="")
{
array_push($arr,"Please Enter Lat.");
}
$lng = $this->_request['lng'];
if($lng=="")
{
array_push($arr,"Please Enter Lng.");
}
$lic_no = $this->_request['lic_no'];
$lic_exp_date = $this->_request['lic_exp_date'];
$payoption = $this->_request['payoption'];
if($payoption=="")
{
array_push($arr,"Please Enter Payment Option.");
}
if(count($arr)==0)
{
/*$squery = mysql_query("select * from tbl_driver_master where username='".$username."' and did='".$did."'", $this->db);
if(mysql_num_rows($squery) > 0){
$error = array("status" => "false", "msg" => 'This username Already Exist.' );
$this->api_response($this->json($error), 400);
exit;
}
else
{*/
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_driver_master set fname='".$fname."', lname='".$lname."', username='".$username."', password='".$password."', emailid='".$emailid."', phone_no='".$phone_no."', driver_noplate='".$driver_noplate."', deviceid='".$deviceid."', lat='".$lat."', lng='".$lng."', lic_no='".$lic_no."', lic_exp_date='".$lic_exp_date."', action_date='".$action_date."',payoption='".$payoption."' where did='".$did."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
//$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE did = '$did'", $this->db);
$sql_res = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE dm.did = '$did'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
//}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit Lat LNG By DID API
* Edit LAT LNG By DID POST method
* did : <Driver ID>
* lat : <Driver LAT>
* lng : <Driver LNG>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editlatlngbydid/
*/
private function editlatlngbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$lat = $this->_request['lat'];
if($lat=="")
{
array_push($arr,"Please Enter Driver LAT.");
}
$lng = $this->_request['lng'];
if($lng=="")
{
array_push($arr,"Please Enter Driver LNG.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_driver_master set lat='".$lat."', lng='".$lng."', action_date='".$action_date."' where did='".$did."'";
$sql = mysql_query($update_sql, $this->db);
$data=array();
$sql_res = mysql_query("SELECT did,lat,lng FROM tbl_driver_master WHERE did='".$did."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit LAT LNG By DeviceId API
* Edit Lat LNG By DeviceId POST method
* deviceid : <Driver DeviceId>
* lat : <Driver LAT>
* lng : <Driver LNG>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editlatlngbydeviceid/
*/
private function editlatlngbydeviceid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$deviceid = $this->_request['deviceid'];
if($deviceid=="")
{
array_push($arr,"Please Enter Driver DeviceId.");
}
$lat = $this->_request['lat'];
if($lat=="")
{
array_push($arr,"Please Enter Driver LAT.");
}
$lng = $this->_request['lng'];
if($lng=="")
{
array_push($arr,"Please Enter Driver LNG.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_driver_master set lat='".$lat."', lng='".$lng."', action_date='".$action_date."' where deviceid='".$deviceid."'";
$sql = mysql_query($update_sql, $this->db);
$data=array();
$sql_res = mysql_query("SELECT deviceid,lat,lng FROM tbl_driver_master WHERE deviceid='".$deviceid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Driver LOGIN API
* Driver Login must be POST method
* username : <Driver username>
* password : <Driver password>
* API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/driverlogin/
*/
private function driverlogin(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$username = $this->_request['username'];
$password = $this->_request['password'];
// Input validations
if(!empty($username) || !empty($password)){
$sql = mysql_query("SELECT * FROM tbl_driver_master WHERE username = '$username' AND password = '".$password."'", $this->db);
//$sql = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE username = '$username' AND password = '".$password."'", $this->db);
if(mysql_num_rows($sql) > 0){
$res=array();
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
if($result["is_activate"]==1)
{
/*$sql1 = mysql_query("SELECT * FROM tbl_driver_master WHERE did = '".$result["did"]."'", $this->db);
$result1 = mysql_fetch_array($sql1,MYSQL_ASSOC);
$res[]=$result1;
$sql2 = mysql_query("SELECT * FROM tbl_vehicle_master WHERE did = '".$result["did"]."'", $this->db);
$result2 = mysql_fetch_array($sql2,MYSQL_ASSOC);
$res[]=$result2;*/
$sql_res_veh = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE dm.did = '".$result["did"]."'", $this->db);
$result2 = mysql_fetch_array($sql_res_veh,MYSQL_ASSOC);
$res[]=$result2;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$success = array("status" => "false", "items" => "Driver is Inactive, Please contact to Administrator");
$this->api_response($this->json($success), 200);
}
}
else
{
$error = array("status" => "false", "msg" => "Invalid Username or Password");
$this->api_response($this->json($error), 400);
}
}
$error = array("status" => "false", "msg" => "Invalid Username or Password");
$this->api_response($this->json($error), 400);
}
/*
* Simple Driver Forget Password API
* Driver Forget Password must be POST method
* username : <Driver username>
* API URL : http://dev9.edreamz3.com/taxiapp/api/driverforgetpassword/
*/
private function driverforgetpassword(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$email = $this->_request['email'];
if(!empty($email) && checkEmail($email)){
$sql = mysql_query("SELECT * FROM tbl_driver_master WHERE emailid = '".$email."'", $this->db);
if(mysql_num_rows($sql) > 0){
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
$length =10;
$conso=array("b","c","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","x","y","z");
$vocal=array("5","8","7","9","6");
$password="";
srand ((double)microtime()*1000000);
$max = $length/2;
for($i=1; $i<=$max; $i++)
{
$password.=$conso[rand(0,19)];
$password.=$vocal[rand(0,4)];
}
$newpass = $password;
$body1 = "<font face=verdana size=2>";
$body1 .= "Your New Password<br><br>";
$body1 .= "EMAIL-ID: ".$email."<br>";
$body1 .= "PASSWORD: ".$newpass."<br>";
$body1 .= "</font>";
$emsubject = "Your New Password.";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($email, $emsubject, $body1, $headers))
{
$del_sql = mysql_query("update tbl_driver_master set password='".$newpass."' where emailid='".$email."'", $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE emailid = '$email' AND password = '".$newpass."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
}
else
{
$error = array("status" => "false", "msg" => "Message delivery failed...");
$this->api_response($this->json($error), 400);
}
$this->api_response($this->json($result), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => "Invalid Email");
$this->api_response($this->json($error), 400);
}
}
$error = array("status" => "false", "msg" => "Invalid Email");
$this->api_response($this->json($error), 400);
}
/*
* Simple Get all details of customer as current or advance booking
* Get all details of customer as current or advance booking must be POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallcustomerbooking/
*/
private function getallcustomerbooking(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
if(count($arr)==0)
{
$ss="SELECT * FROM tbl_taxi_booking WHERE booking_time > '".$timenow."' and is_activate = 1 and is_deleted=0 ";
$sql_res_booking = mysql_query("SELECT * FROM tbl_taxi_booking WHERE booking_time > '".$timenow."' and is_activate = 1 and is_deleted=0 ", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Droped Booking Status API
* Droped Booking Status must be POST method
* did : <Driver ID>
* driving_date : <Driving Date>
* API URL : http://dev9.edreamz3.com/taxiapp/api/dailydriverworkinghrs/
*/
private function dailydriverworkinghrs(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$driving_date = $this->_request['driving_date'];
if($driving_date=="")
{
array_push($arr,"Please Enter Driving Date.");
}
else{
$driving_date=date('Y-m-d', strtotime($driving_date));
}
if(count($arr)==0)
{
$res=array();
$workinghrs=0;
$sql_res = mysql_query("SELECT tbid FROM tbl_taxi_booking_status WHERE did = '$did' and collected_date like '$driving_date%'", $this->db);
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$sql_booking= mysql_query("SELECT traveling_time FROM tbl_taxi_booking WHERE tbid = '".$result_res['tbid']."'", $this->db);
$result_boking = mysql_fetch_array($sql_booking,MYSQL_ASSOC);
$workinghrs=$workinghrs+$result_boking['traveling_time'];
}
$workinghrs1=floor($workinghrs/60);
$workinghrs2=$workinghrs-($workinghrs1*60);
$res[]['workinghrs']=$workinghrs1.":".$workinghrs2;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ DRIVER API END ###################################
################################ Vehicle API Start ###################################
/*
* Simple Vehicle Registeraton API
* Vehicle Registeraton must be POST method
* vtid : <Vehicle TaxiType>
* did : <Driver ID>
* price_per_km : <Driver PricePerKm>
* price_per_min : <Driver PricePerMin>
* min_price : <Driver MinFare>
* veh_no : <Vehicle Number>
* color : <Vehicle Color>
* photo : <Vehicle Photo>
* API URL : http://dev9.edreamz3.com/taxiapp/api/vehicalregisteration/
*/
private function vehicalregisteration(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle TaxiType.");
}
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
/*$price_per_km = $this->_request['price_per_km'];
if($price_per_km=="")
{
array_push($arr,"Please Enter Driver Price Per Km.");
}
$price_per_min = $this->_request['price_per_min'];
if($price_per_min=="")
{
array_push($arr,"Please Enter Driver Price Per Min.");
}
$min_price = $this->_request['min_price'];
if($min_price=="")
{
array_push($arr,"Please Enter Driver Min Price.");
}*/
$veh_no = $this->_request['veh_no'];
$color = $this->_request['color'];
$photo = $this->_request['photo'];
$modelno = $this->_request['modelno'];
if($modelno=="")
{
array_push($arr,"Please Enter Model Number.");
}
$made = $this->_request['made'];
if($made=="")
{
array_push($arr,"Please Enter Made.");
}
$taxifleetname = $this->_request['taxifleetname'];
if($taxifleetname=="")
{
array_push($arr,"Please Enter Taxi Fleet Name.");
}
$taxifleetnumber = $this->_request['taxifleetnumber'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$sql_res = mysql_query("SELECT price_per_min,price_per_km,min_price FROM `tbl_vehicle_type_master` WHERE vtid = '".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$price_per_km = $result_res["price_per_km"];
$price_per_min = $result_res["price_per_min"];
$min_price = $result_res["min_price"];
}
}
$insert_vehicle_sql = "insert into tbl_vehicle_master (did, veh_no, vtid, price_per_km, price_per_min, min_price, action_date, is_activate, is_deleted,modelno,made,taxifleetname,taxifleetnumber) values ('".$did."', '".$veh_no."', '".$vtid."', '".$price_per_km."', '".$price_per_min."', '".$min_price."', '".$action_date."', '".$is_activate."', '".$is_deleted."', '".$modelno."', '".$made."', '".$taxifleetname."', '".$taxifleetnumber."')";
//$insert_vehicle_sql = "insert into tbl_vehicle_master (did, veh_no, vtid, action_date, is_activate, is_deleted,modelno,made,taxifleetname,taxifleetnumber) values ('".$did."', '".$veh_no."', '".$vtid."', '".$action_date."', '".$is_activate."', '".$is_deleted."', '".$modelno."', '".$made."', '".$taxifleetname."', '".$taxifleetnumber."')";
$vehicae_sql = mysql_query($insert_vehicle_sql, $this->db);
$vid=mysql_insert_id();
$res=array();
$sql_res_veh = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE vid = '$vid'", $this->db);
$result_res_veh = mysql_fetch_array($sql_res_veh,MYSQL_ASSOC);
$res[]=$result_res_veh;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get All Vehicle By DID API
* Get Driver By DID POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallvehicalbydid/
*/
private function getallvehicalbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tbl_vehicle_master.*, CONCAT_WS(' ',tbl_driver_master.fname,tbl_driver_master.lname) as name FROM tbl_driver_master,tbl_vehicle_master WHERE tbl_driver_master.did = '".$did."' and tbl_driver_master.did =tbl_vehicle_master.did ", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get All Vehicle By VTID API
* Get Driver By VTID POST method
* vtid : <Vehicle TypeID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallvehicalbyvtid/
*/
private function getallvehicalbyvtid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle TypeID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tbl_vehicle_master*, CONCAT_WS(' ',tbl_driver_master.fname,tbl_driver_master.lname) as name FROM tbl_driver_master,tbl_vehicle_master WHERE tbl_driver_master.vtid = '".$vtid."' and tbl_driver_master.did =tbl_vehicle_master.did ", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit Vehicle By VID API
* Edit Vehicle By VID must be POST method
* vid : <Vehicle ID>
* vtid : <Vehicle TaxiType>
* did : <Driver ID>
* price_per_km : <Driver PricePerKm>
* price_per_min : <Driver PricePerMin>
* min_price : <Driver MinFare>
* veh_no : <Vehicle Number>
* color : <Vehicle Color>
* photo : <Vehicle Photo>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editvehiclebyvid/
*/
private function editvehiclebyvid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$vid = $this->_request['vid'];
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle TaxiType.");
}
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
/*$price_per_km = $this->_request['price_per_km'];
if($price_per_km=="")
{
array_push($arr,"Please Enter Driver Price Per Km.");
}
$price_per_min = $this->_request['price_per_min'];
if($price_per_min=="")
{
array_push($arr,"Please Enter Driver Price Per Min.");
}
$min_price = $this->_request['min_price'];
if($min_price=="")
{
array_push($arr,"Please Enter Driver Min Price.");
}*/
$veh_no = $this->_request['veh_no'];
$color = $this->_request['color'];
$photo = $this->_request['photo'];
$modelno = $this->_request['modelno'];
if($modelno=="")
{
array_push($arr,"Please Enter Model Number.");
}
$made = $this->_request['made'];
if($made=="")
{
array_push($arr,"Please Enter Made.");
}
$taxifleetname = $this->_request['taxifleetname'];
if($taxifleetname=="")
{
array_push($arr,"Please Enter Taxi Fleet Name.");
}
$taxifleetnumber = $this->_request['taxifleetnumber'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$sql_res = mysql_query("SELECT price_per_min,price_per_km,min_price FROM `tbl_vehicle_type_master` WHERE vtid = '".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$price_per_km = $result_res["price_per_km"];
$price_per_min = $result_res["price_per_min"];
$min_price = $result_res["min_price"];
}
}
$update_sql = "update tbl_vehicle_master set did='".$did."', veh_no='".$veh_no."', vtid='".$vtid."', price_per_km='".$price_per_km."', price_per_min='".$price_per_min."', min_price='".$min_price."', action_date='".$action_date."',modelno='".$modelno."',made='".$made."',taxifleetname='".$taxifleetname."',taxifleetnumber='".$taxifleetnumber."' where vid='".$vid."'";
//$update_sql = "update tbl_vehicle_master set did='".$did."', veh_no='".$veh_no."', vtid='".$vtid."', action_date='".$action_date."',modelno='".$modelno."',made='".$made."',taxifleetname='".$taxifleetname."',taxifleetnumber='".$taxifleetnumber."' where vid='".$vid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res_veh = mysql_query("SELECT dm.*,vm.* FROM tbl_vehicle_master vm inner join tbl_driver_master dm on vm.did = dm.did WHERE vid = '$vid'", $this->db);
$result_res_veh = mysql_fetch_array($sql_res_veh,MYSQL_ASSOC);
$res[]=$result_res_veh;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Vehicle API END ###################################
################################ BOOKING STATUS API Start ###################################
/*
* Simple Reg Booking Status API
* Reg Booking Status must be POST method
* did : <Driver ID>
* tbid : <Booking ID>
* status : <Booking Status Declined/Accepted>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerbookingstatus/
*/
private function registerbookingstatus(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID");
}
$status = $this->_request['status'];
if($status=="")
{
array_push($arr,"Please Enter Booking Status.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_taxi_booking_status (did, tbid, status, status_date, action_date, is_activate, is_deleted) values ('".$did."', '".$tbid."', '".$status."', '".$action_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// http://ezygo.co.nz/ftpserver/taxiapp/api/registerbookingstatuspush/
private function registerbookingstatuspush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID");
}
$status = $this->_request['status'];
if($status=="")
{
array_push($arr,"Please Enter Booking Status.");
}
$pushmsg = "";
$cid="";
//$sql_res = mysql_query("SELECT dm.did,dm.fname,dm.lname,tb.cid FROM tbl_driver_master dm inner join tbl_taxi_booking_status bs on bs.did=dm.did inner join tbl_taxi_booking tb on tb.tbid = bs.tbid WHERE bs.did = '".$did."' and bs.tbid= '".$tbid."'", $this->db);
$sql_res = mysql_query("SELECT dm.did, dm.fname, dm.lname, tb.cid, vm.modelno, vm.made FROM tbl_driver_master dm INNER JOIN tbl_taxi_booking_status bs ON bs.did = dm.did INNER JOIN tbl_taxi_booking tb ON tb.tbid = bs.tbid INNER JOIN tbl_vehicle_master vm ON vm.did = dm.did WHERE bs.did = '".$did."' and bs.tbid= '".$tbid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Driver Name: ".$result_res["fname"]." ".$result_res["lname"]." Phone No: ".$result_res["phone_no"]." Taxi Number Plate: ".$result_res["driver_noplate"]." Model Number: ".$result_res["modelno"]." Made: ".$result_res["made"];
$cid = $result_res["cid"];
}
}
$resp=array();
if($status=="Accepted")
{
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $cid,
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Booking Accepted"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_exec($curl);
}
}
/*
* Simple Collected Booking Status API
* Collected Booking Status must be POST method
* tbsid : <Booking Status ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/collectedbookingstatus/
*/
private function collectedbookingstatus(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter Booking Status ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking_status set status='Collected', collected_date='".$action_date."', action_date='".$action_date."' where tbsid='".$tbsid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '$tbsid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Droped Booking Status API
* Droped Booking Status must be POST method
* tbsid : <Booking Status ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/dropedbookingstatus/
*/
private function dropedbookingstatus(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter Booking Status ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking_status set status='Completed', droped_date='".$action_date."', action_date='".$action_date."' where tbsid='".$tbsid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '$tbsid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$collected_date=$result_res['collected_date'];
$droped_date=$result_res['droped_date'];
$traveling_time=round(abs(strtotime($droped_date) - strtotime($collected_date)) / 60,2);
$sql_driver = mysql_query("SELECT total_drive FROM tbl_driver_master WHERE did = '".$result_res['did']."'", $this->db);
$result_driver = mysql_fetch_array($sql_driver,MYSQL_ASSOC);
$total_drive=(int)$result_driver['total_drive'];
$new_total_drive=$total_drive+$traveling_time;
$update_bo = "update tbl_taxi_booking set status='Completed', traveling_time='".$traveling_time."' where tbid='".$result_res['tbid']."'";
$sql_bo = mysql_query($update_bo, $this->db);
$update_dr = "update tbl_driver_master set total_drive='".$new_total_drive."' where did='".$result_res['did']."'";
$sql_dr = mysql_query($update_dr, $this->db);
$msg = array();
$msg["str"] = "Dropped Successfully";
$success = array("status" => "true", "msg" => $msg );
$this->api_response($this->json($success), 200);
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// API URL : http://dev9.edreamz3.com/taxiapp/api/dropedbookingstatuspush/
private function dropedbookingstatuspush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter Booking Status ID.");
}
$pushmsg = "";
$sql_res = mysql_query("SELECT dm.did, dm.fname as dfname, dm.lname as dlname, cm.cid, cm.fname as cfname, cm.lname as clname, tb.booking_from, tb.booking_to FROM tbl_driver_master dm, tbl_taxi_booking tb, tbl_taxi_booking_status bs, tbl_customer_master cm where dm.did=bs.did and bs.tbid=tb.tbid and tb.cid=cm.cid AND bs.status = 'Completed' and bs.tbsid= '".$tbsid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$pushmsgdriver = "Passenger Name: ".$result_res["cfname"]." ".$result_res["clname"]." From: ".$result_res["booking_from"]." To: ".$result_res["booking_to"]." is over";
$APPLICATION_ID = "mALjhLoXULLHOoXR1n6K4pDOhZzKicjfyXMplpzK";
$REST_API_KEY = "sU9RWrGuumdHGHIKOvAosCBk1GRRWXywLoO4EQTV";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'did' => $result_res["did"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsgdriver",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Dropped"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
$pushmsgcustomer = "Driver Name: ".$result_res["dfname"]." ".$result_res["dlname"]." From: ".$result_res["booking_from"]." To: ".$result_res["booking_to"]." is over";
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $result_res["cid"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsgcustomer",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>""),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_exec($curl);
}
/*
* Simple Droped Booking Status API
* Droped Booking Status must be POST method
* tbsid : <Booking Status ID>
* booking_to : <booking_to>
* booking_to_lat : <booking_to_lat>
* booking_to_lng : <booking_to_lng>
* API URL : http://dev9.edreamz3.com/taxiapp/api/dropedbookingstatusfixed/
*/
private function dropedbookingstatusfixed(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter Booking Status ID.");
}
$booking_to = $this->_request['booking_to'];
$booking_to_lat = $this->_request['booking_to_lat'];
$booking_to_lng = $this->_request['booking_to_lng'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking_status set status='Completed', droped_date='".$action_date."', action_date='".$action_date."' where tbsid='".$tbsid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '$tbsid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$collected_date=$result_res['collected_date'];
$droped_date=$result_res['droped_date'];
$traveling_time=round(abs(strtotime($droped_date) - strtotime($collected_date)) / 60,2);
$sql_driver = mysql_query("SELECT total_drive FROM tbl_driver_master WHERE did = '".$result_res['did']."'", $this->db);
$result_driver = mysql_fetch_array($sql_driver,MYSQL_ASSOC);
$total_drive=(int)$result_driver['total_drive'];
$new_total_drive=$total_drive+$traveling_time;
$update_bo = "update tbl_taxi_booking set status='Completed', traveling_time='".$traveling_time."',booking_to='".$booking_to."',booking_to_lat='".$booking_to_lat."',booking_to_lng='".$booking_to_lng."' where booking_type='FixedAdvance' and tbid='".$result_res['tbid']."'";
$sql_bo = mysql_query($update_bo, $this->db);
$update_dr = "update tbl_driver_master set total_drive='".$new_total_drive."' where did='".$result_res['did']."'";
$sql_dr = mysql_query($update_dr, $this->db);
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// API URL : http://dev9.edreamz3.com/taxiapp/api/advancebookingpush/
private function advancebookingpush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$pushmsg = "";
date_default_timezone_set('NZ');
$rem1hr = $date=date("Y-m-d H:i", strtotime('1 hour'));
$rem1hr1 .= $rem1hr.":00";
$rem1hr2 .= $rem1hr.":59";
//$sql_res = mysql_query("SELECT dm.did, dm.fname as dfname, dm.lname as dlname, cm.cid, cm.fname as cfname, cm.lname as clname, tb.booking_from, tb.booking_to, tb.booking_time FROM tbl_driver_master dm, tbl_taxi_booking tb, tbl_taxi_booking_status bs, tbl_customer_master cm where dm.did=bs.did and bs.tbid=tb.tbid and tb.cid=cm.cid and bs.tbsid= '".$tbsid."'", $this->db);
$sql_res = mysql_query("SELECT dm.did, dm.fname AS dfname, dm.lname AS dlname, cm.cid, cm.fname AS cfname, cm.lname AS clname, tb.booking_from, tb.booking_to, tb.booking_time FROM tbl_taxi_booking tb INNER JOIN tbl_customer_master cm ON tb.cid = cm.cid INNER JOIN tbl_taxi_booking_status tbs ON tbs.tbid = tb.tbid INNER JOIN tbl_driver_master dm ON dm.did = tbs.did AND tb.booking_time >= '".$rem1hr1."' and tb.booking_time <= '".$rem1hr2."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$pushmsgdriver = "Passenger Name: ".$result_res["cfname"]." ".$result_res["clname"]." From: ".$result_res["booking_from"]." To: ".$result_res["booking_to"]." At: ".$result_res["booking_time"]." journey will start after 1 hour.";
$APPLICATION_ID = "mALjhLoXULLHOoXR1n6K4pDOhZzKicjfyXMplpzK";
$REST_API_KEY = "sU9RWrGuumdHGHIKOvAosCBk1GRRWXywLoO4EQTV";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'did' => $result_res["did"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsgdriver",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Advance Booking"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
$pushmsgcustomer = "Driver Name: ".$result_res["dfname"]." ".$result_res["dlname"]." From: ".$result_res["booking_from"]." To: ".$result_res["booking_to"]." At: ".$result_res["booking_time"]." journey will start after 1 hour.";
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $result_res["cid"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsgcustomer",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Advance Booking"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
}
//}
//}
/*
* Simple Get all Pending Booking
* Get all Pending Booking must be POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallpendingbooking/
*/
private function getallpendingbooking(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$sql_res_booking = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid not in (select tbid from tbl_taxi_booking_status) and is_activate = 1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Get all New Booking
* Get all New Booking must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallnewbookingbydid/
*/
private function getallnewbookingbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
date_default_timezone_set('NZ');
$timenow1=date("Y-m-d H:i:s");
$timenow=$date=date("Y-m-d H:i:s", strtotime('-15 minutes'));
$ss = "SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.booking_time > '".$timenow."' and tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did!='".$did."' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0";
//$sql_res_booking = mysql_query("SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.booking_time > '".$timenow."' and tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did!='".$did."' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0", $this->db);
$sql_res_booking = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid not in ( select tbid from tbl_taxi_booking_status where status='Accepted' OR status ='Collected' OR status='Completed' or (status='Declined' AND did ='".$did."')) and booking_time >= '".$timenow."' and is_activate = 1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
$dt = array();
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$x= array();
$x['CT'] = $timenow1;
$x['-15 T'] = $timenow;
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $x );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Get all Accepted Booking
* Get all Accepted Booking must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallacceptbookingbydid/
*/
private function getallacceptbookingbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$ss = "SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did='".$did."' and tbl_taxi_booking_status.status='Accepted' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0";
$sql_res_booking = mysql_query("SELECT tbl_taxi_booking.*,tbl_taxi_booking_status.tbsid,tbl_taxi_booking_status.status FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did='".$did."' and tbl_taxi_booking_status.status='Accepted' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0 ORDER BY tbid DESC ", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Get all Booking History
* Get all Booking History must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallbookinghistorybydid/
*/
private function getallbookinghistorybydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$driving_date = $this->_request['driving_date'];
if($driving_date=="")
{
array_push($arr,"Please Enter Driving Date.");
}
else{
$driving_date=date('Y-m-d', strtotime($driving_date));
}
if(count($arr)==0)
{
$ss = "SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did='".$did."' and tbl_taxi_booking_status.status='Completed' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0";
$sql_res_booking = mysql_query("SELECT tbl_taxi_booking.* FROM tbl_taxi_booking, tbl_taxi_booking_status WHERE tbl_taxi_booking.tbid=tbl_taxi_booking_status.tbid and tbl_taxi_booking_status.did='".$did."' and tbl_taxi_booking_status.status='Completed' and tbl_taxi_booking.is_activate = 1 and tbl_taxi_booking.is_deleted=0 ORDER BY tbid DESC", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$result_res_booking['cid']."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['customer'][]=$result_res;
}
$res['booking'][]=$result_res_booking;
$resall[]=$res;
}
//$res1=array();
$workinghrs=0;
$sql_res = mysql_query("SELECT tbid FROM tbl_taxi_booking_status WHERE did = '$did' and collected_date like '$driving_date%'", $this->db);
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$sql_booking= mysql_query("SELECT traveling_time FROM tbl_taxi_booking WHERE tbid = '".$result_res['tbid']."'", $this->db);
$result_boking = mysql_fetch_array($sql_booking,MYSQL_ASSOC);
$workinghrs=$workinghrs+$result_boking['traveling_time'];
}
$workinghrs1=floor($workinghrs/60);
$workinghrs2=$workinghrs-($workinghrs1*60);
//$res1[]['workinghrs']=$workinghrs1.":".$workinghrs2;
$res1 = $workinghrs1.":".$workinghrs2;
$success = array("status" => "true", "items" => $resall, "dailydriverworkinghrs" => $res1);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Get All Advance Booking By Passenger
* Get All Advance Booking By Passenger must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getadvancebookingbypassenger/
*/
private function getadvancebookingbypassenger(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$timenow=date("Y-m-d H:i:s");
$ss = "SELECT * FROM tbl_taxi_booking WHERE booking_time > '".$timenow."' and cid='".$cid."' and booking_type='Advance' or booking_type='FixedAdvance' and is_activate = 1 and is_deleted=0";
$sql_res_booking = mysql_query("SELECT * FROM tbl_taxi_booking WHERE booking_time > '".$timenow."' and cid='".$cid."' and (booking_type='Advance' or booking_type='FixedAdvance') and is_activate = 1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$res[]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
/*
* Simple Cancel the Advance Booking By Passenger API
* Cancel the Advance Booking By Passenger must be POST method
* tbid : <Booking ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/cancelbookingbypassenger/
*/
private function cancelbookingbypassenger(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking set is_activate=0, action_date='".$action_date."' where tbid='".$tbid."'";
$sql = mysql_query($update_sql, $this->db);
$update_status = "update tbl_taxi_booking_status set is_activate=0, action_date='".$action_date."' where tbid='".$tbid."'";
$status = mysql_query($update_status, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid = '$tbid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res['booking'][]=$result_res;
$sql_status = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbid = '$tbid'", $this->db);
if(mysql_num_rows($sql_status)>0)
{
$result_status = mysql_fetch_array($sql_status,MYSQL_ASSOC);
$res['booking_status'][]=$result_status;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get all past booking destinations By Passenger
* Get all past booking destinations By Passenger must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallpastbookingbypassenger/
*/
private function getallpastbookingbypassenger(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$timenow=date("Y-m-d H:i:s");
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$timenow=date("Y-m-d H:i:s");
$ss = "SELECT tbid, cid, booking_to, booking_to_lat, booking_to_lng FROM tbl_taxi_booking WHERE cid='".$cid."'";
$sql_res_booking = mysql_query("SELECT tbid, cid, booking_to, booking_to_lat, booking_to_lng FROM tbl_taxi_booking WHERE cid='".$cid."'", $this->db);
if(mysql_num_rows($sql_res_booking) > 0)
{
$resall=array();
while($result_res_booking = mysql_fetch_array($sql_res_booking,MYSQL_ASSOC))
{
$res=array();
$res[]=$result_res_booking;
$resall[]=$res;
}
$success = array("status" => "true", "items" => $resall);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.', "sql" => $ss );
$this->api_response($this->json($error), 400);
exit;
}
}
}
################################ BOOKING STATUS API END ###################################
################################ INVITE FRIEND API Start ###################################
/*
* Simple Reg Invite Friend API
* Reg INVITE FRIEND must be POST method
* cid : <Customer ID>
* femailid : <Friend Email ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerinvitefriend/
*/
private function registerinvitefriend(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$femailid = $this->_request['femailid'];
if($femailid=="")
{
array_push($arr,"Please Enter Friend Email ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_invite_friends (cid, femailid, action_date, is_activate, is_deleted) values ('".$cid."', '".$femailid."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_invite_friends WHERE ifid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ INVITE FRIEND API END ###################################
################################ Customer Credit API Start ###################################
/*
* Simple Reg Customer Credit API
* Reg Customer Credit must be POST method
* cid : <Customer ID>
* credit : <Customer Credit>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registercustomercredit/
*/
private function registercustomercredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$credit = $this->_request['credit'];
if($credit=="")
{
array_push($arr,"Please Enter Customer Credit.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_credit_master (cid, credit, action_date, is_activate, is_deleted) values ('".$cid."', '".$credit."', '".$action_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_credit_master WHERE crid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Customer Credit API
* Get Customer Credit must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getcustomercredit/
*/
private function getcustomercredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$sql_res = mysql_query("SELECT * FROM tbl_credit_master WHERE cid = '$cid' and is_activate=1 and is_deleted=0", $this->db);
$res=array();
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Edit Customer Credit API
* Edit Customer Credit must be POST method
* crid : <Customer Credit ID>
* cid : <Customer ID>
* credit : <Customer Credit>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editcustomercredit/
*/
private function editcustomercredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$crid = $this->_request['crid'];
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$credit = $this->_request['credit'];
if($credit=="")
{
array_push($arr,"Please Enter Customer Credit.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_credit_master set cid='".$cid."',credit='".$credit."' where crid='".$crid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_credit_master WHERE crid = '$crid'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Customer Credit API END ###################################
################################ SURPLUS API Start ###################################
/*
* Simple Get Surplus API
* Get Surplus must be POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getsurplus/
*/
private function getsurplus(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_surplus_master WHERE is_activate=1 and is_deleted=0", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
################################ SURPLUS API END ###################################
################################ Booking Payment API Start ###################################
/*
* Simple Reg Booking Payment API
* Reg Booking Payment must be POST method
* tbid : <Taxi Booking ID>
* did : <Driver ID>
* cid : <Customer ID>
* oid : <Offer ID>
* spid : <Sur Plus ID>
* pcid : <Promo Code ID>
* crid : <Credit ID>
* paymode : <Payment Mode>
* total_km : <Total KM>
* total_min : <Total Min>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerbookingpayment/
*/
private function registerbookingpayment(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$action_date=date("Y-m-d H:i:s");
$action_dt=date("Y-m-d");
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID.");
}
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$oid = (int)$this->_request['oid'];
$spid = (int)$this->_request['spid'];
$pcid = (int)$this->_request['pcid'];
$crid = (int)$this->_request['crid'];
$paymode = $this->_request['paymode'];
if($paymode=="")
{
array_push($arr,"Please Enter Payment Mode.");
}
$total_km = $this->_request['total_km'];
if($total_km=="")
{
array_push($arr,"Please Enter Total KM.");
}
$total_km =(float) $this->_request['total_km'];
$total_min = $this->_request['total_min'];
if($total_min=="")
{
array_push($arr,"Please Enter Total Min.");
}
$total_min = (float)$this->_request['total_min'];
$driver_query=mysql_query("SELECT price_per_km, price_per_min, min_price FROM tbl_vehicle_master WHERE did = '$did'", $this->db);
$result_driver = mysql_fetch_array($driver_query,MYSQL_ASSOC);
$price_per_km=(float)$result_driver['price_per_km'];
$price_per_min=(float)$result_driver['price_per_min'];
$min_price=(float)$result_driver['min_price'];
$total_fare = ($total_km*$price_per_km)+($total_min*$price_per_min)+$min_price;
$total_fare = number_format($total_fare, 2, '.', '');
if($oid!='' || $oid>0)
{
$query_offer=mysql_query("SELECT offer FROM tbl_offer_master WHERE oid = '$oid' and validfrom <= '$action_dt' and validto >= '$action_dt'", $this->db);
if(mysql_num_rows($query_offer)>0)
{
$result_offer = mysql_fetch_array($query_offer,MYSQL_ASSOC);
$offer_discount_rate=(float)$result_offer['offer'];
$offer_discount=$total_fare*$offer_discount_rate/100;
}
else
{
array_push($arr,"Please Enter Valid Offer ID.");
}
}
if($spid!='' || $spid>0)
{
$query_sur=mysql_query("SELECT surplusper,surplusfix FROM tbl_surplus_master WHERE spid = '$spid'", $this->db);
if(mysql_num_rows($query_sur)>0)
{
$result_sur= mysql_fetch_array($query_sur,MYSQL_ASSOC);
$surplusper=(float)$result_sur['surplusper'];
$surplusfix=(float)$result_sur['surplusfix'];
if($surplusfix=='' || $surplusfix=='0.00')
{
$surplus_added=$total_fare*$surplusper/100;
}
else
{
$surplus_added=$surplusfix;
}
}
else
{
array_push($arr,"Please Enter Valid Sur Plus ID.");
}
}
if($pcid!='' || $pcid>0)
{
$query_promo=mysql_query("SELECT discount FROM tbl_promocode WHERE pcid = '$pcid' and validfrom <= '$action_dt' and validto>= '$action_dt'", $this->db);
if(mysql_num_rows($query_promo)>0)
{
$result_promo = mysql_fetch_array($query_promo,MYSQL_ASSOC);
$promo_discount=(float)$result_promo['discount'];
}
else
{
array_push($arr,"Please Enter Valid Promo Code ID.==== SELECT discount FROM tbl_promocode WHERE pcid = '$pcid' and (validfrom >= '$action_dt' and validto<= '$action_dt')");
}
}
if($crid!='' || $crid>0)
{
$query_credit=mysql_query("SELECT credit FROM tbl_credit_master WHERE crid = '$crid'", $this->db);
if(mysql_num_rows($query_credit)>0)
{
$result_credit = mysql_fetch_array($query_credit,MYSQL_ASSOC);
$credit_discount=(float)$result_credit['credit'];
}
else
{
array_push($arr,"Please Enter Valid Credit ID.");
}
}
$final_total = $total_fare-$offer_discount-$promo_discount-$credit_discount+$surplus_added;
$final_total = number_format($final_total, 2, '.', '');
$query_goloyal=mysql_query("SELECT * FROM tbl_goloyal WHERE tbid = '$tbid' and is_activate=1", $this->db);
if(mysql_num_rows($query_goloyal)>0)
{
$paymode = "Go Loyal";
}
if(count($arr)==0)
{
$is_activate=1;
$is_deleted=0;
$pay_dt=date("Y-m-d H:i:s");
$insert_sql = "insert into tbl_taxi_booking_payment (tbid, did, cid, oid, spid, pcid, crid, paymode, total_km, total_min, total_fare, final_total, pay_dt, action_date, is_activate, is_deleted) values ('".$tbid."', '".$did."', '".$cid."', '".$oid."', '".$spid."', '".$pcid."', '".$crid."', '".$paymode."', '".$total_km."', '".$total_min."', '".$total_fare."', '".$final_total."', '".$pay_dt."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
// Invoice
$sql_res_db = mysql_query("SELECT total_km, total_min,final_total,did,cid FROM tbl_taxi_booking_payment WHERE tbid = '$tbid' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_db) > 0)
{
while($result_res_db = mysql_fetch_array($sql_res_db,MYSQL_ASSOC))
{
$sql_res_b = mysql_query("SELECT collected_date,droped_date FROM tbl_taxi_booking_status WHERE tbid = '$tbid' and status='Completed' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_b) > 0)
{
$total_km = $result_res_db["total_km"];
$total_min = $result_res_db["total_min"];
$final_total = $result_res_db["final_total"];
$result_res_b = mysql_fetch_array($sql_res_b,MYSQL_ASSOC);
$collected_date = stripslashes($result_res_b["collected_date"]);
$droped_date = stripslashes($result_res_b["droped_date"]);
$did = $result_res_db["did"];
$sql_res_d = mysql_query("SELECT fname,lname,emailid FROM tbl_driver_master WHERE did='".$did."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_d = mysql_fetch_array($sql_res_d,MYSQL_ASSOC);
$drivername = stripslashes($result_res_d["fname"]." ".$result_res_d["lname"]);
$driveremail = stripslashes($result_res_d["emailid"]);
$cid = $result_res_db["cid"];
$sql_res_c = mysql_query("SELECT fname,lname,phone_no,emailid FROM tbl_customer_master WHERE cid='".$cid."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_c = mysql_fetch_array($sql_res_c,MYSQL_ASSOC);
$pasgname = stripslashes($result_res_c["fname"]." ".$result_res_c["lname"]);
$pasgmobile = stripslashes($result_res_c["phone_no"]);
$pasgemail = stripslashes($result_res_c["emailid"]);
$sql_res_tb = mysql_query("SELECT booking_from_lat,booking_from_lng,booking_from,booking_to_lat,booking_to_lng,booking_to,booking_time FROM tbl_taxi_booking WHERE tbid='".$tbid."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_tb = mysql_fetch_array($sql_res_tb,MYSQL_ASSOC);
$booking_from_lat = stripslashes($result_res_tb["booking_from_lat"]);
$booking_from_lng = stripslashes($result_res_tb["booking_from_lng"]);
$booking_to_lat = stripslashes($result_res_tb["booking_to_lat"]);
$booking_to_lng = stripslashes($result_res_tb["booking_to_lng"]);
$booking_from = stripslashes($result_res_tb["booking_from"]);
$booking_to = stripslashes($result_res_tb["booking_to"]);
$booking_time = stripslashes($result_res_tb["booking_time"]);
$body1 = "<font face=verdana size=2>";
$body1 .= "<strong>Driver Name:</strong> ".$drivername."<br/>";
$body1 .= "<strong>Booking Date Time:</strong> ".$booking_time."<br/>";
$body1 .= "<strong>Passenger Name:</strong> ".$pasgname."<br/>";
$body1 .= "<strong>Passenger Mob:</strong> ".$pasgmobile."<br/>";
$body1 .= "<strong>Booking From:</strong> ".$booking_from."<br/>";
$body1 .= "<strong>Booking To:</strong> ".$booking_to."<br/>";
$body1 .= "<strong>Collected Time:</strong> ".$collected_date."<br/>";
$body1 .= "<strong>Dropped Time:</strong> ".$droped_date."<br/>";
$body1 .= "<strong>Total KM:</strong> ".$total_km."<br/>";
$body1 .= "<strong>Total Time in minutes:</strong> ".$total_min."<br/>";
$body1 .= "<strong>Total Fare:</strong> ".$final_total."<br/>";
$map = 'https://maps.googleapis.com/maps/api/staticmap?path=color:0xff0000ff%7Cweight:5%7C'.$booking_from_lat.','.$booking_from_lng.'%7C'.$booking_to_lat.','.$booking_to_lng.'&size=512x512';
$body1 .= "<strong>View Road Map of Travel:</strong> <a href=\"".$map."\">Click Here</a><br/>";
$body1 .= "</font>";
$emsubject = "Passenger Receipt from EZYGO.CO.NZ";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
//$driveremail = "corpsoftsol@gmail.com";
mail($driveremail, $emsubject, $body1, $headers);
mail($pasgemail, $emsubject, $body1, $headers);
//echo $driveremail;
//echo "SENT";
}
}
}
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_payment WHERE pid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]." ";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Booking Payment API END ###################################
################################ Driver Rating API Start ###################################
/*
* Simple Reg Driver Rating API
* Reg Driver Rating must be POST method
* did : <Driver ID>
* cid : <Customer ID>
* rating : <rating>
* rdt : <rating Date>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerdriverrating/
*/
private function registerdriverrating(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$rating = $this->_request['rating'];
if($rating=="")
{
array_push($arr,"Please Enter Rating.");
}
$rdt = $this->_request['rdt'];
if($rdt=="")
{
array_push($arr,"Please Enter Rating date.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_driver_rating (did, cid, rating, rdt, action_date, is_activate, is_deleted) values ('".$did."', '".$cid."', '".$rating."', '".$rdt."', '".$action_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_rating WHERE drid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Driver Rating by DID API
* Get Driver Rating by DID must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getdriverratingbydid/
*/
private function getdriverratingbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT tbl_driver_rating.*, CONCAT_WS(' ',tbl_customer_master.fname,tbl_customer_master.lname) as name FROM tbl_driver_rating,tbl_customer_master WHERE did = '$did' and tbl_driver_rating.cid=tbl_customer_master.cid and is_activate=1 and is_deleted=0", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Driver Rating API END ###################################
################################ Driver Feedback API Start ###################################
/*
* Simple Reg Driver Feedback API
* Reg Driver Feedback must be POST method
* did : <Driver ID>
* cid : <Customer ID>
* feedback : <Feedback>
* fdt : <Feedback Date>
* API URL : http://dev9.edreamz3.com/taxiapp/api/registerdriverfeedback/
*/
private function registerdriverfeedback(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$feedback = $this->_request['feedback'];
if($feedback=="")
{
array_push($arr,"Please Enter Feedback.");
}
$fdt = $this->_request['fdt'];
if($fdt=="")
{
array_push($arr,"Please Enter Feedback date.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_driver_feedback (did, cid, feedback, fdt, action_date, is_activate, is_deleted) values ('".$did."', '".$cid."', '".$feedback."', '".$fdt."', '".$action_date."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_driver_feedback WHERE fid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Driver Feedback by DID API
* Get Driver Feedback by DID must be POST method
* did : <Driver ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getdriverfeedbackbydid/
*/
private function getdriverfeedbackbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter Driver ID.");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT tbl_driver_feedback.*, CONCAT_WS(' ',tbl_customer_master.fname,tbl_customer_master.lname) as name FROM tbl_driver_feedback,tbl_customer_master WHERE did = '$did' and tbl_driver_feedback.cid=tbl_customer_master.cid and is_activate=1 and is_deleted=0", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ Driver Feedback API END ###################################
################################ PASSENGER API Start ###################################
/*
* Simple Passenger LOGIN API
* Passenger Login must be POST method
* username : <Passenger username>
* password : <Passenger password>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengerlogin/
*/
private function passengerlogin(){
// Cross validation if the request method is POST else it will return "Not Acceptable" status
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$username = $this->_request['username'];
$password = $this->_request['password'];
// Input validations
if(!empty($username) || !empty($password)){
$sql = mysql_query("SELECT * FROM tbl_customer_master WHERE username = '$username' AND password = '".$password."'", $this->db);
if(mysql_num_rows($sql) > 0){
$res=array();
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
$res[]=$result;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => "Invalid Username or Password1");
$this->api_response($this->json($error), 400);
}
}
$error = array("status" => "false", "msg" => "Invalid Username or Password2");
$this->api_response($this->json($error), 200);
}
/*
* Simple Passenger Forget Password API
* Passenger Forget Password must be POST method
* email : <USER Email>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengerforgetpassword/
*/
private function passengerforgetpassword(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$email = $this->_request['email'];
if(!empty($email) && checkEmail($email)){
$sql = mysql_query("SELECT * FROM tbl_customer_master WHERE emailid = '".$email."'", $this->db);
if(mysql_num_rows($sql) > 0){
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
$length =10;
$conso=array("b","c","d","f","g","h","j","k","l","m","n","p","r","s","t","v","w","x","y","z");
$vocal=array("5","8","7","9","6");
$password="";
srand ((double)microtime()*1000000);
$max = $length/2;
for($i=1; $i<=$max; $i++)
{
$password.=$conso[rand(0,19)];
$password.=$vocal[rand(0,4)];
}
$newpass = $password;
$body1 = "<font face=verdana size=2>";
$body1 .= "Your New Password<br><br>";
$body1 .= "EMAIL-ID: ".$email."<br>";
$body1 .= "PASSWORD: ".$newpass."<br>";
$body1 .= "</font>";
$emsubject = "Your New Password.";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($email, $emsubject, $body1, $headers))
{
$del_sql = mysql_query("update tbl_customer_master set password='".$newpass."' where emailid='".$email."'", $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE emailid = '$email' AND password = '".$newpass."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
}
else
{
$error = array("status" => "false", "msg" => "Message delivery failed...");
$this->api_response($this->json($error), 200);
}
$this->api_response($this->json($result), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => "Invalid Email");
$this->api_response($this->json($error), 200);
}
}
$error = array("status" => "false", "msg" => "Invalid Email");
$this->api_response($this->json($error), 200);
}
/*
* Simple Passenger Registeraton API
* Passenger Registeraton must be POST method
* fname : <Passenger First Name>
* lname : <Passenger Last Name>
* username : <Passenger Username>
* password : <Passenger Password>
* emailid : <Passenger Email>
* phone_no : <Passenger Contact Number>
* deviceid : <Passenger Device ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengerregisteration/
*/
private function passengerregisteration(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$fname = $this->_request['fname'];
if($fname=="")
{
array_push($arr,"Please Enter First Name.");
}
$lname = $this->_request['lname'];
if($lname=="")
{
array_push($arr,"Please Enter Last Name.");
}
$username = $this->_request['username'];
if($username=="")
{
array_push($arr,"Please Enter Username.");
}
$password = $this->_request['password'];
if($password=="")
{
array_push($arr,"Please Enter Password.");
}
$emailid = $this->_request['emailid'];
if($emailid=="")
{
array_push($arr,"Please Enter Email.");
}
else
{
if (!checkEmail($emailid))
{
array_push($arr,"Please Enter Valid Email.");
}
}
$phone_no = $this->_request['phone_no'];
if($phone_no=="")
{
array_push($arr,"Please Enter Contact Number.");
}
$deviceid = $this->_request['deviceid'];
if($deviceid=="")
{
array_push($arr,"Please Enter Device ID.");
}
if(count($arr)==0)
{
$squery = mysql_query("select * from tbl_customer_master where username='".$username."' or emailid='".$emailid."'", $this->db);
if(mysql_num_rows($squery) > 0){
$error = array("status" => "false", "msg" => 'This username or Email Already Exist.' );
$this->api_response($this->json($error), 200);
exit;
//array_push($arr, "This username/Email Already Exist.");
}
else
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_customer_master (fname, lname, username, password, emailid, phone_no, deviceid, action_date, is_activate, is_deleted) values ('".$fname."', '".$lname."', '".$username."', '".$password."', '".$emailid."', '".$phone_no."', '".$deviceid."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
//echo $insert_sql;
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$body1 = "<font face=verdana size=2>";
$body1 .= "Dear ".$fname.". Your account has been created for Passenger and your login details as<br><br>";
$body1 .= "EMAIL-ID: ".$emailid."<br>";
$body1 .= "PASSWORD: ".$password."<br>";
$body1 .= "</font>";
$emsubject = "Welcome to Ezygo.";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($emailid, $emsubject, $body1, $headers);
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 200);
exit;
}
}
/*
* Simple Passenger Edit Registeraton API
* Passenger Registeraton must be POST method
* cid : <Passenger ID>
* fname : <Passenger First Name>
* lname : <Passenger Last Name>
* password : <Passenger Password>
* emailid : <Passenger Email>
* phone_no : <Passenger Contact Number>
* deviceid : <Passenger Device ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengereditprofile/
*/
private function passengereditprofile(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
$fname = $this->_request['fname'];
if($fname=="")
{
array_push($arr,"Please Enter First Name.");
}
$lname = $this->_request['lname'];
if($lname=="")
{
array_push($arr,"Please Enter Last Name.");
}
$password = $this->_request['password'];
if($password=="")
{
array_push($arr,"Please Enter Password.");
}
$emailid = $this->_request['emailid'];
if($emailid=="")
{
array_push($arr,"Please Enter Email.");
}
else
{
if (!checkEmail($emailid))
{
array_push($arr,"Please Enter Valid Email.");
}
}
$phone_no = $this->_request['phone_no'];
if($phone_no=="")
{
array_push($arr,"Please Enter Contact Number.");
}
if(count($arr)==0)
{
$squery = mysql_query("select * from tbl_customer_master where emailid='".$emailid."' and cid!='".$cid."'" , $this->db);
if(mysql_num_rows($squery) > 0){
$error = array("status" => "false", "msg" => 'This Email Already Exist.' );
$this->api_response($this->json($error), 400);
exit;
}
else
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$update_sql = "update tbl_customer_master set fname='".$fname."', lname='".$lname."', emailid='".$emailid."', password='".$password."', phone_no='".$phone_no."', deviceid='".$deviceid."' where cid='".$cid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Passenger Edit Payment Method API
* Passenger Edit Payment Method must be POST method
* cid : <Passenger ID>
* payment_method : <Passenger Payment method>
* cashstatus : <Passenger Cash Status>
* credit_card_no : <Passenger Credit Card No>
* exp_date : <Passenger Credit Card Expiary Date>
* cvv : <Passenger Credit Card CVV>
* paypal : <Passenger Paypal email>
* API URL : http://dev9.edreamz3.com/taxiapp/api/passengerpaymentmethod/
*/
private function passengerpaymentmethod(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$strr="";
$cid = $this->_request['cid'];
$payment_method = $this->_request['payment_method'];
if($payment_method!=''){$strr.="payment_method='".$payment_method."', ";}
$cashstatus = $this->_request['cashstatus'];
if($cashstatus!=''){$strr.="cashstatus='".$cashstatus."', ";}
$credit_card_no = $this->_request['credit_card_no'];
if($credit_card_no!=''){$strr.="credit_card_no='".$credit_card_no."', ";}
$exp_date = $this->_request['exp_date'];
if($exp_date!=''){$strr.="exp_date='".$exp_date."', ";}
$cvv = $this->_request['cvv'];
if($cvv!=''){$strr.="cvv='".$cvv."', ";}
$paypal = $this->_request['paypal'];
if($paypal!=''){$strr.="paypal='".$paypal."', ";}
$strr=substr($strr,0,-2);
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$update_sql = "update tbl_customer_master set ".$strr." where cid='".$cid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Customer Add Address API
* Customer Add Address must be POST method
* cid : <Customer ID>
* add_cat : <Customer Home/Office>
* street : <Customer Street>
* city : <Customer City>
* state : <Customer State>
* postcode : <Customer Post Code>
* API URL : http://dev9.edreamz3.com/taxiapp/api/customeraddress/
*/
private function customeraddress(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$add_cat = $this->_request['add_cat'];
if($add_cat=="")
{
array_push($arr,"Please Enter Customer Home/Office.");
}
$street = $this->_request['street'];
if($street=="")
{
//array_push($arr,"Please Enter Street.");
}
$city = $this->_request['city'];
if($city=="")
{
//array_push($arr,"Please Enter City.");
}
$state = $this->_request['state'];
if($state=="")
{
//array_push($arr,"Please Enter State.");
}
$postcode = $this->_request['postcode'];
if($postcode=="")
{
//array_push($arr,"Please Enter Post Code.");
}
$address = $this->_request['address'];
/*$address = "";
if ($street!="") {$address = $address.$street;}
if ($city!="") {$address = $address.",".$city;}
if ($state!="") {$address = $address.",".$state;}
if ($postcode!="") {$address = $address.",".$postcode;}*/
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_customer_address_master (cid, add_cat, street, city, state, postcode, action_date, is_activate, is_deleted,address) values ('".$cid."', '".$add_cat."', '".$street."', '".$city."', '".$state."', '".$postcode."', '".$action_date."', '".$is_activate."', '".$is_deleted."','".$address."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
//$sql_res = mysql_query("SELECT caid, cid, add_cat, CONCAT_WS(',',street,city,state,postcode) as address FROM tbl_customer_address_master WHERE caid = '$insert_id'", $this->db);
$res=array();
$sql_res = mysql_query("SELECT caid, cid, add_cat, address FROM tbl_customer_address_master WHERE caid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Customer Edit Address API
* Customer Edit Address must be POST method
* caid : <Customer Address ID>
* cid : <Customer ID>
* cid : <Customer ID>
* add_cat : <Customer Home/Office>
* street : <Customer Street>
* city : <Customer City>
* state : <Customer State>
* postcode : <Customer Post Code>
* API URL : http://dev9.edreamz3.com/taxiapp/api/customereditaddress/
*/
private function customereditaddress(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$caid = $this->_request['caid'];
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$add_cat = $this->_request['add_cat'];
if($add_cat=="")
{
array_push($arr,"Please Enter Customer Home/Office.");
}
$street = $this->_request['street'];
if($street=="")
{
//array_push($arr,"Please Enter Street.");
}
$city = $this->_request['city'];
if($city=="")
{
//array_push($arr,"Please Enter City.");
}
$state = $this->_request['state'];
if($state=="")
{
//array_push($arr,"Please Enter State.");
}
$postcode = $this->_request['postcode'];
if($postcode=="")
{
//array_push($arr,"Please Enter Post Code.");
}
$address = $this->_request['address'];
/*$address = "";
if ($street!="") {$address = $address.$street;}
if ($city!="") {$address = $address.",".$city;}
if ($state!="") {$address = $address.",".$state;}
if ($postcode!="") {$address = $address.",".$postcode;} */
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_customer_address_master set cid='".$cid."', add_cat='".$add_cat."', street='".$street."', city='".$city."', state='".$state."', postcode='".$postcode."', action_date='".$action_date."', address='".$address."' where caid='".$caid."'";
$sql = mysql_query($update_sql, $this->db);
//$sql_res = mysql_query("SELECT caid, cid, add_cat, CONCAT_WS(',',street,city,state,postcode) as address FROM tbl_customer_address_master WHERE caid = '".$caid."'", $this->db);
$res=array();
$sql_res = mysql_query("SELECT caid, cid, add_cat, address FROM tbl_customer_address_master WHERE caid = '".$caid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple get API for Home/Office Address info From cid
* get API for Home/Office Address info From cid must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getaddressbycid/
*/
private function getaddressbycid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer Id.");
}
if(count($arr)==0)
{
$data=array();
//$sql_res = mysql_query("SELECT caid, add_cat, CONCAT_WS(',',street,city,state,postcode) as address FROM tbl_customer_address_master WHERE cid = '".$cid."'", $this->db);
$sql_res = mysql_query("SELECT caid, add_cat, address FROM tbl_customer_address_master WHERE cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple get the selected payment method From cid
* get the selected payment method From cid must be POST method
* cid : <Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getpaymentmethodbycid/
*/
private function getpaymentmethodbycid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer Id.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT cid, payment_method, cashstatus, credit_card_no, exp_date, cvv, paypal FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ PASSENGER API End ###################################
/*
* Simple Get Fair Estimate API
* Get Fair Estimate must be POST method
* did : <Driver ID>
* distance : <Tarvel Distance>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getfairestimate/
*/
private function getfairestimate(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$did =(int) $this->_request['did'];
$from = urlencode($this->_request['from']);
$to = urlencode($this->_request['to']);
//$from = file_get_contents($from);
//$to = file_get_contents($to);
//$distance = (float)$this->_request['distance'];
$url = 'https://maps.googleapis.com/maps/api/distancematrix/json?origins='.$from.'&destinations='.$to.'&departure_time=now&traffic_model=best_guess&key=AIzaSyBj2Y63SxN6m0XXbFLyLTbRfDgCC_orFh0';
$data = json_decode(file_get_contents($url), true);
$dist1 = $data["rows"][0]["elements"][0]["distance"]["text"];
$dur1 = $data["rows"][0]["elements"][0]["duration"]["text"];
$durtraf1 = $data["rows"][0]["elements"][0]["duration_in_traffic"]["text"];
$dist = current(explode(' ', $dist1));
$dur = current(explode(' ', $dur1));
$durtraf = current(explode(' ', $durtraf1));
$sql = mysql_query("SELECT vid, did, price_per_km, price_per_min, min_price FROM tbl_vehicle_master WHERE did = '$did'", $this->db);
if(mysql_num_rows($sql) > 0){
$res1=array();
$result = mysql_fetch_array($sql,MYSQL_ASSOC);
$min_price=(float)$result['min_price'];
$price_per_km=(float)$result['price_per_km'];
$total_dist=(float)$price_per_km*$dist; //6.6*1.95
$price_per_min=(float)$result['price_per_min'];
$total_min=(float)$price_per_min*$dur;//22*0.35
$total_traffic_min=(float)$price_per_min*$durtraf;//22*0.35
//$result['distance']=$distance;
//$result['total_fair']=number_format($total_fair,2);
$total_fair=$total_dist+$total_min+$min_price;
$total_traffic_fair=$total_dist+$total_traffic_min+$min_price;
$res1['price_per_km']=$price_per_km;
$res1['total_fair']=number_format($total_fair,2);
$res1['total_traffic_fair']=number_format($total_traffic_fair,2);
$res[]=$res1;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
}
else
{
$error = array("status" => "false", "msg" => "Invalid Driver Id");
$this->api_response($this->json($error), 400);
}
}
################################ BOOKING API Start ###################################
/*
* Simple Add Booking API
* Add Booking must be POST method
* cid : <Customer ID>
* vtid : <Vehicle Type ID>
* booking_type : <Booking Type Current/Advance>
* booking_from_lat : <Booking From Address Lat>
* booking_from_lng : <Booking From Address Lng>
* booking_from : <Booking From Address>
* booking_to_lat : <Booking To Address Lat>
* booking_to_lng : <Booking To Address Lng>
* booking_to : <Booking To Address>
* noofpass : <Number Of Passenger>
* booking_time : <Booking Time>
* notes : <Booking Notes>
* API URL : http://dev9.edreamz3.com/taxiapp/api/addbooking/
*/
private function addbooking(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle Type ID");
}
$booking_type = $this->_request['booking_type'];
if($booking_type=="")
{
array_push($arr,"Please Enter Booking Type Current/Advance.");
}
$booking_from_lat = $this->_request['booking_from_lat'];
if($booking_from_lat=="")
{
array_push($arr,"Please Enter Booking From Address Lat.");
}
$booking_from_lng = $this->_request['booking_from_lng'];
if($booking_from_lng=="")
{
array_push($arr,"Please Enter Booking From Address Lng.");
}
$booking_from = $this->_request['booking_from'];
if($booking_from=="")
{
array_push($arr,"Please Enter Booking From Address.");
}
$booking_to = $this->_request['booking_to'];
if($booking_to=="")
{
//array_push($arr,"Please Enter Booking To Address.");
}
$booking_to_lat = $this->_request['booking_to_lat'];
$booking_to_lng = $this->_request['booking_to_lng'];
if($booking_from_lat!='' && $booking_from_lng!='' && $booking_to_lat!='' && $booking_to_lng!='')
{
$distance=0;
$theta = $booking_from_lng - $booking_to_lng;
$dist = sin(deg2rad($booking_from_lat)) * sin(deg2rad($booking_to_lat)) + cos(deg2rad($booking_from_lat)) * cos(deg2rad($booking_to_lat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$distance = $miles * 1.609344; // KM
}
else{
$distance="";
}
//Vijay
/*$pushmsg = "";
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Passenger Name: ".$result_res["fname"]." ".$result_res["lname"]." From: ".$booking_from." To: ".$booking_to;
}
}
$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$dlat = $result_res["lat"];
$dlng = $result_res["lng"];
$theta = $booking_from_lng - $dlng;
$dist = sin(deg2rad($booking_from_lat)) * sin(deg2rad($dlat)) + cos(deg2rad($booking_from_lat)) * cos(deg2rad($dlat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
$km = round($km,0);
if ($km<=5)
{
$APPLICATION_ID = "fo0mnigXyvaOPvn2KCls3e5u2IZoFunpaohFizzC";
$REST_API_KEY = "q6ty6gEz5XmAJTefUD3bX1ArqKaGhIoVHBTxWg9Z";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'did' => $result_res["did"],
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
curl_close($curl);
}
}
}*/
$noofpass = $this->_request['noofpass'];
if($noofpass=="")
{
//array_push($arr,"Please Enter Number Of Passenger.");
}
$booking_time = $this->_request['booking_time'];
date_default_timezone_set('NZ');
$booking_time=date("Y-m-d H:i:s");
/*$user_tz = 'NZ';
$schedule_date = new DateTime($booking_time, new DateTimeZone($user_tz) );
$schedule_date->setTimeZone(new DateTimeZone('UTC'));
$booking_time = $schedule_date->format('Y-m-d H:i:s');*/
$notes = $this->_request['notes'];
$fixedfare = $this->_request['fixedfare'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_taxi_booking (cid, vtid, booking_type, booking_from_lat, booking_from_lng, booking_from, booking_to_lat, booking_to_lng, booking_to, distance, noofpass, booking_time, notes,fixedfare, action_date, is_activate, is_deleted) values ('".$cid."', '".$vtid."', '".$booking_type."', '".$booking_from_lat."', '".$booking_from_lng."', '".$booking_from."', '".$booking_to_lat."', '".$booking_to_lng."', '".$booking_to."', '".$distance."', '".$noofpass."', '".$booking_time."', '".$notes."', '".$fixedfare."' ,'".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
//$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid = '$insert_id'", $this->db);
$sql_res = mysql_query("SELECT tb. * , (SELECT COUNT( * ) FROM tbl_taxi_booking_payment WHERE cid='$cid') AS cnt FROM tbl_taxi_booking tb WHERE tbid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
// Credit
$crflag="false";
$res1=array();
$action_dt=date("Y-m-d");
$sql_res1 = mysql_query("SELECT oid, offer_reason, offer, validfrom, validto FROM `tbl_offer_master` WHERE is_activate =1 AND is_deleted =0 and validfrom <= '$action_dt' and validto >= '$action_dt'", $this->db);
if(mysql_num_rows($sql_res1) > 0)
{
$result_res1 = mysql_fetch_array($sql_res1,MYSQL_ASSOC);
$res1[]=$result_res1;
$crflag="true";
}
$success = array("status" => "true", "items" => $res,"creditstatus" => $crflag, "credititems" => $res1);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/addbookingpush/
private function addbookingpush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$booking_from_lat = $this->_request['booking_from_lat'];
if($booking_from_lat=="")
{
array_push($arr,"Please Enter Booking From Address Lat.");
}
$booking_from_lng = $this->_request['booking_from_lng'];
if($booking_from_lng=="")
{
array_push($arr,"Please Enter Booking From Address Lng.");
}
$booking_from = $this->_request['booking_from'];
$booking_to = $this->_request['booking_to'];
$pushmsg = "";
$sql_res = mysql_query("SELECT * FROM tbl_customer_master WHERE cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Passenger Name: ".$result_res["fname"]." ".$result_res["lname"]." From: ".$booking_from." To: ".$booking_to." Contact Number: ".$phone_no;
}
}
//$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
$sql_res = mysql_query("SELECT *, ( 6371 * ACOS( COS( RADIANS( '".$booking_from_lat."' ) ) * COS( RADIANS( Lat ) ) * COS( RADIANS( Lng ) - RADIANS( '".$booking_from_lng."' ) ) + SIN( RADIANS( '".$booking_from_lat."' ) ) * SIN( RADIANS( Lat ) ) )) AS distance FROM tbl_driver_master HAVING distance <5 ORDER BY distance", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$did = $result_res["did"];
/*$dlat = $result_res["lat"];
$dlng = $result_res["lng"];
$theta = $booking_from_lng - $dlng;
$dist = sin(deg2rad($booking_from_lat)) * sin(deg2rad($dlat)) + cos(deg2rad($booking_from_lat)) * cos(deg2rad($dlat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
$km = round($km,0);
if ($km<=5)
{*/
$APPLICATION_ID = "mALjhLoXULLHOoXR1n6K4pDOhZzKicjfyXMplpzK";
$REST_API_KEY = "sU9RWrGuumdHGHIKOvAosCBk1GRRWXywLoO4EQTV";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'did' => $did,
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"New Booking"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_exec($curl);
//}
}
}
}
/*
* Simple Edit Booking API
* Edit Booking must be POST method
* tbid : <Booking ID>
* cid : <Customer ID>
* vtid : <Vehicle Type ID>
* booking_type : <Booking Type Current/Advance>
* booking_from_lat : <Booking From Address Lat>
* booking_from_lng : <Booking From Address Lng>
* booking_from : <Booking From Address>
* booking_to_lat : <Booking To Address Lat>
* booking_to_lng : <Booking To Address Lng>
* booking_to : <Booking To Address>
* noofpass : <Number Of Passenger>
* booking_time : <Booking Time>
* notes : <Booking Notes>
* API URL : http://dev9.edreamz3.com/taxiapp/api/editbooking/
*/
private function editbooking(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
$vtid = $this->_request['vtid'];
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle Type ID");
}
$booking_type = $this->_request['booking_type'];
if($booking_type=="")
{
array_push($arr,"Please Enter Booking Type Current/Advance.");
}
$booking_from_lat = $this->_request['booking_from_lat'];
if($booking_from_lat=="")
{
array_push($arr,"Please Enter Booking From Address Lat.");
}
$booking_from_lng = $this->_request['booking_from_lng'];
if($booking_from_lng=="")
{
array_push($arr,"Please Enter Booking From Address Lng.");
}
$booking_from = $this->_request['booking_from'];
if($booking_from=="")
{
array_push($arr,"Please Enter Booking From Address.");
}
$booking_to = $this->_request['booking_to'];
if($booking_to=="")
{
//array_push($arr,"Please Enter Booking To Address.");
}
$booking_to_lat = $this->_request['booking_to_lat'];
$booking_to_lng = $this->_request['booking_to_lng'];
if($booking_from_lat!='' && $booking_from_lng!='' && $booking_to_lat!='' && $booking_to_lng!='')
{
$distance=0;
$theta = $booking_from_lng - $booking_to_lng;
$dist = sin(deg2rad($booking_from_lat)) * sin(deg2rad($booking_to_lat)) + cos(deg2rad($booking_from_lat)) * cos(deg2rad($booking_to_lat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$distance = $miles * 1.609344;
}
else{
$distance="";
}
$noofpass = $this->_request['noofpass'];
if($noofpass=="")
{
//array_push($arr,"Please Enter Number Of Passenger.");
}
$booking_time = $this->_request['booking_time'];
if($booking_time=="")
{
array_push($arr,"Please Enter Booking Time.");
}
$notes = $this->_request['notes'];
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking set cid='".$cid."', vtid='".$vtid."', booking_type='".$booking_type."', booking_from_lat='".$booking_from_lat."', booking_from_lng='".$booking_from_lng."', booking_from='".$booking_from."', booking_to_lat='".$booking_to_lat."', booking_to_lng='".$booking_to_lng."', booking_to='".$booking_to."', distance='".$distance."', noofpass='".$noofpass."', booking_time='".$booking_time."', notes='".$notes."', action_date='".$action_date."' where tbid='".$tbid."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking WHERE tbid = '".$tbid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
################################ BOOKING API End ###################################
/*
* Simple Get vtid API
* Get vtid must be POST method
* vtype : <Vehicle Type>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getvtidbyvtype/
*/
private function getvtidbyvtype(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$vtype = $this->_request['vtype'];
if($vtype=="")
{
array_push($arr,"Please Enter Vehicle Type.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_vehicle_type_master WHERE vtype = '".$vtype."' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get nearby drivers API
* Get Get nearby drivers POST method
* lat : <Latitude>
* lng : <Longitude>
* vtid : <Vehicle Type Id>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallnearbydrivers/
*/
private function getallnearbydrivers(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$lat = $this->_request['lat'];
$lng = $this->_request['lng'];
$vtid = $this->_request['vtid'];
if($lat=="")
{
array_push($arr,"Please Enter Latitude.");
}
if($lng=="")
{
array_push($arr,"Please Enter Longitude.");
}
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle Type Id.");
}
if(count($arr)==0)
{
$data=array();
//$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
$sql_res = mysql_query("SELECT tbl_driver_master.* FROM tbl_driver_master, tbl_vehicle_master WHERE tbl_driver_master.is_activate=1 and tbl_driver_master.is_deleted=0 and tbl_driver_master.did=tbl_vehicle_master.did and tbl_vehicle_master.vtid='".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$found=0;
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$dlat = $result_res["lat"];
$dlng = $result_res["lng"];
$theta = $lng - $dlng;
$dist = sin(deg2rad($lat)) * sin(deg2rad($dlat)) + cos(deg2rad($lat)) * cos(deg2rad($dlat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
$km = round($km,0);
//echo $km."<br/>";
if ($km<=5)
{
$found=$found+1;
$res[]=$result_res;
}
}
if ($found>0)
{
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Records Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else
{
$error = array("status" => "false", "msg" => 'No Records Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
$msg="";
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple get nearest driver API
* get nearest driver POST method
* lat : <Latitude>
* lng : <Longitude>
* vtid : <Vehicle Type Id>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getnearestdriver/
*/
private function getnearestdriver(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$lat = $this->_request['lat'];
$lng = $this->_request['lng'];
$vtid = $this->_request['vtid'];
if($lat=="")
{
array_push($arr,"Please Enter Latitude.");
}
if($lng=="")
{
array_push($arr,"Please Enter Longitude.");
}
if($vtid=="")
{
array_push($arr,"Please Enter Vehicle Type Id.");
}
if(count($arr)==0)
{
$data=array();
//$sql_res = mysql_query("SELECT * FROM tbl_driver_master WHERE is_activate=1 and is_deleted=0", $this->db);
$sql_res = mysql_query("SELECT tbl_driver_master.* FROM tbl_driver_master, tbl_vehicle_master WHERE tbl_driver_master.is_activate=1 and tbl_driver_master.is_deleted=0 and tbl_driver_master.did=tbl_vehicle_master.did and tbl_vehicle_master.vtid='".$vtid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$nkm=99999;
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$dlat = $result_res["lat"];
$dlng = $result_res["lng"];
$theta = $lng - $dlng;
$dist = sin(deg2rad($lat)) * sin(deg2rad($dlat)) + cos(deg2rad($lat)) * cos(deg2rad($dlat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
//$km = round($km,0);
//echo $km."<br/>";
//if ($km<=1)
// Vijay Code Start
$speed=40;
$time=$km/40*60;
$rkm = round($km,1);
$rtime = round($time,0);
$result_res["time"]=$rtime." min";
$result_res["distance"]=$rkm." km";
// Vijay Code End
if ($km<$nkm)
{
$nkm=$km;
$resvvvv=$result_res;
}
}
if ($nkm!=99999)
{
$success = array("status" => "true", "items" => $resvvvv);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Records Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else
{
$error = array("status" => "false", "msg" => 'No Records Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
$msg="";
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple get time and distance according to the passenger's current location API
* get time and distance according to the passenger's current location POST method
* passenger_lat : <Passenger Latitude>
* passenger_lng : <Passenger Longitude>
* driver_lat : <Driver Latitude>
* driver_lng : <Driver Longitude>
* API URL : http://dev9.edreamz3.com/taxiapp/api/gettimedistance/
*/
private function gettimedistance(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$passenger_lat = $this->_request['passenger_lat'];
$passenger_lng = $this->_request['passenger_lng'];
$driver_lat = $this->_request['driver_lat'];
$driver_lng = $this->_request['driver_lng'];
if($passenger_lat=="")
{
array_push($arr,"Please Enter Passenger Latitude.");
}
if($passenger_lng=="")
{
array_push($arr,"Please Enter Passenger Longitude.");
}
if($driver_lat=="")
{
array_push($arr,"Please Enter Driver Latitude.");
}
if($driver_lng=="")
{
array_push($arr,"Please Enter Driver Longitude.");
}
if(count($arr)==0)
{
$res=array();
$theta = $passenger_lng - $driver_lng;
$dist = sin(deg2rad($passenger_lat)) * sin(deg2rad($driver_lat)) + cos(deg2rad($passenger_lat)) * cos(deg2rad($driver_lat)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$km = $miles * 1.609344;
//$km = round($km,0);
$speed=40;
$time=$km/40*60;
$rkm = round($km,1);
$rtime = round($time,0);
$res["time"]=$rtime." min";
$res["distance"]=$rkm." km";
$success = array("status" => "true", "items" => $res );
$this->api_response($this->json($success), 200);
exit;
}
else{
$msg="";
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get vtid API
* Get vtid must be POST method
* cid : <customer id>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getpassfav/
*/
private function getpassfav(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer Id.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tb.* FROM tbl_taxi_booking tb inner join tbl_taxi_booking_status bs on tb.tbid = bs.tbid WHERE bs.status='Completed' and tb.cid = '".$cid."'", $this->db);
//$sql_res = mysql_query("SELECT * from tbl_customer_master where cid = '".$cid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get vtid API
* Get vtid must be POST method
* cid : <customer id>
* API URL : http://dev7.edreamz2.com/taxiapp/api/estfare/
*/
private function estfare(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
$min = $this->_request['min'];
$km = $this->_request['km'];
if($did=="")
{
array_push($arr,"Please Enter Driver Id.");
}
if($min=="")
{
array_push($arr,"Please Enter Min.");
}
if($km=="")
{
array_push($arr,"Please Enter KM.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT price_per_min,price_per_km,min_price FROM `tbl_vehicle_master` WHERE did = '".$did."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res = "";
//$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
//$res[] = ($result_res["price_per_min"] * $min) + ($result_res["price_per_km"] * $km);
$res = (($result_res["price_per_min"] * $min) + ($result_res["price_per_km"] * $km))+$result_res["min_price"];
//$res[]=$result_res;
}
$success = array("status" => "true", "items" => "".$res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
private function getallcust(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM `tbl_customer_master` WHERE is_activate='1' and is_deleted='0'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
######################################## EMERGENCY NO #################################
/*
* Simple Get All Emergency No API
* Get All Emergency No POST method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallemergencyno/
*/
private function getallemergencyno(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_emergency WHERE is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
######################################## EMERGENCY NO END #################################
######################################## Favorite Destination #################################
/*
* Simple Add Favorite Destination API
* Add Favorite Destination POST method
* tbid : <Taxi Booking ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/addfavoritedestination/
*/
private function addfavoritedestination(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
if($tbid=="" || $tbid==0)
{
array_push($arr,"Please Enter Booking ID.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$fvdt=date("Y-m-d H:i:s");
$is_activate=1;
$is_deleted=0;
$insert_sql = "insert into tbl_favorite_destination (tbid, fvdt, action_date, is_activate, is_deleted) values ('".$tbid."', '".$fvdt."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_favorite_destination WHERE fdid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get Favorite Destination By cid API
* Get Get Favorite Destination By cid POST method
* cid : <Taxi Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getfavoritedestinationbycid/
*/
private function getfavoritedestinationbycid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tb.tbid,tb.booking_to,tb.booking_to_lat,tb.booking_to_lng FROM tbl_favorite_destination fd inner join tbl_taxi_booking tb on tb.tbid = fd.tbid and tb.cid ='$cid'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get All Destination By cid API
* Get Get All Destination By cid POST method
* cid : <Taxi Customer ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/getalldestinationbycid/
*/
private function getalldestinationbycid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT tbid,booking_to,booking_to_lat,booking_to_lng FROM tbl_taxi_booking where tbid not in (SELECT tbid from tbl_favorite_destination) and cid ='$cid'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
######################################## Favorite Destination END #################################
######################################## Go Loyal #################################
/*
* Simple Add Go Loyal API
* Add Go Loyal POST method
* tbid : <Taxi Booking ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/addgoloyal/
*/
private function addgoloyal(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
if($tbid=="" || $tbid==0)
{
array_push($arr,"Please Enter Booking ID.");
}
$sql_cid = mysql_query("SELECT cid FROM tbl_taxi_booking WHERE tbid='$tbid' and cid in (select cid from tbl_taxi_booking_payment) ", $this->db);
if(mysql_num_rows($sql_cid) < 0)
{
array_push($arr,"Passenger should not completed his first trip.");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$gldt=date("Y-m-d H:i:s");
$is_activate=0;
$is_deleted=0;
$insert_sql = "insert into tbl_goloyal (tbid, gldt, action_date, is_activate, is_deleted) values ('".$tbid."', '".$gldt."', '".$action_date."', '".$is_activate."', '".$is_deleted."')";
$sql = mysql_query($insert_sql, $this->db);
$insert_id=mysql_insert_id();
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_goloyal WHERE glid = '$insert_id'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
######################################## Go Loyal END #################################
/*
* Simple Add Go Loyal API
* Add Go getfixedfarecharges method
* API URL : http://dev9.edreamz3.com/taxiapp/api/getfixedfarecharges/
*/
private function getfixedfarecharges(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$data=array();
$sql_res = mysql_query("SELECT fixedfare FROM tbl_fixedfarecharge WHERE is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Get booking payment count API
* cid : <customer id>
* API URL : http://dev7.edreamz2.com/taxiapp/api/getbookingpaymentcnt/
*/
private function getbookingpaymentcnt(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Customer Id.");
}
if(count($arr)==0)
{
$data=array();
$action_dt=date("Y-m-d");
$sql_res = mysql_query("SELECT offer, (SELECT COUNT( * ) FROM `tbl_taxi_booking_payment` WHERE cid = '$cid' ) AS cnt FROM `tbl_offer_master` WHERE is_activate =1 AND is_deleted =0 and validfrom <= '$action_dt' and validto >= '$action_dt'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* API URL : http://dev9.edreamz3.com/taxiapp/api/getallvtype/
*/
private function getallvtype(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$data=array();
$sql_res = mysql_query("SELECT * FROM tbl_vehicle_type_master where is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$res=array();
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$res[]=$result_res;
}
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// Cancel Booking By Driver
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/cancelbookingbydid/
private function cancelbookingbydid(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter tbsid.");
}
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter did");
}
if(count($arr)==0)
{
$action_date=date("Y-m-d H:i:s");
$update_sql = "update tbl_taxi_booking_status set status='Canceled', droped_date='".$action_date."' where tbsid = '".$tbsid."' and did = '".$did."'";
$sql = mysql_query($update_sql, $this->db);
$res=array();
$sql_res = mysql_query("SELECT * FROM tbl_taxi_booking_status WHERE tbsid = '".$tbsid."' and did = '".$did."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// Cancel Booking By Driver Push
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/cancelbookingbydidpush/
private function cancelbookingbydidpush(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbsid = $this->_request['tbsid'];
if($tbsid=="")
{
array_push($arr,"Please Enter tbsid.");
}
if(count($arr)==0)
{
$res=array();
$pushmsg = "";
$cid="";
$sql_res = mysql_query("SELECT tb.cid,dm.fname, dm.lname, dm.phone_no, dm.driver_noplate, tb.booking_from, tb.booking_to FROM `tbl_driver_master` dm INNER JOIN `tbl_vehicle_master` vm ON vm.did = dm.did INNER JOIN `tbl_taxi_booking_status` bs ON bs.did = dm.did INNER JOIN `tbl_taxi_booking` tb ON tb.tbid = bs.tbid WHERE bs.status = 'Canceled' AND bs.tbsid = '".$tbsid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Booking Cancelled By Driver Name: ".$result_res["fname"]." ".$result_res["lname"]." Phone No: ".$result_res["phone_no"]." Taxi Number Plate: ".$result_res["driver_noplate"]." Booking From: ".$result_res["booking_from"]." Booking To: ".$result_res["booking_to"];
$cid = $result_res["cid"];
}
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $cid,
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Booking Cancelled"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($curl))
$success = array("status" => "true", "msg" => "Push Send");
else
$success = array("status" => "false", "msg" => "Push Fail");
$this->api_response($this->json($success), 200);
exit;
}
else
{
$msg = "Push Not Send";
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// All Current Booking of Driver
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/currentbookingdrivers/
private function currentbookingdrivers(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter cid");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT dm.fname, dm.lname, dm.phone_no, dm.driver_noplate, vm.made, vm.modelno FROM `tbl_driver_master` dm INNER JOIN `tbl_vehicle_master` vm ON vm.did = dm.did INNER JOIN `tbl_taxi_booking_status` bs ON bs.did = dm.did INNER JOIN `tbl_taxi_booking` tb ON tb.tbid = bs.tbid WHERE bs.status = 'Accepted' AND tb.cid='".$cid."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// All Current Booking of Passenger
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/currentbookingpassengers/
private function currentbookingpassengers(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$did = $this->_request['did'];
if($did=="")
{
array_push($arr,"Please Enter did");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT cm.fname, cm.lname, cm.phone_no, tb.booking_from, tb.booking_to FROM `tbl_customer_master` cm INNER JOIN `tbl_taxi_booking` tb ON cm.cid = tb.cid INNER JOIN `tbl_taxi_booking_status` bs ON bs.tbid = tb.tbid WHERE bs.did ='".$did."'", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// Terms & Condition
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/termscond/
private function termscond(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT term FROM tbl_term WHERE is_activate =1 AND is_deleted =0", $this->db);
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// All Current Booking of Passenger
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/goloyalcredit/
private function goloyalcredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$cid = $this->_request['cid'];
if($cid=="")
{
array_push($arr,"Please Enter Cid");
}
if(count($arr)==0)
{
$res=array();
$sql_res = mysql_query("SELECT tb.booking_from, tb.booking_to, tb.booking_time, tbp.total_km, tbp.total_min, tbp.total_fare, tbp.final_total FROM tbl_taxi_booking tb INNER JOIN tbl_taxi_booking_payment tbp ON tb.tbid = tbp.tbid INNER JOIN tbl_customer_master cm ON cm.cid = tb.cid WHERE cm.cid = '".$cid."' AND tbp.paymode = 'Go Loyal'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/getcredit/
private function getcredit(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
if(count($arr)==0)
{
$res=array();
$action_dt=date("Y-m-d");
$sql_res = mysql_query("SELECT oid, offer_reason, offer, validfrom, validto FROM `tbl_offer_master` WHERE is_activate =1 AND is_deleted =0 and validfrom <= '$action_dt' and validto >= '$action_dt'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
$result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC);
$res[]=$result_res;
$success = array("status" => "true", "items" => $res);
$this->api_response($this->json($success), 200);
exit;
}
else
{
$error = array("status" => "false", "msg" => 'No Record Found.' );
$this->api_response($this->json($error), 400);
exit;
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Simple Payment Receipt to Customer/Driver API
* Send Payment Receipt on Payment Completion to Driver/Customer
* tbid : <Booking ID>
* API URL : http://dev9.edreamz3.com/taxiapp/api/paymentreceiptdrivercustomer/
*/
private function paymentreceiptdrivercustomer(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$tbid = $this->_request['tbid'];
if($tbid=="")
{
array_push($arr,"Please Enter Booking ID.");
}
if(count($arr)==0)
{
$data=array();
$sql_res_db = mysql_query("SELECT total_km, total_min,final_total,did,cid FROM tbl_taxi_booking_payment WHERE tbid='".$tbid."' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_db) > 0)
{
while($result_res_db = mysql_fetch_array($sql_res_db,MYSQL_ASSOC))
{
$sql_res_b = mysql_query("SELECT collected_date,droped_date FROM tbl_taxi_booking_status WHERE tbid='".$tbid."' and status='Completed' and is_activate=1 and is_deleted=0", $this->db);
if(mysql_num_rows($sql_res_b) > 0)
{
$total_km = $result_res_db["total_km"];
$total_min = $result_res_db["total_min"];
$final_total = $result_res_db["final_total"];
$result_res_b = mysql_fetch_array($sql_res_b,MYSQL_ASSOC);
$collected_date = stripslashes($result_res_b["collected_date"]);
$droped_date = stripslashes($result_res_b["droped_date"]);
$did = $result_res_db["did"];
$sql_res_d = mysql_query("SELECT fname,lname,emailid FROM tbl_driver_master WHERE did='".$did."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_d = mysql_fetch_array($sql_res_d,MYSQL_ASSOC);
$drivername = stripslashes($result_res_d["fname"]." ".$result_res_d["lname"]);
$driveremail = stripslashes($result_res_d["emailid"]);
$cid = $result_res_db["cid"];
$sql_res_c = mysql_query("SELECT fname,lname,phone_no,emailid FROM tbl_customer_master WHERE cid='".$cid."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_c = mysql_fetch_array($sql_res_c,MYSQL_ASSOC);
$pasgname = stripslashes($result_res_c["fname"]." ".$result_res_c["lname"]);
$pasgmobile = stripslashes($result_res_c["phone_no"]);
$pasgemail = stripslashes($result_res_c["emailid"]);
$sql_res_tb = mysql_query("SELECT booking_from_lat,booking_from_lng,booking_from,booking_to_lat,booking_to_lng,booking_to,booking_time FROM tbl_taxi_booking WHERE tbid='".$tbid."' and is_activate=1 and is_deleted=0", $this->db);
$result_res_tb = mysql_fetch_array($sql_res_tb,MYSQL_ASSOC);
$booking_from_lat = stripslashes($result_res_tb["booking_from_lat"]);
$booking_from_lng = stripslashes($result_res_tb["booking_from_lng"]);
$booking_to_lat = stripslashes($result_res_tb["booking_to_lat"]);
$booking_to_lng = stripslashes($result_res_tb["booking_to_lng"]);
$booking_from = stripslashes($result_res_tb["booking_from"]);
$booking_to = stripslashes($result_res_tb["booking_to"]);
$booking_time = stripslashes($result_res_tb["booking_time"]);
$body1 = "<font face=verdana size=2>";
$body1 .= "<strong>Driver Name:</strong> ".$drivername."<br/>";
$body1 .= "<strong>Booking Date Time:</strong> ".$booking_time."<br/>";
$body1 .= "<strong>Passenger Name:</strong> ".$pasgname."<br/>";
$body1 .= "<strong>Passenger Mob:</strong> ".$pasgmobile."<br/>";
$body1 .= "<strong>Booking From:</strong> ".$booking_from."<br/>";
$body1 .= "<strong>Booking To:</strong> ".$booking_to."<br/>";
$body1 .= "<strong>Collected Time:</strong> ".$collected_date."<br/>";
$body1 .= "<strong>Dropped Time:</strong> ".$droped_date."<br/>";
$body1 .= "<strong>Total KM:</strong> ".$total_km."<br/>";
$body1 .= "<strong>Total Time in minutes:</strong> ".$total_min."<br/>";
$body1 .= "<strong>Total Fare:</strong> ".$final_total."<br/>";
$map = 'https://maps.googleapis.com/maps/api/staticmap?path=color:0xff0000ff%7Cweight:5%7C'.$booking_from_lat.','.$booking_from_lng.'%7C'.$booking_to_lat.','.$booking_to_lng.'&size=512x512';
$body1 .= "<strong>View Road Map of Travel:</strong> <a href=\"".$map."\">Click Here</a><br/>";
$body1 .= "</font>";
$emsubject = "Passenger Receipt from EZYGO.CO.NZ";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: noreply@ezygo.co.nz' . "\r\n" .
'Reply-To: noreply@ezygo.co.nz' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
//$driveremail = "corpsoftsol@gmail.com";
mail($driveremail, $emsubject, $body1, $headers);
mail($pasgemail, $emsubject, $body1, $headers);
//echo $driveremail;
//echo "SENT";
}
}
}
}
}
// API URL : http://ezygo.co.nz/ftpserver/taxiapp/api/paymentconfirm/
private function paymentconfirm(){
if($this->get_api_request_method() != "POST"){
$this->api_response('',406);
}
$arr = array();
$pid = $this->_request['pid'];
if($pid=="")
{
array_push($arr,"Please Enter pid.");
}
if(count($arr)==0)
{
$res=array();
$pushmsg = "";
$cid="";
$sql_res = mysql_query("SELECT cid,paymode,total_km,total_min,total_fare from `tbl_taxi_booking_payment` where pid = '".$pid."'", $this->db);
if(mysql_num_rows($sql_res) > 0)
{
while($result_res = mysql_fetch_array($sql_res,MYSQL_ASSOC))
{
$pushmsg = "Payment Done Successfully. Payment Mode: ".$result_res["paymode"].", Total KM: ".$result_res["total_km"].", Total Min: ".$result_res["total_min"].", Total Fare: ".$result_res["total_fare"];
$cid = $result_res["cid"];
}
$APPLICATION_ID = "EwtvZ084bz37sdbhUpA8UGgDSjJ3QWzuVxWnxomD";
$REST_API_KEY = "0mULy8Hapo6DPPTpaxTFot4i1vrIXb9FWJEJjvSc";
$url = 'https://api.parse.com/1/push';
$data = array(
'where' => array(
'cid' => $cid,
),
'expiry' => 1451606400,
'data' => array('alert'=>"$pushmsg",'sound'=>"cheering.caf",'badge'=>"Increment",'title'=>"Payment Done"),
);
$_data = json_encode($data);
$headers = array(
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($curl))
$success = array("status" => "true", "msg" => "Push Send");
else
$success = array("status" => "false", "msg" => "Push Fail");
$this->api_response($this->json($success), 200);
exit;
}
else
{
$msg = "Push Not Send";
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
}
}
else{
for ($i=0;$i<count($arr);$i++)
{
$msg .= $arr[$i]."<br>";
}
$error = array("status" => "false", "msg" => $msg );
$this->api_response($this->json($error), 400);
exit;
}
}
/*
* Encode array into JSON
*/
private function json($data){
if(is_array($data)){
return json_encode($data);
}
}
}
$api = new API;
$api->processApi();
?>
Comments
Post a Comment