aboutsummaryrefslogtreecommitdiffstats
path: root/public/admin/controller/extension/dashboard
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2019-08-18 21:14:58 -0500
committerJesús <heckyel@hyperbola.info>2019-08-18 21:14:58 -0500
commit2eed7b082f83630301e51f57ca8394de228a8605 (patch)
tree1d19962d22d30f99317d9276e4bae7744fc93fc2 /public/admin/controller/extension/dashboard
downloadlibrecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.lz
librecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.xz
librecart-2eed7b082f83630301e51f57ca8394de228a8605.zip
first commit
Diffstat (limited to 'public/admin/controller/extension/dashboard')
-rw-r--r--public/admin/controller/extension/dashboard/activity.php120
-rw-r--r--public/admin/controller/extension/dashboard/chart.php197
-rw-r--r--public/admin/controller/extension/dashboard/customer.php124
-rw-r--r--public/admin/controller/extension/dashboard/map.php111
-rw-r--r--public/admin/controller/extension/dashboard/online.php113
-rw-r--r--public/admin/controller/extension/dashboard/order.php124
-rw-r--r--public/admin/controller/extension/dashboard/recent.php118
-rw-r--r--public/admin/controller/extension/dashboard/sale.php123
8 files changed, 1030 insertions, 0 deletions
diff --git a/public/admin/controller/extension/dashboard/activity.php b/public/admin/controller/extension/dashboard/activity.php
new file mode 100644
index 0000000..68d71fe
--- /dev/null
+++ b/public/admin/controller/extension/dashboard/activity.php
@@ -0,0 +1,120 @@
+<?php
+class ControllerExtensionDashboardActivity extends Controller {
+ private $error = array();
+
+ public function index() {
+ $this->load->language('extension/dashboard/activity');
+
+ $this->document->setTitle($this->language->get('heading_title'));
+
+ $this->load->model('setting/setting');
+
+ if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
+ $this->model_setting_setting->editSetting('dashboard_activity', $this->request->post);
+
+ $this->session->data['success'] = $this->language->get('text_success');
+
+ $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true));
+ }
+
+ if (isset($this->error['warning'])) {
+ $data['error_warning'] = $this->error['warning'];
+ } else {
+ $data['error_warning'] = '';
+ }
+
+ $data['breadcrumbs'] = array();
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_home'),
+ 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_extension'),
+ 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('heading_title'),
+ 'href' => $this->url->link('extension/dashboard/activity', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['action'] = $this->url->link('extension/dashboard/activity', 'user_token=' . $this->session->data['user_token'], true);
+
+ $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true);
+
+ if (isset($this->request->post['dashboard_activity_width'])) {
+ $data['dashboard_activity_width'] = $this->request->post['dashboard_activity_width'];
+ } else {
+ $data['dashboard_activity_width'] = $this->config->get('dashboard_activity_width');
+ }
+
+ $data['columns'] = array();
+
+ for ($i = 3; $i <= 12; $i++) {
+ $data['columns'][] = $i;
+ }
+
+ if (isset($this->request->post['dashboard_activity_status'])) {
+ $data['dashboard_activity_status'] = $this->request->post['dashboard_activity_status'];
+ } else {
+ $data['dashboard_activity_status'] = $this->config->get('dashboard_activity_status');
+ }
+
+ if (isset($this->request->post['dashboard_activity_sort_order'])) {
+ $data['dashboard_activity_sort_order'] = $this->request->post['dashboard_activity_sort_order'];
+ } else {
+ $data['dashboard_activity_sort_order'] = $this->config->get('dashboard_activity_sort_order');
+ }
+
+ $data['header'] = $this->load->controller('common/header');
+ $data['column_left'] = $this->load->controller('common/column_left');
+ $data['footer'] = $this->load->controller('common/footer');
+
+ $this->response->setOutput($this->load->view('extension/dashboard/activity_form', $data));
+ }
+
+ protected function validate() {
+ if (!$this->user->hasPermission('modify', 'extension/dashboard/activity')) {
+ $this->error['warning'] = $this->language->get('error_permission');
+ }
+
+ return !$this->error;
+ }
+
+ public function dashboard() {
+ $this->load->language('extension/dashboard/activity');
+
+ $data['user_token'] = $this->session->data['user_token'];
+
+ $data['activities'] = array();
+
+ $this->load->model('extension/dashboard/activity');
+
+ $results = $this->model_extension_dashboard_activity->getActivities();
+
+ foreach ($results as $result) {
+ $comment = vsprintf($this->language->get('text_activity_' . $result['key']), json_decode($result['data'], true));
+
+ $find = array(
+ 'customer_id=',
+ 'order_id=',
+ 'return_id='
+ );
+
+ $replace = array(
+ $this->url->link('customer/customer/edit', 'user_token=' . $this->session->data['user_token'] . '&customer_id=', true),
+ $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=', true),
+ $this->url->link('sale/return/edit', 'user_token=' . $this->session->data['user_token'] . '&return_id=', true)
+ );
+
+ $data['activities'][] = array(
+ 'comment' => str_replace($find, $replace, $comment),
+ 'date_added' => date($this->language->get('datetime_format'), strtotime($result['date_added']))
+ );
+ }
+
+ return $this->load->view('extension/dashboard/activity_info', $data);
+ }
+} \ No newline at end of file
diff --git a/public/admin/controller/extension/dashboard/chart.php b/public/admin/controller/extension/dashboard/chart.php
new file mode 100644
index 0000000..f361a09
--- /dev/null
+++ b/public/admin/controller/extension/dashboard/chart.php
@@ -0,0 +1,197 @@
+<?php
+class ControllerExtensionDashboardChart extends Controller {
+ private $error = array();
+
+ public function index() {
+ $this->load->language('extension/dashboard/chart');
+
+ $this->document->setTitle($this->language->get('heading_title'));
+
+ $this->load->model('setting/setting');
+
+ if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
+ $this->model_setting_setting->editSetting('dashboard_chart', $this->request->post);
+
+ $this->session->data['success'] = $this->language->get('text_success');
+
+ $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true));
+ }
+
+ if (isset($this->error['warning'])) {
+ $data['error_warning'] = $this->error['warning'];
+ } else {
+ $data['error_warning'] = '';
+ }
+
+ $data['breadcrumbs'] = array();
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_home'),
+ 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_extension'),
+ 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('heading_title'),
+ 'href' => $this->url->link('extension/dashboard/chart', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['action'] = $this->url->link('extension/dashboard/chart', 'user_token=' . $this->session->data['user_token'], true);
+
+ $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true);
+
+ if (isset($this->request->post['dashboard_chart_width'])) {
+ $data['dashboard_chart_width'] = $this->request->post['dashboard_chart_width'];
+ } else {
+ $data['dashboard_chart_width'] = $this->config->get('dashboardchart_width');
+ }
+
+ $data['columns'] = array();
+
+ for ($i = 3; $i <= 12; $i++) {
+ $data['columns'][] = $i;
+ }
+
+ if (isset($this->request->post['dashboard_chart_status'])) {
+ $data['dashboard_chart_status'] = $this->request->post['dashboard_chart_status'];
+ } else {
+ $data['dashboard_chart_status'] = $this->config->get('dashboard_chart_status');
+ }
+
+ if (isset($this->request->post['dashboard_chart_sort_order'])) {
+ $data['dashboard_chart_sort_order'] = $this->request->post['dashboard_chart_sort_order'];
+ } else {
+ $data['dashboard_chart_sort_order'] = $this->config->get('dashboard_chart_sort_order');
+ }
+
+ $data['header'] = $this->load->controller('common/header');
+ $data['column_left'] = $this->load->controller('common/column_left');
+ $data['footer'] = $this->load->controller('common/footer');
+
+ $this->response->setOutput($this->load->view('extension/dashboard/chart_form', $data));
+ }
+
+ protected function validate() {
+ if (!$this->user->hasPermission('modify', 'extension/dashboard/chart')) {
+ $this->error['warning'] = $this->language->get('error_permission');
+ }
+
+ return !$this->error;
+ }
+
+ public function dashboard() {
+ $this->load->language('extension/dashboard/chart');
+
+ $data['user_token'] = $this->session->data['user_token'];
+
+ return $this->load->view('extension/dashboard/chart_info', $data);
+ }
+
+ public function chart() {
+ $this->load->language('extension/dashboard/chart');
+
+ $json = array();
+
+ $this->load->model('extension/dashboard/chart');
+
+ $json['order'] = array();
+ $json['customer'] = array();
+ $json['xaxis'] = array();
+
+ $json['order']['label'] = $this->language->get('text_order');
+ $json['customer']['label'] = $this->language->get('text_customer');
+ $json['order']['data'] = array();
+ $json['customer']['data'] = array();
+
+ if (isset($this->request->get['range'])) {
+ $range = $this->request->get['range'];
+ } else {
+ $range = 'day';
+ }
+
+ switch ($range) {
+ default:
+ case 'day':
+ $results = $this->model_extension_dashboard_chart->getTotalOrdersByDay();
+
+ foreach ($results as $key => $value) {
+ $json['order']['data'][] = array($key, $value['total']);
+ }
+
+ $results = $this->model_extension_dashboard_chart->getTotalCustomersByDay();
+
+ foreach ($results as $key => $value) {
+ $json['customer']['data'][] = array($key, $value['total']);
+ }
+
+ for ($i = 0; $i < 24; $i++) {
+ $json['xaxis'][] = array($i, $i);
+ }
+ break;
+ case 'week':
+ $results = $this->model_extension_dashboard_chart->getTotalOrdersByWeek();
+
+ foreach ($results as $key => $value) {
+ $json['order']['data'][] = array($key, $value['total']);
+ }
+
+ $results = $this->model_extension_dashboard_chart->getTotalCustomersByWeek();
+
+ foreach ($results as $key => $value) {
+ $json['customer']['data'][] = array($key, $value['total']);
+ }
+
+ $date_start = strtotime('-' . date('w') . ' days');
+
+ for ($i = 0; $i < 7; $i++) {
+ $date = date('Y-m-d', $date_start + ($i * 86400));
+
+ $json['xaxis'][] = array(date('w', strtotime($date)), date('D', strtotime($date)));
+ }
+ break;
+ case 'month':
+ $results = $this->model_extension_dashboard_chart->getTotalOrdersByMonth();
+
+ foreach ($results as $key => $value) {
+ $json['order']['data'][] = array($key, $value['total']);
+ }
+
+ $results = $this->model_extension_dashboard_chart->getTotalCustomersByMonth();
+
+ foreach ($results as $key => $value) {
+ $json['customer']['data'][] = array($key, $value['total']);
+ }
+
+ for ($i = 1; $i <= date('t'); $i++) {
+ $date = date('Y') . '-' . date('m') . '-' . $i;
+
+ $json['xaxis'][] = array(date('j', strtotime($date)), date('d', strtotime($date)));
+ }
+ break;
+ case 'year':
+ $results = $this->model_extension_dashboard_chart->getTotalOrdersByYear();
+
+ foreach ($results as $key => $value) {
+ $json['order']['data'][] = array($key, $value['total']);
+ }
+
+ $results = $this->model_extension_dashboard_chart->getTotalCustomersByYear();
+
+ foreach ($results as $key => $value) {
+ $json['customer']['data'][] = array($key, $value['total']);
+ }
+
+ for ($i = 1; $i <= 12; $i++) {
+ $json['xaxis'][] = array($i, date('M', mktime(0, 0, 0, $i)));
+ }
+ break;
+ }
+
+ $this->response->addHeader('Content-Type: application/json');
+ $this->response->setOutput(json_encode($json));
+ }
+} \ No newline at end of file
diff --git a/public/admin/controller/extension/dashboard/customer.php b/public/admin/controller/extension/dashboard/customer.php
new file mode 100644
index 0000000..e5054d3
--- /dev/null
+++ b/public/admin/controller/extension/dashboard/customer.php
@@ -0,0 +1,124 @@
+<?php
+class ControllerExtensionDashboardCustomer extends Controller {
+ private $error = array();
+
+ public function index() {
+ $this->load->language('extension/dashboard/customer');
+
+ $this->document->setTitle($this->language->get('heading_title'));
+
+ $this->load->model('setting/setting');
+
+ if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
+ $this->model_setting_setting->editSetting('dashboard_customer', $this->request->post);
+
+ $this->session->data['success'] = $this->language->get('text_success');
+
+ $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true));
+ }
+
+ if (isset($this->error['warning'])) {
+ $data['error_warning'] = $this->error['warning'];
+ } else {
+ $data['error_warning'] = '';
+ }
+
+ $data['breadcrumbs'] = array();
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_home'),
+ 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_extension'),
+ 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('heading_title'),
+ 'href' => $this->url->link('extension/dashboard/customer', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['action'] = $this->url->link('extension/dashboard/customer', 'user_token=' . $this->session->data['user_token'], true);
+
+ $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true);
+
+ if (isset($this->request->post['dashboard_customer_width'])) {
+ $data['dashboard_customer_width'] = $this->request->post['dashboard_customer_width'];
+ } else {
+ $data['dashboard_customer_width'] = $this->config->get('dashboard_customer_width');
+ }
+
+ $data['columns'] = array();
+
+ for ($i = 3; $i <= 12; $i++) {
+ $data['columns'][] = $i;
+ }
+
+ if (isset($this->request->post['dashboard_customer_status'])) {
+ $data['dashboard_customer_status'] = $this->request->post['dashboard_customer_status'];
+ } else {
+ $data['dashboard_customer_status'] = $this->config->get('dashboard_customer_status');
+ }
+
+ if (isset($this->request->post['dashboard_customer_sort_order'])) {
+ $data['dashboard_customer_sort_order'] = $this->request->post['dashboard_customer_sort_order'];
+ } else {
+ $data['dashboard_customer_sort_order'] = $this->config->get('dashboard_customer_sort_order');
+ }
+
+ $data['header'] = $this->load->controller('common/header');
+ $data['column_left'] = $this->load->controller('common/column_left');
+ $data['footer'] = $this->load->controller('common/footer');
+
+ $this->response->setOutput($this->load->view('extension/dashboard/customer_form', $data));
+ }
+
+ protected function validate() {
+ if (!$this->user->hasPermission('modify', 'extension/dashboard/customer')) {
+ $this->error['warning'] = $this->language->get('error_permission');
+ }
+
+ return !$this->error;
+ }
+
+ public function dashboard() {
+ $this->load->language('extension/dashboard/customer');
+
+ $data['user_token'] = $this->session->data['user_token'];
+
+ // Total Orders
+ $this->load->model('customer/customer');
+
+ $today = $this->model_customer_customer->getTotalCustomers(array('filter_date_added' => date('Y-m-d', strtotime('-1 day'))));
+
+ $yesterday = $this->model_customer_customer->getTotalCustomers(array('filter_date_added' => date('Y-m-d', strtotime('-2 day'))));
+
+ $difference = $today - $yesterday;
+
+ if ($difference && $today) {
+ $data['percentage'] = round(($difference / $today) * 100);
+ } else {
+ $data['percentage'] = 0;
+ }
+
+ $customer_total = $this->model_customer_customer->getTotalCustomers();
+
+ if ($customer_total > 1000000000000) {
+ $data['total'] = round($customer_total / 1000000000000, 1) . 'T';
+ } elseif ($customer_total > 1000000000) {
+ $data['total'] = round($customer_total / 1000000000, 1) . 'B';
+ } elseif ($customer_total > 1000000) {
+ $data['total'] = round($customer_total / 1000000, 1) . 'M';
+ } elseif ($customer_total > 1000) {
+ $data['total'] = round($customer_total / 1000, 1) . 'K';
+ } else {
+ $data['total'] = $customer_total;
+ }
+
+ $data['customer'] = $this->url->link('customer/customer', 'user_token=' . $this->session->data['user_token'], true);
+
+ return $this->load->view('extension/dashboard/customer_info', $data);
+ }
+}
diff --git a/public/admin/controller/extension/dashboard/map.php b/public/admin/controller/extension/dashboard/map.php
new file mode 100644
index 0000000..0e19331
--- /dev/null
+++ b/public/admin/controller/extension/dashboard/map.php
@@ -0,0 +1,111 @@
+<?php
+class ControllerExtensionDashboardMap extends Controller {
+ private $error = array();
+
+ public function index() {
+ $this->load->language('extension/dashboard/map');
+
+ $this->document->setTitle($this->language->get('heading_title'));
+
+ $this->load->model('setting/setting');
+
+ if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
+ $this->model_setting_setting->editSetting('dashboard_map', $this->request->post);
+
+ $this->session->data['success'] = $this->language->get('text_success');
+
+ $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true));
+ }
+
+ if (isset($this->error['warning'])) {
+ $data['error_warning'] = $this->error['warning'];
+ } else {
+ $data['error_warning'] = '';
+ }
+
+ $data['breadcrumbs'] = array();
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_home'),
+ 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_extension'),
+ 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('heading_title'),
+ 'href' => $this->url->link('extension/dashboard/map', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['action'] = $this->url->link('extension/dashboard/map', 'user_token=' . $this->session->data['user_token'], true);
+
+ $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true);
+
+ if (isset($this->request->post['dashboard_map_width'])) {
+ $data['dashboard_map_width'] = $this->request->post['dashboard_map_width'];
+ } else {
+ $data['dashboard_map_width'] = $this->config->get('dashboard_map_width');
+ }
+
+ $data['columns'] = array();
+
+ for ($i = 3; $i <= 12; $i++) {
+ $data['columns'][] = $i;
+ }
+
+ if (isset($this->request->post['dashboard_map_status'])) {
+ $data['dashboard_map_status'] = $this->request->post['dashboard_map_status'];
+ } else {
+ $data['dashboard_map_status'] = $this->config->get('dashboard_map_status');
+ }
+
+ if (isset($this->request->post['dashboard_map_sort_order'])) {
+ $data['dashboard_map_sort_order'] = $this->request->post['dashboard_map_sort_order'];
+ } else {
+ $data['dashboard_map_sort_order'] = $this->config->get('dashboard_map_sort_order');
+ }
+
+ $data['header'] = $this->load->controller('common/header');
+ $data['column_left'] = $this->load->controller('common/column_left');
+ $data['footer'] = $this->load->controller('common/footer');
+
+ $this->response->setOutput($this->load->view('extension/dashboard/map_form', $data));
+ }
+
+ protected function validate() {
+ if (!$this->user->hasPermission('modify', 'extension/dashboard/map')) {
+ $this->error['warning'] = $this->language->get('error_permission');
+ }
+
+ return !$this->error;
+ }
+
+ public function dashboard() {
+ $this->load->language('extension/dashboard/map');
+
+ $data['user_token'] = $this->session->data['user_token'];
+
+ return $this->load->view('extension/dashboard/map_info', $data);
+ }
+
+ public function map() {
+ $json = array();
+
+ $this->load->model('extension/dashboard/map');
+
+ $results = $this->model_extension_dashboard_map->getTotalOrdersByCountry();
+
+ foreach ($results as $result) {
+ $json[strtolower($result['iso_code_2'])] = array(
+ 'total' => $result['total'],
+ 'amount' => $this->currency->format($result['amount'], $this->config->get('config_currency'))
+ );
+ }
+
+ $this->response->addHeader('Content-Type: application/json');
+ $this->response->setOutput(json_encode($json));
+ }
+}
diff --git a/public/admin/controller/extension/dashboard/online.php b/public/admin/controller/extension/dashboard/online.php
new file mode 100644
index 0000000..4bb1ff7
--- /dev/null
+++ b/public/admin/controller/extension/dashboard/online.php
@@ -0,0 +1,113 @@
+<?php
+class ControllerExtensionDashboardOnline extends Controller {
+ private $error = array();
+
+ public function index() {
+ $this->load->language('extension/dashboard/online');
+
+ $this->document->setTitle($this->language->get('heading_title'));
+
+ $this->load->model('setting/setting');
+
+ if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
+ $this->model_setting_setting->editSetting('dashboard_online', $this->request->post);
+
+ $this->session->data['success'] = $this->language->get('text_success');
+
+ $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true));
+ }
+
+ if (isset($this->error['warning'])) {
+ $data['error_warning'] = $this->error['warning'];
+ } else {
+ $data['error_warning'] = '';
+ }
+
+ $data['breadcrumbs'] = array();
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_home'),
+ 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_extension'),
+ 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('heading_title'),
+ 'href' => $this->url->link('extension/dashboard/online', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['action'] = $this->url->link('extension/dashboard/online', 'user_token=' . $this->session->data['user_token'], true);
+
+ $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true);
+
+ if (isset($this->request->post['dashboard_online_width'])) {
+ $data['dashboard_online_width'] = $this->request->post['dashboard_online_width'];
+ } else {
+ $data['dashboard_online_width'] = $this->config->get('dashboard_online_width');
+ }
+
+ $data['columns'] = array();
+
+ for ($i = 3; $i <= 12; $i++) {
+ $data['columns'][] = $i;
+ }
+
+ if (isset($this->request->post['dashboard_online_status'])) {
+ $data['dashboard_online_status'] = $this->request->post['dashboard_online_status'];
+ } else {
+ $data['dashboard_online_status'] = $this->config->get('dashboard_online_status');
+ }
+
+ if (isset($this->request->post['dashboard_online_sort_order'])) {
+ $data['dashboard_online_sort_order'] = $this->request->post['dashboard_online_sort_order'];
+ } else {
+ $data['dashboard_online_sort_order'] = $this->config->get('dashboard_online_sort_order');
+ }
+
+ $data['header'] = $this->load->controller('common/header');
+ $data['column_left'] = $this->load->controller('common/column_left');
+ $data['footer'] = $this->load->controller('common/footer');
+
+ $this->response->setOutput($this->load->view('extension/dashboard/online_form', $data));
+ }
+
+ protected function validate() {
+ if (!$this->user->hasPermission('modify', 'extension/dashboard/online')) {
+ $this->error['warning'] = $this->language->get('error_permission');
+ }
+
+ return !$this->error;
+ }
+
+ public function dashboard() {
+ $this->load->language('extension/dashboard/online');
+
+ $data['user_token'] = $this->session->data['user_token'];
+
+ // Total Orders
+ $this->load->model('extension/dashboard/online');
+
+ // Customers Online
+ $online_total = $this->model_extension_dashboard_online->getTotalOnline();
+
+ if ($online_total > 1000000000000) {
+ $data['total'] = round($online_total / 1000000000000, 1) . 'T';
+ } elseif ($online_total > 1000000000) {
+ $data['total'] = round($online_total / 1000000000, 1) . 'B';
+ } elseif ($online_total > 1000000) {
+ $data['total'] = round($online_total / 1000000, 1) . 'M';
+ } elseif ($online_total > 1000) {
+ $data['total'] = round($online_total / 1000, 1) . 'K';
+ } else {
+ $data['total'] = $online_total;
+ }
+
+ $data['online'] = $this->url->link('report/online', 'user_token=' . $this->session->data['user_token'], true);
+
+ return $this->load->view('extension/dashboard/online_info', $data);
+ }
+}
diff --git a/public/admin/controller/extension/dashboard/order.php b/public/admin/controller/extension/dashboard/order.php
new file mode 100644
index 0000000..3383fe3
--- /dev/null
+++ b/public/admin/controller/extension/dashboard/order.php
@@ -0,0 +1,124 @@
+<?php
+class ControllerExtensionDashboardOrder extends Controller {
+ private $error = array();
+
+ public function index() {
+ $this->load->language('extension/dashboard/order');
+
+ $this->document->setTitle($this->language->get('heading_title'));
+
+ $this->load->model('setting/setting');
+
+ if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
+ $this->model_setting_setting->editSetting('dashboard_order', $this->request->post);
+
+ $this->session->data['success'] = $this->language->get('text_success');
+
+ $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true));
+ }
+
+ if (isset($this->error['warning'])) {
+ $data['error_warning'] = $this->error['warning'];
+ } else {
+ $data['error_warning'] = '';
+ }
+
+ $data['breadcrumbs'] = array();
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_home'),
+ 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_extension'),
+ 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('heading_title'),
+ 'href' => $this->url->link('extension/dashboard/order', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['action'] = $this->url->link('extension/dashboard/order', 'user_token=' . $this->session->data['user_token'], true);
+
+ $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true);
+
+ if (isset($this->request->post['dashboard_order_width'])) {
+ $data['dashboard_order_width'] = $this->request->post['dashboard_order_width'];
+ } else {
+ $data['dashboard_order_width'] = $this->config->get('dashboard_order_width');
+ }
+
+ $data['columns'] = array();
+
+ for ($i = 3; $i <= 12; $i++) {
+ $data['columns'][] = $i;
+ }
+
+ if (isset($this->request->post['dashboard_order_status'])) {
+ $data['dashboard_order_status'] = $this->request->post['dashboard_order_status'];
+ } else {
+ $data['dashboard_order_status'] = $this->config->get('dashboard_order_status');
+ }
+
+ if (isset($this->request->post['dashboard_order_sort_order'])) {
+ $data['dashboard_order_sort_order'] = $this->request->post['dashboard_order_sort_order'];
+ } else {
+ $data['dashboard_order_sort_order'] = $this->config->get('dashboard_order_sort_order');
+ }
+
+ $data['header'] = $this->load->controller('common/header');
+ $data['column_left'] = $this->load->controller('common/column_left');
+ $data['footer'] = $this->load->controller('common/footer');
+
+ $this->response->setOutput($this->load->view('extension/dashboard/order_form', $data));
+ }
+
+ protected function validate() {
+ if (!$this->user->hasPermission('modify', 'extension/dashboard/order')) {
+ $this->error['warning'] = $this->language->get('error_permission');
+ }
+
+ return !$this->error;
+ }
+
+ public function dashboard() {
+ $this->load->language('extension/dashboard/order');
+
+ $data['user_token'] = $this->session->data['user_token'];
+
+ // Total Orders
+ $this->load->model('sale/order');
+
+ $today = $this->model_sale_order->getTotalOrders(array('filter_date_added' => date('Y-m-d', strtotime('-1 day'))));
+
+ $yesterday = $this->model_sale_order->getTotalOrders(array('filter_date_added' => date('Y-m-d', strtotime('-2 day'))));
+
+ $difference = $today - $yesterday;
+
+ if ($difference && $today) {
+ $data['percentage'] = round(($difference / $today) * 100);
+ } else {
+ $data['percentage'] = 0;
+ }
+
+ $order_total = $this->model_sale_order->getTotalOrders();
+
+ if ($order_total > 1000000000000) {
+ $data['total'] = round($order_total / 1000000000000, 1) . 'T';
+ } elseif ($order_total > 1000000000) {
+ $data['total'] = round($order_total / 1000000000, 1) . 'B';
+ } elseif ($order_total > 1000000) {
+ $data['total'] = round($order_total / 1000000, 1) . 'M';
+ } elseif ($order_total > 1000) {
+ $data['total'] = round($order_total / 1000, 1) . 'K';
+ } else {
+ $data['total'] = $order_total;
+ }
+
+ $data['order'] = $this->url->link('sale/order', 'user_token=' . $this->session->data['user_token'], true);
+
+ return $this->load->view('extension/dashboard/order_info', $data);
+ }
+}
diff --git a/public/admin/controller/extension/dashboard/recent.php b/public/admin/controller/extension/dashboard/recent.php
new file mode 100644
index 0000000..45063c7
--- /dev/null
+++ b/public/admin/controller/extension/dashboard/recent.php
@@ -0,0 +1,118 @@
+<?php
+class ControllerExtensionDashboardRecent extends Controller {
+ private $error = array();
+
+ public function index() {
+ $this->load->language('extension/dashboard/recent');
+
+ $this->document->setTitle($this->language->get('heading_title'));
+
+ $this->load->model('setting/setting');
+
+ if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
+ $this->model_setting_setting->editSetting('dashboard_recent', $this->request->post);
+
+ $this->session->data['success'] = $this->language->get('text_success');
+
+ $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true));
+ }
+
+ if (isset($this->error['warning'])) {
+ $data['error_warning'] = $this->error['warning'];
+ } else {
+ $data['error_warning'] = '';
+ }
+
+ $data['breadcrumbs'] = array();
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_home'),
+ 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_extension'),
+ 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('heading_title'),
+ 'href' => $this->url->link('extension/dashboard/recent', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['action'] = $this->url->link('extension/dashboard/recent', 'user_token=' . $this->session->data['user_token'], true);
+
+ $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true);
+
+ if (isset($this->request->post['dashboard_recent_width'])) {
+ $data['dashboard_recent_width'] = $this->request->post['dashboard_recent_width'];
+ } else {
+ $data['dashboard_recent_width'] = $this->config->get('dashboard_recent_width');
+ }
+
+ $data['columns'] = array();
+
+ for ($i = 3; $i <= 12; $i++) {
+ $data['columns'][] = $i;
+ }
+
+ if (isset($this->request->post['dashboard_recent_status'])) {
+ $data['dashboard_recent_status'] = $this->request->post['dashboard_recent_status'];
+ } else {
+ $data['dashboard_recent_status'] = $this->config->get('dashboard_recent_status');
+ }
+
+ if (isset($this->request->post['dashboard_recent_sort_order'])) {
+ $data['dashboard_recent_sort_order'] = $this->request->post['dashboard_recent_sort_order'];
+ } else {
+ $data['dashboard_recent_sort_order'] = $this->config->get('dashboard_recent_sort_order');
+ }
+
+ $data['header'] = $this->load->controller('common/header');
+ $data['column_left'] = $this->load->controller('common/column_left');
+ $data['footer'] = $this->load->controller('common/footer');
+
+ $this->response->setOutput($this->load->view('extension/dashboard/recent_form', $data));
+ }
+
+ protected function validate() {
+ if (!$this->user->hasPermission('modify', 'extension/dashboard/recent')) {
+ $this->error['warning'] = $this->language->get('error_permission');
+ }
+
+ return !$this->error;
+ }
+
+ public function dashboard() {
+ $this->load->language('extension/dashboard/recent');
+
+ $data['user_token'] = $this->session->data['user_token'];
+
+ // Last 5 Orders
+ $data['orders'] = array();
+
+ $filter_data = array(
+ 'sort' => 'o.date_added',
+ 'order' => 'DESC',
+ 'start' => 0,
+ 'limit' => 5
+ );
+
+ $this->load->model('sale/order');
+
+ $results = $this->model_sale_order->getOrders($filter_data);
+
+ foreach ($results as $result) {
+ $data['orders'][] = array(
+ 'order_id' => $result['order_id'],
+ 'customer' => $result['customer'],
+ 'status' => $result['order_status'],
+ 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
+ 'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
+ 'view' => $this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $result['order_id'], true),
+ );
+ }
+
+ return $this->load->view('extension/dashboard/recent_info', $data);
+ }
+}
diff --git a/public/admin/controller/extension/dashboard/sale.php b/public/admin/controller/extension/dashboard/sale.php
new file mode 100644
index 0000000..887079c
--- /dev/null
+++ b/public/admin/controller/extension/dashboard/sale.php
@@ -0,0 +1,123 @@
+<?php
+class ControllerExtensionDashboardSale extends Controller {
+ private $error = array();
+
+ public function index() {
+ $this->load->language('extension/dashboard/sale');
+
+ $this->document->setTitle($this->language->get('heading_title'));
+
+ $this->load->model('setting/setting');
+
+ if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
+ $this->model_setting_setting->editSetting('dashboard_sale', $this->request->post);
+
+ $this->session->data['success'] = $this->language->get('text_success');
+
+ $this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true));
+ }
+
+ if (isset($this->error['warning'])) {
+ $data['error_warning'] = $this->error['warning'];
+ } else {
+ $data['error_warning'] = '';
+ }
+
+ $data['breadcrumbs'] = array();
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_home'),
+ 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('text_extension'),
+ 'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true)
+ );
+
+ $data['breadcrumbs'][] = array(
+ 'text' => $this->language->get('heading_title'),
+ 'href' => $this->url->link('extension/dashboard/sale', 'user_token=' . $this->session->data['user_token'], true)
+ );
+
+ $data['action'] = $this->url->link('extension/dashboard/sale', 'user_token=' . $this->session->data['user_token'], true);
+
+ $data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true);
+
+ if (isset($this->request->post['dashboard_sale_width'])) {
+ $data['dashboard_sale_width'] = $this->request->post['dashboard_sale_width'];
+ } else {
+ $data['dashboard_sale_width'] = $this->config->get('dashboard_sale_width');
+ }
+
+ $data['columns'] = array();
+
+ for ($i = 3; $i <= 12; $i++) {
+ $data['columns'][] = $i;
+ }
+
+ if (isset($this->request->post['dashboard_sale_status'])) {
+ $data['dashboard_sale_status'] = $this->request->post['dashboard_sale_status'];
+ } else {
+ $data['dashboard_sale_status'] = $this->config->get('dashboard_sale_status');
+ }
+
+ if (isset($this->request->post['dashboard_sale_sort_order'])) {
+ $data['dashboard_sale_sort_order'] = $this->request->post['dashboard_sale_sort_order'];
+ } else {
+ $data['dashboard_sale_sort_order'] = $this->config->get('dashboard_sale_sort_order');
+ }
+
+ $data['header'] = $this->load->controller('common/header');
+ $data['column_left'] = $this->load->controller('common/column_left');
+ $data['footer'] = $this->load->controller('common/footer');
+
+ $this->response->setOutput($this->load->view('extension/dashboard/sale_form', $data));
+ }
+
+ protected function validate() {
+ if (!$this->user->hasPermission('modify', 'extension/dashboard/sale')) {
+ $this->error['warning'] = $this->language->get('error_permission');
+ }
+
+ return !$this->error;
+ }
+
+ public function dashboard() {
+ $this->load->language('extension/dashboard/sale');
+
+ $data['user_token'] = $this->session->data['user_token'];
+
+ $this->load->model('extension/dashboard/sale');
+
+ $today = $this->model_extension_dashboard_sale->getTotalSales(array('filter_date_added' => date('Y-m-d', strtotime('-1 day'))));
+
+ $yesterday = $this->model_extension_dashboard_sale->getTotalSales(array('filter_date_added' => date('Y-m-d', strtotime('-2 day'))));
+
+ $difference = $today - $yesterday;
+
+ if ($difference && (int)$today) {
+ $data['percentage'] = round(($difference / $today) * 100);
+ } else {
+ $data['percentage'] = 0;
+ }
+
+ $sale_total = $this->model_extension_dashboard_sale->getTotalSales();
+
+ if ($sale_total > 1000000000000) {
+ $data['total'] = round($sale_total / 1000000000000, 1) . 'T';
+ } elseif ($sale_total > 1000000000) {
+ $data['total'] = round($sale_total / 1000000000, 1) . 'B';
+ } elseif ($sale_total > 1000000) {
+ $data['total'] = round($sale_total / 1000000, 1) . 'M';
+ } elseif ($sale_total > 1000) {
+ $data['total'] = round($sale_total / 1000, 1) . 'K';
+ } else {
+ $data['total'] = round($sale_total);
+ }
+
+ $data['sale'] = $this->url->link('sale/order', 'user_token=' . $this->session->data['user_token'], true);
+
+ return $this->load->view('extension/dashboard/sale_info', $data);
+ }
+}