Beispiel #1
0
 /**
  * check client province in ad's geo target
  * input array province number
  * return boolean
  */
 public function checkGeo($listCountries, $listProvinces)
 {
     if (empty($listCountries)) {
         return true;
     }
     $retval = false;
     $ip = getClientIp();
     //live
     //test tren local
     if (isLocal()) {
         $ip = '115.78.162.134';
         // test
     }
     $geoip = GeoBaseModel::getGeoByIp($ip);
     if ($geoip) {
         if (empty($listProvinces)) {
             $retval = in_array($geoip->country_code, $listCountries);
         } else {
             $province = "{$geoip->country_code}:{$geoip->region}";
             $retval = in_array($province, $listProvinces);
         }
     }
     // pr($geoip);
     // pr($retval);
     return $retval;
 }
 /**
  *     add/update agency
  *     @param  integer $id
  */
 function showUpdate($id = 0)
 {
     $this->data['id'] = $id;
     View::share('jsTag', HTML::script("{$this->assetURL}js/select.js") . HTML::script("{$this->assetURL}js/flight.js"));
     // get list Category
     $categoryModel = new CategoryBaseModel();
     $this->data['listCategory'] = $categoryModel->getAllForm(0, 0, 'Run of Network');
     $this->data['listEvent'] = array('' => 'Metric for Frequency Capping') + Config::get('data.event');
     // get list Flight Objective
     //$this->data['provinceLists'] = ProvinceBaseModel::orderBy('order', 'asc')->get();
     // get list Flight Objective
     $this->data['listFlightObjective'] = Config::get('data.flight_objective');
     // get list flight type
     $this->data['listFlightType'] = Config::get('data.flight_type');
     $this->data['getdate'] = Input::get('date', array());
     //--Start--Phuong-VM add 05-05-2015
     $geoModel = new GeoBaseModel();
     $this->data['countryList'] = $geoModel->getCountry();
     $this->data['countrySelected'][] = 'VN';
     //--End--Phuong-VM add 05-05-2015
     //$campaignRetargetingSelected = array();
     $this->loadLeftMenu('menu.flightList');
     //$campaignRange = json_encode(array());
     // WHEN UPDATE SHOW CURRENT INFOMATION
     if (Request::isMethod('get')) {
         $this->data['listKeyword'] = array();
         $this->data['audiences'] = array();
         if ($id != 0) {
             $this->loadLeftMenu('menu.flightUpdate');
             $item = $this->model->with('category', 'ad', 'campaign', 'publisherSite', 'publisher_ad_zone')->find($id);
             if ($item) {
                 //--Start--Phuong-VM add 05-05-2015
                 $this->data['countrySelected'] = json_decode($item->country);
                 $this->data['provinceLists'] = $geoModel->getRegionByCountry($this->data['countrySelected']);
                 //--End--Phuong-VM add 05-05-2015
                 $this->data['provinceSelected'] = json_decode($item->province);
                 $this->data['ageSelected'] = json_decode($item->age);
                 $this->data['item'] = $item;
                 $this->data['getdate'] = $item->getDate;
                 $this->data['gettime'] = $item->getTime();
                 if (!empty($item->filter)) {
                     $this->data['listKeyword'] = explode(',', $item->filter);
                 }
                 /*if( !empty($item->campaign_retargeting) && $item->campaign_retargeting != "null" ){
                       $campaignRange = $item->campaign_retargeting;
                       $campaignRetargetingSelected = CampaignBaseModel::whereIn('id',json_decode($item->campaign_retargeting))->lists('name','id');
                   }*/
             } else {
                 return Redirect::to($this->moduleURL . 'show-list');
             }
         }
     } else {
         $this->data['countrySelected'] = Input::get('selected_country');
         $this->data['provinceLists'] = $geoModel->getRegionByCountry($this->data['countrySelected']);
         $this->data['provinceSelected'] = Input::get('selected_province');
         /*$campaign_retargeting_selected = Input::get('campaign-retargeting-selected',array());
           if (!empty($campaign_retargeting_selected)) {
               $campaignRetargetingSelected = CampaignBaseModel::whereIn('id',Input::get('campaign-retargeting-selected'))->lists('name','id');
           }*/
     }
     /*$this->data['campaignRange'] = $campaignRange;
       $this->data['campaignRetargetingSelected'] = $campaignRetargetingSelected;*/
     if (Request::isMethod('post')) {
         if ($this->postUpdate($id, $this->data)) {
             return Redirect::to($this->moduleURL . 'view/' . $this->data['id']);
         }
     }
     $this->layout->content = View::make('showUpdate', $this->data);
 }
 public function getListGeo($keyword)
 {
     $model = new GeoBaseModel();
     $this->data['provinceLists'] = $model->getRegionByCountry($keyword);
     return View::make('provinceLists', $this->data)->render();
 }