first commit
This commit is contained in:
249
admininistrator/controller/localisation/address_format.php
Normal file
249
admininistrator/controller/localisation/address_format.php
Normal file
@ -0,0 +1,249 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Address Format
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class AddressFormat extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/address_format');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/address_format', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/address_format.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/address_format.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/address_format', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/address_format');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/address_format.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['address_formats'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/address_format');
|
||||
|
||||
$address_format_total = $this->model_localisation_address_format->getTotalAddressFormats($filter_data);
|
||||
|
||||
$results = $this->model_localisation_address_format->getAddressFormats($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['address_formats'][] = [
|
||||
'address_format_id' => $result['address_format_id'],
|
||||
'name' => $result['name'] . (($result['address_format_id'] == $this->config->get('config_address_format_id')) ? $this->language->get('text_default') : ''),
|
||||
'address_format' => nl2br($result['address_format']),
|
||||
'edit' => $this->url->link('localisation/address_format.form', 'user_token=' . $this->session->data['user_token'] . '&address_format_id=' . $result['address_format_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $address_format_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/address_format.list', 'user_token=' . $this->session->data['user_token'] . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($address_format_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($address_format_total - $this->config->get('config_pagination_admin'))) ? $address_format_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $address_format_total, ceil($address_format_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
return $this->load->view('localisation/address_format_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/address_format');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['address_format_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/address_format', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/address_format.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/address_format', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['address_format_id'])) {
|
||||
$this->load->model('localisation/address_format');
|
||||
|
||||
$address_format_info = $this->model_localisation_address_format->getAddressFormat($this->request->get['address_format_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['address_format_id'])) {
|
||||
$data['address_format_id'] = (int)$this->request->get['address_format_id'];
|
||||
} else {
|
||||
$data['address_format_id'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($address_format_info)) {
|
||||
$data['name'] = $address_format_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (!empty($address_format_info)) {
|
||||
$data['address_format'] = $address_format_info['address_format'];
|
||||
} else {
|
||||
$data['address_format'] = '';
|
||||
}
|
||||
|
||||
$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('localisation/address_format_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/address_format');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/address_format')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 1) || (oc_strlen($this->request->post['name']) > 128)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/address_format');
|
||||
|
||||
if (!$this->request->post['address_format_id']) {
|
||||
$json['address_format_id'] = $this->model_localisation_address_format->addAddressFormat($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_address_format->editAddressFormat($this->request->post['address_format_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/address_format');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/address_format')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('localisation/country');
|
||||
|
||||
foreach ($selected as $address_format_id) {
|
||||
if ($this->config->get('config_address_format_id') == $address_format_id) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
$country_total = $this->model_localisation_country->getTotalCountriesByAddressFormatId($address_format_id);
|
||||
|
||||
if ($country_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_country'), $country_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/address_format');
|
||||
|
||||
foreach ($selected as $address_format_id) {
|
||||
$this->model_localisation_address_format->deleteAddressFormat($address_format_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
489
admininistrator/controller/localisation/country.php
Normal file
489
admininistrator/controller/localisation/country.php
Normal file
@ -0,0 +1,489 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Country
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class Country extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/country');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$filter_name = (string)$this->request->get['filter_name'];
|
||||
} else {
|
||||
$filter_name = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_2'])) {
|
||||
$filter_iso_code_2 = (string)$this->request->get['filter_iso_code_2'];
|
||||
} else {
|
||||
$filter_iso_code_2 = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_3'])) {
|
||||
$filter_iso_code_3 = (string)$this->request->get['filter_iso_code_3'];
|
||||
} else {
|
||||
$filter_iso_code_3 = '';
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/country', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/country.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/country.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['filter_name'] = $filter_name;
|
||||
$data['filter_iso_code_2'] = $filter_iso_code_2;
|
||||
$data['filter_iso_code_3'] = $filter_iso_code_3;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/country', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/country');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$filter_name = (string)$this->request->get['filter_name'];
|
||||
} else {
|
||||
$filter_name = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_2'])) {
|
||||
$filter_iso_code_2 = (string)$this->request->get['filter_iso_code_2'];
|
||||
} else {
|
||||
$filter_iso_code_2 = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_3'])) {
|
||||
$filter_iso_code_3 = (string)$this->request->get['filter_iso_code_3'];
|
||||
} else {
|
||||
$filter_iso_code_3 = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_2'])) {
|
||||
$url .= '&filter_iso_code_2=' . urlencode(html_entity_decode($this->request->get['filter_iso_code_2'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_3'])) {
|
||||
$url .= '&filter_iso_code_3=' . urlencode(html_entity_decode($this->request->get['filter_iso_code_3'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/country.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['countries'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_name' => $filter_name,
|
||||
'filter_iso_code_2' => $filter_iso_code_2,
|
||||
'filter_iso_code_3' => $filter_iso_code_3,
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/country');
|
||||
|
||||
$country_total = $this->model_localisation_country->getTotalCountries($filter_data);
|
||||
|
||||
$results = $this->model_localisation_country->getCountries($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['countries'][] = [
|
||||
'country_id' => $result['country_id'],
|
||||
'name' => $result['name'] . (($result['country_id'] == $this->config->get('config_country_id')) ? $this->language->get('text_default') : ''),
|
||||
'status' => $result['status'],
|
||||
'iso_code_2' => $result['iso_code_2'],
|
||||
'iso_code_3' => $result['iso_code_3'],
|
||||
'edit' => $this->url->link('localisation/country.form', 'user_token=' . $this->session->data['user_token'] . '&country_id=' . $result['country_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_2'])) {
|
||||
$url .= '&filter_iso_code_2=' . urlencode(html_entity_decode($this->request->get['filter_iso_code_2'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_3'])) {
|
||||
$url .= '&filter_iso_code_3=' . urlencode(html_entity_decode($this->request->get['filter_iso_code_3'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/country.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
$data['sort_iso_code_2'] = $this->url->link('localisation/country.list', 'user_token=' . $this->session->data['user_token'] . '&sort=iso_code_2' . $url);
|
||||
$data['sort_iso_code_3'] = $this->url->link('localisation/country.list', 'user_token=' . $this->session->data['user_token'] . '&sort=iso_code_3' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_2'])) {
|
||||
$url .= '&filter_iso_code_2=' . urlencode(html_entity_decode($this->request->get['filter_iso_code_2'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_3'])) {
|
||||
$url .= '&filter_iso_code_3=' . urlencode(html_entity_decode($this->request->get['filter_iso_code_3'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $country_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/country.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($country_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($country_total - $this->config->get('config_pagination_admin'))) ? $country_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $country_total, ceil($country_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/country_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/country');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['country_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_2'])) {
|
||||
$url .= '&filter_iso_code_2=' . urlencode(html_entity_decode($this->request->get['filter_iso_code_2'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_iso_code_3'])) {
|
||||
$url .= '&filter_iso_code_3=' . urlencode(html_entity_decode($this->request->get['filter_iso_code_3'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/country', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/country.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/country', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['country_id'])) {
|
||||
$this->load->model('localisation/country');
|
||||
|
||||
$country_info = $this->model_localisation_country->getCountry($this->request->get['country_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['country_id'])) {
|
||||
$data['country_id'] = (int)$this->request->get['country_id'];
|
||||
} else {
|
||||
$data['country_id'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($country_info)) {
|
||||
$data['name'] = $country_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (!empty($country_info)) {
|
||||
$data['iso_code_2'] = $country_info['iso_code_2'];
|
||||
} else {
|
||||
$data['iso_code_2'] = '';
|
||||
}
|
||||
|
||||
if (!empty($country_info)) {
|
||||
$data['iso_code_3'] = $country_info['iso_code_3'];
|
||||
} else {
|
||||
$data['iso_code_3'] = '';
|
||||
}
|
||||
|
||||
$this->load->model('localisation/address_format');
|
||||
|
||||
$data['address_formats'] = $this->model_localisation_address_format->getAddressFormats();
|
||||
|
||||
if (!empty($country_info)) {
|
||||
$data['address_format_id'] = $country_info['address_format_id'];
|
||||
} else {
|
||||
$data['address_format_id'] = '';
|
||||
}
|
||||
|
||||
if (!empty($country_info)) {
|
||||
$data['postcode_required'] = $country_info['postcode_required'];
|
||||
} else {
|
||||
$data['postcode_required'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($country_info)) {
|
||||
$data['status'] = $country_info['status'];
|
||||
} else {
|
||||
$data['status'] = '1';
|
||||
}
|
||||
|
||||
$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('localisation/country_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/country');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/country')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 1) || (oc_strlen($this->request->post['name']) > 128)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/country');
|
||||
|
||||
if (!$this->request->post['country_id']) {
|
||||
$json['country_id'] = $this->model_localisation_country->addCountry($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_country->editCountry($this->request->post['country_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/country');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/country')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('setting/store');
|
||||
$this->load->model('customer/customer');
|
||||
$this->load->model('localisation/zone');
|
||||
$this->load->model('localisation/geo_zone');
|
||||
|
||||
foreach ($selected as $country_id) {
|
||||
if ($this->config->get('config_country_id') == $country_id) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
$store_total = $this->model_setting_store->getTotalStoresByCountryId($country_id);
|
||||
|
||||
if ($store_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_store'), $store_total);
|
||||
}
|
||||
|
||||
$address_total = $this->model_customer_customer->getTotalAddressesByCountryId($country_id);
|
||||
|
||||
if ($address_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_address'), $address_total);
|
||||
}
|
||||
|
||||
$zone_total = $this->model_localisation_zone->getTotalZonesByCountryId($country_id);
|
||||
|
||||
if ($zone_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_zone'), $zone_total);
|
||||
}
|
||||
|
||||
$zone_to_geo_zone_total = $this->model_localisation_geo_zone->getTotalZoneToGeoZoneByCountryId($country_id);
|
||||
|
||||
if ($zone_to_geo_zone_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_zone_to_geo_zone'), $zone_to_geo_zone_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/country');
|
||||
|
||||
foreach ($selected as $country_id) {
|
||||
$this->model_localisation_country->deleteCountry($country_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function country(): void {
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->get['country_id'])) {
|
||||
$country_id = (int)$this->request->get['country_id'];
|
||||
} else {
|
||||
$country_id = 0;
|
||||
}
|
||||
|
||||
$this->load->model('localisation/country');
|
||||
|
||||
$country_info = $this->model_localisation_country->getCountry($country_id);
|
||||
|
||||
if ($country_info) {
|
||||
$this->load->model('localisation/zone');
|
||||
|
||||
$json = [
|
||||
'country_id' => $country_info['country_id'],
|
||||
'name' => $country_info['name'],
|
||||
'iso_code_2' => $country_info['iso_code_2'],
|
||||
'iso_code_3' => $country_info['iso_code_3'],
|
||||
'address_format_id' => $country_info['address_format_id'],
|
||||
'postcode_required' => $country_info['postcode_required'],
|
||||
'zone' => $this->model_localisation_zone->getZonesByCountryId($country_id),
|
||||
'status' => $country_info['status']
|
||||
];
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
406
admininistrator/controller/localisation/currency.php
Normal file
406
admininistrator/controller/localisation/currency.php
Normal file
@ -0,0 +1,406 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Currency
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class Currency extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/currency');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/currency', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['refresh'] = $this->url->link('localisation/currency.refresh', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['add'] = $this->url->link('localisation/currency.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/currency.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/currency', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/currency');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'title';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/currency', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['action'] = $this->url->link('localisation/currency.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['currencies'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/currency');
|
||||
|
||||
$currency_total = $this->model_localisation_currency->getTotalCurrencies();
|
||||
|
||||
$results = $this->model_localisation_currency->getCurrencies($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['currencies'][] = [
|
||||
'currency_id' => $result['currency_id'],
|
||||
'title' => $result['title'] . (($result['code'] == $this->config->get('config_currency')) ? $this->language->get('text_default') : ''),
|
||||
'code' => $result['code'],
|
||||
'value' => $result['value'],
|
||||
'status' => $result['status'],
|
||||
'date_modified' => date($this->language->get('date_format_short'), strtotime($result['date_modified'])),
|
||||
'edit' => $this->url->link('localisation/currency.form', 'user_token=' . $this->session->data['user_token'] . '¤cy_id=' . $result['currency_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_title'] = $this->url->link('localisation/currency.list', 'user_token=' . $this->session->data['user_token'] . '&sort=title' . $url);
|
||||
$data['sort_code'] = $this->url->link('localisation/currency.list', 'user_token=' . $this->session->data['user_token'] . '&sort=code' . $url);
|
||||
$data['sort_value'] = $this->url->link('localisation/currency.list', 'user_token=' . $this->session->data['user_token'] . '&sort=value' . $url);
|
||||
$data['sort_status'] = $this->url->link('localisation/currency.list', 'user_token=' . $this->session->data['user_token'] . '&sort=status' . $url);
|
||||
$data['sort_date_modified'] = $this->url->link('localisation/currency.list', 'user_token=' . $this->session->data['user_token'] . '&sort=date_modified' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $currency_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/currency.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($currency_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($currency_total - $this->config->get('config_pagination_admin'))) ? $currency_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $currency_total, ceil($currency_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/currency_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/currency');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['currency_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/currency', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/currency.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/currency', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['currency_id'])) {
|
||||
$this->load->model('localisation/currency');
|
||||
|
||||
$currency_info = $this->model_localisation_currency->getCurrency($this->request->get['currency_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['currency_id'])) {
|
||||
$data['currency_id'] = (int)$this->request->get['currency_id'];
|
||||
} else {
|
||||
$data['currency_id'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($currency_info)) {
|
||||
$data['title'] = $currency_info['title'];
|
||||
} else {
|
||||
$data['title'] = '';
|
||||
}
|
||||
|
||||
if (!empty($currency_info)) {
|
||||
$data['code'] = $currency_info['code'];
|
||||
} else {
|
||||
$data['code'] = '';
|
||||
}
|
||||
|
||||
if (!empty($currency_info)) {
|
||||
$data['symbol_left'] = $currency_info['symbol_left'];
|
||||
} else {
|
||||
$data['symbol_left'] = '';
|
||||
}
|
||||
|
||||
if (!empty($currency_info)) {
|
||||
$data['symbol_right'] = $currency_info['symbol_right'];
|
||||
} else {
|
||||
$data['symbol_right'] = '';
|
||||
}
|
||||
|
||||
if (!empty($currency_info)) {
|
||||
$data['decimal_place'] = $currency_info['decimal_place'];
|
||||
} else {
|
||||
$data['decimal_place'] = '';
|
||||
}
|
||||
|
||||
if (!empty($currency_info)) {
|
||||
$data['value'] = $currency_info['value'];
|
||||
} else {
|
||||
$data['value'] = '';
|
||||
}
|
||||
|
||||
if (!empty($currency_info)) {
|
||||
$data['status'] = $currency_info['status'];
|
||||
} else {
|
||||
$data['status'] = '';
|
||||
}
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/currency_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/currency');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/currency')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['title']) < 3) || (oc_strlen($this->request->post['title']) > 32)) {
|
||||
$json['error']['title'] = $this->language->get('error_title');
|
||||
}
|
||||
|
||||
if (oc_strlen($this->request->post['code']) != 3) {
|
||||
$json['error']['code'] = $this->language->get('error_code');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/currency');
|
||||
|
||||
if (!$this->request->post['currency_id']) {
|
||||
$json['currency_id'] = $this->model_localisation_currency->addCurrency($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_currency->editCurrency($this->request->post['currency_id'], $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 refresh(): void {
|
||||
$this->load->language('localisation/currency');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/currency')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('setting/extension');
|
||||
|
||||
$extension_info = $this->model_setting_extension->getExtensionByCode('currency', $this->config->get('config_currency_engine'));
|
||||
|
||||
if (!$extension_info) {
|
||||
$json['error'] = $this->language->get('error_extension');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->controller('extension/' . $extension_info['extension'] . '/currency/' . $extension_info['code'] . '.currency', $this->config->get('config_currency'));
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function delete(): void {
|
||||
$this->load->language('localisation/currency');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/currency')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('localisation/currency');
|
||||
$this->load->model('setting/store');
|
||||
$this->load->model('sale/order');
|
||||
|
||||
foreach ($selected as $currency_id) {
|
||||
$currency_info = $this->model_localisation_currency->getCurrency($currency_id);
|
||||
|
||||
if ($currency_info) {
|
||||
if ($this->config->get('config_currency') == $currency_info['code']) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
$store_total = $this->model_setting_store->getTotalStoresByCurrency($currency_info['code']);
|
||||
|
||||
if ($store_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_store'), $store_total);
|
||||
}
|
||||
}
|
||||
|
||||
$order_total = $this->model_sale_order->getTotalOrdersByCurrencyId($currency_id);
|
||||
|
||||
if ($order_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_order'), $order_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
foreach ($selected as $currency_id) {
|
||||
$this->model_localisation_currency->deleteCurrency($currency_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
323
admininistrator/controller/localisation/geo_zone.php
Normal file
323
admininistrator/controller/localisation/geo_zone.php
Normal file
@ -0,0 +1,323 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Geo Zone
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class GeoZone extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/geo_zone');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/geo_zone', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/geo_zone.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/geo_zone.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/geo_zone', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/geo_zone');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/geo_zone.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['geo_zones'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/geo_zone');
|
||||
|
||||
$geo_zone_total = $this->model_localisation_geo_zone->getTotalGeoZones();
|
||||
|
||||
$results = $this->model_localisation_geo_zone->getGeoZones($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['geo_zones'][] = [
|
||||
'geo_zone_id' => $result['geo_zone_id'],
|
||||
'name' => $result['name'],
|
||||
'description' => $result['description'],
|
||||
'edit' => $this->url->link('localisation/geo_zone.form', 'user_token=' . $this->session->data['user_token'] . '&geo_zone_id=' . $result['geo_zone_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/geo_zone.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
$data['sort_description'] = $this->url->link('localisation/geo_zone.list', 'user_token=' . $this->session->data['user_token'] . '&sort=description' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $geo_zone_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/geo_zone.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($geo_zone_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($geo_zone_total - $this->config->get('config_pagination_admin'))) ? $geo_zone_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $geo_zone_total, ceil($geo_zone_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/geo_zone_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/geo_zone');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['geo_zone_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/geo_zone', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/geo_zone.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/geo_zone', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['geo_zone_id'])) {
|
||||
$this->load->model('localisation/geo_zone');
|
||||
|
||||
$geo_zone_info = $this->model_localisation_geo_zone->getGeoZone($this->request->get['geo_zone_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['geo_zone_id'])) {
|
||||
$data['geo_zone_id'] = (int)$this->request->get['geo_zone_id'];
|
||||
} else {
|
||||
$data['geo_zone_id'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($geo_zone_info)) {
|
||||
$data['name'] = $geo_zone_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (!empty($geo_zone_info)) {
|
||||
$data['description'] = $geo_zone_info['description'];
|
||||
} else {
|
||||
$data['description'] = '';
|
||||
}
|
||||
|
||||
$this->load->model('localisation/country');
|
||||
|
||||
$data['countries'] = $this->model_localisation_country->getCountries();
|
||||
|
||||
if (!empty($geo_zone_info)) {
|
||||
$data['zone_to_geo_zones'] = $this->model_localisation_geo_zone->getZoneToGeoZones($this->request->get['geo_zone_id']);
|
||||
} else {
|
||||
$data['zone_to_geo_zones'] = [];
|
||||
}
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/geo_zone_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/geo_zone');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/geo_zone')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 32)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['description']) < 3) || (oc_strlen($this->request->post['description']) > 255)) {
|
||||
$json['error']['description'] = $this->language->get('error_description');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/geo_zone');
|
||||
|
||||
if (!$this->request->post['geo_zone_id']) {
|
||||
$json['geo_zone_id'] = $this->model_localisation_geo_zone->addGeoZone($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_geo_zone->editGeoZone($this->request->post['geo_zone_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/geo_zone');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/geo_zone')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('localisation/tax_rate');
|
||||
|
||||
foreach ($selected as $geo_zone_id) {
|
||||
$tax_rate_total = $this->model_localisation_tax_rate->getTotalTaxRatesByGeoZoneId($geo_zone_id);
|
||||
|
||||
if ($tax_rate_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_tax_rate'), $tax_rate_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/geo_zone');
|
||||
|
||||
foreach ($selected as $geo_zone_id) {
|
||||
$this->model_localisation_geo_zone->deleteGeoZone($geo_zone_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
373
admininistrator/controller/localisation/language.php
Normal file
373
admininistrator/controller/localisation/language.php
Normal file
@ -0,0 +1,373 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Language
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class Language extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/language');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/language', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/language.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/language.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/language', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/language');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/language.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['languages'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$language_total = $this->model_localisation_language->getTotalLanguages();
|
||||
|
||||
$results = $this->model_localisation_language->getLanguages($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['languages'][] = [
|
||||
'language_id' => $result['language_id'],
|
||||
'name' => $result['name'] . (($result['code'] == $this->config->get('config_language')) ? $this->language->get('text_default') : ''),
|
||||
'code' => $result['code'],
|
||||
'status' => $result['status'],
|
||||
'sort_order' => $result['sort_order'],
|
||||
'edit' => $this->url->link('localisation/language.form', 'user_token=' . $this->session->data['user_token'] . '&language_id=' . $result['language_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/language.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
$data['sort_code'] = $this->url->link('localisation/language.list', 'user_token=' . $this->session->data['user_token'] . '&sort=code' . $url);
|
||||
$data['sort_sort_order'] = $this->url->link('localisation/language.list', 'user_token=' . $this->session->data['user_token'] . '&sort=sort_order' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $language_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/language.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($language_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($language_total - $this->config->get('config_pagination_admin'))) ? $language_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $language_total, ceil($language_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/language_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/language');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['language_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/language', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/language.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/language', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['language_id'])) {
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$language_info = $this->model_localisation_language->getLanguage($this->request->get['language_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['language_id'])) {
|
||||
$data['language_id'] = (int)$this->request->get['language_id'];
|
||||
} else {
|
||||
$data['language_id'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($language_info)) {
|
||||
$data['name'] = $language_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (!empty($language_info)) {
|
||||
$data['code'] = $language_info['code'];
|
||||
} else {
|
||||
$data['code'] = '';
|
||||
}
|
||||
|
||||
if (!empty($language_info)) {
|
||||
$data['locale'] = $language_info['locale'];
|
||||
} else {
|
||||
$data['locale'] = '';
|
||||
}
|
||||
|
||||
if (!empty($language_info)) {
|
||||
$data['extension'] = $language_info['extension'];
|
||||
} else {
|
||||
$data['extension'] = '';
|
||||
}
|
||||
|
||||
if (!empty($language_info)) {
|
||||
$data['sort_order'] = $language_info['sort_order'];
|
||||
} else {
|
||||
$data['sort_order'] = 1;
|
||||
}
|
||||
|
||||
if (!empty($language_info)) {
|
||||
$data['status'] = $language_info['status'];
|
||||
} else {
|
||||
$data['status'] = 1;
|
||||
}
|
||||
|
||||
$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('localisation/language_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/language');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/language')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 1) || (oc_strlen($this->request->post['name']) > 32)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['code']) < 2) || (oc_strlen($this->request->post['code']) > 5)) {
|
||||
$json['error']['code'] = $this->language->get('error_code');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['locale']) < 2) || (oc_strlen($this->request->post['locale']) > 255)) {
|
||||
$json['error']['locale'] = $this->language->get('error_locale');
|
||||
}
|
||||
|
||||
$language_info = $this->model_localisation_language->getLanguageByCode($this->request->post['code']);
|
||||
|
||||
if (!$this->request->post['language_id']) {
|
||||
if ($language_info) {
|
||||
$json['error']['warning'] = $this->language->get('error_exists');
|
||||
}
|
||||
} else {
|
||||
if ($language_info && ($this->request->post['language_id'] != $language_info['language_id'])) {
|
||||
$json['error']['warning'] = $this->language->get('error_exists');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
if (!$this->request->post['language_id']) {
|
||||
$json['language_id'] = $this->model_localisation_language->addLanguage($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_language->editLanguage($this->request->post['language_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/language');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/language')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('setting/store');
|
||||
$this->load->model('sale/order');
|
||||
|
||||
foreach ($selected as $language_id) {
|
||||
$language_info = $this->model_localisation_language->getLanguage($language_id);
|
||||
|
||||
if ($language_info) {
|
||||
if ($this->config->get('config_language') == $language_info['code']) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
if ($this->config->get('config_language_admin') == $language_info['code']) {
|
||||
$json['error'] = $this->language->get('error_admin');
|
||||
}
|
||||
|
||||
$store_total = $this->model_setting_store->getTotalStoresByLanguage($language_info['code']);
|
||||
|
||||
if ($store_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_store'), $store_total);
|
||||
}
|
||||
}
|
||||
|
||||
$order_total = $this->model_sale_order->getTotalOrdersByLanguageId($language_id);
|
||||
|
||||
if ($order_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_order'), $order_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
foreach ($selected as $language_id) {
|
||||
$this->model_localisation_language->deleteLanguage($language_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
323
admininistrator/controller/localisation/length_class.php
Normal file
323
admininistrator/controller/localisation/length_class.php
Normal file
@ -0,0 +1,323 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Length Class
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class LengthClass extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/length_class');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/length_class', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/length_class.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/length_class.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/length_class', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/length_class');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'title';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/length_class.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['length_classes'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/length_class');
|
||||
|
||||
$length_class_total = $this->model_localisation_length_class->getTotalLengthClasses();
|
||||
|
||||
$results = $this->model_localisation_length_class->getLengthClasses($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['length_classes'][] = [
|
||||
'length_class_id' => $result['length_class_id'],
|
||||
'title' => $result['title'] . (($result['length_class_id'] == $this->config->get('config_length_class_id')) ? $this->language->get('text_default') : ''),
|
||||
'unit' => $result['unit'],
|
||||
'value' => $result['value'],
|
||||
'edit' => $this->url->link('localisation/length_class.form', 'user_token=' . $this->session->data['user_token'] . '&length_class_id=' . $result['length_class_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_title'] = $this->url->link('localisation/length_class.list', 'user_token=' . $this->session->data['user_token'] . '&sort=title' . $url);
|
||||
$data['sort_unit'] = $this->url->link('localisation/length_class.list', 'user_token=' . $this->session->data['user_token'] . '&sort=unit' . $url);
|
||||
$data['sort_value'] = $this->url->link('localisation/length_class.list', 'user_token=' . $this->session->data['user_token'] . '&sort=value' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $length_class_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/length_class.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($length_class_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($length_class_total - $this->config->get('config_pagination_admin'))) ? $length_class_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $length_class_total, ceil($length_class_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/length_class_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/length_class');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['length_class_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/length_class', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/length_class.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/length_class', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['length_class_id'])) {
|
||||
$this->load->model('localisation/length_class');
|
||||
|
||||
$length_class_info = $this->model_localisation_length_class->getLengthClass($this->request->get['length_class_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['length_class_id'])) {
|
||||
$data['length_class_id'] = (int)$this->request->get['length_class_id'];
|
||||
} else {
|
||||
$data['length_class_id'] = 0;
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$data['languages'] = $this->model_localisation_language->getLanguages();
|
||||
|
||||
if (!empty($length_class_info)) {
|
||||
$data['length_class_description'] = $this->model_localisation_length_class->getDescriptions($this->request->get['length_class_id']);
|
||||
} else {
|
||||
$data['length_class_description'] = [];
|
||||
}
|
||||
|
||||
if (!empty($length_class_info)) {
|
||||
$data['value'] = $length_class_info['value'];
|
||||
} else {
|
||||
$data['value'] = '';
|
||||
}
|
||||
|
||||
$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('localisation/length_class_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/length_class');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/length_class')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
foreach ($this->request->post['length_class_description'] as $language_id => $value) {
|
||||
if ((oc_strlen($value['title']) < 3) || (oc_strlen($value['title']) > 32)) {
|
||||
$json['error']['title_' . $language_id] = $this->language->get('error_title');
|
||||
}
|
||||
|
||||
if (!$value['unit'] || (oc_strlen($value['unit']) > 4)) {
|
||||
$json['error']['unit_' . $language_id] = $this->language->get('error_unit');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/length_class');
|
||||
|
||||
if (!$this->request->post['length_class_id']) {
|
||||
$json['length_class_id'] = $this->model_localisation_length_class->addLengthClass($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_length_class->editLengthClass($this->request->post['length_class_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/length_class');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/length_class')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
foreach ($selected as $length_class_id) {
|
||||
if ($this->config->get('config_length_class_id') == $length_class_id) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
$product_total = $this->model_catalog_product->getTotalProductsByLengthClassId($length_class_id);
|
||||
|
||||
if ($product_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_product'), $product_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/length_class');
|
||||
|
||||
foreach ($selected as $length_class_id) {
|
||||
$this->model_localisation_length_class->deleteLengthClass($length_class_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
349
admininistrator/controller/localisation/location.php
Normal file
349
admininistrator/controller/localisation/location.php
Normal file
@ -0,0 +1,349 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Location
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class Location extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/location');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/location', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/location.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/location.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/location', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/location');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/location.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['locations'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/location');
|
||||
|
||||
$location_total = $this->model_localisation_location->getTotalLocations();
|
||||
|
||||
$results = $this->model_localisation_location->getLocations($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['locations'][] = [
|
||||
'location_id' => $result['location_id'],
|
||||
'name' => $result['name'],
|
||||
'address' => $result['address'],
|
||||
'edit' => $this->url->link('localisation/location.form', 'user_token=' . $this->session->data['user_token'] . '&location_id=' . $result['location_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/location.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
$data['sort_address'] = $this->url->link('localisation/location.list', 'user_token=' . $this->session->data['user_token'] . '&sort=address' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $location_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/location.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($location_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($location_total - $this->config->get('config_pagination_admin'))) ? $location_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $location_total, ceil($location_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/location_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/location');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['location_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/location', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/location.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/location', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['location_id'])) {
|
||||
$this->load->model('localisation/location');
|
||||
|
||||
$location_info = $this->model_localisation_location->getLocation($this->request->get['location_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['location_id'])) {
|
||||
$data['location_id'] = (int)$this->request->get['location_id'];
|
||||
} else {
|
||||
$data['location_id'] = 0;
|
||||
}
|
||||
|
||||
$this->load->model('setting/store');
|
||||
|
||||
if (!empty($location_info)) {
|
||||
$data['name'] = $location_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (!empty($location_info)) {
|
||||
$data['address'] = $location_info['address'];
|
||||
} else {
|
||||
$data['address'] = '';
|
||||
}
|
||||
|
||||
if (!empty($location_info)) {
|
||||
$data['geocode'] = $location_info['geocode'];
|
||||
} else {
|
||||
$data['geocode'] = '';
|
||||
}
|
||||
|
||||
if (!empty($location_info)) {
|
||||
$data['telephone'] = $location_info['telephone'];
|
||||
} else {
|
||||
$data['telephone'] = '';
|
||||
}
|
||||
|
||||
if (!empty($location_info)) {
|
||||
$data['image'] = $location_info['image'];
|
||||
} else {
|
||||
$data['image'] = '';
|
||||
}
|
||||
|
||||
$this->load->model('tool/image');
|
||||
|
||||
$data['placeholder'] = $this->model_tool_image->resize('no_image.png', 100, 100);
|
||||
|
||||
if (is_file(DIR_IMAGE . html_entity_decode($data['image'], ENT_QUOTES, 'UTF-8'))) {
|
||||
$data['thumb'] = $this->model_tool_image->resize(html_entity_decode($data['image'], ENT_QUOTES, 'UTF-8'), 100, 100);
|
||||
} else {
|
||||
$data['thumb'] = $data['placeholder'];
|
||||
}
|
||||
|
||||
if (!empty($location_info)) {
|
||||
$data['open'] = $location_info['open'];
|
||||
} else {
|
||||
$data['open'] = '';
|
||||
}
|
||||
|
||||
if (!empty($location_info)) {
|
||||
$data['comment'] = $location_info['comment'];
|
||||
} else {
|
||||
$data['comment'] = '';
|
||||
}
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/location_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/location');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/location')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 32)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['address']) < 3) || (oc_strlen($this->request->post['address']) > 128)) {
|
||||
$json['error']['address'] = $this->language->get('error_address');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['telephone']) < 3) || (oc_strlen($this->request->post['telephone']) > 32)) {
|
||||
$json['error']['telephone'] = $this->language->get('error_telephone');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/location');
|
||||
|
||||
if (!$this->request->post['location_id']) {
|
||||
$json['location_id'] = $this->model_localisation_location->addLocation($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_location->editLocation($this->request->post['location_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/location');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/location')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/location');
|
||||
|
||||
foreach ($selected as $location_id) {
|
||||
$this->model_localisation_location->deleteLocation($location_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
314
admininistrator/controller/localisation/order_status.php
Normal file
314
admininistrator/controller/localisation/order_status.php
Normal file
@ -0,0 +1,314 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Order Status
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class OrderStatus extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/order_status');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/order_status', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/order_status.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/order_status.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/order_status', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/order_status');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/order_status.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['order_statuses'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
$order_status_total = $this->model_localisation_order_status->getTotalOrderStatuses();
|
||||
|
||||
$results = $this->model_localisation_order_status->getOrderStatuses($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['order_statuses'][] = [
|
||||
'order_status_id' => $result['order_status_id'],
|
||||
'name' => $result['name'] . (($result['order_status_id'] == $this->config->get('config_order_status_id')) ? $this->language->get('text_default') : ''),
|
||||
'edit' => $this->url->link('localisation/order_status.form', 'user_token=' . $this->session->data['user_token'] . '&order_status_id=' . $result['order_status_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/order_status.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $order_status_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/order_status.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($order_status_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($order_status_total - $this->config->get('config_pagination_admin'))) ? $order_status_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $order_status_total, ceil($order_status_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/order_status_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/order_status');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['order_status_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/order_status', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/order_status.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/order_status', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['order_status_id'])) {
|
||||
$data['order_status_id'] = (int)$this->request->get['order_status_id'];
|
||||
} else {
|
||||
$data['order_status_id'] = 0;
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$data['languages'] = $this->model_localisation_language->getLanguages();
|
||||
|
||||
if (isset($this->request->get['order_status_id'])) {
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
$data['order_status'] = $this->model_localisation_order_status->getDescriptions($this->request->get['order_status_id']);
|
||||
} else {
|
||||
$data['order_status'] = [];
|
||||
}
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/order_status_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/order_status');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/order_status')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
foreach ($this->request->post['order_status'] as $language_id => $value) {
|
||||
if ((oc_strlen($value['name']) < 3) || (oc_strlen($value['name']) > 32)) {
|
||||
$json['error']['name_' . $language_id] = $this->language->get('error_name');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
if (!$this->request->post['order_status_id']) {
|
||||
$json['order_status_id'] = $this->model_localisation_order_status->addOrderStatus($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_order_status->editOrderStatus($this->request->post['order_status_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/order_status');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/order_status')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('setting/store');
|
||||
$this->load->model('sale/order');
|
||||
|
||||
foreach ($selected as $order_status_id) {
|
||||
if ($this->config->get('config_order_status_id') == $order_status_id) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
$order_total = $this->model_sale_order->getTotalOrdersByOrderStatusId($order_status_id);
|
||||
|
||||
if ($order_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_order'), $order_total);
|
||||
}
|
||||
|
||||
$order_total = $this->model_sale_order->getTotalHistoriesByOrderStatusId($order_status_id);
|
||||
|
||||
if ($order_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_order'), $order_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/order_status');
|
||||
|
||||
foreach ($selected as $order_status_id) {
|
||||
$this->model_localisation_order_status->deleteOrderStatus($order_status_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
302
admininistrator/controller/localisation/return_action.php
Normal file
302
admininistrator/controller/localisation/return_action.php
Normal file
@ -0,0 +1,302 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Return Action
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class ReturnAction extends \Opencart\System\Engine\Controller {
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/return_action');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/return_action', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/return_action.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/return_action.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/return_action', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/return_action');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/return_action.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['return_actions'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/return_action');
|
||||
|
||||
$return_action_total = $this->model_localisation_return_action->getTotalReturnActions();
|
||||
|
||||
$results = $this->model_localisation_return_action->getReturnActions($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['return_actions'][] = [
|
||||
'return_action_id' => $result['return_action_id'],
|
||||
'name' => $result['name'],
|
||||
'edit' => $this->url->link('localisation/return_action.form', 'user_token=' . $this->session->data['user_token'] . '&return_action_id=' . $result['return_action_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/return_action.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $return_action_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/return_action.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($return_action_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($return_action_total - $this->config->get('config_pagination_admin'))) ? $return_action_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $return_action_total, ceil($return_action_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/return_action_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/return_action');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['return_action_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/return_action', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/return_action.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/return_action', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['return_action_id'])) {
|
||||
$data['return_action_id'] = (int)$this->request->get['return_action_id'];
|
||||
} else {
|
||||
$data['return_action_id'] = 0;
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$data['languages'] = $this->model_localisation_language->getLanguages();
|
||||
|
||||
if (isset($this->request->get['return_action_id'])) {
|
||||
$this->load->model('localisation/return_action');
|
||||
|
||||
$data['return_action'] = $this->model_localisation_return_action->getDescriptions($this->request->get['return_action_id']);
|
||||
} else {
|
||||
$data['return_action'] = [];
|
||||
}
|
||||
|
||||
$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('localisation/return_action_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/return_action');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/return_action')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
foreach ($this->request->post['return_action'] as $language_id => $value) {
|
||||
if ((oc_strlen($value['name']) < 3) || (oc_strlen($value['name']) > 64)) {
|
||||
$json['error']['name_' . $language_id] = $this->language->get('error_name');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/return_action');
|
||||
|
||||
if (!$this->request->post['return_action_id']) {
|
||||
$json['return_action_id'] = $this->model_localisation_return_action->addReturnAction($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_return_action->editReturnAction($this->request->post['return_action_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/return_action');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/return_action')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('sale/returns');
|
||||
|
||||
foreach ($selected as $return_action_id) {
|
||||
$return_total = $this->model_sale_returns->getTotalReturnsByReturnActionId($return_action_id);
|
||||
|
||||
if ($return_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_return'), $return_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/return_action');
|
||||
|
||||
foreach ($selected as $return_action_id) {
|
||||
$this->model_localisation_return_action->deleteReturnAction($return_action_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
301
admininistrator/controller/localisation/return_reason.php
Normal file
301
admininistrator/controller/localisation/return_reason.php
Normal file
@ -0,0 +1,301 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Return Reason
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class ReturnReason extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/return_reason');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/return_reason', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/return_reason.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/return_reason.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/return_reason', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/return_reason');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/return_reason.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['return_reasons'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/return_reason');
|
||||
|
||||
$return_reason_total = $this->model_localisation_return_reason->getTotalReturnReasons();
|
||||
|
||||
$results = $this->model_localisation_return_reason->getReturnReasons($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['return_reasons'][] = [
|
||||
'return_reason_id' => $result['return_reason_id'],
|
||||
'name' => $result['name'],
|
||||
'edit' => $this->url->link('localisation/return_reason.form', 'user_token=' . $this->session->data['user_token'] . '&return_reason_id=' . $result['return_reason_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/return_reason.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $return_reason_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/return_reason.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($return_reason_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($return_reason_total - $this->config->get('config_pagination_admin'))) ? $return_reason_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $return_reason_total, ceil($return_reason_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/return_reason_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/return_reason');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['return_reason_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/return_reason', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/return_reason.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/return_reason', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['return_reason_id'])) {
|
||||
$data['return_reason_id'] = (int)$this->request->get['return_reason_id'];
|
||||
} else {
|
||||
$data['return_reason_id'] = 0;
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$data['languages'] = $this->model_localisation_language->getLanguages();
|
||||
|
||||
if (isset($this->request->get['return_reason_id'])) {
|
||||
$this->load->model('localisation/return_reason');
|
||||
|
||||
$data['return_reason'] = $this->model_localisation_return_reason->getDescriptions($this->request->get['return_reason_id']);
|
||||
} else {
|
||||
$data['return_reason'] = [];
|
||||
}
|
||||
|
||||
$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('localisation/return_reason_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/return_reason');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/return_reason')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
foreach ($this->request->post['return_reason'] as $language_id => $value) {
|
||||
if ((oc_strlen($value['name']) < 3) || (oc_strlen($value['name']) > 128)) {
|
||||
$json['error']['name_' . $language_id] = $this->language->get('error_name');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/return_reason');
|
||||
|
||||
if (!$this->request->post['return_reason_id']) {
|
||||
$json['return_reason_id'] = $this->model_localisation_return_reason->addReturnReason($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_return_reason->editReturnReason($this->request->post['return_reason_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/return_reason');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/return_reason')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('sale/returns');
|
||||
|
||||
foreach ($selected as $return_reason_id) {
|
||||
$return_total = $this->model_sale_returns->getTotalReturnsByReturnReasonId($return_reason_id);
|
||||
|
||||
if ($return_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_return'), $return_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/return_reason');
|
||||
|
||||
foreach ($selected as $return_reason_id) {
|
||||
$this->model_localisation_return_reason->deleteReturnReason($return_reason_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
311
admininistrator/controller/localisation/return_status.php
Normal file
311
admininistrator/controller/localisation/return_status.php
Normal file
@ -0,0 +1,311 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Return Status
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class ReturnStatus extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/return_status');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/return_status', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/return_status.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/return_status.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/return_status', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/return_status');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/return_status.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['return_statuses'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/return_status');
|
||||
|
||||
$return_status_total = $this->model_localisation_return_status->getTotalReturnStatuses();
|
||||
|
||||
$results = $this->model_localisation_return_status->getReturnStatuses($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['return_statuses'][] = [
|
||||
'return_status_id' => $result['return_status_id'],
|
||||
'name' => $result['name'] . (($result['return_status_id'] == $this->config->get('config_return_status_id')) ? $this->language->get('text_default') : ''),
|
||||
'edit' => $this->url->link('localisation/return_status.form', 'user_token=' . $this->session->data['user_token'] . '&return_status_id=' . $result['return_status_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/return_status.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $return_status_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/return_status.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($return_status_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($return_status_total - $this->config->get('config_pagination_admin'))) ? $return_status_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $return_status_total, ceil($return_status_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/return_status_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/return_status');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['return_status_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/return_status', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/return_status.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/return_status', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['return_status_id'])) {
|
||||
$data['return_status_id'] = (int)$this->request->get['return_status_id'];
|
||||
} else {
|
||||
$data['return_status_id'] = 0;
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$data['languages'] = $this->model_localisation_language->getLanguages();
|
||||
|
||||
if (isset($this->request->get['return_status_id'])) {
|
||||
$this->load->model('localisation/return_status');
|
||||
|
||||
$data['return_status'] = $this->model_localisation_return_status->getDescriptions($this->request->get['return_status_id']);
|
||||
} else {
|
||||
$data['return_status'] = [];
|
||||
}
|
||||
|
||||
$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('localisation/return_status_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/return_status');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/return_status')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
foreach ($this->request->post['return_status'] as $language_id => $value) {
|
||||
if ((oc_strlen($value['name']) < 3) || (oc_strlen($value['name']) > 32)) {
|
||||
$json['error']['name_' . $language_id] = $this->language->get('error_name');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/return_status');
|
||||
|
||||
if (!$this->request->post['return_status_id']) {
|
||||
$json['return_status_id'] = $this->model_localisation_return_status->addReturnStatus($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_return_status->editReturnStatus($this->request->post['return_status_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/return_status');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/return_status')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('sale/returns');
|
||||
|
||||
foreach ($this->request->post['selected'] as $return_status_id) {
|
||||
if ($this->config->get('config_return_status_id') == $return_status_id) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
$return_total = $this->model_sale_returns->getTotalReturnsByReturnStatusId($return_status_id);
|
||||
|
||||
if ($return_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_return'), $return_total);
|
||||
}
|
||||
|
||||
$return_total = $this->model_sale_returns->getTotalHistoriesByReturnStatusId($return_status_id);
|
||||
|
||||
if ($return_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_return'), $return_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/return_status');
|
||||
|
||||
foreach ($selected as $return_status_id) {
|
||||
$this->model_localisation_return_status->deleteReturnStatus($return_status_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
301
admininistrator/controller/localisation/stock_status.php
Normal file
301
admininistrator/controller/localisation/stock_status.php
Normal file
@ -0,0 +1,301 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Stock Status
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class StockStatus extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/stock_status');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/stock_status', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/stock_status.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/stock_status.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/stock_status', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/stock_status');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/stock_status.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['stock_statuses'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/stock_status');
|
||||
|
||||
$stock_status_total = $this->model_localisation_stock_status->getTotalStockStatuses();
|
||||
|
||||
$results = $this->model_localisation_stock_status->getStockStatuses($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['stock_statuses'][] = [
|
||||
'stock_status_id' => $result['stock_status_id'],
|
||||
'name' => $result['name'],
|
||||
'edit' => $this->url->link('localisation/stock_status.form', 'user_token=' . $this->session->data['user_token'] . '&stock_status_id=' . $result['stock_status_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/stock_status.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $stock_status_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/stock_status.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($stock_status_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($stock_status_total - $this->config->get('config_pagination_admin'))) ? $stock_status_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $stock_status_total, ceil($stock_status_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/stock_status_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/stock_status');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['stock_status_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/stock_status', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/stock_status.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/stock_status', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['stock_status_id'])) {
|
||||
$data['stock_status_id'] = (int)$this->request->get['stock_status_id'];
|
||||
} else {
|
||||
$data['stock_status_id'] = 0;
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$data['languages'] = $this->model_localisation_language->getLanguages();
|
||||
|
||||
if (isset($this->request->get['stock_status_id'])) {
|
||||
$this->load->model('localisation/stock_status');
|
||||
|
||||
$data['stock_status'] = $this->model_localisation_stock_status->getDescriptions($this->request->get['stock_status_id']);
|
||||
} else {
|
||||
$data['stock_status'] = [];
|
||||
}
|
||||
|
||||
$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('localisation/stock_status_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/stock_status');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/stock_status')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
foreach ($this->request->post['stock_status'] as $language_id => $value) {
|
||||
if ((oc_strlen($value['name']) < 3) || (oc_strlen($value['name']) > 32)) {
|
||||
$json['error']['name_' . $language_id] = $this->language->get('error_name');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/stock_status');
|
||||
|
||||
if (!$this->request->post['stock_status_id']) {
|
||||
$json['stock_status_id'] = $this->model_localisation_stock_status->addStockStatus($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_stock_status->editStockStatus($this->request->post['stock_status_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/stock_status');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/stock_status')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
foreach ($selected as $stock_status_id) {
|
||||
$product_total = $this->model_catalog_product->getTotalProductsByStockStatusId($stock_status_id);
|
||||
|
||||
if ($product_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_product'), $product_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/stock_status');
|
||||
|
||||
foreach ($selected as $stock_status_id) {
|
||||
$this->model_localisation_stock_status->deleteStockStatus($stock_status_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
314
admininistrator/controller/localisation/subscription_status.php
Normal file
314
admininistrator/controller/localisation/subscription_status.php
Normal file
@ -0,0 +1,314 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Subscription Status
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class SubscriptionStatus extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/subscription_status');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/subscription_status', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/subscription_status.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/subscription_status.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/subscription_status', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/subscription_status');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/subscription_status.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['subscription_statuses'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/subscription_status');
|
||||
|
||||
$subscription_status_total = $this->model_localisation_subscription_status->getTotalSubscriptionStatuses();
|
||||
|
||||
$results = $this->model_localisation_subscription_status->getSubscriptionStatuses($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['subscription_statuses'][] = [
|
||||
'subscription_status_id' => $result['subscription_status_id'],
|
||||
'name' => $result['name'] . (($result['subscription_status_id'] == $this->config->get('config_subscription_status_id')) ? $this->language->get('text_default') : ''),
|
||||
'edit' => $this->url->link('localisation/subscription_status.form', 'user_token=' . $this->session->data['user_token'] . '&subscription_status_id=' . $result['subscription_status_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/subscription_status.list', 'user_token=' . $this->session->data['user_token'] . '&sort=name' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $subscription_status_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/subscription_status.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($subscription_status_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($subscription_status_total - $this->config->get('config_pagination_admin'))) ? $subscription_status_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $subscription_status_total, ceil($subscription_status_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/subscription_status_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/subscription_status');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['subscription_status_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/subscription_status', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/subscription_status.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/subscription_status', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['subscription_status_id'])) {
|
||||
$data['subscription_status_id'] = (int)$this->request->get['subscription_status_id'];
|
||||
} else {
|
||||
$data['subscription_status_id'] = 0;
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$data['languages'] = $this->model_localisation_language->getLanguages();
|
||||
|
||||
if (isset($this->request->get['subscription_status_id'])) {
|
||||
$this->load->model('localisation/subscription_status');
|
||||
|
||||
$data['subscription_status'] = $this->model_localisation_subscription_status->getDescriptions($this->request->get['subscription_status_id']);
|
||||
} else {
|
||||
$data['subscription_status'] = [];
|
||||
}
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/subscription_status_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/subscription_status');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/subscription_status')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
foreach ($this->request->post['subscription_status'] as $language_id => $value) {
|
||||
if ((oc_strlen($value['name']) < 3) || (oc_strlen($value['name']) > 32)) {
|
||||
$json['error']['name_' . $language_id] = $this->language->get('error_name');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/subscription_status');
|
||||
|
||||
if (!$this->request->post['subscription_status_id']) {
|
||||
$json['subscription_status_id'] = $this->model_localisation_subscription_status->addSubscriptionStatus($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_subscription_status->editSubscriptionStatus($this->request->post['subscription_status_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/subscription_status');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/subscription_status')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('setting/store');
|
||||
$this->load->model('sale/subscription');
|
||||
|
||||
foreach ($selected as $subscription_status_id) {
|
||||
if ($this->config->get('config_subscription_status_id') == $subscription_status_id) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
$subscription_total = $this->model_sale_subscription->getTotalSubscriptionsBySubscriptionStatusId($subscription_status_id);
|
||||
|
||||
if ($subscription_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_subscription'), $subscription_total);
|
||||
}
|
||||
|
||||
$subscription_total = $this->model_sale_subscription->getTotalHistoriesBySubscriptionStatusId($subscription_status_id);
|
||||
|
||||
if ($subscription_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_subscription'), $subscription_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/subscription_status');
|
||||
|
||||
foreach ($selected as $subscription_status_id) {
|
||||
$this->model_localisation_subscription_status->deleteSubscriptionStatus($subscription_status_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
319
admininistrator/controller/localisation/tax_class.php
Normal file
319
admininistrator/controller/localisation/tax_class.php
Normal file
@ -0,0 +1,319 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Tax Class
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class TaxClass extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/tax_class');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/tax_class', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/tax_class.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/tax_class.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/tax_class', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/tax_class');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'title';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/tax_class.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['tax_classes'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/tax_class');
|
||||
|
||||
$tax_class_total = $this->model_localisation_tax_class->getTotalTaxClasses();
|
||||
|
||||
$results = $this->model_localisation_tax_class->getTaxClasses($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['tax_classes'][] = [
|
||||
'tax_class_id' => $result['tax_class_id'],
|
||||
'title' => $result['title'],
|
||||
'edit' => $this->url->link('localisation/tax_class.form', 'user_token=' . $this->session->data['user_token'] . '&tax_class_id=' . $result['tax_class_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_title'] = $this->url->link('localisation/tax_class.list', 'user_token=' . $this->session->data['user_token'] . '&sort=title' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $tax_class_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/tax_class.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($tax_class_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($tax_class_total - $this->config->get('config_pagination_admin'))) ? $tax_class_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $tax_class_total, ceil($tax_class_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/tax_class_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/tax_class');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['tax_class_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/tax_class', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/tax_class.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/tax_class', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['tax_class_id'])) {
|
||||
$this->load->model('localisation/tax_class');
|
||||
|
||||
$tax_class_info = $this->model_localisation_tax_class->getTaxClass($this->request->get['tax_class_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tax_class_id'])) {
|
||||
$data['tax_class_id'] = (int)$this->request->get['tax_class_id'];
|
||||
} else {
|
||||
$data['tax_class_id'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($tax_class_info)) {
|
||||
$data['title'] = $tax_class_info['title'];
|
||||
} else {
|
||||
$data['title'] = '';
|
||||
}
|
||||
|
||||
if (!empty($tax_class_info)) {
|
||||
$data['description'] = $tax_class_info['description'];
|
||||
} else {
|
||||
$data['description'] = '';
|
||||
}
|
||||
|
||||
$this->load->model('localisation/tax_rate');
|
||||
|
||||
$data['tax_rates'] = $this->model_localisation_tax_rate->getTaxRates();
|
||||
|
||||
if (isset($this->request->get['tax_class_id'])) {
|
||||
$data['tax_rules'] = $this->model_localisation_tax_class->getTaxRules($this->request->get['tax_class_id']);
|
||||
} else {
|
||||
$data['tax_rules'] = [];
|
||||
}
|
||||
|
||||
$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('localisation/tax_class_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/tax_class');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/tax_class')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['title']) < 3) || (oc_strlen($this->request->post['title']) > 32)) {
|
||||
$json['error']['title'] = $this->language->get('error_title');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['description']) < 3) || (oc_strlen($this->request->post['description']) > 255)) {
|
||||
$json['error']['description'] = $this->language->get('error_description');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/tax_class');
|
||||
|
||||
if (!$this->request->post['tax_class_id']) {
|
||||
$json['tax_class_id'] = $this->model_localisation_tax_class->addTaxClass($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_tax_class->editTaxClass($this->request->post['tax_class_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/tax_class');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/tax_class')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
foreach ($selected as $tax_class_id) {
|
||||
$product_total = $this->model_catalog_product->getTotalProductsByTaxClassId($tax_class_id);
|
||||
|
||||
if ($product_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_product'), $product_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/tax_class');
|
||||
|
||||
foreach ($selected as $tax_class_id) {
|
||||
$this->model_localisation_tax_class->deleteTaxClass($tax_class_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
345
admininistrator/controller/localisation/tax_rate.php
Normal file
345
admininistrator/controller/localisation/tax_rate.php
Normal file
@ -0,0 +1,345 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Tax Rate
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class TaxRate extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/tax_rate');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/tax_rate', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/tax_rate.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/tax_rate.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/tax_rate', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/tax_rate');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'tr.name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/tax_rate.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['tax_rates'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/tax_rate');
|
||||
|
||||
$tax_rate_total = $this->model_localisation_tax_rate->getTotalTaxRates();
|
||||
|
||||
$results = $this->model_localisation_tax_rate->getTaxRates($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['tax_rates'][] = [
|
||||
'tax_rate_id' => $result['tax_rate_id'],
|
||||
'name' => $result['name'],
|
||||
'rate' => $result['rate'],
|
||||
'type' => ($result['type'] == 'F' ? $this->language->get('text_amount') : $this->language->get('text_percent')),
|
||||
'geo_zone' => $result['geo_zone'],
|
||||
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
|
||||
'date_modified' => date($this->language->get('date_format_short'), strtotime($result['date_modified'])),
|
||||
'edit' => $this->url->link('localisation/tax_rate.form', 'user_token=' . $this->session->data['user_token'] . '&tax_rate_id=' . $result['tax_rate_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_name'] = $this->url->link('localisation/tax_rate.list', 'user_token=' . $this->session->data['user_token'] . '&sort=tr.name' . $url);
|
||||
$data['sort_rate'] = $this->url->link('localisation/tax_rate.list', 'user_token=' . $this->session->data['user_token'] . '&sort=tr.rate' . $url);
|
||||
$data['sort_type'] = $this->url->link('localisation/tax_rate.list', 'user_token=' . $this->session->data['user_token'] . '&sort=tr.type' . $url);
|
||||
$data['sort_geo_zone'] = $this->url->link('localisation/tax_rate.list', 'user_token=' . $this->session->data['user_token'] . '&sort=gz.name' . $url);
|
||||
$data['sort_date_added'] = $this->url->link('localisation/tax_rate.list', 'user_token=' . $this->session->data['user_token'] . '&sort=tr.date_added' . $url);
|
||||
$data['sort_date_modified'] = $this->url->link('localisation/tax_rate.list', 'user_token=' . $this->session->data['user_token'] . '&sort=tr.date_modified' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $tax_rate_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/tax_rate.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($tax_rate_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($tax_rate_total - $this->config->get('config_pagination_admin'))) ? $tax_rate_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $tax_rate_total, ceil($tax_rate_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/tax_rate_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/tax_rate');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['tax_rate_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/tax_rate', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/tax_rate.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/tax_rate', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['tax_rate_id'])) {
|
||||
$this->load->model('localisation/tax_rate');
|
||||
|
||||
$tax_rate_info = $this->model_localisation_tax_rate->getTaxRate($this->request->get['tax_rate_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['tax_rate_id'])) {
|
||||
$data['tax_rate_id'] = (int)$this->request->get['tax_rate_id'];
|
||||
} else {
|
||||
$data['tax_rate_id'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($tax_rate_info)) {
|
||||
$data['name'] = $tax_rate_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (!empty($tax_rate_info)) {
|
||||
$data['rate'] = $tax_rate_info['rate'];
|
||||
} else {
|
||||
$data['rate'] = '';
|
||||
}
|
||||
|
||||
if (!empty($tax_rate_info)) {
|
||||
$data['type'] = $tax_rate_info['type'];
|
||||
} else {
|
||||
$data['type'] = '';
|
||||
}
|
||||
|
||||
$this->load->model('customer/customer_group');
|
||||
|
||||
$data['customer_groups'] = $this->model_customer_customer_group->getCustomerGroups();
|
||||
|
||||
if (isset($this->request->get['tax_rate_id'])) {
|
||||
$data['tax_rate_customer_group'] = $this->model_localisation_tax_rate->getCustomerGroups($this->request->get['tax_rate_id']);
|
||||
} else {
|
||||
$data['tax_rate_customer_group'] = [$this->config->get('config_customer_group_id')];
|
||||
}
|
||||
|
||||
$this->load->model('localisation/geo_zone');
|
||||
|
||||
$data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
|
||||
|
||||
if (!empty($tax_rate_info)) {
|
||||
$data['geo_zone_id'] = $tax_rate_info['geo_zone_id'];
|
||||
} else {
|
||||
$data['geo_zone_id'] = '';
|
||||
}
|
||||
|
||||
$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('localisation/tax_rate_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/tax_rate');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/tax_rate')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 32)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$this->request->post['rate']) {
|
||||
$json['error']['rate'] = $this->language->get('error_rate');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/tax_rate');
|
||||
|
||||
if (!$this->request->post['tax_rate_id']) {
|
||||
$json['tax_rate_id'] = $this->model_localisation_tax_rate->addTaxRate($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_tax_rate->editTaxRate($this->request->post['tax_rate_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/tax_rate');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/tax_rate')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('localisation/tax_class');
|
||||
|
||||
foreach ($this->request->post['selected'] as $tax_rate_id) {
|
||||
$tax_rule_total = $this->model_localisation_tax_class->getTotalTaxRulesByTaxRateId($tax_rate_id);
|
||||
|
||||
if ($tax_rule_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_tax_rule'), $tax_rule_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/tax_rate');
|
||||
|
||||
foreach ($selected as $tax_rate_id) {
|
||||
$this->model_localisation_tax_rate->deleteTaxRate($tax_rate_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
321
admininistrator/controller/localisation/weight_class.php
Normal file
321
admininistrator/controller/localisation/weight_class.php
Normal file
@ -0,0 +1,321 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Weight Class
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class WeightClass extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/weight_class');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/weight_class', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/weight_class.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/weight_class.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/weight_class', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/weight_class');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'title';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/weight_class.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['weight_classes'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/weight_class');
|
||||
|
||||
$weight_class_total = $this->model_localisation_weight_class->getTotalWeightClasses();
|
||||
|
||||
$results = $this->model_localisation_weight_class->getWeightClasses($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['weight_classes'][] = [
|
||||
'weight_class_id' => $result['weight_class_id'],
|
||||
'title' => $result['title'] . (($result['weight_class_id'] == $this->config->get('config_weight_class_id')) ? $this->language->get('text_default') : ''),
|
||||
'unit' => $result['unit'],
|
||||
'value' => $result['value'],
|
||||
'edit' => $this->url->link('localisation/weight_class.form', 'user_token=' . $this->session->data['user_token'] . '&weight_class_id=' . $result['weight_class_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_title'] = $this->url->link('localisation/weight_class.list', 'user_token=' . $this->session->data['user_token'] . '&sort=title' . $url);
|
||||
$data['sort_unit'] = $this->url->link('localisation/weight_class.list', 'user_token=' . $this->session->data['user_token'] . '&sort=unit' . $url);
|
||||
$data['sort_value'] = $this->url->link('localisation/weight_class.list', 'user_token=' . $this->session->data['user_token'] . '&sort=value' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $weight_class_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/weight_class.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($weight_class_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($weight_class_total - $this->config->get('config_pagination_admin'))) ? $weight_class_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $weight_class_total, ceil($weight_class_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/weight_class_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/weight_class');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['weight_class_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/weight_class', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/weight_class.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/weight_class', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['weight_class_id'])) {
|
||||
$this->load->model('localisation/weight_class');
|
||||
|
||||
$weight_class_info = $this->model_localisation_weight_class->getWeightClass($this->request->get['weight_class_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['weight_class_id'])) {
|
||||
$data['weight_class_id'] = (int)$this->request->get['weight_class_id'];
|
||||
} else {
|
||||
$data['weight_class_id'] = 0;
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$data['languages'] = $this->model_localisation_language->getLanguages();
|
||||
|
||||
if (isset($this->request->get['weight_class_id'])) {
|
||||
$data['weight_class_description'] = $this->model_localisation_weight_class->getDescriptions($this->request->get['weight_class_id']);
|
||||
} else {
|
||||
$data['weight_class_description'] = [];
|
||||
}
|
||||
|
||||
if (!empty($weight_class_info)) {
|
||||
$data['value'] = $weight_class_info['value'];
|
||||
} else {
|
||||
$data['value'] = '';
|
||||
}
|
||||
|
||||
$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('localisation/weight_class_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/weight_class');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/weight_class')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
foreach ($this->request->post['weight_class_description'] as $language_id => $value) {
|
||||
if ((oc_strlen($value['title']) < 3) || (oc_strlen($value['title']) > 32)) {
|
||||
$json['error']['title_' . $language_id] = $this->language->get('error_title');
|
||||
}
|
||||
|
||||
if (!$value['unit'] || (oc_strlen($value['unit']) > 4)) {
|
||||
$json['error']['unit_' . $language_id] = $this->language->get('error_unit');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/weight_class');
|
||||
|
||||
if (!$this->request->post['weight_class_id']) {
|
||||
$json['weight_class_id'] = $this->model_localisation_weight_class->addWeightClass($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_weight_class->editWeightClass($this->request->post['weight_class_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/weight_class');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/weight_class')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
foreach ($selected as $weight_class_id) {
|
||||
if ($this->config->get('config_weight_class_id') == $weight_class_id) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
$product_total = $this->model_catalog_product->getTotalProductsByWeightClassId($weight_class_id);
|
||||
|
||||
if ($product_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_product'), $product_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/weight_class');
|
||||
|
||||
foreach ($selected as $weight_class_id) {
|
||||
$this->model_localisation_weight_class->deleteWeightClass($weight_class_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
435
admininistrator/controller/localisation/zone.php
Normal file
435
admininistrator/controller/localisation/zone.php
Normal file
@ -0,0 +1,435 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Localisation;
|
||||
/**
|
||||
* Class Zone
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Localisation
|
||||
*/
|
||||
class Zone extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('localisation/zone');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$filter_name = (string)$this->request->get['filter_name'];
|
||||
} else {
|
||||
$filter_name = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_country'])) {
|
||||
$filter_country = (string)$this->request->get['filter_country'];
|
||||
} else {
|
||||
$filter_country = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$filter_code = (string)$this->request->get['filter_code'];
|
||||
} else {
|
||||
$filter_code = '';
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/zone', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['add'] = $this->url->link('localisation/zone.form', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
$data['delete'] = $this->url->link('localisation/zone.delete', 'user_token=' . $this->session->data['user_token']);
|
||||
|
||||
$data['list'] = $this->getList();
|
||||
|
||||
$data['filter_name'] = $filter_name;
|
||||
$data['filter_country'] = $filter_country;
|
||||
$data['filter_code'] = $filter_code;
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('localisation/zone', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function list(): void {
|
||||
$this->load->language('localisation/zone');
|
||||
|
||||
$this->response->setOutput($this->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getList(): string {
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$filter_name = (string)$this->request->get['filter_name'];
|
||||
} else {
|
||||
$filter_name = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_country'])) {
|
||||
$filter_country = (string)$this->request->get['filter_country'];
|
||||
} else {
|
||||
$filter_country = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$filter_code = (string)$this->request->get['filter_code'];
|
||||
} else {
|
||||
$filter_code = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$sort = (string)$this->request->get['sort'];
|
||||
} else {
|
||||
$sort = 'c.name';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$order = (string)$this->request->get['order'];
|
||||
} else {
|
||||
$order = 'ASC';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_country'])) {
|
||||
$url .= '&filter_country=' . urlencode(html_entity_decode($this->request->get['filter_country'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . urlencode(html_entity_decode($this->request->get['filter_code'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['action'] = $this->url->link('localisation/zone.list', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
$data['zones'] = [];
|
||||
|
||||
$filter_data = [
|
||||
'filter_name' => $filter_name,
|
||||
'filter_country' => $filter_country,
|
||||
'filter_code' => $filter_code,
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'start' => ($page - 1) * $this->config->get('config_pagination_admin'),
|
||||
'limit' => $this->config->get('config_pagination_admin')
|
||||
];
|
||||
|
||||
$this->load->model('localisation/zone');
|
||||
|
||||
$zone_total = $this->model_localisation_zone->getTotalZones($filter_data);
|
||||
|
||||
$results = $this->model_localisation_zone->getZones($filter_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$data['zones'][] = [
|
||||
'zone_id' => $result['zone_id'],
|
||||
'country' => $result['country'],
|
||||
'name' => $result['name'] . (($result['zone_id'] == $this->config->get('config_zone_id')) ? $this->language->get('text_default') : ''),
|
||||
'code' => $result['code'],
|
||||
'status' => $result['status'],
|
||||
'edit' => $this->url->link('localisation/zone.form', 'user_token=' . $this->session->data['user_token'] . '&zone_id=' . $result['zone_id'] . $url)
|
||||
];
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_country'])) {
|
||||
$url .= '&filter_country=' . urlencode(html_entity_decode($this->request->get['filter_country'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . urlencode(html_entity_decode($this->request->get['filter_code'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if ($order == 'ASC') {
|
||||
$url .= '&order=DESC';
|
||||
} else {
|
||||
$url .= '&order=ASC';
|
||||
}
|
||||
|
||||
$data['sort_country'] = $this->url->link('localisation/zone.list', 'user_token=' . $this->session->data['user_token'] . '&sort=c.name' . $url);
|
||||
$data['sort_name'] = $this->url->link('localisation/zone.list', 'user_token=' . $this->session->data['user_token'] . '&sort=z.name' . $url);
|
||||
$data['sort_code'] = $this->url->link('localisation/zone.list', 'user_token=' . $this->session->data['user_token'] . '&sort=z.code' . $url);
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_country'])) {
|
||||
$url .= '&filter_country=' . urlencode(html_entity_decode($this->request->get['filter_country'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . urlencode(html_entity_decode($this->request->get['filter_code'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $zone_total,
|
||||
'page' => $page,
|
||||
'limit' => $this->config->get('config_pagination_admin'),
|
||||
'url' => $this->url->link('localisation/zone.list', 'user_token=' . $this->session->data['user_token'] . $url . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($zone_total) ? (($page - 1) * $this->config->get('config_pagination_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_pagination_admin')) > ($zone_total - $this->config->get('config_pagination_admin'))) ? $zone_total : ((($page - 1) * $this->config->get('config_pagination_admin')) + $this->config->get('config_pagination_admin')), $zone_total, ceil($zone_total / $this->config->get('config_pagination_admin')));
|
||||
|
||||
$data['sort'] = $sort;
|
||||
$data['order'] = $order;
|
||||
|
||||
return $this->load->view('localisation/zone_list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function form(): void {
|
||||
$this->load->language('localisation/zone');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['text_form'] = !isset($this->request->get['zone_id']) ? $this->language->get('text_add') : $this->language->get('text_edit');
|
||||
|
||||
$url = '';
|
||||
|
||||
if (isset($this->request->get['filter_name'])) {
|
||||
$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_country'])) {
|
||||
$url .= '&filter_country=' . urlencode(html_entity_decode($this->request->get['filter_country'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['filter_code'])) {
|
||||
$url .= '&filter_code=' . urlencode(html_entity_decode($this->request->get['filter_code'], ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
if (isset($this->request->get['sort'])) {
|
||||
$url .= '&sort=' . $this->request->get['sort'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['order'])) {
|
||||
$url .= '&order=' . $this->request->get['order'];
|
||||
}
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$url .= '&page=' . $this->request->get['page'];
|
||||
}
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('localisation/zone', 'user_token=' . $this->session->data['user_token'] . $url)
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('localisation/zone.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('localisation/zone', 'user_token=' . $this->session->data['user_token'] . $url);
|
||||
|
||||
if (isset($this->request->get['zone_id'])) {
|
||||
$this->load->model('localisation/zone');
|
||||
|
||||
$zone_info = $this->model_localisation_zone->getZone($this->request->get['zone_id']);
|
||||
}
|
||||
|
||||
if (isset($this->request->get['zone_id'])) {
|
||||
$data['zone_id'] = (int)$this->request->get['zone_id'];
|
||||
} else {
|
||||
$data['zone_id'] = 0;
|
||||
}
|
||||
|
||||
if (!empty($zone_info)) {
|
||||
$data['status'] = $zone_info['status'];
|
||||
} else {
|
||||
$data['status'] = '1';
|
||||
}
|
||||
|
||||
if (!empty($zone_info)) {
|
||||
$data['name'] = $zone_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (!empty($zone_info)) {
|
||||
$data['code'] = $zone_info['code'];
|
||||
} else {
|
||||
$data['code'] = '';
|
||||
}
|
||||
|
||||
$this->load->model('localisation/country');
|
||||
|
||||
$data['countries'] = $this->model_localisation_country->getCountries();
|
||||
|
||||
if (!empty($zone_info)) {
|
||||
$data['country_id'] = $zone_info['country_id'];
|
||||
} else {
|
||||
$data['country_id'] = '';
|
||||
}
|
||||
|
||||
$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('localisation/zone_form', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('localisation/zone');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/zone')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 1) || (oc_strlen($this->request->post['name']) > 64)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/zone');
|
||||
|
||||
if (!$this->request->post['zone_id']) {
|
||||
$json['zone_id'] = $this->model_localisation_zone->addZone($this->request->post);
|
||||
} else {
|
||||
$this->model_localisation_zone->editZone($this->request->post['zone_id'], $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 delete(): void {
|
||||
$this->load->language('localisation/zone');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['selected'])) {
|
||||
$selected = $this->request->post['selected'];
|
||||
} else {
|
||||
$selected = [];
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'localisation/zone')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
$this->load->model('setting/store');
|
||||
$this->load->model('customer/customer');
|
||||
$this->load->model('localisation/geo_zone');
|
||||
|
||||
foreach ($selected as $zone_id) {
|
||||
if ($this->config->get('config_zone_id') == $zone_id) {
|
||||
$json['error'] = $this->language->get('error_default');
|
||||
}
|
||||
|
||||
$store_total = $this->model_setting_store->getTotalStoresByZoneId($zone_id);
|
||||
|
||||
if ($store_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_store'), $store_total);
|
||||
}
|
||||
|
||||
$address_total = $this->model_customer_customer->getTotalAddressesByZoneId($zone_id);
|
||||
|
||||
if ($address_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_address'), $address_total);
|
||||
}
|
||||
|
||||
$zone_to_geo_zone_total = $this->model_localisation_geo_zone->getTotalZoneToGeoZoneByZoneId($zone_id);
|
||||
|
||||
if ($zone_to_geo_zone_total) {
|
||||
$json['error'] = sprintf($this->language->get('error_zone_to_geo_zone'), $zone_to_geo_zone_total);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('localisation/zone');
|
||||
|
||||
foreach ($selected as $zone_id) {
|
||||
$this->model_localisation_zone->deleteZone($zone_id);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user