public function getReportJson($arrDate, $data, $flagReport) { //get country $itemCountry = modelCountry::select('id', 'country_name')->get(); if ($data && count($data) > 0) { $totalDisapperved = 0; $totalApproved = 0; foreach ($arrDate as $key => $value) { $approved = 0; $disapproved = 0; foreach ($data as $key1 => $value1) { if ($flagReport == 1) { $dateFormat = date("Y-n", strtotime($value1->updated_at)); } else { $dateFormat = date("d", strtotime($value1->updated_at)); $key = $value; } if ($key == $dateFormat) { if ($value1->status == modelAppPubManager::STATUS_APPROVED) { //publisher approved $approved++; $totalApproved++; } if ($value1->status == modelAppPubManager::STATUS_DISAPPROVED) { //publisher disapproved $disapproved++; $totalDisapperved++; } } } $arrDataApproved[] = $approved; $arrDataDisapproved[] = $disapproved; } //math percent approved and disapproved $total = $totalApproved + $totalDisapperved; if ($total > 0) { $percentApproved = round($totalApproved / $total * 100, 2); $percentDisapproved = round($totalDisapperved * 100 / $total, 2); } else { $percentApproved = 0; $percentDisapproved = 0; } //math percent new publisher $mathPercentNewPublisher = $this->mathPercentNewPublisher($flagReport, $itemCountry, $data); //get data approve $itemApprove = modelPubApprove::whereBetween('updated_at', [$this->dateLast, $this->dateEnd])->limit($this->limit)->get()->toArray(); //show list approve if ($itemApprove) { $htmlListApprove = $this->showListApprove($itemApprove); } else { $htmlListApprove = trim(trans("backend::publisher/text.no_data")); } $arrJson = ['status' => 1, 'series' => [['name' => 'Approved', 'data' => $arrDataApproved], ['name' => 'Disapproved', 'data' => $arrDataDisapproved]], 'xAxis' => array_values($arrDate), 'chartpie' => [['name' => 'Percentage', 'data' => [['Approved', $percentApproved], ['Disapproved', $percentDisapproved]]]], 'textPie' => 'Application status', 'chartpie2' => $mathPercentNewPublisher, 'textPie2' => 'New publisher', 'htmlApprove' => trim($htmlListApprove)]; } else { $arrJson = ['status' => 0]; } return json_encode($arrJson); }
function showUpdate($id = 0) { $this->data['id'] = $id; $this->data['user'] = FALSE; $this->data['statusLists'] = Config::get('data.approve_status'); //get country $this->data['countryLists'] = CountryBaseModel::select('id', 'country_name')->get(); //get language $this->data['languageLists'] = LanguageBaseModel::select('id', 'name')->get(); //get category $this->data['channelLists'] = CategoryBaseModel::select('id', 'name')->where('parent_id', 0)->where('status', 1)->get(); // WHEN UPDATE SHOW CURRENT INFOMATION if ($id != 0) { $item = $this->model->find($id); if ($item) { //get site language $this->data['languageSelected'] = $item->language->lists('id'); //get serve country $this->data['countryServeSelected'] = $item->serveCountry->lists('id'); //get site channel $this->data['channelSelected'] = $item->channel->lists('id'); $this->data['item'] = $item; if ($item->user_id != 0) { $user = Sentry::findUserById($item->user_id); $this->data['user'] = $user; } } else { return Redirect::to($this->moduleURL); } } if (Request::isMethod('post')) { if ($this->postUpdate($id)) { return Redirect::to($this->moduleURL); } } $this->layout->content = View::make('showCreate', $this->data); }
public function showListPublisher() { $this->data['defaultField'] = $this->defaultField; $this->data['defaultOrder'] = $this->defaultOrder; $this->data['defaultURL'] = $this->moduleURL; //get country $this->data['itemCountry'] = modelCountry::select('id', 'country_name')->get(); //get category $this->data['itemCate'] = modelCategory::select('id', 'name')->get(); $this->data['publisher_approved'] = Config::get('backend.publisher_approved'); if (method_exists($this, 'beforeShowList')) { $this->beforeShowList(); } $this->layout->content = View::make('showListPublisher', $this->data); }