id,clients.company_name FROM clients INNER JOIN listings on listings.client_id=clients.client_id WHERE publish_ocd='1' and `location` = '$branches' AND emirate = ?", array("emirate" => $emirate) ) or die(mysql_error()); } else{ $query = $this->db->query( "SELECT clients.client_id,clients.company_name FROM clients INNER JOIN usedcar_listings on usedcar_listings.client_id=clients.client_id WHERE publish_ocd='1' and used_cars='$used_cars' and `location` = '$branches' AND emirate = ?", array("emirate" => $emirate) ) or die(mysql_error()); } if ($query->num_rows() > 0) { $result = $query->result_array(); foreach ($result as $val => $aRow) { $company_name2[] = $aRow['company_name']; if($used_cars==0) { $sql = $this->db->query("SELECT listings.car_type,car_types.name FROM listings inner join car_types on listings.car_type=car_types.id WHERE listings.client_id={$aRow['client_id']} group by car_type") or die(mysql_error()); } else{ $sql = $this->db->query("SELECT usedcar_listings.car_type,car_types.name FROM usedcar_listings inner join car_types on usedcar_listings.car_type=car_types.id WHERE usedcar_listings.client_id={$aRow['client_id']} and used_cars='$used_cars' group by car_type") or die(mysql_error()); } if ($sql->num_rows() > 0) { $Rresult = $sql->result_array(); foreach ($Rresult as $val2 => $aRow2) { $car_type[] = $aRow2['name']; } } else { $car_type_final = "Sedan"; } } $company_name = implode(", ", $company_name2); if (isset($car_type) && !empty($car_type)) { $car_types = array_unique($car_type); $car_type_final = implode(", ", $car_types); } $this->memcached_library->add($key_cache, array($company_name, $car_type_final, '1'), 86400); return array($company_name, $car_type_final, '1'); } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { return $check_keyword_is_newbranch; } } function check_keyword_is_branch($keyword, $emirate,$used_cars=0) { $key_cache = 'check_keyword_is_branch21@' . $keyword . '@' . $emirate.$used_cars; $check_keyword_is_branch = $this->memcached_library->get($key_cache); //$this->memcached_library->delete($key_cache); if (empty($check_keyword_is_branch)) { $this->set_memcachekeys($key_cache); if($used_cars==0) { $query = $this->db->query( "SELECT clients.client_id FROM clients INNER JOIN listings on listings.client_id=clients.client_id WHERE publish_ocd='1' and `location` = '$keyword' AND emirate = ?", array("emirate" => $emirate) ); } else{ $query = $this->db->query( "SELECT clients.client_id FROM clients INNER JOIN usedcar_listings on usedcar_listings.client_id=clients.client_id WHERE publish_ocd='1' and used_cars='$used_cars' and `location` = '$keyword' AND emirate = ?", array("emirate" => $emirate) ); } if ($query->num_rows() > 0) { $this->memcached_library->add($key_cache, 1, 86400); return 1; } else { $this->memcached_library->add($key_cache, false, 86400); return false; } } else { return $check_keyword_is_branch; } } function check_keyword_is_fast_location($keyword, $emirate) { $key_cache = 'check_keyword_is_fast_location51@' . $keyword . '@' . $emirate; $check_keyword_is_fast_location = $this->memcached_library->get($key_cache); //$this->memcached_library->delete($key_cache); if (empty($check_keyword_is_fast_location)) { $query = $this->db->query( "SELECT id FROM delivery_locations WHERE (`location` = '$keyword' OR `location_ar` = '$keyword') AND emirate = ?", array("emirate" => $emirate) ); // echo $this->db->last_query(); exit(); if ($query->num_rows() > 0) { $result = $query->row_array(); $id = $result['id']; $query2 = $this->db->query( "SELECT client_id FROM clients WHERE CONCAT(',', fast_delivery_locations, ',') like '%,$id,%' AND emirate = ?", array("emirate" => $emirate) ); if ($query2->num_rows() > 0) { $result2 = $query2->row_array(); $this->memcached_library->add($key_cache, $id, 86400); return $id; } else { $this->memcached_library->add($key_cache, false, 86400); return false; } } else { $this->memcached_library->add($key_cache, false, 86400); return false; } } else { return $check_keyword_is_fast_location; } } function check_keyword_is_make($keyword) { $key_cache = 'check_keyword_is_make@' . $keyword; $check_keyword_is_make = $this->memcached_library->get($key_cache); if (!$check_keyword_is_make && !is_numeric($check_keyword_is_make)) { $this->set_memcachekeys($key_cache); $query = $this->db->query("SELECT id,`name` FROM make WHERE `name` = ?", array("name" => $keyword)); if ($query->num_rows() > 0) { $result = $query->row_array(); $this->memcached_library->add($key_cache, array($result["id"], $result["name"]), 86400); return array($result["id"], $result["name"]); } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { return $check_keyword_is_make; } } function get_make_id_by_group_id($goup_id) { $key_cache = 'get_make_id_by_group_id@' . $goup_id; $check_keyword_is_make = $this->memcached_library->get($key_cache); if (!($check_keyword_is_make)) { $query = $this->db->query("SELECT GROUP_CONCAT(id ) as id FROM `make` WHERE `cartype`=$goup_id or `cartype1`=$goup_id or `cartype2`=$goup_id"); if ($query->num_rows() > 0) { $result = $query->row_array(); $this->memcached_library->add($key_cache, $result["id"], 86400); return $result["id"]; } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { return $check_keyword_is_make; } } function check_if_seo_url_exist($emirate,$car_model_id,$used_cars=0) { $key_cache = 'check_if_seo_url_exist_2023_@' . $emirate."@".$car_model_id.$used_cars; $check_if_seo_url_exist = $this->memcached_library->get($key_cache); if (!$check_if_seo_url_exist && !is_numeric($check_if_seo_url_exist)) { $this->set_memcachekeys($key_cache); $mysql3=mysql_query("select seo_url from admin_seo_car_model where car_model='$car_model_id' and emirate='$emirate' and category='$used_cars'") or die(mysql_error()); if(mysql_num_rows($mysql3)>0){ $row22=mysql_fetch_array($mysql3); $list['seo_url'] =$row22['seo_url']; } else { $list['seo_url'] =''; } $this->memcached_library->add($key_cache, $list, 86400); return $list; } else { return $check_if_seo_url_exist; } } function check_if_seo_urltype_exist($emirate,$car_type,$used_cars=0) { $key_cache = 'check_if_seo_urltype_exist@' . $emirate."@".$car_type.$used_cars; $check_if_seo_url_exist = $this->memcached_library->get($key_cache); if (!$check_if_seo_url_exist && !is_numeric($check_if_seo_url_exist)) { $this->set_memcachekeys($key_cache); $mysql3=mysql_query("select seo_url from admin_seo_dynamic where car_type='$car_type' and emirate='$emirate' and category='$used_cars'") or die(mysql_error()); if(mysql_num_rows($mysql3)>0){ $row22=mysql_fetch_array($mysql3); $list['seo_url'] =$row22['seo_url']; } else { $list['seo_url'] =''; } $this->memcached_library->add($key_cache, $list, 86400); return $list; } else { return $check_if_seo_url_exist; } } function buy_count($emirate3) { $key_cache = 'buy_count_203@1' . $emirate3; $check_if_seo_url_exist_model = $this->memcached_library->get($key_cache); if (!$check_if_seo_url_exist_model && !is_numeric($check_if_seo_url_exist_model)) { $this->set_memcachekeys($key_cache); $this->db->select('count(c.id) as count'); $this->db->from('usedcar_listings as l'); $this->db->join('clients as c', 'l.client_id=c.client_id'); $this->db->where('publish_ocd', '1'); $this->db->where('delete_status', '0'); $used_cars_in = array('1', '2'); $this->db->where_in('l.used_cars', $used_cars_in); // $this->db->where('l.used_cars', '1'); $this->db->where('car_type !=', '2'); $this->db->where('l.client_id !=', 247); $this->db->where('c.emirate =', $emirate3); $this->db->group_by("c.emirate"); $query = $this->db->get(); if ($query->num_rows() > 0) { $result = $query->result_array(); $i = 1; foreach ($result as $val => $aRow) { $count = $aRow['count']; $i++; } //$result = $query->row_array(); $this->memcached_library->add($key_cache, $count, 86400); return $count; } else { $this->memcached_library->add($key_cache, false, 86400); return false; } } else { return $check_if_seo_url_exist_model; } } function new_count($emirate3) { $key_cache = 'new_count@1' . $emirate3; $check_if_seo_url_exist_model = $this->memcached_library->get($key_cache); if (!$check_if_seo_url_exist_model && !is_numeric($check_if_seo_url_exist_model)) { $this->set_memcachekeys($key_cache); $this->db->select('count(c.id) as count'); $this->db->from('usedcar_listings as l'); $this->db->join('clients as c', 'l.client_id=c.client_id'); $this->db->where('publish_ocd', '1'); $this->db->where('delete_status', '0'); $this->db->where('l.used_cars', '2'); $this->db->where('car_type !=', '2'); $this->db->where('l.client_id !=', 247); $this->db->where('c.emirate =', $emirate3); $this->db->group_by("c.emirate"); $query = $this->db->get(); if ($query->num_rows() > 0) { $result = $query->result_array(); $i = 1; foreach ($result as $val => $aRow) { $count = $aRow['count']; $i++; } //$result = $query->row_array(); $this->memcached_library->add($key_cache, $count, 86400); return $count; } else { $this->memcached_library->add($key_cache, false, 86400); return false; } } else { return $check_if_seo_url_exist_model; } } function check_if_seo_url_exist_model($emirate,$car_model_id,$used_cars=0) { $key_cache = 'check_if_seo_url_exist_model_2023_1@' . $emirate."@".$car_model_id.$used_cars; $check_if_seo_url_exist_model = $this->memcached_library->get($key_cache); if (!$check_if_seo_url_exist_model && !is_numeric($check_if_seo_url_exist_model)) { $this->set_memcachekeys($key_cache); $mysql3=mysql_query("select seo_url from admin_seo_car_make where car_make='$car_model_id' and emirate='$emirate' and category='$used_cars'") or die(mysql_error()); if(mysql_num_rows($mysql3)>0){ $row22=mysql_fetch_array($mysql3); $list['seo_url'] =$row22['seo_url']; } else { $list['seo_url'] =''; } $this->memcached_library->add($key_cache, $list, 86400); return $list; } else { return $check_if_seo_url_exist_model; } } public function search_similiar_wishlist($params) { $key_cache = 'wishlist_unpublished@'.$params['listing_id'].$params['city']; $search_similiar_wishlist = $this->memcached_library->get($key_cache); if (!$search_similiar_wishlist && !is_numeric($search_similiar_wishlist)) { $this->set_memcachekeys($key_cache); $table = ($params['used_cars'] == 0) ? 'listings l' : 'usedcar_listings l'; $this->db->select('l.*, m.seo_url'); $this->db->from($table); $this->db->join('models m', 'm.id = l.car_model', 'inner'); $this->db->join('clients client', 'l.client_id = client.client_id', 'inner'); if (!empty($params['brand'])) { $this->db->where('l.car_model', $params['brand']); } if (!empty($params['model'])) { $this->db->where('l.car_make', $params['model']); } if (!empty($params['city'])) { $this->db->where('client.emirate', $params['city']); } if (!empty($params['listing_id'])) { $this->db->where('l.id !=', $params['listing_id']); } $this->db->where([ 'l.daily_price_status' => 1, 'l.publish_ocd' => 1, 'l.delete_status'=> 0 ]); $query = $this->db->get(); // echo $this->db->last_query();exit; $result = ($query->num_rows() > 0) ? $query->result_array() : []; $this->memcached_library->add($key_cache, $result, 86400); return $result; } else { return $search_similiar_wishlist; } } function fetch_seo_url($url, $language_code,$language_anchor){ $main_url = get_language_seo_url($url,$language_code); $main_url = $language_anchor.$main_url; return $main_url; } function check_similiar_cars_wishlist($country, $brand, $model, $emirate, $used_cars, $listing_id, $language_anchor, $language_code, $is_morocco_domain) { if($country!='UAE'){ $url = base_url() . 'cars-for-rent/' . strtolower(str_replace(' ', '-', $emirate)); return $url; } else { $key_cache = 'wishlist_similiar_unpublished@' . $listing_id . $brand . $model . $emirate . $used_cars; $similiar_url_cache = $this->memcached_library->get($key_cache); if (!$similiar_url_cache && !is_numeric($similiar_url_cache)) { $result1 = $this->search_similiar_wishlist([ 'brand' => $brand, 'model' => $model, 'city' => $emirate, 'used_cars' => $used_cars, 'listing_id' => $listing_id ]); if (!empty($result1)) { $makess = $this->get_name_2($brand, "models", "name"); $modelss = $this->functions_model->get_name_2($model, "make", "name,url"); if ($emirate == 'Dubai') { if (!empty($result1[0]['seo_url']) && $used_cars == 0) { $url = $result1[0]['seo_url']; } else { if ($used_cars == 0) { $url = 'cars-for-rent/' . strtolower(str_replace(' ', '-', $emirate)) . '/' . strtolower(str_replace(' ', '-', $makess['name'])) . '/' . strtolower(str_replace(' ', '-', $modelss['name'])); $url = $this->fetch_seo_url($url, $language_code,$language_anchor); } else if ($used_cars == 1) { $url = base_url() . 'buy-' . strtolower(str_replace(' ', '-', $makess['name'])) . '/' . strtolower(str_replace(' ', '-', $modelss['name'])) . "-used-cars-" . strtolower(str_replace(" ", "-", $emirate)); } } } else { if ($used_cars == 0 && $is_morocco_domain == 0) { $url = 'cars-for-rent/' . strtolower(str_replace(' ', '-', $emirate)) . '/' . strtolower(str_replace(' ', '-', $makess['name'])) . '/' . strtolower(str_replace(' ', '-', $modelss['name'])); $url = $this->fetch_seo_url($url, $language_code,$language_anchor); } if ($is_morocco_domain == 1 && $used_cars == 0) { if ($language_code == "fr") { $url = base_url() . strtolower(str_replace(" ", "-", $emirate)) . "/location-voiture" . '-' . strtolower(str_replace(' ', '-', $makess['name'])) . '-' . strtolower(str_replace(' ', '-', $modelss['name'])); } else if ($language_code != "en") { $url = base_url() . $language_code . "/" . strtolower(str_replace(" ", "-", $emirate)) . "/" . strtolower(str_replace(' ', '-', $makess['name'])) . '-' . strtolower(str_replace(' ', '-', $modelss['name'])) . "-car-rental"; } else { $url = base_url() . strtolower(str_replace(" ", "-", $emirate)) . '/' . strtolower(str_replace(' ', '-', $makess['name'])) . '-' . strtolower(str_replace(' ', '-', $modelss['name'])) . "-car-rental"; } } } } else { $result2 = $this->search_similiar_wishlist([ 'brand' => $brand, 'city' => $emirate, 'used_cars' => $used_cars, 'listing_id' => $listing_id ]); if (!empty($result2)) { $makess = $this->get_name_2($brand, "models", "name"); if ($emirate == 'Dubai') { if (!empty($result2[0]['seo_url']) && $used_cars == 0) { $url = $result2[0]['seo_url']; } else { if ($used_cars == 0) { $url = 'cars-for-rent/' . strtolower(str_replace(' ', '-', $emirate)) . '/' . strtolower(str_replace(' ', '-', $makess['name'])); $url = $this->fetch_seo_url($url, $language_code,$language_anchor); } else if ($used_cars == 1) { $url = base_url() . 'buy-' . strtolower(str_replace(' ', '-', $makess['name'])). "-used-cars-" . strtolower(str_replace(" ", "-", $emirate)); } } } else { if ($used_cars == 0 && $is_morocco_domain == 0) { $url = 'cars-for-rent/' . strtolower(str_replace(' ', '-', $emirate)) . '/' . strtolower(str_replace(' ', '-', $makess['name'])); $url = $this->fetch_seo_url($url, $language_code,$language_anchor); } if ($is_morocco_domain == 1 && $used_cars == 0) { if ($language_code == "fr") { $url = base_url() . strtolower(str_replace(" ", "-", $emirate)) . "/location-voiture" . '-' . strtolower(str_replace(' ', '-', $makess['name'])); } else if ($language_code != "en") { $url = base_url() . $language_code . "/" . strtolower(str_replace(" ", "-", $emirate)) . "/" . strtolower(str_replace(' ', '-', $makess['name'])) . "-car-rental"; } else { $url = base_url() . strtolower(str_replace(" ", "-", $emirate)) . '/' . strtolower(str_replace(' ', '-', $makess['name'])). "-car-rental"; } } } } else { $result3 = $this->search_similiar_wishlist([ 'city' => $emirate, 'used_cars' => $used_cars, 'listing_id' => $listing_id ]); if (!empty($result3)) { if ($emirate == 'Dubai') { if (!empty($result3[0]['seo_url']) && $used_cars == 0) { $url = $result3[0]['seo_url']; } else { if ($used_cars == 0) { $url = 'cars-for-rent/' . strtolower(str_replace(' ', '-', $emirate)); $url = $this->fetch_seo_url($url, $language_code,$language_anchor); } else if ($used_cars == 1) { $url = base_url() . "buy-used-cars-" . strtolower(str_replace(" ", "-", $emirate)); } } } else { if ($used_cars == 0 && $is_morocco_domain == 0) { $url = 'cars-for-rent/' . strtolower(str_replace(' ', '-', $emirate)); $url = $this->fetch_seo_url($url, $language_code,$language_anchor); } if ($is_morocco_domain == 1 && $used_cars == 0) { if ($language_code == "fr") { $url = base_url() . strtolower(str_replace(" ", "-", $emirate)); } else if ($language_code != "en") { $url = base_url() . $language_code . "/" . strtolower(str_replace(" ", "-", $emirate)); } else { $url = base_url() . strtolower(str_replace(" ", "-", $emirate)); } } } } } } $this->memcached_library->add($key_cache, $url, 86400); $this->set_memcachekeys($key_cache); return $url; } else { return $similiar_url_cache; } } } function check_keyword_is_brand($keyword) { $key_cache = 'check_keyword_is_brand_202@' . $keyword; $check_keyword_is_brand = $this->memcached_library->get($key_cache); if (!$check_keyword_is_brand && !is_numeric($check_keyword_is_brand)) { $this->set_memcachekeys($key_cache); $query = $this->db->query( "SELECT id,`name`, name_arabic, brand_img, `description`,`description_arabic`,`founded`,`founded_arabic`,`headquarters`, `headquarters_arabic`,`official_name`,`official_name_arabic`,`products`,`products_arabic`,`seo_url` FROM models WHERE `name` = ? OR name_arabic = ?", array("name" => $keyword, "name_arabic" => $keyword) ); if ($query->num_rows() > 0) { $result = $query->row_array(); $this->memcached_library->add($key_cache, array( $result["id"], $result["name"], $result["name_arabic"], $result["brand_img"], $result["description"], $result["description_arabic"], $result["founded"], $result["founded_arabic"], $result["headquarters"], $result["headquarters_arabic"], $result["official_name"], $result["official_name_arabic"], $result["products"], $result["products_arabic"], $result["seo_url"] ), 86400); return array( $result["id"], $result["name"], $result["name_arabic"], $result["brand_img"], $result["description"], $result["description_arabic"], $result["founded"], $result["founded_arabic"], $result["headquarters"], $result["headquarters_arabic"], $result["official_name"], $result["official_name_arabic"], $result["products"], $result["products_arabic"], $result["seo_url"] ); } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { return $check_keyword_is_brand; } } function check_keyword_only_model($keyword,$used_cars=0) { $key_cache = 'check_keyword_only_model10@' . $keyword.$used_cars; //change keycache on elastic_model as well // $this->memcached_library->delete($key_cache); $check_keyword_is_model = $this->memcached_library->get($key_cache); if (empty($check_keyword_is_model) && !is_numeric($check_keyword_is_model)) { $this->set_memcachekeys($key_cache); /* $sql= $this->db->query("SELECT id,model,related_ids FROM make WHERE `complete_car_name` = ? OR `name` = ? OR complete_car_name_ar = ?", array("complete_car_name" => $keyword, "name" => $keyword, "complete_car_name_ar" => $keyword)); */ $sql = $this->db->query( "SELECT id,model,related_ids FROM make WHERE `name` = ? OR name_arabic = ?", array("name" => $keyword, "name_arabic" => $keyword) ); if($used_cars==0){ $sql3 = mysql_query("SELECT DISTINCT car_make FROM listings INNER JOIN make on make.id=listings.car_make WHERE (`name`='$keyword' OR `name_arabic`='$keyword') and publish_ocd='1' and delete_status='0'") or die(mysql_error()); } else { $sql3 = mysql_query("SELECT DISTINCT car_make FROM usedcar_listings INNER JOIN make on make.id=usedcar_listings.car_make WHERE (`name`='$keyword' OR `name_arabic`='$keyword') and used_cars='$used_cars' and publish_ocd='1' and delete_status='0'") or die(mysql_error()); } if ($sql->num_rows() > 0) { $sql_result = $sql->row_array(); $brand_id = $sql_result['model']; $model_id = $sql_result['id']; $related_ids = $sql_result['related_ids']; $related_array=explode($related_ids); if(mysql_num_rows($sql3)>0) { $makeidpp=array(); while($val=mysql_fetch_array($sql3)) { if(!in_array($val['car_make'],$related_array)) { $makeidpp[]=$val['car_make']; } } if(!empty($makeidpp)) { $makeidpp2=implode(",",$makeidpp); } $sql_result['related_ids_new'] = $related_ids . "," . $sql_result['id']. "," .$makeidpp2; $sql_result['listing'] = 1; } else { $sql_result['related_ids_new'] = $related_ids . "," . $sql_result['id']; $sql_result['listing'] = 0; } $query = $this->db->query( "SELECT id,`name`, name_arabic, brand_img,official_name FROM models WHERE `id` = ?", array("id" => $brand_id) ); if ($query->num_rows() > 0) { $result = $query->row_array(); $query2 = $this->db->query( "SELECT m.id as ids, m.`name` as model_name, m.name_arabic as model_name_arabic,m.url as urlss, c.id, " . "c.`name` as car_type, c.name_arabic as car_type_arabic FROM make m, car_types c WHERE m.id = ? AND m.cartype = c.id", array("id" => $model_id) ); if ($query2->num_rows() > 0) { $result2 = $query2->row_array(); $this->memcached_library->add($key_cache, array( "related_ids" => $sql_result["related_ids_new"], "brand_id" => $result["id"], "brand_name" => $result["name"], "brand_name_arabic" => $result["name_arabic"], "official_name" => $result["official_name"], "brand_image" => $result["brand_img"], "model_id" => $result2["ids"], "model_name" => $result2["model_name"], "model_name_arabic" => $result2["model_name_arabic"], "cartype" => $result2["car_type"], "cartype_arabic" => $result2["cartype_arabic"],"url" => $result2["urlss"] ), 86400); return array( "related_ids" => $sql_result["related_ids_new"], "brand_id" => $result["id"], "brand_name" => $result["name"], "brand_name_arabic" => $result["name_arabic"], "official_name" => $result["official_name"], "brand_image" => $result["brand_img"], "model_id" => $result2["ids"], "model_name" => $result2["model_name"], "model_name_arabic" => $result2["model_name_arabic"], "cartype" => $result2["car_type"], "cartype_arabic" => $result2["cartype_arabic"],"url" => $result2["urlss"] ); } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { return $check_keyword_is_model; } } function check_keyword_is_model($keyword,$used_cars=0) { $key_cache = 'check_keyword_is_model36@' . $keyword.$used_cars; //change keycache on elastic_model as well //$this->memcached_library->delete($key_cache); $check_keyword_is_model = $this->memcached_library->get($key_cache); if (empty($check_keyword_is_model) && !is_numeric($check_keyword_is_model)) { $this->set_memcachekeys($key_cache); if($keyword=="Swift"){ $sql = $this->db->query( "SELECT * FROM make WHERE `name`='$keyword'"); } else{ $sql= $this->db->query("SELECT id,model,related_ids FROM make WHERE `complete_car_name` = ? OR `name` = ? OR complete_car_name_ar = ?", array("complete_car_name" => $keyword, "name" => $keyword, "complete_car_name_ar" => $keyword)); } if($used_cars==0) { $sql3 = mysql_query("SELECT DISTINCT car_make FROM listings WHERE (`keywords` like '%$keyword%' OR `keywords_arabic` like '%$keyword%') and publish_ocd='1' and delete_status='0'") or die(mysql_error()); } else{ $sql3 = mysql_query("SELECT DISTINCT car_make FROM usedcar_listings WHERE (`keywords` like '%$keyword%' OR `keywords_arabic` like '%$keyword%') and publish_ocd='1' and delete_status='0' and used_cars='$used_cars'") or die(mysql_error()); } if ($sql->num_rows() > 0) { $sql_result = $sql->row_array(); $brand_id = $sql_result['model']; $model_id = $sql_result['id']; $related_ids = $sql_result['related_ids']; $related_array=explode($related_ids); if(mysql_num_rows($sql3)>0) { $makeidpp=array(); while($val=mysql_fetch_array($sql3)) { if(!in_array($val['car_make'],$related_array)) { $makeidpp[]=$val['car_make']; } } if(!empty($makeidpp)) { $makeidpp2=implode(",",$makeidpp); } $sql_result['related_ids_new'] = $related_ids . "," . $sql_result['id']. "," .$makeidpp2; } else { $sql_result['related_ids_new'] = $related_ids . "," . $sql_result['id']; } $query = $this->db->query( "SELECT id,`name`, name_arabic, brand_img,official_name FROM models WHERE `id` = ?", array("id" => $brand_id) ); if ($query->num_rows() > 0) { $result = $query->row_array(); $query2 = $this->db->query( "SELECT m.id as ids, m.`name` as model_name, m.name_arabic as model_name_arabic,m.url as urlss, c.id, " . "c.`name` as car_type, c.name_arabic as car_type_arabic FROM make m, car_types c WHERE m.id = ? AND m.cartype = c.id", array("id" => $model_id) ); if ($query2->num_rows() > 0) { $result2 = $query2->row_array(); $this->memcached_library->add($key_cache, array( "related_ids" => $sql_result["related_ids_new"], "brand_id" => $result["id"], "brand_name" => $result["name"], "brand_name_arabic" => $result["name_arabic"], "official_name" => $result["official_name"], "brand_image" => $result["brand_img"], "model_id" => $result2["ids"], "model_name" => $result2["model_name"], "model_name_arabic" => $result2["model_name_arabic"], "cartype" => $result2["car_type"], "cartype_arabic" => $result2["cartype_arabic"],"url" => $result2["urlss"] ), 86400); return array( "related_ids" => $sql_result["related_ids_new"], "brand_id" => $result["id"], "brand_name" => $result["name"], "brand_name_arabic" => $result["name_arabic"], "official_name" => $result["official_name"], "brand_image" => $result["brand_img"], "model_id" => $result2["ids"], "model_name" => $result2["model_name"], "model_name_arabic" => $result2["model_name_arabic"], "cartype" => $result2["car_type"], "cartype_arabic" => $result2["cartype_arabic"],"url" => $result2["urlss"] ); } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { return $check_keyword_is_model; } } function get_hyphen_cars(){ $key_cache = 'get_hyphen_cars@134'; $get_hyphen_cars = $this->memcached_library->get($key_cache); $c = 0; if (!$get_hyphen_cars && !is_numeric($get_hyphen_cars)) { $sql = "SELECT id, name, model FROM make WHERE name LIKE '%-%' and is_dubizzle_data='0'"; $rResult = mysql_query($sql) or die(mysql_error()); while($aRow = mysql_fetch_array($rResult)) { $list[$c]['id']=$aRow['id']; $list[$c]['name']=$aRow['name']; $list[$c]['model']=$aRow['model']; $c++; } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return $get_hyphen_cars; } } function get_brand_details($brand_id) { $key_cache = 'get_brand_details@' . $brand_id; $get_brand_details = $this->memcached_library->get($key_cache); if (!$get_brand_details && !is_numeric($get_brand_details)) { $this->set_memcachekeys($key_cache); $query = $this->db->query( "SELECT id,`name`, name_arabic, brand_img, `description`,`description_arabic`,`founded`,`founded_arabic`,`headquarters`, `headquarters_arabic`,`official_name`,`official_name_arabic`,`products`,`products_arabic` FROM models WHERE `id` = ?", array("id" => $brand_id) ); if ($query->num_rows() > 0) { $result = $query->row_array(); $this->memcached_library->add($key_cache, array( $result["id"], $result["name"], $result["name_arabic"], $result["brand_img"], $result["description"], $result["description_arabic"], $result["founded"], $result["founded_arabic"], $result["headquarters"], $result["headquarters_arabic"], $result["official_name"], $result["official_name_arabic"], $result["products"], $result["products_arabic"] ), 86400); return array( $result["id"], $result["name"], $result["name_arabic"], $result["brand_img"], $result["description"], $result["description_arabic"], $result["founded"], $result["founded_arabic"], $result["headquarters"], $result["headquarters_arabic"], $result["official_name"], $result["official_name_arabic"], $result["products"], $result["products_arabic"] ); } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { return $get_brand_details; } } function get_brand_model_details($brand_id, $model_id) { $key_cache = 'get_brand_model_details@' . $brand_id . '@' . $model_id; $get_brand_model_details = $this->memcached_library->get($key_cache); if (!$get_brand_model_details && !is_numeric($get_brand_model_details)) { $this->set_memcachekeys($key_cache); $query = $this->db->query( "SELECT id,`name`, name_arabic, brand_img FROM models WHERE `id` = ?", array("id" => $brand_id) ); if ($query->num_rows() > 0) { $result = $query->row_array(); $query2 = $this->db->query( "SELECT m.id, m.`name` as model_name, m.name_arabic as model_name_arabic, c.id, " . "c.`name` as car_type, c.name_arabic as car_type_arabic FROM make m, car_types c WHERE m.id = ? AND m.cartype = c.id", array("id" => $model_id) ); if ($query2->num_rows() > 0) { $result2 = $query2->row_array(); $this->memcached_library->add($key_cache, array( "brand_name" => $result["name"], "brand_name_arabic" => $result["name_arabic"], "brand_image" => $result["brand_img"], "model_name" => $result2["model_name"], "model_name_arabic" => $result2["model_name_arabic"], "cartype" => $result2["car_type"], "cartype_arabic" => $result2["cartype_arabic"] ), 86400); return array( "brand_name" => $result["name"], "brand_name_arabic" => $result["name_arabic"], "brand_image" => $result["brand_img"], "model_name" => $result2["model_name"], "model_name_arabic" => $result2["model_name_arabic"], "cartype" => $result2["car_type"], "cartype_arabic" => $result2["cartype_arabic"] ); } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { $this->memcached_library->add($key_cache, array(false), 86400); return array(false); } } else { return $get_brand_model_details; } } function get_total_verify_rows_title($data) { $status = $data['status']; $client_id = $data["client_id"]; $condition = ""; $date = date("Y-m-d"); if ($status == "latest") { $condition .= " AND listing_title != ''"; } else if ($status == "approved") { $condition .= " AND listing_title != '' AND listing_title_approve = 2"; } else if ($status == "rejected") { $condition .= " AND listing_title != '' AND listing_title_approve = 1"; } else if ($status == "pending") { $condition .= " AND listing_title != '' AND listing_title_approve = 0"; } if (!empty($client_id)) { $condition .= " AND client_id = $client_id AND submit_status = 1 "; } $sql = "SELECT COUNT(*) as count FROM listings WHERE delete_status = 0 AND submit_status = 1 $condition ORDER BY submit_time DESC"; $rResult = mysql_query($sql) or die(mysql_error()); $result = mysql_fetch_assoc($rResult); return $result['count']; } function get_total_verify_rows($data) { $status = $data['status']; $client_id = $data["client_id"]; $condition = ""; $date = date("Y-m-d"); if ($status == "latest") { $condition .= " AND submit_status = 1 "; } else if ($status == "approved") { $condition .= " AND submit_status = 1 AND images_verify = 2 AND verification_expiry >= '$date' "; } else if ($status == "rejected") { $condition .= " AND submit_status = 1 AND images_verify = 1 "; } else if ($status == "pending") { $condition .= " AND submit_status = 1 AND images_verify = 0 "; } else if ($status == "expired") { $condition .= " AND submit_status = 1 AND images_verify = 2 AND verification_expiry < '$date' "; } if (!empty($client_id)) { $condition .= " AND client_id = $client_id AND submit_status = 1 "; } $sql = "SELECT COUNT(*) as count FROM listings WHERE delete_status = 0 AND submit_status = 1 $condition ORDER BY submit_time DESC"; $rResult = mysql_query($sql) or die(mysql_error()); $result = mysql_fetch_assoc($rResult); return $result['count']; } function get_companies_with_verified_listings_title() { $sql = "SELECT l.client_id, l.listing_title, l.listing_title_approve, l.submit_status, l.delete_status, c.client_id, c.company_name, c.emirate FROM listings l, clients c WHERE l.client_id = c.client_id AND l.submit_status = 1 AND l.delete_status = 0 AND l.listing_title != '' ORDER BY c.company_name ASC"; $query = mysql_query($sql); $clients = array(); while ($row = mysql_fetch_array($query)) { if (array_key_exists($row["client_id"], $clients)) { continue; } $clients[$row["client_id"]] = array("company_name" => $row["company_name"], "emirate" => $row["emirate"]); } return $clients; } function get_companies_with_verified_listings() { $sql = "SELECT l.client_id, l.submit_status, l.delete_status, c.client_id, c.company_name, c.emirate FROM listings l, clients c WHERE l.client_id = c.client_id AND l.submit_status = 1 AND l.delete_status = 0 ORDER BY c.company_name ASC"; $query = mysql_query($sql); $clients = array(); while ($row = mysql_fetch_array($query)) { if (array_key_exists($row["client_id"], $clients)) { continue; } $clients[$row["client_id"]] = array("company_name" => $row["company_name"], "emirate" => $row["emirate"]); } return $clients; } function VerifyListingTitle($start, $per_page, $data) { $status = $data['status']; $client_id = $data["client_id"]; $carmake_id = $data["carmake_id"]; $carmodel_id = $data["carmodel_id"]; $condition = ""; $date = date("Y-m-d"); if ($status == "latest") { $condition .= " AND listing_title != ''"; } else if ($status == "approved") { $condition .= " AND listing_title != '' AND listing_title_approve = 2"; } else if ($status == "rejected") { $condition .= " AND listing_title != '' AND listing_title_approve = 1"; } else if ($status == "pending") { $condition .= " AND listing_title != '' AND listing_title_approve = 0"; } if (!empty($client_id)) { $condition .= " AND client_id = $client_id"; } if (!empty($carmake_id)) { $condition .= " AND car_model = $carmake_id"; } if (!empty($carmodel_id)) { $condition .= " AND car_make = $carmodel_id"; } $sql = "SELECT * FROM listings WHERE delete_status = 0 and publish_ocd = 1 and submit_status=1 $condition ORDER BY submit_time DESC LIMIT $start, $per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $list[$aRow['id']]['reason_reject'] = $aRow["reason_reject"]; $make = $this->get_name($make, "make", "name,logo,cartype,doors,passengers,rate_reviews,review_date,years"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['submit_time'] = $aRow['submit_time']; $list[$aRow['id']]['verified_on'] = $aRow['verified_on']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['color'] = $aRow['color']; $list[$aRow['id']]['interior_color'] = $aRow['interior_color']; $list[$aRow['id']]['id'] = $aRow['id']; $ids[] = $aRow['id']; $list[$aRow['id']]['listing_title'] = $aRow['listing_title']; $list[$aRow['id']]['listing_title_approve'] = $aRow['listing_title_approve']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,emirate,logo,swf,small_logo,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,client_currency,client_country,cost_of_delivery,boss_email, email"); $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; $list[$aRow['id']]['boss_email'] = $client["boss_email"]; $list[$aRow['id']]['email'] = $client["email"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; // $query = "SELECT * FROM gallery WHERE listing_id='" . $aRow['id'] . "' order by `index` desc"; // $result = mysql_query($query) or die(mysql_error()); // $images = array(); // while ($row = mysql_fetch_array($result)) { // array_push($images, $row['thumbnail']); // } // $list[$aRow['id']]['images'] = $images; $query2 = "SELECT * FROM mulkiya WHERE listing_id='" . $aRow['id'] . "' order by `index` desc limit 1"; $result2 = mysql_query($query2) or die(mysql_error()); $row2 = mysql_fetch_array($result2); $list[$aRow['id']]['car_reg_card'] = $row2['thumbnail']; } if(count($ids) > 0) { $idss = implode(",", $ids); $query = "SELECT * FROM gallery WHERE listing_id in ($idss) order by `index` desc"; $result = mysql_query($query) or die(mysql_error()); $images = array(); $out=array(); while ($x = mysql_fetch_array($result)) { $list[$x['listing_id']]['images'][]=$x['thumbnail']; } } //print_r($list); return $list; } function VerifyListing($start, $per_page, $data) { $status = $data['status']; $client_id = $data["client_id"]; $condition = ""; $date = date("Y-m-d"); if ($status == "latest") { $condition .= " AND submit_status = 1 "; } else if ($status == "approved") { $condition .= " AND submit_status = 1 AND images_verify = 2 AND verification_expiry >= '$date' "; } else if ($status == "rejected") { $condition .= " AND submit_status = 1 AND images_verify = 1 "; } else if ($status == "pending") { $condition .= " AND submit_status = 1 AND images_verify = 0 "; } else if ($status == "expired") { $condition .= " AND submit_status = 1 AND images_verify = 2 AND verification_expiry < '$date' "; } if (!empty($client_id)) { $condition .= " AND client_id = $client_id AND submit_status = 1 "; } $sql = "SELECT * FROM listings WHERE delete_status = 0 and submit_status=1 $condition ORDER BY submit_time DESC LIMIT $start, $per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $list[$aRow['id']]['reason_reject'] = $aRow["reason_reject"]; $make = $this->get_name($make, "make", "name,logo,cartype,doors,passengers,rate_reviews,review_date,years"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['submit_time'] = $aRow['submit_time']; $list[$aRow['id']]['verified_on'] = $aRow['verified_on']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['color'] = $aRow['color']; $list[$aRow['id']]['interior_color'] = $aRow['interior_color']; if(!empty($aRow['approved_user_id'])){ $list[$aRow['id']]['verified_user'] = $this->get_user_name($aRow['approved_user_id']); $list[$aRow['id']]['verified_datetime'] = date('Y-m-d h:i A', strtotime($aRow['approved_date_time'])); }else{ $list[$aRow['id']]['verified_user'] = ''; $list[$aRow['id']]['verified_datetime'] = ''; } $list[$aRow['id']]['id'] = $aRow['id']; $ids[] = $aRow['id']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,emirate,logo,swf,small_logo,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,client_currency,client_country,cost_of_delivery,boss_email, email"); $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; $list[$aRow['id']]['boss_email'] = $client["boss_email"]; $list[$aRow['id']]['email'] = $client["email"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; // $query = "SELECT * FROM gallery WHERE listing_id='" . $aRow['id'] . "' order by `index` desc"; // $result = mysql_query($query) or die(mysql_error()); // $images = array(); // while ($row = mysql_fetch_array($result)) { // array_push($images, $row['thumbnail']); // } // $list[$aRow['id']]['images'] = $images; $query2 = "SELECT * FROM mulkiya WHERE (type LIKE '%image%' OR type LIKE '%pdf%') and listing_id='" . $aRow['id'] . "' order by `index` desc limit 1"; $result2 = mysql_query($query2) or die(mysql_error()); $row2 = mysql_fetch_array($result2); $list[$aRow['id']]['car_reg_card'] = $row2["file"]; $list[$aRow['id']]['car_reg_card_s3_status'] = $row2['s3_status']; } if(count($ids) > 0) { $idss = implode(",", $ids); $query = "SELECT * FROM gallery WHERE listing_id in ($idss) order by `index` desc"; $result = mysql_query($query) or die(mysql_error()); $images = array(); $out=array(); while ($x = mysql_fetch_array($result)) { $list[$x['listing_id']]['images'][]=$x['thumbnail']; $list[$x['listing_id']]['s3_status'][]=$x['s3_status']; } } //print_r($list); return $list; } function Verify_Listing($id) { //$sql = "SELECT * FROM `car_documents` as cd inner join listings as ls on cd.`listing_id`=ls.id where delete_status = 0 and ls.client_id in (select client_id from `clients` where emirate like '%Dubai%' OR emirate like '%Abu Dhabi%' OR emirate like '%Sharjah%' OR emirate like '%Ajman%' OR emirate like '%Ras Al Khaimah%' OR emirate like '%Fujairah%') and publish_ocd='1'"; $sql = "SELECT * FROM listings WHERE id='$id'"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { /* update impressions date_wise */ $date = date('Y-m-d'); /* END FEATURES*/ $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype,doors,passengers,rate_reviews,review_date,years"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['id'] = $aRow['id']; $ids[] = $aRow['id']; $list[$aRow['id']]['car_reg_card'] = $aRow['reg_card']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,emirate,logo,swf,small_logo,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,client_currency,client_country,cost_of_delivery,boss_email, email,brand_manager"); $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; $list[$aRow['id']]['boss_email'] = $client["boss_email"]; $list[$aRow['id']]['email'] = $client["email"]; $list[$aRow['id']]['brand_manager'] = $client["brand_manager"]; $query = "SELECT * FROM gallery WHERE listing_id='" . $aRow['id'] . "' order by `index` desc"; $result = mysql_query($query) or die(mysql_error()); $images = array(); while ($row = mysql_fetch_array($result)) { array_push($images, $row['thumbnail']); } $list[$aRow['id']]['images'] = $images; $query2 = "SELECT * FROM mulkiya WHERE listing_id='" . $aRow['id'] . "' order by `index` desc"; $result2 = mysql_query($query2) or die(mysql_error()); $images_mulkiya = array(); while ($row2 = mysql_fetch_array($result2)) { array_push($images_mulkiya, $row2['thumbnail']); } $list[$aRow['id']]['images_mulkiya'] = $images_mulkiya; } return $list; } function EditListing($id) { $listing_id = $id; //$sql = "SELECT * FROM `car_documents` as cd inner join listings as ls on cd.`listing_id`=ls.id where delete_status = 0 and ls.id='".$listing_id."' and ls.client_id in (select client_id from `clients` where emirate like '%Dubai%' OR emirate like '%Abu Dhabi%' OR emirate like '%Sharjah%' OR emirate like '%Ajman%' OR emirate like '%Ras Al Khaimah%' OR emirate like '%Fujairah%') and publish_ocd='1'"; $sql = "SELECT * FROM listings WHERE delete_status = 0 and submit_status = 1 and client_id in (select client_id from `clients` where emirate like '%Dubai%' OR emirate like '%Abu Dhabi%' OR emirate like '%Sharjah%' OR emirate like '%Ajman%' OR emirate like '%Ras Al Khaimah%' OR emirate like '%Fujairah%') ORDER BY submit_time DESC"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype,doors,passengers,rate_reviews,review_date,years"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['id'] = $aRow['id']; $ids[] = $aRow['id']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['submit_time'] = $aRow['submit_time']; $list[$aRow['id']]['eta'] = date("Y-m-d H:i:s", strtotime($aRow['submit_time'] . ' + 2 days')); $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; $list[$aRow['id']]['reg_card_expiry'] = $aRow['reg_card_expiry']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['video'] = $aRow['video']; $list[$aRow['id']]['verified_on'] = $aRow['verified_on']; $list[$aRow['id']]['no_expiry_date'] = $aRow['no_expiry_date']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,emirate,logo,swf,small_logo,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,client_currency,client_country,cost_of_delivery"); $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; $query = "SELECT * FROM gallery WHERE listing_id='" . $aRow['id'] . "'"; $result = mysql_query($query) or die(mysql_error()); $images = array(); while ($row = mysql_fetch_array($result)) { array_push($images, $row['file']); } $list[$aRow['id']]['images'] = $images; $query2 = "SELECT * FROM mulkiya WHERE listing_id='" . $aRow['id'] . "'"; $result2 = mysql_query($query2) or die(mysql_error()); $images2 = array(); while ($row2 = mysql_fetch_array($result2)) { array_push($images2, $row2['file']); } $list[$aRow['id']]['reg_card'] = $images2; } return $list; } function EditListing2($id) { $listing_id = $id; //$sql = "SELECT * FROM `car_documents` as cd inner join listings as ls on cd.`listing_id`=ls.id where delete_status = 0 and ls.id='".$listing_id."' and ls.client_id in (select client_id from `clients` where emirate like '%Dubai%' OR emirate like '%Abu Dhabi%' OR emirate like '%Sharjah%' OR emirate like '%Ajman%' OR emirate like '%Ras Al Khaimah%' OR emirate like '%Fujairah%') and publish_ocd='1'"; $sql = "SELECT * FROM listings WHERE delete_status = 0 and submit_status = 1 ORDER BY submit_time DESC"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype,doors,passengers,rate_reviews,review_date,years"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['id'] = $aRow['id']; $ids[] = $aRow['id']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['submit_time'] = $aRow['submit_time']; $list[$aRow['id']]['eta'] = date("Y-m-d H:i:s", strtotime($aRow['submit_time'] . ' + 2 days')); $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; $list[$aRow['id']]['reg_card_expiry'] = $aRow['reg_card_expiry']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['video'] = $aRow['video']; $list[$aRow['id']]['verified_on'] = $aRow['verified_on']; $list[$aRow['id']]['no_expiry_date'] = $aRow['no_expiry_date']; $client = $this->get_company($aRow['client_id'], "clients", "brand_manager,company_name,emirate,logo,swf,small_logo,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,client_currency,client_country,cost_of_delivery"); $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['brand_manager'] = $client["brand_manager"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; $query = "SELECT * FROM gallery WHERE listing_id='" . $aRow['id'] . "'"; $result = mysql_query($query) or die(mysql_error()); $images = array(); while ($row = mysql_fetch_array($result)) { array_push($images, $row['file']); } $list[$aRow['id']]['images'] = $images; $query2 = "SELECT * FROM mulkiya WHERE listing_id='" . $aRow['id'] . "'"; $result2 = mysql_query($query2) or die(mysql_error()); $images2 = array(); while ($row2 = mysql_fetch_array($result2)) { array_push($images2, $row2['file']); } $list[$aRow['id']]['reg_card'] = $images2; } return $list; } function get_copy_listings_data($id){ $sql = "SELECT l.*, c.emirate FROM listings l, clients c WHERE l.client_id = c.client_id AND l.delete_status = 0 AND l.copy_id = ?"; $qry = $this->db->query($sql, array($id)); return $qry->result_array(); } function EditListing_new2($id) { $listing_id = $id; //$sql = "SELECT * FROM `car_documents` as cd inner join listings as ls on cd.`listing_id`=ls.id where delete_status = 0 and ls.id='".$listing_id."' and ls.client_id in (select client_id from `clients` where emirate like '%Dubai%' OR emirate like '%Abu Dhabi%' OR emirate like '%Sharjah%' OR emirate like '%Ajman%' OR emirate like '%Ras Al Khaimah%' OR emirate like '%Fujairah%') and publish_ocd='1'"; $sql = "SELECT * FROM listings WHERE delete_status = 0 and submit_status = 1 and id=$id ORDER BY submit_time DESC"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype,doors,passengers,rate_reviews,review_date,years"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['listing_title'] = $aRow["listing_title"]; $list[$aRow['id']]['listing_title_approve'] = $aRow["listing_title_approve"]; $list[$aRow['id']]['car_spec_id'] = $aRow["car_spec_id"]; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['id'] = $aRow['id']; $ids[] = $aRow['id']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['submit_time'] = $aRow['submit_time']; $list[$aRow['id']]['eta'] = date("Y-m-d H:i:s", strtotime($aRow['submit_time'] . ' + 2 days')); $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; $list[$aRow['id']]['reg_card_expiry'] = $aRow['reg_card_expiry']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['video'] = $aRow['video']; $list[$aRow['id']]['verified_on'] = $aRow['verified_on']; $list[$aRow['id']]['video_upload'] = $aRow['video_upload']; $list[$aRow['id']]['video_thumbnail_big'] = $aRow['video_thumbnail_big']; $list[$aRow['id']]['video_thumbnail'] = $aRow['video_thumbnail']; $list[$aRow['id']]['video_thumb_orginal'] = $aRow['video_thumb_orginal']; $list[$aRow['id']]['video_half_size'] = $aRow['video_half_size']; $list[$aRow['id']]['video_quarter_size'] = $aRow['video_quarter_size']; $list[$aRow['id']]['video_thumb_sec'] = $aRow['video_thumb_sec']; $list[$aRow['id']]['image_rating'] = $aRow['image_rating']; $list[$aRow['id']]['no_expiry_date'] = $aRow['no_expiry_date']; $client = $this->get_company_no_mem($aRow['client_id'], "clients", "copy_to_other_branches,brand_manager,company_name,emirate,logo,swf,small_logo,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,client_currency,client_country,cost_of_delivery"); $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['brand_manager'] = $client["brand_manager"]; $list[$aRow['id']]['copy_to_other_branches'] = $client["copy_to_other_branches"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; $query = "SELECT * FROM gallery WHERE listing_id='" . $aRow['id'] . "'"; $result = mysql_query($query) or die(mysql_error()); $images = array(); while ($row = mysql_fetch_array($result)) { array_push($images, $row['file']); } $list[$aRow['id']]['images'] = $images; $query2 = $this->db->query("SELECT * FROM mulkiya WHERE listing_id='" . $aRow['id'] . "' and (type LIKE '%image%' OR type LIKE '%pdf%')"); $result2 = $query2->result_array(); $list[$aRow['id']]['reg_card'] = $result2; //mulkiya video $query22 = "SELECT * FROM mulkiya WHERE listing_id='" . $aRow['id'] . "' and type LIKE '%video%'"; $result22 = mysql_query($query22) or die(mysql_error()); while ($row22 = mysql_fetch_array($result22)) { $list[$aRow['id']]['mul_video'] = $row22['video_file']; } $color2 = $aRow['color']; $list[$aRow['id']]['color'] = $color2; if ($color2 == "" || $color2 == NULL) { $list['final_colors'] = ""; } else { $color_separate = explode(',', $color2); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"]; } $final_color2 = implode(",", $final_color); $list[$aRow['id']]['final_colors'] = $final_color2; } $color3 = $aRow['interior_color']; $list[$aRow['id']]['second_color'] = $aRow['second_color']; $list[$aRow['id']]['int_color'] = $color3; if ($color3 == "" || $color3 == NULL) { $list['interior_color'] = ""; } else { $color_separate = explode(',', $color3); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"]; } $final_color3 = implode(",", $final_color); $list[$aRow['id']]['interior_color'] = $final_color3; } } return $list; } function ListingStatus($id, $status, $reason, $task = '') { $loginUserId = isset($_SESSION['user_id']) && !empty($_SESSION['user_id']) ? $_SESSION['user_id'] : '123'; $sql = "select * from listings where id=$id"; $rResult = mysql_query($sql) or die(mysql_error()); $aRow = mysql_fetch_array($rResult); //renew listing - 2 if ($status == 2) { $reg_card_expiry = $aRow['reg_card_expiry']; $no_expiry_date = $aRow['no_expiry_date']; $verified_on = date("Y-m-d"); //this should be dynamic from mulkiya // $verify_till_2021 = "2025-12-30"; $verify_till_2021 = date('Y-m-d', strtotime('+1 year')); if ($no_expiry_date == 1) { $verification_expiry = $verify_till_2021; } else if (($no_expiry_date == 0) && ($reg_card_expiry <= $verify_till_2021)) { $verification_expiry = $reg_card_expiry; } else { $verification_expiry = $verify_till_2021; } /* added by nikhil on 30-10-2024 */ if(!empty($task) && $task == 'approve'){ $stmt = "UPDATE listings SET images_verify = ?, verified_on = ?, verification_expiry = ?, approved_user_id = ?, approved_date_time = ? WHERE id = ?"; $qry = $this->db->query($stmt, array( "images_verify" => 2, "verified_on" => $verified_on, "verification_expiry" => $verification_expiry, "approved_user_id" => $loginUserId, "approved_date_time" => date('Y-m-d h:i:s'), "id" => $id, )); }else if(!empty($task) && $task == 'renew'){ $stmt = "UPDATE listings SET images_verify = ?, verified_on = ?, verification_expiry = ?, renewed_user_id = ?, renewed_date_time = ? WHERE id = ?"; $qry = $this->db->query($stmt, array( "images_verify" => 2, "verified_on" => $verified_on, "verification_expiry" => $verification_expiry, "renewed_user_id" => $loginUserId, "renewed_date_time" => date('Y-m-d h:i:s'), "id" => $id, )); } mysql_query("update gallery set status = " . $status . " where listing_id='$id'") or die(mysql_error()); } else if ($status == 1) { //reject == 1 $stmt = "UPDATE listings SET images_verify = ?, verified_on = ?, verification_expiry = ?, reason_reject = ?, reg_card = ?, reg_card_back = ?, cancelleed_user_id = ?, cancelleed_date_time = ? WHERE id = ?"; $qry = $this->db->query($stmt, array( "images_verify" => 1, "verified_on" => NULL, "verification_expiry" => NULL, "reason_reject" => $reason, "reg_card" => "", "reg_card_back" => "", "cancelleed_user_id" => $loginUserId, "cancelleed_date_time" => date('Y-m-d h:i:s'), "id" => $id )); mysql_query("DELETE FROM gallery WHERE listing_id='$id'") or die(mysql_error()); // mysql_query("DELETE FROM mulkiya WHERE listing_id='$id'")or die(mysql_error()); } return $status; } function reset_verification($list_id) { $stmt = "UPDATE listings SET images_verify =?, verified_on = ?, verification_expiry = ?, reason_reject = ?, " . "submit_status = ?, submit_time = ? WHERE id = ?"; $qry = $this->db->query($stmt, array( "images_verify" => 0, "verified_on" => NULL, "verification_expiry" => NULL, "reason_reject" => NULL, "submit_status" => 0, "submit_time" => NULL, "id" => $list_id )); $status = 0; mysql_query("update gallery set status = " . $status . " where listing_id='$list_id'") or die(mysql_error()); return "success"; } function get_free_refresh_status($id) { $stmt = "SELECT free_refresh FROM listings WHERE id = ?"; $qry = $this->db->query($stmt, array("id" => $id)); $res = $qry->row_array(); return $res['free_refresh']; } // function RejectListing($id){ // $sql = "select * from listings where id=$id"; // $rResult = mysql_query($sql) or die(mysql_error()); // $aRow = mysql_fetch_array($rResult); // $images_verify = $aRow['images_verify']; // $sql_imp =mysql_query("update listings set images_verify = 1 where id='$id'")or die(mysql_error()); // mysql_query("update gallery set status = 1 where listing_id='$id'")or die(mysql_error()); // return "1"; // } function get_clients_accpted_in($pay) { $cachekey = implode("@", $pay); $key_cache = 'get_clients_accpted_in2@' . $cachekey; //$this->memcached_library->delete($key_cache); $get_clients_accpted_in = $this->memcached_library->get($key_cache); if (!$get_clients_accpted_in && !is_numeric($get_clients_accpted_in)) { $list = []; foreach ($pay as $pay_where) { $sql = "SELECT DISTINCT client_id FROM clients where clients.accepted_in_cl like '%$pay_where%' and clients.client_id!=''"; $qry = $this->db->query($sql); $result = $qry->result_array(); foreach ($result as $client) { array_push($list, $client["client_id"]); } } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return $get_clients_accpted_in; } } function get_open_now_clients($current_time, $current_day) { $key_cache = 'get_open_now_clients@' . $current_time . '@' . $current_day; // $this->memcached_library->delete($key_cache); $get_open_now_clients = $this->memcached_library->get($key_cache); if (!$get_open_now_clients && !is_numeric($get_open_now_clients)) { $sql = "SELECT DISTINCT client_id FROM shop_timings WHERE week_day = ? AND ( (CAST(start_hour1 AS TIME) <= CAST(? AS TIME) AND CAST(end_hour1 AS TIME) >= CAST(? AS TIME)) OR (CAST(start_hour2 AS TIME) <= CAST(? AS TIME) AND CAST(end_hour2 AS TIME) >= CAST(? AS TIME)) OR always_open = 1 OR ((CAST(start_hour1 AS TIME) <= CAST(? AS TIME)) AND end_hour1 = 'End Hour') )"; $qry = $this->db->query($sql, array( "week_day" => $current_day, "start_hour1" => $current_time, "end_hour1" => $current_time, "start_hour2" => $current_time, "end_hour2" => $current_time, "start_hour11" => $current_time, )); $result = $qry->result_array(); $list = array(); foreach ($result as $client) { array_push($list, $client["client_id"]); } $this->memcached_library->add($key_cache, $list, 3600); $this->set_memcachekeys($key_cache); return $list; } else { return $get_open_now_clients; } } function get_clients_with_no_shoptime(){ $key_cache = 'clients_with_no_shoptime' . '@' . date('Y-m-d-H'); // $this->memcached_library->delete($key_cache); $result = $this->memcached_library->get($key_cache); if ($result == '') { $this->db->select("c.client_id"); $this->db->join('shop_timings s', "s.client_id = c.client_id and NOT (s.start_hour1='Start Hour' and s.start_hour2='Start Hour') ", "left"); $this->db->from('clients c'); $this->db->where("s.id is NULL and c.client_id !='' "); $query = $this->db->get(); $res = $query->result_array(); if(!empty($res)){ $result = array_map(function($row){ return $row['client_id'];}, $res); $this->memcached_library->add($key_cache, $result, 3600); $this->set_memcachekeys($key_cache); } } return $result; } function get_clients_with_no_shoptime_db(){ $this->db->select("c.client_id"); $this->db->join('shop_timings s', "s.client_id = c.client_id and NOT (s.start_hour1='Start Hour' and s.start_hour2='Start Hour') ", "left"); $this->db->from('clients c'); $this->db->where("s.id is NULL and c.client_id !='' "); $query = $this->db->get(); $res = $query->result_array(); $result = []; if(!empty($res)){ $result = array_map(function($row){ return $row['client_id'];}, $res); } return $result; } function clients_emirate_include($emirates) { //$key_cache = 'clients_emirate_include@'.$emirates; // incase modified then update the elastic_model update_elastic_clients as well //$this->memcached_library->delete($key_cache); $qry = mysql_query("SELECT DISTINCT client_id FROM clients WHERE emirate in ($emirates) and client_id!=''"); if(mysql_num_rows($qry)>0) { $list = array(); while( $result = mysql_fetch_array($qry)) { array_push($list, $result["client_id"]); } return $list; } else { return 1; } } function clients_morocco() { $key_cache = 'clients_morocco@'; // incase modified then update the elastic_model update_elastic_clients as well //$this->memcached_library->delete($key_cache); $clients_morocco = $this->memcached_library->get($key_cache); if (!$clients_morocco && !is_numeric($clients_morocco)) { $qry = mysql_query("SELECT DISTINCT client_id FROM clients WHERE emirate in ('Marrakesh','Casablanca') and client_id!=''"); if(mysql_num_rows($qry)>0) { $list = array(); while( $result = mysql_fetch_array($qry)) { array_push($list, $result["client_id"]); } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return 1; } } else { return $clients_morocco; } } function get_make_bypassenger_count($pass_where) { $key_cache = 'get_make_bypassenger_count@' . $pass_where; //$this->memcached_library->delete($key_cache); $get_open_now_clients = $this->memcached_library->get($key_cache); if (!$get_open_now_clients && !is_numeric($get_open_now_clients)) { $sql = "SELECT DISTINCT id FROM make WHERE passengers in (" . $pass_where . ")"; $qry = $this->db->query($sql); $result = $qry->result_array(); $list = array(); foreach ($result as $make) { array_push($list, $make["id"]); } $this->memcached_library->add($key_cache, $list, 86400); $this->set_memcachekeys($key_cache); return $list; } else { return $get_open_now_clients; } } function GetAllCars_slider($start, $cars_per_page, $where_stmt, $order) { $key_cache = "getAllCars_slider20561@" . $start . "@" . $cars_per_page . "@" . $where_stmt . "@" . $order; // $this->memcached_library->delete($key_cache); $GetAllCars_slider = $this->memcached_library->get($key_cache); if (!$GetAllCars_slider && !is_numeric($GetAllCars_slider)) { $brands_array = array(); $qry = $this->db->query("select * from listings where $where_stmt and publish_ocd='1' order by $order refresh desc"); $res = $qry->result_array(); foreach($res as $re){ $model = $re['car_model']; $model = $this->get_name_2($model, "models", "brand_img_webp"); if(!in_array($model['brand_img_webp'],$brands_array)){ $brands_array[] = $model['brand_img_webp']; } if(count($brands_array) >= 8){ break; } } $sql = "select * from listings where $where_stmt and publish_ocd='1' order by $order refresh desc limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($rResult)>0) { while ($aRow = mysql_fetch_array($rResult)) { /* update impressions date_wise */ $date = date('Y-m-d'); /*$update_impression=mysql_query("select * from track_impressions where listing_id='".$aRow['id']."' and client_id='".$aRow['client_id']."' and date_ts='$date'")or die(mysql_error()); if(mysql_num_rows($update_impression)>0) { $impression=mysql_fetch_array($update_impression); $track_id=$impression['track_id']; $check_imp=$impression['impressions']; $sql_imp =mysql_query("update track_impressions set impressions = $check_imp + 1 where track_id='$track_id'")or die(mysql_error()); } else { $sql_imp =mysql_query("insert into track_impressions set impressions ='1', listing_id='".$aRow['id']."',client_id='".$aRow['client_id']."',date_ts='$date'")or die(mysql_error()); }*/ /* END update impressions date_wise */ $feature_k = $aRow['free_features']; if ($feature_k == "") { $list[$aRow['id']]['final_feature'] = "0"; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name($valfeature, "free_features", "name,icons"); if ($fea["name"] != "") { $final_feature[] = $fea["name"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $model = $aRow['car_model']; $model = $this->get_name_2($model, "models", "name,brand_img_png,brand_img_webp,seo_url"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['brand_image'] = $model['brand_img_webp']; $list[$aRow['id']]['seo_url'] = $model['seo_url']; $make = $aRow['car_make']; $make = $this->get_name_2($make, "make", "larg_bag,name,logo,cartype,cartype1,cartype2,cartype3,doors,passengers,rate_reviews,review_date,years,url"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_id'] = $aRow['car_make']; $list[$aRow['id']]['car_model_id'] = $aRow['car_model']; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['make_url'] = $make["url"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; if ($aRow['passengers'] == "" || $aRow['passengers'] == "0") { $list[$aRow['id']]['passengers'] = $make['passengers']; } else { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } if ($make['larg_bag'] == "" || $make['larg_bag'] == "0") { $list[$aRow['id']]['larg_bag'] = $aRow['larg_bag']; } else { $list[$aRow['id']]['larg_bag'] = $make['larg_bag']; } $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name_2($cartype, "car_types", "name,icon,url"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_icon'] = $cartype["icon"]; $list[$aRow['id']]['cartype_url'] = $cartype["url"]; $cartype2 = $make["cartype1"]; $cartype2 = $this->get_name_2($cartype2, "car_types", "name"); $list[$aRow['id']]['cartype2'] = $cartype2["name"]; $cartype3 = $make["cartype2"]; $cartype3 = $this->get_name_2($cartype3, "car_types", "name"); $list[$aRow['id']]['cartype3'] = $cartype3["name"]; $cartype4 = $make["cartype3"]; $cartype4 = $this->get_name_2($cartype4, "car_types", "name"); $list[$aRow['id']]['cartype4'] = $cartype4["name"]; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['hour_price_status'] = $aRow['hour_price_status']; $list[$aRow['id']]['daily_price_status'] = $aRow['daily_price_status']; $list[$aRow['id']]['security_amount_hour'] = $aRow['security_amount_hour']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['under_promotion'] = $aRow['under_promotion']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mile_week'] = $aRow['mileage_week']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['min_days_booking'] = $aRow['min_days_booking']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; if (($aRow['images_verify'] == 2) && ($aRow['verification_expiry'] >= date("Y-m-d"))) { $list[$aRow['id']]['gallery'] = $this->get_gallery($aRow['id']); } $trans = $aRow['transmission']; $trans = $this->get_name_2($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client = $this->get_company_2($aRow['client_id'], "clients", "phone_number,whatsapp_api_enabled,company_name,emirate,logo,swf,small_logo,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,client_currency,client_country,cost_of_delivery, minimum_cust_age, fast_delivery_locations"); $list[$aRow['id']]['fast_delivery_locations'] = $client["fast_delivery_locations"]; $list[$aRow['id']]['airport_meet'] = $client["airport_meetgreet"]; $list[$aRow['id']]['delivery_location'] = $client["delivery_at_location"]; $list[$aRow['id']]['location'] = $client["location_arabic"]; $list[$aRow['id']]['location_english'] = $client["location"]; $list[$aRow['id']]['small_company_logo'] = $client["small_logo"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['logo'] = $client["logo"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; $list[$aRow['id']]['latitude'] = $client["latitude"]; $list[$aRow['id']]['longitude'] = $client["longitude"]; $list[$aRow['id']]['client_currency'] = $client["client_currency"]; $list[$aRow['id']]['client_country'] = $client["client_country"]; $list[$aRow['id']]['whatsapp_number'] = $client["whatsapp_number"]; $list[$aRow['id']]['whatsapp_api_enabled'] = $client["whatsapp_api_enabled"]; $list[$aRow['id']]['phone_number'] = $client["phone_number"]; $list[$aRow['id']]['cost_of_delivery'] = $client["cost_of_delivery"]; $list[$aRow['id']]['minimum_cust_age'] = $client["minimum_cust_age"]; $qry = mysql_query("SELECT * FROM delivery_terms WHERE delivery_term = 'Free' and min_days_booking='1' and emirate='" . $client['emirate'] . "' and client_id = '" . $aRow['client_id'] . "'"); if (mysql_num_rows($qry) > 0) { $list[$aRow['id']]['free_delivery'] = "Free Delivery"; } else { $list[$aRow['id']]['free_delivery'] = "0"; } $color2 = $aRow['color']; if ($color2 == "" || $color2 == NULL) { $list['final_colors'] = ""; } else { $color_separate = explode(',', $color2); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"] . "+" . $colo["hex_code"] . "+" . $colo["id"]; } $final_color2 = implode(",", $final_color); $list[$aRow['id']]['final_colors'] = $final_color2; } } } else { $list="0"; $brands_array = array(); } $this->update_impressions($ids); $this->memcached_library->add($key_cache, array($list,$brands_array), 86400); $this->set_memcachekeys($key_cache); return array($list,$brands_array); } else { return $GetAllCars_slider; } } function GetAllCars333($start, $cars_per_page, $where_stmt, $order, $community) { // $key_cache="getAllCars3@".$start."@".$cars_per_page."@".$where_stmt."@".$order; // $GetAllCars3 = $this->memcached_library->get($key_cache); // if(!$GetAllCars3 && !is_numeric($GetAllCars3)){ $list = []; /*Call Multiple select query and then do the union */ //$sql1="select models.name,models.brand_img_png,models.brand_img_webp,models.brand_img,models.seo_url from models inner join listings on listings.car_model=models.id where $where_stmt and publish_ocd='1'"; $sql = "select listings.*,clients.is_community,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business, clients.accepted_in_cl from listings inner join clients on listings.client_id=clients.client_id where $where_stmt and publish_ocd='1' order by $order refresh desc limit $start,$cars_per_page"; // echo $sql ; exit(); try { $rResult = mysql_query($sql); if ($rResult) { //continue } else { return $list; } $rResult = mysql_query($sql) or die(mysql_error()); } catch (Exception $e) { return $list; } while ($aRow = mysql_fetch_array($rResult)) { /* update impressions date_wise */ $date = date('Y-m-d'); $feature_k = $aRow['free_features']; if ($feature_k == "") { $list[$aRow['id']]['final_feature'] = "0"; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name_2($valfeature, "free_features", "name,icons"); if ($fea["name"] != "") { $final_feature[] = $fea["name"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $model = $aRow['car_model']; $model = $this->get_name_2($model, "models", "name,brand_img_png,brand_img_webp,brand_img,seo_url"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['brand_image'] = $model['brand_img_webp']; $list[$aRow['id']]['brand_svg'] = $model['brand_img']; $list[$aRow['id']]['seo_url'] = $model['seo_url']; $make = $aRow['car_make']; $make = $this->get_name_2($make, "make", "name,logo,cartype,cartype1,cartype2,cartype3,doors,passengers,larg_bag,rate_reviews,review_date,years,url"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_id'] = $aRow['car_make']; $list[$aRow['id']]['car_model_id'] = $aRow['car_model']; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['make_url'] = $make["url"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; $list[$aRow['id']]['larg_bag'] = $make['larg_bag']; if ($make['passengers'] == "" || $make['passengers'] == "0") { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } else { $list[$aRow['id']]['passengers'] = $make['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name_2($cartype, "car_types", "name,icon,url"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_icon'] = $cartype["icon"]; $list[$aRow['id']]['cartype_url'] = $cartype["url"]; $cartype2 = $make["cartype1"]; $cartype2 = $this->get_name_2($cartype2, "car_types", "name"); $list[$aRow['id']]['cartype2'] = $cartype2["name"]; $cartype3 = $make["cartype2"]; $cartype3 = $this->get_name_2($cartype3, "car_types", "name"); $list[$aRow['id']]['cartype3'] = $cartype3["name"]; $cartype4 = $make["cartype3"]; $cartype4 = $this->get_name_2($cartype4, "car_types", "name"); $list[$aRow['id']]['cartype4'] = $cartype4["name"]; //refresh time by refresh key $refresh = $aRow['refresh']; // $refresh_time = $this->get_refresh_date_2($refresh); //verfied time $verified_on = $aRow['verified_on']; //Added time $submit_time = $aRow['submit_time']; $date_now = date("Y-m-d"); // this format is string comparable $check_date_status = 0; $availability = ""; /* if($refresh_time!="") { $refresh_time = date('Y-m-d', strtotime("+3 months", strtotime($refresh_time))); //if refresh time greater than today after increament if ($date_now < $refresh_time) { //set date status variable $check_date_status=1; //set to availability $availability = $refresh_time; }else{ $refresh_time=""; } }*/ if ($verified_on != "") { $verified_on = date('Y-m-d', strtotime("+6 months", strtotime($verified_on))); //if verified time greater than today after increament if ($date_now < $verified_on) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $verified_on; else if ($availability > $verified_on) $availability = $verified_on; } else { $verified_on = ""; } } if ($submit_time != "") { $submit_time = date('Y-m-d', strtotime("+12 months", strtotime($submit_time))); //if submit time greater than today after increament if ($date_now < $submit_time) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $submit_time; else if ($availability > $submit_time) $availability = $submit_time; } else { $submit_time = ""; } } //if three dates are less than current increament 2 months to current day if ($check_date_status == 0) { $availability = date('Y-m-d', strtotime("+2 months", strtotime($date_now))); } $list[$aRow['id']]['priceValidUntil'] = $availability; $list[$aRow['id']]['is_premium'] = $aRow['is_premium']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['showcase_day'] = $aRow['showcase_day']; $list[$aRow['id']]['showcase_week'] = $aRow['showcase_week']; $list[$aRow['id']]['showcase_month'] = $aRow['showcase_month']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['hour_price_status'] = $aRow['hour_price_status']; $list[$aRow['id']]['daily_price_status'] = $aRow['daily_price_status']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['security_amount_hour'] = $aRow['security_amount_hour']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['under_promotion'] = $aRow['under_promotion']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_day'] = $aRow['mileage_day']; $list[$aRow['id']]['cdw_day'] = $aRow["cdw_day"]; $list[$aRow['id']]['cdw_month'] = $aRow["cdw_month"]; $list[$aRow['id']]['mile_week'] = $aRow['mileage_week']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['min_days_booking'] = $aRow['min_days_booking']; /*$list[$aRow['id']]['2000_12month_price'] = $aRow['2000_12month_price']; $list[$aRow['id']]['2000_24month_price'] = $aRow['2000_24month_price']; $list[$aRow['id']]['2000_36month_price'] = $aRow['2000_36month_price']; $list[$aRow['id']]['3000_12month_price'] = $aRow['3000_12month_price']; $list[$aRow['id']]['3000_24month_price'] = $aRow['3000_24month_price']; $list[$aRow['id']]['3000_36month_price'] = $aRow['3000_36month_price']; $list[$aRow['id']]['4000_12month_price'] = $aRow['4000_12month_price']; $list[$aRow['id']]['4000_24month_price'] = $aRow['4000_24month_price']; $list[$aRow['id']]['4000_36month_price'] = $aRow['4000_36month_price']; $list[$aRow['id']]['4500_12month_price'] = $aRow['4500_12month_price']; $list[$aRow['id']]['4500_24month_price'] = $aRow['4500_24month_price']; $list[$aRow['id']]['4500_36month_price'] = $aRow['4500_36month_price']; $list[$aRow['id']]['5000_12month_price'] = $aRow['5000_12month_price']; $list[$aRow['id']]['5000_24month_price'] = $aRow['5000_24month_price']; $list[$aRow['id']]['5000_36month_price'] = $aRow['5000_36month_price']; $list[$aRow['id']]['6000_12month_price'] = $aRow['6000_12month_price']; $list[$aRow['id']]['6000_24month_price'] = $aRow['6000_24month_price']; $list[$aRow['id']]['6000_36month_price'] = $aRow['6000_36month_price'];*/ $list[$aRow['id']]['one_year_price'] = $aRow['one_year_price']; $list[$aRow['id']]['two_year_price'] = $aRow['two_year_price']; $list[$aRow['id']]['three_year_price'] = $aRow['three_year_price']; $list[$aRow['id']]['del_pick_option'] = $aRow['del_pick_option']; $list[$aRow['id']]['del_pick_charge'] = $aRow['del_pick_charge']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; if (($aRow['images_verify'] == 2) && ($aRow['verification_expiry'] >= date("Y-m-d"))) { $list[$aRow['id']]['gallery'] = $this->get_gallery_2($aRow['id']); } if ($community!='0' && ($aRow['is_community'] !='') && !empty($aRow['is_community'])) { $list[$aRow['id']]['community_note'] = $this->get_community_note($aRow['client_id'],$community); } else { $list[$aRow['id']]['community_note'] = "0"; } $trans = $aRow['transmission']; $trans = $this->get_name_2($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $list[$aRow['id']]['fast_delivery_locations'] = $aRow["fast_delivery_locations"]; $list[$aRow['id']]['airport_meet'] = $aRow["airport_meetgreet"]; $list[$aRow['id']]['delivery_location'] = $aRow["delivery_at_location"]; $list[$aRow['id']]['location'] = $aRow["location_arabic"]; $list[$aRow['id']]['supplier_settings'] = $aRow["supplier_settings"]; $list[$aRow['id']]['small_company_logo_png'] = $aRow["small_logo"]; $list[$aRow['id']]['location_english'] = $aRow["location"]; $list[$aRow['id']]['company_name'] = $aRow["company_name"]; $list[$aRow['id']]['emirate'] = $aRow["emirate"]; $list[$aRow['id']]['latitude'] = $aRow["latitude"]; $list[$aRow['id']]['longitude'] = $aRow["longitude"]; $list[$aRow['id']]['client_currency'] = $aRow["client_currency"]; $list[$aRow['id']]['unverified_business'] = $aRow["unverified_business"]; $list[$aRow['id']]['client_country'] = $aRow["client_country"]; $list[$aRow['id']]['whatsapp_number'] = $aRow["whatsapp_number"]; $list[$aRow['id']]['phone_number'] = $aRow["phone_number"]; $list[$aRow['id']]['cost_of_delivery'] = $aRow["cost_of_delivery"]; $list[$aRow['id']]['minimum_cust_age'] = $aRow["minimum_cust_age"]; $list[$aRow['id']]['gcc_specs_cl'] = $aRow["gcc_specs_cl"]; $list[$aRow['id']]['accepted_in_cl'] = $aRow["accepted_in_cl"]; $list[$aRow['id']]['logo'] = $aRow["logo"]; if (strpos($aRow["small_logo_webp"], '.webp') !== false) { $list[$aRow['id']]['small_company_logo'] = 'company_small_webp/' . $aRow["small_logo_webp"]; } else { $list[$aRow['id']]['small_company_logo'] = $aRow["small_logo_webp"]; } if (strpos($aRow["logo_webp"], '.webp') !== false) { $list[$aRow['id']]['company_logo'] = 'company_webp/' . $aRow["logo_webp"]; } else { $list[$aRow['id']]['company_logo'] = $aRow["logo_webp"]; } $key_cache4 = 'seo_home_country_url@' . $aRow['emirate'] . $aRow['client_id']; // $this->memcached_library->delete($key_cache4); $delivery_term = $this->memcached_library->get($key_cache4); if (!$delivery_term && !is_numeric($delivery_term)) { $qry = mysql_query("SELECT * FROM delivery_terms WHERE delivery_term = 'Free' and emirate='" . $aRow['emirate'] . "' and client_id = '" . $aRow['client_id'] . "'"); if (mysql_num_rows($qry) > 0) { $list[$aRow['id']]['free_delivery'] = "Free Delivery"; } else { $list[$aRow['id']]['free_delivery'] = "0"; } $this->memcached_library->add($key_cache4, $list[$aRow['id']]['free_delivery'], 86400); $this->set_memcachekeys($key_cache4); } else { $list[$aRow['id']]['free_delivery'] = $delivery_term; } $color2 = $aRow['color']; if ($color2 == "" || $color2 == NULL) { $list['final_colors'] = ""; } else { $color_separate = explode(',', $color2); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name_2($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"] . "+" . $colo["hex_code"] . "+" . $colo["id"]; } $final_color2 = implode(",", $final_color); $list[$aRow['id']]['final_colors'] = $final_color2; } } //$this->update_impressions($ids); // $this->memcached_library->add($key_cache, $list, 86400); // $this->set_memcachekeys($key_cache); return $list; // } // else { // return $GetAllCars3; // } } function get_community_note($client_id,$community) { $key_cache = 'get_community_note8@' . $client_id; $get_gallery = $this->memcached_library->get($key_cache); if (empty($get_gallery)) { $sql_query = "select * from community_discount where client_id='$client_id' and community_id= '$community'"; $Result = mysql_query($sql_query) or die(mysql_error()); $Row = mysql_fetch_array($Result); $note = $Row['community_name']."||".$Row['discount']."||".$Row['is_daily']."||".$Row['is_weekly']."||".$Row['is_monthly']; $this->memcached_library->add($key_cache, $note, 86400); $this->set_memcachekeys($key_cache); return $note; } else { return $get_gallery; } } function GetAllCars3($start, $cars_per_page, $where_stmt, $order) { // $key_cache="getAllCars3@".$start."@".$cars_per_page."@".$where_stmt."@".$order; // $GetAllCars3 = $this->memcached_library->get($key_cache); // if(!$GetAllCars3 && !is_numeric($GetAllCars3)){ $list = []; /*Call Multiple select query and then do the union */ //$sql1="select models.name,models.brand_img_png,models.brand_img_webp,models.brand_img,models.seo_url from models inner join listings on listings.car_model=models.id where $where_stmt and publish_ocd='1'"; $sql = "select listings.*,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from listings inner join clients on listings.client_id=clients.client_id where $where_stmt and publish_ocd='1' order by $order refresh desc limit $start,$cars_per_page"; //echo $sql ; try { $rResult = mysql_query($sql); if ($rResult) { //continue } else { return $list; } $rResult = mysql_query($sql) or die(mysql_error()); } catch (Exception $e) { return $list; } while ($aRow = mysql_fetch_array($rResult)) { /* update impressions date_wise */ $date = date('Y-m-d'); $feature_k = $aRow['free_features']; if ($feature_k == "") { $list[$aRow['id']]['final_feature'] = "0"; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name_2($valfeature, "free_features", "name,icons"); if ($fea["name"] != "") { $final_feature[] = $fea["name"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $model = $aRow['car_model']; $model = $this->get_name_2($model, "models", "name,brand_img_png,brand_img_webp,brand_img,seo_url"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['brand_image'] = $model['brand_img_webp']; $list[$aRow['id']]['brand_svg'] = $model['brand_img']; $list[$aRow['id']]['seo_url'] = $model['seo_url']; $make = $aRow['car_make']; $make = $this->get_name_2($make, "make", "name,logo,cartype,doors,passengers,larg_bag,rate_reviews,review_date,years,url"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_id'] = $aRow['car_make']; $list[$aRow['id']]['car_model_id'] = $aRow['car_model']; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['make_url'] = $make["url"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; $list[$aRow['id']]['larg_bag'] = $make['larg_bag']; if ($make['passengers'] == "" || $make['passengers'] == "0") { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } else { $list[$aRow['id']]['passengers'] = $make['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name_2($cartype, "car_types", "name,icon,url"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_icon'] = $cartype["icon"]; $list[$aRow['id']]['cartype_url'] = $cartype["url"]; //refresh time by refresh key $refresh = $aRow['refresh']; // $refresh_time = $this->get_refresh_date_2($refresh); //verfied time $verified_on = $aRow['verified_on']; //Added time $submit_time = $aRow['submit_time']; $date_now = date("Y-m-d"); // this format is string comparable $check_date_status = 0; $availability = ""; /* if($refresh_time!="") { $refresh_time = date('Y-m-d', strtotime("+3 months", strtotime($refresh_time))); //if refresh time greater than today after increament if ($date_now < $refresh_time) { //set date status variable $check_date_status=1; //set to availability $availability = $refresh_time; }else{ $refresh_time=""; } }*/ if ($verified_on != "") { $verified_on = date('Y-m-d', strtotime("+6 months", strtotime($verified_on))); //if verified time greater than today after increament if ($date_now < $verified_on) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $verified_on; else if ($availability > $verified_on) $availability = $verified_on; } else { $verified_on = ""; } } if ($submit_time != "") { $submit_time = date('Y-m-d', strtotime("+12 months", strtotime($submit_time))); //if submit time greater than today after increament if ($date_now < $submit_time) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $submit_time; else if ($availability > $submit_time) $availability = $submit_time; } else { $submit_time = ""; } } //if three dates are less than current increament 2 months to current day if ($check_date_status == 0) { $availability = date('Y-m-d', strtotime("+2 months", strtotime($date_now))); } $list[$aRow['id']]['priceValidUntil'] = $availability; $list[$aRow['id']]['is_premium'] = $aRow['is_premium']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['showcase_day'] = $aRow['showcase_day']; $list[$aRow['id']]['showcase_week'] = $aRow['showcase_week']; $list[$aRow['id']]['showcase_month'] = $aRow['showcase_month']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['hour_price_status'] = $aRow['hour_price_status']; $list[$aRow['id']]['daily_price_status'] = $aRow['daily_price_status']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['security_amount_hour'] = $aRow['security_amount_hour']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['under_promotion'] = $aRow['under_promotion']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_day'] = $aRow['mileage_day']; $list[$aRow['id']]['cdw_day'] = $aRow["cdw_day"]; $list[$aRow['id']]['cdw_month'] = $aRow["cdw_month"]; $list[$aRow['id']]['mile_week'] = $aRow['mileage_week']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['min_days_booking'] = $aRow['min_days_booking']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; if (($aRow['images_verify'] == 2) && ($aRow['verification_expiry'] >= date("Y-m-d"))) { $list[$aRow['id']]['gallery'] = $this->get_gallery_2($aRow['id']); } $trans = $aRow['transmission']; $trans = $this->get_name_2($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $list[$aRow['id']]['fast_delivery_locations'] = $aRow["fast_delivery_locations"]; $list[$aRow['id']]['airport_meet'] = $aRow["airport_meetgreet"]; $list[$aRow['id']]['delivery_location'] = $aRow["delivery_at_location"]; $list[$aRow['id']]['location'] = $aRow["location_arabic"]; $list[$aRow['id']]['supplier_settings'] = $aRow["supplier_settings"]; $list[$aRow['id']]['small_company_logo_png'] = $aRow["small_logo"]; $list[$aRow['id']]['location_english'] = $aRow["location"]; $list[$aRow['id']]['company_name'] = $aRow["company_name"]; $list[$aRow['id']]['emirate'] = $aRow["emirate"]; $list[$aRow['id']]['latitude'] = $aRow["latitude"]; $list[$aRow['id']]['longitude'] = $aRow["longitude"]; $list[$aRow['id']]['client_currency'] = $aRow["client_currency"]; $list[$aRow['id']]['unverified_business'] = $aRow["unverified_business"]; $list[$aRow['id']]['client_country'] = $aRow["client_country"]; $list[$aRow['id']]['whatsapp_number'] = $aRow["whatsapp_number"]; $list[$aRow['id']]['phone_number'] = $aRow["phone_number"]; $list[$aRow['id']]['cost_of_delivery'] = $aRow["cost_of_delivery"]; $list[$aRow['id']]['minimum_cust_age'] = $aRow["minimum_cust_age"]; $list[$aRow['id']]['gcc_specs_cl'] = $aRow["gcc_specs_cl"]; if (strpos($aRow["small_logo_webp"], '.webp') !== false) { $list[$aRow['id']]['small_company_logo'] = 'company_small_webp/' . $aRow["small_logo_webp"]; } else { $list[$aRow['id']]['small_company_logo'] = $aRow["small_logo_webp"]; } if (strpos($aRow["logo_webp"], '.webp') !== false) { $list[$aRow['id']]['company_logo'] = 'company_webp/' . $aRow["logo_webp"]; } else { $list[$aRow['id']]['company_logo'] = $aRow["logo_webp"]; } $key_cache4 = 'seo_home_country_url@' . $aRow['emirate'] . $aRow['client_id']; $delivery_term = $this->memcached_library->get($key_cache4); if (!$delivery_term && !is_numeric($delivery_term)) { $qry = mysql_query("SELECT * FROM delivery_terms WHERE delivery_term = 'Free' and emirate='" . $aRow['emirate'] . "' and client_id = '" . $aRow['client_id'] . "'"); if (mysql_num_rows($qry) > 0) { $list[$aRow['id']]['free_delivery'] = "Free Delivery"; } else { $list[$aRow['id']]['free_delivery'] = "0"; } $this->memcached_library->add($key_cache4, $list[$aRow['id']]['free_delivery'], 3600); $this->set_memcachekeys($key_cache4); } else { $list[$aRow['id']]['free_delivery'] = $delivery_term; } $color2 = $aRow['color']; if ($color2 == "" || $color2 == NULL) { $list['final_colors'] = ""; } else { $color_separate = explode(',', $color2); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name_2($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"] . "+" . $colo["hex_code"] . "+" . $colo["id"]; } $final_color2 = implode(",", $final_color); $list[$aRow['id']]['final_colors'] = $final_color2; } } //$this->update_impressions($ids); // $this->memcached_library->add($key_cache, $list, 86400); // $this->set_memcachekeys($key_cache); return $list; // } // else { // return $GetAllCars3; // } } public function duplicate_title(){ $list = []; $title = []; $c = 0; $sql = mysql_query("select listings.*,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from listings inner join clients on listings.client_id=clients.client_id where publish_ocd='1' order by refresh desc"); while ($aRow = mysql_fetch_array($sql)) { $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['is_premium'] = $aRow['is_premium']; $list[$aRow['id']]['reference_id'] = $aRow['reference_id']; $list[$aRow['id']]['id'] = $aRow['id']; $model = $list[$aRow['id']]['car_brand'] = $aRow['car_model']; $model = $this->get_name($model, "models", "name,brand_img_png,seo_url"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['seo_url'] = $model["seo_url"]; $list[$aRow['id']]['car_model_eng'] = $model["name"]; $list[$aRow['id']]['brand_image'] = $model['brand_img_png']; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype,cartype1,cartype2,description,doors,larg_bag,passengers,video,rate_reviews,review_date,years,url"); $list[$aRow['id']]['video'] = $make["video"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_eng'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['make_url'] = $make["url"]; $list[$aRow['id']]['larg_bag'] = $make['larg_bag']; if ($make['passengers'] != "" || $make['passengers'] != "0") { $list[$aRow['id']]['passengers'] = $make['passengers']; } else { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } $list[$aRow['id']]['car_desc'] = $make["description"]; $cartype = $make["cartype"]; $cartype1 = $make["cartype1"]; $cartype2 = $make["cartype2"]; $list[$aRow['id']]['cartype_id'] = $cartype; $cartype = $this->get_name($cartype, "car_types", "name,url"); $list[$aRow['id']]['cartype'] = $cartype["name"]; if ($cartype1 > 0) { $cartype1datata = $this->get_name($cartype1, "car_types", "name,url"); $list[$aRow['id']]['cartype_1_id'] = $cartype1; $list[$aRow['id']]['cartype_1_name'] = $cartype1datata["name"]; } if ($cartype2 > 0) { $cartype2data = $this->get_name($cartype2, "car_types", "name,url"); $list[$aRow['id']]['cartype_2_id'] = $cartype2; $list[$aRow['id']]['cartype_2_name'] = $cartype2data["name"]; } $list[$aRow['id']]['cartype_url'] = $cartype["url"]; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['under_promotion'] = $aRow['under_promotion']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['car_spec_id'] = $aRow['car_spec_id']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['car_type'] = $aRow['car_type']; $list[$aRow['id']]['page'] = $aRow['page']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['security_amount_hour'] = $aRow['security_amount_hour']; $list[$aRow['id']]['car_is'] = $aRow['car_is']; $list[$aRow['id']]['chauffer'] = $aRow['chauffer']; $list[$aRow['id']]['additional_mileage_charge'] = $aRow['additional_mileage_charge']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['accepted_in'] = $aRow['accepted_in']; $list[$aRow['id']]['note'] = $aRow['note']; $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['min_days_booking'] = $min_days_booking = $aRow['min_days_booking']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $client_id = $aRow['client_id']; $client = $this->get_company($client_id, "clients", "emirate"); $client_id = $aRow['client_id']; $client = $this->get_company($client_id, "clients", "languages_spoken,accepted_in_cl,small_logo,small_logo_webp,logo_webp,swf,company_name,description,airport_meetgreet,delivery_at_location,salik_toll_charges,client_currency,client_country,cost_of_delivery,minimum_cust_age,location,location_arabic,fast_delivery_locations,youtube,youtube_status,emirate,gps_device_cost,cost_driver_coverage,unverified_business"); $list[$aRow['id']]['emirate'] = $client["emirate"]; $list[$aRow['id']]['client_country'] = $client["client_country"]; $list[$aRow['id']]['client_currency'] = $client["client_currency"]; $list[$aRow['id']]['cost_of_delivery'] = $client["cost_of_delivery"]; } // while ($aRow = mysql_fetch_array($sql)) { // $model = $aRow['car_model']; // $model = $this->get_name_2($model, "models", "name,brand_img_png,brand_img_webp,brand_img,seo_url"); // $list[$aRow['id']]['car_model'] = $model["name"]; // $make = $aRow['car_make']; // $make = $this->get_name_2($make, "make", "name,logo,cartype,doors,passengers,larg_bag,rate_reviews,review_date,years,url"); // $list[$aRow['id']]['car_make'] = $make["name"]; // $list[$aRow['id']]['year'] = $aRow['year']; // $title[$c]['id'] = $aRow['id']; // $title[$c]['title']= "Rent" . " " . $model["name"] . " " . $make["name"] . " " . $aRow['year'] . " " . "in" . " " . $aRow["emirate"]; // //echo "
"; // $tle[$c] = "Rent" . " " . $model["name"] . " " . $make["name"] . " " . $aRow['year'] . " " . "in" . " " . $aRow["emirate"]; // $c++; // } // $unique = array_unique($tle); // //$duplicates = array_diff_assoc($tle, $unique); // //print_r(count($unique)); // //echo "
"; // $ids = []; // $i = 0; // foreach($unique as $s){ // $b = 0; // foreach($title as $t){ // if($t['title'] == $s){ // if($b==0){ // $b++; // } else { // $ids[$i] = $t['id']; // $i++; // } // } // } // } return $list; } public function set_refid($ids){ foreach($ids as $b){ $sql = mysql_query("update listings set reference_id = 'Ref$b' where id = $b"); } } public function GetAllPremium_new($url, $where_stmt_premium, $order) { if (strpos($order, 'featured') !== false) { $order = str_ireplace("featured desc", "", $order); $order = str_ireplace(", images_verify desc", "images_verify desc", $order); } if (strpos($order, 'weekly_price') !== false) { $where_stmt_premium = str_ireplace("weekly_price!='0' and", "", $where_stmt_premium); } if (strpos($order, 'monthly_price') !== false) { $where_stmt_premium = str_ireplace("monthly_price!='0' and", "", $where_stmt_premium); } $sql = mysql_query("select listing_id,client_id from premium_listings where seo_url='$url'"); if (mysql_num_rows($sql) > 0) { $listings = array(); while ($val = mysql_fetch_array($sql)) { $lists = $val['listing_id']; $client_id = $val['client_id']; $sql2 = mysql_query("select listings.id from listings inner join clients on listings.client_id=clients.client_id where $where_stmt_premium and listings.id='$lists' and publish_ocd='1'"); if (mysql_num_rows($sql2) > 0) { $listings[] = $lists; } else { $val2 = []; $sql3 = mysql_query("select listings.id from listings inner join clients on listings.client_id=clients.client_id where $where_stmt_premium and listings.client_id='$client_id' and publish_ocd='1' order by $order refresh desc limit 1"); if (mysql_num_rows($sql3) > 0) { $val2 = mysql_fetch_array($sql3); $listings[] = $val2['id']; } } } $list = implode(",", $listings); $sql2 = "select * from listings where id IN ($list) order by $order refresh desc"; $list = []; try { $rResult = mysql_query($sql2); if ($rResult) { //continue } else { return $list; } $rResult = mysql_query($sql2) or die(mysql_error()); } catch (Exception $e) { return $list; } while ($aRow = mysql_fetch_array($rResult)) { /* update impressions date_wise */ $date = date('Y-m-d'); /*$update_impression=mysql_query("select * from track_impressions where listing_id='".$aRow['id']."' and client_id='".$aRow['client_id']."' and date_ts='$date'")or die(mysql_error()); if(mysql_num_rows($update_impression)>0) { $impression=mysql_fetch_array($update_impression); $track_id=$impression['track_id']; $check_imp=$impression['impressions']; $sql_imp =mysql_query("update track_impressions set impressions = $check_imp + 1 where track_id='$track_id'")or die(mysql_error()); } else { $sql_imp =mysql_query("insert into track_impressions set impressions ='1', listing_id='".$aRow['id']."',client_id='".$aRow['client_id']."',date_ts='$date'")or die(mysql_error()); }*/ /* END update impressions date_wise */ $feature_k = $aRow['free_features']; if ($feature_k == "") { $list[$aRow['id']]['final_feature'] = "0"; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name_2($valfeature, "free_features", "name,icons"); if ($fea["name"] != "") { $final_feature[] = $fea["name"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $model = $aRow['car_model']; $model = $this->get_name_2($model, "models", "name,brand_img_png,brand_img_webp,brand_img,seo_url"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['brand_image'] = $model['brand_img_webp']; $list[$aRow['id']]['brand_svg'] = $model['brand_img']; $list[$aRow['id']]['seo_url'] = $model['seo_url']; $make = $aRow['car_make']; $make = $this->get_name_2($make, "make", "name,logo,cartype,doors,passengers,larg_bag,rate_reviews,review_date,years,url"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_id'] = $aRow['car_make']; $list[$aRow['id']]['car_model_id'] = $aRow['car_model']; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['make_url'] = $make["url"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; $list[$aRow['id']]['larg_bag'] = $make['larg_bag']; if ($make['passengers'] == "" || $make['passengers'] == "0") { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } else { $list[$aRow['id']]['passengers'] = $make['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name_2($cartype, "car_types", "name,icon,url"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_icon'] = $cartype["icon"]; $list[$aRow['id']]['cartype_url'] = $cartype["url"]; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['showcase_day'] = $aRow['showcase_day']; $list[$aRow['id']]['showcase_week'] = $aRow['showcase_week']; $list[$aRow['id']]['showcase_month'] = $aRow['showcase_month']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['hour_price_status'] = $aRow['hour_price_status']; $list[$aRow['id']]['daily_price_status'] = $aRow['daily_price_status']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['security_amount_hour'] = $aRow['security_amount_hour']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['under_promotion'] = $aRow['under_promotion']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_day'] = $aRow['mileage_day']; $list[$aRow['id']]['cdw_day'] = $aRow["cdw_day"]; $list[$aRow['id']]['cdw_month'] = $aRow["cdw_month"]; $list[$aRow['id']]['mile_week'] = $aRow['mileage_week']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['min_days_booking'] = $aRow['min_days_booking']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; if (($aRow['images_verify'] == 2) && ($aRow['verification_expiry'] >= date("Y-m-d"))) { $list[$aRow['id']]['gallery'] = $this->get_gallery_2($aRow['id']); } $trans = $aRow['transmission']; $trans = $this->get_name_2($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client = $this->get_company_2($aRow['client_id'], "clients", "company_name,small_logo,logo,emirate,logo_webp,swf,small_logo_webp,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,phone_number,client_currency,client_country,cost_of_delivery, minimum_cust_age, fast_delivery_locations,supplier_settings,gcc_specs_cl,unverified_business"); $list[$aRow['id']]['fast_delivery_locations'] = $client["fast_delivery_locations"]; $list[$aRow['id']]['airport_meet'] = $client["airport_meetgreet"]; $list[$aRow['id']]['delivery_location'] = $client["delivery_at_location"]; $list[$aRow['id']]['location'] = $client["location_arabic"]; $list[$aRow['id']]['supplier_settings'] = $client["supplier_settings"]; $list[$aRow['id']]['small_company_logo_png'] = $client["small_logo"]; $list[$aRow['id']]['location_english'] = $client["location"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; $list[$aRow['id']]['latitude'] = $client["latitude"]; $list[$aRow['id']]['longitude'] = $client["longitude"]; $list[$aRow['id']]['client_currency'] = $client["client_currency"]; $list[$aRow['id']]['unverified_business'] = $client["unverified_business"]; $list[$aRow['id']]['client_country'] = $client["client_country"]; $list[$aRow['id']]['whatsapp_number'] = $client["whatsapp_number"]; $list[$aRow['id']]['phone_number'] = $client["phone_number"]; $list[$aRow['id']]['cost_of_delivery'] = $client["cost_of_delivery"]; $list[$aRow['id']]['minimum_cust_age'] = $client["minimum_cust_age"]; $list[$aRow['id']]['gcc_specs_cl'] = $client["gcc_specs_cl"]; if (strpos($client["small_logo_webp"], '.webp') !== false) { $list[$aRow['id']]['small_company_logo'] = 'company_small_webp/' . $client["small_logo_webp"]; } else { $list[$aRow['id']]['small_company_logo'] = $client["small_logo_webp"]; } if (strpos($client["logo_webp"], '.webp') !== false) { $list[$aRow['id']]['company_logo'] = 'company_webp/' . $client["logo_webp"]; } else { $list[$aRow['id']]['company_logo'] = $client["logo_webp"]; } $qry = mysql_query("SELECT * FROM delivery_terms WHERE delivery_term = 'Free' and emirate='" . $client['emirate'] . "' and client_id = '" . $aRow['client_id'] . "'"); if (mysql_num_rows($qry) > 0) { $list[$aRow['id']]['free_delivery'] = "Free Delivery"; } else { $list[$aRow['id']]['free_delivery'] = "0"; } $color2 = $aRow['color']; if ($color2 == "" || $color2 == NULL) { $list['final_colors'] = ""; } else { $color_separate = explode(',', $color2); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name_2($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"] . "+" . $colo["hex_code"] . "+" . $colo["id"]; } $final_color2 = implode(",", $final_color); $list[$aRow['id']]['final_colors'] = $final_color2; } } //$this->update_impressions($ids); // $this->memcached_library->add($key_cache, $list, 86400); // $this->set_memcachekeys($key_cache); return $list; } else { return 0; } } public function GetAllPremium($url, $order) { if (strpos($order, 'featured') !== false) { $order = str_ireplace("featured desc", "", $order); $order = str_ireplace(", images_verify desc", "images_verify desc", $order); } $sql = mysql_query("select listing_id,client_id from premium_listings where seo_url='$url'"); if (mysql_num_rows($sql) > 0) { $listings = array(); while ($val = mysql_fetch_array($sql)) { $lists = $val['listing_id']; $client_id = $val['client_id']; $sql2 = mysql_query("select id from listings where id='$lists' and publish_ocd='1'"); if (mysql_num_rows($sql2) > 0) { $listings[] = $lists; } else { $val2 = []; $sql3 = mysql_query("select id from listings where client_id='$client_id' and publish_ocd='1' and delete_status='0' order by $order refresh desc limit 1"); if (mysql_num_rows($sql3) > 0) { $val2 = mysql_fetch_array($sql3); $listings[] = $val2['id']; } } } $list = implode(",", $listings); $sql2 = "select * from listings where id IN ($list) order by $order refresh desc"; $list = []; try { $rResult = mysql_query($sql2); if ($rResult) { //continue } else { return $list; } $rResult = mysql_query($sql2) or die(mysql_error()); } catch (Exception $e) { return $list; } while ($aRow = mysql_fetch_array($rResult)) { /* update impressions date_wise */ $date = date('Y-m-d'); /*$update_impression=mysql_query("select * from track_impressions where listing_id='".$aRow['id']."' and client_id='".$aRow['client_id']."' and date_ts='$date'")or die(mysql_error()); if(mysql_num_rows($update_impression)>0) { $impression=mysql_fetch_array($update_impression); $track_id=$impression['track_id']; $check_imp=$impression['impressions']; $sql_imp =mysql_query("update track_impressions set impressions = $check_imp + 1 where track_id='$track_id'")or die(mysql_error()); } else { $sql_imp =mysql_query("insert into track_impressions set impressions ='1', listing_id='".$aRow['id']."',client_id='".$aRow['client_id']."',date_ts='$date'")or die(mysql_error()); }*/ /* END update impressions date_wise */ $feature_k = $aRow['free_features']; if ($feature_k == "") { $list[$aRow['id']]['final_feature'] = "0"; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name($valfeature, "free_features", "name,icons"); if ($fea["name"] != "") { $final_feature[] = $fea["name"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name,brand_img_png,brand_img_webp,brand_img,seo_url"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['brand_image'] = $model['brand_img_webp']; $list[$aRow['id']]['brand_svg'] = $model['brand_img']; $list[$aRow['id']]['seo_url'] = $model['seo_url']; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype,doors,passengers,larg_bag,rate_reviews,review_date,years,url"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_id'] = $aRow['car_make']; $list[$aRow['id']]['car_model_id'] = $aRow['car_model']; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['make_url'] = $make["url"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; $list[$aRow['id']]['larg_bag'] = $make['larg_bag']; if ($make['passengers'] == "" || $make['passengers'] == "0") { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } else { $list[$aRow['id']]['passengers'] = $make['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name,icon,url"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_icon'] = $cartype["icon"]; $list[$aRow['id']]['cartype_url'] = $cartype["url"]; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['showcase_day'] = $aRow['showcase_day']; $list[$aRow['id']]['showcase_week'] = $aRow['showcase_week']; $list[$aRow['id']]['showcase_month'] = $aRow['showcase_month']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['hour_price_status'] = $aRow['hour_price_status']; $list[$aRow['id']]['daily_price_status'] = $aRow['daily_price_status']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['security_amount_hour'] = $aRow['security_amount_hour']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['under_promotion'] = $aRow['under_promotion']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_day'] = $aRow['mileage_day']; $list[$aRow['id']]['cdw_day'] = $aRow["cdw_day"]; $list[$aRow['id']]['cdw_month'] = $aRow["cdw_month"]; $list[$aRow['id']]['mile_week'] = $aRow['mileage_week']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['min_days_booking'] = $aRow['min_days_booking']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; if (($aRow['images_verify'] == 2) && ($aRow['verification_expiry'] >= date("Y-m-d"))) { $list[$aRow['id']]['gallery'] = $this->get_gallery($aRow['id']); } $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,small_logo,logo,emirate,logo_webp,swf,small_logo_webp,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,phone_number,client_currency,client_country,cost_of_delivery, minimum_cust_age, fast_delivery_locations,supplier_settings,gcc_specs_cl,unverified_business"); $list[$aRow['id']]['fast_delivery_locations'] = $client["fast_delivery_locations"]; $list[$aRow['id']]['airport_meet'] = $client["airport_meetgreet"]; $list[$aRow['id']]['delivery_location'] = $client["delivery_at_location"]; $list[$aRow['id']]['location'] = $client["location_arabic"]; $list[$aRow['id']]['supplier_settings'] = $client["supplier_settings"]; $list[$aRow['id']]['small_company_logo_png'] = $client["small_logo"]; $list[$aRow['id']]['location_english'] = $client["location"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; $list[$aRow['id']]['latitude'] = $client["latitude"]; $list[$aRow['id']]['longitude'] = $client["longitude"]; $list[$aRow['id']]['client_currency'] = $client["client_currency"]; $list[$aRow['id']]['unverified_business'] = $client["unverified_business"]; $list[$aRow['id']]['client_country'] = $client["client_country"]; $list[$aRow['id']]['whatsapp_number'] = $client["whatsapp_number"]; $list[$aRow['id']]['phone_number'] = $client["phone_number"]; $list[$aRow['id']]['cost_of_delivery'] = $client["cost_of_delivery"]; $list[$aRow['id']]['minimum_cust_age'] = $client["minimum_cust_age"]; $list[$aRow['id']]['gcc_specs_cl'] = $client["gcc_specs_cl"]; if (strpos($client["small_logo_webp"], '.webp') !== false) { $list[$aRow['id']]['small_company_logo'] = 'company_small_webp/' . $client["small_logo_webp"]; } else { $list[$aRow['id']]['small_company_logo'] = $client["small_logo_webp"]; } if (strpos($client["logo_webp"], '.webp') !== false) { $list[$aRow['id']]['company_logo'] = 'company_webp/' . $client["logo_webp"]; } else { $list[$aRow['id']]['company_logo'] = $client["logo_webp"]; } $qry = mysql_query("SELECT * FROM delivery_terms WHERE delivery_term = 'Free' and emirate='" . $client['emirate'] . "' and client_id = '" . $aRow['client_id'] . "'"); if (mysql_num_rows($qry) > 0) { $list[$aRow['id']]['free_delivery'] = "Free Delivery"; } else { $list[$aRow['id']]['free_delivery'] = "0"; } $color2 = $aRow['color']; if ($color2 == "" || $color2 == NULL) { $list['final_colors'] = ""; } else { $color_separate = explode(',', $color2); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"] . "+" . $colo["hex_code"] . "+" . $colo["id"]; } $final_color2 = implode(",", $final_color); $list[$aRow['id']]['final_colors'] = $final_color2; } } //$this->update_impressions($ids); // $this->memcached_library->add($key_cache, $list, 86400); // $this->set_memcachekeys($key_cache); return $list; } else { return 0; } } function get_gallery($gid) { // $key_cache='get_gallery@'.$gid; // $get_gallery = $this->memcached_library->get($key_cache); // if(!$getAllCars && !is_numeric($get_gallery)){ $sql_query = "select * from gallery where listing_id=" . $gid . " and status=2 order by `index` desc"; $Result = mysql_query($sql_query) or die(mysql_error()); $gallery = array(); $k = 0; while ($Row = mysql_fetch_array($Result)) { $gallery[$k]['file'] = $Row['file']; $gallery[$k]['thumbnail'] = $Row['thumbnail']; $gallery[$k]['s3_status'] = $Row['s3_status']; $k++; } // $this->memcached_library->add($key_cache, $gallery); // $this->set_memcachekeys($key_cache); return $gallery; // } // else { // return $get_gallery; // } } function get_gallery_2($gid) { $key_cache = 'get_gallery_3@' . $gid; $get_gallery = $this->memcached_library->get($key_cache); if (!$get_gallery && !is_numeric($get_gallery)) { $sql_query = "select * from gallery where listing_id=" . $gid . " and status=2 order by `index` desc"; $Result = mysql_query($sql_query) or die(mysql_error()); $gallery = array(); $k = 0; while ($Row = mysql_fetch_array($Result)) { $gallery[$k]['file'] = $Row['file']; $gallery[$k]['thumbnail'] = $Row['thumbnail']; $gallery[$k]['s3_status'] = $Row['s3_status']; $k++; } $this->memcached_library->add($key_cache, $gallery, 86400); $this->set_memcachekeys($key_cache); return $gallery; } else { return $get_gallery; } } function GetAllCars3_arabic($start, $cars_per_page, $where_stmt, $order) { $sql = "select * from listings where $where_stmt and publish_ocd='1' order by $order refresh desc limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { /* update impressions date_wise */ $date = date('Y-m-d'); /*$update_impression=mysql_query("select * from track_impressions where listing_id='".$aRow['id']."' and client_id='".$aRow['client_id']."' and date_ts='$date'")or die(mysql_error()); if(mysql_num_rows($update_impression)>0) { $impression=mysql_fetch_array($update_impression); $track_id=$impression['track_id']; $check_imp=$impression['impressions']; $sql_imp =mysql_query("update track_impressions set impressions = $check_imp + 1 where track_id='$track_id'")or die(mysql_error()); } else { $sql_imp =mysql_query("insert into track_impressions set impressions ='1', listing_id='".$aRow['id']."',client_id='".$aRow['client_id']."',date_ts='$date'")or die(mysql_error()); }*/ /* END update impressions date_wise */ $feature_k = $aRow['free_features']; if ($feature_k == " ") { $list[$aRow['id']]['final_feature'] = ""; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name($valfeature, "free_features", "name_arabic,icons"); if ($fea["name_arabic"] != "") { $final_feature[] = $fea["name_arabic"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name_arabic,name"); $list[$aRow['id']]['car_model'] = $model["name_arabic"]; $list[$aRow['id']]['car_model_eng'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name_arabic,name,logo,cartype,doors,passengers,rate_reviews,review_date,years"); $list[$aRow['id']]['car_make'] = $make["name_arabic"]; $list[$aRow['id']]['car_make_eng'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; if ($make['passengers'] == "" || $make['passengers'] == "0") { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } else { $list[$aRow['id']]['passengers'] = $make['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name_arabic"); $list[$aRow['id']]['cartype'] = $cartype["name_arabic"]; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['under_promotion'] = $aRow['under_promotion']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mile_week'] = $aRow['mileage_week']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['min_days_booking'] = $aRow['min_days_booking']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['larg_bag'] = $aRow['larg_bag']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; if (($aRow['images_verify'] == 2) && ($aRow['verification_expiry'] >= date("Y-m-d"))) { $sql_query = "select * from gallery where listing_id=" . $aRow['id'] . " and status=2 order by `index` desc"; $Result = mysql_query($sql_query) or die(mysql_error()); $gallery = array(); $k = 0; while ($Row = mysql_fetch_array($Result)) { $gallery[$k]['file'] = $Row['file']; $gallery[$k]['thumbnail'] = $Row['thumbnail']; $k++; } $list[$aRow['id']]['gallery'] = $gallery; } $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,company_name_arabic,emirate_arabic,logo,swf,small_logo,location,location_arabic,airport_meetgreet,delivery_at_location,latitude,longitude,whatsapp_number,client_currency,client_country,cost_of_delivery,minimum_cust_age"); $list[$aRow['id']]['airport_meet'] = $client["airport_meetgreet"]; $list[$aRow['id']]['delivery_location'] = $client["delivery_at_location"]; $list[$aRow['id']]['location'] = $client["location_arabic"]; $list[$aRow['id']]['location_english'] = $client["location"]; $list[$aRow['id']]['small_company_logo'] = $client["small_logo"]; $list[$aRow['id']]['company_name'] = $client["company_name_arabic"]; $list[$aRow['id']]['company_name_english'] = $client["company_name"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; $list[$aRow['id']]['emirate'] = $client["emirate_arabic"]; $list[$aRow['id']]['latitude'] = $client["latitude"]; $list[$aRow['id']]['longitude'] = $client["longitude"]; $list[$aRow['id']]['whatsapp_number'] = $client["whatsapp_number"]; $list[$aRow['id']]['client_currency'] = $client["client_currency"]; $list[$aRow['id']]['client_country'] = $client["client_country"]; $list[$aRow['id']]['cost_of_delivery'] = $client["cost_of_delivery"]; $list[$aRow['id']]['minimum_cust_age'] = $client["minimum_cust_age"]; $color2 = $aRow['color']; if ($color2 == "" || $color2 == NULL) { $list['final_colors'] = ""; } else { $color_separate = explode(',', $color2); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"] . "+" . $colo["hex_code"] . "+" . $colo["id"];; } $final_color2 = implode(",", $final_color); $list[$aRow['id']]['final_colors'] = $final_color2; } } // $this->update_impressions($ids); return $list; } function GetAllCars2($start, $cars_per_page, $where_stmt, $order) { $sql = "select id , car_model , client_id , car_make , passengers , doors , daily_price , monthly_price, weekly_price, larg_bag , year , transmission , page , featured from listings where $where_stmt and publish_ocd='1' order by featured desc , $order page desc , refresh desc limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $cartype = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['passengers'] = $aRow['passengers']; $list[$aRow['id']]['doors'] = $aRow['doors']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['larg_bag'] = $aRow['larg_bag']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,emirate,logo,swf,small_logo,location"); $list[$aRow['id']]['location'] = $client["location"]; $list[$aRow['id']]['small_company_logo'] = $client["small_logo"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; } return $list; } function GetAllUsedCars($start, $cars_per_page, $where_stmt, $order) { $key_cache = 'getAllUsedCars1@' . $start . '@' . $cars_per_page . '@' . $where_stmt . '@' . $order; $getAllUsedCars = $this->memcached_library->get($key_cache); if (!$getAllUsedCars && !is_numeric($getAllUsedCars)) { $sql = "select * from usedcar_listings where $where_stmt and publish_ocd='1' order by featured desc , $order page desc , refresh desc limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $cartype = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['passengers'] = $aRow['passengers']; $list[$aRow['id']]['doors'] = $aRow['doors']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['daily_price'] = $aRow['price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['larg_bag'] = $aRow['larg_bag']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,logo,swf,small_logo,location"); $list[$aRow['id']]['location'] = $client["location"]; $list[$aRow['id']]['small_company_logo'] = $client["small_logo"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; } $this->memcached_library->add($key_cache, $list, 3600); $this->set_memcachekeys($key_cache); return $list; } else { return $getAllUsedCars; } } function GetAllCars($start, $cars_per_page, $where_stmt, $order) { $key_cache = 'getAllCars1@' . $start . '@' . $cars_per_page . '@' . $where_stmt . '@' . $order; $getAllCars = $this->memcached_library->get($key_cache); if (!$getAllCars && !is_numeric($getAllCars)) { $sql = "select * from listings where $where_stmt and publish_ocd='1' order by featured desc , $order page desc , refresh desc limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $cartype = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['passengers'] = $aRow['passengers']; $list[$aRow['id']]['doors'] = $aRow['doors']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['larg_bag'] = $aRow['larg_bag']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,logo,swf,small_logo,location"); $list[$aRow['id']]['location'] = $client["location"]; $list[$aRow['id']]['small_company_logo'] = $client["small_logo"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; } $this->memcached_library->add($key_cache, $list, 3600); $this->set_memcachekeys($key_cache); return $list; } else { return $getAllCars; } } function GetAllCars_recomm($start, $cars_per_page, $where_stmt, $order) { $sql = "select *, CAST(recomm_count AS UNSIGNED) AS Recommcount from listings where $where_stmt and publish_ocd='1' order by $order limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $feature_k = $aRow['free_features']; if ($feature_k == "") { $list[$aRow['id']]['final_feature'] = "0"; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name($valfeature, "free_features", "name,icons"); if ($fea["name"] != "") { $final_feature[] = $fea["name"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name,name_arabic"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['car_model_arabic'] = $model["name_arabic"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,name_arabic,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_arabic'] = $make["name_arabic"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $cartype = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['passengers'] = $aRow['passengers']; $list[$aRow['id']]['doors'] = $aRow['doors']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['larg_bag'] = $aRow['larg_bag']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,logo,swf,small_logo,location,airport_meetgreet,delivery_at_location"); $list[$aRow['id']]['airport_meet'] = $client["airport_meetgreet"]; $list[$aRow['id']]['delivery_location'] = $client["delivery_at_location"]; $list[$aRow['id']]['location'] = $client["location"]; $list[$aRow['id']]['small_company_logo'] = $client["small_logo"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; } return $list; } function get_trending_deals(){ $query = "SELECT * FROM trending_deals WHERE id = 1"; $result = $this->db->query($query); return $result->result_array(); } function GetAllListings($start, $cars_per_page, $where_stmt, $order) { $sql = "select * from listings where $where_stmt and delete_status='0' order by featured desc ,publish_ocd desc, refresh desc, $order page desc limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $list[$aRow['id']]['car_make_id'] = $aRow['car_make']; $list[$aRow['id']]['car_model_id'] = $aRow['car_model']; $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $cartype = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['passengers'] = $aRow['passengers']; $list[$aRow['id']]['note'] = $aRow['note']; $list[$aRow['id']]['is_lock'] = $aRow['is_lock']; $list[$aRow['id']]['min_days_booking'] = $aRow['min_days_booking']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['accepted_in'] = $aRow['accepted_in']; $list[$aRow['id']]['chauffer'] = $aRow['chauffer']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['car_is'] = $aRow['car_is']; $list[$aRow['id']]['cdw_day'] = $aRow['cdw_day']; $list[$aRow['id']]['cdw_month'] = $aRow['cdw_month']; $list[$aRow['id']]['additional_mileage_charge'] = $aRow['additional_mileage_charge']; $list[$aRow['id']]['impressions'] = $aRow['impressions']; $list[$aRow['id']]['views'] = $aRow['views']; $list[$aRow['id']]['best_offer'] = $aRow['best_offer']; $list[$aRow['id']]['popular_car'] = $aRow['popular_car']; $list[$aRow['id']]['colors'] = $aRow['color']; $list[$aRow['id']]['feature'] = $aRow['free_features']; $list[$aRow['id']]['doors'] = $aRow['doors']; $list[$aRow['id']]['video'] = $aRow['video']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['publish_ocd'] = $aRow['publish_ocd']; $list[$aRow['id']]['showcase_day'] = $aRow['showcase_day']; $list[$aRow['id']]['showcase_week'] = $aRow['showcase_week']; $list[$aRow['id']]['showcase_month'] = $aRow['showcase_month']; $list[$aRow['id']]['private_website'] = $aRow['private_website']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['additional_mileage_charge_hour'] = $aRow['security_amount_hour']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $refresh = $aRow['refresh']; $list[$aRow['id']]['refresh_time'] = $this->get_refresh_date($refresh); $list[$aRow['id']]['larg_bag'] = $aRow['larg_bag']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; /*$trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name");*/ $list[$aRow['id']]['transmission'] = $aRow['transmission']; $list[$aRow['id']]['reg_card'] = $aRow['reg_card']; $list[$aRow['id']]['no_expiry_date'] = $aRow['no_expiry_date']; $list[$aRow['id']]['reg_card_back'] = $aRow['reg_card_back']; $list[$aRow['id']]['reg_card_expiry'] = $aRow['reg_card_expiry']; $list[$aRow['id']]['submit_status'] = $aRow['submit_status']; $list[$aRow['id']]['submit_time'] = $aRow['submit_time']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['reason_reject'] = $aRow['reason_reject']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; $list[$aRow['id']]['verified_on'] = $aRow['verified_on']; $ids[] = $aRow['id']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,logo,swf,small_logo,location"); $list[$aRow['id']]['location'] = $client["location"]; $list[$aRow['id']]['small_company_logo'] = $client["small_logo"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['company_logo'] = $client["logo"]; $list[$aRow['id']]['images'] = $this->get_car_images($aRow['id']); } return $list; } function get_car_image_gallery($list_id) { } function get_car_images($list_id) { $result = $this->db->query("SELECT * FROM gallery WHERE listing_id = ? ORDER BY `index` ASC", array("listing_id" => $list_id)); return $result->result_array(); } function get_car_images_mulkiya($list_id) { $result = $this->db->query("SELECT * FROM mulkiya WHERE listing_id = ? and (type LIKE '%image%' OR type LIKE '%pdf%') ORDER BY `index` ASC", array("listing_id" => $list_id)); return $result->result_array(); } function get_car_video_mulkiya($list_id) { $result = $this->db->query("SELECT * FROM mulkiya WHERE listing_id = ? and type LIKE '%video%' ORDER BY `index` ASC", array("listing_id" => $list_id)); return $result->result_array(); } function GetAllLeads($client_id, $limit) { $sql = "select email_sms.listing_id,listings.car_model,listings.car_make,listings.featured,listings.year,listings.monthly_price,listings.weekly_price,listings.daily_price,listings.transmission,email_sms.email,email_sms.mobile,email_sms.name,email_sms.message,email_sms.ts,email_sms.id from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='1' and email_sms.daily_spam='0' and email_sms.client_id='$client_id' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts) ORDER BY email_sms.id desc limit $limit"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $listing_id = $aRow['listing_id']; $check_share_lead = mysql_query("select * from listings where client_id='$client_id' and id='$listing_id'"); if (mysql_num_rows($check_share_lead) > 0) { $list[$aRow['id']]['share_lead'] = '0'; $list[$aRow['id']]['featured'] = $aRow['featured']; } else { $list[$aRow['id']]['share_lead'] = '1'; $list[$aRow['id']]['featured'] = '0'; } $list[$aRow['id']]['id'] = $aRow['listing_id']; $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['year'] = $aRow['year']; $cartype = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['message'] = $aRow['message']; $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $list[$aRow['id']]['email'] = $aRow['email']; $list[$aRow['id']]['mobile'] = $aRow['mobile']; $list[$aRow['id']]['ts'] = $aRow['ts']; $list[$aRow['id']]['name'] = $aRow['name']; } return $list; } function get_leads_count($client_id) { $sql = mysql_query("select * from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='1' and email_sms.daily_spam='0' and email_sms.client_id='$client_id' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts)"); $data = mysql_num_rows($sql); return $data; } function get_listings_count($client_id) { $sql = mysql_query("select * from listings where client_id='$client_id' and listings.delete_status='0'"); $data = mysql_num_rows($sql); return $data; } function GetAllLeads_main($start, $cars_per_page, $client_id) { $sql = "select email_sms.listing_id,email_sms.from_page,email_sms.car_type,email_sms.dropoffdate,email_sms.pickupdate,listings.car_model,listings.car_make,listings.featured,listings.year,listings.monthly_price,listings.weekly_price,listings.daily_price,listings.transmission,listings.passengers,email_sms.email,email_sms.mobile,email_sms.name,email_sms.message,email_sms.ts,email_sms.time,email_sms.id,email_sms.type from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type IN (1,3,4) and email_sms.daily_spam='0' and email_sms.client_id='$client_id' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts) ORDER BY email_sms.id desc limit $start, $cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $listing_id = $aRow['listing_id']; $check_share_lead = mysql_query("select * from listings where client_id='$client_id' and id='$listing_id'"); if (mysql_num_rows($check_share_lead) > 0) { $list[$aRow['id']]['share_lead'] = '0'; $list[$aRow['id']]['featured'] = $aRow['featured']; } else { $list[$aRow['id']]['share_lead'] = '1'; $list[$aRow['id']]['featured'] = '0'; } $list[$aRow['id']]['id'] = $aRow['listing_id']; $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['car_typeid'] = $make['cartype']; $car_typeid = $make['cartype']; if ($car_typeid != '0') { $cartype = $car_typeid; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; } else { $cartype = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; } $list[$aRow['id']]['type'] = $aRow['type']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['message'] = $aRow['message']; $list[$aRow['id']]['passengers'] = $aRow['passengers']; $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $list[$aRow['id']]['email'] = $aRow['email']; $list[$aRow['id']]['mobile'] = $aRow['mobile']; $list[$aRow['id']]['ts'] = $aRow['ts']; $list[$aRow['id']]['time'] = $aRow['time']; $list[$aRow['id']]['from_page'] = $aRow['from_page']; $list[$aRow['id']]['name'] = $aRow['name']; $list[$aRow['id']]['name'] = $aRow['name']; $list[$aRow['id']]['name'] = $aRow['name']; $list[$aRow['id']]['pickupdate'] = $aRow['pickupdate']; $list[$aRow['id']]['dropoffdate'] = $aRow['dropoffdate']; } return $list; } function get_leads_count_all($client_id, $filterby) { /*$sql_website = mysql_query("select * from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='1' and email_sms.client_id='$client_id' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts)");*/ /*$sql_mobile = mysql_query("select * from mobileapp_email_sms_track INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='1' and email_sms.client_id='$client_id' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts)");*/ $sql_website = "select email_sms.id from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type='1' and email_sms.client_id='$client_id' and email_sms.daily_spam='0' and listings.delete_status='0' and listings.publish_ocd='1' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts)"; $sql_mobile = "select est.id from mobileapp_email_sms_track as est INNER JOIN listings l ON est.listing_id=l.id where est.type='1' and est.client_id='$client_id' and est.daily_spam='0' and l.delete_status='0' and l.publish_ocd='1' and est.name NOT LIKE 'test' group by est.listing_id ,est.client_id,est.mobile,DATE(ts)"; if ($filterby == "All") $sql = "( " . $sql_website . " )" . " UNION ALL " . "( " . $sql_mobile . " )"; else if ($filterby == "Website") $sql = $sql_website; else if ($filterby == "OCDapp") $sql = $sql_mobile; else $sql = "( " . $sql_website . " )" . " UNION ALL " . "( " . $sql_mobile . " )"; $rResult = mysql_query($sql) or die(mysql_error()); $data = mysql_num_rows($rResult); return $data; } function GetAllLeads_main_all($start, $cars_per_page, $client_id, $filterby) { if ($filterby == "All") $cars_per_page1 = 15; else $cars_per_page1 = 30; $sql_website = "select 'Website' as 'resulttype' , email_sms.listing_id,email_sms.from_page,email_sms.car_type,email_sms.dropoffdate,email_sms.pickupdate,listings.car_model,listings.car_make,listings.featured,listings.year,listings.monthly_price,listings.weekly_price,listings.daily_price,listings.transmission,listings.passengers,email_sms.email,email_sms.mobile,email_sms.name,email_sms.message,email_sms.ts,email_sms.time,email_sms.id,email_sms.type from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type IN (1,3,4) and email_sms.daily_spam='0' and email_sms.client_id='$client_id' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts) ORDER BY email_sms.id desc limit $start, $cars_per_page1"; $sql_mobile = "select 'OCD App' as 'resulttype' , email_sms.listing_id,email_sms.from_page,email_sms.car_type,email_sms.dropoffdate,email_sms.pickupdate,listings.car_model,listings.car_make,listings.featured,listings.year,listings.monthly_price,listings.weekly_price,listings.daily_price,listings.transmission,listings.passengers,email_sms.email,email_sms.mobile,email_sms.name,email_sms.message,email_sms.ts,email_sms.time,email_sms.id,email_sms.type from mobileapp_email_sms_track as email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.type IN (1,3,4) and email_sms.daily_spam='0' and email_sms.client_id='$client_id' and email_sms.name NOT LIKE 'test' group by email_sms.listing_id ,email_sms.client_id,email_sms.mobile,DATE(ts) ORDER BY email_sms.id desc limit $start, $cars_per_page1"; if ($filterby == "All") $sql = "( " . $sql_website . " )" . " UNION ALL " . "( " . $sql_mobile . " )"; else if ($filterby == "Website") $sql = $sql_website; else if ($filterby == "OCDapp") $sql = $sql_mobile; else $sql = "( " . $sql_website . " )" . " UNION ALL " . "( " . $sql_mobile . " )"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $listing_id = $aRow['listing_id']; $check_share_lead = mysql_query("select * from listings where client_id='$client_id' and id='$listing_id'"); if (mysql_num_rows($check_share_lead) > 0) { $list[$aRow['id']]['share_lead'] = '0'; $list[$aRow['id']]['featured'] = $aRow['featured']; } else { $list[$aRow['id']]['share_lead'] = '1'; $list[$aRow['id']]['featured'] = '0'; } $list[$aRow['id']]['id'] = $aRow['listing_id']; $list[$aRow['id']]['resulttype'] = $aRow["resulttype"]; $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['car_typeid'] = $make['cartype']; $car_typeid = $make['cartype']; if ($car_typeid != '0') { $cartype = $car_typeid; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; } else { $cartype = $make["cartype"]; $cartype = $this->get_name($cartype, "car_types", "name"); $list[$aRow['id']]['cartype'] = $cartype["name"]; } $list[$aRow['id']]['type'] = $aRow['type']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['message'] = $aRow['message']; $list[$aRow['id']]['passengers'] = $aRow['passengers']; $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $list[$aRow['id']]['email'] = $aRow['email']; $list[$aRow['id']]['mobile'] = $aRow['mobile']; $list[$aRow['id']]['ts'] = $aRow['ts']; $list[$aRow['id']]['time'] = $aRow['time']; $list[$aRow['id']]['from_page'] = $aRow['from_page']; $list[$aRow['id']]['name'] = $aRow['name']; $list[$aRow['id']]['name'] = $aRow['name']; $list[$aRow['id']]['name'] = $aRow['name']; $list[$aRow['id']]['pickupdate'] = $aRow['pickupdate']; $list[$aRow['id']]['dropoffdate'] = $aRow['dropoffdate']; } return $list; } function GetAllLease($start, $cars_per_page, $client_id) { $sql = "select * from email_lease where lease_type='0' and client_id='$client_id' ORDER BY ts desc limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $list[$aRow['id']]['car_type'] = $aRow['car_type']; $list[$aRow['id']]['web_address'] = $aRow['web_address']; $list[$aRow['id']]['message'] = $aRow['message']; $list[$aRow['id']]['period'] = $aRow['period']; $list[$aRow['id']]['sender'] = $aRow['sender']; $list[$aRow['id']]['emirates'] = $aRow['emirates']; $list[$aRow['id']]['email'] = $aRow['email_id']; $list[$aRow['id']]['mobile'] = $aRow['mobile']; $list[$aRow['id']]['ts'] = $aRow['ts']; $list[$aRow['id']]['name'] = $aRow['name']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['lease_type'] = $aRow['lease_type']; $list[$aRow['id']]['lease_id'] = $aRow['lease_id']; if ($aRow['lease_id'] > 0) { $sql2 = mysql_query("select * from lease_cars where id='" . $aRow['lease_id'] . "'"); $aRow2 = mysql_fetch_array($sql2); $model = $aRow2['car_model']; $model = $this->get_name($model, "models", "name"); $make = $aRow2['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype"); $list[$aRow['id']]['car_name'] = $model["name"] . " " . $make["name"] . " " . $aRow2['year']; $list[$aRow['id']]['form_type'] = "Lease Procees"; $sql3 = mysql_query("select * from email_lease where insert_id='" . $aRow['id'] . "' and lease_type='1' and client_id='$client_id'"); $list[$aRow['id']]['call_clicks'] = mysql_num_rows($sql3); $sql4 = mysql_query("select * from email_lease where insert_id='" . $aRow['id'] . "' and lease_type='2' and client_id='$client_id'"); $list[$aRow['id']]['whatsapp_clicks'] = mysql_num_rows($sql4); } else { $list[$aRow['id']]['car_name'] = ""; $list[$aRow['id']]['form_type'] = "Instant Book"; $list[$aRow['id']]['call_clicks'] = "0"; $list[$aRow['id']]['whatsapp_clicks'] = "0"; } } return $list; } function get_lease_count($client_id) { $sql = mysql_query("select * from email_lease where client_id='$client_id' ORDER BY ts desc"); $count = mysql_num_rows($sql); return $count; } function leads_chart($client_id, $date_limit, $startdate, $enddate, $check_all_listing = 1) { $date = date("Y-m-d"); $rec_email = []; $rec_phone = []; $rec_wa = []; $rec_other = []; $rec_email2 = []; $rec_phone2 = []; $rec_wa2 = []; $c = 0; $qry = $this->db->query("SELECT * FROM clients WHERE client_id = ?",array($client_id)); $res = $qry->row_array(); $more_rentals = $res["more_rentals"]; if($more_rentals == 5){ // if($check_all_listing == 1){ $sql = "select * from usedcar_listings where client_id='$client_id' AND car_model > 0 AND car_make > 0 order by refresh DESC"; // }else{ // $sql = "select * from usedcar_listings where (publish_ocd='1' or mobile_publish_ocd='1') and delete_status='0' and client_id='$client_id'"; // } }else{ // if($check_all_listing == 1){ $sql = "select * from listings where client_id='$client_id' AND car_model > 0 AND car_make > 0 order by refresh DESC"; // }else{ // $sql = "select * from listings where (publish_ocd='1' or mobile_publish_ocd='1') and delete_status='0' and client_id='$client_id'"; // } } // $sql = "select * from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.client_id='$client_id' and listings.delete_status='0' and listings.publish_ocd='1' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() group by listing_id"; $rResult = mysql_query($sql) or die(mysql_error()); $i = 0; $str = ""; if (mysql_num_rows($rResult) > 0) { while ($aRow = mysql_fetch_array($rResult)) { $listing_id = $aRow['id']; if($i == 0){ $str = $listing_id; } else { $str .= ",".$listing_id; } $i++; $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['delete_status'] = $aRow['delete_status']; $list[$aRow['id']]['publish_ocd'] = $aRow['publish_ocd']; $list[$aRow['id']]['mobile_publish_ocd'] = $aRow['mobile_publish_ocd']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['is_premium'] = $aRow['is_premium']; if ($aRow['images_verify'] == '2' && $aRow['verification_expiry'] >= $date) { $list[$aRow['id']]['is_verify'] = "1"; } else { $list[$aRow['id']]['is_verify'] = "2"; } $trim = $aRow['car_trim']; if (!empty($trim)) { $trim = $this->get_name($trim, "usedcar_trim", "name"); if (!empty($trim['name'])) { $list[$aRow['id']]['car_trim'] = $trim['name']; } } } $product_type = "1,2"; //email if($more_rentals == 5){ $sql = mysql_query("select count(id) as count, listing_id from email_sms where usedcar IN ($product_type) and type='1' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $sql = mysql_query("select count(id) as count, listing_id from email_sms where type='1' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); } if (mysql_num_rows($sql) > 0) { while ($lead_lead1 = mysql_fetch_array($sql)){ if($lead_lead1['count'] != ''){ $list[$lead_lead1['listing_id']]['lead_email'] = $lead_lead1['count']; } } } if($more_rentals == 5){ $mobileEmailSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where usedcar IN ($product_type) and type='1' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $mobileEmailSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where type='1' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); } if (mysql_num_rows($mobileEmailSql) > 0) { while ($lead_lead_emial1 = mysql_fetch_array($mobileEmailSql)){ if($lead_lead_emial1['count'] != ''){ $list[$lead_lead_emial1['listing_id']]['lead_email_ap'] = $lead_lead_emial1['count']; } } } //lead_phone if($more_rentals == 5){ $sqlPhone = mysql_query("select count(id) as count, listing_id from email_sms where usedcar IN ($product_type) and type='2' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $sqlPhone = mysql_query("select count(id) as count, listing_id from email_sms where type='2' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); } if (mysql_num_rows($sqlPhone) > 0) { while ($lead_lead_phone1 = mysql_fetch_array($sqlPhone)){ if($lead_lead_phone1['count'] != ''){ $list[$lead_lead_phone1['listing_id']]['lead_phone'] = $lead_lead_phone1['count']; } } } if($more_rentals == 5){ $mobilePhoneMobSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where usedcar IN ($product_type) and type='2' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $mobilePhoneMobSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where type='2' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); } if (mysql_num_rows($mobilePhoneMobSql) > 0) { while ($lead_lead_mob_phone1 = mysql_fetch_array($mobilePhoneMobSql)){ if($lead_lead_mob_phone1['count'] != ''){ $list[$lead_lead_mob_phone1['listing_id']]['lead_phone_ap'] = $lead_lead_mob_phone1['count']; } } } //lead_wa if($more_rentals == 5){ $sqlWa = mysql_query("select count(id) as count, listing_id from email_sms where usedcar IN ($product_type) and type='5' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $sqlWa = mysql_query("select count(id) as count, listing_id from email_sms where type='5' and client_id='$client_id' and daily_spam='0' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); } if (mysql_num_rows($sqlWa) > 0) { while ($lead_lead_wa1 = mysql_fetch_array($sqlWa)){ if($lead_lead_wa1['count'] != ''){ $list[$lead_lead_wa1['listing_id']]['lead_wa'] = $lead_lead_wa1['count']; } } } if($more_rentals == 5){ $mobileWhatsppSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where usedcar IN ($product_type) and type='5' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $mobileWhatsppSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where type='5' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); } if (mysql_num_rows($mobileWhatsppSql) > 0) { while ($lead_lead_mob_whatsapp1 = mysql_fetch_array($mobileWhatsppSql)){ if($lead_lead_mob_whatsapp1['count'] != ''){ $list[$lead_lead_mob_whatsapp1['listing_id']]['lead_wa_ap'] = $lead_lead_mob_whatsapp1['count']; } } } //lead_other if($more_rentals == 5){ $sqlOthers = mysql_query("select count(id) as count, listing_id from email_sms where usedcar IN ($product_type) and type NOT IN ('1','2','5') and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $sqlOthers = mysql_query("select count(id) as count, listing_id from email_sms where type NOT IN ('1','2','5') and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); } if (mysql_num_rows($sqlOthers) > 0) { while ($lead_lead_other1 = mysql_fetch_array($sqlOthers)){ if($lead_lead_other1['count'] != ''){ $list[$lead_lead_other1['listing_id']]['lead_other'] = $lead_lead_other1['count']; } } } //lead_other if($more_rentals == 5){ $mobileOtherSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where usedcar IN ($product_type) and type NOT IN ('1','2','5') and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $mobileOtherSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where type NOT IN ('1','2','5') and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); } if (mysql_num_rows($mobileOtherSql) > 0) { while ($lead_lead_mob_other1 = mysql_fetch_array($mobileOtherSql)){ if($lead_lead_mob_other1['count'] != ''){ $list[$lead_lead_mob_other1['listing_id']]['lead_other_ap'] = $lead_lead_mob_other1['count']; } } } //total web leads if($more_rentals == 5){ $totalLeadSql = mysql_query("select count(id) as count, listing_id from email_sms where usedcar IN ($product_type) and type != '8' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $totalLeadSql = mysql_query("select count(id) as count, listing_id from email_sms where type != '8' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); } if (mysql_num_rows($totalLeadSql) > 0) { while ($lead_total = mysql_fetch_array($totalLeadSql)){ if($lead_total['count'] != ''){ $list[$lead_total['listing_id']]['total_lead'] = $lead_total['count']; } } } //total mobile leads if($more_rentals == 5){ $totalLeadMobSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where usedcar IN ($product_type) and type != '8' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id"); }else{ $totalLeadMobSql = mysql_query("select count(id) as count, listing_id from mobileapp_email_sms_track where type != '8' and daily_spam='0' and client_id='$client_id' and ts BETWEEN '$startdate' AND '$enddate' GROUP BY listing_id "); } if (mysql_num_rows($totalLeadMobSql) > 0) { while ($lead_total_mob = mysql_fetch_array($totalLeadMobSql)){ if($lead_total_mob['count'] != ''){ $list[$lead_total_mob['listing_id']]['total_lead_mobile'] = $lead_total_mob['count']; } } } } else { // $list[$aRow['id']]['car_model'] = '0'; // $list[$aRow['id']]['car_make'] = '0'; // $list[$aRow['id']]['year'] = '0'; // $list[$aRow['id']]['views'] = '0'; // $list[$aRow['id']]['impressions'] = '0'; // $list[$aRow['id']]['lead_email'] = '0'; // $list[$aRow['id']]['lead_phone'] = '0'; // $list[$aRow['id']]['total_lead'] = '0'; } // echo json_encode($list); return $list; } function leads_chart_optimized($client_id, $date_limit, $startdate, $enddate, $check_all_listing = 1) { $date = date("Y-m-d"); $list = []; // Get client info $qry = $this->db->query("SELECT more_rentals FROM clients WHERE client_id = ?", array($client_id)); $res = $qry->row_array(); $more_rentals = $res["more_rentals"]; // Build listings query with parameterized query if($more_rentals == 5){ // $sql = "SELECT id, car_model, car_make, year, delete_status, publish_ocd, mobile_publish_ocd, featured, is_premium, images_verify, verification_expiry, car_trim FROM usedcar_listings WHERE client_id=? AND car_model > 0 AND car_make > 0 ORDER BY refresh DESC"; $this->db->select('id, car_model, car_make, year, delete_status, publish_ocd, mobile_publish_ocd, featured, is_premium, images_verify, verification_expiry, car_trim'); $this->db->from('usedcar_listings'); $this->db->where('client_id', $client_id); $this->db->where('car_model >', 0); $this->db->where('car_make >', 0); $this->db->order_by('refresh', 'DESC'); $query = $this->db->get(); } else { // $sql = "SELECT id, car_model, car_make, year, delete_status, publish_ocd, mobile_publish_ocd, featured, is_premium, images_verify, verification_expiry, car_trim FROM listings WHERE client_id=? AND car_model > 0 AND car_make > 0 ORDER BY refresh DESC"; $this->db->select('id, car_model, car_make, year, delete_status, publish_ocd, mobile_publish_ocd, featured, is_premium, images_verify, verification_expiry'); $this->db->from('listings'); $this->db->where('client_id', $client_id); $this->db->where('car_model >', 0); $this->db->where('car_make >', 0); $this->db->order_by('refresh', 'DESC'); $query = $this->db->get(); } $rResult = $query; if (isset($_GET['debug']) && $_GET['debug'] == 1) { echo 'Clientid: ' . $client_id . '
'; echo 'Last Query:
'; echo $this->db->last_query(); echo '
Rows: '; echo $rResult->num_rows(); } if ($rResult->num_rows() > 0) { $rows = $rResult->result_array(); // Collect all IDs for efficient string building $listing_ids = array_column($rows, 'id'); $str = implode(',', $listing_ids); // Collect all model, make, and trim IDs for batch fetching $model_ids = array_unique(array_filter(array_column($rows, 'car_model'))); $make_ids = array_unique(array_filter(array_column($rows, 'car_make'))); $trim_ids = array_unique(array_filter(array_column($rows, 'car_trim'))); // fetch all models $models_map = []; if (!empty($model_ids)) { $model_ids_str = implode(',', $model_ids); $models_query = $this->db->query("SELECT id, name FROM models WHERE id IN ($model_ids_str)"); foreach ($models_query->result_array() as $model_row) { $models_map[$model_row['id']] = $model_row['name']; } } // fetch all makes $makes_map = []; if (!empty($make_ids)) { $make_ids_str = implode(',', $make_ids); $makes_query = $this->db->query("SELECT id, name FROM make WHERE id IN ($make_ids_str)"); foreach ($makes_query->result_array() as $make_row) { $makes_map[$make_row['id']] = $make_row['name']; } } // fetch all trims $trims_map = []; if (!empty($trim_ids)) { $trim_ids_str = implode(',', $trim_ids); $trims_query = $this->db->query("SELECT id, name FROM usedcar_trim WHERE id IN ($trim_ids_str)"); foreach ($trims_query->result_array() as $trim_row) { $trims_map[$trim_row['id']] = $trim_row['name']; } } // Process listings foreach ($rows as $aRow) { $listing_id = $aRow['id']; $list[$listing_id]['car_model'] = isset($models_map[$aRow['car_model']]) ? $models_map[$aRow['car_model']] : ''; $list[$listing_id]['car_make'] = isset($makes_map[$aRow['car_make']]) ? $makes_map[$aRow['car_make']] : ''; $list[$listing_id]['year'] = $aRow['year']; $list[$listing_id]['delete_status'] = $aRow['delete_status']; $list[$listing_id]['publish_ocd'] = $aRow['publish_ocd']; $list[$listing_id]['mobile_publish_ocd'] = $aRow['mobile_publish_ocd']; $list[$listing_id]['featured'] = $aRow['featured']; $list[$listing_id]['is_premium'] = $aRow['is_premium']; if ($aRow['images_verify'] == '2' && $aRow['verification_expiry'] >= $date) { $list[$listing_id]['is_verify'] = "1"; } else { $list[$listing_id]['is_verify'] = "2"; } if (!empty($aRow['car_trim']) && isset($trims_map[$aRow['car_trim']])) { $list[$listing_id]['car_trim'] = $trims_map[$aRow['car_trim']]; } } $product_type = "1,2"; // OPTIMIZED: Combine all email_sms queries into one query if($more_rentals == 5){ $webLeadsSql = "SELECT listing_id, SUM(CASE WHEN type='1' THEN 1 ELSE 0 END) as lead_email, SUM(CASE WHEN type='2' THEN 1 ELSE 0 END) as lead_phone, SUM(CASE WHEN type='5' THEN 1 ELSE 0 END) as lead_wa, SUM(CASE WHEN type NOT IN ('1','2','5') THEN 1 ELSE 0 END) as lead_other, SUM(CASE WHEN type != '8' AND type != '' THEN 1 ELSE 0 END) as total_lead FROM email_sms WHERE usedcar IN ($product_type) AND daily_spam='0' AND client_id=? AND ts BETWEEN ? AND ? GROUP BY listing_id"; $webLeadsQuery = $this->db->query($webLeadsSql, array($client_id, $startdate, $enddate)); } else { $webLeadsSql = "SELECT listing_id, SUM(CASE WHEN type='1' THEN 1 ELSE 0 END) as lead_email, SUM(CASE WHEN type='2' THEN 1 ELSE 0 END) as lead_phone, SUM(CASE WHEN type='5' THEN 1 ELSE 0 END) as lead_wa, SUM(CASE WHEN type NOT IN ('1','2','5') THEN 1 ELSE 0 END) as lead_other, SUM(CASE WHEN type != '8' AND type != '' THEN 1 ELSE 0 END) as total_lead FROM email_sms WHERE daily_spam='0' AND client_id=? AND ts BETWEEN ? AND ? GROUP BY listing_id"; $webLeadsQuery = $this->db->query($webLeadsSql, array($client_id, $startdate, $enddate)); } if($_GET['debug'] == 1){ echo 'web leads sql starts here
'; echo $webLeadsSql; echo '
'; } // Process web leads results if ($webLeadsQuery->num_rows() > 0) { foreach ($webLeadsQuery->result_array() as $lead_row) { $lid = $lead_row['listing_id']; if (!empty($lead_row['lead_email'])) { $list[$lid]['lead_email'] = $lead_row['lead_email']; } if (!empty($lead_row['lead_phone'])) { $list[$lid]['lead_phone'] = $lead_row['lead_phone']; } if (!empty($lead_row['lead_wa'])) { $list[$lid]['lead_wa'] = $lead_row['lead_wa']; } if (!empty($lead_row['lead_other'])) { $list[$lid]['lead_other'] = $lead_row['lead_other']; } if (!empty($lead_row['total_lead'])) { $list[$lid]['total_lead'] = $lead_row['total_lead']; } } } // OPTIMIZED: Combine all mobileapp_email_sms_track queries into one query if($more_rentals == 5){ $mobileLeadsSql = "SELECT listing_id, SUM(CASE WHEN type='1' THEN 1 ELSE 0 END) as lead_email_ap, SUM(CASE WHEN type='2' THEN 1 ELSE 0 END) as lead_phone_ap, SUM(CASE WHEN type='5' THEN 1 ELSE 0 END) as lead_wa_ap, SUM(CASE WHEN type NOT IN ('1','2','5') THEN 1 ELSE 0 END) as lead_other_ap, SUM(CASE WHEN type != '8' THEN 1 ELSE 0 END) as total_lead_mobile FROM mobileapp_email_sms_track WHERE usedcar IN ($product_type) AND daily_spam='0' AND client_id=? AND ts BETWEEN ? AND ? GROUP BY listing_id"; $mobileLeadsQuery = $this->db->query($mobileLeadsSql, array($client_id, $startdate, $enddate)); } else { $mobileLeadsSql = "SELECT listing_id, SUM(CASE WHEN type='1' THEN 1 ELSE 0 END) as lead_email_ap, SUM(CASE WHEN type='2' THEN 1 ELSE 0 END) as lead_phone_ap, SUM(CASE WHEN type='5' THEN 1 ELSE 0 END) as lead_wa_ap, SUM(CASE WHEN type NOT IN ('1','2','5') THEN 1 ELSE 0 END) as lead_other_ap, SUM(CASE WHEN type != '8' THEN 1 ELSE 0 END) as total_lead_mobile FROM mobileapp_email_sms_track WHERE daily_spam='0' AND client_id=? AND ts BETWEEN ? AND ? GROUP BY listing_id"; $mobileLeadsQuery = $this->db->query($mobileLeadsSql, array($client_id, $startdate, $enddate)); } if($_GET['debug'] == 1){ echo 'mobile leads sql starts here
'; echo $mobileLeadsSql; echo '
'; } // Process mobile leads results if ($mobileLeadsQuery->num_rows() > 0) { foreach ($mobileLeadsQuery->result_array() as $lead_row) { $lid = $lead_row['listing_id']; if (!empty($lead_row['lead_email_ap'])) { $list[$lid]['lead_email_ap'] = $lead_row['lead_email_ap']; } if (!empty($lead_row['lead_phone_ap'])) { $list[$lid]['lead_phone_ap'] = $lead_row['lead_phone_ap']; } if (!empty($lead_row['lead_wa_ap'])) { $list[$lid]['lead_wa_ap'] = $lead_row['lead_wa_ap']; } if (!empty($lead_row['lead_other_ap'])) { $list[$lid]['lead_other_ap'] = $lead_row['lead_other_ap']; } if (!empty($lead_row['total_lead_mobile'])) { $list[$lid]['total_lead_mobile'] = $lead_row['total_lead_mobile']; } } } } //removed not required listings if(!empty($list)){ foreach($list as $key => $value){ if(!isset($value['total_lead']) && !isset($value['total_lead_mobile'])){ unset($list[$key]); } else if(!isset($value['total_lead']) && isset($value['total_lead_mobile'])){ $value['total_lead'] = 0; } else if(empty($value['total_lead']) && empty($value['total_lead_mobile'])){ unset($list[$key]); } } } if($_GET['debug'] == 1){ echo 'listings after removing not required listings starts here
'; echo json_encode($list); echo '
'; } return $list; } function leads_main_chart($client_id, $date_limit, $sort) { $date = date("Y-m-d"); $rec_email = []; $rec_phone = []; $rec_wa = []; $rec_other = []; $rec_email2 = []; $rec_phone2 = []; $rec_wa2 = []; $c = 0; $qry = $this->db->query("SELECT * FROM clients WHERE client_id = ?",array($client_id)); $res = $qry->row_array(); $more_rentals = $res["more_rentals"]; // $sql = "select * from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.client_id='$client_id' and listings.delete_status='0' and listings.publish_ocd='1' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() group by listing_id"; if($more_rentals == 5){ if ($sort == "top_10") { $sql = "select count(*) as counts,usedcar_listings.id,usedcar_listings.car_make,usedcar_listings.car_model,usedcar_listings.year from usedcar_listings INNER JOIN email_sms on usedcar_listings.id=email_sms.listing_id where (publish_ocd='1' or mobile_publish_ocd='1') and email_sms.daily_spam='0' and delete_status='0' and email_sms.client_id='$client_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP by email_sms.listing_id order by counts DESC limit 10"; } else if ($sort == "low_10") { $sql = "select count(*) as counts,usedcar_listings.id,usedcar_listings.car_make,usedcar_listings.car_model,usedcar_listings.year from usedcar_listings INNER JOIN email_sms on usedcar_listings.id=email_sms.listing_id where (publish_ocd='1' or mobile_publish_ocd='1') and email_sms.daily_spam='0' and delete_status='0' and email_sms.client_id='$client_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP by email_sms.listing_id order by counts ASC limit 10"; } else { $sql = "select * from usedcar_listings where (publish_ocd='1' or mobile_publish_ocd='1') and delete_status='0' and client_id='$client_id' limit $sort,10"; } }else{ if ($sort == "top_10") { $sql = "select count(*) as counts,listings.id,listings.car_make,listings.car_model,listings.year from listings INNER JOIN email_sms on listings.id=email_sms.listing_id where (publish_ocd='1' or mobile_publish_ocd='1') and email_sms.daily_spam='0' and delete_status='0' and email_sms.client_id='$client_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP by email_sms.listing_id order by counts DESC limit 10"; } else if ($sort == "low_10") { $sql = "select count(*) as counts,listings.id,listings.car_make,listings.car_model,listings.year from listings INNER JOIN email_sms on listings.id=email_sms.listing_id where (publish_ocd='1' or mobile_publish_ocd='1') and email_sms.daily_spam='0' and delete_status='0' and email_sms.client_id='$client_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP by email_sms.listing_id order by counts ASC limit 10"; } else { $sql = "select * from listings where (publish_ocd='1' or mobile_publish_ocd='1') and delete_status='0' and client_id='$client_id' limit $sort,10"; } } $rResult = mysql_query($sql) or die(mysql_error()); // $sql_email = mysql_query("select listing_id, count(*) as count from email_sms where type='1' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); // while ($lead_email = mysql_fetch_array($sql_email)){ // $rec_email[$c]['listing_id'] = $lead_email['listing_id']; // $rec_email[$c]['count'] = $lead_email['count']; // $c++; // } // $c = 0; // //$list[$aRow['id']]['lead_email'] = $lead_email['count']; // $sql_phone = mysql_query("select listing_id, count(*) as count2 from email_sms where type='2' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); // //$lead_phone = mysql_fetch_array($sql_phone); // //$list[$aRow['id']]['lead_phone'] = $lead_phone['count2']; // while ($lead_phone = mysql_fetch_array($sql_phone)){ // $rec_phone[$c]['listing_id'] = $lead_phone['listing_id']; // $rec_phone[$c]['count'] = $lead_phone['count']; // $c++; // } // $c = 0; // $sql_wa = mysql_query("select listing_id, count(*) as count3 from email_sms where type='5' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); // //$lead_wa = mysql_fetch_array($sql_wa); // //$list[$aRow['id']]['lead_wa'] = $lead_wa['count3']; // while ($lead_wa = mysql_fetch_array($sql_wa)){ // $rec_wa[$c]['listing_id'] = $lead_wa['listing_id']; // $rec_wa[$c]['count'] = $lead_wa['count']; // $c++; // } // $c = 0; // $sql_other = mysql_query("select listing_id, count(*) as count3 from email_sms where type NOT IN ('1','2','5') and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); // //$lead_other = mysql_fetch_array($sql_other); // //$list[$aRow['id']]['lead_other'] = $lead_other['count3']; // while ($lead_other = mysql_fetch_array($sql_other)){ // $rec_other[$c]['listing_id'] = $lead_other['listing_id']; // $rec_other[$c]['count'] = $lead_other['count']; // $c++; // } // $c = 0; // $sql_email2 = mysql_query("select listing_id, count(*) as count from mobileapp_email_sms_track where type='1' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); // //$lead_email2 = mysql_fetch_array($sql_email2); // //$list[$aRow['id']]['lead_email_app'] = $lead_email2['count']; // while ($lead_email2 = mysql_fetch_array($sql_email2)){ // $rec_email2[$c]['listing_id'] = $lead_email2['listing_id']; // $rec_email2[$c]['count'] = $lead_email2['count']; // $c++; // } // $c = 0; // $sql_phone2 = mysql_query("select listing_id, count(*) as count2 from mobileapp_email_sms_track where type='2' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); // //$lead_phone2 = mysql_fetch_array($sql_phone2); // //$list[$aRow['id']]['lead_phone_app'] = $lead_phone2['count2']; // while ($lead_phone2 = mysql_fetch_array($sql_phone2)){ // $rec_phone2[$c]['listing_id'] = $lead_phone2['listing_id']; // $rec_phone2[$c]['count'] = $lead_phone2['count']; // $c++; // } // $c = 0; // $sql_wa2 = mysql_query("select listing_id, count(*) as count3 from mobileapp_email_sms_track where type='5' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); // //$lead_wa2 = mysql_fetch_array($sql_wa2); // //$list[$aRow['id']]['lead_phone_app'] = $lead_wa2['count3']; // while ($lead_wa2 = mysql_fetch_array($sql_wa2)){ // $rec_wa2[$c]['listing_id'] = $lead_wa2['listing_id']; // $rec_wa2[$c]['count'] = $lead_wa2['count']; // $c++; // } //die(); $i = 0; $str = ""; if (mysql_num_rows($rResult) > 0) { while ($aRow = mysql_fetch_array($rResult)) { $listing_id = $aRow['id']; if($i == 0){ $str = $listing_id; } else { $str .= ",".$listing_id; } $i++; $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['year'] = $aRow['year']; /*$sql_view=mysql_query("select SUM(views) as total from track_views where listing_id='$listing_id' and date_ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() group by listing_id"); $views=mysql_fetch_array($sql_view); $list[$aRow['id']]['views']=$views['total']; $sql_impression=mysql_query("select SUM(impressions) as total from track_impressions where listing_id='$listing_id' and date_ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() group by listing_id"); $impressions=mysql_fetch_array($sql_impression); $list[$aRow['id']]['impressions']=$impressions['total']; */ // $sql_email = mysql_query("select count(*) as count from email_sms where listing_id='$listing_id' and type='1' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW()") or die(mysql_error()); // $lead_email = mysql_fetch_array($sql_email); // $list[$aRow['id']]['lead_email'] = $lead_email['count']; // $sql_phone = mysql_query("select count(*) as count2 from email_sms where listing_id='$listing_id' and type='2' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW()") or die(mysql_error()); // $lead_phone = mysql_fetch_array($sql_phone); // $list[$aRow['id']]['lead_phone'] = $lead_phone['count2']; // $sql_wa = mysql_query("select count(*) as count3 from email_sms where listing_id='$listing_id' and type='5' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW()") or die(mysql_error()); // $lead_wa = mysql_fetch_array($sql_wa); // $list[$aRow['id']]['lead_wa'] = $lead_wa['count3']; // $sql_other = mysql_query("select count(*) as count3 from email_sms where listing_id='$listing_id' and type NOT IN ('1','2','5') and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW()") or die(mysql_error()); // $lead_other = mysql_fetch_array($sql_other); // $list[$aRow['id']]['lead_other'] = $lead_other['count3']; // $sql_email2 = mysql_query("select count(*) as count from mobileapp_email_sms_track where listing_id='$listing_id' and type='1' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW()") or die(mysql_error()); // $lead_email2 = mysql_fetch_array($sql_email2); // $list[$aRow['id']]['lead_email_app'] = $lead_email2['count']; // $sql_phone2 = mysql_query("select count(*) as count2 from mobileapp_email_sms_track where listing_id='$listing_id' and type='2' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW()") or die(mysql_error()); // $lead_phone2 = mysql_fetch_array($sql_phone2); // $list[$aRow['id']]['lead_phone_app'] = $lead_phone2['count2']; // $sql_wa2 = mysql_query("select count(*) as count3 from mobileapp_email_sms_track where listing_id='$listing_id' and type='5' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW()") or die(mysql_error()); // $lead_wa2 = mysql_fetch_array($sql_wa2); // $list[$aRow['id']]['lead_phone_app'] = $lead_wa2['count3']; /* $sql_lead=mysql_query("select count(id) as count from email_sms where listing_id='$listing_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() and type!='8' and type!=''"); $sql_lead2 = mysql_fetch_array($sql_lead); $list[$aRow['id']]['total_lead']=$sql_lead2['count']; $sql_lead_mobile=mysql_query("select count(id) as count from mobileapp_email_sms_track where listing_id='$listing_id' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW()"); $sql_lead_mobile2 = mysql_fetch_array($sql_lead_mobile); $list[$aRow['id']]['total_lead_mobile']=$sql_lead_mobile2['count']; */ } //echo $str; $sql_email = mysql_query("select listing_id, count(*) as count from email_sms where listing_id IN ($str) and type='1' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); if (mysql_num_rows($sql_email) > 0) { while ($lead_email = mysql_fetch_array($sql_email)){ $list[$lead_email['listing_id']]['lead_email'] = $lead_email['count']; } } $sql_phone = mysql_query("select listing_id, count(*) as count2 from email_sms where listing_id IN ($str) and type='2' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); //$lead_phone = mysql_fetch_array($sql_phone); //$list[$aRow['id']]['lead_phone'] = $lead_phone['count2']; if (mysql_num_rows($sql_phone) > 0) { while ($lead_phone = mysql_fetch_array($sql_phone)){ $list[$lead_phone['listing_id']]['lead_phone'] = $lead_phone['count2']; } } $sql_wa = mysql_query("select listing_id, count(*) as count3 from email_sms where listing_id IN ($str) and type='5' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); //$lead_wa = mysql_fetch_array($sql_wa); //$list[$aRow['id']]['lead_wa'] = $lead_wa['count3']; if (mysql_num_rows($sql_wa) > 0) { while ($lead_wa = mysql_fetch_array($sql_wa)){ $list[$lead_wa['listing_id']]['lead_wa'] = $lead_wa['count3']; } } $sql_other = mysql_query("select listing_id, count(*) as count3 from email_sms where listing_id IN ($str) and daily_spam='0' and type NOT IN ('1','2','5') and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); //$lead_other = mysql_fetch_array($sql_other); //$list[$aRow['id']]['lead_other'] = $lead_other['count3']; if (mysql_num_rows($sql_other) > 0) { while ($lead_other = mysql_fetch_array($sql_other)){ $list[$lead_other['listing_id']]['lead_other'] = $lead_other['count3']; } } $sql_email2 = mysql_query("select listing_id, count(*) as count from mobileapp_email_sms_track where listing_id IN ($str) and type='1' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); //$lead_email2 = mysql_fetch_array($sql_email2); //$list[$aRow['id']]['lead_email_app'] = $lead_email2['count']; if (mysql_num_rows($sql_email2) > 0) { while ($lead_email2 = mysql_fetch_array($sql_email2)){ $list[$lead_email2['listing_id']]['lead_email_app'] = $lead_email2['count']; } } $sql_phone2 = mysql_query("select listing_id, count(*) as count2 from mobileapp_email_sms_track where listing_id IN ($str) and type='2' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); //$lead_phone2 = mysql_fetch_array($sql_phone2); //$list[$aRow['id']]['lead_phone_app'] = $lead_phone2['count2']; if (mysql_num_rows($sql_phone2) > 0) { while ($lead_phone2 = mysql_fetch_array($sql_phone2)){ $list[$lead_phone2['listing_id']]['lead_phone_app'] = $lead_phone2['count2']; } } $sql_wa2 = mysql_query("select listing_id, count(*) as count3 from mobileapp_email_sms_track where listing_id IN ($str) and type='5' and daily_spam='0' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() GROUP BY listing_id") or die(mysql_error()); //$lead_wa2 = mysql_fetch_array($sql_wa2); //$list[$aRow['id']]['lead_phone_app'] = $lead_wa2['count3']; if (mysql_num_rows($sql_wa2) > 0) { while ($lead_wa2 = mysql_fetch_array($sql_wa2)){ $list[$lead_wa2['listing_id']]['lead_phone_app'] = $lead_wa2['count3']; } } //die(); } else { $list[$aRow['id']]['car_model'] = '0'; $list[$aRow['id']]['car_make'] = '0'; $list[$aRow['id']]['year'] = '0'; $list[$aRow['id']]['lead_email'] = '0'; $list[$aRow['id']]['lead_phone'] = '0'; $list[$aRow['id']]['lead_wa'] = '0'; $list[$aRow['id']]['lead_other'] = '0'; $list[$aRow['id']]['lead_email_app'] = '0'; $list[$aRow['id']]['lead_phone_app'] = '0'; $list[$aRow['id']]['lead_wa_app'] = '0'; } return $list; } function leads_main_chart_total($client_id, $date_limit) { $date = date("Y-m-d"); // $sql = "select * from email_sms INNER JOIN listings ON email_sms.listing_id=listings.id where email_sms.client_id='$client_id' and listings.delete_status='0' and listings.publish_ocd='1' and ts BETWEEN DATE_SUB(NOW(), INTERVAL $date_limit DAY) AND NOW() group by listing_id"; $qry = $this->db->query("SELECT * FROM clients WHERE client_id = ?",array($client_id)); $res = $qry->row_array(); $more_rentals = $res["more_rentals"]; if($more_rentals == 5){ $sql = "select count(*) as count from usedcar_listings where (publish_ocd='1' or mobile_publish_ocd='1') and delete_status='0' and client_id='$client_id'"; }else{ $sql = "select count(*) as count from listings where (publish_ocd='1' or mobile_publish_ocd='1') and delete_status='0' and client_id='$client_id'"; } $rResult = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($rResult) > 0) { $aRow = mysql_fetch_array($rResult); $listing_id = $aRow['count']; return $listing_id; } } function get_feedback($client_id) { $sql = "select call_tracking.id,call_tracking.client_name,call_tracking.call_status,call_tracking.last_updated,call_tracking.car_available,call_tracking.honest,call_tracking.email,call_tracking.mobile,listings.car_model, listings.car_make,listings.year from call_tracking INNER JOIN listings ON call_tracking.listing_id=listings.id where call_tracking.client_id='$client_id' and call_tracking.call_status!='' order by call_tracking.last_updated DESC"; $rResult = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($rResult) > 0) { while ($aRow = mysql_fetch_array($rResult)) { $model = $aRow['car_model']; $model = $this->get_name($model, "models", "name"); $list[$aRow['id']]['car_model'] = $model["name"]; $make = $aRow['car_make']; $make = $this->get_name($make, "make", "name,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['year'] = $aRow["year"]; $list[$aRow['id']]['call_status'] = $aRow["call_status"]; $list[$aRow['id']]['car_available'] = $aRow["car_available"]; $list[$aRow['id']]['honest'] = $aRow["honest"]; $list[$aRow['id']]['email'] = $aRow["email"]; $list[$aRow['id']]['mobile'] = $aRow["mobile"]; $list[$aRow['id']]['last_updated'] = $aRow["last_updated"]; } } else { $list[] = "0"; } return $list; } function KeywordAllCars($start, $cars_per_page, $where_stmt, $order) { $sql = "select listings.id , car_model , listings.client_id , car_make , listings.passengers , listings.doors , daily_price , monthly_price, larg_bag , year , transmission , page,clients.client_country from listings INNER JOIN clients ON listings.client_id=clients.client_id where $where_stmt and publish_ocd='1' and listings.client_id!='247' order by featured desc , $order page desc , refresh desc limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $car_model = $aRow['car_model']; $model = $this->get_name($car_model, "models", "name"); $model_arabic = $this->get_name($car_model, "models", "name_arabic"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['car_model_arabic'] = $model_arabic["name_arabic"]; $car_make = $aRow['car_make']; $make = $this->get_name($car_make, "make", "name,logo,cartype"); $make_arabic = $this->get_name($car_make, "make", "name_arabic,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_arabic'] = $make_arabic["name_arabic"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $car_type = $make["cartype"]; $cartype = $this->get_name($car_type, "car_types", "name"); $cartype_arabic = $this->get_name($car_type, "car_types", "name_arabic"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_arabic'] = $cartype_arabic["name_arabic"]; $list[$aRow['id']]['passengers'] = $aRow['passengers']; $list[$aRow['id']]['doors'] = $aRow['doors']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_country'] = $aRow['client_country']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['larg_bag'] = $aRow['larg_bag']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client = $this->get_company($aRow['client_id'], "clients", "company_name,logo,swf,small_logo,location,emirate,fast_delivery_locations"); $client_arabic = $this->get_company($aRow['client_id'], "clients", "company_name_arabic,logo,swf,small_logo,location_arabic,emirate_arabic,fast_delivery_locations"); $list[$aRow['id']]['small_company_logo'] = $client["small_logo"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['location'] = $client["location"]; $list[$aRow['id']]['fast_delivery_locations'] = $client["fast_delivery_locations"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; $list[$aRow['id']]['company_name_arabic'] = $client_arabic["company_name_arabic"]; $list[$aRow['id']]['location_arabic'] = $client_arabic["location_arabic"]; $list[$aRow['id']]['emirate_arabic'] = $client_arabic["emirate_arabic"]; } // $this->update_impressions($ids); return $list; } /* keyword web end*/ function Appget_make_keyword_list() { $sql = "select id ,name,related_ids,complete_car_name,complete_car_name_ar from make where id NOT IN( SELECT car_model FROM `listings` group by car_model) and related_ids!='' group by complete_car_name ORDER BY `make`.`id` DESC"; $result = mysql_query($sql); while ($aRow = mysql_fetch_array($result)) { $related_id = $aRow["related_ids"] . "," . $aRow["id"]; $list[] = $aRow["complete_car_name"] . "*****" . $related_id; } return $list; } /* keyword app start*/ function AppKeywordAllCars($start, $cars_per_page, $where_stmt, $order) { $city_all_array = array("Ajman", "Abu Dhabi", "Dubai", "Sharjah", "Ras Al Khaimah"); $now_date = date('Y-m-d'); $sql = "select listings.id ,listings.verification_expiry ,listings.images_verify , car_model , listings.client_id , car_make , listings.passengers , listings.doors , daily_price , monthly_price, larg_bag , year , transmission , page,clients.client_country from listings INNER JOIN clients ON listings.client_id=clients.client_id where $where_stmt and publish_ocd='1' and clients.ocd_app=1 and listings.client_id!='247' order by featured desc , $order page desc , refresh desc limit $start,$cars_per_page"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $client = $this->get_company($aRow['client_id'], "clients", "company_name,logo,swf,small_logo,location,emirate,fast_delivery_locations"); $verified_listing = 3; $k_emirate = $client["emirate"]; if (!in_array($k_emirate, $city_all_array)) { // echo "no"; //List non verified cars $verified_listing = 3; } else { //List verified cars $verified_listing = 0; $verification_expiry = $aRow['verification_expiry']; $images_verify = $aRow['images_verify']; if ($images_verify == 2 && $verification_expiry > $now_date) { $verified_listing = 3; } else { $verified_listing = 0; } } if ($verified_listing == 3) { $car_model = $aRow['car_model']; $model = $this->get_name($car_model, "models", "name"); $model_arabic = $this->get_name($car_model, "models", "name_arabic"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['car_model_arabic'] = $model_arabic["name_arabic"]; $car_make = $aRow['car_make']; $make = $this->get_name($car_make, "make", "name,logo,cartype"); $make_arabic = $this->get_name($car_make, "make", "name_arabic,logo,cartype"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_arabic'] = $make_arabic["name_arabic"]; $list[$aRow['id']]['car_logo'] = $make["logo"]; $car_type = $make["cartype"]; $cartype = $this->get_name($car_type, "car_types", "name"); $cartype_arabic = $this->get_name($car_type, "car_types", "name_arabic"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_arabic'] = $cartype_arabic["name_arabic"]; $list[$aRow['id']]['passengers'] = $aRow['passengers']; $list[$aRow['id']]['doors'] = $aRow['doors']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_country'] = $aRow['client_country']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['larg_bag'] = $aRow['larg_bag']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $trans = $aRow['transmission']; $trans = $this->get_name($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $client_arabic = $this->get_company($aRow['client_id'], "clients", "company_name_arabic,logo,swf,small_logo,location_arabic,emirate_arabic,fast_delivery_locations"); $list[$aRow['id']]['small_company_logo'] = $client["small_logo"]; $list[$aRow['id']]['company_name'] = $client["company_name"]; $list[$aRow['id']]['location'] = $client["location"]; $list[$aRow['id']]['fast_delivery_locations'] = $client["fast_delivery_locations"]; $list[$aRow['id']]['emirate'] = $client["emirate"]; $list[$aRow['id']]['company_name_arabic'] = $client_arabic["company_name_arabic"]; $list[$aRow['id']]['location_arabic'] = $client_arabic["location_arabic"]; $list[$aRow['id']]['emirate_arabic'] = $client_arabic["emirate_arabic"]; } //end of verified condition } // $this->update_impressions($ids); return $list; } /*Keyword app end */ function update_impressions($ids) { $ids_str = implode(",", $ids); $sql = "update listings set impressions = impressions + 1 where id in ($ids_str)"; mysql_query($sql); } function update_views($id, $client_id) { return; //disable function $sql = "update listings set views = views + 1 where id = $id"; mysql_query($sql); /* update views date_wise */ $date = date('Y-m-d'); $update_views = mysql_query("select * from track_views where listing_id='$id' and client_id='$client_id' and date_ts='$date'") or die(mysql_error()); if (mysql_num_rows($update_views) > 0) { $views = mysql_fetch_array($update_views); $track_id = $views['track_id']; $check_view = $views['views']; $sql_imp = mysql_query("update track_views set views = $check_view + 1 where track_id='$track_id'") or die(mysql_error()); } else { $sql_imp = mysql_query("insert into track_views set views ='1', listing_id='$id',client_id='$client_id',date_ts='$date'") or die(mysql_error()); } /* END update impressions date_wise */ } public function viewed_listing($user_id,$listing_id,$client_id,$device) { $logged_in_status = "loggedin"; $created_date = date("Y-m-d H:i:s"); $ip_address = $this->get_your_ip(); if($device == "mobile"){ $device = "phone"; } else { $device = "desktop"; } $sql = "insert into app_viewed_car_listing (user_id,client_id,listing_id,device,logged_in_status,ip_address,created_date) values (" . "'" . $user_id . "'," . "'" . $client_id . "'," . "'" . $listing_id . "'," . "'" . $device . "'," . "'" . $logged_in_status . "'," . "'" . $ip_address . "'," . "'" . $created_date . "'" .")"; // $sql2 = "insert into app_viewed_car_listing (user_id,client_id,listing_id,device,logged_in_status,ip_address,created_date) values (" // . "'" . mysql_real_escape_string($user_id) . "'," // . "'" . mysql_real_escape_string($client_id) . "'," // . "'" . mysql_real_escape_string($listing_id) . "'," // . "'" . mysql_real_escape_string($device) . "'," // . "'" . mysql_real_escape_string($logged_in_status) . "'," // . "'" . mysql_real_escape_string($ip_address) . "'," // . "'" . mysql_real_escape_string($created_date) . "'" // .")"; mysql_query($sql); return "1"; } function insert_email_img($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'3'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_img2($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $featured_listing, $best_offer_listing) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,featured_listing,best_offer_listing,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'3'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_img3($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $featured_listing, $best_offer_listing, $verification, $price_stat) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,featured_listing,best_offer_listing,verified_listing,price_stat,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'3'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($price_stat) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function insert_email_img_spam($client_id, $listing_id, $name, $email, $mobile, $message, $car, $status, $featured_listing, $best_offer_listing, $verification, $restrict_leads) { $ip = $this->get_your_ip(); $sql = "insert into email_sms (client_id,listing_id,name,email,mobile,type,message,status,car_name,featured_listing,best_offer_listing,verified_listing,restrict_leads,time) values (" . "'" . mysql_real_escape_string($client_id) . "'," . "'" . mysql_real_escape_string($listing_id) . "'," . "'" . mysql_real_escape_string($name) . "'," . "'" . mysql_real_escape_string($email) . "'," . "'" . mysql_real_escape_string($mobile) . "'," . "'3'" . "," . "'" . mysql_real_escape_string($message) . "'," . "'" . mysql_real_escape_string($status) . "'," . "'" . mysql_real_escape_string($car) . "'," . "'" . mysql_real_escape_string($featured_listing) . "'," . "'" . mysql_real_escape_string($best_offer_listing) . "'," . "'" . mysql_real_escape_string($verification) . "'," . "'" . mysql_real_escape_string($restrict_leads) . "'," . "'" . date('Y-m-d H:i:s') . "'" . ")"; mysql_query($sql); } function GetCarDetailsEmailcontacted($user_id){ // $key_cache = 'getcardetailsviewed1@' . $user_id; // $getcardetailsviewed = $this->memcached_library->get($key_cache); // if (!$getcardetailsviewed && !is_numeric($getcardetailsviewed)) { $sql = "select DISTINCT listings.*,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from email_sms INNER JOIN listings on listings.id = email_sms.listing_id INNER JOIN clients on clients.client_id = listings.client_id where email_sms.user_id = $user_id and email_sms.daily_spam = 0 and email_sms.display_status = 1 and email_sms.type = 1 and listings.publish_ocd='1' and listings.client_id!='247' ORDER BY id DESC"; $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $date = date('Y-m-d'); $feature_k = $aRow['free_features']; if ($feature_k == "") { $list[$aRow['id']]['final_feature'] = "0"; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name_2($valfeature, "free_features", "name,icons"); if ($fea["name"] != "") { $final_feature[] = $fea["name"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $model = $aRow['car_model']; $model = $this->get_name_2($model, "models", "name,brand_img_png,brand_img_webp,brand_img,seo_url"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['brand_image'] = $model['brand_img_webp']; $list[$aRow['id']]['brand_svg'] = $model['brand_img']; $list[$aRow['id']]['seo_url'] = $model['seo_url']; $make = $aRow['car_make']; $make = $this->get_name_2($make, "make", "name,logo,cartype,doors,passengers,larg_bag,rate_reviews,review_date,years,url"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_id'] = $aRow['car_make']; $list[$aRow['id']]['car_model_id'] = $aRow['car_model']; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['make_url'] = $make["url"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; $list[$aRow['id']]['larg_bag'] = $make['larg_bag']; if ($make['passengers'] == "" || $make['passengers'] == "0") { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } else { $list[$aRow['id']]['passengers'] = $make['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name_2($cartype, "car_types", "name,icon,url"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_icon'] = $cartype["icon"]; $list[$aRow['id']]['cartype_url'] = $cartype["url"]; //refresh time by refresh key $refresh = $aRow['refresh']; // $refresh_time = $this->get_refresh_date_2($refresh); //verfied time $verified_on = $aRow['verified_on']; //Added time $submit_time = $aRow['submit_time']; $date_now = date("Y-m-d"); // this format is string comparable $check_date_status = 0; $availability = ""; /* if($refresh_time!="") { $refresh_time = date('Y-m-d', strtotime("+3 months", strtotime($refresh_time))); //if refresh time greater than today after increament if ($date_now < $refresh_time) { //set date status variable $check_date_status=1; //set to availability $availability = $refresh_time; }else{ $refresh_time=""; } }*/ if ($verified_on != "") { $verified_on = date('Y-m-d', strtotime("+6 months", strtotime($verified_on))); //if verified time greater than today after increament if ($date_now < $verified_on) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $verified_on; else if ($availability > $verified_on) $availability = $verified_on; } else { $verified_on = ""; } } if ($submit_time != "") { $submit_time = date('Y-m-d', strtotime("+12 months", strtotime($submit_time))); //if submit time greater than today after increament if ($date_now < $submit_time) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $submit_time; else if ($availability > $submit_time) $availability = $submit_time; } else { $submit_time = ""; } } //if three dates are less than current increament 2 months to current day if ($check_date_status == 0) { $availability = date('Y-m-d', strtotime("+2 months", strtotime($date_now))); } $list[$aRow['id']]['priceValidUntil'] = $availability; $list[$aRow['id']]['is_premium'] = $aRow['is_premium']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['showcase_day'] = $aRow['showcase_day']; $list[$aRow['id']]['showcase_week'] = $aRow['showcase_week']; $list[$aRow['id']]['showcase_month'] = $aRow['showcase_month']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['hour_price_status'] = $aRow['hour_price_status']; $list[$aRow['id']]['daily_price_status'] = $aRow['daily_price_status']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['security_amount_hour'] = $aRow['security_amount_hour']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['under_promotion'] = $aRow['under_promotion']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_day'] = $aRow['mileage_day']; $list[$aRow['id']]['cdw_day'] = $aRow["cdw_day"]; $list[$aRow['id']]['cdw_month'] = $aRow["cdw_month"]; $list[$aRow['id']]['mile_week'] = $aRow['mileage_week']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['min_days_booking'] = $aRow['min_days_booking']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; if (($aRow['images_verify'] == 2) && ($aRow['verification_expiry'] >= date("Y-m-d"))) { $list[$aRow['id']]['gallery'] = $this->get_gallery_2($aRow['id']); } $trans = $aRow['transmission']; $trans = $this->get_name_2($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $list[$aRow['id']]['fast_delivery_locations'] = $aRow["fast_delivery_locations"]; $list[$aRow['id']]['airport_meet'] = $aRow["airport_meetgreet"]; $list[$aRow['id']]['delivery_location'] = $aRow["delivery_at_location"]; $list[$aRow['id']]['location'] = $aRow["location_arabic"]; $list[$aRow['id']]['supplier_settings'] = $aRow["supplier_settings"]; $list[$aRow['id']]['small_company_logo_png'] = $aRow["small_logo"]; $list[$aRow['id']]['location_english'] = $aRow["location"]; $list[$aRow['id']]['company_name'] = $aRow["company_name"]; $list[$aRow['id']]['emirate'] = $aRow["emirate"]; $list[$aRow['id']]['latitude'] = $aRow["latitude"]; $list[$aRow['id']]['longitude'] = $aRow["longitude"]; $list[$aRow['id']]['client_currency'] = $aRow["client_currency"]; $list[$aRow['id']]['unverified_business'] = $aRow["unverified_business"]; $list[$aRow['id']]['client_country'] = $aRow["client_country"]; $list[$aRow['id']]['whatsapp_number'] = $aRow["whatsapp_number"]; $list[$aRow['id']]['phone_number'] = $aRow["phone_number"]; $list[$aRow['id']]['cost_of_delivery'] = $aRow["cost_of_delivery"]; $list[$aRow['id']]['minimum_cust_age'] = $aRow["minimum_cust_age"]; $list[$aRow['id']]['gcc_specs_cl'] = $aRow["gcc_specs_cl"]; if (strpos($aRow["small_logo_webp"], '.webp') !== false) { $list[$aRow['id']]['small_company_logo'] = 'company_small_webp/' . $aRow["small_logo_webp"]; } else { $list[$aRow['id']]['small_company_logo'] = $aRow["small_logo_webp"]; } if (strpos($aRow["logo_webp"], '.webp') !== false) { $list[$aRow['id']]['company_logo'] = 'company_webp/' . $aRow["logo_webp"]; } else { $list[$aRow['id']]['company_logo'] = $aRow["logo_webp"]; } $key_cache4 = 'seo_home_country_url@' . $aRow['emirate'] . $aRow['client_id']; $delivery_term = $this->memcached_library->get($key_cache4); if (!$delivery_term && !is_numeric($delivery_term)) { $qry = mysql_query("SELECT * FROM delivery_terms WHERE delivery_term = 'Free' and emirate='" . $aRow['emirate'] . "' and client_id = '" . $aRow['client_id'] . "'"); if (mysql_num_rows($qry) > 0) { $list[$aRow['id']]['free_delivery'] = "Free Delivery"; } else { $list[$aRow['id']]['free_delivery'] = "0"; } $this->memcached_library->add($key_cache4, $list[$aRow['id']]['free_delivery'], 3600); $this->set_memcachekeys($key_cache4); } else { $list[$aRow['id']]['free_delivery'] = $delivery_term; } $color2 = $aRow['color']; if ($color2 == "" || $color2 == NULL) { $list['final_colors'] = ""; } else { $color_separate = explode(',', $color2); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name_2($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"] . "+" . $colo["hex_code"] . "+" . $colo["id"]; } $final_color2 = implode(",", $final_color); $list[$aRow['id']]['final_colors'] = $final_color2; } } // $this->memcached_library->add($key_cache, $list, 3600); // $this->set_memcachekeys($key_cache); // return $list; // } else { // return $getcardetailsviewed; // } } function GetCarDetailscontacted($user_id, $start = -1, $cars_per_page = -1, $morocco = 0){ // $key_cache = 'getcardetailscontacted@' . $user_id; // $getcardetailscontacted = $this->memcached_library->get($key_cache); // if (!$getcardetailscontacted && !is_numeric($getcardetailscontacted)) { if($morocco == 1){ if($start != -1 && $cars_per_page != -1){ $sql = "select DISTINCT listings.*,email_sms.is_hourly,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from email_sms INNER JOIN listings on listings.id = email_sms.listing_id INNER JOIN clients on clients.client_id = listings.client_id where clients.client_country = 'Morocco' and email_sms.user_id = $user_id and email_sms.daily_spam='0' and email_sms.display_status = 1 and email_sms.type IN (1,2,5) and listings.client_id!='247' ORDER BY email_sms.id DESC limit $start,$cars_per_page"; } else { $sql = "select DISTINCT listings.*,email_sms.is_hourly,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from email_sms INNER JOIN listings on listings.id = email_sms.listing_id INNER JOIN clients on clients.client_id = listings.client_id where clients.client_country = 'Morocco' and email_sms.user_id = $user_id and email_sms.daily_spam='0' and email_sms.display_status = 1 and email_sms.type IN (1,2,5) and listings.client_id!='247' ORDER BY id DESC"; } } else { if($start != -1 && $cars_per_page != -1){ $sql = "select DISTINCT listings.*,email_sms.is_hourly,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from email_sms INNER JOIN listings on listings.id = email_sms.listing_id INNER JOIN clients on clients.client_id = listings.client_id where email_sms.user_id = $user_id and email_sms.daily_spam='0' and email_sms.display_status = 1 and email_sms.type IN (1,2,5) and listings.client_id!='247' ORDER BY email_sms.id DESC limit $start,$cars_per_page"; } else { $sql = "select DISTINCT listings.*,email_sms.is_hourly,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from email_sms INNER JOIN listings on listings.id = email_sms.listing_id INNER JOIN clients on clients.client_id = listings.client_id where email_sms.user_id = $user_id and email_sms.daily_spam='0' and email_sms.display_status = 1 and email_sms.type IN (1,2,5) and listings.client_id!='247' ORDER BY id DESC"; } } $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $date = date('Y-m-d'); //hourly fixes - by nikhil on 15-12-2025 if($aRow['hour_price_status'] == 1 && $aRow['per_hour_price'] > 0){ $list[$aRow['id']]['is_hourly'] = $aRow['is_hourly']; }else{ $list[$aRow['id']]['is_hourly'] = 0; } $feature_k = $aRow['free_features']; if ($feature_k == "") { $list[$aRow['id']]['final_feature'] = "0"; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name_2($valfeature, "free_features", "name,icons"); if ($fea["name"] != "") { $final_feature[] = $fea["name"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $list[$aRow['id']]['publish_ocd'] = $aRow['publish_ocd']; $list[$aRow['id']]['car_spec_id'] = $aRow['car_spec_id']; $model = $aRow['car_model']; $model = $this->get_name_2($model, "models", "name,brand_img_png,brand_img_webp,brand_img,seo_url"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['brand_image'] = $model['brand_img_webp']; $list[$aRow['id']]['brand_svg'] = $model['brand_img']; $list[$aRow['id']]['seo_url'] = $model['seo_url']; $make = $aRow['car_make']; $make = $this->get_name_2($make, "make", "name,logo,cartype,cartype1,cartype2,cartype3,doors,passengers,larg_bag,rate_reviews,review_date,years,url"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_id'] = $aRow['car_make']; $list[$aRow['id']]['car_model_id'] = $aRow['car_model']; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['make_url'] = $make["url"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; $list[$aRow['id']]['larg_bag'] = $make['larg_bag']; if ($make['passengers'] == "" || $make['passengers'] == "0") { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } else { $list[$aRow['id']]['passengers'] = $make['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name_2($cartype, "car_types", "name,icon,url"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_icon'] = $cartype["icon"]; $list[$aRow['id']]['cartype_url'] = $cartype["url"]; $cartype2 = $make["cartype1"]; $cartype2 = $this->get_name_2($cartype2, "car_types", "name"); $list[$aRow['id']]['cartype2'] = $cartype2["name"]; $cartype3 = $make["cartype2"]; $cartype3 = $this->get_name_2($cartype3, "car_types", "name"); $list[$aRow['id']]['cartype3'] = $cartype3["name"]; $cartype4 = $make["cartype3"]; $cartype4 = $this->get_name_2($cartype4, "car_types", "name"); $list[$aRow['id']]['cartype4'] = $cartype4["name"]; //refresh time by refresh key $refresh = $aRow['refresh']; // $refresh_time = $this->get_refresh_date_2($refresh); //verfied time $verified_on = $aRow['verified_on']; //Added time $submit_time = $aRow['submit_time']; $date_now = date("Y-m-d"); // this format is string comparable $check_date_status = 0; $availability = ""; if ($verified_on != "") { $verified_on = date('Y-m-d', strtotime("+6 months", strtotime($verified_on))); //if verified time greater than today after increament if ($date_now < $verified_on) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $verified_on; else if ($availability > $verified_on) $availability = $verified_on; } else { $verified_on = ""; } } if ($submit_time != "") { $submit_time = date('Y-m-d', strtotime("+12 months", strtotime($submit_time))); //if submit time greater than today after increament if ($date_now < $submit_time) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $submit_time; else if ($availability > $submit_time) $availability = $submit_time; } else { $submit_time = ""; } } //if three dates are less than current increament 2 months to current day if ($check_date_status == 0) { $availability = date('Y-m-d', strtotime("+2 months", strtotime($date_now))); } $list[$aRow['id']]['priceValidUntil'] = $availability; $list[$aRow['id']]['time'] = $this->get_date($aRow['id'], "email_sms", "time","id",$user_id,"listing_id"); $list[$aRow['id']]['is_premium'] = $aRow['is_premium']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $client = $this->get_company($aRow['client_id'], "clients", "languages_spoken,accepted_in_cl,logo,small_logo,small_logo_webp,logo_webp,swf,company_name,description,airport_meetgreet,delivery_at_location,salik_toll_charges,client_currency,client_country,cost_of_delivery,minimum_cust_age,location,location_arabic,fast_delivery_locations,youtube,youtube_status,emirate,gps_device_cost,cost_driver_coverage,unverified_business"); $list[$aRow['id']]['company_logo'] = $client["logo"]; $list[$aRow['id']]['rate'] = $this->get_currency_rate_from_user($_COOKIE['currency'],$client["client_currency"]); $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['showcase_day'] = $aRow['showcase_day']; $list[$aRow['id']]['showcase_week'] = $aRow['showcase_week']; $list[$aRow['id']]['showcase_month'] = $aRow['showcase_month']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['hour_price_status'] = $aRow['hour_price_status']; $list[$aRow['id']]['daily_price_status'] = $aRow['daily_price_status']; $list[$aRow['id']]['gcc_specs'] = $aRow['gcc_specs']; $list[$aRow['id']]['security_amount_hour'] = $aRow['security_amount_hour']; $list[$aRow['id']]['daily_price_offer'] = $aRow['daily_price_offer']; $list[$aRow['id']]['monthly_price_offer'] = $aRow['monthly_price_offer']; $list[$aRow['id']]['weekly_price_offer'] = $aRow['weekly_price_offer']; $list[$aRow['id']]['under_promotion'] = $aRow['under_promotion']; $list[$aRow['id']]['mileage_day'] = $aRow['mileage_day']; $list[$aRow['id']]['mileage_week'] = $aRow['mileage_week']; $list[$aRow['id']]['mileage_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_month'] = $aRow['mileage_month']; $list[$aRow['id']]['mile_day'] = $aRow['mileage_day']; $list[$aRow['id']]['cdw_day'] = $aRow["cdw_day"]; $list[$aRow['id']]['cdw_month'] = $aRow["cdw_month"]; $list[$aRow['id']]['mile_week'] = $aRow['mileage_week']; $list[$aRow['id']]['insurance'] = $aRow['insurance']; $list[$aRow['id']]['cruise_control'] = $aRow['cruise_control']; $list[$aRow['id']]['security_amount'] = $aRow['security_amount']; $list[$aRow['id']]['excess_claim'] = $aRow['excess_claim']; $list[$aRow['id']]['min_days_booking'] = $aRow['min_days_booking']; $list[$aRow['id']]['id'] = $aRow['id']; $list[$aRow['id']]['page'] = $aRow['page']; $list[$aRow['id']]['engine_capacity'] = $aRow['engine_capacity']; $list[$aRow['id']]['images_verify'] = $aRow['images_verify']; $list[$aRow['id']]['verification_expiry'] = $aRow['verification_expiry']; if (($aRow['images_verify'] == 2) && ($aRow['verification_expiry'] >= date("Y-m-d"))) { $list[$aRow['id']]['gallery'] = $this->get_gallery_2($aRow['id']); } $trans = $aRow['transmission']; $trans = $this->get_name_2($trans, "transmission", "name"); $list[$aRow['id']]['transmission'] = $trans["name"]; $ids[] = $aRow['id']; $list[$aRow['id']]['fast_delivery_locations'] = $aRow["fast_delivery_locations"]; $list[$aRow['id']]['airport_meet'] = $aRow["airport_meetgreet"]; $list[$aRow['id']]['delivery_location'] = $aRow["delivery_at_location"]; $list[$aRow['id']]['location'] = $aRow["location_arabic"]; $list[$aRow['id']]['supplier_settings'] = $aRow["supplier_settings"]; $list[$aRow['id']]['small_company_logo_png'] = $aRow["small_logo"]; $list[$aRow['id']]['location_english'] = $aRow["location"]; $list[$aRow['id']]['company_name'] = $aRow["company_name"]; $list[$aRow['id']]['emirate'] = $aRow["emirate"]; $list[$aRow['id']]['latitude'] = $aRow["latitude"]; $list[$aRow['id']]['longitude'] = $aRow["longitude"]; $list[$aRow['id']]['client_currency'] = $aRow["client_currency"]; $list[$aRow['id']]['unverified_business'] = $aRow["unverified_business"]; $list[$aRow['id']]['client_country'] = $aRow["client_country"]; $list[$aRow['id']]['whatsapp_number'] = $aRow["whatsapp_number"]; $list[$aRow['id']]['phone_number'] = $aRow["phone_number"]; $list[$aRow['id']]['cost_of_delivery'] = $aRow["cost_of_delivery"]; $list[$aRow['id']]['minimum_cust_age'] = $aRow["minimum_cust_age"]; $list[$aRow['id']]['gcc_specs_cl'] = $aRow["gcc_specs_cl"]; if (strpos($aRow["small_logo_webp"], '.webp') !== false) { $list[$aRow['id']]['small_company_logo'] = 'company_small_webp/' . $aRow["small_logo_webp"]; } else { $list[$aRow['id']]['small_company_logo'] = $aRow["small_logo_webp"]; } // if (strpos($aRow["logo_webp"], '.webp') !== false) { // $list[$aRow['id']]['company_logo'] = 'company_webp/' . $aRow["logo_webp"]; // } else { // $list[$aRow['id']]['company_logo'] = $aRow["logo_webp"]; // } $key_cache4 = 'seo_home_country_url@' . $aRow['emirate'] . $aRow['client_id']; $delivery_term = $this->memcached_library->get($key_cache4); if (!$delivery_term && !is_numeric($delivery_term)) { $qry = mysql_query("SELECT * FROM delivery_terms WHERE delivery_term = 'Free' and emirate='" . $aRow['emirate'] . "' and client_id = '" . $aRow['client_id'] . "'"); if (mysql_num_rows($qry) > 0) { $list[$aRow['id']]['free_delivery'] = "Free Delivery"; } else { $list[$aRow['id']]['free_delivery'] = "0"; } $this->memcached_library->add($key_cache4, $list[$aRow['id']]['free_delivery'], 3600); $this->set_memcachekeys($key_cache4); } else { $list[$aRow['id']]['free_delivery'] = $delivery_term; } $color2 = $aRow['color']; if ($color2 == "" || $color2 == NULL) { $list['final_colors'] = ""; } else { $color_separate = explode(',', $color2); $final_color = array(); foreach ($color_separate as $valcolor) { $colo = $this->get_name_2($valcolor, "colors", "name,hex_code,id"); $final_color[] = $colo["name"] . "+" . $colo["hex_code"] . "+" . $colo["id"]; } $final_color2 = implode(",", $final_color); $list[$aRow['id']]['final_colors'] = $final_color2; } } // $this->memcached_library->add($key_cache, $list, 3600); // $this->set_memcachekeys($key_cache); return $list; // } else { // return $getcardetailscontacted; // } } function DeleteCarcontacted($user_id,$listing_id){ $sql = "UPDATE feedback_track SET display_status = 0 WHERE user_id = '$user_id' AND listing_id = $listing_id"; $rResult = mysql_query($sql) or die(mysql_error()); $sql2 = "UPDATE email_sms SET display_status = 0 WHERE user_id = '$user_id' AND listing_id = $listing_id"; $rResult2 = mysql_query($sql2) or die(mysql_error()); return "success"; } function GetCarDetailswishlist($user_id, $start = -1, $cars_per_page = -1, $morocco = 0){ // $key_cache = 'getcardetailswishlist@' . $user_id; // $getcardetailswishlist = $this->memcached_library->get($key_cache); // if (!$getcardetailswishlist && !is_numeric($getcardetailswishlist)) { if($morocco == 1){ if($start != -1 && $cars_per_page != -1){ $sql = "select DISTINCT listings.*,user_cars_favourite.is_hourly,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from user_cars_favourite INNER JOIN listings on listings.id = user_cars_favourite.car_id INNER JOIN clients on clients.client_id = listings.client_id where clients.client_country = 'Morocco' and user_cars_favourite.user_id = $user_id and listings.client_id!='247' ORDER BY user_cars_favourite_id DESC limit $start,$cars_per_page"; } else { $sql = "select DISTINCT listings.*,user_cars_favourite.is_hourly,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from user_cars_favourite INNER JOIN listings on listings.id = user_cars_favourite.car_id INNER JOIN clients on clients.client_id = listings.client_id where clients.client_country = 'Morocco' and user_cars_favourite.user_id = $user_id and listings.client_id!='247' ORDER BY user_cars_favourite_id DESC"; } } else { if($start != -1 && $cars_per_page != -1){ $sql = "select DISTINCT listings.*,user_cars_favourite.is_hourly,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from user_cars_favourite INNER JOIN listings on listings.id = user_cars_favourite.car_id INNER JOIN clients on clients.client_id = listings.client_id where user_cars_favourite.user_id = $user_id and listings.client_id!='247' ORDER BY user_cars_favourite_id DESC limit $start,$cars_per_page"; } else { $sql = "select DISTINCT listings.*,user_cars_favourite.is_hourly,clients.company_name,clients.small_logo,clients.logo,clients.emirate,clients.logo_webp,clients.swf,clients.small_logo_webp,clients.location,clients.location_arabic,clients.airport_meetgreet,clients.delivery_at_location,clients.latitude,clients.longitude,clients.whatsapp_number,clients.phone_number,clients.client_currency,clients.client_country,clients.cost_of_delivery, clients.minimum_cust_age, clients.fast_delivery_locations,clients.supplier_settings,clients.gcc_specs_cl,clients.unverified_business from user_cars_favourite INNER JOIN listings on listings.id = user_cars_favourite.car_id INNER JOIN clients on clients.client_id = listings.client_id where user_cars_favourite.user_id = $user_id and listings.client_id!='247' ORDER BY user_cars_favourite_id DESC"; } } $rResult = mysql_query($sql) or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult)) { $date = date('Y-m-d'); $list[$aRow['id']]['is_hourly'] = $aRow['is_hourly']; $feature_k = $aRow['free_features']; if ($feature_k == "") { $list[$aRow['id']]['final_feature'] = "0"; } else { $final_feature = array(); $feature_separate = explode(',', $feature_k); foreach ($feature_separate as $valfeature) { $fea = $this->get_name_2($valfeature, "free_features", "name,icons"); if ($fea["name"] != "") { $final_feature[] = $fea["name"] . "+" . $fea["icons"]; } } $final_feature2 = implode(",", $final_feature); $list[$aRow['id']]['final_feature'] = $final_feature2; } /* END FEATURES*/ $list[$aRow['id']]['publish_ocd'] = $aRow['publish_ocd']; $list[$aRow['id']]['car_spec_id'] = $aRow['car_spec_id']; $model = $aRow['car_model']; $model = $this->get_name_2($model, "models", "name,brand_img_png,brand_img_webp,brand_img,seo_url"); $list[$aRow['id']]['car_model'] = $model["name"]; $list[$aRow['id']]['brand_image'] = $model['brand_img_webp']; $list[$aRow['id']]['brand_svg'] = $model['brand_img']; $list[$aRow['id']]['seo_url'] = $model['seo_url']; $make = $aRow['car_make']; $make = $this->get_name_2($make, "make", "name,logo,cartype,cartype1,cartype2,cartype3,doors,passengers,larg_bag,rate_reviews,review_date,years,url"); $list[$aRow['id']]['car_make'] = $make["name"]; $list[$aRow['id']]['car_make_id'] = $aRow['car_make']; $list[$aRow['id']]['car_model_id'] = $aRow['car_model']; $list[$aRow['id']]['car_logo'] = $make["logo"]; $list[$aRow['id']]['years'] = $make["years"]; $list[$aRow['id']]['make_url'] = $make["url"]; $list[$aRow['id']]['rate_reviews'] = $make["rate_reviews"]; $list[$aRow['id']]['review_date'] = $make["review_date"]; $list[$aRow['id']]['larg_bag'] = $make['larg_bag']; if ($make['passengers'] == "" || $make['passengers'] == "0") { $list[$aRow['id']]['passengers'] = $aRow['passengers']; } else { $list[$aRow['id']]['passengers'] = $make['passengers']; } if ($make['doors'] == "" || $make['doors'] == "0") { $list[$aRow['id']]['doors'] = $aRow['doors']; } else { $list[$aRow['id']]['doors'] = $make['doors']; } $cartype = $make["cartype"]; $list[$aRow['id']]['cartype_id'] = $make["cartype"]; $cartype = $this->get_name_2($cartype, "car_types", "name,icon,url"); $list[$aRow['id']]['cartype'] = $cartype["name"]; $list[$aRow['id']]['cartype_icon'] = $cartype["icon"]; $list[$aRow['id']]['cartype_url'] = $cartype["url"]; $cartype2 = $make["cartype1"]; $cartype2 = $this->get_name_2($cartype2, "car_types", "name"); $list[$aRow['id']]['cartype2'] = $cartype2["name"]; $cartype3 = $make["cartype2"]; $cartype3 = $this->get_name_2($cartype3, "car_types", "name"); $list[$aRow['id']]['cartype3'] = $cartype3["name"]; $cartype4 = $make["cartype3"]; $cartype4 = $this->get_name_2($cartype4, "car_types", "name"); $list[$aRow['id']]['cartype4'] = $cartype4["name"]; //refresh time by refresh key $refresh = $aRow['refresh']; // $refresh_time = $this->get_refresh_date_2($refresh); //verfied time $verified_on = $aRow['verified_on']; //Added time $submit_time = $aRow['submit_time']; $date_now = date("Y-m-d"); // this format is string comparable $check_date_status = 0; $availability = ""; /* if($refresh_time!="") { $refresh_time = date('Y-m-d', strtotime("+3 months", strtotime($refresh_time))); //if refresh time greater than today after increament if ($date_now < $refresh_time) { //set date status variable $check_date_status=1; //set to availability $availability = $refresh_time; }else{ $refresh_time=""; } }*/ if ($verified_on != "") { $verified_on = date('Y-m-d', strtotime("+6 months", strtotime($verified_on))); //if verified time greater than today after increament if ($date_now < $verified_on) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $verified_on; else if ($availability > $verified_on) $availability = $verified_on; } else { $verified_on = ""; } } if ($submit_time != "") { $submit_time = date('Y-m-d', strtotime("+12 months", strtotime($submit_time))); //if submit time greater than today after increament if ($date_now < $submit_time) { $check_date_status = 1; //assigning lowest date to availability if ($availability == "") $availability = $submit_time; else if ($availability > $submit_time) $availability = $submit_time; } else { $submit_time = ""; } } //if three dates are less than current increament 2 months to current day if ($check_date_status == 0) { $availability = date('Y-m-d', strtotime("+2 months", strtotime($date_now))); } $list[$aRow['id']]['priceValidUntil'] = $availability; $list[$aRow['id']]['created_time'] = $this->get_date($aRow['id'], "user_cars_favourite", "created_time","user_cars_favourite_id",$user_id,"car_id"); $list[$aRow['id']]['is_premium'] = $aRow['is_premium']; $list[$aRow['id']]['featured'] = $aRow['featured']; $list[$aRow['id']]['year'] = $aRow['year']; $list[$aRow['id']]['client_id'] = $aRow['client_id']; $client = $this->get_company($aRow['client_id'], "clients", "languages_spoken,accepted_in_cl,logo,small_logo,small_logo_webp,logo_webp,swf,company_name,description,airport_meetgreet,delivery_at_location,salik_toll_charges,client_currency,client_country,cost_of_delivery,minimum_cust_age,location,location_arabic,fast_delivery_locations,youtube,youtube_status,emirate,gps_device_cost,cost_driver_coverage,unverified_business"); $list[$aRow['id']]['company_logo'] = $client["logo"]; $list[$aRow['id']]['rate'] = $this->get_currency_rate_from_user($_COOKIE['currency'],$client["client_currency"]); $list[$aRow['id']]['deal_id'] = $aRow['deal_id']; $list[$aRow['id']]['showcase_day'] = $aRow['showcase_day']; $list[$aRow['id']]['showcase_week'] = $aRow['showcase_week']; $list[$aRow['id']]['showcase_month'] = $aRow['showcase_month']; $list[$aRow['id']]['daily_price'] = $aRow['daily_price']; $list[$aRow['id']]['monthly_price'] = $aRow['monthly_price']; $list[$aRow['id']]['weekly_price'] = $aRow['weekly_price']; $list[$aRow['id']]['per_hour_price'] = $aRow['per_hour_price']; $list[$aRow['id']]['per_hour2_price'] = $aRow['per_hour2_price']; $list[$aRow['id']]['mileage_hour'] = $aRow['mileage_hour']; $list[$aRow['id']]['mileage_hour_2'] = $aRow['mileage_hour_2']; $list[$aRow['id']]['hour_price_status'] = $aRow['hour_price_status'];