PageRenderTime 54ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/mall/upload/admin/controller/report/customer_online.php

https://bitbucket.org/allanxyh/uniquemall
PHP | 143 lines | 109 code | 34 blank | 0 comment | 14 complexity | a9d3176d2fc41c6cfcf4783e8759318c MD5 | raw file
  1. <?php
  2. class ControllerReportCustomerOnline extends Controller {
  3. public function index() {
  4. $this->language->load('report/customer_online');
  5. $this->document->setTitle($this->language->get('heading_title'));
  6. if (isset($this->request->get['filter_ip'])) {
  7. $filter_ip = $this->request->get['filter_ip'];
  8. } else {
  9. $filter_ip = NULL;
  10. }
  11. if (isset($this->request->get['filter_customer'])) {
  12. $filter_customer = $this->request->get['filter_customer'];
  13. } else {
  14. $filter_customer = NULL;
  15. }
  16. if (isset($this->request->get['page'])) {
  17. $page = $this->request->get['page'];
  18. } else {
  19. $page = 1;
  20. }
  21. $url = '';
  22. if (isset($this->request->get['filter_customer'])) {
  23. $url .= '&filter_customer=' . urlencode($this->request->get['filter_customer']);
  24. }
  25. if (isset($this->request->get['filter_ip'])) {
  26. $url .= '&filter_ip=' . $this->request->get['filter_ip'];
  27. }
  28. if (isset($this->request->get['page'])) {
  29. $url .= '&page=' . $this->request->get['page'];
  30. }
  31. $this->data['breadcrumbs'] = array();
  32. $this->data['breadcrumbs'][] = array(
  33. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
  34. 'text' => $this->language->get('text_home'),
  35. 'separator' => false
  36. );
  37. $this->data['breadcrumbs'][] = array(
  38. 'href' => $this->url->link('report/customer_online', 'token=' . $this->session->data['token'] . $url, 'SSL'),
  39. 'text' => $this->language->get('heading_title'),
  40. 'separator' => ' :: '
  41. );
  42. $this->load->model('report/online');
  43. $this->load->model('sale/customer');
  44. $this->data['customers'] = array();
  45. $data = array(
  46. 'filter_ip' => $filter_ip,
  47. 'filter_customer' => $filter_customer,
  48. 'start' => ($page - 1) * 20,
  49. 'limit' => 20
  50. );
  51. $customer_total = $this->model_report_online->getTotalCustomersOnline($data);
  52. $results = $this->model_report_online->getCustomersOnline($data);
  53. foreach ($results as $result) {
  54. $action = array();
  55. if ($result['customer_id']) {
  56. $action[] = array(
  57. 'text' => 'Edit',
  58. 'href' => $this->url->link('sale/customer/update', 'token=' . $this->session->data['token'] . '&customer_id=' . $result['customer_id'], 'SSL')
  59. );
  60. }
  61. $customer_info = $this->model_sale_customer->getCustomer($result['customer_id']);
  62. if ($customer_info) {
  63. $customer = $customer_info['firstname'] . ' ' . $customer_info['lastname'];
  64. } else {
  65. $customer = $this->language->get('text_guest');
  66. }
  67. $this->data['customers'][] = array(
  68. 'ip' => $result['ip'],
  69. 'customer' => $customer,
  70. 'url' => $result['url'],
  71. 'referer' => $result['referer'],
  72. 'date_added' => date('d/m/Y H:i:s', strtotime($result['date_added'])),
  73. 'action' => $action
  74. );
  75. }
  76. $this->data['heading_title'] = $this->language->get('heading_title');
  77. $this->data['text_no_results'] = $this->language->get('text_no_results');
  78. $this->data['column_ip'] = $this->language->get('column_ip');
  79. $this->data['column_customer'] = $this->language->get('column_customer');
  80. $this->data['column_url'] = $this->language->get('column_url');
  81. $this->data['column_referer'] = $this->language->get('column_referer');
  82. $this->data['column_date_added'] = $this->language->get('column_date_added');
  83. $this->data['column_action'] = $this->language->get('column_action');
  84. $this->data['button_filter'] = $this->language->get('button_filter');
  85. $this->data['token'] = $this->session->data['token'];
  86. $url = '';
  87. if (isset($this->request->get['filter_customer'])) {
  88. $url .= '&filter_customer=' . urlencode($this->request->get['filter_customer']);
  89. }
  90. if (isset($this->request->get['filter_ip'])) {
  91. $url .= '&filter_ip=' . $this->request->get['filter_ip'];
  92. }
  93. $pagination = new Pagination();
  94. $pagination->total = $customer_total;
  95. $pagination->page = $page;
  96. $pagination->limit = 20;
  97. $pagination->url = $this->url->link('report/customer_online', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
  98. $this->data['pagination'] = $pagination->render();
  99. $this->data['filter_customer'] = $filter_customer;
  100. $this->data['filter_ip'] = $filter_ip;
  101. $this->template = 'report/customer_online.tpl';
  102. $this->children = array(
  103. 'common/header',
  104. 'common/footer'
  105. );
  106. $this->response->setOutput($this->render());
  107. }
  108. }
  109. ?>