first commit
This commit is contained in:
198
extension/opencart/admin/controller/report/customer.php
Normal file
198
extension/opencart/admin/controller/report/customer.php
Normal file
@ -0,0 +1,198 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class Customer
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class Customer extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/customer');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/customer', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/customer.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_customer_status'] = $this->config->get('report_customer_status');
|
||||
$data['report_customer_sort_order'] = $this->config->get('report_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/opencart/report/customer_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/customer');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/customer')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_customer', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/customer');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$data['groups'] = [];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_year'),
|
||||
'value' => 'year',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_month'),
|
||||
'value' => 'month',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_week'),
|
||||
'value' => 'week',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_day'),
|
||||
'value' => 'day',
|
||||
];
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/customer', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/customer');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$filter_group = $this->request->get['filter_group'];
|
||||
} else {
|
||||
$filter_group = 'week';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['customers'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_group' => $filter_group,
|
||||
'start' => ($page - 1) * 20,
|
||||
'limit' => 20
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/customer');
|
||||
|
||||
$customer_total = $this->model_extension_opencart_report_customer->getTotalCustomers($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_customer->getCustomers($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['customers'][] = [
|
||||
'date_start' => date($this->language->get('date_format_short'), strtotime($result['date_start'])),
|
||||
'date_end' => date($this->language->get('date_format_short'), strtotime($result['date_end'])),
|
||||
'total' => $result['total'],
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$url .= '&filter_group=' . $this->request->get['filter_group'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $customer_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/customer.report', 'user_token=' . $this->session->data['user_token'] . '&code=customer' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($customer_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($customer_total - $this->config->get('config_pagination'))) ? $customer_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $customer_total, ceil($customer_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_group'] = $filter_group;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/customer_list', $data);
|
||||
}
|
||||
}
|
200
extension/opencart/admin/controller/report/customer_activity.php
Normal file
200
extension/opencart/admin/controller/report/customer_activity.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class Customer Activity
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class CustomerActivity extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/customer_activity');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/customer_activity', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/customer_activity.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_customer_activity_status'] = $this->config->get('report_customer_activity_status');
|
||||
$data['report_customer_activity_sort_order'] = $this->config->get('report_customer_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/opencart/report/customer_activity_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/customer_activity');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/customer_activity')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_customer_activity', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/customer_activity');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/customer_activity', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/customer_activity');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): 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['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['activities'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_customer' => $filter_customer,
|
||||
'filter_ip' => $filter_ip,
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'start' => ($page - 1) * 20,
|
||||
'limit' => 20
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/customer');
|
||||
|
||||
$activity_total = $this->model_extension_opencart_report_customer->getTotalCustomerActivities($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_customer->getCustomerActivities($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$comment = vsprintf($this->language->get('text_activity_' . $result['key']), json_decode($result['data'], true));
|
||||
|
||||
$find = [
|
||||
'customer_id=',
|
||||
'order_id='
|
||||
];
|
||||
|
||||
$replace = [
|
||||
$this->url->link('customer/customer.form', 'user_token=' . $this->session->data['user_token'] . '&customer_id='),
|
||||
$this->url->link('sale/order.info', 'user_token=' . $this->session->data['user_token'] . '&order_id=')
|
||||
];
|
||||
|
||||
$data['activities'][] = [
|
||||
'comment' => str_replace($find, $replace, $comment),
|
||||
'ip' => $result['ip'],
|
||||
'date_added' => date($this->language->get('datetime_format'), strtotime($result['date_added']))
|
||||
];
|
||||
}
|
||||
|
||||
$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'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $activity_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/customer_activity.report', 'user_token=' . $this->session->data['user_token'] . '&code=customer_activity' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($activity_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($activity_total - $this->config->get('config_pagination'))) ? $activity_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $activity_total, ceil($activity_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_customer'] = $filter_customer;
|
||||
$data['filter_ip'] = $filter_ip;
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/customer_activity_list', $data);
|
||||
}
|
||||
}
|
197
extension/opencart/admin/controller/report/customer_order.php
Normal file
197
extension/opencart/admin/controller/report/customer_order.php
Normal file
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class Customer Order
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class CustomerOrder extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/customer_order');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/opencart/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/customer_order', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/customer_order.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_customer_order_status'] = $this->config->get('report_customer_order_status');
|
||||
$data['report_customer_order_sort_order'] = $this->config->get('report_customer_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/opencart/report/customer_order_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/customer_order');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/customer_order')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_customer_order', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/customer_order');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/customer_order', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/customer_order');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_customer'])) {
|
||||
$filter_customer = $this->request->get['filter_customer'];
|
||||
} else {
|
||||
$filter_customer = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$filter_order_status_id = (int)$this->request->get['filter_order_status_id'];
|
||||
} else {
|
||||
$filter_order_status_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['customers'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_customer' => $filter_customer,
|
||||
'filter_order_status_id' => $filter_order_status_id,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/customer');
|
||||
|
||||
$customer_total = $this->model_extension_opencart_report_customer->getTotalOrders($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_customer->getOrders($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['customers'][] = [
|
||||
'customer' => $result['customer'],
|
||||
'email' => $result['email'],
|
||||
'customer_group' => $result['customer_group'],
|
||||
'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
|
||||
'orders' => $result['orders'],
|
||||
'products' => $result['products'],
|
||||
'total' => $this->currency->format($result['total'], $this->config->get('config_currency')),
|
||||
'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_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_customer'])) {
|
||||
$url .= '&filter_customer=' . urlencode($this->request->get['filter_customer']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $customer_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/customer_order.report', 'user_token=' . $this->session->data['user_token'] . '&code=customer_order' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($customer_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($customer_total - $this->config->get('config_pagination'))) ? $customer_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $customer_total, ceil($customer_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_customer'] = $filter_customer;
|
||||
$data['filter_order_status_id'] = $filter_order_status_id;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/customer_order_list', $data);
|
||||
}
|
||||
}
|
181
extension/opencart/admin/controller/report/customer_reward.php
Normal file
181
extension/opencart/admin/controller/report/customer_reward.php
Normal file
@ -0,0 +1,181 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class Customer Reward
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class CustomerReward extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/customer_reward');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/customer_reward', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/customer_reward.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_customer_reward_status'] = $this->config->get('report_customer_reward_status');
|
||||
$data['report_customer_reward_sort_order'] = $this->config->get('report_customer_reward_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/opencart/report/customer_reward_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/customer_reward');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/customer_reward')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_customer_reward', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/customer_reward');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/customer_reward', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/customer_reward');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_customer'])) {
|
||||
$filter_customer = $this->request->get['filter_customer'];
|
||||
} else {
|
||||
$filter_customer = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['customers'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_customer' => $filter_customer,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/customer');
|
||||
|
||||
$customer_total = $this->model_extension_opencart_report_customer->getTotalRewardPoints($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_customer->getRewardPoints($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['customers'][] = [
|
||||
'customer' => $result['customer'],
|
||||
'email' => $result['email'],
|
||||
'customer_group' => $result['customer_group'],
|
||||
'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
|
||||
'points' => $result['points'],
|
||||
'orders' => $result['orders'],
|
||||
'total' => $this->currency->format((float)$result['total'], $this->config->get('config_currency')),
|
||||
'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_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_customer'])) {
|
||||
$url .= '&filter_customer=' . urlencode($this->request->get['filter_customer']);
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $customer_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/customer_reward.report', 'user_token=' . $this->session->data['user_token'] . '&code=customer_reward' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($customer_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($customer_total - $this->config->get('config_pagination'))) ? $customer_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $customer_total, ceil($customer_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_customer'] = $filter_customer;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/customer_reward_list', $data);
|
||||
}
|
||||
}
|
218
extension/opencart/admin/controller/report/customer_search.php
Normal file
218
extension/opencart/admin/controller/report/customer_search.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class CustomerSearch
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class CustomerSearch extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/customer_search');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/customer_search', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/customer_search.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_customer_search_status'] = $this->config->get('report_customer_search_status');
|
||||
$data['report_customer_search_sort_order'] = $this->config->get('report_customer_search_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/opencart/report/customer_search_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/customer_search');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/customer_search')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_customer_search', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/customer_search');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/customer_search', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/customer_search');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_keyword'])) {
|
||||
$filter_keyword = $this->request->get['filter_keyword'];
|
||||
} else {
|
||||
$filter_keyword = '';
|
||||
}
|
||||
|
||||
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['searches'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_keyword' => $filter_keyword,
|
||||
'filter_customer' => $filter_customer,
|
||||
'filter_ip' => $filter_ip,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/customer');
|
||||
$this->load->model('catalog/category');
|
||||
|
||||
$search_total = $this->model_extension_opencart_report_customer->getTotalCustomerSearches($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_customer->getCustomerSearches($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$category_info = $this->model_catalog_category->getCategory($result['category_id']);
|
||||
|
||||
if ($category_info) {
|
||||
$category = ($category_info['path']) ? $category_info['path'] . ' > ' . $category_info['name'] : $category_info['name'];
|
||||
} else {
|
||||
$category = '';
|
||||
}
|
||||
|
||||
if ($result['customer_id'] > 0) {
|
||||
$customer = sprintf($this->language->get('text_customer'), $this->url->link('customer/customer.form', 'user_token=' . $this->session->data['user_token'] . '&customer_id=' . $result['customer_id']), $result['customer']);
|
||||
} else {
|
||||
$customer = $this->language->get('text_guest');
|
||||
}
|
||||
|
||||
$data['searches'][] = [
|
||||
'keyword' => $result['keyword'],
|
||||
'products' => $result['products'],
|
||||
'category' => $category,
|
||||
'customer' => $customer,
|
||||
'ip' => $result['ip'],
|
||||
'date_added' => date($this->language->get('datetime_format'), strtotime($result['date_added']))
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_keyword'])) {
|
||||
$url .= '&filter_keyword=' . urlencode($this->request->get['filter_keyword']);
|
||||
}
|
||||
|
||||
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' => $search_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/customer_search.report', 'user_token=' . $this->session->data['user_token'] . '&code=customer_search' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($search_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($search_total - $this->config->get('config_pagination'))) ? $search_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $search_total, ceil($search_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_keyword'] = $filter_keyword;
|
||||
$data['filter_customer'] = $filter_customer;
|
||||
$data['filter_ip'] = $filter_ip;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/customer_search_list', $data);
|
||||
}
|
||||
}
|
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class CustomerSubscription
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class CustomerSubscription extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/customer_subscription');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/customer_subscription', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/customer_subscription.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_customer_subscription_status'] = $this->config->get('report_customer_subscription_status');
|
||||
$data['report_customer_subscription_sort_order'] = $this->config->get('report_customer_subscription_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/opencart/report/customer_subscription_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/customer_subscription');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/customer_subscription')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_customer_subscription', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/customer_subscription');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/customer_subscription', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/customer_subscription');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_customer'])) {
|
||||
$filter_customer = $this->request->get['filter_customer'];
|
||||
} else {
|
||||
$filter_customer = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['subscriptions'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_customer' => $filter_customer,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/customer_subscription');
|
||||
|
||||
$subscription_total = $this->model_extension_opencart_report_customer_subscription->getTotalTransactions($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_customer_subscription->getTransactions($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['subscriptions'][] = [
|
||||
'customer' => $result['customer'],
|
||||
'email' => $result['email'],
|
||||
'customer_group' => $result['customer_group'],
|
||||
'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
|
||||
'total' => $this->currency->format($result['total'], $this->config->get('config_currency')),
|
||||
'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_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_customer'])) {
|
||||
$url .= '&filter_customer=' . urlencode($this->request->get['filter_customer']);
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $subscription_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/customer_subscription.report', 'user_token=' . $this->session->data['user_token'] . '&code=customer_subscription' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($subscription_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($subscription_total - $this->config->get('config_pagination'))) ? $subscription_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $subscription_total, ceil($subscription_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_customer'] = $filter_customer;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/customer_subscription_list', $data);
|
||||
}
|
||||
}
|
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class CustomerTransaction
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class CustomerTransaction extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/customer_transaction');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/customer_transaction', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/customer_transaction.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_customer_transaction_status'] = $this->config->get('report_customer_transaction_status');
|
||||
$data['report_customer_transaction_sort_order'] = $this->config->get('report_customer_transaction_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/opencart/report/customer_transaction_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/customer_transaction');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/customer_transaction')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_customer_transaction', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/customer_transaction');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/customer_transaction', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/customer_transaction');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_customer'])) {
|
||||
$filter_customer = $this->request->get['filter_customer'];
|
||||
} else {
|
||||
$filter_customer = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['customers'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_customer' => $filter_customer,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/customer_transaction');
|
||||
|
||||
$customer_total = $this->model_extension_opencart_report_customer_transaction->getTotalTransactions($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_customer_transaction->getTransactions($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['customers'][] = [
|
||||
'customer' => $result['customer'],
|
||||
'email' => $result['email'],
|
||||
'customer_group' => $result['customer_group'],
|
||||
'status' => ($result['status'] ? $this->language->get('text_enabled') : $this->language->get('text_disabled')),
|
||||
'total' => $this->currency->format($result['total'], $this->config->get('config_currency')),
|
||||
'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_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_customer'])) {
|
||||
$url .= '&filter_customer=' . urlencode($this->request->get['filter_customer']);
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $customer_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/customer_transaction.report', 'user_token=' . $this->session->data['user_token'] . '&code=customer_transaction' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($customer_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($customer_total - $this->config->get('config_pagination'))) ? $customer_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $customer_total, ceil($customer_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_customer'] = $filter_customer;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/customer_transaction_list', $data);
|
||||
}
|
||||
}
|
183
extension/opencart/admin/controller/report/marketing.php
Normal file
183
extension/opencart/admin/controller/report/marketing.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class Marketing
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class Marketing extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/marketing');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/marketing', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/marketing.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_marketing_status'] = $this->config->get('report_marketing_status');
|
||||
$data['report_marketing_sort_order'] = $this->config->get('report_marketing_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/opencart/report/marketing_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/marketing');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/marketing')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_marketing', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/marketing');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/marketing', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/marketing');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$filter_order_status_id = (int)$this->request->get['filter_order_status_id'];
|
||||
} else {
|
||||
$filter_order_status_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['marketings'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_order_status_id' => $filter_order_status_id,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/marketing');
|
||||
|
||||
$marketing_total = $this->model_extension_opencart_report_marketing->getTotalMarketing($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_marketing->getMarketing($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['marketings'][] = [
|
||||
'campaign' => $result['campaign'],
|
||||
'code' => $result['code'],
|
||||
'clicks' => $result['clicks'],
|
||||
'orders' => $result['orders'],
|
||||
'total' => $this->currency->format((float)$result['total'], $this->config->get('config_currency')),
|
||||
'save' => $this->url->link('marketing/marketing/edit', 'user_token=' . $this->session->data['user_token'] . '&marketing_id=' . $result['marketing_id'])
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $marketing_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/marketing.report', 'user_token=' . $this->session->data['user_token'] . '&code=marketing' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($marketing_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($marketing_total - $this->config->get('config_pagination'))) ? $marketing_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $marketing_total, ceil($marketing_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_order_status_id'] = $filter_order_status_id;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/marketing_list', $data);
|
||||
}
|
||||
}
|
181
extension/opencart/admin/controller/report/product_purchased.php
Normal file
181
extension/opencart/admin/controller/report/product_purchased.php
Normal file
@ -0,0 +1,181 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class ProductPurchased
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class ProductPurchased extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/product_purchased');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/product_purchased', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/product_purchased.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_product_purchased_status'] = $this->config->get('report_product_purchased_status');
|
||||
$data['report_product_purchased_sort_order'] = $this->config->get('report_product_purchased_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/opencart/report/product_purchased_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/product_purchased');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/product_purchased')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_product_purchased', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/product_purchased');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/product_purchased', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/product_purchased');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$filter_order_status_id = (int)$this->request->get['filter_order_status_id'];
|
||||
} else {
|
||||
$filter_order_status_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['products'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_order_status_id' => $filter_order_status_id,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/product_purchased');
|
||||
|
||||
$product_total = $this->model_extension_opencart_report_product_purchased->getTotalPurchased($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_product_purchased->getPurchased($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['products'][] = [
|
||||
'name' => $result['name'],
|
||||
'model' => $result['model'],
|
||||
'quantity' => $result['quantity'],
|
||||
'total' => $this->currency->format($result['total'], $this->config->get('config_currency'))
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $product_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/product_purchased.report', 'user_token=' . $this->session->data['user_token'] . '&code=product_purchased' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($product_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($product_total - $this->config->get('config_pagination'))) ? $product_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $product_total, ceil($product_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_order_status_id'] = $filter_order_status_id;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/product_purchased_list', $data);
|
||||
}
|
||||
}
|
227
extension/opencart/admin/controller/report/product_viewed.php
Normal file
227
extension/opencart/admin/controller/report/product_viewed.php
Normal file
@ -0,0 +1,227 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class ProductViewed
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class ProductViewed extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/product_viewed');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/product_viewed', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/product_viewed.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_product_viewed_status'] = $this->config->get('report_product_viewed_status');
|
||||
$data['report_product_viewed_sort_order'] = $this->config->get('report_product_viewed_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/opencart/report/product_viewed_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/product_viewed');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/product_viewed')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_product_viewed', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function install(): void {
|
||||
if ($this->user->hasPermission('modify', 'extension/report')) {
|
||||
$this->load->model('extension/opencart/report/product_viewed');
|
||||
|
||||
$this->model_extension_opencart_report_product_viewed->install();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function uninstall(): void {
|
||||
if ($this->user->hasPermission('modify', 'extension/report')) {
|
||||
$this->load->model('extension/opencart/report/product_viewed');
|
||||
|
||||
$this->model_extension_opencart_report_product_viewed->uninstall();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/product_viewed');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/product_viewed', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/product_viewed');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['products'] = [];
|
||||
|
||||
$this->load->model('extension/opencart/report/product_viewed');
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$total = $this->model_extension_opencart_report_product_viewed->getTotal();
|
||||
|
||||
$viewed_total = $this->model_extension_opencart_report_product_viewed->getTotalViewed();
|
||||
|
||||
$results = $this->model_extension_opencart_report_product_viewed->getViewed(($page - 1) * $this->config->get('config_pagination'), $this->config->get('config_pagination'));
|
||||
|
||||
foreach ($results as $result) {
|
||||
$product_info = $this->model_catalog_product->getProduct($result['product_id']);
|
||||
|
||||
if ($product_info) {
|
||||
if ($result['viewed']) {
|
||||
$percent = round(($result['viewed'] / $total) * 100, 2);
|
||||
} else {
|
||||
$percent = 0;
|
||||
}
|
||||
|
||||
$data['products'][] = [
|
||||
'name' => $product_info['name'],
|
||||
'model' => $product_info['model'],
|
||||
'viewed' => $result['viewed'],
|
||||
'percent' => $percent . '%'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $viewed_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/product_viewed.list', 'user_token=' . $this->session->data['user_token'] . '&code=product_viewed&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($viewed_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($viewed_total - $this->config->get('config_pagination'))) ? $viewed_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $viewed_total, ceil($viewed_total / $this->config->get('config_pagination')));
|
||||
|
||||
return $this->load->view('extension/opencart/report/product_viewed_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function generate(): void {
|
||||
$this->load->language('extension/opencart/report/product_viewed');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$limit = 10;
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/product_viewed')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('extension/opencart/report/product_viewed');
|
||||
|
||||
if ($page == 1) {
|
||||
$this->model_extension_opencart_report_product_viewed->clear();
|
||||
}
|
||||
|
||||
$filter_data = [
|
||||
'start' => ($page - 1) * $limit,
|
||||
'limit' => $limit
|
||||
];
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$product_total = $this->model_catalog_product->getTotalProducts();
|
||||
|
||||
$products = $this->model_catalog_product->getProducts($filter_data);
|
||||
|
||||
foreach ($products as $product) {
|
||||
$this->model_extension_opencart_report_product_viewed->addReport($product['product_id'], $this->model_catalog_product->getTotalReports($product['product_id']));
|
||||
}
|
||||
|
||||
if (($page * $limit) <= $product_total) {
|
||||
$json['text'] = sprintf($this->language->get('text_progress'), ($page - 1) * $limit, $product_total);
|
||||
|
||||
$json['next'] = $this->url->link('extension/opencart/report/product_viewed.generate', 'user_token=' . $this->session->data['user_token'] . '&page=' . ($page + 1), true);
|
||||
} else {
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
166
extension/opencart/admin/controller/report/sale_coupon.php
Normal file
166
extension/opencart/admin/controller/report/sale_coupon.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* CLass SaleCoupon
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class SaleCoupon extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/sale_coupon');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/sale_coupon', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/sale_coupon.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_sale_coupon_status'] = $this->config->get('report_sale_coupon_status');
|
||||
$data['report_sale_coupon_sort_order'] = $this->config->get('report_sale_coupon_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/opencart/report/sale_coupon_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/sale_coupon');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/sale_coupon')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_sale_coupon', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/sale_coupon');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/sale_coupon', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/sale_coupon');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['coupons'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/coupon');
|
||||
|
||||
$coupon_total = $this->model_extension_opencart_report_coupon->getTotalCoupons($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_coupon->getCoupons($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['coupons'][] = [
|
||||
'name' => $result['name'],
|
||||
'code' => $result['code'],
|
||||
'orders' => $result['orders'],
|
||||
'total' => $this->currency->format($result['total'], $this->config->get('config_currency')),
|
||||
'edit' => $this->url->link('marketing/coupon.edit', 'user_token=' . $this->session->data['user_token'] . '&coupon_id=' . $result['coupon_id'])
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $coupon_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/sale_coupon.report', 'user_token=' . $this->session->data['user_token'] . '&code=sale_coupon' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($coupon_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($coupon_total - $this->config->get('config_pagination'))) ? $coupon_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $coupon_total, ceil($coupon_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/sale_coupon_list', $data);
|
||||
}
|
||||
}
|
217
extension/opencart/admin/controller/report/sale_order.php
Normal file
217
extension/opencart/admin/controller/report/sale_order.php
Normal file
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class SaleOrder
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class SaleOrder extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/sale_order');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/sale_order', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/sale_order.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_sale_order_status'] = $this->config->get('report_sale_order_status');
|
||||
$data['report_sale_order_sort_order'] = $this->config->get('report_sale_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/opencart/report/sale_order_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/sale_order');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/sale_order')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_sale_order', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/sale_order');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
|
||||
|
||||
$data['groups'] = [];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_year'),
|
||||
'value' => 'year',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_month'),
|
||||
'value' => 'month',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_week'),
|
||||
'value' => 'week',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_day'),
|
||||
'value' => 'day',
|
||||
];
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/sale_order', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/sale_order');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = date('Y-m-d', strtotime(date('Y') . '-' . date('m') . '-01'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = date('Y-m-d');
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$filter_group = $this->request->get['filter_group'];
|
||||
} else {
|
||||
$filter_group = 'week';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$filter_order_status_id = (int)$this->request->get['filter_order_status_id'];
|
||||
} else {
|
||||
$filter_order_status_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['orders'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_group' => $filter_group,
|
||||
'filter_order_status_id' => $filter_order_status_id,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/sale');
|
||||
|
||||
$order_total = $this->model_extension_opencart_report_sale->getTotalOrders($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_sale->getOrders($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['orders'][] = [
|
||||
'date_start' => date($this->language->get('date_format_short'), strtotime($result['date_start'])),
|
||||
'date_end' => date($this->language->get('date_format_short'), strtotime($result['date_end'])),
|
||||
'orders' => $result['orders'],
|
||||
'products' => $result['products'],
|
||||
'tax' => $this->currency->format((float)$result['tax'], $this->config->get('config_currency')),
|
||||
'total' => $this->currency->format((float)$result['total'], $this->config->get('config_currency'))
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$url .= '&filter_group=' . $this->request->get['filter_group'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $order_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/sale_order', 'user_token=' . $this->session->data['user_token'] . '&code=sale_order' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($order_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($order_total - $this->config->get('config_pagination'))) ? $order_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $order_total, ceil($order_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_group'] = $filter_group;
|
||||
$data['filter_order_status_id'] = $filter_order_status_id;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/sale_order_list', $data);
|
||||
}
|
||||
}
|
214
extension/opencart/admin/controller/report/sale_return.php
Normal file
214
extension/opencart/admin/controller/report/sale_return.php
Normal file
@ -0,0 +1,214 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class Sale Return
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class SaleReturn extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/sale_return');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/sale_return', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/sale_return.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_sale_return_status'] = $this->config->get('report_sale_return_status');
|
||||
$data['report_sale_return_sort_order'] = $this->config->get('report_sale_return_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/opencart/report/sale_return_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/sale_coupon');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/sale_return')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_sale_return', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/sale_return');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$this->load->model('localisation/return_status');
|
||||
|
||||
$data['return_statuses'] = $this->model_localisation_return_status->getReturnStatuses();
|
||||
|
||||
$data['groups'] = [];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_year'),
|
||||
'value' => 'year',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_month'),
|
||||
'value' => 'month',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_week'),
|
||||
'value' => 'week',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_day'),
|
||||
'value' => 'day',
|
||||
];
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/sale_return', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/sale_return');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$filter_group = $this->request->get['filter_group'];
|
||||
} else {
|
||||
$filter_group = 'week';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_return_status_id'])) {
|
||||
$filter_return_status_id = (int)$this->request->get['filter_return_status_id'];
|
||||
} else {
|
||||
$filter_return_status_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['returns'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_group' => $filter_group,
|
||||
'filter_return_status_id' => $filter_return_status_id,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/returns');
|
||||
|
||||
$return_total = $this->model_extension_opencart_report_returns->getTotalReturns($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_returns->getReturns($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['returns'][] = [
|
||||
'date_start' => date($this->language->get('date_format_short'), strtotime($result['date_start'])),
|
||||
'date_end' => date($this->language->get('date_format_short'), strtotime($result['date_end'])),
|
||||
'returns' => $result['returns']
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$url .= '&filter_group=' . $this->request->get['filter_group'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_return_status_id'])) {
|
||||
$url .= '&filter_return_status_id=' . $this->request->get['filter_return_status_id'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $return_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/sale_return.report', 'user_token=' . $this->session->data['user_token'] . '&code=sale_return' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($return_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($return_total - $this->config->get('config_pagination'))) ? $return_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $return_total, ceil($return_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_group'] = $filter_group;
|
||||
$data['filter_return_status_id'] = $filter_return_status_id;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/sale_return_list', $data);
|
||||
}
|
||||
}
|
216
extension/opencart/admin/controller/report/sale_shipping.php
Normal file
216
extension/opencart/admin/controller/report/sale_shipping.php
Normal file
@ -0,0 +1,216 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class Sale Shipping
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class SaleShipping extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/sale_shipping');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/sale_shipping', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/sale_shipping.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_sale_shipping_status'] = $this->config->get('report_sale_shipping_status');
|
||||
$data['report_sale_shipping_sort_order'] = $this->config->get('report_sale_shipping_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/opencart/report/sale_shipping_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/sale_shipping');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/sale_shipping')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_sale_shipping', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/sale_shipping');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
|
||||
|
||||
$data['groups'] = [];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_year'),
|
||||
'value' => 'year',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_month'),
|
||||
'value' => 'month',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_week'),
|
||||
'value' => 'week',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_day'),
|
||||
'value' => 'day',
|
||||
];
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/sale_shipping', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/sale_shipping');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$filter_group = $this->request->get['filter_group'];
|
||||
} else {
|
||||
$filter_group = 'week';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$filter_order_status_id = (int)$this->request->get['filter_order_status_id'];
|
||||
} else {
|
||||
$filter_order_status_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['orders'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_group' => $filter_group,
|
||||
'filter_order_status_id' => $filter_order_status_id,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/sale');
|
||||
|
||||
$order_total = $this->model_extension_opencart_report_sale->getTotalShipping($filter_data);
|
||||
|
||||
$results = $this->model_extension_opencart_report_sale->getShipping($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['orders'][] = [
|
||||
'date_start' => date($this->language->get('date_format_short'), strtotime($result['date_start'])),
|
||||
'date_end' => date($this->language->get('date_format_short'), strtotime($result['date_end'])),
|
||||
'title' => $result['title'],
|
||||
'orders' => $result['orders'],
|
||||
'total' => $this->currency->format($result['total'], $this->config->get('config_currency'))
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$url .= '&filter_group=' . $this->request->get['filter_group'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $order_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/sale_shipping.list', 'user_token=' . $this->session->data['user_token'] . '&code=sale_shipping' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($order_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($order_total - $this->config->get('config_pagination'))) ? $order_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $order_total, ceil($order_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_group'] = $filter_group;
|
||||
$data['filter_order_status_id'] = $filter_order_status_id;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/sale_shipping_list', $data);
|
||||
}
|
||||
}
|
218
extension/opencart/admin/controller/report/sale_tax.php
Normal file
218
extension/opencart/admin/controller/report/sale_tax.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Report;
|
||||
/**
|
||||
* Class Sale Tax
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Report
|
||||
*/
|
||||
class SaleTax extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/report/sale_tax');
|
||||
|
||||
$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('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/report/sale_tax', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/report/sale_tax.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=report');
|
||||
|
||||
$data['report_sale_tax_status'] = $this->config->get('report_sale_tax_status');
|
||||
$data['report_sale_tax_sort_order'] = $this->config->get('report_sale_tax_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/opencart/report/sale_tax_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/report/sale_tax');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/report/sale_tax')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('report_sale_tax', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/report/sale_tax');
|
||||
|
||||
$data['list'] = $this->getReport();
|
||||
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
$data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
|
||||
|
||||
$data['groups'] = [];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_year'),
|
||||
'value' => 'year',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_month'),
|
||||
'value' => 'month',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_week'),
|
||||
'value' => 'week',
|
||||
];
|
||||
|
||||
$data['groups'][] = [
|
||||
'text' => $this->language->get('text_day'),
|
||||
'value' => 'day',
|
||||
];
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/report/sale_tax', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('extension/opencart/report/sale_tax');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$filter_date_start = $this->request->get['filter_date_start'];
|
||||
} else {
|
||||
$filter_date_start = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$filter_date_end = $this->request->get['filter_date_end'];
|
||||
} else {
|
||||
$filter_date_end = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$filter_group = $this->request->get['filter_group'];
|
||||
} else {
|
||||
$filter_group = 'week';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$filter_order_status_id = (int)$this->request->get['filter_order_status_id'];
|
||||
} else {
|
||||
$filter_order_status_id = 0;
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$data['orders'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_date_start' => $filter_date_start,
|
||||
'filter_date_end' => $filter_date_end,
|
||||
'filter_group' => $filter_group,
|
||||
'filter_order_status_id' => $filter_order_status_id,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination'),
|
||||
'limit' => $this->config->get('config_pagination')
|
||||
];
|
||||
|
||||
$this->load->model('extension/opencart/report/sale');
|
||||
|
||||
$order_total = $this->model_extension_opencart_report_sale->getTotalTaxes($filter_data);
|
||||
|
||||
$data['orders'] = [];
|
||||
|
||||
$results = $this->model_extension_opencart_report_sale->getTaxes($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['orders'][] = [
|
||||
'date_start' => date($this->language->get('date_format_short'), strtotime($result['date_start'])),
|
||||
'date_end' => date($this->language->get('date_format_short'), strtotime($result['date_end'])),
|
||||
'title' => $result['title'],
|
||||
'orders' => $result['orders'],
|
||||
'total' => $this->currency->format($result['total'], $this->config->get('config_currency'))
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_date_start'])) {
|
||||
$url .= '&filter_date_start=' . $this->request->get['filter_date_start'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_date_end'])) {
|
||||
$url .= '&filter_date_end=' . $this->request->get['filter_date_end'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_group'])) {
|
||||
$url .= '&filter_group=' . $this->request->get['filter_group'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_order_status_id'])) {
|
||||
$url .= '&filter_order_status_id=' . $this->request->get['filter_order_status_id'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $order_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination'),
|
||||
'url' => $this->url->link('extension/opencart/report/sale_tax.report', 'user_token=' . $this->session->data['user_token'] . '&code=sale_tax' . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($order_total) ? (($page - 1) * $this->config->get('config_pagination')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination')) > ($order_total - $this->config->get('config_pagination'))) ? $order_total : ((($page - 1) * $this->config->get('config_pagination')) + $this->config->get('config_pagination')), $order_total, ceil($order_total / $this->config->get('config_pagination')));
|
||||
|
||||
$data['filter_date_start'] = $filter_date_start;
|
||||
$data['filter_date_end'] = $filter_date_end;
|
||||
$data['filter_group'] = $filter_group;
|
||||
$data['filter_order_status_id'] = $filter_order_status_id;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
return $this->load->view('extension/opencart/report/sale_tax_list', $data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user