first commit
This commit is contained in:
137
admininistrator/model/setting/cron.php
Normal file
137
admininistrator/model/setting/cron.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Model\Setting;
|
||||
/**
|
||||
* Class Cron
|
||||
*
|
||||
* @package Opencart\Admin\Model\Setting
|
||||
*/
|
||||
class Cron extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param string $code
|
||||
* @param string $description
|
||||
* @param string $cycle
|
||||
* @param string $action
|
||||
* @param bool $status
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function addCron(string $code, string $description, string $cycle, string $action, bool $status): int {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "cron` SET `code` = '" . $this->db->escape($code) . "', `description` = '" . $this->db->escape($description) . "', `cycle` = '" . $this->db->escape($cycle) . "', `action` = '" . $this->db->escape($action) . "', `status` = '" . (int)$status . "', `date_added` = NOW(), `date_modified` = NOW()");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cron_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteCron(int $cron_id): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "cron` WHERE `cron_id` = '" . (int)$cron_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteCronByCode(string $code): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "cron` WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cron_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editCron(int $cron_id): void {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "cron` SET `date_modified` = NOW() WHERE `cron_id` = '" . (int)$cron_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cron_id
|
||||
* @param bool $status
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editStatus(int $cron_id, bool $status): void {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "cron` SET `status` = '" . (bool)$status . "' WHERE `cron_id` = '" . (int)$cron_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cron_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCron(int $cron_id): array {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "cron` WHERE `cron_id` = '" . (int)$cron_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCronByCode(string $code): array {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "cron` WHERE `code` = '" . $this->db->escape($code) . "' LIMIT 1");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCrons(array $data = []): array {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "cron`";
|
||||
|
||||
$sort_data = [
|
||||
'code',
|
||||
'cycle',
|
||||
'action',
|
||||
'status',
|
||||
'date_added',
|
||||
'date_modified'
|
||||
];
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY `date_added`";
|
||||
}
|
||||
|
||||
if (isset($data['order']) && ($data['order'] == 'DESC')) {
|
||||
$sql .= " DESC";
|
||||
} else {
|
||||
$sql .= " ASC";
|
||||
}
|
||||
|
||||
if (isset($data['start']) || isset($data['limit'])) {
|
||||
if ($data['start'] < 0) {
|
||||
$data['start'] = 0;
|
||||
}
|
||||
|
||||
if ($data['limit'] < 1) {
|
||||
$data['limit'] = 20;
|
||||
}
|
||||
|
||||
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalCrons(): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "cron`");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
}
|
124
admininistrator/model/setting/event.php
Normal file
124
admininistrator/model/setting/event.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Model\Setting;
|
||||
/**
|
||||
* Class Event
|
||||
*
|
||||
* @package Opencart\Admin\Model\Setting
|
||||
*/
|
||||
class Event extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function addEvent(array $data): int {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = '" . $this->db->escape($data['code']) . "', `description` = '" . $this->db->escape($data['description']) . "', `trigger` = '" . $this->db->escape($data['trigger']) . "', `action` = '" . $this->db->escape($data['action']) . "', `status` = '" . (bool)$data['status'] . "', `sort_order` = '" . (int)$data['sort_order'] . "'");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $event_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteEvent(int $event_id): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `event_id` = '" . (int)$event_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteEventByCode(string $code): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $event_id
|
||||
* @param bool $status
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editStatus(int $event_id, bool $status): void {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "event` SET `status` = '" . (bool)$status . "' WHERE `event_id` = '" . (int)$event_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $event_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEvent(int $event_id): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "event` WHERE `event_id` = '" . (int)$event_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEventByCode(string $code): array {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "event` WHERE `code` = '" . $this->db->escape($code) . "' LIMIT 1");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEvents(array $data = []): array {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "event`";
|
||||
|
||||
$sort_data = [
|
||||
'code',
|
||||
'trigger',
|
||||
'action',
|
||||
'sort_order',
|
||||
'status',
|
||||
'date_added'
|
||||
];
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY `sort_order`";
|
||||
}
|
||||
|
||||
if (isset($data['order']) && ($data['order'] == 'DESC')) {
|
||||
$sql .= " DESC";
|
||||
} else {
|
||||
$sql .= " ASC";
|
||||
}
|
||||
|
||||
if (isset($data['start']) || isset($data['limit'])) {
|
||||
if ($data['start'] < 0) {
|
||||
$data['start'] = 0;
|
||||
}
|
||||
|
||||
if ($data['limit'] < 1) {
|
||||
$data['limit'] = 20;
|
||||
}
|
||||
|
||||
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalEvents(): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "event`");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
}
|
258
admininistrator/model/setting/extension.php
Normal file
258
admininistrator/model/setting/extension.php
Normal file
@ -0,0 +1,258 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Model\Setting;
|
||||
/**
|
||||
* Class Extension
|
||||
*
|
||||
* @package Opencart\Admin\Model\Setting
|
||||
*/
|
||||
class Extension extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensions(): array {
|
||||
$query = $this->db->query("SELECT DISTINCT `extension` FROM `" . DB_PREFIX . "extension`");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensionsByType(string $type): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension` WHERE `type` = '" . $this->db->escape($type) . "' ORDER BY `code` ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $code
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensionByCode(string $type, string $code): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension` WHERE `type` = '" . $this->db->escape($type) . "' AND `code` = '" . $this->db->escape($code) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $extension
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalExtensionsByExtension(string $extension): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "extension` WHERE `extension` = '" . $this->db->escape($extension) . "'");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $extension
|
||||
* @param string $code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function install(string $type, string $extension, string $code): void {
|
||||
$extensions = $this->getExtensionsByType($type);
|
||||
|
||||
$codes = array_column($extensions, 'code');
|
||||
|
||||
if (!in_array($code, $codes)) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "extension` SET `extension` = '" . $this->db->escape($extension) . "', `type` = '" . $this->db->escape($type) . "', `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function uninstall(string $type, string $code): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "extension` WHERE `type` = '" . $this->db->escape($type) . "' AND `code` = '" . $this->db->escape($code) . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "setting` WHERE `code` = '" . $this->db->escape($type . '_' . $code) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function addInstall(array $data): int {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "extension_install` SET `extension_id` = '" . (int)$data['extension_id'] . "', `extension_download_id` = '" . (int)$data['extension_download_id'] . "', `name` = '" . $this->db->escape($data['name']) . "', `code` = '" . $this->db->escape($data['code']) . "', `version` = '" . $this->db->escape($data['version']) . "', `author` = '" . $this->db->escape($data['author']) . "', `link` = '" . $this->db->escape($data['link']) . "', `status` = '0', `date_added` = NOW()");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $extension_install_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteInstall(int $extension_install_id): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "extension_install` WHERE `extension_install_id` = '" . (int)$extension_install_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $extension_install_id
|
||||
* @param bool $status
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editStatus(int $extension_install_id, bool $status): void {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "extension_install` SET `status` = '" . (bool)$status . "' WHERE `extension_install_id` = '" . (int)$extension_install_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $extension_install_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getInstall(int $extension_install_id): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension_install` WHERE `extension_install_id` = '" . (int)$extension_install_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $extension_download_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getInstallByExtensionDownloadId(int $extension_download_id): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension_install` WHERE `extension_download_id` = '" . (int)$extension_download_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getInstallByCode(string $code): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension_install` WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getInstalls(array $data = []): array {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "extension_install`";
|
||||
|
||||
if (!empty($data['filter_extension_download_id'])) {
|
||||
$sql .= " WHERE `extension_download_id` = '" . (int)$data['filter_extension_download_id'] . "'";
|
||||
}
|
||||
|
||||
$sort_data = [
|
||||
'name',
|
||||
'version',
|
||||
'date_added'
|
||||
];
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY `date_added`";
|
||||
}
|
||||
|
||||
if (isset($data['order']) && ($data['order'] == 'DESC')) {
|
||||
$sql .= " DESC";
|
||||
} else {
|
||||
$sql .= " ASC";
|
||||
}
|
||||
|
||||
if (isset($data['start']) || isset($data['limit'])) {
|
||||
if ($data['start'] < 0) {
|
||||
$data['start'] = 0;
|
||||
}
|
||||
|
||||
if ($data['limit'] < 1) {
|
||||
$data['limit'] = 20;
|
||||
}
|
||||
|
||||
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalInstalls(array $data = []): int {
|
||||
$sql = "SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "extension_install`";
|
||||
|
||||
if (!empty($data['filter_extension_download_id'])) {
|
||||
$sql .= " WHERE `extension_download_id` = '" . (int)$data['filter_extension_download_id'] . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $extension_install_id
|
||||
* @param string $path
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPath(int $extension_install_id, string $path): void {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "extension_path` SET `extension_install_id` = '" . (int)$extension_install_id . "', `path` = '" . $this->db->escape($path) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $extension_path_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deletePath(int $extension_path_id): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "extension_path` WHERE `extension_path_id` = '" . (int)$extension_path_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $extension_install_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPathsByExtensionInstallId(int $extension_install_id): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension_path` WHERE `extension_install_id` = '" . (int)$extension_install_id . "' ORDER BY `extension_path_id` ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPaths(string $path): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension_path` WHERE `path` LIKE '" . $this->db->escape($path) . "' ORDER BY `path` ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalPaths(string $path): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "extension_path` WHERE `path` LIKE '" . $this->db->escape($path) . "'");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
}
|
86
admininistrator/model/setting/module.php
Normal file
86
admininistrator/model/setting/module.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Model\Setting;
|
||||
/**
|
||||
* Class Module
|
||||
*
|
||||
* @package Opencart\Admin\Model\Setting
|
||||
*/
|
||||
class Module extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param string $code
|
||||
* @param array $data
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function addModule(string $code, array $data): int {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape((string)$data['name']) . "', `code` = '" . $this->db->escape($code) . "', `setting` = '" . $this->db->escape(json_encode($data)) . "'");
|
||||
|
||||
$module_id = $this->db->getLastId();
|
||||
|
||||
return (int)$module_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $module_id
|
||||
* @param array $data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editModule(int $module_id, array $data): void {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape((string)$data['name']) . "', `setting` = '" . $this->db->escape(json_encode($data)) . "' WHERE `module_id` = '" . (int)$module_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $module_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteModule(int $module_id): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "module` WHERE `module_id` = '" . (int)$module_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $module_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getModule(int $module_id): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` WHERE `module_id` = '" . (int)$module_id . "'");
|
||||
|
||||
if ($query->row) {
|
||||
return json_decode($query->row['setting'], true);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getModules(): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` ORDER BY `code`");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getModulesByCode(string $code): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` WHERE `code` = '" . $this->db->escape($code) . "' ORDER BY `name`");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteModulesByCode(string $code): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "module` WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "layout_module` WHERE `code` = '" . $this->db->escape($code) . "' OR `code` LIKE '" . $this->db->escape($code . '.%') . "'");
|
||||
}
|
||||
}
|
104
admininistrator/model/setting/setting.php
Normal file
104
admininistrator/model/setting/setting.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Model\Setting;
|
||||
/**
|
||||
* Class Setting
|
||||
*
|
||||
* @package Opencart\Admin\Model\Setting
|
||||
*/
|
||||
class Setting extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param int $store_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSettings(int $store_id = 0): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "setting` WHERE `store_id` = '" . (int)$store_id . "' OR `store_id` = '0' ORDER BY `store_id` ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param int $store_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSetting(string $code, int $store_id = 0): array {
|
||||
$setting_data = [];
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "setting` WHERE `store_id` = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
if (!$result['serialized']) {
|
||||
$setting_data[$result['key']] = $result['value'];
|
||||
} else {
|
||||
$setting_data[$result['key']] = json_decode($result['value'], true);
|
||||
}
|
||||
}
|
||||
|
||||
return $setting_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param array $data
|
||||
* @param int $store_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editSetting(string $code, array $data, int $store_id = 0): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "setting` WHERE `store_id` = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (substr($key, 0, strlen($code)) == $code) {
|
||||
if (!is_array($value)) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "setting` SET `store_id` = '" . (int)$store_id . "', `code` = '" . $this->db->escape($code) . "', `key` = '" . $this->db->escape($key) . "', `value` = '" . $this->db->escape($value) . "'");
|
||||
} else {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "setting` SET `store_id` = '" . (int)$store_id . "', `code` = '" . $this->db->escape($code) . "', `key` = '" . $this->db->escape($key) . "', `value` = '" . $this->db->escape(json_encode($value)) . "', `serialized` = '1'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param int $store_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteSetting(string $code, int $store_id = 0): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "setting` WHERE `store_id` = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param int $store_id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getValue(string $key, int $store_id = 0): string {
|
||||
$query = $this->db->query("SELECT `value` FROM `" . DB_PREFIX . "setting` WHERE `store_id` = '" . (int)$store_id . "' AND `key` = '" . $this->db->escape($key) . "'");
|
||||
|
||||
if ($query->num_rows) {
|
||||
return $query->row['value'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @param string $key
|
||||
* @param string|array $value
|
||||
* @param int $store_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editValue(string $code = '', string $key = '', string|array $value = '', int $store_id = 0): void {
|
||||
if (!is_array($value)) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `value` = '" . $this->db->escape($value) . "', `serialized` = '0' WHERE `code` = '" . $this->db->escape($code) . "' AND `key` = '" . $this->db->escape($key) . "' AND `store_id` = '" . (int)$store_id . "'");
|
||||
} else {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "setting` SET `value` = '" . $this->db->escape(json_encode($value)) . "', `serialized` = '1' WHERE `code` = '" . $this->db->escape($code) . "' AND `key` = '" . $this->db->escape($key) . "' AND `store_id` = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
}
|
123
admininistrator/model/setting/startup.php
Normal file
123
admininistrator/model/setting/startup.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Model\Setting;
|
||||
/**
|
||||
* Class Startup
|
||||
*
|
||||
* @package Opencart\Admin\Model\Setting
|
||||
*/
|
||||
class Startup extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function addStartup(array $data): int {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "startup` SET `code` = '" . $this->db->escape($data['code']) . "', `action` = '" . $this->db->escape($data['action']) . "', `status` = '" . (bool)$data['status'] . "', `sort_order` = '" . (int)$data['sort_order'] . "'");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $startup_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteStartup(int $startup_id): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "startup` WHERE `startup_id` = '" . (int)$startup_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteStartupByCode(string $code): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "startup` WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $startup_id
|
||||
* @param bool $status
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editStatus(int $startup_id, bool $status): void {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "startup` SET `status` = '" . (bool)$status . "' WHERE `startup_id` = '" . (int)$startup_id . "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $startup_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStartup(int $startup_id): array {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "startup` WHERE `startup_id` = '" . (int)$startup_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStartupByCode(string $code): array {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "startup` WHERE `code` = '" . $this->db->escape($code) . "' LIMIT 1");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStartups(array $data = []): array {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "startup`";
|
||||
|
||||
$sort_data = [
|
||||
'code',
|
||||
'action',
|
||||
'status',
|
||||
'sort_order',
|
||||
'date_added'
|
||||
];
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY `sort_order`";
|
||||
}
|
||||
|
||||
if (isset($data['order']) && ($data['order'] == 'DESC')) {
|
||||
$sql .= " DESC";
|
||||
} else {
|
||||
$sql .= " ASC";
|
||||
}
|
||||
|
||||
if (isset($data['start']) || isset($data['limit'])) {
|
||||
if ($data['start'] < 0) {
|
||||
$data['start'] = 0;
|
||||
}
|
||||
|
||||
if ($data['limit'] < 1) {
|
||||
$data['limit'] = 20;
|
||||
}
|
||||
|
||||
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStartups(): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "startup`");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
}
|
325
admininistrator/model/setting/store.php
Normal file
325
admininistrator/model/setting/store.php
Normal file
@ -0,0 +1,325 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Model\Setting;
|
||||
/**
|
||||
* Class Store
|
||||
*
|
||||
* @package Opencart\Admin\Model\Setting
|
||||
*/
|
||||
class Store extends \Opencart\System\Engine\Model {
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function addStore(array $data): int {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "store` SET `name` = '" . $this->db->escape((string)$data['config_name']) . "', `url` = '" . $this->db->escape((string)$data['config_url']) . "'");
|
||||
|
||||
$store_id = $this->db->getLastId();
|
||||
|
||||
// Layout Route
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "layout_route` WHERE `store_id` = '0'");
|
||||
|
||||
foreach ($query->rows as $layout_route) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "layout_route` SET `layout_id` = '" . (int)$layout_route['layout_id'] . "', `route` = '" . $this->db->escape($layout_route['route']) . "', `store_id` = '" . (int)$store_id . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('store');
|
||||
|
||||
return $store_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $store_id
|
||||
* @param array $data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editStore(int $store_id, array $data): void {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "store` SET `name` = '" . $this->db->escape((string)$data['config_name']) . "', `url` = '" . $this->db->escape((string)$data['config_url']) . "' WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
|
||||
$this->cache->delete('store');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $store_id
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteStore(int $store_id): void {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "store` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "category_to_layout` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "category_to_store` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_affiliate_report` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_ip` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_search` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "download_report` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "gdpr` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "information_to_layout` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "information_to_store` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "layout_route` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "manufacturer_to_layout` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "manufacturer_to_store` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "marketing_report` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "order` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "product_report` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "product_to_layout` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "product_to_store` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "setting` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "subscription` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "theme` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "translation` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
|
||||
$this->cache->delete('store');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $store_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStore(int $store_id): array {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "store` WHERE `store_id` = '" . (int)$store_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getStores(array $data = []): array {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "store` ORDER BY `url`";
|
||||
|
||||
$store_data = $this->cache->get('store.' . md5($sql));
|
||||
|
||||
if (!$store_data) {
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$store_data = $query->rows;
|
||||
|
||||
$this->cache->set('store.' . md5($sql), $store_data);
|
||||
}
|
||||
|
||||
return $store_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $store_id
|
||||
* @param string $language
|
||||
* @param string $session_id
|
||||
*
|
||||
* @return \Opencart\System\Engine\Registry
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createStoreInstance(int $store_id = 0, string $language = '', string $session_id = ''): object {
|
||||
// Autoloader
|
||||
$this->autoloader->register('Opencart\Catalog', DIR_CATALOG);
|
||||
|
||||
// Registry
|
||||
$registry = new \Opencart\System\Engine\Registry();
|
||||
$registry->set('autoloader', $this->autoloader);
|
||||
|
||||
// Config
|
||||
$config = new \Opencart\System\Engine\Config();
|
||||
$registry->set('config', $config);
|
||||
|
||||
// Load the default config
|
||||
$config->addPath(DIR_CONFIG);
|
||||
$config->load('default');
|
||||
$config->load('catalog');
|
||||
$config->set('application', 'Catalog');
|
||||
|
||||
// Store
|
||||
$config->set('config_store_id', $store_id);
|
||||
|
||||
// Logging
|
||||
$registry->set('log', $this->log);
|
||||
|
||||
// Event
|
||||
$event = new \Opencart\System\Engine\Event($registry);
|
||||
$registry->set('event', $event);
|
||||
|
||||
// Event Register
|
||||
if ($config->has('action_event')) {
|
||||
foreach ($config->get('action_event') as $key => $value) {
|
||||
foreach ($value as $priority => $action) {
|
||||
$event->register($key, new \Opencart\System\Engine\Action($action), $priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loader
|
||||
$loader = new \Opencart\System\Engine\Loader($registry);
|
||||
$registry->set('load', $loader);
|
||||
|
||||
// Create a dummy request class, so we can feed the data to the order editor
|
||||
$request = new \stdClass();
|
||||
$request->get = [];
|
||||
$request->post = [];
|
||||
$request->server = $this->request->server;
|
||||
$request->cookie = [];
|
||||
|
||||
// Request
|
||||
$registry->set('request', $request);
|
||||
|
||||
// Response
|
||||
$response = new \Opencart\System\Library\Response();
|
||||
$registry->set('response', $response);
|
||||
|
||||
// Database
|
||||
$registry->set('db', $this->db);
|
||||
|
||||
// Cache
|
||||
$registry->set('cache', $this->cache);
|
||||
|
||||
// Session
|
||||
$session = new \Opencart\System\Library\Session($config->get('session_engine'), $registry);
|
||||
$registry->set('session', $session);
|
||||
|
||||
// Start session
|
||||
$session->start($session_id);
|
||||
|
||||
// Template
|
||||
$template = new \Opencart\System\Library\Template($config->get('template_engine'));
|
||||
$template->addPath(DIR_CATALOG . 'view/template/');
|
||||
$registry->set('template', $template);
|
||||
|
||||
// Adding language var to the GET variable so there is a default language
|
||||
$registry->request->get['language'] = $language;
|
||||
|
||||
// Language
|
||||
$language = new \Opencart\System\Library\Language($config->get('language_code'));
|
||||
$language->addPath(DIR_CATALOG . 'language/');
|
||||
$language->load('default');
|
||||
$registry->set('language', $language);
|
||||
|
||||
// Url
|
||||
$registry->set('url', new \Opencart\System\Library\Url($config->get('site_url')));
|
||||
|
||||
// Document
|
||||
$registry->set('document', new \Opencart\System\Library\Document());
|
||||
|
||||
// Run pre actions to load key settings and classes.
|
||||
$pre_actions = [
|
||||
'startup/setting',
|
||||
'startup/language',
|
||||
'startup/extension',
|
||||
'startup/customer',
|
||||
'startup/tax',
|
||||
'startup/currency',
|
||||
'startup/application',
|
||||
'startup/startup',
|
||||
'startup/event'
|
||||
];
|
||||
|
||||
// Pre Actions
|
||||
foreach ($pre_actions as $pre_action) {
|
||||
$loader->controller($pre_action);
|
||||
}
|
||||
|
||||
return $registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStores(): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "store`");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $layout_id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStoresByLayoutId(int $layout_id): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_layout_id' AND `value` = '" . (int)$layout_id . "' AND `store_id` != '0'");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $language
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStoresByLanguage(string $language): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_language' AND `value` = '" . $this->db->escape($language) . "' AND `store_id` != '0'");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $currency
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStoresByCurrency(string $currency): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_currency' AND `value` = '" . $this->db->escape($currency) . "' AND `store_id` != '0'");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $country_id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStoresByCountryId(int $country_id): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_country_id' AND `value` = '" . (int)$country_id . "' AND `store_id` != '0'");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $zone_id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStoresByZoneId(int $zone_id): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_zone_id' AND `value` = '" . (int)$zone_id . "' AND `store_id` != '0'");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $customer_group_id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStoresByCustomerGroupId(int $customer_group_id): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_customer_group_id' AND `value` = '" . (int)$customer_group_id . "' AND `store_id` != '0'");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $information_id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStoresByInformationId(int $information_id): int {
|
||||
$account_query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_account_id' AND `value` = '" . (int)$information_id . "' AND `store_id` != '0'");
|
||||
|
||||
$checkout_query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_checkout_id' AND `value` = '" . (int)$information_id . "' AND `store_id` != '0'");
|
||||
|
||||
return ($account_query->row['total'] + $checkout_query->row['total']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $order_status_id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTotalStoresByOrderStatusId(int $order_status_id): int {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_order_status_id' AND `value` = '" . (int)$order_status_id . "' AND `store_id` != '0'");
|
||||
|
||||
return (int)$query->row['total'];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user