Пример #1
0
 /**
  * Generate the report data array
  *
  * @param array $report
  * @return array
  */
 private function prepareData($report)
 {
     $saveReportData = $this->Report->get_save_report_by_id($report['saved_reports_id']);
     $this->data->report_info = $this->Report->get_save_report_by_id($report['saved_reports_id']);
     if (empty($saveReportData)) {
         return;
     }
     if (empty($this->data->report_info)) {
         return;
     }
     $report_where = json_decode($saveReportData['report_where'], true);
     if (!empty($report_where)) {
         foreach ($report_where as $key => $value) {
             $this->data->{$key} = $value;
         }
     }
     $report_where = json_decode($this->data->report_info['report_where'], true);
     if (!empty($report_where)) {
         foreach ($report_where as $key => $value) {
             $this->data->{$key} = $value;
         }
     }
     $this->data->last_crawl = $this->crawl_data_m->last_crawl();
     $this->crawl_range = $this->crawl_data_m->last_crawl_range();
     $saveReportData['report_where'] = $report_where;
     $this->data->report_where = $report_where;
     $store_data = $this->Store->get_store_track($saveReportData['store_id']);
     $this->load->library('reportinfo');
     $this->report_info = new Reportinfo($saveReportData);
     $this->report_info->report_id = $saveReportData['id'];
     $this->report_info->report_name = $saveReportData['report_name'];
     $this->report_info->report_type = $report_where['report_type'];
     $this->report_info->controller = $saveReportData['controller'];
     $this->report_info->controller_function = $saveReportData['controller_function'];
     $this->report_info->user_id = isset($store_data->user_id) ? $store_data->user_id : 0;
     $this->report_info->store_id = $report['store_id'];
     $this->store_id = $report['store_id'];
     //prep data for specific type of report
     if ($this->report_info->report_type === 'group_report') {
         $groupProducts = $this->Product->getProductsByGroupId($report_where['group_id']);
         $product_ids = array();
         foreach ($groupProducts as $gp) {
             $product_ids[] = $gp['product_id'];
         }
         $this->report_info->product_ids = $product_ids;
     }
     //
     // Set all the request data
     //
     $this->report_info->store_id = $this->report_info->store_id == '0' ? 'all' : $this->report_info->store_id;
     $this->user_id = $this->report_info->user_id;
     $this->_get_report_data();
     $this->data->report_chart = 'line';
     $this->data->request_info = $this->report_info->get();
     foreach ($this->data->request_info as $key => $value) {
         $this->data->{$key} = $value;
     }
     $brandInfo = $this->account->get_brand_info($this->report_info->store_id);
     $this->data->brand_name = $brandInfo['store_name'];
     $this->data->noRecord = $this->config->item('no_record');
     $this->data->url_modifier = $this->data->controller_function === 'bycompetition' ? '0/bycompetition' : '';
     $this->data->merchant_logo = $this->account->get_merchant_thumb($this->report_info->store_id);
     if ($this->report_info->report_type === 'whois') {
         $this->data->is_report = true;
         if (!trim($this->data->reportMarketPlace)) {
             $report_data = get24ReportTitleAndDate(array('time_frame' => 24, 'title' => "Who's selling my products in", 'fromDate' => strtotime('-24 hours'), 'toDate' => time()));
             $this->data->headerDate = $report_data['date'];
             $this->data->title = $report_data['title'];
             $this->data->is_report = false;
         }
     } elseif ($this->report_info->report_type === 'pricingoverview' || $this->report_info->report_type === 'violationoverview') {
         $this->data->headerDate = date("m/d/Y H:ia", time());
         $this->data->title = $this->report_info->report_name;
     } else {
         $rptInfo = getTitleReporting($this->data->request_info);
         $this->data->headerDate = $rptInfo['date'];
         $this->data->title = $rptInfo['title'];
     }
     // the variables are populated in the wrong sequence.  We pass them here to ensure accuracy.  // TODO: refactor?
     if (!empty($this->data->Data)) {
         foreach ($this->data->Data as $key => $value) {
             $this->data->{$key} = $value;
         }
     }
 }
Пример #2
0
 function pdfExport($imageName = '')
 {
     ini_set('memory_limit', '1024M');
     //
     // Get the request info
     //
     $this->data->report_where = json_decode(html_entity_decode($this->input->post('report_where')), true);
     $this->data->report_where['fromDate'] = isset($this->data->report_where['date_from']) ? $this->data->report_where['date_from'] : strtotime(date('Y-m-d 00:00:00'));
     $this->data->report_where['toDate'] = isset($this->data->report_where['date_to']) ? $this->data->report_where['date_to'] : strtotime(date('Y-m-d 23:59:59'));
     $this->data->report_where['time_frame'] = isset($this->data->report_where['time_frame']) ? $this->data->report_where['time_frame'] : '24';
     $overviews = array('pricingoverview' => TRUE, 'violationoverview' => TRUE);
     if (isset($this->data->report_where) && !isset($overviews[$this->data->report_where['report_type']])) {
         if (isset($this->data->report_where['product_ids'])) {
             $this->data->product_ids = $this->data->report_where['product_ids'];
         }
     }
     //
     // Determine the title
     //
     $reportInfo = getTitleReporting($this->data->report_where, 'Y', true);
     $this->data->headerDate = $reportInfo['date'];
     $this->data->title = $reportInfo['title'];
     if ($report_title = $this->input->post('report_title')) {
         $this->data->title = $report_title;
     } elseif (!empty($this->data->report_where['group_id'])) {
         $group = $this->Product->getGroupByID($this->data->report_where['group_id']);
         if (!empty($group['name'])) {
             $this->data->title = $group['name'];
         }
     }
     if (isset($_POST['report_name'])) {
         $this->data->title = $this->input->post('report_name') . " - " . $this->data->title;
     }
     //
     // Get the images used
     //
     $graphData = $this->input->post('graph_data');
     if ($imageName == '' and $graphData) {
         $imageName = $this->generateImage($graphData, $this->store_id);
     }
     $this->data->graph_image_name = $imageName ? $imageName : '';
     $this->data->merchant_logo = $this->Account->get_merchant_thumb($this->store_id);
     //
     // Generate the content
     //
     require_once APPPATH . 'libraries/mvexport.php';
     $this->mvexport = new mvexport($this->input->post('export_content'));
     $this->data->report = $this->mvexport->getReport('.reportTable');
     $phtml = $this->load->view('reports/_pdf', $this->data, TRUE);
     //
     // Determine the filename
     //
     $fn = $this->input->post('file_name');
     if (!$fn) {
         $fn = $this->data->title;
     }
     //
     // Create the pdf
     //
     $this->writePDF($phtml, $fn . '.pdf');
     exit;
 }