Commit 420b3c8d by Jansa Jose

Merge branch 'master' into 'dev_production'

Master See merge request !71
parents 40a0bedb d3c07698
...@@ -521,7 +521,7 @@ ...@@ -521,7 +521,7 @@
$url = ""; $url = "";
$searchType = $postData['type']; $searchType = $postData['type'];
$searchData = $postData['vehicleData']; //$searchData = $postData['vehicleData'];
$locationData = $postData['location']; $locationData = $postData['location'];
$vehicle_data['status'] = '1'; $vehicle_data['status'] = '1';
...@@ -530,6 +530,16 @@ ...@@ -530,6 +530,16 @@
$vehicle_data['car_loc_lng'] = $locationData['location_lng']; $vehicle_data['car_loc_lng'] = $locationData['location_lng'];
$vehicle_data['car_location'] = $locationData['location']; $vehicle_data['car_location'] = $locationData['location'];
$last_date ='';
if(isset($postData['vehicleData']['lastMaintanceDate']) && !empty($postData['vehicleData']['lastMaintanceDate'])){
$vehicle_data['last_maintenance_date'] = $postData['vehicleData']['lastMaintanceDate'];
}
$last_maintanence_date ='';
if(isset($postData['vehicleData']['maintanence_interval']) && !empty($postData['vehicleData']['maintanence_interval'])){
$vehicle_data['maintanence_interval'] = $postData['vehicleData']['maintanence_interval'];
}
$this->load->model('Settings_model'); $this->load->model('Settings_model');
$settings = $this->Settings_model->settings_viewing(); $settings = $this->Settings_model->settings_viewing();
...@@ -1415,7 +1425,7 @@ ...@@ -1415,7 +1425,7 @@
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($postdata)); //Post Fields curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($postdata));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
...@@ -1480,7 +1490,8 @@ ...@@ -1480,7 +1490,8 @@
} }
} }
public function fail($ref='',$payFor='1'){ public function fail($ref='',$payFor='1',$mobile='0'){
if($mobile == '0'){
$settings = getSettings(); $settings = getSettings();
if($payFor == '1'){ if($payFor == '1'){
$url = $settings['web_url']."/dashboard?status=failure&tab=appointment&ref=".$ref; $url = $settings['web_url']."/dashboard?status=failure&tab=appointment&ref=".$ref;
...@@ -1489,22 +1500,22 @@ ...@@ -1489,22 +1500,22 @@
$url = $settings['web_url']."/purchaseHome?status=failure&ref=".$ref; $url = $settings['web_url']."/purchaseHome?status=failure&ref=".$ref;
header("Location:".$url); header("Location:".$url);
} }
} } else {
redirect('Webservices/mobPayFailed');
public function success($ref='',$payFor='1'){
if($payFor == '1'){
$this->serviceBookSuccess($ref);
}else{
$this->orderPlacedSuccess($ref);
} }
} }
public function serviceBookSuccess($ref=''){ public function mobPayFailed(){}
$this->db->select('customer_vehicle.car_name,bookings.scheduled_date,bookings.scheduled_time public function mobPaySuccess(){}
,customers.email,bookings.cost');
public function success($ref='',$payFor='1',$mobile='0'){
if($payFor == '1'){
$this->db->select('customer_vehicle.car_name,bookings.scheduled_date,
bookings.scheduled_time,customers.email,bookings.cost');
$this->db->from('transaction'); $this->db->from('transaction');
$this->db->join('bookings','transaction.booking_id = bookings.booking_id'); $this->db->join('bookings','transaction.booking_id = bookings.booking_id');
$this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id'); $this->db->join('customer_vehicle',
'customer_vehicle.customer_veh_id = bookings.customer_veh_id');
$this->db->join('customers','customers.customer_id = bookings.customer_id'); $this->db->join('customers','customers.customer_id = bookings.customer_id');
$this->db->where('transaction.id',$ref); $this->db->where('transaction.id',$ref);
$bookData = $this->db->get()->row(); $bookData = $this->db->get()->row();
...@@ -1521,17 +1532,21 @@ ...@@ -1521,17 +1532,21 @@
$message = str_replace(array('{:car_name}','{:book_date}','{:amount}'),array($bookData->car_name,$bookData->scheduled_date,$bookData->cost),$template['success_booking']); $message = str_replace(array('{:car_name}','{:book_date}','{:amount}'),array($bookData->car_name,$bookData->scheduled_date,$bookData->cost),$template['success_booking']);
} }
send_mail($subject,$email_id,$message); send_mail($subject,$email_id,$message);
}
if($mobile == '1'){
redirect('Webservices/mobPaySuccess');
} else {
$settings = getSettings(); $settings = getSettings();
if($payFor == '1'){
$url = $settings['web_url']."/dashboard?status=success&tab=appointment&ref=".$ref; $url = $settings['web_url']."/dashboard?status=success&tab=appointment&ref=".$ref;
header("Location: ".$url); header("Location: ".$url);
} } else {
public function orderPlacedSuccess($ref=''){
$settings = getSettings();
$url = $settings['web_url']."/track?ref=".$ref; $url = $settings['web_url']."/track?ref=".$ref;
header("Location: ".$url); header("Location: ".$url);
} }
}
}
//Search Products //Search Products
public function productSearch(){ public function productSearch(){
...@@ -1596,6 +1611,25 @@ ...@@ -1596,6 +1611,25 @@
echo json_encode($result);exit; echo json_encode($result);exit;
} }
public function brand_details(){
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_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$result = $this->Webservice_model->getBrands('1');
echo json_encode($result);exit;
}
//Search Product By Brand //Search Product By Brand
public function productSearchbyBrand(){ public function productSearchbyBrand(){
header('Content-type:application/json'); header('Content-type:application/json');
...@@ -1718,13 +1752,14 @@ ...@@ -1718,13 +1752,14 @@
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
$postData['user_id'] = $authRes['data']['customer_id'];
$per_page = 10; $per_page = 10;
$page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1; $page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1;
$start = ($page - 1) * $per_page; $start = ($page - 1) * $per_page;
$productResult = $this->Webservice_model->get_latest_product_list(0,0); $productResult = $this->Webservice_model->get_latest_product_list(0,0);
$productList = $this->Webservice_model->get_latest_product_list($start,$per_page); $productList = $this->Webservice_model->get_latest_product_list($start,$per_page,$postData);
$product = array(); $product = array();
$total = 0; $total = 0;
...@@ -1787,13 +1822,14 @@ ...@@ -1787,13 +1822,14 @@
echo json_encode($authRes);exit; echo json_encode($authRes);exit;
} }
$postData['user_id'] = $authRes['data']['customer_id'];
$per_page = 10; $per_page = 10;
$page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1; $page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1;
$start = ($page - 1) * $per_page; $start = ($page - 1) * $per_page;
$productResult = $this->Webservice_model->get_trending_product_list(0,0); $productResult = $this->Webservice_model->get_trending_product_list(0,0);
$productList = $this->Webservice_model->get_trending_product_list($start,$per_page); $productList = $this->Webservice_model->get_trending_product_list($start,$per_page,$postData);
$product = array(); $product = array();
$total = 0; $total = 0;
...@@ -1858,6 +1894,7 @@ ...@@ -1858,6 +1894,7 @@
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post,true); $postData = json_decode($post,true);
$postData['user_id'] = $authRes['data']['customer_id'];
$result = $this->Webservice_model->SingleProductSearch($postData); $result = $this->Webservice_model->SingleProductSearch($postData);
echo json_encode($result);exit; echo json_encode($result);exit;
...@@ -2076,6 +2113,28 @@ ...@@ -2076,6 +2113,28 @@
echo json_encode($result);exit; echo json_encode($result);exit;
} }
public function cancel_order(){
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_model->get_customer_authtoken($headers['Auth']);
if($authRes['status'] == 'error'){
echo json_encode($authRes);exit;
}
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$result = $this->Webservice_model->cancelOrder($postData);
echo json_encode($result);exit;
}
public function getCartData(){ public function getCartData(){
header('Content-type:application/json'); header('Content-type:application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
...@@ -2364,6 +2423,7 @@ ...@@ -2364,6 +2423,7 @@
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post,true); $postData = json_decode($post,true);
$postData['user_id'] = $authRes['data']['customer_id'];
$per_page = 10; $per_page = 10;
...@@ -2436,6 +2496,7 @@ ...@@ -2436,6 +2496,7 @@
$post = file_get_contents("php://input"); $post = file_get_contents("php://input");
$postData = json_decode($post,true); $postData = json_decode($post,true);
$postData['user_id'] = $authRes['data']['customer_id'];
$per_page = 10; $per_page = 10;
...@@ -2607,29 +2668,30 @@ ...@@ -2607,29 +2668,30 @@
header('Content-type:application/json'); header('Content-type:application/json');
$headers = apache_request_headers(); $headers = apache_request_headers();
if(!isset($headers['Auth']) || empty($headers['Auth'])){ $post = file_get_contents("php://input");
$this->fail(); if(empty($post) || empty($postData = json_decode($post,true)) ||
!isset($postData['Auth']) || empty($postData['Auth']) ||
!isset($postData['data']) || empty($postData['data'])){
$this->fail('','','1');
} }
$authRes = $this->Webservice_model->get_customer_authtoken($headers['Auth']); $authRes = $this->Webservice_model->get_customer_authtoken($postData['Auth']);
if($authRes['status'] == 'error'){ if($authRes['status'] == 'error'){
$this->fail(); $this->fail('','','1');
} }
$post = file_get_contents("php://input");
$postData = json_decode($post, true);
$postData['customer_id'] = $authRes['data']['customer_id']; $postData['customer_id'] = $authRes['data']['customer_id'];
$result = $this->Webservice_model->bulkOrderBooking($postData); $result = $this->Webservice_model->bulkOrderBooking($postData);
if($result['status'] == 'success'){ if($result['status'] == 'success'){
$this->orderPayNowApi($result['data']); $this->orderPayNowApi($result['data']);
} }
$this->fail(); $this->fail('','','1');
} }
public function orderPayNowApi($transId=''){ public function orderPayNowApi($transId=''){
if(empty($transId)){ if(empty($transId)){
$this->fail(); $this->fail('','','1');
} }
$orderData = $this->Webservice_model->getOrderPayDetailsApi($transId); $orderData = $this->Webservice_model->getOrderPayDetailsApi($transId);
...@@ -2674,7 +2736,7 @@ ...@@ -2674,7 +2736,7 @@
public function verify_payment_api($transId='',$payFor='1') { public function verify_payment_api($transId='',$payFor='1') {
if(empty($transId)){ if(empty($transId)){
$this->fail(); $this->fail('','','1');
} }
$result = array(); $result = array();
...@@ -2698,20 +2760,19 @@ ...@@ -2698,20 +2760,19 @@
if($result){ if($result){
if($result['data']){ if($result['data']){
if($result['data']['status'] == 'success'){ if($result['data']['status'] == 'success'){
header("Location:".base_url('Webservices/success/'.$transId.'/'.$payFor)); header("Location:".base_url('Webservices/success/'.$transId.'/'.$payFor.'/1'));
}else{ } else {
header("Location:".base_url('Webservices/fail/'.$transId.'/'.$payFor)); header("Location:".base_url('Webservices/fail/'.$transId.'/'.$payFor.'/1'));
}
} }
else{ } else {
header("Location: ".base_url('Webservices/fail/'.$transId.'/'.$payFor)); header("Location: ".base_url('Webservices/fail/'.$transId.'/'.$payFor.'/1'));
} }
}else{ } else {
header("Location: ".base_url('Webservices/fail/'.$transId.'/'.$payFor)); header("Location: ".base_url('Webservices/fail/'.$transId.'/'.$payFor.'/1'));
} }
} }
}else{ }else{
header("Location: ".base_url('Webservices/fail/'.$transId.'/'.$payFor)); header("Location: ".base_url('Webservices/fail/'.$transId.'/'.$payFor.'/1'));
} }
} }
...@@ -2725,6 +2786,29 @@ ...@@ -2725,6 +2786,29 @@
$result = $this->Webservice_model->socialLogin($postData); $result = $this->Webservice_model->socialLogin($postData);
echo json_encode($result);exit; echo json_encode($result);exit;
} }
public function getCustRemainders(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$result = $this->Webservice_model->getCustRemainders($postData);
echo json_encode($result);exit;
}
public function changeReminderStatus(){
header('Content-type:application/json');
$headers = apache_request_headers();
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$this->load->model('Vehicle_model');
$result = $this->Vehicle_model->changeReminderStatus($postData);
echo json_encode($result);exit;
}
} }
......
...@@ -208,9 +208,9 @@ class Booking_model extends CI_Model { ...@@ -208,9 +208,9 @@ class Booking_model extends CI_Model {
BK.customer_veh_id,BK.scheduled_date,BK.scheduled_time,BK.cost,BK.status,BK.mileage, BK.customer_veh_id,BK.scheduled_date,BK.scheduled_time,BK.cost,BK.status,BK.mileage,
BK.issues_selected,VEH.car_name,BK.custom_issue_data,VEH.car_model,VEH.car_maker, BK.issues_selected,VEH.car_name,BK.custom_issue_data,VEH.car_model,VEH.car_maker,
VEH.car_model_year,VEH.car_vin,VEH.vehicle_data,BK.car_location,BK.car_loc_lat, VEH.car_model_year,VEH.car_vin,VEH.vehicle_data,BK.car_location,BK.car_loc_lat,
BK.car_loc_lng,CUST.first_name AS custFirstName,CUST.last_name AS custLastName,CUST.phone, BK.car_loc_lng,CUST.first_name AS custFirstName,CUST.last_name AS custLastName,
CUST.email,CUST.address,CUST.profile_image,CUST.date_of_birth,CUSQTE.custom_id, CUST.phone,CUST.email,CUST.address,CUST.profile_image,CUST.date_of_birth,
MBK.status AS mech_status CUSQTE.custom_id,MBK.status AS mech_status
FROM bookings AS BK FROM bookings AS BK
INNER JOIN mechanic_booking AS MBK ON (MBK.booking_id=BK.booking_id) INNER JOIN mechanic_booking AS MBK ON (MBK.booking_id=BK.booking_id)
INNER JOIN customers AS CUST ON (CUST.customer_id=BK.customer_id) INNER JOIN customers AS CUST ON (CUST.customer_id=BK.customer_id)
......
...@@ -183,8 +183,6 @@ class Mechanic_model extends CI_Model { ...@@ -183,8 +183,6 @@ class Mechanic_model extends CI_Model {
foreach($mechData AS $index => $data){ foreach($mechData AS $index => $data){
$data['distance'] = (int)$data['distance']; $data['distance'] = (int)$data['distance'];
if(empty($data['start_time']) || empty($data['end_time'])){ if(empty($data['start_time']) || empty($data['end_time'])){
//$scheduleTiming = array('09:00 AM','10:00 AM','11:00 AM','12:00 PM','01:00 PM',
// '02:00 PM','03:00 PM','04:00 PM','05:00 PM','06:00 PM');
$scheduleTiming = array( $scheduleTiming = array(
strtotime(date('Y-m-d 09:00'))*1000, strtotime(date('Y-m-d 09:00'))*1000,
strtotime(date('Y-m-d 10:00'))*1000, strtotime(date('Y-m-d 10:00'))*1000,
...@@ -206,7 +204,6 @@ class Mechanic_model extends CI_Model { ...@@ -206,7 +204,6 @@ class Mechanic_model extends CI_Model {
$scheduleTiming = array(); $scheduleTiming = array();
for( ; $schTime <= ($endTime-3600) ; $schTime += 3600){ for( ; $schTime <= ($endTime-3600) ; $schTime += 3600){
//$scheduleTiming[] = date('h:i A',$schTime);
$scheduleTiming[] = $schTime * 1000; $scheduleTiming[] = $schTime * 1000;
} }
} }
......
...@@ -132,7 +132,7 @@ class Vehicle_model extends CI_Model { ...@@ -132,7 +132,7 @@ class Vehicle_model extends CI_Model {
return $last_id; return $last_id;
} }
function updateVehModel($model_id = '', $model_data = array()){ public function updateVehModel($model_id = '', $model_data = array()){
if(empty($model_id) || empty($model_data)){ if(empty($model_id) || empty($model_data)){
return 0; return 0;
} }
...@@ -140,5 +140,16 @@ class Vehicle_model extends CI_Model { ...@@ -140,5 +140,16 @@ class Vehicle_model extends CI_Model {
return ($status)?1:0; return ($status)?1:0;
} }
public function changeReminderStatus($postData = array()){
$respArr = array('status'=>'error');
if(empty($postData)){
$respArr['message'] = 'All Field is Required';
}
if($this->db->update('customer_vehicle',array('enable_notification'=>$postData['status']),array('customer_veh_id'=>$postData['customer_veh_id']))){
$respArr['status'] = 'success';
}
return $respArr;
}
} }
?> ?>
\ No newline at end of file
...@@ -279,18 +279,21 @@ class Webservice_model extends CI_Model { ...@@ -279,18 +279,21 @@ class Webservice_model extends CI_Model {
$respArr['message'] = 'All Field is required'; $respArr['message'] = 'All Field is required';
return $respArr; return $respArr;
} }
$insert_array = array('cost'=>$postData['total_cost'],'mechanic_id'=>$postData['mechanic_id'],'scheduled_date'=>date('Y-m-d',$postData['date']/1000),'scheduled_time'=>$postData['time'],'issues_selected'=>json_encode($postData['service_id'])); $insert_array = array('cost'=>$postData['total_cost'],'scheduled_date'=>date('Y-m-d',$postData['date']/1000),'scheduled_time'=>$postData['time'],'issues_selected'=>json_encode($postData['service_id']));
if($this->db->update('bookings',$insert_array,array('booking_id'=>$postData['booking_id']))){ 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'=>$postData['total_cost'],'status'=>'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,mechanic_shop.shop_name as mechanic_shop,mechanic.address,mechanic.phone,admin_users.profile_image as image,bookings.mileage,bookings.issues_selected"); $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,mechanic_shop.shop_name as mechanic_shop,mechanic.address,mechanic.phone,admin_users.profile_image as image,bookings.mileage,bookings.issues_selected");
$this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id'); $this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id');
$this->db->join('mechanic','bookings.mechanic_id = mechanic.mechanic_id'); $this->db->join("mechanic_booking","mechanic_booking.booking_id = bookings.booking_id AND mechanic_booking.mechanic_id =".$postData['mechanic_id'],'left');
$this->db->join('mechanic','mechanic_booking.mechanic_id = mechanic.mechanic_id');
$this->db->join('admin_users','admin_users.id = mechanic.mechanic_id'); $this->db->join('admin_users','admin_users.id = mechanic.mechanic_id');
$this->db->join('mechanic_shop','mechanic_shop.shop_id = mechanic.shop_id','left'); $this->db->join('mechanic_shop','mechanic_shop.shop_id = mechanic.shop_id','left');
$mech_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id'])); $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())){ if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$mech_veh_data = json_decode($mechanic_data['vehicle_data']); $mech_veh_data = json_decode($mechanic_data['vehicle_data']);
$mechanic_data['engine_no'] = $mech_veh_data->attributes->Engine; $mechanic_data['engine_no'] = !empty($mech_veh_data->attributes->Engine)?$mech_veh_data->attributes->Engine:'';
$mechanic_data['vehicle_trim'] = $mech_veh_data->attributes->Trim; $mechanic_data['vehicle_trim'] = !empty($mech_veh_data->attributes->Trim)?$mech_veh_data->attributes->Trim:'';
unset($mechanic_data['vehicle_data']); unset($mechanic_data['vehicle_data']);
$mechanic_data['services'] = json_decode($mechanic_data['issues_selected']); $mechanic_data['services'] = json_decode($mechanic_data['issues_selected']);
unset($mechanic_data['issues_selected']); unset($mechanic_data['issues_selected']);
...@@ -309,13 +312,15 @@ class Webservice_model extends CI_Model { ...@@ -309,13 +312,15 @@ class Webservice_model extends CI_Model {
$respArr['message'] = 'Booking Id is required'; $respArr['message'] = 'Booking Id is required';
return $respArr; return $respArr;
} }
$this->db->select("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,bookings.mileage,bookings.issues_selected,bookings.custom_issue_data,bookings.mechanic_id"); $this->db->select("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,bookings.mileage,bookings.issues_selected,bookings.custom_issue_data,mechanic_booking.mechanic_id");
$this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id'); $this->db->join('customer_vehicle','customer_vehicle.customer_veh_id = bookings.customer_veh_id');
$mech_data = $this->db->get_where('bookings',array('booking_id'=>$postData['booking_id'])); $this->db->join("mechanic_booking","mechanic_booking.booking_id = bookings.booking_id AND mechanic_booking.status = '1'",'left');
$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())){ if(!empty($mech_data) && !empty($mechanic_data = $mech_data->row_array())){
$mech_veh_data = json_decode($mechanic_data['vehicle_data']); $mech_veh_data = json_decode($mechanic_data['vehicle_data']);
$mechanic_data['engine_no'] = $mech_veh_data->attributes->Engine; $mechanic_data['engine_no'] = !empty($mech_veh_data->attributes->Engine)?$mech_veh_data->attributes->Engine:'';
$mechanic_data['vehicle_trim'] = $mech_veh_data->attributes->Trim; $mechanic_data['vehicle_trim'] = !empty($mech_veh_data->attributes->Trim)?$mech_veh_data->attributes->Trim:'';
unset($mechanic_data['vehicle_data']); unset($mechanic_data['vehicle_data']);
$mechanic_data['services'] = json_decode($mechanic_data['issues_selected']); $mechanic_data['services'] = json_decode($mechanic_data['issues_selected']);
if(!empty($mechanic_data['services'])){ if(!empty($mechanic_data['services'])){
...@@ -622,6 +627,14 @@ class Webservice_model extends CI_Model { ...@@ -622,6 +627,14 @@ class Webservice_model extends CI_Model {
$lmt .= "LIMIT $start,$per_page"; $lmt .= "LIMIT $start,$per_page";
} }
$cartSel = '';
$cartJoin = '';
if(isset($postData['user_id']) && !empty($postData['user_id'])){
$cartSel = ',CRT.cart_id';
$cartJoin = "LEFT JOIN cart AS CRT ON
(CRT.product_id=PRD.product_id AND CRT.customer_id=".$postData['user_id'].")";
}
$where = ''; $where = '';
if(isset($postData['key']) && !empty($postData['key'])){ if(isset($postData['key']) && !empty($postData['key'])){
$where .= " (PRD.product_name LIKE '%".$postData['key']."%' OR $where .= " (PRD.product_name LIKE '%".$postData['key']."%' OR
...@@ -655,14 +668,14 @@ class Webservice_model extends CI_Model { ...@@ -655,14 +668,14 @@ class Webservice_model extends CI_Model {
} }
$result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating, $result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating,
COUNT(REV.id) AS count,PRD.*,PI.image COUNT(REV.id) AS count,PRD.*,PI.image".$cartSel."
FROM products AS PRD FROM products AS PRD
LEFT JOIN cardetails AS CRD ON (PRD.cardetail_id=CRD.id) LEFT JOIN cardetails AS CRD ON (PRD.cardetail_id=CRD.id)
LEFT JOIN product_rating AS REV ON (REV.product_id=PRD.product_id) LEFT JOIN product_rating AS REV ON (REV.product_id=PRD.product_id)
LEFT JOIN vehicles_model AS VEHM ON (VEHM.veh_modal_id=CRD.veh_modal_id) LEFT JOIN vehicles_model AS VEHM ON (VEHM.veh_modal_id=CRD.veh_modal_id)
LEFT JOIN product_images AS PI ON (PI.id= LEFT JOIN product_images AS PI ON (PI.id=
(SELECT MIN(id) FROM product_images (SELECT MIN(id) FROM product_images
WHERE product_id=PRD.product_id AND PRD.status='1')) WHERE product_id=PRD.product_id AND PRD.status='1')) ".$cartJoin."
WHERE $where PRD.status='1' WHERE $where PRD.status='1'
GROUP BY PRD.product_id,PI.product_id $lmt"); GROUP BY PRD.product_id,PI.product_id $lmt");
...@@ -677,16 +690,21 @@ class Webservice_model extends CI_Model { ...@@ -677,16 +690,21 @@ class Webservice_model extends CI_Model {
return $respArr; return $respArr;
} }
public function getBrands(){ public function getBrands($type='0'){
$respArr = array('status'=>'error'); $respArr = array('status'=>'error');
$prdt_brand = $this->db->get_where('product_brand',array('status'=>'1'))->result(); $prdt_brand = $this->db->get_where('product_brand',array('status'=>'1'))->result();
if(count($prdt_brand) > 0){ if(count($prdt_brand) > 0){
$query = $this->db->query("SELECT MIN(amount) AS minamount, MAX(amount) AS maxamount $query = $this->db->query("SELECT MIN(amount) AS minamount, MAX(amount) AS maxamount
FROM products WHERE status='1'")->row(); FROM products WHERE status='1'")->row();
$respArr['status'] = 'success'; $respArr['status'] = 'success';
$respArr['brands'] = $prdt_brand; if($type == '0'){
$respArr['minamount'] = $query->minamount; $respArr['minamount'] = $query->minamount;
$respArr['maxamount'] = $query->maxamount; $respArr['maxamount'] = $query->maxamount;
$respArr['brands'] = $prdt_brand;
}else{
$respArr['data'] = $prdt_brand;
}
} }
return $respArr; return $respArr;
} }
...@@ -897,6 +915,7 @@ class Webservice_model extends CI_Model { ...@@ -897,6 +915,7 @@ class Webservice_model extends CI_Model {
return $respArr; return $respArr;
} }
$this->db->delete('cart',array('customer_id'=>$postData['customer_id']));
$bulk_flag = 0; $bulk_flag = 0;
$bulkUnqueId = ''; $bulkUnqueId = '';
if(($bulk_flag = count($postData['data'])) > 1){ if(($bulk_flag = count($postData['data'])) > 1){
...@@ -1044,14 +1063,23 @@ class Webservice_model extends CI_Model { ...@@ -1044,14 +1063,23 @@ class Webservice_model extends CI_Model {
return $respArr; return $respArr;
} }
public function get_latest_product_list($start = '',$per_page=''){ public function get_latest_product_list($start = '',$per_page='',$postData=array()){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.'); $respArr = array('status'=>'error','message'=>'Something Went Wrong.');
$lmt = ''; $lmt = '';
if($start != 0 || $per_page != 0){ if($start != 0 || $per_page != 0){
$lmt .= "LIMIT $start,$per_page"; $lmt .= "LIMIT $start,$per_page";
} }
$cartSel = '';
$cartJoin = '';
if(isset($postData['user_id']) && !empty($postData['user_id'])){
$cartSel = ',CRT.cart_id';
$cartJoin = "LEFT JOIN cart AS CRT ON
(CRT.product_id=PRD.product_id AND CRT.customer_id=".$postData['user_id'].")";
}
$result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating, $result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating,
COUNT(REV.id) AS reviews,PRD.*,PI.image as product_image,BRND.brand_name COUNT(REV.id) AS reviews,PRD.*,PI.image as product_image,BRND.brand_name".$cartSel."
FROM products AS PRD FROM products AS PRD
LEFT JOIN product_images AS PI ON LEFT JOIN product_images AS PI ON
(PI.id=(SELECT MIN(id) (PI.id=(SELECT MIN(id)
...@@ -1059,7 +1087,7 @@ class Webservice_model extends CI_Model { ...@@ -1059,7 +1087,7 @@ class Webservice_model extends CI_Model {
WHERE product_id= PRD.product_id AND WHERE product_id= PRD.product_id AND
PRD.status='1')) PRD.status='1'))
LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id
JOIN product_brand AS BRND ON BRND.brand_id = PRD.brand_id JOIN product_brand AS BRND ON BRND.brand_id = PRD.brand_id ".$cartJoin."
WHERE PRD.status='1' WHERE PRD.status='1'
GROUP BY PRD.product_id,PI.product_id GROUP BY PRD.product_id,PI.product_id
ORDER BY PRD.product_id DESC ORDER BY PRD.product_id DESC
...@@ -1076,18 +1104,27 @@ class Webservice_model extends CI_Model { ...@@ -1076,18 +1104,27 @@ class Webservice_model extends CI_Model {
return $respArr; return $respArr;
} }
public function get_trending_product_list($start='',$per_page=''){ public function get_trending_product_list($start='',$per_page='',$postData=array()){
$respArr = array('status'=>'error','message'=>'Something Went Wrong.'); $respArr = array('status'=>'error','message'=>'Something Went Wrong.');
$lmt = ''; $lmt = '';
if($start != 0 || $per_page != 0){ if($start != 0 || $per_page != 0){
$lmt .= "LIMIT $start,$per_page"; $lmt .= "LIMIT $start,$per_page";
} }
$cartSel = '';
$cartJoin = '';
if(isset($postData['user_id']) && !empty($postData['user_id'])){
$cartSel = ',CRT.cart_id';
$cartJoin = "LEFT JOIN cart AS CRT ON
(CRT.product_id=PRD.product_id AND CRT.customer_id=".$postData['user_id'].")";
}
$sql = $this->db->query("SELECT COUNT(ORDS.product_id) as count,PRD.product_id FROM products PRD LEFT JOIN orders AS ORDS ON ORDS.product_id = PRD.product_id WHERE PRD.status='1' GROUP BY PRD.product_id ORDER BY count DESC $lmt "); $sql = $this->db->query("SELECT COUNT(ORDS.product_id) as count,PRD.product_id FROM products PRD LEFT JOIN orders AS ORDS ON ORDS.product_id = PRD.product_id WHERE PRD.status='1' GROUP BY PRD.product_id ORDER BY count DESC $lmt ");
if(!empty($sql) && $sql->num_rows() > 0){ if(!empty($sql) && $sql->num_rows() > 0){
foreach ($sql->result_array() as $key => $value) { foreach ($sql->result_array() as $key => $value) {
$result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating, $result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating,
COUNT(REV.id) AS reviews,PRD.*,PI.image as product_image,BRND.brand_name COUNT(REV.id) AS reviews,PRD.*,PI.image as product_image,BRND.brand_name".$cartSel."
FROM products AS PRD FROM products AS PRD
LEFT JOIN product_images AS PI ON LEFT JOIN product_images AS PI ON
(PI.id=(SELECT MIN(id) (PI.id=(SELECT MIN(id)
...@@ -1095,7 +1132,7 @@ class Webservice_model extends CI_Model { ...@@ -1095,7 +1132,7 @@ class Webservice_model extends CI_Model {
WHERE product_id= PRD.product_id AND WHERE product_id= PRD.product_id AND
PRD.status='1')) PRD.status='1'))
LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id LEFT JOIN product_rating AS REV ON REV.product_id = PRD.product_id
JOIN product_brand AS BRND ON BRND.brand_id = PRD.brand_id JOIN product_brand AS BRND ON BRND.brand_id = PRD.brand_id ".$cartJoin."
WHERE PRD.status='1' AND PRD.product_id =".$value['product_id']); WHERE PRD.status='1' AND PRD.product_id =".$value['product_id']);
if(!empty($result) && $result->num_rows() > 0){ if(!empty($result) && $result->num_rows() > 0){
$result = $result->row_array(); $result = $result->row_array();
...@@ -1122,7 +1159,7 @@ class Webservice_model extends CI_Model { ...@@ -1122,7 +1159,7 @@ class Webservice_model extends CI_Model {
} }
$result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating, $result = $this->db->query("SELECT ROUND(AVG(REV.rating),2) AS rating,
COUNT(REV.id) AS reviews,PRD.product_name,PRD.short_description,PRD.part_id,TRANS.id AS transId, COUNT(REV.id) AS reviews,PRD.product_name,PRD.short_description,PRD.part_id,TRANS.id AS transId,
TRANS.status AS tranStatus,TRANS.datetime,ORD.*,PI.image as product_image TRANS.status AS tranStatus,TRANS.datetime,ORD.*,PI.image as product_image,BRND.brand_name
FROM orders ORD FROM orders ORD
JOIN products PRD ON ORD.product_id = PRD.product_id JOIN products PRD ON ORD.product_id = PRD.product_id
JOIN transaction TRANS ON (ORD.order_id = TRANS.booking_id AND TRANS.payment_for= '2') JOIN transaction TRANS ON (ORD.order_id = TRANS.booking_id AND TRANS.payment_for= '2')
...@@ -1133,6 +1170,8 @@ class Webservice_model extends CI_Model { ...@@ -1133,6 +1170,8 @@ class Webservice_model extends CI_Model {
FROM product_images FROM product_images
WHERE product_id= PRD.product_id AND WHERE product_id= PRD.product_id AND
PRD.status='1')) PRD.status='1'))
JOIN product_brand AS BRND ON BRND.brand_id = PRD.brand_id
WHERE ORD.customer_id=".$postData['customer_id']." GROUP BY ORD.order_id ORDER BY ORD.order_id DESC $lmt"); WHERE ORD.customer_id=".$postData['customer_id']." GROUP BY ORD.order_id ORDER BY ORD.order_id DESC $lmt");
if(empty($result) || empty($result = $result->result())){ if(empty($result) || empty($result = $result->result())){
$respArr['status'] = "error"; $respArr['status'] = "error";
...@@ -1313,7 +1352,54 @@ class Webservice_model extends CI_Model { ...@@ -1313,7 +1352,54 @@ class Webservice_model extends CI_Model {
$respArr['status'] = 1; $respArr['status'] = 1;
return $respArr; return $respArr;
} }
}
public function getCustRemainders($postData=array()){
$respArr = array('status'=>'error');
if(empty($cust_id = $postData['customer_id'])){
$respArr['message'] = 'Customer Id is Required' ;
}
$new = array();
$result = $this->db->get_where('customer_vehicle',
array('customer_id'=>$cust_id,'enable_notification'=>'1','status'=>'1'));
if(!empty($result) && !empty($result = $result->result_array())){
foreach ($result AS $veh_value) {
$veh_id = $veh_value['customer_veh_id'];
$this->db->where('customer_veh_id',$veh_id);
$this->db->where_in('status',array('1','3'));
$this->db->order_by('booking_id','DESC');
$lstBok = $this->db->get("bookings");
$lastMainDate = $veh_value['last_maintenance_date'];
if(!empty($lstBok) && $lstBok->num_rows() > 0 && !empty($lstBok = $lstBok->row_array())){
if(strtotime($lstBok['scheduled_date']) > strtotime($lastMainDate)){
$lastMainDate = $lstBok['scheduled_date'];
}
}
if(empty($lastMainDate)){
continue;
}
$interval = (!empty($veh_value['maintanence_interval']))?$veh_value['maintanence_interval']:6;
$newMainDate = strtotime(date("Y-m-d", strtotime($lastMainDate)) . " +".$interval." month");
$remindDate = strtotime(date("Y-m-d", $newMainDate) . " -10 days");
if(strtotime(date('Y-m-d')) >= $remindDate){
$veh_value['last_maintenance_date'] = $lastMainDate;
$veh_value['next_maintenance_date'] = date('Y-m-d',$newMainDate);
$new[] = $veh_value;
}
}
if(count($new) > 0){
$respArr['status'] = 'success';
$respArr['data'] = $new;
}
}
return $respArr;
} }
} }
......
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