Commit ac8adb32 by Jansa Jose

add cartid for apis

parent 51e41fc3
......@@ -521,7 +521,7 @@
$url = "";
$searchType = $postData['type'];
$searchData = $postData['vehicleData'];
//$searchData = $postData['vehicleData'];
$locationData = $postData['location'];
$vehicle_data['status'] = '1';
......@@ -530,6 +530,16 @@
$vehicle_data['car_loc_lng'] = $locationData['location_lng'];
$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');
$settings = $this->Settings_model->settings_viewing();
......@@ -1723,13 +1733,14 @@
echo json_encode($authRes);exit;
}
$postData['user_id'] = $authRes['data']['customer_id'];
$per_page = 10;
$page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1;
$start = ($page - 1) * $per_page;
$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();
$total = 0;
......@@ -1792,13 +1803,14 @@
echo json_encode($authRes);exit;
}
$postData['user_id'] = $authRes['data']['customer_id'];
$per_page = 10;
$page = (isset($_GET['page']) && $_GET['page'] >= 1)?(int)$_GET['page']:1;
$start = ($page - 1) * $per_page;
$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();
$total = 0;
......@@ -1863,6 +1875,7 @@
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$postData['user_id'] = $authRes['data']['customer_id'];
$result = $this->Webservice_model->SingleProductSearch($postData);
echo json_encode($result);exit;
......@@ -2369,7 +2382,8 @@
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$postData['user_id'] = $authRes['data']['customer_id'];
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
......@@ -2441,7 +2455,8 @@
$post = file_get_contents("php://input");
$postData = json_decode($post,true);
$postData['user_id'] = $authRes['data']['customer_id'];
$per_page = 10;
$page = (isset($postData['page']) && $postData['page'] >= 1)?(int)$postData['page']:1;
......
......@@ -622,6 +622,14 @@ class Webservice_model extends CI_Model {
$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 = '';
if(isset($postData['key']) && !empty($postData['key'])){
$where .= " (PRD.product_name LIKE '%".$postData['key']."%' OR
......@@ -655,14 +663,14 @@ class Webservice_model extends CI_Model {
}
$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
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 vehicles_model AS VEHM ON (VEHM.veh_modal_id=CRD.veh_modal_id)
LEFT JOIN product_images AS PI ON (PI.id=
(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'
GROUP BY PRD.product_id,PI.product_id $lmt");
......@@ -1045,14 +1053,23 @@ class Webservice_model extends CI_Model {
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.');
$lmt = '';
if($start != 0 || $per_page != 0){
$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,
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
LEFT JOIN product_images AS PI ON
(PI.id=(SELECT MIN(id)
......@@ -1060,7 +1077,7 @@ class Webservice_model extends CI_Model {
WHERE product_id= PRD.product_id AND
PRD.status='1'))
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'
GROUP BY PRD.product_id,PI.product_id
ORDER BY PRD.product_id DESC
......@@ -1077,18 +1094,27 @@ class Webservice_model extends CI_Model {
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.');
$lmt = '';
if($start != 0 || $per_page != 0){
$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 ");
if(!empty($sql) && $sql->num_rows() > 0){
foreach ($sql->result_array() as $key => $value) {
$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
LEFT JOIN product_images AS PI ON
(PI.id=(SELECT MIN(id)
......@@ -1096,7 +1122,7 @@ class Webservice_model extends CI_Model {
WHERE product_id= PRD.product_id AND
PRD.status='1'))
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']);
if(!empty($result) && $result->num_rows() > 0){
$result = $result->row_array();
......
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