first commit

This commit is contained in:
sujan
2024-08-06 18:06:00 +05:45
commit a2fa49071a
2745 changed files with 391199 additions and 0 deletions

View File

@ -0,0 +1,142 @@
<?php
namespace Opencart\Admin\Controller\Report;
/**
* Class Online
*
* @package Opencart\Admin\Controller\Report
*/
class Online extends \Opencart\System\Engine\Controller {
/**
* @return void
*/
public function index(): void {
$this->load->language('report/online');
$this->document->setTitle($this->language->get('heading_title'));
$url = '';
if (isset($this->request->get['filter_customer'])) {
$url .= '&filter_customer=' . urlencode(html_entity_decode((string)$this->request->get['filter_customer'], ENT_QUOTES, 'UTF-8'));
}
if (isset($this->request->get['filter_ip'])) {
$url .= '&filter_ip=' . $this->request->get['filter_ip'];
}
if (isset($this->request->get['page'])) {
$url .= '&page=' . $this->request->get['page'];
}
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('report/online', 'user_token=' . $this->session->data['user_token'])
];
$data['list'] = $this->getList();
$data['user_token'] = $this->session->data['user_token'];
$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('report/online', $data));
}
/**
* @return void
*/
public function list(): void {
$this->load->language('report/online');
$this->response->setOutput($this->getList());
}
/**
* @return string
*/
protected function getList(): string {
if (isset($this->request->get['filter_customer'])) {
$filter_customer = $this->request->get['filter_customer'];
} else {
$filter_customer = '';
}
if (isset($this->request->get['filter_ip'])) {
$filter_ip = $this->request->get['filter_ip'];
} else {
$filter_ip = '';
}
if (isset($this->request->get['page'])) {
$page = (int)$this->request->get['page'];
} else {
$page = 1;
}
$data['customers'] = [];
$filter_data = [
'filter_customer' => $filter_customer,
'filter_ip' => $filter_ip,
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
'limit' => $this->config->get('config_pagination_admin')
];
$this->load->model('report/online');
$this->load->model('customer/customer');
$customer_total = $this->model_report_online->getTotalOnline($filter_data);
$results = $this->model_report_online->getOnline($filter_data);
foreach ($results as $result) {
$customer_info = $this->model_customer_customer->getCustomer($result['customer_id']);
if ($customer_info) {
$customer = $customer_info['firstname'] . ' ' . $customer_info['lastname'];
} else {
$customer = $this->language->get('text_guest');
}
$data['customers'][] = [
'customer_id' => $result['customer_id'],
'ip' => $result['ip'],
'customer' => $customer,
'url' => $result['url'],
'referer' => $result['referer'],
'date_added' => date($this->language->get('datetime_format'), strtotime($result['date_added'])),
'edit' => $this->url->link('customer/customer.form', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . $result['customer_id'])
];
}
$url = '';
if (isset($this->request->get['filter_customer'])) {
$url .= '&filter_customer=' . urlencode($this->request->get['filter_customer']);
}
if (isset($this->request->get['filter_ip'])) {
$url .= '&filter_ip=' . $this->request->get['filter_ip'];
}
$data['pagination'] = $this->load->controller('common/pagination', [
'total' => $customer_total,
'page' => $page,
'limit' => $this->config->get('config_pagination_admin'),
'url' => $this->url->link('report/online.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
]);
$data['results'] = sprintf($this->language->get('text_pagination'), ($customer_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($customer_total - $this->config->get('config_pagination_admin'))) ? $customer_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $customer_total, ceil($customer_total / $this->config->get('config_pagination_admin')));
return $this->load->view('report/online_list', $data);
}
}

View File

@ -0,0 +1,73 @@
<?php
namespace Opencart\Admin\Controller\Report;
/**
* Class Report
*
* @package Opencart\Admin\Controller\Report
*/
class Report extends \Opencart\System\Engine\Controller {
/**
* @return void
*/
public function index(): void {
$this->load->language('report/report');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('report/report', 'user_token=' . $this->session->data['user_token'])
];
if (isset($this->request->get['code'])) {
$data['code'] = $this->request->get['code'];
} else {
$data['code'] = '';
}
// Reports
$data['reports'] = [];
$this->load->model('setting/extension');
// Get a list of installed modules
$results = $this->model_setting_extension->getExtensionsByType('report');
// Add all the modules which have multiple settings for each module
foreach ($results as $result) {
if ($this->config->get('report_' . $result['code'] . '_status') && $this->user->hasPermission('access', 'extension/' . $result['extension'] . '/report/' . $result['code'])) {
$this->load->language('extension/' . $result['extension'] . '/report/' . $result['code'], $result['code']);
$data['reports'][] = [
'text' => $this->language->get($result['code'] . '_heading_title'),
'code' => $result['code'],
'sort_order' => $this->config->get('report_' . $result['code'] . '_sort_order'),
'href' => $this->url->link('extension/' . $result['extension'] . '/report/' . $result['code'] . '.report', 'user_token=' . $this->session->data['user_token'])
];
}
}
$sort_order = [];
foreach ($data['reports'] as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $data['reports']);
$data['user_token'] = $this->session->data['user_token'];
$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('report/report', $data));
}
}

