shop.balmet.com

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

customer_order.php (7153B)


      1 <?php
      2 class ControllerExtensionReportCustomerOrder extends Controller {
      3 	public function index() {
      4 		$this->load->language('extension/report/customer_order');
      5 
      6 		$this->document->setTitle($this->language->get('heading_title'));
      7 
      8 		$this->load->model('setting/setting');
      9 
     10 		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
     11 			$this->model_setting_setting->editSetting('report_customer_order', $this->request->post);
     12 
     13 			$this->session->data['success'] = $this->language->get('text_success');
     14 
     15 			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report', true));
     16 		}
     17 
     18 		if (isset($this->error['warning'])) {
     19 			$data['error_warning'] = $this->error['warning'];
     20 		} else {
     21 			$data['error_warning'] = '';
     22 		}
     23 
     24 		$data['breadcrumbs'] = array();
     25 
     26 		$data['breadcrumbs'][] = array(
     27 			'text' => $this->language->get('text_home'),
     28 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
     29 		);
     30 
     31 		$data['breadcrumbs'][] = array(
     32 			'text' => $this->language->get('text_extension'),
     33 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report', true)
     34 		);
     35 
     36 		$data['breadcrumbs'][] = array(
     37 			'text' => $this->language->get('heading_title'),
     38 			'href' => $this->url->link('extension/report/customer_order', 'user_token=' . $this->session->data['user_token'], true)
     39 		);
     40 
     41 		$data['action'] = $this->url->link('extension/report/customer_order', 'user_token=' . $this->session->data['user_token'], true);
     42 
     43 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report', true);
     44 
     45 		if (isset($this->request->post['report_customer_order_status'])) {
     46 			$data['report_customer_order_status'] = $this->request->post['report_customer_order_status'];
     47 		} else {
     48 			$data['report_customer_order_status'] = $this->config->get('report_customer_order_status');
     49 		}
     50 
     51 		if (isset($this->request->post['report_customer_order_sort_order'])) {
     52 			$data['report_customer_order_sort_order'] = $this->request->post['report_customer_order_sort_order'];
     53 		} else {
     54 			$data['report_customer_order_sort_order'] = $this->config->get('report_customer_order_sort_order');
     55 		}
     56 
     57 		$data['header'] = $this->load->controller('common/header');
     58 		$data['column_left'] = $this->load->controller('common/column_left');
     59 		$data['footer'] = $this->load->controller('common/footer');
     60 
     61 		$this->response->setOutput($this->load->view('extension/report/customer_order_form', $data));
     62 	}
     63 	
     64 	protected function validate() {
     65 		if (!$this->user->hasPermission('modify', 'extension/report/customer_order')) {
     66 			$this->error['warning'] = $this->language->get('error_permission');
     67 		}
     68 
     69 		return !$this->error;
     70 	}
     71 			
     72 	public function report() {
     73 		$this->load->language('extension/report/customer_order');
     74 
     75 		if (isset($this->request->get['filter_date_start'])) {
     76 			$filter_date_start = $this->request->get['filter_date_start'];
     77 		} else {
     78 			$filter_date_start = '';
     79 		}
     80 
     81 		if (isset($this->request->get['filter_date_end'])) {
     82 			$filter_date_end = $this->request->get['filter_date_end'];
     83 		} else {
     84 			$filter_date_end = '';
     85 		}
     86 
     87 		if (isset($this->request->get['filter_customer'])) {
     88 			$filter_customer = $this->request->get['filter_customer'];
     89 		} else {
     90 			$filter_customer = '';
     91 		}
     92 
     93 		if (isset($this->request->get['filter_order_status_id'])) {
     94 			$filter_order_status_id = $this->request->get['filter_order_status_id'];
     95 		} else {
     96 			$filter_order_status_id = 0;
     97 		}
     98 
     99 		if (isset($this->request->get['page'])) {
    100 			$page = $this->request->get['page'];
    101 		} else {
    102 			$page = 1;
    103 		}
    104 
    105 		$this->load->model('extension/report/customer');
    106 
    107 		$data['customers'] = array();
    108 
    109 		$filter_data = array(
    110 			'filter_date_start'			=> $filter_date_start,
    111 			'filter_date_end'			=> $filter_date_end,
    112 			'filter_customer'			=> $filter_customer,
    113 			'filter_order_status_id'	=> $filter_order_status_id,
    114 			'start'						=> ($page - 1) * $this->config->get('config_limit_admin'),
    115 			'limit'						=> $this->config->get('config_limit_admin')
    116 		);
    117 
    118 		$customer_total = $this->model_extension_report_customer->getTotalOrders($filter_data);
    119 
    120 		$results = $this->model_extension_report_customer->getOrders($filter_data);
    121 
    122 		foreach ($results as $result) {
    123 			$data['customers'][] = array(
    124 				'customer'       => $result['customer'],
    125 				'email'          => $result['email'],
    126 				'customer_group' => $result['customer_group'],
    127 				'status'         => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
    128 				'orders'         => $result['orders'],
    129 				'products'       => $result['products'],
    130 				'total'          => $this->currency->format($result['total'], $this->config->get('config_currency')),
    131 				'edit'           => $this->url->link('customer/customer/edit', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . $result['customer_id'], true)
    132 			);
    133 		}
    134 
    135 		$data['user_token'] = $this->session->data['user_token'];
    136 
    137 		$this->load->model('localisation/order_status');
    138 
    139 		$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
    140 
    141 		$url = '';
    142 
    143 		if (isset($this->request->get['filter_date_start'])) {
    144 			$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
    145 		}
    146 
    147 		if (isset($this->request->get['filter_date_end'])) {
    148 			$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
    149 		}
    150 
    151 		if (isset($this->request->get['filter_customer'])) {
    152 			$url .= '&filter_customer=' . urlencode($this->request->get['filter_customer']);
    153 		}
    154 
    155 		if (isset($this->request->get['filter_order_status_id'])) {
    156 			$url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
    157 		}
    158 
    159 		$pagination = new Pagination();
    160 		$pagination->total = $customer_total;
    161 		$pagination->page = $page;
    162 		$pagination->limit = $this->config->get('config_limit_admin');
    163 		$pagination->url = $this->url->link('report/report', 'user_token=' . $this->session->data['user_token'] . '&code=customer_order' . $url . '&page={page}', true);
    164 
    165 		$data['pagination'] = $pagination->render();
    166 
    167 		$data['results'] = sprintf($this->language->get('text_pagination'), ($customer_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($customer_total - $this->config->get('config_limit_admin'))) ? $customer_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $customer_total, ceil($customer_total / $this->config->get('config_limit_admin')));
    168 
    169 		$data['filter_date_start'] = $filter_date_start;
    170 		$data['filter_date_end'] = $filter_date_end;
    171 		$data['filter_customer'] = $filter_customer;
    172 		$data['filter_order_status_id'] = $filter_order_status_id;
    173 
    174 		return $this->load->view('extension/report/customer_order_info', $data);
    175 	}
    176 }