Commit f8361e66 by Jansa Jose

all product list api

parent 9dc92515
......@@ -988,5 +988,11 @@
$respArr = $this->Webservice_model->get_requestacceptedgarage($postData['request_id']);
echo json_encode($respArr); exit;
}
public function all_productList(){
header('Content-type: application/json');
$respArr = $this->Webservice_model->all_productList();
echo json_encode($respArr); exit;
}
}
?>
......@@ -668,5 +668,26 @@ class Webservice_model extends CI_Model {
$respArr['data'] = $result;
return $respArr;
}
public function all_productList(){
$respArr = array('status'=>'error');
$sql = $this->db->query("SELECT id,unique_name,pos_parts_img FROM pos_parts");
if(empty($sql) || empty($result = $sql->result_array())){
$respArr['message'] = "No data Found";
return $respArr;
}
foreach ($result as $key => $value) {
$this->db->select("round(AVG(rate),2) AS rating ");
$this->db->join('pos_booking','pos_booking.id = rating.booking_id AND rating.type=3');
$this->db->join('pos_response','pos_response.id = pos_booking.resp_id');
$posRvw = $this->db->get_where('rating',array('pos_response.pos_parts'=>$value['id']));
if(!empty($posRvw) && !empty($posRvws = $posRvw->row_array())){
$result[$key]['rating'] = (empty($posRvws['rating']))?'0':$posRvws['rating'];
}
}
$respArr['status'] = "success";
$respArr['data'] = $result;
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