Commit 64baf8eb by Jansa Jose

Merge branch 'master' into 'local_production'

Master See merge request !226
parents 737edd7d f305528d
......@@ -34,7 +34,7 @@ class Bookings extends CI_Controller {
$template['mechanic_id'] = ($this->session->userdata('user_type')==1 &&
empty($mechanic_id))?'':$mechanic_id;
$template['mechanic_data'] = $mechanic_data;
$template['bookingData'] = $this->Booking_model->getMechBookings($mechanic_id,'','0,1,3,4');
$template['bookingData'] = $this->Booking_model->getMechBookings($mechanic_id,'','0,1,3,4,6');
$this->load->view('template',$template);
}
......
......@@ -387,7 +387,6 @@ class Vehicle extends CI_Controller {
$results = '<option value="-1">No Trims</option>';
if($result){
$trim = array();
// $results = '<option value="-1">Choose Vehicle Trim</option>';
$results = '';
foreach ($result as $key => $trim) {
if(empty($trim->trim)){
......@@ -403,19 +402,12 @@ class Vehicle extends CI_Controller {
public function get_all_activity(){
$data = $_GET;
$columns = array("vehicles.year","vehicles_brand.maker","vehicle_models.model_name","vehicles.trim","vehicles.engine","vehicles.status");
$value['search'] = $data['search']['value'];
$value['start'] = $data['start'];
$value['length'] = $data['length'];
// $search_box = array('bookingId','name','operatorName','travelDate','mobile','amount','payType','Action');
$limit = count($data['columns']);
$value['where'] = '';
$where_data = array();
if(!empty($value['search'])) {
$where = array();
foreach($columns as $c) {
......@@ -425,21 +417,15 @@ class Vehicle extends CI_Controller {
$where = "(".$where.")";
$value['where'] = $where;
}
$value['order_type'] = $data['order'][0]['dir'];
$activity = $this->Vehicle_model->get_activity($value);
$all_activity = $this->Vehicle_model->get_activity();
$filtered = count($all_activity);
$filtered = count($all_activity);
if($value['where']!='') {
$value['length'] = '-1';
$page_activity = $this->Vehicle_model->get_activity($value);
$filtered = count($page_activity);
}
$data = array();
if($activity) {
foreach ($activity as $r) {
......@@ -457,7 +443,6 @@ class Vehicle extends CI_Controller {
"<a class='btn btn-sm btn-success' href=changeModelStatus/".encode_param($r->veh_id)."/1>
<i class='fa fa-cog'></i> Activate
</a>";
array_push($data, array(
$r->year,
$r->maker,
......@@ -469,9 +454,7 @@ class Vehicle extends CI_Controller {
));
}
}
echo json_encode(array('recordsFiltered' => $filtered, 'recordsTotal' => count($all_activity), 'data' => $data));
}
}
?>
\ No newline at end of file
......@@ -25,14 +25,13 @@
//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(){
header('Content-type: application/json');
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
//pr($postData);
$this->load->model('Customer_model');
$respArr = array('status'=>'0','message'=>'Required Fields are empty.');
if(!isset($postData['email']) || empty($postData['email']) ||
......@@ -144,7 +143,7 @@
$respArr['status'] = '2';
$respArr['message'] = 'Email Address already in use';
echo json_encode($respArr);exit;
} else if($custResp == '3'){
} else if($custResp == '3'){
$respArr['status'] = '2';
$respArr['message'] = 'Phone already in use';
echo json_encode($respArr);exit;
......@@ -425,7 +424,6 @@
}
echo json_encode($respArr);exit;
}
// addCustomerCar
public function addCustomerCar(){
header('Content-type: application/json');
......
......@@ -24,6 +24,7 @@
$this->load->library('form_validation');
define("PAYSTACK_SECRET_KEY", "sk_live_ac1f5350a42852fd3439fdac8ba1d434f1c42360");
date_default_timezone_set("Africa/Lagos");
}
// customer_login
......@@ -53,8 +54,7 @@
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$postData = $_GET;
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
$start = ($page - 1) * $per_page;
......@@ -134,11 +134,10 @@
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$postData = $_GET;
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
$start = ($page - 1) * $per_page;
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$bookDataCount = $this->Webservice_mechanic_model->getBookedService($postData,0,0,0,3);
$bookDataResult=$this->Webservice_mechanic_model->getBookedService($postData,$start,$per_page,0,3);
......@@ -259,5 +258,63 @@
$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;
}
public function add_location(){
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['location']) && empty($postData['location'])){
$respArr['message'] = "Location is Required";
echo json_encode($respArr) ;exit;
}else if(!isset($postData['location_lng']) && empty($postData['location_lng'])){
$respArr['message'] = "Longitude is Required";
echo json_encode($respArr) ;exit;
}else if(!isset($postData['location_lat']) && empty($postData['location_lat'])){
$respArr['message'] = "Latitude is Required";
echo json_encode($respArr) ;exit;
}
$postData['mechanic_id'] = $authRes['data']['mechanic_id'];
$respArr = $this->Webservice_mechanic_model->add_location($postData);
echo json_encode($respArr);exit;
}
}
?>
......@@ -274,6 +274,16 @@ class Booking_model extends CI_Model {
array('status'=>'2'),
array('booking_id'=>$booking_id,'mechanic_id'=> $id));
}
else if($status == '6'){
$this->db->update('bookings',
array('status'=>'6'),
array('booking_id'=>$booking_id));
}
else if($status == '3'){
$this->db->update('bookings',
array('status'=>'3'),
array('booking_id'=>$booking_id));
}
}
return $status;
}
......
......@@ -140,7 +140,7 @@ class Vehicle_model extends CI_Model {
if($filter) {
if($filter['length']!=-1)
$this->db->limit($filter['length'], $filter['start']);
$this->db->order_by("model", $filter['order_type']);
$this->db->order_by("model", $filter['order_type']);
if(!empty($filter['where'])) {
$this->db->where($filter['where']);
......
......@@ -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***********************************/
......@@ -11,7 +11,7 @@ function checkMechanicLogin($userLogData){
if(empty($userLogData)){
return $respArr;
}
$this->db->select("MCH.mechanic_id as user_id,TRIM(CONCAT(MCH.first_name,' ' ,IFNULL(MCH.last_name,''))) as name,MCH.email_id,MCH.phone as phone_number,IFNULL(MCHSHP.shop_name,'') as workshop_name,MCH.city,MCH.location as place");
$this->db->select("MCH.mechanic_id as user_id,TRIM(CONCAT(MCH.first_name,' ' ,IFNULL(MCH.last_name,''))) as name,MCH.email_id,MCH.phone as phone_number,IFNULL(MCHSHP.shop_name,'') as workshop_name,MCH.city,MCH.location as place,MCH.is_online");
$this->db->from('admin_users as AU');
$this->db->join('mechanic as MCH','MCH.mechanic_id = AU.id');
$this->db->join('mechanic_shop as MCHSHP','MCHSHP.shop_id = MCH.shop_id','LEFT');
......@@ -200,5 +200,28 @@ 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;
}
public function add_location($postData){
$respArr = array('status'=>'error');
if(empty($postData)){
return $respArr;
}
if($this->db->update('mechanic',array('location'=>$postData['location'],'location_lat'=>$postData['location_lat'],'location_lng'=>$postData['location_lng']),array('mechanic_id'=>$postData['mechanic_id']))){
$respArr['status'] = "success";
$respArr['message'] = "Location Updated Successfully";
}
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*********************************************/
......@@ -374,7 +374,7 @@ class Webservice_model extends CI_Model {
'car_location'=> $car_location,'car_loc_lat'=>$car_loc_lat,'car_loc_lng'=>$car_loc_lng
);
if($this->db->update('bookings',$insert_array,array('booking_id'=>$postData['booking_id']))){
$this->db->insert("mechanic_booking",array('booking_id'=>$postData['booking_id'],'mechanic_id'=>$postData['mechanic_id'],'amount'=>$cost,'status'=>'0'));
$this->db->insert("mechanic_booking",array('booking_id'=>$postData['booking_id'],'mechanic_id'=>$postData['mechanic_id'],'amount'=>$cost,'status'=>(isset($postData['is_emergency']) && !empty($postData['is_emergency']))?1:0));
$this->db->select("bookings.scheduled_time,bookings.scheduled_date,customer_vehicle.car_model as vehicle_model,customer_vehicle.car_maker as vehicle_make,customer_vehicle.car_model_year as vehicle_year,customer_vehicle.vehicle_data,TRIM(concat(mechanic.first_name,' ',IFNULL(mechanic.last_name,''))) as mechanic_name,bookings.service_type,mechanic_shop.shop_name as mechanic_shop,mechanic.address,mechanic.phone,mechanic.device_id,admin_users.profile_image as image,bookings.mileage,bookings.issues_selected,bookings.customer_id");
$this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id');
......@@ -386,7 +386,7 @@ class Webservice_model extends CI_Model {
$mech_data = $this->db->get_where('bookings',array('bookings.booking_id'=>$postData['booking_id']));
if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$this->db->insert('transaction',array('customer_id'=>$mechanic_data['customer_id'],'booking_id'=>$postData['booking_id'],'payment_for'=>'1','datetime'=>date('Y-m-d h:i:s'),'amount'=>$cost));
$this->db->insert('transaction',array('customer_id'=>$mechanic_data['customer_id'],'booking_id'=>$postData['booking_id'],'payment_for'=>'1','datetime'=>date('Y-m-d h:i:s'),'amount'=>$cost,'status'=>(isset($postData['is_emergency']) && !empty($postData['is_emergency']))?1:2));
$mechanic_data['trans_id'] = $this->db->insert_id();
$mech_veh_data = json_decode($mechanic_data['vehicle_data']);
......@@ -397,7 +397,7 @@ class Webservice_model extends CI_Model {
$mechanic_data['services'] = json_decode($mechanic_data['issues_selected']);
unset($mechanic_data['issues_selected']);
}
$mechanic_data['scheduled_date'] = strtotime($mechanic_data['scheduled_date']);
$mechanic_data['scheduled_date'] = strval(strtotime($mechanic_data['scheduled_date'])*1000);
$respArr['status'] = 'success';
$respArr['message'] = 'success';
$respArr['data'] = $mechanic_data;
......@@ -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);
......@@ -1612,7 +1614,6 @@ class Webservice_model extends CI_Model {
AND VEHM.model_name LIKE '$veh_data->model'"
);
}
//pr($this->db->last_query());
if(!empty($result) && $result->num_rows() > 0 && !empty($data = $result->row())){
$respArr['data'] = $data;
$respArr['status'] = 'success';
......
......@@ -100,6 +100,7 @@
case 1: echo 'Accepted'; break;
case 3: echo 'Completed'; break;
case 4: echo 'Cancelled'; break;
case 6: echo 'Work in Progress'; break;
}
} else {
switch($bookData->mech_status){
......@@ -134,7 +135,18 @@
<i class="fa fa-cog"></i> Accept
</a>
<?php }
} ?>
if($bookData->status == 1 && $bookData->mech_status == 1){ ?>
<a class="btn btn-sm btn-info" href="<?= base_url("Bookings/changeBookingStatus/".encode_param($bookData->booking_id)."/6/".encode_param($mechanic_id)) ?>">
<i class="fa fa-cog"></i> Start Service
</a>
<?php
}
if($bookData->status == 6 && $bookData->mech_status == 1){ ?>
<a class="btn btn-sm btn-warning" href="<?= base_url("Bookings/changeBookingStatus/".encode_param($bookData->booking_id)."/3/".encode_param($mechanic_id)) ?>">
<i class="fa fa-cog"></i> Stop Service
</a>
<?php
} } ?>
<a class="btn btn-sm btn-danger"
href="<?= base_url("Bookings/changeBookingStatus/".encode_param($bookData->booking_id)."/2/".encode_param($mechanic_id))?>"
onClick="return doconfirm()">
......
......@@ -67,8 +67,6 @@
});
var schedulingGrid = $('.dataTable-custom').DataTable({
/*"ordering" : $(this).data("ordering"),
"order": [[ 0, "desc" ]],*/
"processing": true,
"serverSide": true,
"ajax": "<?php echo base_url(); ?>" + $(this).data("ajax"),
......
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