shop.balmet.com

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

customer_transaction.php (6608B)


      1 <?php
      2 class ControllerExtensionReportCustomerTransaction extends Controller {
      3 	public function index() {
      4 		$this->load->language('extension/report/customer_transaction');
      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_transaction', $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_transaction', 'user_token=' . $this->session->data['user_token'], true)
     39 		);
     40 
     41 		$data['action'] = $this->url->link('extension/report/customer_transaction', '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_transaction_status'])) {
     46 			$data['report_customer_transaction_status'] = $this->request->post['report_customer_transaction_status'];
     47 		} else {
     48 			$data['report_customer_transaction_status'] = $this->config->get('report_customer_transaction_status');
     49 		}
     50 
     51 		if (isset($this->request->post['report_customer_transaction_sort_order'])) {
     52 			$data['report_customer_transaction_sort_order'] = $this->request->post['report_customer_transaction_sort_order'];
     53 		} else {
     54 			$data['report_customer_transaction_sort_order'] = $this->config->get('report_customer_transaction_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_transaction_form', $data));
     62 	}
     63 	
     64 	protected function validate() {
     65 		if (!$this->user->hasPermission('modify', 'extension/report/customer_transaction')) {
     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_transaction');
     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['page'])) {
     94 			$page = $this->request->get['page'];
     95 		} else {
     96 			$page = 1;
     97 		}
     98 
     99 		$this->load->model('extension/report/customer_transaction');
    100 		
    101 		$data['customers'] = array();
    102 
    103 		$filter_data = array(
    104 			'filter_date_start'	=> $filter_date_start,
    105 			'filter_date_end'	=> $filter_date_end,
    106 			'filter_customer'	=> $filter_customer,
    107 			'start'				=> ($page - 1) * $this->config->get('config_limit_admin'),
    108 			'limit'				=> $this->config->get('config_limit_admin')
    109 		);
    110 
    111 		$customer_total = $this->model_extension_report_customer_transaction->getTotalTransactions($filter_data);
    112 
    113 		$results = $this->model_extension_report_customer_transaction->getTransactions($filter_data);
    114 
    115 		foreach ($results as $result) {
    116 			$data['customers'][] = array(
    117 				'customer'       => $result['customer'],
    118 				'email'          => $result['email'],
    119 				'customer_group' => $result['customer_group'],
    120 				'status'         => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
    121 				'total'          => $this->currency->format($result['total'], $this->config->get('config_currency')),
    122 				'edit'           => $this->url->link('customer/customer/edit', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . $result['customer_id'], true)
    123 			);
    124 		}
    125 
    126 		$data['user_token'] = $this->session->data['user_token'];
    127 
    128 		$url = '';
    129 
    130 		if (isset($this->request->get['filter_date_start'])) {
    131 			$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
    132 		}
    133 
    134 		if (isset($this->request->get['filter_date_end'])) {
    135 			$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
    136 		}
    137 
    138 		if (isset($this->request->get['filter_customer'])) {
    139 			$url .= '&filter_customer=' . urlencode($this->request->get['filter_customer']);
    140 		}
    141 
    142 		$pagination = new Pagination();
    143 		$pagination->total = $customer_total;
    144 		$pagination->page = $page;
    145 		$pagination->limit = $this->config->get('config_limit_admin');
    146 		$pagination->url = $this->url->link('report/report', 'user_token=' . $this->session->data['user_token'] . '&code=customer_transaction' . $url . '&page={page}', true);
    147 
    148 		$data['pagination'] = $pagination->render();
    149 
    150 		$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')));
    151 
    152 		$data['filter_date_start'] = $filter_date_start;
    153 		$data['filter_date_end'] = $filter_date_end;
    154 		$data['filter_customer'] = $filter_customer;
    155 
    156 		return $this->load->view('extension/report/customer_transaction_info', $data);
    157 	}
    158 }