Commit 19016293 by Jansa Jose

online status

parent f552d7b6
......@@ -25,7 +25,7 @@
//define("PAYSTACK_SECRET_KEY", "sk_live_ac1f5350a42852fd3439fdac8ba1d434f1c42360");
define("PAYSTACK_SECRET_KEY", "sk_test_dae3d816baeeabcab5063def4aad5fe546e9758d");
date_default_timezone_set('Asia/Kolkata');
date_default_timezone_set("Africa/Lagos");
}
// customer_login
public function customer_login(){
......
......@@ -24,6 +24,7 @@
$this->load->library('form_validation');
define("PAYSTACK_SECRET_KEY", "sk_live_ac1f5350a42852fd3439fdac8ba1d434f1c42360");
date_default_timezone_set("Africa/Lagos");
}
// customer_login
......@@ -259,5 +260,31 @@
$respArr = $this->Webservice_mechanic_model->start_service($postData,1);
echo json_encode($respArr);exit;
}
public function update_profile_status(){
header('Content-type: application/json');
$headers = apache_request_headers();
if(!isset($headers['auth']) || empty($headers['auth'])){
$respArr['status'] = 'error';
$respArr['message'] = 'Authtoken is Required';
echo json_encode($respArr);exit;
}
$authRes = $this->Webservice_mechanic_model->get_mechanic_authtoken($headers['auth']);
if($authRes['status'] == 'error'){
echo json_encode($respArr);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
if(!isset($postData['status']) ){
$respArr['message'] = "Online status is Required";
echo json_encode($respArr) ;exit;
}
$postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$respArr = $this->Webservice_mechanic_model->update_profile_status($postData);
echo json_encode($respArr);exit;
}
}
?>
......@@ -2,7 +2,7 @@
class Webservice_mechanic_model extends CI_Model {
function __construct() {
parent::__construct();
date_default_timezone_set('Asia/Kolkata');
date_default_timezone_set("Africa/Lagos");
}
/***************************************************************************************/
/****************************************Mobile API's***********************************/
......@@ -200,5 +200,16 @@ public function start_service($postData = array(),$type = 0){
}
return $respArr;
}
public function update_profile_status($postData = array()){
$respArr = array('status'=>'error');
if(empty($postData)){
return $respArr;
}
if($this->db->update('mechanic',array('is_online'=>$postData['status']),array('mechanic_id'=>$postData['mechanic_id']))){
$respArr['status'] = "success";
$respArr['data']['profile_status'] = $postData['status'];
}
return $respArr;
}
}
?>
......@@ -2,7 +2,7 @@
class Webservice_model extends CI_Model {
function __construct() {
parent::__construct();
date_default_timezone_set('Asia/Kolkata');
date_default_timezone_set("Africa/Lagos");
}
/*************************************************************************************************/
/****************************************Mobile API's*********************************************/
......@@ -464,11 +464,13 @@ class Webservice_model extends CI_Model {
$current_lat = $postData['location_lat'];
$current_lng = $postData['location_lng'];
$issue_cat_id = (isset($postData['is_emergency']) && $postData['is_emergency'] == 1)?'':$postData['service_id'];
$limt = "";
if($start != 0 || $per_page != 0){
$limt = "limit ".$start.",".$per_page;
}else{
$limt = "";
}
$cond = (isset($postData['is_emergency']) && $postData['is_emergency'] == 1)?" AND ME.is_online='1'":"";
$sql = "SELECT AU.display_name,AU.profile_image,ME.*,MS.shop_name,MS.address AS shop_address,
MS.phone AS shop_phone,MS.email_id AS shop_email_id,
3956*2*ASIN(SQRT(POWER(SIN(($current_lat-ME.location_lat)*pi()/180/2),2)+
......@@ -477,7 +479,7 @@ class Webservice_model extends CI_Model {
FROM mechanic AS ME
INNER JOIN admin_users AS AU ON (AU.id=ME.mechanic_id)
LEFT JOIN mechanic_shop AS MS ON (MS.shop_id=ME.shop_id AND MS.status='1')
WHERE AU.status='1'
WHERE AU.status='1' $cond
HAVING distance<10
".$limt;
$mechData = $this->db->query($sql);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment