| 1: | <?php
|
| 2: | namespace Opencart\Admin\Controller\Extension\Opencart\Dashboard;
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | class Recent extends \Opencart\System\Engine\Controller {
|
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: |
|
| 14: | public function index(): void {
|
| 15: | $this->load->language('extension/opencart/dashboard/recent');
|
| 16: |
|
| 17: | $this->document->setTitle($this->language->get('heading_title'));
|
| 18: |
|
| 19: | $data['breadcrumbs'] = [];
|
| 20: |
|
| 21: | $data['breadcrumbs'][] = [
|
| 22: | 'text' => $this->language->get('text_home'),
|
| 23: | 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
| 24: | ];
|
| 25: |
|
| 26: | $data['breadcrumbs'][] = [
|
| 27: | 'text' => $this->language->get('text_extension'),
|
| 28: | 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard')
|
| 29: | ];
|
| 30: |
|
| 31: | $data['breadcrumbs'][] = [
|
| 32: | 'text' => $this->language->get('heading_title'),
|
| 33: | 'href' => $this->url->link('extension/opencart/dashboard/recent', 'user_token=' . $this->session->data['user_token'])
|
| 34: | ];
|
| 35: |
|
| 36: | $data['save'] = $this->url->link('extension/opencart/dashboard/recent.save', 'user_token=' . $this->session->data['user_token']);
|
| 37: | $data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard');
|
| 38: |
|
| 39: | $data['dashboard_recent_width'] = $this->config->get('dashboard_recent_width');
|
| 40: |
|
| 41: | $data['columns'] = [];
|
| 42: |
|
| 43: | for ($i = 3; $i <= 12; $i++) {
|
| 44: | $data['columns'][] = $i;
|
| 45: | }
|
| 46: |
|
| 47: | $data['dashboard_recent_status'] = $this->config->get('dashboard_recent_status');
|
| 48: | $data['dashboard_recent_sort_order'] = $this->config->get('dashboard_recent_sort_order');
|
| 49: |
|
| 50: | $data['header'] = $this->load->controller('common/header');
|
| 51: | $data['column_left'] = $this->load->controller('common/column_left');
|
| 52: | $data['footer'] = $this->load->controller('common/footer');
|
| 53: |
|
| 54: | $this->response->setOutput($this->load->view('extension/opencart/dashboard/recent_form', $data));
|
| 55: | }
|
| 56: |
|
| 57: | |
| 58: | |
| 59: | |
| 60: | |
| 61: |
|
| 62: | public function save(): void {
|
| 63: | $this->load->language('extension/opencart/dashboard/recent');
|
| 64: |
|
| 65: | $json = [];
|
| 66: |
|
| 67: | if (!$this->user->hasPermission('modify', 'extension/opencart/dashboard/recent')) {
|
| 68: | $json['error'] = $this->language->get('error_permission');
|
| 69: | }
|
| 70: |
|
| 71: | if (!$json) {
|
| 72: | $this->load->model('setting/setting');
|
| 73: |
|
| 74: | $this->model_setting_setting->editSetting('dashboard_recent', $this->request->post);
|
| 75: |
|
| 76: | $json['success'] = $this->language->get('text_success');
|
| 77: | }
|
| 78: |
|
| 79: | $this->response->addHeader('Content-Type: application/json');
|
| 80: | $this->response->setOutput(json_encode($json));
|
| 81: | }
|
| 82: |
|
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: |
|
| 88: | public function dashboard(): string {
|
| 89: | $this->load->language('extension/opencart/dashboard/recent');
|
| 90: |
|
| 91: |
|
| 92: | $data['orders'] = [];
|
| 93: |
|
| 94: | $filter_data = [
|
| 95: | 'sort' => 'o.date_added',
|
| 96: | 'order' => 'DESC',
|
| 97: | 'start' => 0,
|
| 98: | 'limit' => 5
|
| 99: | ];
|
| 100: |
|
| 101: | $this->load->model('sale/order');
|
| 102: |
|
| 103: | $results = $this->model_sale_order->getOrders($filter_data);
|
| 104: |
|
| 105: | foreach ($results as $result) {
|
| 106: | $data['orders'][] = [
|
| 107: | 'order_id' => $result['order_id'],
|
| 108: | 'customer' => $result['customer'],
|
| 109: | 'status' => $result['order_status'],
|
| 110: | 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
|
| 111: | 'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
|
| 112: | 'view' => $this->url->link('sale/order.info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $result['order_id'])
|
| 113: | ];
|
| 114: | }
|
| 115: |
|
| 116: | $data['user_token'] = $this->session->data['user_token'];
|
| 117: |
|
| 118: | return $this->load->view('extension/opencart/dashboard/recent_info', $data);
|
| 119: | }
|
| 120: | }
|
| 121: | |