Exemplo n.º 1
0
 function cgAction()
 {
     $clearArray = array();
     $this->filter($clearArray);
     if (!isset($this->params['group_by'])) {
         $this->params['group_by'] = 1;
     }
     if (isset($this->params['download_csv'])) {
         $csvField = array('campaign_id', 'campaign_name', 'gateway_id_n', 'alias', 'profile_id', 'profile_name', 'country_id', 'country_name');
         $models = AFActiveDataProvider::models('Gateway', $this->params);
         $dataProvider = $models->getCGReportCSV();
         Csv::printDataProviderCsv($dataProvider, $csvField, 'cg_report');
     }
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
     $models = AFActiveDataProvider::models('Gateway', $this->params, $pagination);
     $dataProvider = $models->getCGReport();
     $filterFields = Gateway::$FilterFields = $models->getoutFilterFields($clearArray);
     $fields = array('cg_field_' . $this->params['group_by'] . '_formatted', 'profile_formatted', 'country_formatted', 'count_cg_' . $this->params['group_by'] . '_formatted');
     $campaigns = $models->getCGReportCampaigns();
     $gateways = $models->getCGReportGateways();
     $currencies = $models->getCGReportCurrencies();
     // set ajax table
     if (AF::isAjaxRequestModels()) {
         $this->view->includeFile('_cg_table', array('application', 'views', 'reports'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'fields' => $fields, 'campaigns' => $campaigns, 'gateways' => $gateways, 'currencies' => $currencies, 'ajax' => true));
         die;
     }
     $this->addToPageTitle(__('cg_report'));
     Assets::css('jquery-ui');
     Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js');
     Assets::js('dateRange/jquery.daterange');
     Assets::js('ajax_table');
     $this->render('cg', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'campaigns' => $campaigns, 'currencies' => $currencies, 'gateways' => $gateways, 'filterFields' => $filterFields, 'fields' => $fields));
 }