public function getHomeView()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $lat = $_POST['lat'];
     $lng = $_POST['lng'];
     $district = $_POST['district'];
     $city = $_POST['city'];
     //        Generic::saveDistrictCity($district, $city);
     $results['home'] = array();
     $mainHomeModel = new HomeSettingModel();
     $arrMainHome = $mainHomeModel->getAll();
     foreach ($arrMainHome as $mainHome) {
         unset($b);
         $b["id_home"] = $mainHome->setting_type;
         $b['name'] = $mainHome->setting_type;
         $b['status'] = true;
         $b['image'] = _BPATH . _PHOTOURL . $mainHome->img_home;
         $b['search_type'] = $mainHome->setting_type;
         $b['search_term'] = $mainHome->setting_type;
         $b['query'] = $mainHome->setting_type;
         $b['is_restaurant'] = true;
         $results['home'][] = $b;
     }
     $extraHomeModel = new HomeModel();
     $arrExtraHome = $extraHomeModel->getWhere("status='1' AND search_type!='0' ORDER BY home_order DESC");
     foreach ($arrExtraHome as $extraHome) {
         unset($b);
         $b["id_home"] = $extraHome->id_home;
         $b['name'] = $extraHome->name;
         $b['status'] = $extraHome->status == true;
         $b['image'] = _BPATH . _PHOTOURL . $extraHome->image;
         $b['search_type'] = $extraHome->search_type;
         $b['search_term'] = $extraHome->search_term;
         $b['query'] = $extraHome->query;
         $b['is_restaurant'] = !($extraHome->search_type == "5" || $extraHome->search_type == "6");
         $results['home'][] = $b;
     }
     $locPromoModel = new LocationPromoModel();
     $results['location_promo'] = array();
     $q = "status='1' AND (type='2') ";
     if (!Generic::IsNullOrEmptyString($city)) {
         $q .= " OR (type='1' AND city='{$city}')";
     }
     if (!Generic::IsNullOrEmptyString($city) && !Generic::IsNullOrEmptyString($district)) {
         $q .= " OR (type='0' AND district='{$district}' AND city='{$city}')";
     }
     $now = leap_mysqldate();
     $arrLocPromo = $locPromoModel->getWhere("( " . $q . " ) AND (promo_start <= '{$now}' AND promo_end >= '{$now}') ORDER BY promo_order DESC");
     //        echo $q;
     //        echo "<br>";
     //        echo $q . " AND (promo_start <= '$now' AND promo_end >= '$now') ORDER BY promo_order DESC";
     //        echo count($arrLocPromo);
     foreach ($arrLocPromo as $alp) {
         unset($lp);
         $lp['id_promo'] = $alp->id_promo;
         $lp['title'] = $alp->title;
         $lp['image'] = _BPATH . _PHOTOURL . $alp->image;
         $lp['district'] = $alp->district;
         $lp['city'] = $alp->city;
         $lp['type'] = $alp->type;
         $results['location_promo'][] = $lp;
     }
     //        pr($results['location_promo']);
     $this->finish($results);
 }
 public function getHomeView()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $lat = $_POST['lat'];
     $lng = $_POST['lng'];
     $district = "";
     $city = "";
     $arrDistrict = self::CalDistrictCityFromLatLng($lat, $lng);
     if (count($arrDistrict) > 0) {
         $district = $arrDistrict['district'];
         $city = $arrDistrict['city'];
     }
     //        Generic::saveDistrictCity($district, $city);
     $results['home'] = array();
     $mainHomeModel = new HomeSettingModel();
     $arrMainHome = $mainHomeModel->getAll();
     foreach ($arrMainHome as $mainHome) {
         unset($b);
         $b["id_home"] = $mainHome->setting_type;
         $b['name'] = $mainHome->setting_type;
         $b['status'] = true;
         $b['image'] = _BPATH . _PHOTOURL . $mainHome->img_home;
         $b['search_type'] = $mainHome->setting_type;
         $b['search_term'] = $mainHome->setting_type;
         $b['query'] = $mainHome->setting_type;
         $b['is_restaurant'] = true;
         $results['home'][] = $b;
     }
     $extraHomeModel = new HomeModel();
     $arrExtraHome = $extraHomeModel->getWhere("status='1' AND search_type!='0' ORDER BY id_home DESC");
     foreach ($arrExtraHome as $extraHome) {
         unset($b);
         $b["id_home"] = $extraHome->id_home;
         $b['name'] = $extraHome->name;
         $b['status'] = $extraHome->status == true;
         $b['image'] = _BPATH . _PHOTOURL . $extraHome->image;
         $b['search_type'] = $extraHome->search_type;
         $b['search_term'] = $extraHome->search_term;
         $b['query'] = $extraHome->query;
         $b['is_restaurant'] = !($extraHome->search_type == "5" || $extraHome->search_type == "6");
         $results['home'][] = $b;
     }
     $locPromoModel = new LocationPromoModel();
     $results['location_promo'] = array();
     $q = "status='1' AND (type='2') ";
     if (!Generic::IsNullOrEmptyString($city)) {
         $q .= " OR (type='1' AND city='{$city}')";
     }
     if (!Generic::IsNullOrEmptyString($city) && !Generic::IsNullOrEmptyString($district)) {
         $q .= " OR (type='0' AND district='{$district}' AND city='{$city}')";
     }
     $arrLocPromo = $locPromoModel->getWhere($q . " ORDER BY id_promo DESC");
     foreach ($arrLocPromo as $alp) {
         unset($lp);
         $lp['id_promo'] = $alp->id_promo;
         $lp['title'] = $alp->title;
         $lp['image'] = _BPATH . _PHOTOURL . $alp->image;
         $lp['district'] = $alp->district;
         $lp['city'] = $alp->city;
         $lp['type'] = $alp->type;
         $results['location_promo'][] = $lp;
     }
     $this->finish($results);
 }