shop.balmet.com

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

transaction.php (3133B)


      1 <?php
      2 class ControllerAccountTransaction extends Controller {
      3 	public function index() {
      4 		if (!$this->customer->isLogged()) {
      5 			$this->session->data['redirect'] = $this->url->link('account/transaction', '', true);
      6 
      7 			$this->response->redirect($this->url->link('account/login', '', true));
      8 		}
      9 
     10 		$this->load->language('account/transaction');
     11 
     12 		$this->document->setTitle($this->language->get('heading_title'));
     13 
     14 		$data['breadcrumbs'] = array();
     15 
     16 		$data['breadcrumbs'][] = array(
     17 			'text' => $this->language->get('text_home'),
     18 			'href' => $this->url->link('common/home')
     19 		);
     20 
     21 		$data['breadcrumbs'][] = array(
     22 			'text' => $this->language->get('text_account'),
     23 			'href' => $this->url->link('account/account', '', true)
     24 		);
     25 
     26 		$data['breadcrumbs'][] = array(
     27 			'text' => $this->language->get('text_transaction'),
     28 			'href' => $this->url->link('account/transaction', '', true)
     29 		);
     30 
     31 		$this->load->model('account/transaction');
     32 		
     33 		$data['column_amount'] = sprintf($this->language->get('column_amount'), $this->config->get('config_currency'));
     34 
     35 		if (isset($this->request->get['page'])) {
     36 			$page = $this->request->get['page'];
     37 		} else {
     38 			$page = 1;
     39 		}
     40 
     41 		$data['transactions'] = array();
     42 
     43 		$filter_data = array(
     44 			'sort'  => 'date_added',
     45 			'order' => 'DESC',
     46 			'start' => ($page - 1) * 10,
     47 			'limit' => 10
     48 		);
     49 
     50 		$transaction_total = $this->model_account_transaction->getTotalTransactions();
     51 
     52 		$results = $this->model_account_transaction->getTransactions($filter_data);
     53 
     54 		foreach ($results as $result) {
     55 			$data['transactions'][] = array(
     56 				'amount'      => $this->currency->format($result['amount'], $this->config->get('config_currency')),
     57 				'description' => $result['description'],
     58 				'date_added'  => date($this->language->get('date_format_short'), strtotime($result['date_added']))
     59 			);
     60 		}
     61 
     62 		$pagination = new Pagination();
     63 		$pagination->total = $transaction_total;
     64 		$pagination->page = $page;
     65 		$pagination->limit = 10;
     66 		$pagination->url = $this->url->link('account/transaction', 'page={page}', true);
     67 
     68 		$data['pagination'] = $pagination->render();
     69 
     70 		$data['results'] = sprintf($this->language->get('text_pagination'), ($transaction_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($transaction_total - 10)) ? $transaction_total : ((($page - 1) * 10) + 10), $transaction_total, ceil($transaction_total / 10));
     71 
     72 		$data['total'] = $this->currency->format($this->customer->getBalance(), $this->session->data['currency']);
     73 
     74 		$data['continue'] = $this->url->link('account/account', '', true);
     75 
     76 		$data['column_left'] = $this->load->controller('common/column_left');
     77 		$data['column_right'] = $this->load->controller('common/column_right');
     78 		$data['content_top'] = $this->load->controller('common/content_top');
     79 		$data['content_bottom'] = $this->load->controller('common/content_bottom');
     80 		$data['footer'] = $this->load->controller('common/footer');
     81 		$data['header'] = $this->load->controller('common/header');
     82 
     83 		$this->response->setOutput($this->load->view('account/transaction', $data));
     84 	}
     85 }