Commit f899048d by Tobin

Merge branch 'jansa' into 'master'

Jansa See merge request !94
parents 0eb3a948 b8b13356
...@@ -42,7 +42,7 @@ class Api_model extends CI_Model { ...@@ -42,7 +42,7 @@ class Api_model extends CI_Model {
function register($data) { function register($data) {
try{ try{
$email = $data['email_id']; $email = $data['email_id'];
$phone = $data['phone']; $phone = preg_replace('/\D/', '', $data['phone']);
$res_count = $res_count =
$this->db->query("SELECT * FROM customer $this->db->query("SELECT * FROM customer
INNER JOIN `users` ON users.id=customer.customer_id AND users.user_type='3' INNER JOIN `users` ON users.id=customer.customer_id AND users.user_type='3'
......
...@@ -103,6 +103,7 @@ class Webservice_model extends CI_Model { ...@@ -103,6 +103,7 @@ class Webservice_model extends CI_Model {
try{ try{
$is_email_available = "true"; $is_email_available = "true";
$is_phone_available = "true"; $is_phone_available = "true";
$data['phone'] = preg_replace('/\D/', '', $data['phone']);
$res_count = $this->db->where('email',$data['email'])->or_where('phone',$data['phone'])->get('customer')->result(); $res_count = $this->db->where('email',$data['email'])->or_where('phone',$data['phone'])->get('customer')->result();
if(count($res_count) > 0) { if(count($res_count) > 0) {
foreach ($res_count as $rs) { foreach ($res_count as $rs) {
...@@ -130,7 +131,7 @@ class Webservice_model extends CI_Model { ...@@ -130,7 +131,7 @@ class Webservice_model extends CI_Model {
function register($data) { function register($data) {
try{ try{
$email = $data['email']; $email = $data['email'];
$phone = $data['phone']; $phone = preg_replace('/\D/', '', $data['phone']);
$res_count = $this->db->query("SELECT * FROM customer $res_count = $this->db->query("SELECT * FROM customer
INNER JOIN `users` ON users.id=customer.customer_id AND users.user_type='3' INNER JOIN `users` ON users.id=customer.customer_id AND users.user_type='3'
WHERE users.status!='2' AND WHERE users.status!='2' AND
...@@ -1759,25 +1760,27 @@ class Webservice_model extends CI_Model { ...@@ -1759,25 +1760,27 @@ class Webservice_model extends CI_Model {
public function sync_contacts($data){ public function sync_contacts($data){
$user_id = $this->auth_token_get($data['auth_token']); $user_id = $this->auth_token_get($data['auth_token']);
$respArr = array('status'=>0,'code'=>'918','message'=>'Something Went Wrong..Try Again'); $respArr = array('status'=>0,'code'=>'918','message'=>'Data Missing');
if(empty($data)){ if(empty($data)){
return $respArr; return $respArr;
} }
$phNumbers = ''; $phNumbers = '';
foreach($data['contacts'] AS $key => $number) { foreach($data['contacts'] AS $key => $number) {
$number = preg_replace('/\D/', '', $number);
$eCond = ($key != count($data['contacts'])-1)?' OR ':''; $eCond = ($key != count($data['contacts'])-1)?' OR ':'';
if(strlen($number) > 10){ if(strlen($number) > 9){
$phNumbers .= " phone LIKE '%".substr($number, strlen($number)-10)."' ".$eCond; $phNumbers .= " phone LIKE '%".substr($number, strlen($number)-9)."' ".$eCond;
} else { } else {
$phNumbers .= " phone LIKE '%".$number."' ".$eCond; $phNumbers .= " phone LIKE '%".$number."' ".$eCond;
} }
} }
$result = $this->db->query("SELECT name,phone,profile_image FROM customer WHERE (".$phNumbers.") AND customer_id NOT IN (SELECT from_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2')) AND customer_id NOT IN (SELECT to_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2'))"); $result = $this->db->query("SELECT customer_id,name,phone,profile_image FROM customer WHERE (".$phNumbers.") AND customer_id NOT IN (SELECT from_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2')) AND customer_id NOT IN (SELECT to_user FROM chats WHERE (from_user=$user_id AND type='2') OR (to_user =$user_id AND type='2'))");
if(!empty($result) && !empty($result = $result->result_array())){
$respArr['status'] = 1; $respArr['status'] = 1;
if(!empty($result) && !empty($result = $result->result_array())){
$respArr['data'] = $result; $respArr['data'] = $result;
}else{
$respArr['message'] = 'No Data Found';
} }
return $respArr; return $respArr;
} }
...@@ -1809,7 +1812,7 @@ class Webservice_model extends CI_Model { ...@@ -1809,7 +1812,7 @@ class Webservice_model extends CI_Model {
public function get_friend_requests($data){ public function get_friend_requests($data){
$respArr = array('status'=>0,'code'=>'918','message'=>'No Request for you'); $respArr = array('status'=>0,'code'=>'918','message'=>'No Request for you');
$user_id = $this->auth_token_get($data['auth_token']); $user_id = $this->auth_token_get($data['auth_token']);
$this->db->select("name,phone,profile_image"); $this->db->select("name,phone,profile_image,customer_id");
$this->db->join('customer','customer.customer_id = chats.to_user'); $this->db->join('customer','customer.customer_id = chats.to_user');
$result=$this->db->get_where('chats',array('to_user'=>$user_id,'type'=>'0'))->result_array(); $result=$this->db->get_where('chats',array('to_user'=>$user_id,'type'=>'0'))->result_array();
if(!empty($result)){ if(!empty($result)){
...@@ -1828,7 +1831,7 @@ class Webservice_model extends CI_Model { ...@@ -1828,7 +1831,7 @@ class Webservice_model extends CI_Model {
if($value['to_user'] == $user_id && $value['type'] == 0){ if($value['to_user'] == $user_id && $value['type'] == 0){
continue; continue;
} }
$this->db->select("name,phone,profile_image"); $this->db->select("name,phone,profile_image,customer_id");
$cust = $this->db->get_where('customer',array('customer_id'=>$value['to_user'])); $cust = $this->db->get_where('customer',array('customer_id'=>$value['to_user']));
if(!empty($cust) && !empty($cust = $cust->row_array())){ if(!empty($cust) && !empty($cust = $cust->row_array())){
$custData[] = $cust; $custData[] = $cust;
......
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