/** * * Change status */ function websiteChangeStatus() { if (Request::ajax()) { $id = Input::get('id'); $currentStatus = Input::get('status'); $status = $currentStatus == 1 ? 0 : 1; $flightWebsite = FlightWebsiteBaseModel::find($id); if ($flightWebsite) { $flightWebsite->status = $status; if ($flightWebsite->save()) { //Thuc hien ghi cache flight website da update (to do) (new Delivery())->renewCache('flight_website', $id); return View::make('ajaxWebsiteChangeStatus', compact('flightWebsite')); } } } return "fail"; }
public function generateSummaryData($rawSummaryData) { $recordUpdated = 0; if (empty($rawSummaryData)) { return $recordUpdated; } foreach ($rawSummaryData as $row) { $dataUpdate = []; $where = []; $where = ['website_id' => $row['w'], 'publisher_ad_zone_id' => $row['az'], 'ad_format_id' => $row['af'], 'hour' => intval(substr($row['created_h'], -2)), 'date' => $row['created_d']]; if ('ovr' == substr($row['_id'], -3)) { $where['ovr'] = 1; } else { $where['ovr'] = 0; } if (strpos($row['_id'], 'noads') === FALSE) { //summary of tracking success $where['flight_id'] = $row['f']; $where['flight_website_id'] = $row['fw']; $where['campaign_id'] = $row['camp']; $where['ad_id'] = $row['a']; $arrID = explode('_', $row['_id']); if (!empty($arrID) && count($arrID) >= 3 && is_numeric($arrID[2])) { $where['publisher_base_cost'] = $arrID[2]; } else { $flight_website = FlightWebsiteBaseModel::find($row['fw']); if ($flight_website) { $where['publisher_base_cost'] = $flight_website->publisher_base_cost; } } } else { //summary ads request of adzone and adformat when no ads deliveried $where['flight_website_id'] = 0; } //list metrics to repport $metrics = ['impression', 'unique_impression', 'click', 'unique_click', 'ads_request', 'conversion', 'start', 'firstquartile', 'midpoint', 'thirdquartile', 'complete', 'pause', 'unpause', 'mute', 'unmute', 'fullscreen']; $checkExists = DB::table($this->tableMySQL)->select('id')->where($where)->first(); foreach ($metrics as $metric) { if (!empty($row[$metric])) { $dataUpdate[$metric] = $row[$metric]; } } if ($checkExists) { DB::table($this->tableMySQL)->where('id', $checkExists->id)->update($dataUpdate); } else { $dataUpdate = array_merge($dataUpdate, $where); DB::table($this->tableMySQL)->insert($dataUpdate); } // pr($dataUpdate); $recordUpdated++; } return $recordUpdated; }
function saveOrder() { if (Request::ajax()) { $listorder = Input::get('sort'); if (is_array($listorder)) { $order = 1; foreach ($listorder as $id => $value) { $item = FlightWebsiteBaseModel::find($id); $item->order = $order; $item->update(); $order++; } return "TRUE"; } return "FALSE"; } }
public function showPreview($fwid = 0, $id = 0) { if ($fwid != 0 && $id != 0) { $item = FlightBaseModel::with('ad', 'flightWebsite')->find($id); $flightWebsite = FlightWebsiteBaseModel::find($fwid); $isActive = isset($flightWebsite->status) ? $flightWebsite->status : 0; if ($item) { $data = $item; switch ($item->ad_format_id) { case '8': $view = View::make('previewVideo', compact('data', 'isActive')); break; case '9': $view = ''; break; case '12': $view = View::make('previewBalloon', compact('data', 'isActive')); break; case '14': $view = ''; break; case '16': $view = View::make('previewImage', compact('data', 'isActive')); break; default: $view = ''; break; } return $view; } } }