/upload/admin/controller/report/sale_order.php

https://bitbucket.org/elena_dyavolova/omf · PHP · 190 lines · 146 code · 44 blank · 0 comment · 19 complexity · 73e6edef4c7f15a877577c8c251a37f4 MD5 · raw file

  1. <?php
  2. class ControllerReportSaleOrder extends Controller {
  3. public function index() {
  4. $this->language->load('report/sale_order');
  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 = date('Y-m-d', strtotime(date('Y') . '-' . date('m') . '-01'));
  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 = date('Y-m-d');
  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_order', '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->getTotalOrders($data);
  69. $results = $this->model_report_sale->getOrders($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. 'orders' => $result['orders'],
  75. 'products' => $result['products'],
  76. 'tax' => $this->currency->format($result['tax'], $this->config->get('config_currency')),
  77. 'total' => $this->currency->format($result['total'], $this->config->get('config_currency'))
  78. );
  79. }
  80. $this->data['heading_title'] = $this->language->get('heading_title');
  81. $this->data['text_no_results'] = $this->language->get('text_no_results');
  82. $this->data['text_all_status'] = $this->language->get('text_all_status');
  83. $this->data['column_date_start'] = $this->language->get('column_date_start');
  84. $this->data['column_date_end'] = $this->language->get('column_date_end');
  85. $this->data['column_orders'] = $this->language->get('column_orders');
  86. $this->data['column_products'] = $this->language->get('column_products');
  87. $this->data['column_tax'] = $this->language->get('column_tax');
  88. $this->data['column_total'] = $this->language->get('column_total');
  89. $this->data['entry_date_start'] = $this->language->get('entry_date_start');
  90. $this->data['entry_date_end'] = $this->language->get('entry_date_end');
  91. $this->data['entry_group'] = $this->language->get('entry_group');
  92. $this->data['entry_status'] = $this->language->get('entry_status');
  93. $this->data['button_filter'] = $this->language->get('button_filter');
  94. $this->data['token'] = $this->session->data['token'];
  95. $this->load->model('localisation/order_status');
  96. $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
  97. $this->data['groups'] = array();
  98. $this->data['groups'][] = array(
  99. 'text' => $this->language->get('text_year'),
  100. 'value' => 'year',
  101. );
  102. $this->data['groups'][] = array(
  103. 'text' => $this->language->get('text_month'),
  104. 'value' => 'month',
  105. );
  106. $this->data['groups'][] = array(
  107. 'text' => $this->language->get('text_week'),
  108. 'value' => 'week',
  109. );
  110. $this->data['groups'][] = array(
  111. 'text' => $this->language->get('text_day'),
  112. 'value' => 'day',
  113. );
  114. $url = '';
  115. if (isset($this->request->get['filter_date_start'])) {
  116. $url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
  117. }
  118. if (isset($this->request->get['filter_date_end'])) {
  119. $url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
  120. }
  121. if (isset($this->request->get['filter_group'])) {
  122. $url .= '&filter_group=' . $this->request->get['filter_group'];
  123. }
  124. if (isset($this->request->get['filter_order_status_id'])) {
  125. $url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
  126. }
  127. $pagination = new Pagination();
  128. $pagination->total = $order_total;
  129. $pagination->page = $page;
  130. $pagination->limit = $this->config->get('config_admin_limit');
  131. $pagination->text = $this->language->get('text_pagination');
  132. $pagination->url = $this->url->link('report/sale_order', 'token=' . $this->session->data['token'] . $url . '&page={page}', 'SSL');
  133. $this->data['pagination'] = $pagination->render();
  134. $this->data['filter_date_start'] = $filter_date_start;
  135. $this->data['filter_date_end'] = $filter_date_end;
  136. $this->data['filter_group'] = $filter_group;
  137. $this->data['filter_order_status_id'] = $filter_order_status_id;
  138. $this->template = 'report/sale_order.tpl';
  139. $this->children = array(
  140. 'common/header',
  141. 'common/footer'
  142. );
  143. $this->response->setOutput($this->render());
  144. }
  145. }
  146. ?>