Exemplo n.º 1
0
 /**
  * Display method
  *
  * @param   string  $tpl  The template name
  *
  * @return  void
  */
 public function display($tpl = null)
 {
     $model = $this->getModel();
     $this->state = $model->getState();
     $this->activeFilters = $model->getActiveFilters();
     $this->filterForm = $model->getForm();
     $filters = array();
     $filters['status'] = RApiPaymentStatus::getStatusCompleted();
     if ($filter = $this->state->get('filter.payment_name')) {
         $filters['payment_name'] = $filter;
     }
     if ($filter = $this->state->get('filter.extension_name')) {
         $filters['extension_name'] = $filter;
     }
     if ($startDate = $this->state->get('filter.start_date')) {
         $filters['start_date'] = $startDate;
     }
     if ($endDate = $this->state->get('filter.end_date')) {
         $filters['end_date'] = $endDate;
     }
     $this->viewType = $this->state->get('filter.dashboard_view_type');
     $this->chartType = $this->state->get('filter.chart_type');
     if (empty($this->viewType)) {
         $this->viewType = RBootstrap::getConfig('payment_dashboard_view_type', 'payment_name');
         $this->state->set('filter.dashboard_view_type', $this->viewType);
     }
     if (empty($this->chartType)) {
         $this->chartType = RBootstrap::getConfig('payment_chart_type', 'Line');
         $this->state->set('filter.chart_type', $this->chartType);
     }
     if ($this->viewType == 'status') {
         unset($filters['status']);
     }
     $this->paymentData['chart'] = RApiPaymentHelper::getChartData($filters, 7, $this->viewType);
     $filters['start_date'] = date('Y-01-01', strtotime('today -1 year'));
     $filters['end_date'] = date('Y-m-d', strtotime('today'));
     $filters['status'] = RApiPaymentStatus::getStatusCompleted();
     $this->paymentData['overall'] = RApiPaymentHelper::getChartData($filters, 7, 'all');
     $this->chartData = RApiPaymentHelper::prepareChartData($this->paymentData['chart'], $this->chartType);
     parent::display($tpl);
 }