/**
  *     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->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);
 }