| 1: | <?php
|
| 2: | namespace Opencart\Catalog\Controller\Event;
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | class Statistics extends \Opencart\System\Engine\Controller {
|
| 9: |
|
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: |
|
| 19: | public function addReview(string &$route, array &$args, &$output): void {
|
| 20: | $this->load->model('report/statistics');
|
| 21: |
|
| 22: | $this->model_report_statistics->addValue('review', 1);
|
| 23: | }
|
| 24: |
|
| 25: |
|
| 26: |
|
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: |
|
| 36: | public function addReturn(string &$route, array &$args, &$output): void {
|
| 37: | $this->load->model('report/statistics');
|
| 38: |
|
| 39: | $this->model_report_statistics->addValue('returns', 1);
|
| 40: | }
|
| 41: |
|
| 42: |
|
| 43: |
|
| 44: | |
| 45: | |
| 46: | |
| 47: | |
| 48: | |
| 49: | |
| 50: | |
| 51: |
|
| 52: | public function addHistory(string &$route, array &$args): void {
|
| 53: | $this->load->model('checkout/order');
|
| 54: |
|
| 55: | $order_info = $this->model_checkout_order->getOrder($args[0]);
|
| 56: |
|
| 57: | if ($order_info) {
|
| 58: | $this->load->model('report/statistics');
|
| 59: |
|
| 60: | $old_status_id = $order_info['order_status_id'];
|
| 61: | $new_status_id = $args[1];
|
| 62: |
|
| 63: | $processing_status = (array)$this->config->get('config_processing_status');
|
| 64: | $complete_status = (array)$this->config->get('config_complete_status');
|
| 65: |
|
| 66: | $active_status = array_merge($processing_status, $complete_status);
|
| 67: |
|
| 68: |
|
| 69: | if (in_array($new_status_id, $active_status) && !in_array($old_status_id, $active_status)) {
|
| 70: | $this->model_report_statistics->addValue('order_sale', $order_info['total']);
|
| 71: | }
|
| 72: |
|
| 73: |
|
| 74: | if (!in_array($new_status_id, $active_status) && in_array($old_status_id, $active_status)) {
|
| 75: | $this->model_report_statistics->removeValue('order_sale', $order_info['total']);
|
| 76: | }
|
| 77: |
|
| 78: |
|
| 79: | if (in_array($new_status_id, $processing_status) && !in_array($old_status_id, $processing_status)) {
|
| 80: | $this->model_report_statistics->addValue('order_processing', 1);
|
| 81: | }
|
| 82: |
|
| 83: |
|
| 84: | if (!in_array($new_status_id, $processing_status) && in_array($old_status_id, $processing_status)) {
|
| 85: | $this->model_report_statistics->removeValue('order_processing', 1);
|
| 86: | }
|
| 87: |
|
| 88: |
|
| 89: | if (in_array($new_status_id, $complete_status) && !in_array($old_status_id, $complete_status)) {
|
| 90: | $this->model_report_statistics->addValue('order_complete', 1);
|
| 91: | }
|
| 92: |
|
| 93: |
|
| 94: | if (!in_array($new_status_id, $complete_status) && in_array($old_status_id, $complete_status)) {
|
| 95: | $this->model_report_statistics->removeValue('order_complete', 1);
|
| 96: | }
|
| 97: | }
|
| 98: | }
|
| 99: | }
|
| 100: | |