shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

statistics.php (8897B)


      1 <?php
      2 class ControllerReportStatistics extends Controller {
      3 	private $error = array();
      4 	
      5 	public function index() {
      6 		$this->load->language('report/statistics');
      7 
      8 		$this->document->setTitle($this->language->get('heading_title'));
      9 
     10 		$this->load->model('report/statistics');
     11 
     12 		$this->getList();	
     13 	}
     14 	
     15 	public function ordersale() {
     16 		$this->load->language('report/statistics');
     17 
     18 		$this->document->setTitle($this->language->get('heading_title'));
     19 
     20 		$this->load->model('report/statistics');		
     21 
     22 		if ($this->validate()) {
     23 			$this->load->model('sale/order');
     24 			
     25 			$this->model_report_statistics->editValue('order_sale', $this->model_sale_order->getTotalSales(array('filter_order_status' => implode(',', array_merge($this->config->get('config_complete_status'), $this->config->get('config_processing_status'))))));		
     26 		
     27 			$this->session->data['success'] = $this->language->get('text_success');
     28 			
     29 			$this->response->redirect($this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true));
     30 		}
     31 		
     32 		$this->getList();	
     33 	}
     34 		
     35 	public function orderprocessing() {
     36 		$this->load->language('report/statistics');
     37 
     38 		$this->document->setTitle($this->language->get('heading_title'));
     39 
     40 		$this->load->model('report/statistics');		
     41 
     42 		if ($this->validate()) {
     43 			$this->load->model('sale/order');
     44 			
     45 			$this->model_report_statistics->editValue('order_processing', $this->model_sale_order->getTotalOrders(array('filter_order_status' => implode(',', $this->config->get('config_processing_status')))));		
     46 		
     47 			$this->session->data['success'] = $this->language->get('text_success');
     48 			
     49 			$this->response->redirect($this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true));
     50 		}
     51 		
     52 		$this->getList();	
     53 	}
     54 	
     55 	public function ordercomplete() {
     56 		$this->load->language('report/statistics');
     57 
     58 		$this->document->setTitle($this->language->get('heading_title'));		
     59 		
     60 		$this->load->model('report/statistics');
     61 		
     62 		if ($this->validate()) {
     63 			$this->load->model('sale/order');
     64 			
     65 			$this->model_report_statistics->editValue('order_complete', $this->model_sale_order->getTotalOrders(array('filter_order_status' => implode(',', $this->config->get('config_complete_status')))));		
     66 		
     67 			$this->session->data['success'] = $this->language->get('text_success');
     68 
     69 			$this->response->redirect($this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true));
     70 		}		
     71 		
     72 		$this->getList();	
     73 	}
     74 	
     75 	public function orderother() {
     76 		$this->load->language('report/statistics');
     77 
     78 		$this->document->setTitle($this->language->get('heading_title'));	
     79 		
     80 		$this->load->model('report/statistics');
     81 		
     82 		if ($this->validate()) {
     83 			$this->load->model('localisation/order_status');
     84 				
     85 			$order_status_data = array();
     86 	
     87 			$results = $this->model_localisation_order_status->getOrderStatuses();
     88 	
     89 			foreach ($results as $result) {
     90 				if (!in_array($result['order_status_id'], array_merge($this->config->get('config_complete_status'), $this->config->get('config_processing_status')))) {
     91 					$order_status_data[] = $result['order_status_id'];
     92 				}
     93 			}		
     94 			
     95 			$this->load->model('sale/order');
     96 			
     97 			$this->model_report_statistics->editValue('order_other', $this->model_sale_order->getTotalOrders(array('filter_order_status' => implode(',', $order_status_data))));
     98 		
     99 			$this->session->data['success'] = $this->language->get('text_success');
    100 			
    101 			$this->response->redirect($this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true));
    102 		}
    103 		
    104 		$this->getList();	
    105 	}
    106 
    107 	public function returns() {
    108 		$this->load->language('report/statistics');
    109 
    110 		$this->document->setTitle($this->language->get('heading_title'));	
    111 				
    112 		$this->load->model('report/statistics');
    113 		
    114 		if ($this->validate()) {
    115 			$this->load->model('sale/return');
    116 			
    117 			$this->model_report_statistics->editValue('return', $this->model_sale_return->getTotalReturns(array('filter_return_status_id' => $this->config->get('config_return_status_id'))));
    118 		
    119 			$this->session->data['success'] = $this->language->get('text_success');
    120 
    121 			$this->response->redirect($this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true));		
    122 		}
    123 		
    124 		$this->getList();	
    125 	}
    126 	
    127 	public function customer() {
    128 		$this->load->language('report/statistics');
    129 
    130 		$this->document->setTitle($this->language->get('heading_title'));	
    131 				
    132 		$this->load->model('report/statistics');
    133 		
    134 		if ($this->validate()) {	
    135 			$this->load->model('customer/customer');
    136 			
    137 			$this->model_report_statistics->editValue('customer', $this->model_customer_customer->getTotalCustomers(array('filter_approved' => 0)));
    138 		
    139 			$this->session->data['success'] = $this->language->get('text_success');
    140 
    141 			$this->response->redirect($this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true));		
    142 		}
    143 		
    144 		$this->getList();	
    145 	}	
    146 		
    147 	public function affiliate() {
    148 		$this->load->language('report/statistics');
    149 
    150 		$this->document->setTitle($this->language->get('heading_title'));	
    151 				
    152 		$this->load->model('report/statistics');
    153 		
    154 		if ($this->validate()) {
    155 			$this->load->model('customer/customer');
    156 	
    157 			$this->model_report_statistics->editValue('affiliate', $this->model_customer_customer->getTotalAffiliates(array('filter_approved' => 0)));
    158 			
    159 			$this->session->data['success'] = $this->language->get('text_success');
    160 			
    161 			$this->response->redirect($this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true));
    162 		}
    163 		
    164 		$this->getList();				
    165 	}
    166 
    167 	public function product() {
    168 		$this->load->language('report/statistics');
    169 
    170 		$this->document->setTitle($this->language->get('heading_title'));	
    171 				
    172 		$this->load->model('report/statistics');
    173 		
    174 		if ($this->validate()) {		
    175 			$this->load->model('catalog/product');
    176 			
    177 			$this->model_report_statistics->editValue('product', $this->model_catalog_product->getTotalProducts(array('filter_quantity' => 0)));
    178 
    179 			$this->session->data['success'] = $this->language->get('text_success');
    180 
    181 			$this->response->redirect($this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true));
    182 		}
    183 		
    184 		$this->getList();
    185 	}	
    186 	
    187 	public function review() {
    188 		$this->load->language('report/statistics');
    189 
    190 		$this->document->setTitle($this->language->get('heading_title'));	
    191 				
    192 		$this->load->model('report/statistics');	
    193 		
    194 		if ($this->validate()) {	
    195 			$this->load->model('catalog/review');
    196 				
    197 			$this->model_report_statistics->editValue('review', $this->model_catalog_review->getTotalReviews(array('filter_status' => 0)));
    198 			
    199 			$this->session->data['success'] = $this->language->get('text_success');
    200 
    201 			$this->response->redirect($this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true));
    202 		}
    203 
    204 		$this->getList();
    205 	}
    206 	
    207 	public function getList() {
    208 		$data['breadcrumbs'] = array();
    209 
    210 		$data['breadcrumbs'][] = array(
    211 			'text' => $this->language->get('text_home'),
    212 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
    213 		);
    214 
    215 		$data['breadcrumbs'][] = array(
    216 			'text' => $this->language->get('heading_title'),
    217 			'href' => $this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'], true)
    218 		);
    219 
    220 		$data['statistics'] = array();
    221 		
    222 		$this->load->model('report/statistics');
    223 		
    224 		$results = $this->model_report_statistics->getStatistics();
    225 		
    226 		foreach ($results as $result) {
    227 			$data['statistics'][] = array(
    228 				'name'  => $this->language->get('text_' . $result['code']),
    229 				'value' => $result['value'],
    230 				'href'  => $this->url->link('report/statistics/' . str_replace('_', '', $result['code']), 'user_token=' . $this->session->data['user_token'], true)
    231 			);
    232 		}
    233 				
    234 		if (isset($this->error['warning'])) {
    235 			$data['error_warning'] = $this->error['warning'];
    236 		} else {
    237 			$data['error_warning'] = '';
    238 		}
    239 
    240 		if (isset($this->session->data['success'])) {
    241 			$data['success'] = $this->session->data['success'];
    242 
    243 			unset($this->session->data['success']);
    244 		} else {
    245 			$data['success'] = '';
    246 		}
    247 							
    248 		$data['header'] = $this->load->controller('common/header');
    249 		$data['column_left'] = $this->load->controller('common/column_left');
    250 		$data['footer'] = $this->load->controller('common/footer');
    251 
    252 		$this->response->setOutput($this->load->view('report/statistics', $data));
    253 	}
    254 	
    255 	protected function validate() {
    256 		if (!$this->user->hasPermission('modify', 'report/statistics')) {
    257 			$this->error['warning'] = $this->language->get('error_permission');
    258 		}
    259 		
    260 		return !$this->error;
    261 	}	
    262 }