View File

@ -0,0 +1,256 @@
<?php
namespace Opencart\Admin\Controller\Report;
/**
* Class Statistics
*
* @package Opencart\Admin\Controller\Report
*/
class Statistics extends \Opencart\System\Engine\Controller {
/**
* @return void
*/
public function index(): void {
$this->load->language('report/statistics');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('report/statistics', 'user_token=' . $this->session->data['user_token'])
];
$data['list'] = $this->getList();
$data['user_token'] = $this->session->data['user_token'];
$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('report/statistics', $data));
}
/**
* @return void
*/
public function list(): void {
$this->load->language('report/statistics');
$this->response->setOutput($this->getList());
}
/**
* @return string
*/
public function getList(): string {
$data['statistics'] = [];
$this->load->model('report/statistics');
$results = $this->model_report_statistics->getStatistics();
foreach ($results as $result) {
$data['statistics'][] = [
'name' => $this->language->get('text_' . $result['code']),
'value' => $result['value'],
'href' => $this->url->link('report/statistics.' . str_replace('_', '', $result['code']), 'user_token=' . $this->session->data['user_token'])
];
}
return $this->load->view('report/statistics_list', $data);
}
/**
* @return void
*/
public function orderSale(): void {
$this->load->language('report/statistics');
$json = [];
if (!$this->user->hasPermission('modify', 'report/statistics')) {
$json['error'] = $this->language->get('error_permission');
}
if (!$json) {
$this->load->model('report/statistics');
$this->load->model('sale/order');
$this->model_report_statistics->editValue('order_sale', $this->model_sale_order->getTotalSales(['filter_order_status' => implode(',', array_merge($this->config->get('config_complete_status'), $this->config->get('config_processing_status')))]));
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
/**
* @return void
*/
public function orderProcessing(): void {
$this->load->language('report/statistics');
$json = [];
if (!$this->user->hasPermission('modify', 'report/statistics')) {
$json['error'] = $this->language->get('error_permission');
}
if (!$json) {
$this->load->model('report/statistics');
$this->load->model('sale/order');
$this->model_report_statistics->editValue('order_processing', $this->model_sale_order->getTotalOrders(['filter_order_status' => implode(',', $this->config->get('config_processing_status'))]));
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
/**
* @return void
*/
public function orderComplete(): void {
$this->load->language('report/statistics');
$json = [];
if (!$this->user->hasPermission('modify', 'report/statistics')) {
$json['error'] = $this->language->get('error_permission');
}
if (!$json) {
$this->load->model('report/statistics');
$this->load->model('sale/order');
$this->model_report_statistics->editValue('order_complete', $this->model_sale_order->getTotalOrders(['filter_order_status' => implode(',', $this->config->get('config_complete_status'))]));
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
/**
* @return void
*/
public function orderOther(): void {
$this->load->language('report/statistics');
$json = [];
if (!$this->user->hasPermission('modify', 'report/statistics')) {
$json['error'] = $this->language->get('error_permission');
}
if (!$json) {
$this->load->model('report/statistics');
$this->load->model('localisation/order_status');
$order_status_data = [];
$results = $this->model_localisation_order_status->getOrderStatuses();
foreach ($results as $result) {
if (!in_array($result['order_status_id'], array_merge($this->config->get('config_complete_status'), $this->config->get('config_processing_status')))) {
$order_status_data[] = $result['order_status_id'];
}
}
$this->load->model('sale/order');
$this->model_report_statistics->editValue('order_other', $this->model_sale_order->getTotalOrders(['filter_order_status' => implode(',', $order_status_data)]));
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
/**
* @return void
*/
public function returns(): void {
$this->load->language('report/statistics');
$json = [];
if (!$this->user->hasPermission('modify', 'report/statistics')) {
$json['error'] = $this->language->get('error_permission');
}
if (!$json) {
$this->load->model('report/statistics');
$this->load->model('sale/returns');
$this->model_report_statistics->editValue('return', $this->model_sale_returns->getTotalReturns(['filter_return_status_id' => $this->config->get('config_return_status_id')]));
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
/**
* @return void
*/
public function product(): void {
$this->load->language('report/statistics');
$json = [];
if (!$this->user->hasPermission('modify', 'report/statistics')) {
$json['error'] = $this->language->get('error_permission');
}
if (!$json) {
$this->load->model('report/statistics');
$this->load->model('catalog/product');
$this->model_report_statistics->editValue('product', $this->model_catalog_product->getTotalProducts(['filter_quantity' => 0]));
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
/**
* @return void
*/
public function review(): void {
$this->load->language('report/statistics');
$json = [];
if (!$this->user->hasPermission('modify', 'report/statistics')) {
$json['error'] = $this->language->get('error_permission');
}
if (!$json) {
$this->load->model('report/statistics');
$this->load->model('catalog/review');
$this->model_report_statistics->editValue('review', $this->model_catalog_review->getTotalReviewsAwaitingApproval());
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}