/admin/controller/report/sale_shipping.php

https://github.com/sansanwawa/e-commerse · PHP · 188 lines · 144 code · 44 blank · 0 comment · 19 complexity · 3fe183848bb41f53fd44de7855a7181f MD5 · raw file

  1. <?php
  2. class ControllerReportSaleShipping extends Controller {
  3. public function index() {
  4. $this->load->language('report/sale_shipping');
  5. $this->document->setTitle($this->language->get('heading_title'));
  6. if (isset($this->request->get['filter_date_start'])) {
  7. $filter_date_start = $this->request->get['filter_date_start'];
  8. } else {
  9. $filter_date_start = '';
  10. }
  11. if (isset($this->request->get['filter_date_end'])) {
  12. $filter_date_end = $this->request->get['filter_date_end'];
  13. } else {
  14. $filter_date_end = '';
  15. }
  16. if (isset($this->request->get['filter_group'])) {
  17. $filter_group = $this->request->get['filter_group'];
  18. } else {
  19. $filter_group = 'week';
  20. }
  21. if (isset($this->request->get['filter_order_status_id'])) {
  22. $filter_order_status_id = $this->request->get['filter_order_status_id'];
  23. } else {
  24. $filter_order_status_id = 0;
  25. }
  26. if (isset($this->request->get['page'])) {
  27. $page = $this->request->get['page'];
  28. } else {
  29. $page = 1;
  30. }
  31. $url = '';
  32. if (isset($this->request->get['filter_date_start'])) {
  33. $url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
  34. }
  35. if (isset($this->request->get['filter_date_end'])) {
  36. $url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
  37. }
  38. if (isset($this->request->get['filter_group'])) {
  39. $url .= '&filter_group=' . $this->request->get['filter_group'];
  40. }
  41. if (isset($this->request->get['filter_order_status_id'])) {
  42. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  43. }
  44. if (isset($this->request->get['page'])) {
  45. $url .= '&page=' . $this->request->get['page'];
  46. }
  47. $this->data['breadcrumbs'] = array();
  48. $this->data['breadcrumbs'][] = array(
  49. 'text' => $this->language->get('text_home'),
  50. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
  51. 'separator' => false
  52. );
  53. $this->data['breadcrumbs'][] = array(
  54. 'text' => $this->language->get('heading_title'),
  55. 'href' => $this->url->link('report/sale_shipping', 'token=' . $this->session->data['token'] . $url, 'SSL'),
  56. 'separator' => ' :: '
  57. );
  58. $this->load->model('report/sale');
  59. $this->data['orders'] = array();
  60. $data = array(
  61. 'filter_date_start' => $filter_date_start,
  62. 'filter_date_end' => $filter_date_end,
  63. 'filter_group' => $filter_group,
  64. 'filter_order_status_id' => $filter_order_status_id,
  65. 'start' => ($page - 1) * $this->config->get('config_admin_limit'),
  66. 'limit' => $this->config->get('config_admin_limit')
  67. );
  68. $order_total = $this->model_report_sale->getTotalShipping($data);
  69. $results = $this->model_report_sale->getShipping($data);
  70. foreach ($results as $result) {
  71. $this->data['orders'][] = array(
  72. 'date_start' => date($this->language->get('date_format_short'), strtotime($result['date_start'])),
  73. 'date_end' => date($this->language->get('date_format_short'), strtotime($result['date_end'])),
  74. 'title' => $result['title'],
  75. 'orders' => $result['orders'],
  76. 'total' => $this->currency->format($result['total'], $this->config->get('config_currency'))
  77. );
  78. }
  79. $this->data['heading_title'] = $this->language->get('heading_title');
  80. $this->data['text_no_results'] = $this->language->get('text_no_results');
  81. $this->data['text_all_status'] = $this->language->get('text_all_status');
  82. $this->data['column_date_start'] = $this->language->get('column_date_start');
  83. $this->data['column_date_end'] = $this->language->get('column_date_end');
  84. $this->data['column_title'] = $this->language->get('column_title');
  85. $this->data['column_orders'] = $this->language->get('column_orders');
  86. $this->data['column_total'] = $this->language->get('column_total');
  87. $this->data['entry_date_start'] = $this->language->get('entry_date_start');
  88. $this->data['entry_date_end'] = $this->language->get('entry_date_end');
  89. $this->data['entry_group'] = $this->language->get('entry_group');
  90. $this->data['entry_status'] = $this->language->get('entry_status');
  91. $this->data['button_filter'] = $this->language->get('button_filter');
  92. $this->data['token'] = $this->session->data['token'];
  93. $this->load->model('localisation/order_status');
  94. $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
  95. $this->data['groups'] = array();
  96. $this->data['groups'][] = array(
  97. 'text' => $this->language->get('text_year'),
  98. 'value' => 'year',
  99. );
  100. $this->data['groups'][] = array(
  101. 'text' => $this->language->get('text_month'),
  102. 'value' => 'month',
  103. );
  104. $this->data['groups'][] = array(
  105. 'text' => $this->language->get('text_week'),
  106. 'value' => 'week',
  107. );
  108. $this->data['groups'][] = array(
  109. 'text' => $this->language->get('text_day'),
  110. 'value' => 'day',
  111. );
  112. $url = '';
  113. if (isset($this->request->get['filter_date_start'])) {
  114. $url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
  115. }
  116. if (isset($this->request->get['filter_date_end'])) {
  117. $url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
  118. }
  119. if (isset($this->request->get['filter_group'])) {
  120. $url .= '&filter_group=' . $this->request->get['filter_group'];
  121. }
  122. if (isset($this->request->get['filter_order_status_id'])) {
  123. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  124. }
  125. $pagination = new Pagination();
  126. $pagination->total = $order_total;
  127. $pagination->page = $page;
  128. $pagination->limit = $this->config->get('config_admin_limit');
  129. $pagination->text = $this->language->get('text_pagination');
  130. $pagination->url = $this->url->link('report/sale_shipping', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
  131. $this->data['pagination'] = $pagination->render();
  132. $this->data['filter_date_start'] = $filter_date_start;
  133. $this->data['filter_date_end'] = $filter_date_end;
  134. $this->data['filter_group'] = $filter_group;
  135. $this->data['filter_order_status_id'] = $filter_order_status_id;
  136. $this->template = 'report/sale_shipping.tpl';
  137. $this->children = array(
  138. 'common/header',
  139. 'common/footer',
  140. );
  141. $this->response->setOutput($this->render());
  142. }
  143. }
  144. ?>