public function updateData($userId) { $this->storeData($userId); $this->updateUser(); $websiteModel = new PublisherSiteBaseModel(); $status = $this->status == 3 ? 1 : 0; $websiteModel->updateAllStatus($this->id, $status); return $this; }
public function showPublisher() { $start_date = Input::get('start_date') ? date("Y-m-d", strtotime(Input::get('start_date'))) : date('Y-m-d'); $end_date = Input::get('end_date') ? date("Y-m-d", strtotime(Input::get('end_date'))) : date('Y-m-d'); $website = Input::get('website'); $adformat = Input::get('adformat'); $this->data['lists_website'] = PublisherSiteBaseModel::where("status", '=', 1)->get(); $this->data['lists_adfortmat'] = AdFormatBaseModel::get(); $tracking = DB::connection('mongodb')->collection('trackings_summary')->where("created_d", '>=', $start_date)->where("created_d", '<=', $end_date); if ($website != "") { $tracking = $tracking->where('w', '=', (int) $website); } if ($adformat != "") { $tracking = $tracking->where('af', '=', (int) $adformat); } $tracking = $tracking->get(); $list_site = array(); $list_zone = array(); $data_ok = array(); if (!empty($tracking)) { foreach ($tracking as $tract) { if (isset($tract['ads_request'])) { if (!isset($list_site[$tract['w']])) { $site = PublisherSiteBaseModel::find($tract['w']); if ($site) { $list_site[$tract['w']] = $site; } else { continue; } } if (!isset($list_zone[$tract['az']])) { $adzone = PublisherAdZoneBaseModel::find($tract['az']); if ($adzone) { $list_zone[$tract['az']] = $adzone; } else { continue; } } if (isset($tract['f'])) { $data_ok[$tract['w']][$tract['az']]['ads'][] = $tract['ads_request']; } else { $data_ok[$tract['w']][$tract['az']]['noads'][] = $tract['ads_request']; } } } } $this->data['list_zone'] = $list_zone; $this->data['list_site'] = $list_site; $this->data['data_ok'] = $data_ok; $this->data['start_date'] = date("m/d/Y", strtotime($start_date)); $this->data['end_date'] = date("m/d/Y", strtotime($end_date)); $this->data['website'] = $website; $this->data['adformat'] = $adformat; $this->layout->content = View::make('publisher', $this->data); }
public function getWebsites() { $flight_ids = Input::get('flights', array()); $websites = PublisherSiteBaseModel::join('flight_website', 'publisher_site.id', '=', 'flight_website.website_id')->whereIn('flight_website.flight_id', $flight_ids)->groupBy('publisher_site.id')->select('publisher_site.name as name', 'publisher_site.id as id')->lists('name', 'id'); return Response::json($websites); }
public function addAllWebsite() { $status = TRUE; $view = NULL; $flightId = Input::get('flightId'); $flightData = FlightBaseModel::find($flightId); // get all website $listWebsite = PublisherSiteBaseModel::where('status', 1)->lists('id'); if (!empty($listWebsite)) { foreach ($listWebsite as $websiteId) { // check flightWebsite exist $exist = FlightWebsiteBaseModel::where(array('flight_id' => $flightId, 'website_id' => $websiteId))->first(); if (empty($exist)) { $item = new FlightWebsiteBaseModel(); $item->flight_id = $flightId; $item->website_id = $websiteId; $item->type = 'adnetwork'; $item->created_by = $this->user->id; $item->updated_by = $this->user->id; $item->status = 1; $item->save(); (new Delivery())->renewCache('flight_website', $item->id); } } } $this->data['flightWebsiteList'] = $flightData->flightWebsite; $this->data['totalInventory'] = $flightData->total_inventory; $view = View::make('websiteList', $this->data)->render(); return Response::json(array('status' => $status, 'view' => $view)); }
public function showDelSite($pid = 0, $wid = 0) { if ($pid == 0 || $wid == 0) { return Redirect::to($this->moduleURL . 'show-list'); } $item = PublisherSiteBaseModel::find($wid); if (!$item) { return Redirect::to($this->moduleURL . 'show-list'); } if ($item->publisher_id != $pid) { return Redirect::to($this->moduleURL . 'show-list'); } if ($item->delete()) { return Redirect::to($this->moduleURL . 'view/' . $pid); } }