tracking.php (2866B)
1 <?php 2 class ControllerAccountTracking extends Controller { 3 public function index() { 4 if (!$this->customer->isLogged()) { 5 $this->session->data['redirect'] = $this->url->link('account/tracking', '', true); 6 7 $this->response->redirect($this->url->link('account/login', '', true)); 8 } 9 10 $this->load->model('account/customer'); 11 12 $affiliate_info = $this->model_account_customer->getAffiliate($this->customer->getId()); 13 14 if ($affiliate_info) { 15 $this->load->language('account/tracking'); 16 17 $this->document->setTitle($this->language->get('heading_title')); 18 19 $data['breadcrumbs'] = array(); 20 21 $data['breadcrumbs'][] = array( 22 'text' => $this->language->get('text_home'), 23 'href' => $this->url->link('common/home') 24 ); 25 26 $data['breadcrumbs'][] = array( 27 'text' => $this->language->get('text_account'), 28 'href' => $this->url->link('account/account', '', true) 29 ); 30 31 $data['breadcrumbs'][] = array( 32 'text' => $this->language->get('heading_title'), 33 'href' => $this->url->link('account/tracking', '', true) 34 ); 35 36 $data['text_description'] = sprintf($this->language->get('text_description'), $this->config->get('config_name')); 37 38 $data['code'] = $affiliate_info['tracking']; 39 40 $data['continue'] = $this->url->link('account/account', '', true); 41 42 $data['column_left'] = $this->load->controller('common/column_left'); 43 $data['column_right'] = $this->load->controller('common/column_right'); 44 $data['content_top'] = $this->load->controller('common/content_top'); 45 $data['content_bottom'] = $this->load->controller('common/content_bottom'); 46 $data['footer'] = $this->load->controller('common/footer'); 47 $data['header'] = $this->load->controller('common/header'); 48 49 $this->response->setOutput($this->load->view('account/tracking', $data)); 50 } else { 51 return new Action('error/not_found'); 52 } 53 } 54 55 public function autocomplete() { 56 $json = array(); 57 58 if (isset($this->request->get['filter_name'])) { 59 if (isset($this->request->get['tracking'])) { 60 $tracking = $this->request->get['tracking']; 61 } else { 62 $tracking = ''; 63 } 64 65 $this->load->model('catalog/product'); 66 67 $filter_data = array( 68 'filter_name' => $this->request->get['filter_name'], 69 'start' => 0, 70 'limit' => 5 71 ); 72 73 $results = $this->model_catalog_product->getProducts($filter_data); 74 75 foreach ($results as $result) { 76 $json[] = array( 77 'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')), 78 'link' => str_replace('&', '&', $this->url->link('product/product', 'product_id=' . $result['product_id'] . '&tracking=' . $tracking)) 79 ); 80 } 81 } 82 83 $this->response->addHeader('Content-Type: application/json'); 84 $this->response->setOutput(json_encode($json)); 85 } 86 }