/**
  *     add/update agency
  *     @param  integer $id 
  */
 function showUpdate($id = 0)
 {
     $this->data['id'] = $id;
     View::share('jsTag', HTML::script("{$this->assetURL}js/select.js"));
     // get list Category
     $categoryModel = new CategoryBaseModel();
     $this->data['listCategory'] = $categoryModel->getAllForm(0);
     // get list Ad Format
     $AdFormatModel = new AdFormatBaseModel();
     $this->data['listAdFormat'] = $AdFormatModel->getAllForm();
     // get list Type
     $this->data['listAdType'] = Config::get('data.ad_type');
     // get list Wmode
     $this->data['listWmode'] = Config::get('data.wmode');
     // WHEN UPDATE SHOW CURRENT INFOMATION
     if ($id != 0) {
         $item = $this->model->with('campaign', 'adFormat')->find($id);
         if ($item) {
             $this->data['item'] = $item;
         } else {
             return Redirect::to($this->moduleURL . 'show-list');
         }
     }
     if (Request::isMethod('post')) {
         if ($this->postUpdate($id, $this->data)) {
             return $this->redirectAfterSave(Input::get('save'));
         }
     }
     $this->layout->content = View::make('showUpdate', $this->data);
 }
 /**
  *     add/update agency
  *     @param  integer $id 
  */
 function showUpdate($id = 0)
 {
     $this->data['id'] = $id;
     View::share('jsTag', HTML::script("{$this->assetURL}js/select.js"));
     // get list Category
     $categoryModel = new CategoryBaseModel();
     $this->data['listCategory'] = $categoryModel->getAllForm(0, 0, 'Run of Network');
     // get list Flight Objective
     $this->data['listFlightObjective'] = Config::get('data.flight_objective');
     $this->loadLeftMenu('menu.flightList');
     // WHEN UPDATE SHOW CURRENT INFOMATION
     if ($id != 0) {
         $this->loadLeftMenu('menu.flightUpdate');
         $item = $this->model->with('category', 'campaign', 'publisher', 'publisherSite', 'publisher_ad_zone')->find($id);
         if ($item) {
             $this->data['item'] = $item;
         } else {
             return Redirect::to($this->moduleURL . 'show-list');
         }
     }
     if (Request::isMethod('post')) {
         if ($this->postUpdate($id, $this->data)) {
             return $this->redirectAfterSave(Input::get('save'));
         }
     }
     $this->layout->content = View::make('showUpdate', $this->data);
 }
 /**
  *     add/update agency
  *     @param  integer $id 
  */
 function showUpdate($id = 0)
 {
     $this->data['id'] = $id;
     View::share('jsTag', HTML::script("{$this->assetURL}js/select.js"));
     // get list country
     $countryModel = new CountryBaseModel();
     $this->data['listCountry'] = $countryModel->getAllForm();
     // get list Category
     $categoryModel = new CategoryBaseModel();
     $this->data['listCategory'] = $categoryModel->getAllForm();
     // get expected close month
     $this->data['listExpectedCloseMonth'] = getMonthRange();
     // get list Currency
     $currencyModel = new CurrencyBaseModel();
     $this->data['listCurrency'] = $currencyModel->getAllForm();
     // get list Sale Status
     $this->data['listSaleStatus'] = Config::get('data.sale_status');
     $this->loadLeftMenu('menu.campaignList');
     // WHEN UPDATE SHOW CURRENT INFORMATION
     if ($id != 0) {
         $item = $this->model->with('agency', 'advertiser', 'sale', 'campaign_manager')->find($id);
         if ($item) {
             $this->data['item'] = $item;
             $this->loadLeftMenu('menu.campaignUpdate', array('item' => $item));
         } else {
             return Redirect::to($this->moduleURL . 'show-list');
         }
     }
     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);
 }
 /**
  *     add/update agency
  *     @param  integer $id 
  */
 function showUpdate($id = 0)
 {
     $this->loadLeftMenu('menu.Ad');
     $this->data['id'] = $id;
     View::share('jsTag', HTML::script("{$this->assetURL}js/select.js") . HTML::script("{$this->assetURL}js/selectize.js"));
     // get list Category
     $categoryModel = new CategoryBaseModel();
     $this->data['listCategory'] = $categoryModel->getAllForm(0);
     // get list Ad Format
     $AdFormatModel = new AdFormatBaseModel();
     $this->data['listAdFormat'] = json_encode($AdFormatModel->getAllForm());
     // get list Type
     $this->data['listAdType'] = Config::get('data.ad_type');
     // get list Wmode
     $this->data['listWmode'] = Config::get('data.wmode');
     // get list Video Linear
     $this->data['listVideoLinear'] = Config::get('data.video_linear');
     // get list Video Type Vast
     $this->data['listTypeVast'] = Config::get('data.video_type_vast');
     /* Phuong-VM 2015/06/30 */
     $this->data['listPlatform'] = Config::get('data.platform');
     $this->data['audiences'] = array();
     // WHEN UPDATE SHOW CURRENT INFOMATION
     if ($id != 0) {
         //get list Audience
         $this->data['audiences'] = $this->audience->getItems($id);
         $this->loadLeftMenu('menu.adUpdate');
         $item = $this->model->find($id);
         // $this->data['adMapFlight'] = $item->flight->lists('name', 'id');
         // $this->data['campaignMapFlight'] = $item->campaign->flight->lists('name', 'id');
         if ($item) {
             $item->platform = json_decode($item->platform);
             $this->data['item'] = $item;
         } else {
             return Redirect::to($this->moduleURL . 'show-list');
         }
     }
     if (Request::isMethod('post')) {
         if ($this->postUpdate($id, $this->data)) {
             return Redirect::to($this->moduleURL . 'show-list');
         }
     }
     $this->layout->content = View::make('showUpdate', $this->data);
 }
 /**
  *     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);
 }