コード例 #1
0
 public function updateData()
 {
     // get list flight website
     if ($publisher = $this->getPublisher()) {
         $websiteRange = $publisher->publisherSite->lists('id');
         $flightWebsite = new FlightWebsiteBaseModel();
         $lists = $flightWebsite->getListByRangeWebsite($websiteRange);
         if (!empty($lists)) {
             foreach ($lists as $item) {
             }
         }
     }
 }
コード例 #2
0
 public function getPdf()
 {
     $datemonth = Input::get('datemonth');
     if ($datemonth) {
         if ($datemonth != null) {
             $datemonth >= 1 && $datemonth <= 9 ? $month = '0' . $datemonth : ($month = $datemonth);
             $flight = new FlightWebsiteBaseModel();
             $start_date = date('Y', time()) . '-' . $month . '-01';
             $end_date = date('Y', time()) . '-' . $month . '-' . date('t', strtotime($start_date));
             $idpublisher = $this->getPublisher()->id;
             // get Campagin da chay
             $camend = $flight->join('campaign', 'campaign.id', '=', 'flight.campaign_id')->join('flight', 'flight.id', '=', 'flight_website.flight_id')->where('campaign.start_date', '>=', $start_date)->where('campaign.end_date', '<=', $end_date)->where('flight_website.website_id', '=', $idpublisher)->select(array('campaign.name as campaignname', 'campaign.start_date', 'campaign.end_date', 'campaign.sale_order_tax', 'flight_website.*'))->get();
             $camend = $this->sumEarnings($camend, $start_date, $end_date);
             pr($camend, 1);
             //$camend = $this->sumEarnings($camend, $start_date, $end_date);
             //// get Campagin dang chay
             $camrun = $flight->join('campaign', 'campaign.id', '=', 'flight.campaign_id')->join('flight', 'flight.id', '=', 'flight_website.flight_id')->where('campaign.start_date', '<', $end_date)->where('campaign.end_date', '>', date("Y-m-d", time()))->where('flight_website.website_id', '=', $idpublisher)->select(array('campaign.name as campaignname', 'campaign.start_date', 'campaign.end_date', 'campaign.sale_order_tax', 'flight_website.*'))->get();
             if (count($camrun) == 0 && count($camend) == 0) {
                 $_SESSION['error'] = "No data";
                 return Redirect::to($this->moduleURL . 'get-invoice');
             }
             $camrun = $this->sumEarnings($camrun, $start_date, $end_date);
             $publisher = PublisherBaseModel::find($idpublisher);
             $param['datemonth'] = $datemonth;
             $param['camend'] = $camend;
             $param['mont'] = $start_date;
             $param['camrun'] = $camrun;
             $param['publisher'] = $publisher;
             $param['pinetech'] = ConfigBaseModel::find(1);
             if ($param['pinetech'] == null) {
                 $pinetech = new stdClass();
                 $pinetech->name = "N/A";
                 $pinetech->address = "N/A";
                 $pinetech->state = "N/A";
                 $pinetech->city = "N/A";
                 $pinetech->country = "N/A";
                 $param['pinetech'] = $pinetech;
             }
             $pdf = PDF::loadView('getInvoicePdf', $param)->setPaper('a4')->setWarnings(false);
             $file = "Invoice_" . $publisher->id . "_" . $publisher->company . "_" . date('M_Y', strtotime($start_date)) . '.pdf';
             return $pdf->download($file);
         } else {
             return Redirect::to($this->moduleURL . 'get-invoice');
         }
     } else {
         return Redirect::to($this->moduleURL . 'get-invoice');
     }
 }
コード例 #3
0
 /**
  * 
  * 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";
 }
コード例 #4
0
 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";
     }
 }
コード例 #5
0
ファイル: Delivery.php プロジェクト: huycao/yoplatform
 public function removeCache($object, $objectID)
 {
     $object = strtolower($object);
     $renewCache = true;
     switch ($object) {
         case 'flight':
             $flight = $this->getFlight($objectID);
             if ($flight) {
                 $flightWebsites = FlightWebsiteBaseModel::where("flight_id", $flight->id)->whereRaw("( SELECT count(*) FROM `pt_flight` WHERE `ad_format_id` = {$flight->ad_format_id} AND id = `pt_flight_website`.`flight_id` AND `status` = 1) > 0")->get();
                 if ($flightWebsites) {
                     $redis = new RedisBaseModel(Config::get('redis.redis_2.host'), Config::get('redis.redis_2.port'), false);
                     foreach ($flightWebsites as $fw) {
                         $cacheKey = "FlightWebsite_{$fw->website_id}_{$flight->ad_format_id}";
                         $cachField = $fw->id;
                         $redis->hDel($cacheKey, $cachField);
                     }
                 }
             }
             break;
         default:
             return false;
     }
     return true;
 }
コード例 #6
0
 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;
 }
コード例 #7
0
 function updateTrackingSumary()
 {
     $datas = FlightWebsiteBaseModel::where("publisher_base_cost", ">", 0)->get();
     foreach ($datas as $data) {
         DB::table('tracking_summary')->where('flight_website_id', $data->id)->update(['publisher_base_cost' => $data->publisher_base_cost]);
     }
     return "";
 }