public function homeWS()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $objHS = new HomeSettingModel();
     $json = array();
     $json['status_code'] = 1;
     $arrHS = $objHS->getWhere("aktiv = 1");
     $expHS = explode(",", str_replace(" ", "", $objHS->crud_webservice_allowed));
     $arrPicsToAddPhotoUrl = $objHS->crud_add_photourl;
     $sem = array();
     foreach ($arrHS as $o) {
         foreach ($expHS as $attr) {
             if (in_array($attr, $arrPicsToAddPhotoUrl)) {
                 $json["results"]["main_menu"][$o->settingType] = _BPATH . _PHOTOURL . $o->{$attr};
             }
             //$sem[$attr] = stripslashes($o->$attr);
         }
         //$json["results"]["main_menu"][$o->settingType][] = $sem;
     }
     $obj = new HomeModel();
     //        $arr = $obj->getWhere("aktiv = 1 AND id_restaurant = " . $id_restaurant );
     $arr = $obj->getWhere("aktiv = 1");
     $exp = explode(",", str_replace(" ", "", $obj->crud_webservice_allowed));
     //tmbh untuk add photo url
     $arrPicsToAddPhotoUrl = $obj->crud_add_photourl;
     foreach ($arr as $o) {
         $sem = array();
         foreach ($exp as $attr) {
             if (in_array($attr, $arrPicsToAddPhotoUrl)) {
                 $sem[$attr] = _BPATH . _PHOTOURL . $o->{$attr};
             } else {
                 $sem[$attr] = stripslashes($o->{$attr});
             }
         }
         //            pr($sem);
         $json["results"]["extra_menu"][] = $sem;
     }
     echo json_encode($json);
     die;
 }
 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);
 }