shop.balmet.com

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

reward.php (2942B)


      1 <?php
      2 class ControllerAccountReward extends Controller {
      3 	public function index() {
      4 		if (!$this->customer->isLogged()) {
      5 			$this->session->data['redirect'] = $this->url->link('account/reward', '', true);
      6 
      7 			$this->response->redirect($this->url->link('account/login', '', true));
      8 		}
      9 
     10 		$this->load->language('account/reward');
     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_reward'),
     28 			'href' => $this->url->link('account/reward', '', true)
     29 		);
     30 
     31 		$this->load->model('account/reward');
     32 
     33 		if (isset($this->request->get['page'])) {
     34 			$page = $this->request->get['page'];
     35 		} else {
     36 			$page = 1;
     37 		}
     38 
     39 		$data['rewards'] = array();
     40 
     41 		$filter_data = array(
     42 			'sort'  => 'date_added',
     43 			'order' => 'DESC',
     44 			'start' => ($page - 1) * 10,
     45 			'limit' => 10
     46 		);
     47 
     48 		$reward_total = $this->model_account_reward->getTotalRewards();
     49 
     50 		$results = $this->model_account_reward->getRewards($filter_data);
     51 
     52 		foreach ($results as $result) {
     53 			$data['rewards'][] = array(
     54 				'order_id'    => $result['order_id'],
     55 				'points'      => $result['points'],
     56 				'description' => $result['description'],
     57 				'date_added'  => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
     58 				'href'        => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], true)
     59 			);
     60 		}
     61 
     62 		$pagination = new Pagination();
     63 		$pagination->total = $reward_total;
     64 		$pagination->page = $page;
     65 		$pagination->limit = 10;
     66 		$pagination->url = $this->url->link('account/reward', 'page={page}', true);
     67 
     68 		$data['pagination'] = $pagination->render();
     69 
     70 		$data['results'] = sprintf($this->language->get('text_pagination'), ($reward_total) ? (($page - 1) * 10) + 1 : 0, ((($page - 1) * 10) > ($reward_total - 10)) ? $reward_total : ((($page - 1) * 10) + 10), $reward_total, ceil($reward_total / 10));
     71 
     72 		$data['total'] = (int)$this->customer->getRewardPoints();
     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/reward', $data));
     84 	}
     85 }