first commit
This commit is contained in:
@@ -0,0 +1,459 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ModelBlogArticle extends Model {
|
||||
public function addArticle($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article SET status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW()");
|
||||
|
||||
$article_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "article SET image = '" . $this->db->escape($data['image']) . "' WHERE article_id = '" . (int)$article_id . "'");
|
||||
}
|
||||
|
||||
foreach ($data['article_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_description SET article_id = '" . (int)$article_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['article_store'])) {
|
||||
foreach ($data['article_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_store SET article_id = '" . (int)$article_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['article_image'])) {
|
||||
foreach ($data['article_image'] as $article_image) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_image SET article_id = '" . (int)$article_id . "', image = '" . $this->db->escape($article_image['image']) . "', sort_order = '" . (int)$article_image['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['article_download'])) {
|
||||
foreach ($data['article_download'] as $download_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_download SET article_id = '" . (int)$article_id . "', download_id = '" . (int)$download_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['article_category'])) {
|
||||
foreach ($data['article_category'] as $blog_category_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_blog_category SET article_id = '" . (int)$article_id . "', blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['main_blog_category_id']) && $data['main_blog_category_id'] > 0) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_blog_category WHERE article_id = '" . (int)$article_id . "' AND blog_category_id = '" . (int)$data['main_blog_category_id'] . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_blog_category SET article_id = '" . (int)$article_id . "', blog_category_id = '" . (int)$data['main_blog_category_id'] . "', main_blog_category = 1");
|
||||
} elseif (isset($data['article_category'][0])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "article_to_blog_category SET main_blog_category = 1 WHERE article_id = '" . (int)$article_id . "' AND blog_category_id = '" . (int)$data['article_category'][0] . "'");
|
||||
}
|
||||
|
||||
if (isset($data['article_related'])) {
|
||||
foreach ($data['article_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related WHERE article_id = '" . (int)$article_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related SET article_id = '" . (int)$article_id . "', related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related WHERE article_id = '" . (int)$related_id . "' AND related_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related SET article_id = '" . (int)$related_id . "', related_id = '" . (int)$article_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related_product WHERE article_id = '" . (int)$article_id . "' AND product_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related_product SET article_id = '" . (int)$article_id . "', product_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
if (isset($data['article_seo_url'])) {
|
||||
foreach ($data['article_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'article_id=" . (int)$article_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['article_layout'])) {
|
||||
foreach ($data['article_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_layout SET article_id = '" . (int)$article_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
|
||||
$this->cache->delete('article');
|
||||
|
||||
return $article_id;
|
||||
}
|
||||
|
||||
public function editArticle($article_id, $data) {
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "article SET status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_modified = NOW() WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "article SET image = '" . $this->db->escape($data['image']) . "' WHERE article_id = '" . (int)$article_id . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_description WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
foreach ($data['article_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_description SET article_id = '" . (int)$article_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_store WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
if (isset($data['article_store'])) {
|
||||
foreach ($data['article_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_store SET article_id = '" . (int)$article_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_image WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
if (isset($data['article_image'])) {
|
||||
foreach ($data['article_image'] as $article_image) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_image SET article_id = '" . (int)$article_id . "', image = '" . $this->db->escape($article_image['image']) . "', sort_order = '" . (int)$article_image['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_download WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
if (isset($data['article_download'])) {
|
||||
foreach ($data['article_download'] as $download_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_download SET article_id = '" . (int)$article_id . "', download_id = '" . (int)$download_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_blog_category WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
if (isset($data['article_category'])) {
|
||||
foreach ($data['article_category'] as $blog_category_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_blog_category SET article_id = '" . (int)$article_id . "', blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['main_blog_category_id']) && $data['main_blog_category_id'] > 0) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_blog_category WHERE article_id = '" . (int)$article_id . "' AND blog_category_id = '" . (int)$data['main_blog_category_id'] . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_blog_category SET article_id = '" . (int)$article_id . "', blog_category_id = '" . (int)$data['main_blog_category_id'] . "', main_blog_category = 1");
|
||||
} elseif (isset($data['article_category'][0])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "article_to_blog_category SET main_blog_category = 1 WHERE article_id = '" . (int)$article_id . "' AND blog_category_id = '" . (int)$data['article_category'][0] . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related WHERE related_id = '" . (int)$article_id . "'");
|
||||
|
||||
if (isset($data['article_related'])) {
|
||||
foreach ($data['article_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related WHERE article_id = '" . (int)$article_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related SET article_id = '" . (int)$article_id . "', related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related WHERE article_id = '" . (int)$related_id . "' AND related_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related SET article_id = '" . (int)$related_id . "', related_id = '" . (int)$article_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related_product WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related_product WHERE article_id = '" . (int)$article_id . "' AND product_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related_product SET article_id = '" . (int)$article_id . "', product_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'article_id=" . (int)$article_id . "'");
|
||||
|
||||
if (isset($data['article_seo_url'])) {
|
||||
foreach ($data['article_seo_url']as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'article_id=" . (int)$article_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_layout WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
if (isset($data['article_layout'])) {
|
||||
foreach ($data['article_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_to_layout SET article_id = '" . (int)$article_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('article');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function editArticleStatus($article_id, $status) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "article SET status = '" . (int)$status . "', date_modified = NOW() WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
$this->cache->delete('article');
|
||||
|
||||
return $article_id;
|
||||
}
|
||||
|
||||
public function copyArticle($article_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id) WHERE p.article_id = '" . (int)$article_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
if ($query->num_rows) {
|
||||
$data = $query->row;
|
||||
|
||||
$data['viewed'] = '0';
|
||||
$data['keyword'] = '';
|
||||
$data['status'] = '0';
|
||||
$data['noindex'] = '0';
|
||||
|
||||
$data['article_description'] = $this->getArticleDescriptions($article_id);
|
||||
$data['article_image'] = $this->getArticleImages($article_id);
|
||||
$data['article_related'] = $this->getArticleRelated($article_id);
|
||||
$data['product_related'] = $this->getProductRelated($article_id);
|
||||
$data['article_category'] = $this->getArticleCategories($article_id);
|
||||
$data['article_download'] = $this->getArticleDownloads($article_id);
|
||||
$data['article_layout'] = $this->getArticleLayouts($article_id);
|
||||
$data['article_store'] = $this->getArticleStores($article_id);
|
||||
|
||||
$this->addArticle($data);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteArticle($article_id) {
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_description WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_image WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related WHERE related_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related_product WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_blog_category WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_download WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_layout WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_store WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "review_article WHERE article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'article_id=" . (int)$article_id . "'");
|
||||
|
||||
$this->cache->delete('article');
|
||||
|
||||
}
|
||||
|
||||
public function getArticle($article_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id) WHERE p.article_id = '" . (int)$article_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getArticles($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND pd.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
|
||||
$sql .= " AND p.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_noindex']) && !is_null($data['filter_noindex'])) {
|
||||
$sql .= " AND p.noindex = '" . (int)$data['filter_noindex'] . "'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY p.article_id";
|
||||
|
||||
$sort_data = array(
|
||||
'pd.name',
|
||||
'p.status',
|
||||
'p.noindex',
|
||||
'p.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY pd.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getArticlesByCategoryId($blog_category_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id) LEFT JOIN " . DB_PREFIX . "article_to_blog_category p2c ON (p.article_id = p2c.article_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.blog_category_id = '" . (int)$blog_category_id . "' ORDER BY pd.name ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getArticleDescriptions($article_id) {
|
||||
$article_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_description WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_description_data[$result['language_id']] = array(
|
||||
'name' => $result['name'],
|
||||
'description' => $result['description'],
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword']
|
||||
);
|
||||
}
|
||||
|
||||
return $article_description_data;
|
||||
}
|
||||
|
||||
public function getArticleCategories($article_id) {
|
||||
$article_category_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_to_blog_category WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_category_data[] = $result['blog_category_id'];
|
||||
}
|
||||
|
||||
return $article_category_data;
|
||||
}
|
||||
|
||||
public function getArticleMainCategoryId($article_id) {
|
||||
$query = $this->db->query("SELECT blog_category_id FROM " . DB_PREFIX . "article_to_blog_category WHERE article_id = '" . (int)$article_id . "' AND main_blog_category = '1' LIMIT 1");
|
||||
|
||||
return ($query->num_rows ? (int)$query->row['blog_category_id'] : 0);
|
||||
}
|
||||
|
||||
public function getArticleImages($article_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_image WHERE article_id = '" . (int)$article_id . "' ORDER BY sort_order ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getArticleDownloads($article_id) {
|
||||
$article_download_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_to_download WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_download_data[] = $result['download_id'];
|
||||
}
|
||||
|
||||
return $article_download_data;
|
||||
}
|
||||
|
||||
public function getArticleStores($article_id) {
|
||||
$article_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_to_store WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $article_store_data;
|
||||
}
|
||||
|
||||
public function getArticleSeoUrls($article_id) {
|
||||
$article_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'article_id=" . (int)$article_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
|
||||
return $article_seo_url_data;
|
||||
}
|
||||
|
||||
public function getArticleLayouts($article_id) {
|
||||
$article_layout_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_to_layout WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
|
||||
return $article_layout_data;
|
||||
}
|
||||
|
||||
public function getArticleRelated($article_id) {
|
||||
$article_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_related WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_related_data[] = $result['related_id'];
|
||||
}
|
||||
|
||||
return $article_related_data;
|
||||
}
|
||||
|
||||
public function getProductRelated($article_id) {
|
||||
$article_related_product = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_related_product WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_related_product[] = $result['product_id'];
|
||||
}
|
||||
|
||||
return $article_related_product;
|
||||
}
|
||||
|
||||
public function getTotalArticles($data = array()) {
|
||||
$sql = "SELECT COUNT(DISTINCT p.article_id) AS total FROM " . DB_PREFIX . "article p LEFT JOIN " . DB_PREFIX . "article_description pd ON (p.article_id = pd.article_id)";
|
||||
|
||||
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND pd.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
|
||||
$sql .= " AND p.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_noindex']) && $data['filter_noindex'] !== null) {
|
||||
$sql .= " AND p.noindex = '" . (int)$data['filter_noindex'] . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalArticlesByDownloadId($download_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "article_to_download WHERE download_id = '" . (int)$download_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalArticlesByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "article_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
class ModelBlogCategory extends Model {
|
||||
public function addCategory($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "blog_category SET parent_id = '" . (int)$data['parent_id'] . "', `top` = '" . (isset($data['top']) ? (int)$data['top'] : 0) . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', date_modified = NOW(), date_added = NOW()");
|
||||
$blog_category_id = $this->db->getLastId();
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "blog_category SET image = '" . $this->db->escape($data['image']) . "' WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
}
|
||||
foreach ($data['category_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "blog_category_description SET blog_category_id = '" . (int)$blog_category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
// MySQL Hierarchical Data Closure Table Pattern
|
||||
$level = 0;
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "blog_category_path` WHERE blog_category_id = '" . (int)$data['parent_id'] . "' ORDER BY `level` ASC");
|
||||
foreach ($query->rows as $result) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "blog_category_path` SET `blog_category_id` = '" . (int)$blog_category_id . "', `path_id` = '" . (int)$result['path_id'] . "', `level` = '" . (int)$level . "'");
|
||||
$level++;
|
||||
}
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "blog_category_path` SET `blog_category_id` = '" . (int)$blog_category_id . "', `path_id` = '" . (int)$blog_category_id . "', `level` = '" . (int)$level . "'");
|
||||
if (isset($data['category_store'])) {
|
||||
foreach ($data['category_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "blog_category_to_store SET blog_category_id = '" . (int)$blog_category_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['category_seo_url'])) {
|
||||
foreach ($data['category_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'blog_category_id=" . (int)$blog_category_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Set which layout to use with this category
|
||||
if (isset($data['category_layout'])) {
|
||||
foreach ($data['category_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "blog_category_to_layout SET blog_category_id = '" . (int)$blog_category_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
$this->cache->delete('blog_category');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
return $blog_category_id;
|
||||
}
|
||||
public function editCategory($blog_category_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "blog_category SET parent_id = '" . (int)$data['parent_id'] . "', `top` = '" . (isset($data['top']) ? (int)$data['top'] : 0) . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', date_modified = NOW() WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "blog_category SET image = '" . $this->db->escape($data['image']) . "' WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
}
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "blog_category_description WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
foreach ($data['category_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "blog_category_description SET blog_category_id = '" . (int)$blog_category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
// MySQL Hierarchical Data Closure Table Pattern
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "blog_category_path` WHERE path_id = '" . (int)$blog_category_id . "' ORDER BY level ASC");
|
||||
if ($query->rows) {
|
||||
foreach ($query->rows as $category_path) {
|
||||
// Delete the path below the current one
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "blog_category_path` WHERE blog_category_id = '" . (int)$category_path['blog_category_id'] . "' AND level < '" . (int)$category_path['level'] . "'");
|
||||
$path = array();
|
||||
// Get the nodes new parents
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "blog_category_path` WHERE blog_category_id = '" . (int)$data['parent_id'] . "' ORDER BY level ASC");
|
||||
foreach ($query->rows as $result) {
|
||||
$path[] = $result['path_id'];
|
||||
}
|
||||
// Get whats left of the nodes current path
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "blog_category_path` WHERE blog_category_id = '" . (int)$category_path['blog_category_id'] . "' ORDER BY level ASC");
|
||||
foreach ($query->rows as $result) {
|
||||
$path[] = $result['path_id'];
|
||||
}
|
||||
// Combine the paths with a new level
|
||||
$level = 0;
|
||||
foreach ($path as $path_id) {
|
||||
$this->db->query("REPLACE INTO `" . DB_PREFIX . "blog_category_path` SET blog_category_id = '" . (int)$category_path['blog_category_id'] . "', `path_id` = '" . (int)$path_id . "', level = '" . (int)$level . "'");
|
||||
$level++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Delete the path below the current one
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "blog_category_path` WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
// Fix for records with no paths
|
||||
$level = 0;
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "blog_category_path` WHERE blog_category_id = '" . (int)$data['parent_id'] . "' ORDER BY level ASC");
|
||||
foreach ($query->rows as $result) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "blog_category_path` SET blog_category_id = '" . (int)$blog_category_id . "', `path_id` = '" . (int)$result['path_id'] . "', level = '" . (int)$level . "'");
|
||||
$level++;
|
||||
}
|
||||
$this->db->query("REPLACE INTO `" . DB_PREFIX . "blog_category_path` SET blog_category_id = '" . (int)$blog_category_id . "', `path_id` = '" . (int)$blog_category_id . "', level = '" . (int)$level . "'");
|
||||
}
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "blog_category_to_store WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
if (isset($data['category_store'])) {
|
||||
foreach ($data['category_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "blog_category_to_store SET blog_category_id = '" . (int)$blog_category_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE query = 'blog_category_id=" . (int)$blog_category_id . "'");
|
||||
if (isset($data['category_seo_url'])) {
|
||||
foreach ($data['category_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'blog_category_id=" . (int)$blog_category_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "blog_category_to_layout WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
if (isset($data['category_layout'])) {
|
||||
foreach ($data['category_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "blog_category_to_layout SET blog_category_id = '" . (int)$blog_category_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
$this->cache->delete('category');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
}
|
||||
|
||||
public function editCategoryStatus($blog_category_id, $status) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "blog_category SET status = '" . (int)$status . "', date_modified = NOW() WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
|
||||
$this->cache->delete('category');
|
||||
}
|
||||
public function deleteCategory($blog_category_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "blog_category_path WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "blog_category_path WHERE path_id = '" . (int)$blog_category_id . "'");
|
||||
foreach ($query->rows as $result) {
|
||||
$this->deleteCategory($result['blog_category_id']);
|
||||
}
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "blog_category WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "blog_category_description WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "blog_category_to_store WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "blog_category_to_layout WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_blog_category WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'blog_category_id=" . (int)$blog_category_id . "'");
|
||||
$this->cache->delete('blog_category');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
}
|
||||
public function repairCategories($parent_id = 0) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "blog_category WHERE parent_id = '" . (int)$parent_id . "'");
|
||||
foreach ($query->rows as $category) {
|
||||
// Delete the path below the current one
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "blog_category_path` WHERE blog_category_id = '" . (int)$category['blog_category_id'] . "'");
|
||||
// Fix for records with no paths
|
||||
$level = 0;
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "blog_category_path` WHERE blog_category_id = '" . (int)$parent_id . "' ORDER BY level ASC");
|
||||
foreach ($query->rows as $result) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "blog_category_path` SET blog_category_id = '" . (int)$category['blog_category_id'] . "', `path_id` = '" . (int)$result['path_id'] . "', level = '" . (int)$level . "'");
|
||||
$level++;
|
||||
}
|
||||
$this->db->query("REPLACE INTO `" . DB_PREFIX . "blog_category_path` SET blog_category_id = '" . (int)$category['blog_category_id'] . "', `path_id` = '" . (int)$category['blog_category_id'] . "', level = '" . (int)$level . "'");
|
||||
$this->repairCategories($category['blog_category_id']);
|
||||
}
|
||||
}
|
||||
public function getCategory($blog_category_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT *, (SELECT GROUP_CONCAT(cd1.name ORDER BY level SEPARATOR ' > ') FROM " . DB_PREFIX . "blog_category_path cp LEFT JOIN " . DB_PREFIX . "blog_category_description cd1 ON (cp.path_id = cd1.blog_category_id AND cp.blog_category_id != cp.path_id) WHERE cp.blog_category_id = c.blog_category_id AND cd1.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY cp.blog_category_id) AS path FROM " . DB_PREFIX . "blog_category c LEFT JOIN " . DB_PREFIX . "blog_category_description cd2 ON (c.blog_category_id = cd2.blog_category_id) WHERE c.blog_category_id = '" . (int)$blog_category_id . "' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
return $query->row;
|
||||
}
|
||||
public function getCategories($data = array()) {
|
||||
$sql = "SELECT cp.blog_category_id AS blog_category_id, GROUP_CONCAT(cd1.name ORDER BY cp.level SEPARATOR ' > ') AS name, c1.parent_id, c1.sort_order, c1.noindex FROM " . DB_PREFIX . "blog_category_path cp LEFT JOIN " . DB_PREFIX . "blog_category c1 ON (cp.blog_category_id = c1.blog_category_id) LEFT JOIN " . DB_PREFIX . "blog_category c2 ON (cp.path_id = c2.blog_category_id) LEFT JOIN " . DB_PREFIX . "blog_category_description cd1 ON (cp.path_id = cd1.blog_category_id) LEFT JOIN " . DB_PREFIX . "blog_category_description cd2 ON (cp.blog_category_id = cd2.blog_category_id) WHERE cd1.language_id = '" . (int)$this->config->get('config_language_id') . "' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND cd2.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
$sql .= " GROUP BY cp.blog_category_id";
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'sort_order',
|
||||
'noindex'
|
||||
);
|
||||
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;
|
||||
}
|
||||
public function getCategoryDescriptions($blog_category_id) {
|
||||
$category_description_data = array();
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "blog_category_description WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
foreach ($query->rows as $result) {
|
||||
$category_description_data[$result['language_id']] = array(
|
||||
'name' => $result['name'],
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword'],
|
||||
'description' => $result['description']
|
||||
);
|
||||
}
|
||||
return $category_description_data;
|
||||
}
|
||||
public function getCategoryStores($blog_category_id) {
|
||||
$category_store_data = array();
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "blog_category_to_store WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
foreach ($query->rows as $result) {
|
||||
$category_store_data[] = $result['store_id'];
|
||||
}
|
||||
return $category_store_data;
|
||||
}
|
||||
|
||||
public function getCategorySeoUrls($blog_category_id) {
|
||||
$category_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'blog_category_id=" . (int)$blog_category_id . "'");
|
||||
foreach ($query->rows as $result) {
|
||||
$category_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
return $category_seo_url_data;
|
||||
}
|
||||
public function getCategoryLayouts($blog_category_id) {
|
||||
$category_layout_data = array();
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "blog_category_to_layout WHERE blog_category_id = '" . (int)$blog_category_id . "'");
|
||||
foreach ($query->rows as $result) {
|
||||
$category_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
return $category_layout_data;
|
||||
}
|
||||
public function getTotalCategories() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "blog_category");
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalCategoriesByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "blog_category_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getCategoriesByParentId($parent_id = 0) {
|
||||
$query = $this->db->query("SELECT *, (SELECT COUNT(parent_id) FROM " . DB_PREFIX . "blog_category WHERE parent_id = c.blog_category_id) AS children FROM " . DB_PREFIX . "blog_category c LEFT JOIN " . DB_PREFIX . "blog_category_description cd ON (c.blog_category_id = cd.blog_category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY c.sort_order, cd.name");
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getAllCategories() {
|
||||
$category_data = $this->cache->get('category.all.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'));
|
||||
if (!$category_data || !is_array($category_data)) {
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "blog_category c LEFT JOIN " . DB_PREFIX . "blog_category_description cd ON (c.blog_category_id = cd.blog_category_id) LEFT JOIN " . DB_PREFIX . "blog_category_to_store c2s ON (c.blog_category_id = c2s.blog_category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY c.parent_id, c.sort_order, cd.name");
|
||||
$category_data = array();
|
||||
|
||||
foreach ($query->rows as $row) {
|
||||
$category_data[$row['parent_id']][$row['blog_category_id']] = $row;
|
||||
}
|
||||
$this->cache->set('category.all.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'), $category_data);
|
||||
}
|
||||
|
||||
return $category_data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ModelBlogReview extends Model {
|
||||
public function addReview($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "review_article SET author = '" . $this->db->escape($data['author']) . "', article_id = '" . (int)$data['article_id'] . "', text = '" . $this->db->escape(strip_tags($data['text'])) . "', rating = '" . (int)$data['rating'] . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "'");
|
||||
|
||||
$review_article_id = $this->db->getLastId();
|
||||
|
||||
$this->cache->delete('article');
|
||||
|
||||
return $review_article_id;
|
||||
}
|
||||
|
||||
public function editReview($review_article_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "review_article SET author = '" . $this->db->escape($data['author']) . "', article_id = '" . (int)$data['article_id'] . "', text = '" . $this->db->escape(strip_tags($data['text'])) . "', rating = '" . (int)$data['rating'] . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "', date_modified = NOW() WHERE review_article_id = '" . (int)$review_article_id . "'");
|
||||
|
||||
$this->cache->delete('article');
|
||||
}
|
||||
|
||||
public function deleteReview($review_article_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "review_article WHERE review_article_id = '" . (int)$review_article_id . "'");
|
||||
|
||||
$this->cache->delete('article');
|
||||
}
|
||||
|
||||
public function getReview($review_article_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT *, (SELECT pd.name FROM " . DB_PREFIX . "article_description pd WHERE pd.article_id = r.article_id AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS article FROM " . DB_PREFIX . "review_article r WHERE r.review_article_id = '" . (int)$review_article_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getReviews($data = array()) {
|
||||
$sql = "SELECT r.review_article_id, pd.name, r.author, r.rating, r.status, r.date_added FROM " . DB_PREFIX . "review_article r LEFT JOIN " . DB_PREFIX . "article_description pd ON (r.article_id = pd.article_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_article'])) {
|
||||
$sql .= " AND pd.name LIKE '" . $this->db->escape($data['filter_article']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_author'])) {
|
||||
$sql .= " AND r.author LIKE '" . $this->db->escape($data['filter_author']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && $data['filter_status'] !== '') {
|
||||
$sql .= " AND r.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(r.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'pd.name',
|
||||
'r.author',
|
||||
'r.rating',
|
||||
'r.status',
|
||||
'r.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY r.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;
|
||||
}
|
||||
|
||||
public function getTotalReviews($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review_article r LEFT JOIN " . DB_PREFIX . "article_description pd ON (r.article_id = pd.article_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_article'])) {
|
||||
$sql .= " AND pd.name LIKE '" . $this->db->escape($data['filter_article']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_author'])) {
|
||||
$sql .= " AND r.author LIKE '" . $this->db->escape($data['filter_author']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && $data['filter_status'] !== '') {
|
||||
$sql .= " AND r.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(r.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalReviewsAwaitingApproval() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review_article WHERE status = '0'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
class ModelCatalogAttribute extends Model {
|
||||
public function addAttribute($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "attribute SET attribute_group_id = '" . (int)$data['attribute_group_id'] . "', sort_order = '" . (int)$data['sort_order'] . "'");
|
||||
|
||||
$attribute_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['attribute_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_description SET attribute_id = '" . (int)$attribute_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
return $attribute_id;
|
||||
}
|
||||
|
||||
public function editAttribute($attribute_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "attribute SET attribute_group_id = '" . (int)$data['attribute_group_id'] . "', sort_order = '" . (int)$data['sort_order'] . "' WHERE attribute_id = '" . (int)$attribute_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_description WHERE attribute_id = '" . (int)$attribute_id . "'");
|
||||
|
||||
foreach ($data['attribute_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_description SET attribute_id = '" . (int)$attribute_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAttribute($attribute_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute WHERE attribute_id = '" . (int)$attribute_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_description WHERE attribute_id = '" . (int)$attribute_id . "'");
|
||||
}
|
||||
|
||||
public function getAttribute($attribute_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE a.attribute_id = '" . (int)$attribute_id . "' AND ad.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getAttributes($data = array()) {
|
||||
$sql = "SELECT *, (SELECT agd.name FROM " . DB_PREFIX . "attribute_group_description agd WHERE agd.attribute_group_id = a.attribute_group_id AND agd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS attribute_group FROM " . DB_PREFIX . "attribute a LEFT JOIN " . DB_PREFIX . "attribute_description ad ON (a.attribute_id = ad.attribute_id) WHERE ad.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND ad.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_attribute_group_id'])) {
|
||||
$sql .= " AND a.attribute_group_id = '" . $this->db->escape($data['filter_attribute_group_id']) . "'";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'ad.name',
|
||||
'attribute_group',
|
||||
'a.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY attribute_group, ad.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getAttributeDescriptions($attribute_id) {
|
||||
$attribute_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "attribute_description WHERE attribute_id = '" . (int)$attribute_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$attribute_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $attribute_data;
|
||||
}
|
||||
|
||||
public function getTotalAttributes() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "attribute");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalAttributesByAttributeGroupId($attribute_group_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "attribute WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
class ModelCatalogAttributeGroup extends Model {
|
||||
public function addAttributeGroup($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_group SET sort_order = '" . (int)$data['sort_order'] . "'");
|
||||
|
||||
$attribute_group_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['attribute_group_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_group_description SET attribute_group_id = '" . (int)$attribute_group_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
return $attribute_group_id;
|
||||
}
|
||||
|
||||
public function editAttributeGroup($attribute_group_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "attribute_group SET sort_order = '" . (int)$data['sort_order'] . "' WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_group_description WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
|
||||
|
||||
foreach ($data['attribute_group_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_group_description SET attribute_group_id = '" . (int)$attribute_group_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteAttributeGroup($attribute_group_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_group WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "attribute_group_description WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
|
||||
}
|
||||
|
||||
public function getAttributeGroup($attribute_group_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "attribute_group WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getAttributeGroups($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "attribute_group ag LEFT JOIN " . DB_PREFIX . "attribute_group_description agd ON (ag.attribute_group_id = agd.attribute_group_id) WHERE agd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sort_data = array(
|
||||
'agd.name',
|
||||
'ag.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY agd.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getAttributeGroupDescriptions($attribute_group_id) {
|
||||
$attribute_group_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "attribute_group_description WHERE attribute_group_id = '" . (int)$attribute_group_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$attribute_group_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $attribute_group_data;
|
||||
}
|
||||
|
||||
public function getTotalAttributeGroups() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "attribute_group");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,486 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ModelCatalogCategory extends Model {
|
||||
public function addCategory($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category SET parent_id = '" . (int)$data['parent_id'] . "', `top` = '" . (isset($data['top']) ? (int)$data['top'] : 0) . "', `column` = '" . (int)$data['column'] . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', date_modified = NOW(), date_added = NOW()");
|
||||
|
||||
$category_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "category SET image = '" . $this->db->escape($data['image']) . "' WHERE category_id = '" . (int)$category_id . "'");
|
||||
}
|
||||
|
||||
foreach ($data['category_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
// MySQL Hierarchical Data Closure Table Pattern
|
||||
$level = 0;
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "category_path` WHERE category_id = '" . (int)$data['parent_id'] . "' ORDER BY `level` ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "category_path` SET `category_id` = '" . (int)$category_id . "', `path_id` = '" . (int)$result['path_id'] . "', `level` = '" . (int)$level . "'");
|
||||
|
||||
$level++;
|
||||
}
|
||||
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "category_path` SET `category_id` = '" . (int)$category_id . "', `path_id` = '" . (int)$category_id . "', `level` = '" . (int)$level . "'");
|
||||
|
||||
if (isset($data['category_filter'])) {
|
||||
foreach ($data['category_filter'] as $filter_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category_filter SET category_id = '" . (int)$category_id . "', filter_id = '" . (int)$filter_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['category_store'])) {
|
||||
foreach ($data['category_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category_to_store SET category_id = '" . (int)$category_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['category_seo_url'])) {
|
||||
foreach ($data['category_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'category_id=" . (int)$category_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related_wb SET category_id = '" . (int)$category_id . "', product_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['article_related'])) {
|
||||
foreach ($data['article_related'] as $related_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related_wb SET category_id = '" . (int)$category_id . "', article_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// Set which layout to use with this category
|
||||
if (isset($data['category_layout'])) {
|
||||
foreach ($data['category_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category_to_layout SET category_id = '" . (int)$category_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('category');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
|
||||
return $category_id;
|
||||
}
|
||||
|
||||
public function editCategory($category_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "category SET parent_id = '" . (int)$data['parent_id'] . "', `top` = '" . (isset($data['top']) ? (int)$data['top'] : 0) . "', `column` = '" . (int)$data['column'] . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', date_modified = NOW() WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "category SET image = '" . $this->db->escape($data['image']) . "' WHERE category_id = '" . (int)$category_id . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_description WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($data['category_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
// MySQL Hierarchical Data Closure Table Pattern
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "category_path` WHERE path_id = '" . (int)$category_id . "' ORDER BY level ASC");
|
||||
|
||||
if ($query->rows) {
|
||||
foreach ($query->rows as $category_path) {
|
||||
// Delete the path below the current one
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "category_path` WHERE category_id = '" . (int)$category_path['category_id'] . "' AND level < '" . (int)$category_path['level'] . "'");
|
||||
|
||||
$path = array();
|
||||
|
||||
// Get the nodes new parents
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "category_path` WHERE category_id = '" . (int)$data['parent_id'] . "' ORDER BY level ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$path[] = $result['path_id'];
|
||||
}
|
||||
|
||||
// Get whats left of the nodes current path
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "category_path` WHERE category_id = '" . (int)$category_path['category_id'] . "' ORDER BY level ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$path[] = $result['path_id'];
|
||||
}
|
||||
|
||||
// Combine the paths with a new level
|
||||
$level = 0;
|
||||
|
||||
foreach ($path as $path_id) {
|
||||
$this->db->query("REPLACE INTO `" . DB_PREFIX . "category_path` SET category_id = '" . (int)$category_path['category_id'] . "', `path_id` = '" . (int)$path_id . "', level = '" . (int)$level . "'");
|
||||
|
||||
$level++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Delete the path below the current one
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "category_path` WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
// Fix for records with no paths
|
||||
$level = 0;
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "category_path` WHERE category_id = '" . (int)$data['parent_id'] . "' ORDER BY level ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "category_path` SET category_id = '" . (int)$category_id . "', `path_id` = '" . (int)$result['path_id'] . "', level = '" . (int)$level . "'");
|
||||
|
||||
$level++;
|
||||
}
|
||||
|
||||
$this->db->query("REPLACE INTO `" . DB_PREFIX . "category_path` SET category_id = '" . (int)$category_id . "', `path_id` = '" . (int)$category_id . "', level = '" . (int)$level . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_filter WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['category_filter'])) {
|
||||
foreach ($data['category_filter'] as $filter_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category_filter SET category_id = '" . (int)$category_id . "', filter_id = '" . (int)$filter_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_to_store WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['category_store'])) {
|
||||
foreach ($data['category_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category_to_store SET category_id = '" . (int)$category_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE query = 'category_id=" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['category_seo_url'])) {
|
||||
foreach ($data['category_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'category_id=" . (int)$category_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related_wb WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related_wb WHERE category_id = '" . (int)$category_id . "' AND product_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related_wb SET category_id = '" . (int)$category_id . "', product_id = '" . (int)$related_id . "'");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related_wb WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['article_related'])) {
|
||||
foreach ($data['article_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related_wb WHERE category_id = '" . (int)$category_id . "' AND article_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related_wb SET category_id = '" . (int)$category_id . "', article_id = '" . (int)$related_id . "'");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_to_layout WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['category_layout'])) {
|
||||
foreach ($data['category_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category_to_layout SET category_id = '" . (int)$category_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('category');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
}
|
||||
|
||||
public function editCategoryStatus($category_id, $status) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "category SET status = '" . (int)$status . "', date_modified = NOW() WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
$this->cache->delete('category');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function deleteCategory($category_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_path WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_path WHERE path_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$this->deleteCategory($result['category_id']);
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_description WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_filter WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_to_store WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_to_layout WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'category_id=" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related_wb WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related_wb WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_category WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
$this->cache->delete('category');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
}
|
||||
|
||||
public function repairCategories($parent_id = 0) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category WHERE parent_id = '" . (int)$parent_id . "'");
|
||||
|
||||
foreach ($query->rows as $category) {
|
||||
// Delete the path below the current one
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "category_path` WHERE category_id = '" . (int)$category['category_id'] . "'");
|
||||
|
||||
// Fix for records with no paths
|
||||
$level = 0;
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "category_path` WHERE category_id = '" . (int)$parent_id . "' ORDER BY level ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "category_path` SET category_id = '" . (int)$category['category_id'] . "', `path_id` = '" . (int)$result['path_id'] . "', level = '" . (int)$level . "'");
|
||||
|
||||
$level++;
|
||||
}
|
||||
|
||||
$this->db->query("REPLACE INTO `" . DB_PREFIX . "category_path` SET category_id = '" . (int)$category['category_id'] . "', `path_id` = '" . (int)$category['category_id'] . "', level = '" . (int)$level . "'");
|
||||
|
||||
$this->repairCategories($category['category_id']);
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategory($category_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT *, (SELECT GROUP_CONCAT(cd1.name ORDER BY level SEPARATOR ' > ') FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "category_description cd1 ON (cp.path_id = cd1.category_id AND cp.category_id != cp.path_id) WHERE cp.category_id = c.category_id AND cd1.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY cp.category_id) AS path FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd2 ON (c.category_id = cd2.category_id) WHERE c.category_id = '" . (int)$category_id . "' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getAllCategories() {
|
||||
$result = $this->cache->get('category.all.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'));
|
||||
|
||||
if (!$result || !is_array($result)) {
|
||||
$query = $this->db->query("SELECT c.category_id, c.parent_id, name FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY c.parent_id, c.sort_order, cd.name");
|
||||
|
||||
$categories = array();
|
||||
|
||||
foreach ($query->rows as $row) {
|
||||
$categories[$row['parent_id']][$row['category_id']] = $row;
|
||||
}
|
||||
|
||||
$result = $this->getCategories($categories);
|
||||
|
||||
$this->cache->set('category.all.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'), $result);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getCategories($data = array()) {
|
||||
$sql = "SELECT cp.category_id AS category_id, GROUP_CONCAT(cd1.name ORDER BY cp.level SEPARATOR ' > ') AS name, c1.parent_id, c1.sort_order, c1.noindex FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "category c1 ON (cp.category_id = c1.category_id) LEFT JOIN " . DB_PREFIX . "category c2 ON (cp.path_id = c2.category_id) LEFT JOIN " . DB_PREFIX . "category_description cd1 ON (cp.path_id = cd1.category_id) LEFT JOIN " . DB_PREFIX . "category_description cd2 ON (cp.category_id = cd2.category_id) WHERE cd1.language_id = '" . (int)$this->config->get('config_language_id') . "' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND cd2.name LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY cp.category_id";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'sort_order',
|
||||
'noindex'
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getCategoryDescriptions($category_id) {
|
||||
$category_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_description WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_description_data[$result['language_id']] = array(
|
||||
'name' => $result['name'],
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword'],
|
||||
'description' => $result['description']
|
||||
);
|
||||
}
|
||||
|
||||
return $category_description_data;
|
||||
}
|
||||
|
||||
public function getCategoryPath($category_id) {
|
||||
$query = $this->db->query("SELECT category_id, path_id, level FROM " . DB_PREFIX . "category_path WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getCategoryFilters($category_id) {
|
||||
$category_filter_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_filter WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_filter_data[] = $result['filter_id'];
|
||||
}
|
||||
|
||||
return $category_filter_data;
|
||||
}
|
||||
|
||||
public function getCategoryStores($category_id) {
|
||||
$category_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_to_store WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $category_store_data;
|
||||
}
|
||||
|
||||
public function getCategorySeoUrls($category_id) {
|
||||
$category_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'category_id=" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
|
||||
return $category_seo_url_data;
|
||||
}
|
||||
|
||||
public function getCategoryRelated($category_id) {
|
||||
$category_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related_wb WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_related_data[] = $result['related_id'];
|
||||
}
|
||||
|
||||
return $product_related_data;
|
||||
}
|
||||
|
||||
public function getCategoryRelated_article($category_id) {
|
||||
$category_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_related_wb WHERE article_id = '" . (int)$article_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_related_data[] = $result['related_id'];
|
||||
}
|
||||
|
||||
return $article_related_data;
|
||||
}
|
||||
|
||||
public function getCategoryLayouts($category_id) {
|
||||
$category_layout_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_to_layout WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
|
||||
return $category_layout_data;
|
||||
}
|
||||
|
||||
public function getTotalCategories() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "category");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalCategoriesByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "category_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getCategoriesByParentId($parent_id = 0) {
|
||||
$query = $this->db->query("SELECT *, (SELECT COUNT(parent_id) FROM " . DB_PREFIX . "category WHERE parent_id = c.category_id) AS children FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY c.sort_order, cd.name");
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getCategoriesChildren($parent_id = 0) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_path WHERE path_id = '" . (int)$parent_id . "'");
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getProductRelated($category_id) {
|
||||
$product_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related_wb WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_related_data[] = $result['product_id'];
|
||||
}
|
||||
|
||||
return $product_related_data;
|
||||
}
|
||||
|
||||
public function getArticleRelated($category_id) {
|
||||
$article_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_related_wb WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_related_data[] = $result['article_id'];
|
||||
}
|
||||
|
||||
return $article_related_data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
class ModelCatalogDownload extends Model {
|
||||
public function addDownload($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "download SET filename = '" . $this->db->escape($data['filename']) . "', mask = '" . $this->db->escape($data['mask']) . "', date_added = NOW()");
|
||||
|
||||
$download_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['download_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "download_description SET download_id = '" . (int)$download_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
return $download_id;
|
||||
}
|
||||
|
||||
public function editDownload($download_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "download SET filename = '" . $this->db->escape($data['filename']) . "', mask = '" . $this->db->escape($data['mask']) . "' WHERE download_id = '" . (int)$download_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "download_description WHERE download_id = '" . (int)$download_id . "'");
|
||||
|
||||
foreach ($data['download_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "download_description SET download_id = '" . (int)$download_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteDownload($download_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "download WHERE download_id = '" . (int)$download_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "download_description WHERE download_id = '" . (int)$download_id . "'");
|
||||
}
|
||||
|
||||
public function getDownload($download_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "download d LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE d.download_id = '" . (int)$download_id . "' AND dd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getDownloads($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "download d LEFT JOIN " . DB_PREFIX . "download_description dd ON (d.download_id = dd.download_id) WHERE dd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND dd.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'dd.name',
|
||||
'd.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY dd.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getDownloadDescriptions($download_id) {
|
||||
$download_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "download_description WHERE download_id = '" . (int)$download_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$download_description_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $download_description_data;
|
||||
}
|
||||
|
||||
public function getTotalDownloads() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "download");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
class ModelCatalogFilter extends Model {
|
||||
public function addFilter($data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "filter_group` SET sort_order = '" . (int)$data['sort_order'] . "'");
|
||||
|
||||
$filter_group_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['filter_group_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "filter_group_description SET filter_group_id = '" . (int)$filter_group_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['filter'])) {
|
||||
foreach ($data['filter'] as $filter) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "filter SET filter_group_id = '" . (int)$filter_group_id . "', sort_order = '" . (int)$filter['sort_order'] . "'");
|
||||
|
||||
$filter_id = $this->db->getLastId();
|
||||
|
||||
foreach ($filter['filter_description'] as $language_id => $filter_description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "filter_description SET filter_id = '" . (int)$filter_id . "', language_id = '" . (int)$language_id . "', filter_group_id = '" . (int)$filter_group_id . "', name = '" . $this->db->escape($filter_description['name']) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $filter_group_id;
|
||||
}
|
||||
|
||||
public function editFilter($filter_group_id, $data) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "filter_group` SET sort_order = '" . (int)$data['sort_order'] . "' WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "filter_group_description WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
|
||||
foreach ($data['filter_group_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "filter_group_description SET filter_group_id = '" . (int)$filter_group_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "filter WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "filter_description WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
|
||||
if (isset($data['filter'])) {
|
||||
foreach ($data['filter'] as $filter) {
|
||||
if ($filter['filter_id']) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "filter SET filter_id = '" . (int)$filter['filter_id'] . "', filter_group_id = '" . (int)$filter_group_id . "', sort_order = '" . (int)$filter['sort_order'] . "'");
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "filter SET filter_group_id = '" . (int)$filter_group_id . "', sort_order = '" . (int)$filter['sort_order'] . "'");
|
||||
}
|
||||
|
||||
$filter_id = $this->db->getLastId();
|
||||
|
||||
foreach ($filter['filter_description'] as $language_id => $filter_description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "filter_description SET filter_id = '" . (int)$filter_id . "', language_id = '" . (int)$language_id . "', filter_group_id = '" . (int)$filter_group_id . "', name = '" . $this->db->escape($filter_description['name']) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteFilter($filter_group_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "filter_group` WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "filter_group_description` WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "filter` WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "filter_description` WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
}
|
||||
|
||||
public function getFilterGroup($filter_group_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "filter_group` fg LEFT JOIN " . DB_PREFIX . "filter_group_description fgd ON (fg.filter_group_id = fgd.filter_group_id) WHERE fg.filter_group_id = '" . (int)$filter_group_id . "' AND fgd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getFilterGroups($data = array()) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "filter_group` fg LEFT JOIN " . DB_PREFIX . "filter_group_description fgd ON (fg.filter_group_id = fgd.filter_group_id) WHERE fgd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sort_data = array(
|
||||
'fgd.name',
|
||||
'fg.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY fgd.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getFilterGroupDescriptions($filter_group_id) {
|
||||
$filter_group_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "filter_group_description WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$filter_group_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $filter_group_data;
|
||||
}
|
||||
|
||||
public function getFilter($filter_id) {
|
||||
$query = $this->db->query("SELECT *, (SELECT name FROM " . DB_PREFIX . "filter_group_description fgd WHERE f.filter_group_id = fgd.filter_group_id AND fgd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS `group` FROM " . DB_PREFIX . "filter f LEFT JOIN " . DB_PREFIX . "filter_description fd ON (f.filter_id = fd.filter_id) WHERE f.filter_id = '" . (int)$filter_id . "' AND fd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getFilters($data) {
|
||||
$sql = "SELECT *, (SELECT name FROM " . DB_PREFIX . "filter_group_description fgd WHERE f.filter_group_id = fgd.filter_group_id AND fgd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS `group` FROM " . DB_PREFIX . "filter f LEFT JOIN " . DB_PREFIX . "filter_description fd ON (f.filter_id = fd.filter_id) WHERE fd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND fd.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY f.sort_order 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;
|
||||
}
|
||||
|
||||
public function getFilterDescriptions($filter_group_id) {
|
||||
$filter_data = array();
|
||||
|
||||
$filter_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "filter WHERE filter_group_id = '" . (int)$filter_group_id . "'");
|
||||
|
||||
foreach ($filter_query->rows as $filter) {
|
||||
$filter_description_data = array();
|
||||
|
||||
$filter_description_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "filter_description WHERE filter_id = '" . (int)$filter['filter_id'] . "'");
|
||||
|
||||
foreach ($filter_description_query->rows as $filter_description) {
|
||||
$filter_description_data[$filter_description['language_id']] = array('name' => $filter_description['name']);
|
||||
}
|
||||
|
||||
$filter_data[] = array(
|
||||
'filter_id' => $filter['filter_id'],
|
||||
'filter_description' => $filter_description_data,
|
||||
'sort_order' => $filter['sort_order']
|
||||
);
|
||||
}
|
||||
|
||||
return $filter_data;
|
||||
}
|
||||
|
||||
public function getTotalFilterGroups() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "filter_group`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ModelCatalogInformation extends Model {
|
||||
public function addInformation($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "information SET sort_order = '" . (int)$data['sort_order'] . "', bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "'");
|
||||
|
||||
$information_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['information_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET information_id = '" . (int)$information_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['information_store'])) {
|
||||
foreach ($data['information_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "information_to_store SET information_id = '" . (int)$information_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
if (isset($data['information_seo_url'])) {
|
||||
foreach ($data['information_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'information_id=" . (int)$information_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['information_layout'])) {
|
||||
foreach ($data['information_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "information_to_layout SET information_id = '" . (int)$information_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('information');
|
||||
|
||||
return $information_id;
|
||||
}
|
||||
|
||||
public function editInformation($information_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "information SET sort_order = '" . (int)$data['sort_order'] . "', bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "' WHERE information_id = '" . (int)$information_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "information_description WHERE information_id = '" . (int)$information_id . "'");
|
||||
|
||||
foreach ($data['information_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET information_id = '" . (int)$information_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "information_to_store WHERE information_id = '" . (int)$information_id . "'");
|
||||
|
||||
if (isset($data['information_store'])) {
|
||||
foreach ($data['information_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "information_to_store SET information_id = '" . (int)$information_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'information_id=" . (int)$information_id . "'");
|
||||
|
||||
if (isset($data['information_seo_url'])) {
|
||||
foreach ($data['information_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (trim($keyword)) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "seo_url` SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'information_id=" . (int)$information_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "information_to_layout` WHERE information_id = '" . (int)$information_id . "'");
|
||||
|
||||
if (isset($data['information_layout'])) {
|
||||
foreach ($data['information_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "information_to_layout` SET information_id = '" . (int)$information_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('information');
|
||||
}
|
||||
|
||||
public function editInformationStatus($information_id, $status) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "information SET status = '" . (int)$status . "'WHERE information_id = '" . (int)$information_id . "'");
|
||||
|
||||
$this->cache->delete('information');
|
||||
|
||||
}
|
||||
|
||||
public function deleteInformation($information_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "information` WHERE information_id = '" . (int)$information_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "information_description` WHERE information_id = '" . (int)$information_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "information_to_store` WHERE information_id = '" . (int)$information_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "information_to_layout` WHERE information_id = '" . (int)$information_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE query = 'information_id=" . (int)$information_id . "'");
|
||||
|
||||
$this->cache->delete('information');
|
||||
}
|
||||
|
||||
public function getInformation($information_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "information WHERE information_id = '" . (int)$information_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getInformations($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sort_data = array(
|
||||
'id.title',
|
||||
'i.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY id.title";
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
$information_data = $this->cache->get('information.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$information_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information i LEFT JOIN " . DB_PREFIX . "information_description id ON (i.information_id = id.information_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY id.title");
|
||||
|
||||
$information_data = $query->rows;
|
||||
|
||||
$this->cache->set('information.' . (int)$this->config->get('config_language_id'), $information_data);
|
||||
}
|
||||
|
||||
return $information_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getInformationDescriptions($information_id) {
|
||||
$information_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_description WHERE information_id = '" . (int)$information_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$information_description_data[$result['language_id']] = array(
|
||||
'title' => $result['title'],
|
||||
'description' => $result['description'],
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword']
|
||||
);
|
||||
}
|
||||
|
||||
return $information_description_data;
|
||||
}
|
||||
|
||||
public function getInformationStores($information_id) {
|
||||
$information_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_to_store WHERE information_id = '" . (int)$information_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$information_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $information_store_data;
|
||||
}
|
||||
|
||||
public function getInformationSeoUrls($information_id) {
|
||||
$information_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'information_id=" . (int)$information_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$information_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
|
||||
return $information_seo_url_data;
|
||||
}
|
||||
|
||||
public function getInformationLayouts($information_id) {
|
||||
$information_layout_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_to_layout WHERE information_id = '" . (int)$information_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$information_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
|
||||
return $information_layout_data;
|
||||
}
|
||||
|
||||
public function getTotalInformations() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "information");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalInformationsByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "information_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ModelCatalogManufacturer extends Model {
|
||||
public function addManufacturer($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer SET name = '" . $this->db->escape($data['name']) . "', sort_order = '" . (int)$data['sort_order'] . "', noindex = '" . (int)$data['noindex'] . "'");
|
||||
|
||||
$manufacturer_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['manufacturer_layout'])) {
|
||||
foreach ($data['manufacturer_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_to_layout SET manufacturer_id = '" . (int)$manufacturer_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "manufacturer SET image = '" . $this->db->escape($data['image']) . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
}
|
||||
|
||||
foreach ($data['manufacturer_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_description SET manufacturer_id = '" . (int)$manufacturer_id . "', language_id = '" . (int)$language_id . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['manufacturer_store'])) {
|
||||
foreach ($data['manufacturer_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_to_store SET manufacturer_id = '" . (int)$manufacturer_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related_mn SET manufacturer_id = '" . (int)$manufacturer_id . "', product_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['article_related'])) {
|
||||
foreach ($data['article_related'] as $related_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related_mn SET manufacturer_id = '" . (int)$manufacturer_id . "', article_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
if (isset($data['manufacturer_seo_url'])) {
|
||||
foreach ($data['manufacturer_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'manufacturer_id=" . (int)$manufacturer_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('manufacturer');
|
||||
|
||||
return $manufacturer_id;
|
||||
}
|
||||
|
||||
public function editManufacturer($manufacturer_id, $data) {
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "manufacturer_to_layout WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
if (isset($data['manufacturer_layout'])) {
|
||||
foreach ($data['manufacturer_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_to_layout SET manufacturer_id = '" . (int)$manufacturer_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "manufacturer SET name = '" . $this->db->escape($data['name']) . "', sort_order = '" . (int)$data['sort_order'] . "', noindex = '" . (int)$data['noindex'] . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "manufacturer SET image = '" . $this->db->escape($data['image']) . "' WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "manufacturer_description WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
foreach ($data['manufacturer_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_description SET manufacturer_id = '" . (int)$manufacturer_id . "', language_id = '" . (int)$language_id . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "manufacturer_to_store WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
if (isset($data['manufacturer_store'])) {
|
||||
foreach ($data['manufacturer_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "manufacturer_to_store SET manufacturer_id = '" . (int)$manufacturer_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related_mn WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related_mn WHERE manufacturer_id = '" . (int)$manufacturer_id . "' AND product_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related_mn SET manufacturer_id = '" . (int)$manufacturer_id . "', product_id = '" . (int)$related_id . "'");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related_mn WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
if (isset($data['article_related'])) {
|
||||
foreach ($data['article_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_related_mn WHERE manufacturer_id = '" . (int)$manufacturer_id . "' AND article_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "article_related_mn SET manufacturer_id = '" . (int)$manufacturer_id . "', article_id = '" . (int)$related_id . "'");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE query = 'manufacturer_id=" . (int)$manufacturer_id . "'");
|
||||
|
||||
if (isset($data['manufacturer_seo_url'])) {
|
||||
foreach ($data['manufacturer_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "seo_url` SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'manufacturer_id=" . (int)$manufacturer_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('manufacturer');
|
||||
}
|
||||
|
||||
public function deleteManufacturer($manufacturer_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "manufacturer` WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "manufacturer_to_layout` WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "manufacturer_description` WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "manufacturer_to_store` WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE query = 'manufacturer_id=" . (int)$manufacturer_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "product_related_mn` WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "article_related_mn` WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
$this->cache->delete('manufacturer');
|
||||
}
|
||||
|
||||
public function getManufacturer($manufacturer_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "manufacturer WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getManufacturers($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "manufacturer";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " WHERE name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getManufacturerStores($manufacturer_id) {
|
||||
$manufacturer_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "manufacturer_to_store WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$manufacturer_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $manufacturer_store_data;
|
||||
}
|
||||
|
||||
public function getManufacturerSeoUrls($manufacturer_id) {
|
||||
$manufacturer_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'manufacturer_id=" . (int)$manufacturer_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$manufacturer_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
|
||||
return $manufacturer_seo_url_data;
|
||||
}
|
||||
|
||||
public function getManufacturerLayouts($manufacturer_id) {
|
||||
$manufacturer_layout_data = array();
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "manufacturer_to_layout WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
foreach ($query->rows as $result) {
|
||||
$manufacturer_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
return $manufacturer_layout_data;
|
||||
}
|
||||
|
||||
public function getTotalManufacturerByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "manufacturer_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalManufacturers() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "manufacturer");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getManufacturerDescriptions($manufacturer_id) {
|
||||
$manufacturer_description_data = array();
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "manufacturer_description WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
foreach ($query->rows as $result) {
|
||||
$manufacturer_description_data[$result['language_id']] = array(
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword'],
|
||||
'description' => $result['description']
|
||||
);
|
||||
}
|
||||
return $manufacturer_description_data;
|
||||
}
|
||||
|
||||
public function getProductRelated($manufacturer_id) {
|
||||
$product_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related_mn WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_related_data[] = $result['product_id'];
|
||||
}
|
||||
|
||||
return $product_related_data;
|
||||
}
|
||||
|
||||
public function getArticleRelated($manufacturer_id) {
|
||||
$article_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "article_related_mn WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_related_data[] = $result['article_id'];
|
||||
}
|
||||
|
||||
return $article_related_data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
class ModelCatalogOption extends Model {
|
||||
public function addOption($data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "option` SET type = '" . $this->db->escape($data['type']) . "', sort_order = '" . (int)$data['sort_order'] . "'");
|
||||
|
||||
$option_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['option_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "option_description SET option_id = '" . (int)$option_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['option_value'])) {
|
||||
foreach ($data['option_value'] as $option_value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "option_value SET option_id = '" . (int)$option_id . "', image = '" . $this->db->escape(html_entity_decode($option_value['image'], ENT_QUOTES, 'UTF-8')) . "', sort_order = '" . (int)$option_value['sort_order'] . "'");
|
||||
|
||||
$option_value_id = $this->db->getLastId();
|
||||
|
||||
foreach ($option_value['option_value_description'] as $language_id => $option_value_description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "option_value_description SET option_value_id = '" . (int)$option_value_id . "', language_id = '" . (int)$language_id . "', option_id = '" . (int)$option_id . "', name = '" . $this->db->escape($option_value_description['name']) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $option_id;
|
||||
}
|
||||
|
||||
public function editOption($option_id, $data) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "option` SET type = '" . $this->db->escape($data['type']) . "', sort_order = '" . (int)$data['sort_order'] . "' WHERE option_id = '" . (int)$option_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "option_description WHERE option_id = '" . (int)$option_id . "'");
|
||||
|
||||
foreach ($data['option_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "option_description SET option_id = '" . (int)$option_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "option_value_description WHERE option_id = '" . (int)$option_id . "'");
|
||||
|
||||
if (isset($data['option_value'])) {
|
||||
foreach ($data['option_value'] as $option_value) {
|
||||
if ($option_value['option_value_id']) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "option_value SET option_value_id = '" . (int)$option_value['option_value_id'] . "', option_id = '" . (int)$option_id . "', image = '" . $this->db->escape(html_entity_decode($option_value['image'], ENT_QUOTES, 'UTF-8')) . "', sort_order = '" . (int)$option_value['sort_order'] . "'");
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "option_value SET option_id = '" . (int)$option_id . "', image = '" . $this->db->escape(html_entity_decode($option_value['image'], ENT_QUOTES, 'UTF-8')) . "', sort_order = '" . (int)$option_value['sort_order'] . "'");
|
||||
}
|
||||
|
||||
$option_value_id = $this->db->getLastId();
|
||||
|
||||
foreach ($option_value['option_value_description'] as $language_id => $option_value_description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "option_value_description SET option_value_id = '" . (int)$option_value_id . "', language_id = '" . (int)$language_id . "', option_id = '" . (int)$option_id . "', name = '" . $this->db->escape($option_value_description['name']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteOption($option_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "option` WHERE option_id = '" . (int)$option_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "option_description WHERE option_id = '" . (int)$option_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "option_value_description WHERE option_id = '" . (int)$option_id . "'");
|
||||
}
|
||||
|
||||
public function getOption($option_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "option` o LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE o.option_id = '" . (int)$option_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getOptions($data = array()) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "option` o LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) WHERE od.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND od.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'od.name',
|
||||
'o.type',
|
||||
'o.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY od.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getOptionDescriptions($option_id) {
|
||||
$option_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_description WHERE option_id = '" . (int)$option_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$option_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $option_data;
|
||||
}
|
||||
|
||||
public function getOptionValue($option_value_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value ov LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE ov.option_value_id = '" . (int)$option_value_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getOptionValues($option_id) {
|
||||
$option_value_data = array();
|
||||
|
||||
$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value ov LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE ov.option_id = '" . (int)$option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY ov.sort_order, ovd.name");
|
||||
|
||||
foreach ($option_value_query->rows as $option_value) {
|
||||
$option_value_data[] = array(
|
||||
'option_value_id' => $option_value['option_value_id'],
|
||||
'name' => $option_value['name'],
|
||||
'image' => $option_value['image'],
|
||||
'sort_order' => $option_value['sort_order']
|
||||
);
|
||||
}
|
||||
|
||||
return $option_value_data;
|
||||
}
|
||||
|
||||
public function getOptionValueDescriptions($option_id) {
|
||||
$option_value_data = array();
|
||||
|
||||
$option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value WHERE option_id = '" . (int)$option_id . "' ORDER BY sort_order");
|
||||
|
||||
foreach ($option_value_query->rows as $option_value) {
|
||||
$option_value_description_data = array();
|
||||
|
||||
$option_value_description_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value_description WHERE option_value_id = '" . (int)$option_value['option_value_id'] . "'");
|
||||
|
||||
foreach ($option_value_description_query->rows as $option_value_description) {
|
||||
$option_value_description_data[$option_value_description['language_id']] = array('name' => $option_value_description['name']);
|
||||
}
|
||||
|
||||
$option_value_data[] = array(
|
||||
'option_value_id' => $option_value['option_value_id'],
|
||||
'option_value_description' => $option_value_description_data,
|
||||
'image' => $option_value['image'],
|
||||
'sort_order' => $option_value['sort_order']
|
||||
);
|
||||
}
|
||||
|
||||
return $option_value_data;
|
||||
}
|
||||
|
||||
public function getTotalOptions() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "option`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,917 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ModelCatalogProduct extends Model {
|
||||
public function addProduct($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "',price_2 = '" . (float)$data['price_2'] . "',price_3 = '" . (float)$data['price_3'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW(), date_modified = NOW()");
|
||||
|
||||
$product_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape($data['image']) . "' WHERE product_id = '" . (int)$product_id . "'");
|
||||
}
|
||||
|
||||
foreach ($data['product_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', tag = '" . $this->db->escape($value['tag']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['product_store'])) {
|
||||
foreach ($data['product_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_store SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_attribute'])) {
|
||||
foreach ($data['product_attribute'] as $product_attribute) {
|
||||
if ($product_attribute['attribute_id']) {
|
||||
// Removes duplicates
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "'");
|
||||
|
||||
foreach ($product_attribute['product_attribute_description'] as $language_id => $product_attribute_description) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "' AND language_id = '" . (int)$language_id . "'");
|
||||
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_id . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" . $this->db->escape($product_attribute_description['text']) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_option'])) {
|
||||
foreach ($data['product_option'] as $product_option) {
|
||||
if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
|
||||
if (isset($product_option['product_option_value'])) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', required = '" . (int)$product_option['required'] . "'");
|
||||
|
||||
$product_option_id = $this->db->getLastId();
|
||||
|
||||
foreach ($product_option['product_option_value'] as $product_option_value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value_id = '" . (int)$product_option_value['option_value_id'] . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', price_prefix = '" . $this->db->escape($product_option_value['price_prefix']) . "', points = '" . (int)$product_option_value['points'] . "', points_prefix = '" . $this->db->escape($product_option_value['points_prefix']) . "', weight = '" . (float)$product_option_value['weight'] . "', weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', value = '" . $this->db->escape($product_option['value']) . "', required = '" . (int)$product_option['required'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_recurring'])) {
|
||||
foreach ($data['product_recurring'] as $recurring) {
|
||||
|
||||
$query = $this->db->query("SELECT `product_id` FROM `" . DB_PREFIX . "product_recurring` WHERE `product_id` = '" . (int)$product_id . "' AND `customer_group_id = '" . (int)$recurring['customer_group_id'] . "' AND `recurring_id` = '" . (int)$recurring['recurring_id'] . "'");
|
||||
|
||||
if (!$query->num_rows) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "product_recurring` SET `product_id` = '" . (int)$product_id . "', customer_group_id = '" . (int)$recurring['customer_group_id'] . "', `recurring_id` = '" . (int)$recurring['recurring_id'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_discount'])) {
|
||||
foreach ($data['product_discount'] as $product_discount) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_discount SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_discount['customer_group_id'] . "', quantity = '" . (int)$product_discount['quantity'] . "', priority = '" . (int)$product_discount['priority'] . "', price = '" . (float)$product_discount['price'] . "', date_start = '" . $this->db->escape($product_discount['date_start']) . "', date_end = '" . $this->db->escape($product_discount['date_end']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_special'])) {
|
||||
foreach ($data['product_special'] as $product_special) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_special SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_special['customer_group_id'] . "', priority = '" . (int)$product_special['priority'] . "', price = '" . (float)$product_special['price'] . "', date_start = '" . $this->db->escape($product_special['date_start']) . "', date_end = '" . $this->db->escape($product_special['date_end']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_image'])) {
|
||||
foreach ($data['product_image'] as $product_image) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($product_image['image']) . "', sort_order = '" . (int)$product_image['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_download'])) {
|
||||
foreach ($data['product_download'] as $download_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_download SET product_id = '" . (int)$product_id . "', download_id = '" . (int)$download_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_category'])) {
|
||||
foreach ($data['product_category'] as $category_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$category_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['main_category_id']) && $data['main_category_id'] > 0) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "' AND category_id = '" . (int)$data['main_category_id'] . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$data['main_category_id'] . "', main_category = 1");
|
||||
} elseif (isset($data['product_category'][0])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "product_to_category SET main_category = 1 WHERE product_id = '" . (int)$product_id . "' AND category_id = '" . (int)$data['product_category'][0] . "'");
|
||||
}
|
||||
|
||||
if (isset($data['product_filter'])) {
|
||||
foreach ($data['product_filter'] as $filter_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_filter SET product_id = '" . (int)$product_id . "', filter_id = '" . (int)$filter_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$related_id . "' AND related_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_related_article'])) {
|
||||
foreach ($data['product_related_article'] as $article_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related_article WHERE product_id = '" . (int)$product_id . "' AND article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related_article SET product_id = '" . (int)$product_id . "', article_id = '" . (int)$article_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_reward'])) {
|
||||
foreach ($data['product_reward'] as $customer_group_id => $product_reward) {
|
||||
if ((int)$product_reward['points'] > 0) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_reward SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$customer_group_id . "', points = '" . (int)$product_reward['points'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
if (isset($data['product_seo_url'])) {
|
||||
foreach ($data['product_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'product_id=" . (int)$product_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_layout'])) {
|
||||
foreach ($data['product_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_layout SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->cache->delete('product');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
|
||||
return $product_id;
|
||||
}
|
||||
|
||||
public function editProduct($product_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "',price_2 = '" . (float)$data['price_2'] . "',price_3 = '" . (float)$data['price_3'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "product SET image = '" . $this->db->escape($data['image']) . "' WHERE product_id = '" . (int)$product_id . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($data['product_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', tag = '" . $this->db->escape($value['tag']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_store'])) {
|
||||
foreach ($data['product_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_store SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (!empty($data['product_attribute'])) {
|
||||
foreach ($data['product_attribute'] as $product_attribute) {
|
||||
if ($product_attribute['attribute_id']) {
|
||||
// Removes duplicates
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "'");
|
||||
|
||||
foreach ($product_attribute['product_attribute_description'] as $language_id => $product_attribute_description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_id . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" . $this->db->escape($product_attribute_description['text']) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_option'])) {
|
||||
foreach ($data['product_option'] as $product_option) {
|
||||
if ($product_option['type'] == 'select' || $product_option['type'] == 'radio' || $product_option['type'] == 'checkbox' || $product_option['type'] == 'image') {
|
||||
if (isset($product_option['product_option_value'])) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_option_id = '" . (int)$product_option['product_option_id'] . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', required = '" . (int)$product_option['required'] . "'");
|
||||
|
||||
$product_option_id = $this->db->getLastId();
|
||||
|
||||
foreach ($product_option['product_option_value'] as $product_option_value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_value_id = '" . (int)$product_option_value['product_option_value_id'] . "', product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value_id = '" . (int)$product_option_value['option_value_id'] . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', price_prefix = '" . $this->db->escape($product_option_value['price_prefix']) . "', points = '" . (int)$product_option_value['points'] . "', points_prefix = '" . $this->db->escape($product_option_value['points_prefix']) . "', weight = '" . (float)$product_option_value['weight'] . "', weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_option SET product_option_id = '" . (int)$product_option['product_option_id'] . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', value = '" . $this->db->escape($product_option['value']) . "', required = '" . (int)$product_option['required'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "product_recurring` WHERE product_id = " . (int)$product_id);
|
||||
|
||||
if (isset($data['product_recurring'])) {
|
||||
foreach ($data['product_recurring'] as $product_recurring) {
|
||||
$query = $this->db->query("SELECT `product_id` FROM `" . DB_PREFIX . "product_recurring` WHERE `product_id` = '" . (int)$product_id . "' AND `customer_group_id` = '" . (int)$product_recurring['customer_group_id'] . "' AND `recurring_id` = '" . (int)$product_recurring['recurring_id'] . "'");
|
||||
|
||||
if (!$query->num_rows) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "product_recurring` SET `product_id` = '" . (int)$product_id . "', `customer_group_id` = '" . (int)$product_recurring['customer_group_id'] . "', `recurring_id` = '" . (int)$product_recurring['recurring_id'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_discount'])) {
|
||||
foreach ($data['product_discount'] as $product_discount) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_discount SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_discount['customer_group_id'] . "', quantity = '" . (int)$product_discount['quantity'] . "', priority = '" . (int)$product_discount['priority'] . "', price = '" . (float)$product_discount['price'] . "', date_start = '" . $this->db->escape($product_discount['date_start']) . "', date_end = '" . $this->db->escape($product_discount['date_end']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_special'])) {
|
||||
foreach ($data['product_special'] as $product_special) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_special SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$product_special['customer_group_id'] . "', priority = '" . (int)$product_special['priority'] . "', price = '" . (float)$product_special['price'] . "', date_start = '" . $this->db->escape($product_special['date_start']) . "', date_end = '" . $this->db->escape($product_special['date_end']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_image'])) {
|
||||
foreach ($data['product_image'] as $product_image) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($product_image['image']) . "', sort_order = '" . (int)$product_image['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_download'])) {
|
||||
foreach ($data['product_download'] as $download_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_download SET product_id = '" . (int)$product_id . "', download_id = '" . (int)$download_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_category'])) {
|
||||
foreach ($data['product_category'] as $category_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$category_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_filter WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['main_category_id']) && $data['main_category_id'] > 0) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "' AND category_id = '" . (int)$data['main_category_id'] . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_category SET product_id = '" . (int)$product_id . "', category_id = '" . (int)$data['main_category_id'] . "', main_category = 1");
|
||||
} elseif (isset($data['product_category'][0])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "product_to_category SET main_category = 1 WHERE product_id = '" . (int)$product_id . "' AND category_id = '" . (int)$data['product_category'][0] . "'");
|
||||
}
|
||||
|
||||
if (isset($data['product_filter'])) {
|
||||
foreach ($data['product_filter'] as $filter_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_filter SET product_id = '" . (int)$product_id . "', filter_id = '" . (int)$filter_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$product_id . "', related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$related_id . "' AND related_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related SET product_id = '" . (int)$related_id . "', related_id = '" . (int)$product_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related_article WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_related_article'])) {
|
||||
foreach ($data['product_related_article'] as $article_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related_article WHERE product_id = '" . (int)$product_id . "' AND article_id = '" . (int)$article_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_related_article SET product_id = '" . (int)$product_id . "', article_id = '" . (int)$article_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_reward WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_reward'])) {
|
||||
foreach ($data['product_reward'] as $customer_group_id => $value) {
|
||||
if ((int)$value['points'] > 0) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_reward SET product_id = '" . (int)$product_id . "', customer_group_id = '" . (int)$customer_group_id . "', points = '" . (int)$value['points'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'product_id=" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_seo_url'])) {
|
||||
foreach ($data['product_seo_url']as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'product_id=" . (int)$product_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if (isset($data['product_layout'])) {
|
||||
foreach ($data['product_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_to_layout SET product_id = '" . (int)$product_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('product');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
}
|
||||
|
||||
public function editProductStatus($product_id, $status) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "product SET status = '" . (int)$status . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
$this->cache->delete('product');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
|
||||
return $product_id;
|
||||
}
|
||||
|
||||
public function copyProduct($product_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "product p WHERE p.product_id = '" . (int)$product_id . "'");
|
||||
|
||||
if ($query->num_rows) {
|
||||
$data = $query->row;
|
||||
|
||||
$data['sku'] = '';
|
||||
$data['upc'] = '';
|
||||
$data['viewed'] = '0';
|
||||
$data['keyword'] = '';
|
||||
$data['status'] = '0';
|
||||
$data['noindex'] = '0';
|
||||
|
||||
$data['product_attribute'] = $this->getProductAttributes($product_id);
|
||||
$data['product_description'] = $this->getProductDescriptions($product_id);
|
||||
$data['product_discount'] = $this->getProductDiscounts($product_id);
|
||||
$data['product_filter'] = $this->getProductFilters($product_id);
|
||||
$data['product_image'] = $this->getProductImages($product_id);
|
||||
$data['product_option'] = $this->getProductOptions($product_id);
|
||||
$data['product_related'] = $this->getProductRelated($product_id);
|
||||
$data['product_related_article'] = $this->getArticleRelated($product_id);
|
||||
$data['product_reward'] = $this->getProductRewards($product_id);
|
||||
$data['product_special'] = $this->getProductSpecials($product_id);
|
||||
$data['product_category'] = $this->getProductCategories($product_id);
|
||||
$data['product_download'] = $this->getProductDownloads($product_id);
|
||||
$data['product_layout'] = $this->getProductLayouts($product_id);
|
||||
$data['product_store'] = $this->getProductStores($product_id);
|
||||
$data['product_recurrings'] = $this->getRecurrings($product_id);
|
||||
|
||||
$this->addProduct($data);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteProduct($product_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_filter WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_option_value WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related WHERE related_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_related_article WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_reward WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_recurring WHERE product_id = " . (int)$product_id);
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "review WHERE product_id = '" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'product_id=" . (int)$product_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_product WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
$this->cache->delete('product');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
}
|
||||
|
||||
public function getProduct($product_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE p.product_id = '" . (int)$product_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getProducts($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (isset($data['filter_category']) && !is_null($data['filter_category'])) {
|
||||
preg_match('/(.*)(WHERE pd\.language_id.*)/', $sql, $sql_crutch_matches);
|
||||
if (isset($sql_crutch_matches[2])) {
|
||||
$sql = $sql_crutch_matches[1] . " LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id)" . $sql_crutch_matches[2];
|
||||
} else {
|
||||
$data['filter_category'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND pd.name LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_model'])) {
|
||||
$sql .= " AND p.model LIKE '%" . $this->db->escape($data['filter_model']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_category']) && !is_null($data['filter_category'])) {
|
||||
if (!empty($data['filter_category']) && !empty($data['filter_sub_category'])) {
|
||||
$implode_data = array();
|
||||
|
||||
$this->load->model('catalog/category');
|
||||
|
||||
$categories = $this->model_catalog_category->getCategoriesChildren($data['filter_category']);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$implode_data[] = "p2c.category_id = '" . (int)$category['category_id'] . "'";
|
||||
}
|
||||
|
||||
$sql .= " AND (" . implode(' OR ', $implode_data) . ")";
|
||||
} else {
|
||||
if ((int)$data['filter_category'] > 0) {
|
||||
$sql .= " AND p2c.category_id = '" . (int)$data['filter_category'] . "'";
|
||||
} else {
|
||||
$sql .= " AND p2c.category_id IS NULL";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['filter_manufacturer_id']) && !is_null($data['filter_manufacturer_id'])) {
|
||||
$sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_price'])) {
|
||||
$sql .= " AND p.price LIKE '" . $this->db->escape($data['filter_price']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_price_min']) && !is_null($data['filter_price_min'])) {
|
||||
$sql .= " AND p.price >= '" . (float)$data['filter_price_min'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_price_max']) && !is_null($data['filter_price_max'])) {
|
||||
$sql .= " AND p.price <= '" . (float)$data['filter_price_max'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_quantity']) && $data['filter_quantity'] !== '') {
|
||||
$sql .= " AND p.quantity = '" . (int)$data['filter_quantity'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_quantity_min']) && !is_null($data['filter_quantity_min'])) {
|
||||
$sql .= " AND p.quantity >= '" . (int)$data['filter_quantity_min'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_quantity_max']) && !is_null($data['filter_quantity_max'])) {
|
||||
$sql .= " AND p.quantity <= '" . (int)$data['filter_quantity_max'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && $data['filter_status'] !== '') {
|
||||
$sql .= " AND p.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_noindex']) && $data['filter_noindex'] !== '') {
|
||||
$sql .= " AND p.noindex = '" . (int)$data['filter_noindex'] . "'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY p.product_id";
|
||||
|
||||
$sort_data = array(
|
||||
'pd.name',
|
||||
'p.model',
|
||||
'p.price',
|
||||
'p.quantity',
|
||||
'p.status',
|
||||
'p.noindex',
|
||||
'p.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY pd.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getProductsByCategoryId($category_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p2c.category_id = '" . (int)$category_id . "' ORDER BY pd.name ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getProductDescriptions($product_id) {
|
||||
$product_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_description_data[$result['language_id']] = array(
|
||||
'name' => $result['name'],
|
||||
'description' => $result['description'],
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword'],
|
||||
'tag' => $result['tag']
|
||||
);
|
||||
}
|
||||
|
||||
return $product_description_data;
|
||||
}
|
||||
|
||||
public function getProductCategories($product_id) {
|
||||
$product_category_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_category_data[] = $result['category_id'];
|
||||
}
|
||||
|
||||
return $product_category_data;
|
||||
}
|
||||
|
||||
public function getProductMainCategoryId($product_id) {
|
||||
$query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "' AND main_category = '1' LIMIT 1");
|
||||
|
||||
return ($query->num_rows ? (int)$query->row['category_id'] : 0);
|
||||
}
|
||||
|
||||
public function getProductFilters($product_id) {
|
||||
$product_filter_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_filter WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_filter_data[] = $result['filter_id'];
|
||||
}
|
||||
|
||||
return $product_filter_data;
|
||||
}
|
||||
|
||||
public function getProductAttributes($product_id) {
|
||||
$product_attribute_data = array();
|
||||
|
||||
$product_attribute_query = $this->db->query("SELECT attribute_id FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' GROUP BY attribute_id");
|
||||
|
||||
foreach ($product_attribute_query->rows as $product_attribute) {
|
||||
$product_attribute_description_data = array();
|
||||
|
||||
$product_attribute_description_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_attribute WHERE product_id = '" . (int)$product_id . "' AND attribute_id = '" . (int)$product_attribute['attribute_id'] . "'");
|
||||
|
||||
foreach ($product_attribute_description_query->rows as $product_attribute_description) {
|
||||
$product_attribute_description_data[$product_attribute_description['language_id']] = array('text' => $product_attribute_description['text']);
|
||||
}
|
||||
|
||||
$product_attribute_data[] = array(
|
||||
'attribute_id' => $product_attribute['attribute_id'],
|
||||
'product_attribute_description' => $product_attribute_description_data
|
||||
);
|
||||
}
|
||||
|
||||
return $product_attribute_data;
|
||||
}
|
||||
|
||||
public function getProductOptions($product_id) {
|
||||
$product_option_data = array();
|
||||
|
||||
$product_option_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "product_option` po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) LEFT JOIN `" . DB_PREFIX . "option_description` od ON (o.option_id = od.option_id) WHERE po.product_id = '" . (int)$product_id . "' AND od.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY o.sort_order ASC");
|
||||
|
||||
foreach ($product_option_query->rows as $product_option) {
|
||||
$product_option_value_data = array();
|
||||
|
||||
$product_option_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON(pov.option_value_id = ov.option_value_id) WHERE pov.product_option_id = '" . (int)$product_option['product_option_id'] . "' ORDER BY ov.sort_order ASC");
|
||||
|
||||
foreach ($product_option_value_query->rows as $product_option_value) {
|
||||
$product_option_value_data[] = array(
|
||||
'product_option_value_id' => $product_option_value['product_option_value_id'],
|
||||
'option_value_id' => $product_option_value['option_value_id'],
|
||||
'quantity' => $product_option_value['quantity'],
|
||||
'subtract' => $product_option_value['subtract'],
|
||||
'price' => $product_option_value['price'],
|
||||
'price_prefix' => $product_option_value['price_prefix'],
|
||||
'points' => $product_option_value['points'],
|
||||
'points_prefix' => $product_option_value['points_prefix'],
|
||||
'weight' => $product_option_value['weight'],
|
||||
'weight_prefix' => $product_option_value['weight_prefix']
|
||||
);
|
||||
}
|
||||
|
||||
$product_option_data[] = array(
|
||||
'product_option_id' => $product_option['product_option_id'],
|
||||
'product_option_value' => $product_option_value_data,
|
||||
'option_id' => $product_option['option_id'],
|
||||
'name' => $product_option['name'],
|
||||
'type' => $product_option['type'],
|
||||
'value' => $product_option['value'],
|
||||
'required' => $product_option['required']
|
||||
);
|
||||
}
|
||||
|
||||
return $product_option_data;
|
||||
}
|
||||
|
||||
public function getProductOptionValue($product_id, $product_option_value_id) {
|
||||
$query = $this->db->query("SELECT pov.option_value_id, ovd.name, pov.quantity, pov.subtract, pov.price, pov.price_prefix, pov.points, pov.points_prefix, pov.weight, pov.weight_prefix FROM " . DB_PREFIX . "product_option_value pov LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) WHERE pov.product_id = '" . (int)$product_id . "' AND pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getProductImages($product_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getProductDiscounts($product_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)$product_id . "' ORDER BY quantity, priority, price");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getProductSpecials($product_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_special WHERE product_id = '" . (int)$product_id . "' ORDER BY priority, price");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getProductRewards($product_id) {
|
||||
$product_reward_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_reward WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_reward_data[$result['customer_group_id']] = array('points' => $result['points']);
|
||||
}
|
||||
|
||||
return $product_reward_data;
|
||||
}
|
||||
|
||||
public function getProductDownloads($product_id) {
|
||||
$product_download_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_download WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_download_data[] = $result['download_id'];
|
||||
}
|
||||
|
||||
return $product_download_data;
|
||||
}
|
||||
|
||||
public function getProductStores($product_id) {
|
||||
$product_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_store WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $product_store_data;
|
||||
}
|
||||
|
||||
public function getProductSeoUrls($product_id) {
|
||||
$product_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'product_id=" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
|
||||
return $product_seo_url_data;
|
||||
}
|
||||
|
||||
public function getProductLayouts($product_id) {
|
||||
$product_layout_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_layout WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
|
||||
return $product_layout_data;
|
||||
}
|
||||
|
||||
public function getProductRelated($product_id) {
|
||||
$product_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_related_data[] = $result['related_id'];
|
||||
}
|
||||
|
||||
return $product_related_data;
|
||||
}
|
||||
|
||||
public function getArticleRelated($product_id) {
|
||||
$article_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related_article WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$article_related_data[] = $result['article_id'];
|
||||
}
|
||||
|
||||
return $article_related_data;
|
||||
}
|
||||
|
||||
public function getRecurrings($product_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "product_recurring` WHERE product_id = '" . (int)$product_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalProducts($data = array()) {
|
||||
$sql = "SELECT COUNT(DISTINCT p.product_id) AS total FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)";
|
||||
|
||||
if (isset($data['filter_category']) && !is_null($data['filter_category'])) {
|
||||
$sql .= " LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id)";
|
||||
}
|
||||
|
||||
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND pd.name LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_model'])) {
|
||||
$sql .= " AND p.model LIKE '%" . $this->db->escape($data['filter_model']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_category']) && !is_null($data['filter_category'])) {
|
||||
if (!empty($data['filter_category']) && !empty($data['filter_sub_category'])) {
|
||||
$implode_data = array();
|
||||
|
||||
$this->load->model('catalog/category');
|
||||
|
||||
$categories = $this->model_catalog_category->getCategoriesChildren($data['filter_category']);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$implode_data[] = "p2c.category_id = '" . (int)$category['category_id'] . "'";
|
||||
}
|
||||
|
||||
$sql .= " AND (" . implode(' OR ', $implode_data) . ")";
|
||||
} else {
|
||||
if ((int)$data['filter_category'] > 0) {
|
||||
$sql .= " AND p2c.category_id = '" . (int)$data['filter_category'] . "'";
|
||||
} else {
|
||||
$sql .= " AND p2c.category_id IS NULL";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['filter_manufacturer_id']) && !is_null($data['filter_manufacturer_id'])) {
|
||||
$sql .= " AND p.manufacturer_id = '" . (int)$data['filter_manufacturer_id'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_price']) && !is_null($data['filter_price'])) {
|
||||
$sql .= " AND p.price LIKE '" . $this->db->escape($data['filter_price']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_price_min']) && !is_null($data['filter_price_min'])) {
|
||||
$sql .= " AND p.price >= '" . (float)$data['filter_price_min'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_price_max']) && !is_null($data['filter_price_max'])) {
|
||||
$sql .= " AND p.price <= '" . (float)$data['filter_price_max'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_quantity']) && $data['filter_quantity'] !== '') {
|
||||
$sql .= " AND p.quantity = '" . (int)$data['filter_quantity'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_quantity_min']) && !is_null($data['filter_quantity_min'])) {
|
||||
$sql .= " AND p.quantity >= '" . (int)$data['filter_quantity_min'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_quantity_max']) && !is_null($data['filter_quantity_max'])) {
|
||||
$sql .= " AND p.quantity <= '" . (int)$data['filter_quantity_max'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && $data['filter_status'] !== '') {
|
||||
$sql .= " AND p.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_noindex']) && $data['filter_noindex'] !== '') {
|
||||
$sql .= " AND p.noindex = '" . (int)$data['filter_noindex'] . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByTaxClassId($tax_class_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE tax_class_id = '" . (int)$tax_class_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByStockStatusId($stock_status_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE stock_status_id = '" . (int)$stock_status_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByWeightClassId($weight_class_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE weight_class_id = '" . (int)$weight_class_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByLengthClassId($length_class_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE length_class_id = '" . (int)$length_class_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByDownloadId($download_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_to_download WHERE download_id = '" . (int)$download_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByManufacturerId($manufacturer_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByAttributeId($attribute_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_attribute WHERE attribute_id = '" . (int)$attribute_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByOptionId($option_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_option WHERE option_id = '" . (int)$option_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByProfileId($recurring_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_recurring WHERE recurring_id = '" . (int)$recurring_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
class ModelCatalogRecurring extends Model {
|
||||
public function addRecurring($data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "recurring` SET `sort_order` = " . (int)$data['sort_order'] . ", `status` = " . (int)$data['status'] . ", `price` = " . (float)$data['price'] . ", `frequency` = '" . $this->db->escape($data['frequency']) . "', `duration` = " . (int)$data['duration'] . ", `cycle` = " . (int)$data['cycle'] . ", `trial_status` = " . (int)$data['trial_status'] . ", `trial_price` = " . (float)$data['trial_price'] . ", `trial_frequency` = '" . $this->db->escape($data['trial_frequency']) . "', `trial_duration` = " . (int)$data['trial_duration'] . ", `trial_cycle` = '" . (int)$data['trial_cycle'] . "'");
|
||||
|
||||
$recurring_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['recurring_description'] as $language_id => $recurring_description) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "recurring_description` (`recurring_id`, `language_id`, `name`) VALUES (" . (int)$recurring_id . ", " . (int)$language_id . ", '" . $this->db->escape($recurring_description['name']) . "')");
|
||||
}
|
||||
|
||||
return $recurring_id;
|
||||
}
|
||||
|
||||
public function editRecurring($recurring_id, $data) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "recurring_description` WHERE recurring_id = '" . (int)$recurring_id . "'");
|
||||
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "recurring` SET `price` = '" . (float)$data['price'] . "', `frequency` = '" . $this->db->escape($data['frequency']) . "', `duration` = '" . (int)$data['duration'] . "', `cycle` = '" . (int)$data['cycle'] . "', `sort_order` = '" . (int)$data['sort_order'] . "', `status` = '" . (int)$data['status'] . "', `trial_price` = '" . (float)$data['trial_price'] . "', `trial_frequency` = '" . $this->db->escape($data['trial_frequency']) . "', `trial_duration` = '" . (int)$data['trial_duration'] . "', `trial_cycle` = '" . (int)$data['trial_cycle'] . "', `trial_status` = '" . (int)$data['trial_status'] . "' WHERE recurring_id = '" . (int)$recurring_id . "'");
|
||||
|
||||
foreach ($data['recurring_description'] as $language_id => $recurring_description) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "recurring_description` (`recurring_id`, `language_id`, `name`) VALUES (" . (int)$recurring_id . ", " . (int)$language_id . ", '" . $this->db->escape($recurring_description['name']) . "')");
|
||||
}
|
||||
}
|
||||
|
||||
public function copyRecurring($recurring_id) {
|
||||
$data = $this->getRecurring($recurring_id);
|
||||
|
||||
$data['recurring_description'] = $this->getRecurringDescription($recurring_id);
|
||||
|
||||
foreach ($data['recurring_description'] as &$recurring_description) {
|
||||
$recurring_description['name'] .= ' - 2';
|
||||
}
|
||||
|
||||
$this->addRecurring($data);
|
||||
}
|
||||
|
||||
public function deleteRecurring($recurring_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "recurring` WHERE recurring_id = " . (int)$recurring_id . "");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "recurring_description` WHERE recurring_id = " . (int)$recurring_id . "");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "product_recurring` WHERE recurring_id = " . (int)$recurring_id . "");
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "order_recurring` SET `recurring_id` = 0 WHERE `recurring_id` = " . (int)$recurring_id . "");
|
||||
}
|
||||
|
||||
public function getRecurring($recurring_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "recurring` WHERE recurring_id = '" . (int)$recurring_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getRecurringDescription($recurring_id) {
|
||||
$recurring_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "recurring_description` WHERE `recurring_id` = '" . (int)$recurring_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$recurring_description_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $recurring_description_data;
|
||||
}
|
||||
|
||||
public function getRecurrings($data = array()) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "recurring` r LEFT JOIN " . DB_PREFIX . "recurring_description rd ON (r.recurring_id = rd.recurring_id) WHERE rd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND rd.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'rd.name',
|
||||
'r.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY rd.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalRecurrings() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "recurring`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ModelCatalogReview extends Model {
|
||||
public function addReview($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "review SET author = '" . $this->db->escape($data['author']) . "', product_id = '" . (int)$data['product_id'] . "', text = '" . $this->db->escape(strip_tags($data['text'])) . "', rating = '" . (int)$data['rating'] . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "'");
|
||||
|
||||
$review_id = $this->db->getLastId();
|
||||
|
||||
$this->cache->delete('product');
|
||||
|
||||
return $review_id;
|
||||
}
|
||||
|
||||
public function editReview($review_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "review SET author = '" . $this->db->escape($data['author']) . "', product_id = '" . (int)$data['product_id'] . "', text = '" . $this->db->escape(strip_tags($data['text'])) . "', rating = '" . (int)$data['rating'] . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "', date_modified = NOW() WHERE review_id = '" . (int)$review_id . "'");
|
||||
|
||||
$this->cache->delete('product');
|
||||
}
|
||||
|
||||
public function deleteReview($review_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "review WHERE review_id = '" . (int)$review_id . "'");
|
||||
|
||||
$this->cache->delete('product');
|
||||
}
|
||||
|
||||
public function getReview($review_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT *, (SELECT pd.name FROM " . DB_PREFIX . "product_description pd WHERE pd.product_id = r.product_id AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS product FROM " . DB_PREFIX . "review r WHERE r.review_id = '" . (int)$review_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getReviews($data = array()) {
|
||||
$sql = "SELECT r.review_id, pd.name, r.author, r.rating, r.status, r.date_added FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product_description pd ON (r.product_id = pd.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_product'])) {
|
||||
$sql .= " AND pd.name LIKE '" . $this->db->escape($data['filter_product']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_author'])) {
|
||||
$sql .= " AND r.author LIKE '" . $this->db->escape($data['filter_author']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && $data['filter_status'] !== '') {
|
||||
$sql .= " AND r.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(r.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'pd.name',
|
||||
'r.author',
|
||||
'r.rating',
|
||||
'r.status',
|
||||
'r.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY r.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;
|
||||
}
|
||||
|
||||
public function getTotalReviews($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review r LEFT JOIN " . DB_PREFIX . "product_description pd ON (r.product_id = pd.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_product'])) {
|
||||
$sql .= " AND pd.name LIKE '" . $this->db->escape($data['filter_product']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_author'])) {
|
||||
$sql .= " AND r.author LIKE '" . $this->db->escape($data['filter_author']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && $data['filter_status'] !== '') {
|
||||
$sql .= " AND r.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(r.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalReviewsAwaitingApproval() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "review WHERE status = '0'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
class ModelCustomerCustomField extends Model {
|
||||
public function addCustomField($data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "custom_field` SET type = '" . $this->db->escape($data['type']) . "', value = '" . $this->db->escape($data['value']) . "', validation = '" . $this->db->escape($data['validation']) . "', location = '" . $this->db->escape($data['location']) . "', status = '" . (int)$data['status'] . "', sort_order = '" . (int)$data['sort_order'] . "'");
|
||||
|
||||
$custom_field_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['custom_field_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_description SET custom_field_id = '" . (int)$custom_field_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['custom_field_customer_group'])) {
|
||||
foreach ($data['custom_field_customer_group'] as $custom_field_customer_group) {
|
||||
if (isset($custom_field_customer_group['customer_group_id'])) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_customer_group SET custom_field_id = '" . (int)$custom_field_id . "', customer_group_id = '" . (int)$custom_field_customer_group['customer_group_id'] . "', required = '" . (int)(isset($custom_field_customer_group['required']) ? 1 : 0) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['custom_field_value'])) {
|
||||
foreach ($data['custom_field_value'] as $custom_field_value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_value SET custom_field_id = '" . (int)$custom_field_id . "', sort_order = '" . (int)$custom_field_value['sort_order'] . "'");
|
||||
|
||||
$custom_field_value_id = $this->db->getLastId();
|
||||
|
||||
foreach ($custom_field_value['custom_field_value_description'] as $language_id => $custom_field_value_description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_value_description SET custom_field_value_id = '" . (int)$custom_field_value_id . "', language_id = '" . (int)$language_id . "', custom_field_id = '" . (int)$custom_field_id . "', name = '" . $this->db->escape($custom_field_value_description['name']) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $custom_field_id;
|
||||
}
|
||||
|
||||
public function editCustomField($custom_field_id, $data) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "custom_field` SET type = '" . $this->db->escape($data['type']) . "', value = '" . $this->db->escape($data['value']) . "', validation = '" . $this->db->escape($data['validation']) . "', location = '" . $this->db->escape($data['location']) . "', status = '" . (int)$data['status'] . "', sort_order = '" . (int)$data['sort_order'] . "' WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "custom_field_description WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
|
||||
foreach ($data['custom_field_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_description SET custom_field_id = '" . (int)$custom_field_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "custom_field_customer_group WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
|
||||
if (isset($data['custom_field_customer_group'])) {
|
||||
foreach ($data['custom_field_customer_group'] as $custom_field_customer_group) {
|
||||
if (isset($custom_field_customer_group['customer_group_id'])) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_customer_group SET custom_field_id = '" . (int)$custom_field_id . "', customer_group_id = '" . (int)$custom_field_customer_group['customer_group_id'] . "', required = '" . (int)(isset($custom_field_customer_group['required']) ? 1 : 0) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "custom_field_value WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "custom_field_value_description WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
|
||||
if (isset($data['custom_field_value'])) {
|
||||
foreach ($data['custom_field_value'] as $custom_field_value) {
|
||||
if ($custom_field_value['custom_field_value_id']) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_value SET custom_field_value_id = '" . (int)$custom_field_value['custom_field_value_id'] . "', custom_field_id = '" . (int)$custom_field_id . "', sort_order = '" . (int)$custom_field_value['sort_order'] . "'");
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_value SET custom_field_id = '" . (int)$custom_field_id . "', sort_order = '" . (int)$custom_field_value['sort_order'] . "'");
|
||||
}
|
||||
|
||||
$custom_field_value_id = $this->db->getLastId();
|
||||
|
||||
foreach ($custom_field_value['custom_field_value_description'] as $language_id => $custom_field_value_description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_value_description SET custom_field_value_id = '" . (int)$custom_field_value_id . "', language_id = '" . (int)$language_id . "', custom_field_id = '" . (int)$custom_field_id . "', name = '" . $this->db->escape($custom_field_value_description['name']) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteCustomField($custom_field_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "custom_field` WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "custom_field_description` WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "custom_field_customer_group` WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "custom_field_value` WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "custom_field_value_description` WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
}
|
||||
|
||||
public function getCustomField($custom_field_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "custom_field` cf LEFT JOIN " . DB_PREFIX . "custom_field_description cfd ON (cf.custom_field_id = cfd.custom_field_id) WHERE cf.custom_field_id = '" . (int)$custom_field_id . "' AND cfd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCustomFields($data = array()) {
|
||||
if (empty($data['filter_customer_group_id'])) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "custom_field` cf LEFT JOIN " . DB_PREFIX . "custom_field_description cfd ON (cf.custom_field_id = cfd.custom_field_id) WHERE cfd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
} else {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "custom_field_customer_group cfcg LEFT JOIN `" . DB_PREFIX . "custom_field` cf ON (cfcg.custom_field_id = cf.custom_field_id) LEFT JOIN " . DB_PREFIX . "custom_field_description cfd ON (cf.custom_field_id = cfd.custom_field_id) WHERE cfd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND cfd.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer_group_id'])) {
|
||||
$sql .= " AND cfcg.customer_group_id = '" . (int)$data['filter_customer_group_id'] . "'";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'cfd.name',
|
||||
'cf.type',
|
||||
'cf.location',
|
||||
'cf.status',
|
||||
'cf.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY cfd.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getCustomFieldDescriptions($custom_field_id) {
|
||||
$custom_field_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "custom_field_description WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$custom_field_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $custom_field_data;
|
||||
}
|
||||
|
||||
public function getCustomFieldValue($custom_field_value_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "custom_field_value cfv LEFT JOIN " . DB_PREFIX . "custom_field_value_description cfvd ON (cfv.custom_field_value_id = cfvd.custom_field_value_id) WHERE cfv.custom_field_value_id = '" . (int)$custom_field_value_id . "' AND cfvd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCustomFieldValues($custom_field_id) {
|
||||
$custom_field_value_data = array();
|
||||
|
||||
$custom_field_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "custom_field_value cfv LEFT JOIN " . DB_PREFIX . "custom_field_value_description cfvd ON (cfv.custom_field_value_id = cfvd.custom_field_value_id) WHERE cfv.custom_field_id = '" . (int)$custom_field_id . "' AND cfvd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY cfv.sort_order ASC");
|
||||
|
||||
foreach ($custom_field_value_query->rows as $custom_field_value) {
|
||||
$custom_field_value_data[$custom_field_value['custom_field_value_id']] = array(
|
||||
'custom_field_value_id' => $custom_field_value['custom_field_value_id'],
|
||||
'name' => $custom_field_value['name']
|
||||
);
|
||||
}
|
||||
|
||||
return $custom_field_value_data;
|
||||
}
|
||||
|
||||
public function getCustomFieldCustomerGroups($custom_field_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "custom_field_customer_group` WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getCustomFieldValueDescriptions($custom_field_id) {
|
||||
$custom_field_value_data = array();
|
||||
|
||||
$custom_field_value_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "custom_field_value WHERE custom_field_id = '" . (int)$custom_field_id . "'");
|
||||
|
||||
foreach ($custom_field_value_query->rows as $custom_field_value) {
|
||||
$custom_field_value_description_data = array();
|
||||
|
||||
$custom_field_value_description_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "custom_field_value_description WHERE custom_field_value_id = '" . (int)$custom_field_value['custom_field_value_id'] . "'");
|
||||
|
||||
foreach ($custom_field_value_description_query->rows as $custom_field_value_description) {
|
||||
$custom_field_value_description_data[$custom_field_value_description['language_id']] = array('name' => $custom_field_value_description['name']);
|
||||
}
|
||||
|
||||
$custom_field_value_data[] = array(
|
||||
'custom_field_value_id' => $custom_field_value['custom_field_value_id'],
|
||||
'custom_field_value_description' => $custom_field_value_description_data,
|
||||
'sort_order' => $custom_field_value['sort_order']
|
||||
);
|
||||
}
|
||||
|
||||
return $custom_field_value_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomFields() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "custom_field`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,487 @@
|
||||
<?php
|
||||
class ModelCustomerCustomer extends Model {
|
||||
public function addCustomer($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : json_encode(array())) . "', newsletter = '" . (int)$data['newsletter'] . "', salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', status = '" . (int)$data['status'] . "', safe = '" . (int)$data['safe'] . "', date_added = NOW()");
|
||||
|
||||
$customer_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['address'])) {
|
||||
foreach ($data['address'] as $address) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "address SET customer_id = '" . (int)$customer_id . "', firstname = '" . $this->db->escape($address['firstname']) . "', lastname = '" . $this->db->escape($address['lastname']) . "', company = '" . $this->db->escape($address['company']) . "', address_1 = '" . $this->db->escape($address['address_1']) . "', address_2 = '" . $this->db->escape($address['address_2']) . "', city = '" . $this->db->escape($address['city']) . "', postcode = '" . $this->db->escape($address['postcode']) . "', country_id = '" . (int)$address['country_id'] . "', zone_id = '" . (int)$address['zone_id'] . "', custom_field = '" . $this->db->escape(isset($address['custom_field']) ? json_encode($address['custom_field']) : json_encode(array())) . "'");
|
||||
|
||||
if (isset($address['default'])) {
|
||||
$address_id = $this->db->getLastId();
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int)$address_id . "' WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['affiliate']) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_affiliate SET customer_id = '" . (int)$customer_id . "', company = '" . $this->db->escape($data['company']) . "', website = '" . $this->db->escape($data['website']) . "', tracking = '" . $this->db->escape($data['tracking']) . "', commission = '" . (float)$data['commission'] . "', tax = '" . $this->db->escape($data['tax']) . "', payment = '" . $this->db->escape($data['payment']) . "', cheque = '" . $this->db->escape($data['cheque']) . "', paypal = '" . $this->db->escape($data['paypal']) . "', bank_name = '" . $this->db->escape($data['bank_name']) . "', bank_branch_number = '" . $this->db->escape($data['bank_branch_number']) . "', bank_swift_code = '" . $this->db->escape($data['bank_swift_code']) . "', bank_account_name = '" . $this->db->escape($data['bank_account_name']) . "', bank_account_number = '" . $this->db->escape($data['bank_account_number']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : json_encode(array())) . "', status = '" . (int)$data['affiliate'] . "', date_added = NOW()");
|
||||
}
|
||||
|
||||
return $customer_id;
|
||||
}
|
||||
|
||||
public function editCustomer($customer_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "customer SET customer_group_id = '" . (int)$data['customer_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : json_encode(array())) . "', newsletter = '" . (int)$data['newsletter'] . "', status = '" . (int)$data['status'] . "', safe = '" . (int)$data['safe'] . "' WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
if ($data['password']) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "customer SET salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "' WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "address WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
if (isset($data['address'])) {
|
||||
foreach ($data['address'] as $address) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "address SET address_id = '" . (int)$address['address_id'] . "', customer_id = '" . (int)$customer_id . "', firstname = '" . $this->db->escape($address['firstname']) . "', lastname = '" . $this->db->escape($address['lastname']) . "', company = '" . $this->db->escape($address['company']) . "', address_1 = '" . $this->db->escape($address['address_1']) . "', address_2 = '" . $this->db->escape($address['address_2']) . "', city = '" . $this->db->escape($address['city']) . "', postcode = '" . $this->db->escape($address['postcode']) . "', country_id = '" . (int)$address['country_id'] . "', zone_id = '" . (int)$address['zone_id'] . "', custom_field = '" . $this->db->escape(isset($address['custom_field']) ? json_encode($address['custom_field']) : json_encode(array())) . "'");
|
||||
|
||||
if (isset($address['default'])) {
|
||||
$address_id = $this->db->getLastId();
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int)$address_id . "' WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['affiliate']) {
|
||||
$this->db->query("REPLACE INTO " . DB_PREFIX . "customer_affiliate SET customer_id = '" . (int)$customer_id . "', company = '" . $this->db->escape($data['company']) . "', website = '" . $this->db->escape($data['website']) . "', tracking = '" . $this->db->escape($data['tracking']) . "', commission = '" . (float)$data['commission'] . "', tax = '" . $this->db->escape($data['tax']) . "', payment = '" . $this->db->escape($data['payment']) . "', cheque = '" . $this->db->escape($data['cheque']) . "', paypal = '" . $this->db->escape($data['paypal']) . "', bank_name = '" . $this->db->escape($data['bank_name']) . "', bank_branch_number = '" . $this->db->escape($data['bank_branch_number']) . "', bank_swift_code = '" . $this->db->escape($data['bank_swift_code']) . "', bank_account_name = '" . $this->db->escape($data['bank_account_name']) . "', bank_account_number = '" . $this->db->escape($data['bank_account_number']) . "', status = '" . (int)$data['affiliate'] . "', date_added = NOW()");
|
||||
}
|
||||
}
|
||||
|
||||
public function editToken($customer_id, $token) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "customer SET token = '" . $this->db->escape($token) . "' WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
}
|
||||
|
||||
public function deleteCustomer($customer_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_activity WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_affiliate WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_approval WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_history WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_reward WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_transaction WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_ip WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "address WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
}
|
||||
|
||||
public function getCustomer($customer_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCustomerByEmail($email) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "customer WHERE LCASE(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCustomers($data = array()) {
|
||||
$sql = "SELECT *, CONCAT(c.firstname, ' ', c.lastname) AS name, cgd.name AS customer_group FROM " . DB_PREFIX . "customer c LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (c.customer_group_id = cgd.customer_group_id)";
|
||||
|
||||
if (!empty($data['filter_affiliate'])) {
|
||||
$sql .= " LEFT JOIN " . DB_PREFIX . "customer_affiliate ca ON (c.customer_id = ca.customer_id)";
|
||||
}
|
||||
|
||||
$sql .= " WHERE cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$implode[] = "CONCAT(c.firstname, ' ', c.lastname) LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_email'])) {
|
||||
$implode[] = "c.email LIKE '" . $this->db->escape($data['filter_email']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_newsletter']) && !is_null($data['filter_newsletter'])) {
|
||||
$implode[] = "c.newsletter = '" . (int)$data['filter_newsletter'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer_group_id'])) {
|
||||
$implode[] = "c.customer_group_id = '" . (int)$data['filter_customer_group_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_affiliate'])) {
|
||||
$implode[] = "ca.status = '" . (int)$data['filter_affiliate'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_ip'])) {
|
||||
$implode[] = "c.customer_id IN (SELECT customer_id FROM " . DB_PREFIX . "customer_ip WHERE ip = '" . $this->db->escape($data['filter_ip']) . "')";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && $data['filter_status'] !== '') {
|
||||
$implode[] = "c.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "DATE(c.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " AND " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'c.email',
|
||||
'customer_group',
|
||||
'c.status',
|
||||
'c.ip',
|
||||
'c.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getAddress($address_id) {
|
||||
$address_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE address_id = '" . (int)$address_id . "'");
|
||||
|
||||
if ($address_query->num_rows) {
|
||||
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$address_query->row['country_id'] . "'");
|
||||
|
||||
if ($country_query->num_rows) {
|
||||
$country = $country_query->row['name'];
|
||||
$iso_code_2 = $country_query->row['iso_code_2'];
|
||||
$iso_code_3 = $country_query->row['iso_code_3'];
|
||||
$address_format = $country_query->row['address_format'];
|
||||
} else {
|
||||
$country = '';
|
||||
$iso_code_2 = '';
|
||||
$iso_code_3 = '';
|
||||
$address_format = '';
|
||||
}
|
||||
|
||||
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$address_query->row['zone_id'] . "'");
|
||||
|
||||
if ($zone_query->num_rows) {
|
||||
$zone = $zone_query->row['name'];
|
||||
$zone_code = $zone_query->row['code'];
|
||||
} else {
|
||||
$zone = '';
|
||||
$zone_code = '';
|
||||
}
|
||||
|
||||
return array(
|
||||
'address_id' => $address_query->row['address_id'],
|
||||
'customer_id' => $address_query->row['customer_id'],
|
||||
'firstname' => $address_query->row['firstname'],
|
||||
'lastname' => $address_query->row['lastname'],
|
||||
'company' => $address_query->row['company'],
|
||||
'address_1' => $address_query->row['address_1'],
|
||||
'address_2' => $address_query->row['address_2'],
|
||||
'postcode' => $address_query->row['postcode'],
|
||||
'city' => $address_query->row['city'],
|
||||
'zone_id' => $address_query->row['zone_id'],
|
||||
'zone' => $zone,
|
||||
'zone_code' => $zone_code,
|
||||
'country_id' => $address_query->row['country_id'],
|
||||
'country' => $country,
|
||||
'iso_code_2' => $iso_code_2,
|
||||
'iso_code_3' => $iso_code_3,
|
||||
'address_format' => $address_format,
|
||||
'custom_field' => json_decode($address_query->row['custom_field'], true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAddresses($customer_id) {
|
||||
$address_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT address_id FROM " . DB_PREFIX . "address WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$address_info = $this->getAddress($result['address_id']);
|
||||
|
||||
if ($address_info) {
|
||||
$address_data[$result['address_id']] = $address_info;
|
||||
}
|
||||
}
|
||||
|
||||
return $address_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomers($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer c";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$implode[] = "CONCAT(firstname, ' ', lastname) LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_email'])) {
|
||||
$implode[] = "email LIKE '" . $this->db->escape($data['filter_email']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_newsletter']) && !is_null($data['filter_newsletter'])) {
|
||||
$implode[] = "newsletter = '" . (int)$data['filter_newsletter'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer_group_id'])) {
|
||||
$implode[] = "customer_group_id = '" . (int)$data['filter_customer_group_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_ip'])) {
|
||||
$implode[] = "customer_id IN (SELECT customer_id FROM " . DB_PREFIX . "customer_ip WHERE ip = '" . $this->db->escape($data['filter_ip']) . "')";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && $data['filter_status'] !== '') {
|
||||
$implode[] = "status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "DATE(date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getAffliateByTracking($tracking) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_affiliate WHERE tracking = '" . $this->db->escape($tracking) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getAffiliate($customer_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_affiliate WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getAffiliates($data = array()) {
|
||||
$sql = "SELECT DISTINCT *, CONCAT(c.firstname, ' ', c.lastname) AS name FROM " . DB_PREFIX . "customer_affiliate ca LEFT JOIN " . DB_PREFIX . "customer c ON (ca.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$implode[] = "CONCAT(c.firstname, ' ', c.lastname) LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
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 . "ORDER BY name");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalAffiliates($data = array()) {
|
||||
$sql = "SELECT DISTINCT COUNT(*) AS total FROM " . DB_PREFIX . "customer_affiliate ca LEFT JOIN " . DB_PREFIX . "customer c ON (ca.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$implode[] = "CONCAT(c.firstname, ' ', c.lastname) LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalAddressesByCustomerId($customer_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "address WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalAddressesByCountryId($country_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "address WHERE country_id = '" . (int)$country_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalAddressesByZoneId($zone_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "address WHERE zone_id = '" . (int)$zone_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalCustomersByCustomerGroupId($customer_group_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function addHistory($customer_id, $comment) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_history SET customer_id = '" . (int)$customer_id . "', comment = '" . $this->db->escape(strip_tags($comment)) . "', date_added = NOW()");
|
||||
}
|
||||
|
||||
public function getHistories($customer_id, $start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT comment, date_added FROM " . DB_PREFIX . "customer_history WHERE customer_id = '" . (int)$customer_id . "' ORDER BY date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalHistories($customer_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_history WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function addTransaction($customer_id, $description = '', $amount = '', $order_id = 0) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_transaction SET customer_id = '" . (int)$customer_id . "', order_id = '" . (int)$order_id . "', description = '" . $this->db->escape($description) . "', amount = '" . (float)$amount . "', date_added = NOW()");
|
||||
}
|
||||
|
||||
public function deleteTransactionByOrderId($order_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_transaction WHERE order_id = '" . (int)$order_id . "'");
|
||||
}
|
||||
|
||||
public function getTransactions($customer_id, $start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_transaction WHERE customer_id = '" . (int)$customer_id . "' ORDER BY date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalTransactions($customer_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_transaction WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTransactionTotal($customer_id) {
|
||||
$query = $this->db->query("SELECT SUM(amount) AS total FROM " . DB_PREFIX . "customer_transaction WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalTransactionsByOrderId($order_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_transaction WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function addReward($customer_id, $description = '', $points = '', $order_id = 0) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$customer_id . "', order_id = '" . (int)$order_id . "', points = '" . (int)$points . "', description = '" . $this->db->escape($description) . "', date_added = NOW()");
|
||||
}
|
||||
|
||||
public function deleteReward($order_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_reward WHERE order_id = '" . (int)$order_id . "' AND points > 0");
|
||||
}
|
||||
|
||||
public function getRewards($customer_id, $start = 0, $limit = 10) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_reward WHERE customer_id = '" . (int)$customer_id . "' ORDER BY date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalRewards($customer_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_reward WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getRewardTotal($customer_id) {
|
||||
$query = $this->db->query("SELECT SUM(points) AS total FROM " . DB_PREFIX . "customer_reward WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalCustomerRewardsByOrderId($order_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_reward WHERE order_id = '" . (int)$order_id . "' AND points > 0");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getIps($customer_id, $start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_ip WHERE customer_id = '" . (int)$customer_id . "' ORDER BY date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalIps($customer_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_ip WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalCustomersByIp($ip) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_ip WHERE ip = '" . $this->db->escape($ip) . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalLoginAttempts($email) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_login` WHERE `email` = '" . $this->db->escape($email) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function deleteLoginAttempts($email) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_login` WHERE `email` = '" . $this->db->escape($email) . "'");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
class ModelCustomerCustomerApproval extends Model {
|
||||
public function getCustomerApprovals($data = array()) {
|
||||
$sql = "SELECT *, CONCAT(c.`firstname`, ' ', c.`lastname`) AS name, cgd.`name` AS customer_group, ca.`type` FROM `" . DB_PREFIX . "customer_approval` ca LEFT JOIN `" . DB_PREFIX . "customer` c ON (ca.`customer_id` = c.`customer_id`) LEFT JOIN `" . DB_PREFIX . "customer_group_description` cgd ON (c.`customer_group_id` = cgd.`customer_group_id`) WHERE cgd.`language_id` = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND CONCAT(c.`firstname`, ' ', c.`lastname`) LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_email'])) {
|
||||
$sql .= " AND c.`email` LIKE '" . $this->db->escape($data['filter_email']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer_group_id'])) {
|
||||
$sql .= " AND c.`customer_group_id` = '" . (int)$data['filter_customer_group_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_type'])) {
|
||||
$sql .= " AND ca.`type` = '" . $this->db->escape($data['filter_type']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(c.`date_added`) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY c.`date_added` DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getCustomerApproval($customer_approval_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_approval` WHERE `customer_approval_id` = '" . (int)$customer_approval_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getTotalCustomerApprovals($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_approval` ca LEFT JOIN `" . DB_PREFIX . "customer` c ON (ca.`customer_id` = c.`customer_id`)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$implode[] = "CONCAT(c.`firstname`, ' ', c.`lastname`) LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_email'])) {
|
||||
$implode[] = "c.`email` LIKE '" . $this->db->escape($data['filter_email']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer_group_id'])) {
|
||||
$implode[] = "c.`customer_group_id` = '" . (int)$data['filter_customer_group_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_type'])) {
|
||||
$implode[] = "ca.`type` = '" . $this->db->escape($data['filter_type']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "DATE(ca.`date_added`) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function approveCustomer($customer_id) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "customer` SET status = '1' WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_approval` WHERE customer_id = '" . (int)$customer_id . "' AND `type` = 'customer'");
|
||||
}
|
||||
|
||||
public function denyCustomer($customer_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_approval` WHERE customer_id = '" . (int)$customer_id . "' AND `type` = 'customer'");
|
||||
}
|
||||
|
||||
public function approveAffiliate($customer_id) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "customer_affiliate` SET status = '1' WHERE customer_id = '" . (int)$customer_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_approval` WHERE customer_id = '" . (int)$customer_id . "' AND `type` = 'affiliate'");
|
||||
}
|
||||
|
||||
public function denyAffiliate($customer_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_approval` WHERE customer_id = '" . (int)$customer_id . "' AND `type` = 'affiliate'");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
class ModelCustomerCustomerGroup extends Model {
|
||||
public function addCustomerGroup($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_group SET approval = '" . (int)$data['approval'] . "', sort_order = '" . (int)$data['sort_order'] . "'");
|
||||
|
||||
$customer_group_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['customer_group_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_group_description SET customer_group_id = '" . (int)$customer_group_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "'");
|
||||
}
|
||||
|
||||
return $customer_group_id;
|
||||
}
|
||||
|
||||
public function editCustomerGroup($customer_group_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "customer_group SET approval = '" . (int)$data['approval'] . "', sort_order = '" . (int)$data['sort_order'] . "' WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_group_description WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
|
||||
foreach ($data['customer_group_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_group_description SET customer_group_id = '" . (int)$customer_group_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteCustomerGroup($customer_group_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_group WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_group_description WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_special WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_reward WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "tax_rate_to_customer_group WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
}
|
||||
|
||||
public function getCustomerGroup($customer_group_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "customer_group cg LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (cg.customer_group_id = cgd.customer_group_id) WHERE cg.customer_group_id = '" . (int)$customer_group_id . "' AND cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCustomerGroups($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "customer_group cg LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (cg.customer_group_id = cgd.customer_group_id) WHERE cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sort_data = array(
|
||||
'cgd.name',
|
||||
'cg.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY cgd.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getCustomerGroupDescriptions($customer_group_id) {
|
||||
$customer_group_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_group_description WHERE customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$customer_group_data[$result['language_id']] = array(
|
||||
'name' => $result['name'],
|
||||
'description' => $result['description']
|
||||
);
|
||||
}
|
||||
|
||||
return $customer_group_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomerGroups() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer_group");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
class ModelDesignBanner extends Model {
|
||||
public function addBanner($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "banner SET name = '" . $this->db->escape($data['name']) . "', status = '" . (int)$data['status'] . "'");
|
||||
|
||||
$banner_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['banner_image'])) {
|
||||
foreach ($data['banner_image'] as $language_id => $value) {
|
||||
foreach ($value as $banner_image) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "banner_image SET banner_id = '" . (int)$banner_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($banner_image['title']) . "', link = '" . $this->db->escape($banner_image['link']) . "', description = '" . $this->db->escape($banner_image['description']) . "', button_text = '" . $this->db->escape($banner_image['button_text']) . "', image = '" . $this->db->escape($banner_image['image']) . "', image_mobile = '" . $this->db->escape($banner_image['image_mobile']) . "', sort_order = '" . (int)$banner_image['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $banner_id;
|
||||
}
|
||||
|
||||
public function editBanner($banner_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "banner SET name = '" . $this->db->escape($data['name']) . "', status = '" . (int)$data['status'] . "' WHERE banner_id = '" . (int)$banner_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "banner_image WHERE banner_id = '" . (int)$banner_id . "'");
|
||||
|
||||
if (isset($data['banner_image'])) {
|
||||
foreach ($data['banner_image'] as $language_id => $value) {
|
||||
foreach ($value as $banner_image) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "banner_image SET banner_id = '" . (int)$banner_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($banner_image['title']) . "', link = '" . $this->db->escape($banner_image['link']) . "', description = '" . $this->db->escape($banner_image['description']) . "', button_text = '" . $this->db->escape($banner_image['button_text']) . "', image = '" . $this->db->escape($banner_image['image']) . "', image_mobile = '" . $this->db->escape($banner_image['image_mobile']) . "', sort_order = '" . (int)$banner_image['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteBanner($banner_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "banner WHERE banner_id = '" . (int)$banner_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "banner_image WHERE banner_id = '" . (int)$banner_id . "'");
|
||||
}
|
||||
|
||||
public function getBanner($banner_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "banner WHERE banner_id = '" . (int)$banner_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getBanners($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "banner";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'status'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getBannerImages($banner_id) {
|
||||
$banner_image_data = array();
|
||||
|
||||
$banner_image_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner_image WHERE banner_id = '" . (int)$banner_id . "' ORDER BY sort_order ASC");
|
||||
|
||||
foreach ($banner_image_query->rows as $banner_image) {
|
||||
$banner_image_data[$banner_image['language_id']][] = array(
|
||||
'title' => $banner_image['title'],
|
||||
'link' => $banner_image['link'],
|
||||
'description' => $banner_image['description'],
|
||||
'button_text' => $banner_image['button_text'],
|
||||
'image' => $banner_image['image'],
|
||||
'image_mobile' => $banner_image['image_mobile'],
|
||||
'sort_order' => $banner_image['sort_order']
|
||||
);
|
||||
}
|
||||
|
||||
return $banner_image_data;
|
||||
}
|
||||
|
||||
public function getTotalBanners() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "banner");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
class ModelDesignLayout extends Model {
|
||||
public function addLayout($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "layout SET name = '" . $this->db->escape($data['name']) . "'");
|
||||
|
||||
$layout_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['layout_route'])) {
|
||||
foreach ($data['layout_route'] as $layout_route) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "layout_route SET layout_id = '" . (int)$layout_id . "', store_id = '" . (int)$layout_route['store_id'] . "', route = '" . $this->db->escape($layout_route['route']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['layout_module'])) {
|
||||
foreach ($data['layout_module'] as $layout_module) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "layout_module SET layout_id = '" . (int)$layout_id . "', code = '" . $this->db->escape($layout_module['code']) . "', position = '" . $this->db->escape($layout_module['position']) . "', sort_order = '" . (int)$layout_module['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
return $layout_id;
|
||||
}
|
||||
|
||||
public function editLayout($layout_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "layout SET name = '" . $this->db->escape($data['name']) . "' WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "layout_route WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
if (isset($data['layout_route'])) {
|
||||
foreach ($data['layout_route'] as $layout_route) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "layout_route SET layout_id = '" . (int)$layout_id . "', store_id = '" . (int)$layout_route['store_id'] . "', route = '" . $this->db->escape($layout_route['route']) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "layout_module WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
if (isset($data['layout_module'])) {
|
||||
foreach ($data['layout_module'] as $layout_module) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "layout_module SET layout_id = '" . (int)$layout_id . "', code = '" . $this->db->escape($layout_module['code']) . "', position = '" . $this->db->escape($layout_module['position']) . "', sort_order = '" . (int)$layout_module['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteLayout($layout_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "layout_route WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "layout_module WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "category_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "information_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
|
||||
public function getLayout($layout_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getLayouts($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "layout";
|
||||
|
||||
$sort_data = array('name');
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getLayoutRoutes($layout_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_route WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getLayoutModules($layout_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_module WHERE layout_id = '" . (int)$layout_id . "' ORDER BY position ASC, sort_order ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalLayouts() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "layout");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
class ModelDesignSeoUrl extends Model {
|
||||
public function addSeoUrl($data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "seo_url` SET store_id = '" . (int)$data['store_id'] . "', language_id = '" . (int)$data['language_id'] . "', query = '" . $this->db->escape($data['query']) . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
|
||||
}
|
||||
|
||||
public function editSeoUrl($seo_url_id, $data) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "seo_url` SET store_id = '" . (int)$data['store_id'] . "', language_id = '" . (int)$data['language_id'] . "', query = '" . $this->db->escape($data['query']) . "', keyword = '" . $this->db->escape($data['keyword']) . "' WHERE seo_url_id = '" . (int)$seo_url_id . "'");
|
||||
}
|
||||
|
||||
public function deleteSeoUrl($seo_url_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE seo_url_id = '" . (int)$seo_url_id . "'");
|
||||
}
|
||||
|
||||
public function getSeoUrl($seo_url_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE seo_url_id = '" . (int)$seo_url_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getSeoUrls($data = array()) {
|
||||
$sql = "SELECT *, (SELECT `name` FROM `" . DB_PREFIX . "store` s WHERE s.store_id = su.store_id) AS store, (SELECT `name` FROM `" . DB_PREFIX . "language` l WHERE l.language_id = su.language_id) AS language FROM `" . DB_PREFIX . "seo_url` su";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_query'])) {
|
||||
$implode[] = "`query` LIKE '" . $this->db->escape($data['filter_query']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_keyword'])) {
|
||||
$implode[] = "`keyword` LIKE '" . $this->db->escape($data['filter_keyword']) . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_store_id']) && $data['filter_store_id'] !== '') {
|
||||
$implode[] = "`store_id` = '" . (int)$data['filter_store_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_language_id']) && $data['filter_language_id'] !== '') {
|
||||
$implode[] = "`language_id` = '" . (int)$data['filter_language_id'] . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'query',
|
||||
'keyword',
|
||||
'language_id',
|
||||
'store_id'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY query";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalSeoUrls($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "seo_url`";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_query'])) {
|
||||
$implode[] = "query LIKE '" . $this->db->escape($data['filter_query']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_keyword'])) {
|
||||
$implode[] = "keyword LIKE '" . $this->db->escape($data['filter_keyword']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_store_id']) && $data['filter_store_id'] !== '') {
|
||||
$implode[] = "store_id = '" . (int)$data['filter_store_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_language_id']) && $data['filter_language_id'] !== '') {
|
||||
$implode[] = "language_id = '" . (int)$data['filter_language_id'] . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getSeoUrlsByKeyword($keyword) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getSeoUrlsByQuery($keyword) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
class ModelDesignTheme extends Model {
|
||||
public function editTheme($store_id, $theme, $route, $code) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "theme` WHERE store_id = '" . (int)$store_id . "' AND theme = '" . $this->db->escape($theme) . "' AND route = '" . $this->db->escape($route) . "'");
|
||||
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "theme` SET store_id = '" . (int)$store_id . "', theme = '" . $this->db->escape($theme) . "', route = '" . $this->db->escape($route) . "', code = '" . $this->db->escape($code) . "', date_added = NOW()");
|
||||
}
|
||||
|
||||
public function deleteTheme($theme_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "theme` WHERE theme_id = '" . (int)$theme_id . "'");
|
||||
}
|
||||
|
||||
public function getTheme($store_id, $theme, $route) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "theme` WHERE store_id = '" . (int)$store_id . "' AND theme = '" . $this->db->escape($theme) . "' AND route = '" . $this->db->escape($route) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getThemes($start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT *, (SELECT name FROM `" . DB_PREFIX . "store` s WHERE s.store_id = t.store_id) AS store FROM `" . DB_PREFIX . "theme` t ORDER BY t.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalThemes() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "theme`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
class ModelDesignTranslation extends Model {
|
||||
public function addTranslation($data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape($data['value']) . "', `date_added` = NOW()");
|
||||
}
|
||||
|
||||
public function editTranslation($translation_id, $data) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape($data['value']) . "' WHERE `translation_id` = '" . (int)$translation_id . "'");
|
||||
}
|
||||
|
||||
public function deleteTranslation($translation_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "translation` WHERE `translation_id` = '" . (int)$translation_id . "'");
|
||||
}
|
||||
|
||||
public function getTranslation($translation_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "translation` WHERE `translation_id` = '" . (int)$translation_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getTranslations($data = array()) {
|
||||
$sql = "SELECT *, (SELECT s.name FROM `" . DB_PREFIX . "store` s WHERE s.store_id = t.store_id) AS store, (SELECT l.name FROM `" . DB_PREFIX . "language` l WHERE l.language_id = t.language_id) AS language FROM `" . DB_PREFIX . "translation` t";
|
||||
|
||||
$sort_data = array(
|
||||
'store',
|
||||
'language',
|
||||
'route',
|
||||
'key',
|
||||
'value'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY `" . $data['sort'] . "`";
|
||||
} else {
|
||||
$sql .= " ORDER BY store";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalTranslations() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "translation`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,697 @@
|
||||
<?php
|
||||
|
||||
use \googleshopping\exception\Connection as ConnectionException;
|
||||
use \googleshopping\Googleshopping;
|
||||
|
||||
class ModelExtensionAdvertiseGoogle extends Model {
|
||||
private $events = array(
|
||||
'admin/view/common/column_left/before' => array(
|
||||
'extension/advertise/google/admin_link',
|
||||
),
|
||||
'admin/model/catalog/product/addProduct/after' => array(
|
||||
'extension/advertise/google/addProduct',
|
||||
),
|
||||
'admin/model/catalog/product/copyProduct/after' => array(
|
||||
'extension/advertise/google/copyProduct',
|
||||
),
|
||||
'admin/model/catalog/product/deleteProduct/after' => array(
|
||||
'extension/advertise/google/deleteProduct',
|
||||
),
|
||||
'catalog/controller/checkout/success/before' => array(
|
||||
'extension/advertise/google/before_checkout_success'
|
||||
),
|
||||
'store/view/common/header/after' => array(
|
||||
'extension/advertise/google/google_global_site_tag'
|
||||
),
|
||||
'store/view/common/success/after' => array(
|
||||
'extension/advertise/google/google_dynamic_remarketing_purchase'
|
||||
),
|
||||
'store/view/product/product/after' => array(
|
||||
'extension/advertise/google/google_dynamic_remarketing_product'
|
||||
),
|
||||
'store/view/product/search/after' => array(
|
||||
'extension/advertise/google/google_dynamic_remarketing_searchresults'
|
||||
),
|
||||
'store/view/product/category/after' => array(
|
||||
'extension/advertise/google/google_dynamic_remarketing_category'
|
||||
),
|
||||
'store/view/common/home/after' => array(
|
||||
'extension/advertise/google/google_dynamic_remarketing_home'
|
||||
),
|
||||
'store/view/checkout/cart/after' => array(
|
||||
'extension/advertise/google/google_dynamic_remarketing_cart'
|
||||
)
|
||||
);
|
||||
|
||||
private $rename_tables = array(
|
||||
'advertise_google_target' => 'googleshopping_target',
|
||||
'category_to_google_product_category' => 'googleshopping_category',
|
||||
'product_advertise_google_status' => 'googleshopping_product_status',
|
||||
'product_advertise_google_target' => 'googleshopping_product_target',
|
||||
'product_advertise_google' => 'googleshopping_product'
|
||||
);
|
||||
|
||||
private $table_columns = array(
|
||||
'googleshopping_target' => array(
|
||||
'advertise_google_target_id',
|
||||
'store_id',
|
||||
'campaign_name',
|
||||
'country',
|
||||
'budget',
|
||||
'feeds',
|
||||
'status'
|
||||
),
|
||||
'googleshopping_category' => array(
|
||||
'google_product_category',
|
||||
'store_id',
|
||||
'category_id'
|
||||
),
|
||||
'googleshopping_product_status' => array(
|
||||
'product_id',
|
||||
'store_id',
|
||||
'product_variation_id',
|
||||
'destination_statuses',
|
||||
'data_quality_issues',
|
||||
'item_level_issues',
|
||||
'google_expiration_date'
|
||||
),
|
||||
'googleshopping_product_target' => array(
|
||||
'product_id',
|
||||
'store_id',
|
||||
'advertise_google_target_id'
|
||||
),
|
||||
'googleshopping_product' => array(
|
||||
'product_advertise_google_id',
|
||||
'product_id',
|
||||
'store_id',
|
||||
'has_issues',
|
||||
'destination_status',
|
||||
'impressions',
|
||||
'clicks',
|
||||
'conversions',
|
||||
'cost',
|
||||
'conversion_value',
|
||||
'google_product_category',
|
||||
'condition',
|
||||
'adult',
|
||||
'multipack',
|
||||
'is_bundle',
|
||||
'age_group',
|
||||
'color',
|
||||
'gender',
|
||||
'size_type',
|
||||
'size_system',
|
||||
'size',
|
||||
'is_modified'
|
||||
)
|
||||
);
|
||||
|
||||
public function isAppIdUsed($app_id, $store_id) {
|
||||
$sql = "SELECT `store_id` FROM `" . DB_PREFIX . "setting` WHERE `key`='advertise_google_app_id' AND `value`='" . $this->db->escape($store_id) . "' AND `store_id`!=" . (int)$store_id . " LIMIT 1";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
try {
|
||||
$googleshopping = new Googleshopping($this->registry, (int)$result->row['store_id']);
|
||||
|
||||
return $googleshopping->isConnected();
|
||||
} catch (\RuntimeException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFinalProductId() {
|
||||
$sql = "SELECT product_id FROM `" . DB_PREFIX . "product` ORDER BY product_id DESC LIMIT 1";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
return (int)$result->row['product_id'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function isAnyProductCategoryModified($store_id) {
|
||||
$sql = "SELECT pag.is_modified FROM `" . DB_PREFIX . "googleshopping_product` pag WHERE pag.google_product_category IS NOT NULL AND pag.store_id=" . (int)$store_id . " LIMIT 0,1";
|
||||
|
||||
return $this->db->query($sql)->num_rows > 0;
|
||||
}
|
||||
|
||||
public function getAdvertisedCount($store_id) {
|
||||
$result = $this->db->query("SELECT COUNT(product_id) as total FROM `" . DB_PREFIX . "googleshopping_product_target` WHERE store_id=" . (int)$store_id . " GROUP BY `product_id`");
|
||||
|
||||
return $result->num_rows > 0 ? (int)$result->row['total'] : 0;
|
||||
}
|
||||
|
||||
public function getMapping($store_id) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "googleshopping_category` WHERE store_id=" . (int)$store_id;
|
||||
|
||||
return $this->db->query($sql)->rows;
|
||||
}
|
||||
|
||||
public function setCategoryMapping($google_product_category, $store_id, $category_id) {
|
||||
$sql = "INSERT INTO `" . DB_PREFIX . "googleshopping_category` SET `google_product_category`='" . $this->db->escape($google_product_category) . "', `store_id`=" . (int)$store_id . ", `category_id`=" . (int)$category_id . " ON DUPLICATE KEY UPDATE `category_id`=" . (int)$category_id;
|
||||
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
public function getMappedCategory($google_product_category, $store_id) {
|
||||
$sql = "SELECT GROUP_CONCAT(cd.name ORDER BY cp.level SEPARATOR ' > ') AS name, cp.category_id FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "category_description cd ON (cp.path_id = cd.category_id) LEFT JOIN `" . DB_PREFIX . "googleshopping_category` c2gpc ON (c2gpc.category_id = cp.category_id) WHERE cd.language_id=" . (int)$this->config->get('config_language_id') . " AND c2gpc.google_product_category='" . $this->db->escape($google_product_category) . "' AND c2gpc.store_id=" . (int)$store_id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
return $result->row;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getProductByProductAdvertiseGoogleId($product_advertise_google_id) {
|
||||
$sql = "SELECT pag.product_id FROM `" . DB_PREFIX . "googleshopping_product` pag WHERE pag.product_advertise_google_id=" . (int)$product_advertise_google_id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result->num_rows) {
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
return $this->model_catalog_product->getProduct($result->row['product_id']);
|
||||
}
|
||||
}
|
||||
|
||||
public function getProductAdvertiseGoogle($product_advertise_google_id) {
|
||||
$sql = "SELECT pag.* FROM `" . DB_PREFIX . "googleshopping_product` pag WHERE pag.product_advertise_google_id=" . (int)$product_advertise_google_id;
|
||||
|
||||
return $this->db->query($sql)->row;
|
||||
}
|
||||
|
||||
public function hasActiveTarget($store_id) {
|
||||
$sql = "SELECT agt.advertise_google_target_id FROM `" . DB_PREFIX . "googleshopping_target` agt WHERE agt.store_id=" . (int)$store_id . " AND agt.status='active' LIMIT 1";
|
||||
|
||||
return $this->db->query($sql)->num_rows > 0;
|
||||
}
|
||||
|
||||
public function getRequiredFieldsByProductIds($product_ids, $store_id) {
|
||||
$this->load->config('googleshopping/googleshopping');
|
||||
|
||||
$result = array();
|
||||
$countries = $this->getTargetCountriesByProductIds($product_ids, $store_id);
|
||||
|
||||
foreach ($countries as $country) {
|
||||
foreach ($this->config->get('advertise_google_country_required_fields') as $field => $requirements) {
|
||||
if (
|
||||
(!empty($requirements['countries']) && in_array($country, $requirements['countries']))
|
||||
||
|
||||
(is_array($requirements['countries']) && empty($requirements['countries']))
|
||||
) {
|
||||
$result[$field] = $requirements;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getRequiredFieldsByFilter($data, $store_id) {
|
||||
$this->load->config('googleshopping/googleshopping');
|
||||
|
||||
$result = array();
|
||||
$countries = $this->getTargetCountriesByFilter($data, $store_id);
|
||||
|
||||
foreach ($countries as $country) {
|
||||
foreach ($this->config->get('advertise_google_country_required_fields') as $field => $requirements) {
|
||||
if (
|
||||
(!empty($requirements['countries']) && in_array($country, $requirements['countries']))
|
||||
||
|
||||
(is_array($requirements['countries']) && empty($requirements['countries']))
|
||||
) {
|
||||
$result[$field] = $requirements;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTargetCountriesByProductIds($product_ids, $store_id) {
|
||||
$sql = "SELECT DISTINCT agt.country FROM `" . DB_PREFIX . "googleshopping_product_target` pagt LEFT JOIN `" . DB_PREFIX . "googleshopping_target` agt ON (agt.advertise_google_target_id = pagt.advertise_google_target_id AND agt.store_id = pagt.store_id) WHERE pagt.product_id IN (" . $this->googleshopping->productIdsToIntegerExpression($product_ids) . ") AND pagt.store_id=" . (int)$store_id;
|
||||
|
||||
return array_map(array($this, 'country'), $this->db->query($sql)->rows);
|
||||
}
|
||||
|
||||
public function getTargetCountriesByFilter($data, $store_id) {
|
||||
$sql = "SELECT DISTINCT agt.country FROM `" . DB_PREFIX . "googleshopping_product_target` pagt LEFT JOIN `" . DB_PREFIX . "googleshopping_target` agt ON (agt.advertise_google_target_id = pagt.advertise_google_target_id AND agt.store_id = pagt.store_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (pagt.product_id = p.product_id) LEFT JOIN `" . DB_PREFIX . "product_description` pd ON (pd.product_id = pagt.product_id) WHERE pagt.store_id=" . (int)$store_id . " AND pd.language_id=" . (int)$this->config->get('config_language_id');
|
||||
|
||||
$this->googleshopping->applyFilter($sql, $data);
|
||||
|
||||
return array_map(array($this, 'country'), $this->db->query($sql)->rows);
|
||||
}
|
||||
|
||||
public function getProductOptionsByProductIds($product_ids) {
|
||||
$sql = "SELECT po.option_id, od.name FROM `" . DB_PREFIX . "product_option` po LEFT JOIN `" . DB_PREFIX . "option_description` od ON (od.option_id=po.option_id AND od.language_id=" . (int)$this->config->get('config_language_id') . ") LEFT JOIN `" . DB_PREFIX . "option` o ON (o.option_id = po.option_id) WHERE o.type IN ('select', 'radio') AND po.product_id IN (" . $this->googleshopping->productIdsToIntegerExpression($product_ids) . ")";
|
||||
|
||||
return $this->db->query($sql)->rows;
|
||||
}
|
||||
|
||||
public function getProductOptionsByFilter($data) {
|
||||
$sql = "SELECT DISTINCT po.option_id, od.name FROM `" . DB_PREFIX . "product_option` po LEFT JOIN `" . DB_PREFIX . "option_description` od ON (od.option_id=po.option_id AND od.language_id=" . (int)$this->config->get('config_language_id') . ") LEFT JOIN `" . DB_PREFIX . "option` o ON (o.option_id = po.option_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (po.product_id = p.product_id) LEFT JOIN `" . DB_PREFIX . "product_description` pd ON (pd.product_id = po.product_id) WHERE o.type IN ('select', 'radio') AND pd.language_id=" . (int)$this->config->get('config_language_id');
|
||||
|
||||
$this->googleshopping->applyFilter($sql, $data);
|
||||
|
||||
return $this->db->query($sql)->rows;
|
||||
}
|
||||
|
||||
public function addTarget($target, $store_id) {
|
||||
$sql = "INSERT INTO `" . DB_PREFIX . "googleshopping_target` SET `store_id`=" . (int)$store_id . ", `campaign_name`='" . $this->db->escape($target['campaign_name']) . "', `country`='" . $this->db->escape($target['country']) . "', `budget`='" . (float)$target['budget'] . "', `feeds`='" . $this->db->escape(json_encode($target['feeds'])) . "', `date_added`=NOW(), `roas`=" . (int)$target['roas'] . " , `status`='" . $this->db->escape($target['status']) . "'";
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function deleteProducts($product_ids) {
|
||||
$sql = "DELETE FROM `" . DB_PREFIX . "googleshopping_product` WHERE `product_id` IN (" . $this->googleshopping->productIdsToIntegerExpression($product_ids) . ")";
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
$sql = "DELETE FROM `" . DB_PREFIX . "googleshopping_product_target` WHERE `product_id` IN (" . $this->googleshopping->productIdsToIntegerExpression($product_ids) . ")";
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
$sql = "DELETE FROM `" . DB_PREFIX . "googleshopping_product_status` WHERE `product_id` IN (" . $this->googleshopping->productIdsToIntegerExpression($product_ids) . ")";
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setAdvertisingBySelect($post_product_ids, $post_target_ids, $store_id) {
|
||||
if (!empty($post_product_ids)) {
|
||||
$product_ids = array_map(array($this->googleshopping, 'integer'), $post_product_ids);
|
||||
|
||||
$product_ids_expression = implode(',', $product_ids);
|
||||
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "googleshopping_product_target` WHERE product_id IN (" . $product_ids_expression . ") AND store_id=" . (int)$store_id);
|
||||
|
||||
if (!empty($post_target_ids)) {
|
||||
$target_ids = array_map(array($this->googleshopping, 'integer'), $post_target_ids);
|
||||
|
||||
$values = array();
|
||||
|
||||
foreach ($product_ids as $product_id) {
|
||||
foreach ($target_ids as $target_id) {
|
||||
$values[] = '(' . $product_id . ',' . $store_id . ',' . $target_id . ')';
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `" . DB_PREFIX . "googleshopping_product_target` (`product_id`, `store_id`, `advertise_google_target_id`) VALUES " . implode(',', $values);
|
||||
|
||||
$this->db->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setAdvertisingByFilter($data, $post_target_ids, $store_id) {
|
||||
$sql = "DELETE pagt FROM `" . DB_PREFIX . "googleshopping_product_target` pagt LEFT JOIN `" . DB_PREFIX . "product` p ON (pagt.product_id = p.product_id) LEFT JOIN `" . DB_PREFIX . "product_description` pd ON (pd.product_id = p.product_id) WHERE pd.language_id=" . (int)$this->config->get('config_language_id');
|
||||
|
||||
$this->googleshopping->applyFilter($sql, $data);
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
if (!empty($post_target_ids)) {
|
||||
$target_ids = array_map(array($this->googleshopping, 'integer'), $post_target_ids);
|
||||
|
||||
$insert_sql = "SELECT p.product_id, " . (int)$store_id . " as store_id, '{TARGET_ID}' as advertise_google_target_id FROM `" . DB_PREFIX . "product` p LEFT JOIN `" . DB_PREFIX . "product_description` pd ON (pd.product_id = p.product_id) WHERE pd.language_id=" . (int)$this->config->get('config_language_id');
|
||||
|
||||
$this->googleshopping->applyFilter($insert_sql, $data);
|
||||
|
||||
foreach ($target_ids as $target_id) {
|
||||
$sql = "INSERT INTO `" . DB_PREFIX . "googleshopping_product_target` (`product_id`, `store_id`, `advertise_google_target_id`) " . str_replace('{TARGET_ID}', (string)$target_id, $insert_sql);
|
||||
|
||||
$this->db->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function insertNewProducts($product_ids = array(), $store_id) {
|
||||
$sql = "INSERT INTO `" . DB_PREFIX . "googleshopping_product` (`product_id`, `store_id`, `google_product_category`) SELECT p.product_id, p2s.store_id, (SELECT c2gpc.google_product_category FROM `" . DB_PREFIX . "product_to_category` p2c LEFT JOIN `" . DB_PREFIX . "category_path` cp ON (p2c.category_id = cp.category_id) LEFT JOIN `" . DB_PREFIX . "googleshopping_category` c2gpc ON (c2gpc.category_id = cp.path_id AND c2gpc.store_id = " . (int)$store_id . ") WHERE p2c.product_id = p.product_id AND c2gpc.google_product_category IS NOT NULL ORDER BY cp.level DESC LIMIT 0,1) as `google_product_category` FROM `" . DB_PREFIX . "product` p LEFT JOIN `" . DB_PREFIX . "product_to_store` p2s ON (p2s.product_id = p.product_id AND p2s.store_id = " . (int)$store_id . ") LEFT JOIN `" . DB_PREFIX . "googleshopping_product` pag ON (pag.product_id = p.product_id AND pag.store_id=p2s.store_id) WHERE pag.product_id IS NULL AND p2s.store_id IS NOT NULL";
|
||||
|
||||
if (!empty($product_ids)) {
|
||||
$sql .= " AND p.product_id IN (" . $this->googleshopping->productIdsToIntegerExpression($product_ids) . ")";
|
||||
}
|
||||
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
public function updateGoogleProductCategoryMapping($store_id) {
|
||||
$sql = "INSERT INTO `" . DB_PREFIX . "googleshopping_product` (`product_id`, `store_id`, `google_product_category`) SELECT p.product_id, " . (int)$store_id . " as store_id, (SELECT c2gpc.google_product_category FROM `" . DB_PREFIX . "product_to_category` p2c LEFT JOIN `" . DB_PREFIX . "category_path` cp ON (p2c.category_id = cp.category_id) LEFT JOIN `" . DB_PREFIX . "googleshopping_category` c2gpc ON (c2gpc.category_id = cp.path_id AND c2gpc.store_id = " . (int)$store_id . ") WHERE p2c.product_id = p.product_id AND c2gpc.google_product_category IS NOT NULL ORDER BY cp.level DESC LIMIT 0,1) as `google_product_category` FROM `" . DB_PREFIX . "product` p LEFT JOIN `" . DB_PREFIX . "googleshopping_product` pag ON (pag.product_id = p.product_id) WHERE pag.product_id IS NOT NULL ON DUPLICATE KEY UPDATE `google_product_category`=VALUES(`google_product_category`)";
|
||||
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
public function updateSingleProductFields($data) {
|
||||
$values = array();
|
||||
|
||||
$entry = array();
|
||||
$entry['product_id'] = (int)$data['product_id'];
|
||||
$entry = array_merge($entry, $this->makeInsertData($data));
|
||||
|
||||
$values[] = "(" . implode(",", $entry) . ")";
|
||||
|
||||
$sql = "INSERT INTO `" . DB_PREFIX . "googleshopping_product` (`product_id`, `store_id`, `google_product_category`, `condition`, `adult`, `multipack`, `is_bundle`, `age_group`, `color`, `gender`, `size_type`, `size_system`, `size`, `is_modified`) VALUES " . implode(',', $values) . " ON DUPLICATE KEY UPDATE " . $this->makeOnDuplicateKeyData();
|
||||
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
public function updateMultipleProductFields($filter_data, $data) {
|
||||
$insert_sql = "SELECT p.product_id, {INSERT_DATA} FROM `" . DB_PREFIX . "product` p LEFT JOIN `" . DB_PREFIX . "product_description` pd ON (pd.product_id = p.product_id) WHERE pd.language_id=" . (int)$this->config->get('config_language_id');
|
||||
|
||||
$this->googleshopping->applyFilter($insert_sql, $filter_data);
|
||||
|
||||
$insert_data = array();
|
||||
$keys[] = "`product_id`";
|
||||
|
||||
foreach ($this->makeInsertData($data) as $key => $value) {
|
||||
$insert_data[] = $value . " as `" . $key . "`";
|
||||
$keys[] = "`" . $key . "`";
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `" . DB_PREFIX . "googleshopping_product` (" . implode(", ", $keys) . ") " . str_replace('{INSERT_DATA}', implode(", ", $insert_data), $insert_sql) . " ON DUPLICATE KEY UPDATE " . $this->makeOnDuplicateKeyData();
|
||||
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
protected function makeInsertData($data) {
|
||||
$insert_data = array();
|
||||
|
||||
$insert_data['store_id'] = (int)$data['store_id'];
|
||||
$insert_data['google_product_category'] = "'" . $this->db->escape($data['google_product_category']) . "'";
|
||||
$insert_data['condition'] = "'" . $this->db->escape($data['condition']) . "'";
|
||||
$insert_data['adult'] = (int)$data['adult'];
|
||||
$insert_data['multipack'] = (int)$data['multipack'];
|
||||
$insert_data['is_bundle'] = (int)$data['is_bundle'];
|
||||
$insert_data['age_group'] = "'" . $this->db->escape($data['age_group']) . "'";
|
||||
$insert_data['color'] = (int)$data['color'];
|
||||
$insert_data['gender'] = "'" . $this->db->escape($data['gender']) . "'";
|
||||
$insert_data['size_type'] = "'" . $this->db->escape($data['size_type']) . "'";
|
||||
$insert_data['size_system'] = "'" . $this->db->escape($data['size_system']) . "'";
|
||||
$insert_data['size'] = (int)$data['size'];
|
||||
$insert_data['is_modified'] = 1;
|
||||
|
||||
return $insert_data;
|
||||
}
|
||||
|
||||
protected function makeOnDuplicateKeyData() {
|
||||
return "`google_product_category`=VALUES(`google_product_category`), `condition`=VALUES(`condition`), `adult`=VALUES(`adult`), `multipack`=VALUES(`multipack`), `is_bundle`=VALUES(`is_bundle`), `age_group`=VALUES(`age_group`), `color`=VALUES(`color`), `gender`=VALUES(`gender`), `size_type`=VALUES(`size_type`), `size_system`=VALUES(`size_system`), `size`=VALUES(`size`), `is_modified`=VALUES(`is_modified`)";
|
||||
}
|
||||
|
||||
public function getCategories($data = array(), $store_id) {
|
||||
$sql = "SELECT cp.category_id AS category_id, GROUP_CONCAT(cd1.name ORDER BY cp.level SEPARATOR ' > ') AS name, c1.parent_id, c1.sort_order FROM " . DB_PREFIX . "category_path cp LEFT JOIN `" . DB_PREFIX . "category_to_store` c2s ON (c2s.category_id = cp.category_id AND c2s.store_id=" . (int)$store_id . ") LEFT JOIN " . DB_PREFIX . "category c1 ON (cp.category_id = c1.category_id) LEFT JOIN " . DB_PREFIX . "category c2 ON (cp.path_id = c2.category_id) LEFT JOIN " . DB_PREFIX . "category_description cd1 ON (cp.path_id = cd1.category_id) LEFT JOIN " . DB_PREFIX . "category_description cd2 ON (cp.category_id = cd2.category_id) WHERE c2s.store_id IS NOT NULL AND cd1.language_id = '" . (int)$this->config->get('config_language_id') . "' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND cd2.name LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY cp.category_id";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'sort_order'
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getProductCampaigns($product_id, $store_id) {
|
||||
$sql = "SELECT agt.advertise_google_target_id, agt.campaign_name FROM `" . DB_PREFIX . "googleshopping_product_target` pagt LEFT JOIN `" . DB_PREFIX . "googleshopping_target` agt ON (pagt.advertise_google_target_id = agt.advertise_google_target_id) WHERE pagt.product_id=" . (int)$product_id . " AND pagt.store_id=" . (int)$store_id;
|
||||
|
||||
return $this->db->query($sql)->rows;
|
||||
}
|
||||
|
||||
public function getProductIssues($product_id, $store_id) {
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$sql = "SELECT pag.color, pag.size, pd.name, p.model FROM `" . DB_PREFIX . "googleshopping_product` pag LEFT JOIN `" . DB_PREFIX . "product` p ON (p.product_id = pag.product_id) LEFT JOIN `" . DB_PREFIX . "product_description` pd ON (pd.product_id = pag.product_id AND pd.language_id=" . (int)$this->config->get('config_language_id') . ") WHERE pag.product_id=" . (int)$product_id . " AND pag.store_id=" . (int)$store_id;
|
||||
|
||||
$product_info = $this->db->query($sql)->row;
|
||||
|
||||
if (!empty($product_info)) {
|
||||
$result = array();
|
||||
$result['name'] = $product_info['name'];
|
||||
$result['model'] = $product_info['model'];
|
||||
$result['entries'] = array();
|
||||
|
||||
foreach ($this->model_localisation_language->getLanguages() as $language) {
|
||||
$language_id = $language['language_id'];
|
||||
$groups = $this->googleshopping->getGroups($product_id, $language_id, $product_info['color'], $product_info['size']);
|
||||
|
||||
$result['entries'][$language_id] = array(
|
||||
'language_name' => $language['name'],
|
||||
'issues' => array()
|
||||
);
|
||||
|
||||
foreach ($groups as $id => $group) {
|
||||
$issues = $this->db->query("SELECT * FROM `" . DB_PREFIX . "googleshopping_product_status` WHERE product_id=" . (int)$product_id . " AND store_id=" . (int)$store_id . " AND product_variation_id='" . $this->db->escape($id) . "'")->row;
|
||||
|
||||
$destination_statuses = !empty($issues['destination_statuses']) ? json_decode($issues['destination_statuses'], true) : array();
|
||||
$data_quality_issues = !empty($issues['data_quality_issues']) ? json_decode($issues['data_quality_issues'], true) : array();
|
||||
$item_level_issues = !empty($issues['item_level_issues']) ? json_decode($issues['item_level_issues'], true) : array();
|
||||
$google_expiration_date = !empty($issues['google_expiration_date']) ? date($this->language->get('datetime_format'), $issues['google_expiration_date']) : $this->language->get('text_na');
|
||||
|
||||
$result['entries'][$language_id]['issues'][] = array(
|
||||
'color' => $group['color'] != "" ? $group['color'] : $this->language->get('text_na'),
|
||||
'size' => $group['size'] != "" ? $group['size'] : $this->language->get('text_na'),
|
||||
'destination_statuses' => $destination_statuses,
|
||||
'data_quality_issues' => $data_quality_issues,
|
||||
'item_level_issues' => $item_level_issues,
|
||||
'google_expiration_date' => $google_expiration_date
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shortly after releasing the extension,
|
||||
* we learned that the table names are actually
|
||||
* clashing with third-party extensions.
|
||||
* Hence, this renaming script was created.
|
||||
*/
|
||||
public function renameTables() {
|
||||
foreach ($this->rename_tables as $old_table => $new_table) {
|
||||
$new_table_name = DB_PREFIX . $new_table;
|
||||
$old_table_name = DB_PREFIX . $old_table;
|
||||
|
||||
if ($this->tableExists($old_table_name) && !$this->tableExists($new_table_name) && $this->tableColumnsMatch($old_table_name, $this->table_columns[$new_table])) {
|
||||
$this->db->query("RENAME TABLE `" . $old_table_name . "` TO `" . $new_table_name . "`");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function tableExists($table) {
|
||||
return $this->db->query("SHOW TABLES LIKE '" . $table . "'")->num_rows > 0;
|
||||
}
|
||||
|
||||
private function tableColumnsMatch($table, $columns) {
|
||||
$num_columns = $this->db->query("SHOW COLUMNS FROM `" . $table . "` WHERE Field IN (" . implode(',', $this->wrap($columns, '"')) . ")")->num_rows;
|
||||
|
||||
return $num_columns == count($columns);
|
||||
}
|
||||
|
||||
private function wrap($text, $char) {
|
||||
if (is_array($text)) {
|
||||
foreach ($text as &$string) {
|
||||
$string = $char . $string . $char;
|
||||
}
|
||||
|
||||
return $text;
|
||||
} else {
|
||||
return $char . $text . $char;
|
||||
}
|
||||
}
|
||||
|
||||
public function createTables() {
|
||||
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "googleshopping_product` (
|
||||
`product_advertise_google_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`product_id` INT(11),
|
||||
`store_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`has_issues` TINYINT(1),
|
||||
`destination_status` ENUM('pending','approved','disapproved') NOT NULL DEFAULT 'pending',
|
||||
`impressions` INT(11) NOT NULL DEFAULT '0',
|
||||
`clicks` INT(11) NOT NULL DEFAULT '0',
|
||||
`conversions` INT(11) NOT NULL DEFAULT '0.0000',
|
||||
`cost` decimal(15,4) NOT NULL DEFAULT '0.0000',
|
||||
`conversion_value` decimal(15,4) NOT NULL DEFAULT '0.0000',
|
||||
`google_product_category` VARCHAR(10),
|
||||
`condition` ENUM('new','refurbished','used'),
|
||||
`adult` TINYINT(1),
|
||||
`multipack` INT(11),
|
||||
`is_bundle` TINYINT(1),
|
||||
`age_group` ENUM('newborn','infant','toddler','kids','adult'),
|
||||
`color` INT(11),
|
||||
`gender` ENUM('male','female','unisex'),
|
||||
`size_type` ENUM('regular','petite','plus','big and tall','maternity'),
|
||||
`size_system` ENUM('AU','BR','CN','DE','EU','FR','IT','JP','MEX','UK','US'),
|
||||
`size` INT(11),
|
||||
`is_modified` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`product_advertise_google_id`),
|
||||
UNIQUE `product_id_store_id` (`product_id`, `store_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
|
||||
|
||||
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "googleshopping_product_status` (
|
||||
`product_id` INT(11),
|
||||
`store_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`product_variation_id` varchar(64),
|
||||
`destination_statuses` TEXT NOT NULL,
|
||||
`data_quality_issues` TEXT NOT NULL,
|
||||
`item_level_issues` TEXT NOT NULL,
|
||||
`google_expiration_date` INT(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`product_id`, `store_id`, `product_variation_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
|
||||
|
||||
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "googleshopping_product_target` (
|
||||
`product_id` INT(11) NOT NULL,
|
||||
`store_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`advertise_google_target_id` INT(11) UNSIGNED NOT NULL,
|
||||
PRIMARY KEY (`product_id`, `advertise_google_target_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
|
||||
|
||||
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "googleshopping_category` (
|
||||
`google_product_category` VARCHAR(10) NOT NULL,
|
||||
`store_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`category_id` INT(11) NOT NULL,
|
||||
INDEX `category_id_store_id` (`category_id`, `store_id`),
|
||||
PRIMARY KEY (`google_product_category`, `store_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
|
||||
|
||||
$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "googleshopping_target` (
|
||||
`advertise_google_target_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`store_id` INT(11) NOT NULL DEFAULT '0',
|
||||
`campaign_name` varchar(255) NOT NULL DEFAULT '',
|
||||
`country` varchar(2) NOT NULL DEFAULT '',
|
||||
`budget` decimal(15,4) NOT NULL DEFAULT '0.0000',
|
||||
`feeds` text NOT NULL,
|
||||
`date_added` DATE,
|
||||
`roas` INT(11) NOT NULL DEFAULT '0',
|
||||
`status` ENUM('paused','active') NOT NULL DEFAULT 'paused',
|
||||
INDEX `store_id` (`store_id`),
|
||||
PRIMARY KEY (`advertise_google_target_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
|
||||
}
|
||||
|
||||
public function fixColumns() {
|
||||
$has_auto_increment = $this->db->query("SHOW COLUMNS FROM `" . DB_PREFIX . "googleshopping_product` WHERE Field='product_advertise_google_id' AND Extra LIKE '%auto_increment%'")->num_rows > 0;
|
||||
|
||||
if (!$has_auto_increment) {
|
||||
$this->db->query("ALTER TABLE " . DB_PREFIX . "googleshopping_product MODIFY COLUMN product_advertise_google_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT");
|
||||
}
|
||||
|
||||
$has_unique_key = $this->db->query("SHOW INDEX FROM `" . DB_PREFIX . "googleshopping_product` WHERE Key_name='product_id_store_id' AND Non_unique=0")->num_rows == 2;
|
||||
|
||||
if (!$has_unique_key) {
|
||||
$index_exists = $this->db->query("SHOW INDEX FROM `" . DB_PREFIX . "googleshopping_product` WHERE Key_name='product_id_store_id'")->num_rows > 0;
|
||||
|
||||
if ($index_exists) {
|
||||
$this->db->query("ALTER TABLE `" . DB_PREFIX . "googleshopping_product` DROP INDEX product_id_store_id;");
|
||||
}
|
||||
|
||||
$this->db->query("CREATE UNIQUE INDEX product_id_store_id ON `" . DB_PREFIX . "googleshopping_product` (product_id, store_id)");
|
||||
}
|
||||
|
||||
$has_date_added_column = $this->db->query("SHOW COLUMNS FROM `" . DB_PREFIX . "googleshopping_target` WHERE Field='date_added'")->num_rows > 0;
|
||||
|
||||
if (!$has_date_added_column) {
|
||||
$this->db->query("ALTER TABLE " . DB_PREFIX . "googleshopping_target ADD COLUMN date_added DATE");
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "googleshopping_target SET date_added = NOW() WHERE date_added IS NULL");
|
||||
}
|
||||
|
||||
$has_roas_column = $this->db->query("SHOW COLUMNS FROM `" . DB_PREFIX . "googleshopping_target` WHERE Field='roas'")->num_rows > 0;
|
||||
|
||||
if (!$has_roas_column) {
|
||||
$this->db->query("ALTER TABLE " . DB_PREFIX . "googleshopping_target ADD COLUMN roas INT(11) NOT NULL DEFAULT '0'");
|
||||
}
|
||||
}
|
||||
|
||||
public function dropTables() {
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "googleshopping_target`");
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "googleshopping_category`");
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "googleshopping_product_status`");
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "googleshopping_product_target`");
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "googleshopping_product`");
|
||||
}
|
||||
|
||||
public function deleteEvents() {
|
||||
$this->load->model('setting/event');
|
||||
|
||||
$this->model_setting_event->deleteEventByCode('advertise_google');
|
||||
}
|
||||
|
||||
public function createEvents() {
|
||||
$this->load->model('setting/event');
|
||||
|
||||
foreach ($this->events as $trigger => $actions) {
|
||||
foreach ($actions as $action) {
|
||||
$this->model_setting_event->addEvent('advertise_google', $trigger, $action, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllowedTargets() {
|
||||
$this->load->config('googleshopping/googleshopping');
|
||||
|
||||
$result = array();
|
||||
|
||||
foreach ($this->config->get('advertise_google_targets') as $target) {
|
||||
$result[] = array(
|
||||
'country' => array(
|
||||
'code' => $target['country'],
|
||||
'name' => $this->googleshopping->getCountryName($target['country'])
|
||||
),
|
||||
'languages' => $this->googleshopping->getLanguages($target['languages']),
|
||||
'currencies' => $this->googleshopping->getCurrencies($target['currencies'])
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function country($row) {
|
||||
return $row['country'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
class ModelExtensionDashboardActivity extends Model {
|
||||
public function getActivities() {
|
||||
$query = $this->db->query("SELECT `key`, `data`, `date_added` FROM `" . DB_PREFIX . "customer_activity` ORDER BY `date_added` DESC LIMIT 0,5");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
class ModelExtensionDashboardChart extends Model {
|
||||
public function getTotalOrdersByDay() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$order_data[$i] = array(
|
||||
'hour' => $i,
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, HOUR(date_added) AS hour FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND DATE(date_added) = DATE(NOW()) GROUP BY HOUR(date_added) ORDER BY date_added ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[$result['hour']] = array(
|
||||
'hour' => $result['hour'],
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByWeek() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
$date_start = strtotime('-' . date('w') . ' days');
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$date = date('Y-m-d', $date_start + ($i * 86400));
|
||||
|
||||
$order_data[date('w', strtotime($date))] = array(
|
||||
'day' => date('D', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND DATE(date_added) >= DATE('" . $this->db->escape(date('Y-m-d', $date_start)) . "') GROUP BY DAYNAME(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[date('w', strtotime($result['date_added']))] = array(
|
||||
'day' => date('D', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByMonth() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
for ($i = 1; $i <= date('t'); $i++) {
|
||||
$date = date('Y') . '-' . date('m') . '-' . $i;
|
||||
|
||||
$order_data[date('j', strtotime($date))] = array(
|
||||
'day' => date('d', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND DATE(date_added) >= '" . $this->db->escape(date('Y') . '-' . date('m') . '-1') . "' GROUP BY DATE(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[date('j', strtotime($result['date_added']))] = array(
|
||||
'day' => date('d', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByYear() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$order_data[$i] = array(
|
||||
'month' => date('M', mktime(0, 0, 0, $i)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND YEAR(date_added) = YEAR(NOW()) GROUP BY MONTH(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[date('n', strtotime($result['date_added']))] = array(
|
||||
'month' => date('M', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomersByDay() {
|
||||
$customer_data = array();
|
||||
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$customer_data[$i] = array(
|
||||
'hour' => $i,
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, HOUR(date_added) AS hour FROM `" . DB_PREFIX . "customer` WHERE DATE(date_added) = DATE(NOW()) GROUP BY HOUR(date_added) ORDER BY date_added ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$customer_data[$result['hour']] = array(
|
||||
'hour' => $result['hour'],
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $customer_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomersByWeek() {
|
||||
$customer_data = array();
|
||||
|
||||
$date_start = strtotime('-' . date('w') . ' days');
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$date = date('Y-m-d', $date_start + ($i * 86400));
|
||||
|
||||
$customer_data[date('w', strtotime($date))] = array(
|
||||
'day' => date('D', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "customer` WHERE DATE(date_added) >= DATE('" . $this->db->escape(date('Y-m-d', $date_start)) . "') GROUP BY DAYNAME(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$customer_data[date('w', strtotime($result['date_added']))] = array(
|
||||
'day' => date('D', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $customer_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomersByMonth() {
|
||||
$customer_data = array();
|
||||
|
||||
for ($i = 1; $i <= date('t'); $i++) {
|
||||
$date = date('Y') . '-' . date('m') . '-' . $i;
|
||||
|
||||
$customer_data[date('j', strtotime($date))] = array(
|
||||
'day' => date('d', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "customer` WHERE DATE(date_added) >= '" . $this->db->escape(date('Y') . '-' . date('m') . '-1') . "' GROUP BY DATE(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$customer_data[date('j', strtotime($result['date_added']))] = array(
|
||||
'day' => date('d', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $customer_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomersByYear() {
|
||||
$customer_data = array();
|
||||
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$customer_data[$i] = array(
|
||||
'month' => date('M', mktime(0, 0, 0, $i)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "customer` WHERE YEAR(date_added) = YEAR(NOW()) GROUP BY MONTH(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$customer_data[date('n', strtotime($result['date_added']))] = array(
|
||||
'month' => date('M', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $customer_data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
class ModelExtensionDashboardMap extends Model {
|
||||
public function getTotalOrdersByCountry() {
|
||||
$implode = array();
|
||||
|
||||
if (is_array($this->config->get('config_complete_status'))) {
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = (int)$order_status_id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, SUM(o.total) AS amount, c.iso_code_2 FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "country` c ON (o.payment_country_id = c.country_id) WHERE o.order_status_id IN(" . implode(',', $implode) . ") GROUP BY o.payment_country_id");
|
||||
|
||||
return $query->rows;
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
class ModelExtensionDashboardOnline extends Model {
|
||||
public function getTotalOnline($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_online` co LEFT JOIN " . DB_PREFIX . "customer c ON (co.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_ip'])) {
|
||||
$implode[] = "co.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "co.customer_id > 0 AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,438 @@
|
||||
<?php
|
||||
class ModelExtensionDashboardSale extends Model {
|
||||
public function getTotalSales($data = array()) {
|
||||
$sql = "SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0'";
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalOrdersByCountry() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, SUM(o.total) AS amount, c.iso_code_2 FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "country` c ON (o.payment_country_id = c.country_id) WHERE o.order_status_id > '0' GROUP BY o.payment_country_id");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByDay() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$order_data[$i] = array(
|
||||
'hour' => $i,
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, HOUR(date_added) AS hour FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND DATE(date_added) = DATE(NOW()) GROUP BY HOUR(date_added) ORDER BY date_added ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[$result['hour']] = array(
|
||||
'hour' => $result['hour'],
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByWeek() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
$date_start = strtotime('-' . date('w') . ' days');
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$date = date('Y-m-d', $date_start + ($i * 86400));
|
||||
|
||||
$order_data[date('w', strtotime($date))] = array(
|
||||
'day' => date('D', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND DATE(date_added) >= DATE('" . $this->db->escape(date('Y-m-d', $date_start)) . "') GROUP BY DAYNAME(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[date('w', strtotime($result['date_added']))] = array(
|
||||
'day' => date('D', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByMonth() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
for ($i = 1; $i <= date('t'); $i++) {
|
||||
$date = date('Y') . '-' . date('m') . '-' . $i;
|
||||
|
||||
$order_data[date('j', strtotime($date))] = array(
|
||||
'day' => date('d', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND DATE(date_added) >= '" . $this->db->escape(date('Y') . '-' . date('m') . '-1') . "' GROUP BY DATE(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[date('j', strtotime($result['date_added']))] = array(
|
||||
'day' => date('d', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByYear() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$order_data[$i] = array(
|
||||
'month' => date('M', mktime(0, 0, 0, $i)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND YEAR(date_added) = YEAR(NOW()) GROUP BY MONTH(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[date('n', strtotime($result['date_added']))] = array(
|
||||
'month' => date('M', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getOrders($data = array()) {
|
||||
$sql = "SELECT MIN(o.date_added) AS date_start, MAX(o.date_added) AS date_end, COUNT(*) AS `orders`, SUM((SELECT SUM(op.quantity) FROM `" . DB_PREFIX . "order_product` op WHERE op.order_id = o.order_id GROUP BY op.order_id)) AS products, SUM((SELECT SUM(ot.value) FROM `" . DB_PREFIX . "order_total` ot WHERE ot.order_id = o.order_id AND ot.code = 'tax' GROUP BY ot.order_id)) AS tax, SUM(o.total) AS `total` FROM `" . DB_PREFIX . "order` o";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " WHERE o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added)";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), WEEK(o.date_added)";
|
||||
break;
|
||||
case 'month':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added)";
|
||||
break;
|
||||
case 'year':
|
||||
$sql .= " GROUP BY YEAR(o.date_added)";
|
||||
break;
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY o.date_added DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalOrders($data = array()) {
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added), MONTH(date_added), DAY(date_added)) AS total FROM `" . DB_PREFIX . "order`";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added), WEEK(date_added)) AS total FROM `" . DB_PREFIX . "order`";
|
||||
break;
|
||||
case 'month':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added), MONTH(date_added)) AS total FROM `" . DB_PREFIX . "order`";
|
||||
break;
|
||||
case 'year':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added)) AS total FROM `" . DB_PREFIX . "order`";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " WHERE order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTaxes($data = array()) {
|
||||
$sql = "SELECT MIN(o.date_added) AS date_start, MAX(o.date_added) AS date_end, ot.title, SUM(ot.value) AS total, COUNT(o.order_id) AS `orders` FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "order_total` ot ON (ot.order_id = o.order_id) WHERE ot.code = 'tax'";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added), ot.title";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), WEEK(o.date_added), ot.title";
|
||||
break;
|
||||
case 'month':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), ot.title";
|
||||
break;
|
||||
case 'year':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), ot.title";
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalTaxes($data = array()) {
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), WEEK(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
case 'month':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), MONTH(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
case 'year':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
}
|
||||
|
||||
$sql .= " LEFT JOIN `" . DB_PREFIX . "order_total` ot ON (o.order_id = ot.order_id) WHERE ot.code = 'tax'";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getShipping($data = array()) {
|
||||
$sql = "SELECT MIN(o.date_added) AS date_start, MAX(o.date_added) AS date_end, ot.title, SUM(ot.value) AS total, COUNT(o.order_id) AS `orders` FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "order_total` ot ON (o.order_id = ot.order_id) WHERE ot.code = 'shipping'";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added), ot.title";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), WEEK(o.date_added), ot.title";
|
||||
break;
|
||||
case 'month':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), ot.title";
|
||||
break;
|
||||
case 'year':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), ot.title";
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalShipping($data = array()) {
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), WEEK(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
case 'month':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), MONTH(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
case 'year':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
}
|
||||
|
||||
$sql .= " LEFT JOIN `" . DB_PREFIX . "order_total` ot ON (o.order_id = ot.order_id) WHERE ot.code = 'shipping'";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
class ModelExtensionFeedGoogleBase extends Model {
|
||||
public function install() {
|
||||
$this->db->query("
|
||||
CREATE TABLE `" . DB_PREFIX . "google_base_category` (
|
||||
`google_base_category_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`google_base_category_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
|
||||
");
|
||||
|
||||
$this->db->query("
|
||||
CREATE TABLE `" . DB_PREFIX . "google_base_category_to_category` (
|
||||
`google_base_category_id` INT(11) NOT NULL,
|
||||
`category_id` INT(11) NOT NULL,
|
||||
PRIMARY KEY (`google_base_category_id`, `category_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
|
||||
");
|
||||
}
|
||||
|
||||
public function uninstall() {
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "google_base_category`");
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "google_base_category_to_category`");
|
||||
}
|
||||
|
||||
public function import($string) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "google_base_category");
|
||||
|
||||
$lines = explode("\n", $string);
|
||||
|
||||
foreach ($lines as $line) {
|
||||
if (substr($line, 0, 1) != '#') {
|
||||
$part = explode(' - ', $line, 2);
|
||||
|
||||
if (isset($part[1])) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "google_base_category SET google_base_category_id = '" . (int)$part[0] . "', name = '" . $this->db->escape($part[1]) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getGoogleBaseCategories($data = array()) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "google_base_category` WHERE name LIKE '%" . $this->db->escape($data['filter_name']) . "%' ORDER BY name 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;
|
||||
}
|
||||
|
||||
public function addCategory($data) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "google_base_category_to_category WHERE category_id = '" . (int)$data['category_id'] . "'");
|
||||
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "google_base_category_to_category SET google_base_category_id = '" . (int)$data['google_base_category_id'] . "', category_id = '" . (int)$data['category_id'] . "'");
|
||||
}
|
||||
|
||||
public function deleteCategory($category_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "google_base_category_to_category WHERE category_id = '" . (int)$category_id . "'");
|
||||
}
|
||||
|
||||
public function getCategories($data = array()) {
|
||||
$sql = "SELECT google_base_category_id, (SELECT name FROM `" . DB_PREFIX . "google_base_category` gbc WHERE gbc.google_base_category_id = gbc2c.google_base_category_id) AS google_base_category, category_id, (SELECT name FROM `" . DB_PREFIX . "category_description` cd WHERE cd.category_id = gbc2c.category_id AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS category FROM `" . DB_PREFIX . "google_base_category_to_category` gbc2c ORDER BY google_base_category 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;
|
||||
}
|
||||
|
||||
public function getTotalCategories() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "google_base_category_to_category`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
class ModelExtensionFraudFraudLabsPro extends Model {
|
||||
public function install() {
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "fraudlabspro` (
|
||||
`order_id` VARCHAR(11) NOT NULL,
|
||||
`is_country_match` CHAR(2) NOT NULL,
|
||||
`is_high_risk_country` CHAR(2) NOT NULL,
|
||||
`distance_in_km` VARCHAR(10) NOT NULL,
|
||||
`distance_in_mile` VARCHAR(10) NOT NULL,
|
||||
`ip_address` VARCHAR(15) NOT NULL,
|
||||
`ip_country` VARCHAR(2) NOT NULL,
|
||||
`ip_continent` VARCHAR(20) NOT NULL,
|
||||
`ip_region` VARCHAR(21) NOT NULL,
|
||||
`ip_city` VARCHAR(21) NOT NULL,
|
||||
`ip_latitude` VARCHAR(21) NOT NULL,
|
||||
`ip_longitude` VARCHAR(21) NOT NULL,
|
||||
`ip_timezone` VARCHAR(10) NOT NULL,
|
||||
`ip_elevation` VARCHAR(10) NOT NULL,
|
||||
`ip_domain` VARCHAR(50) NOT NULL,
|
||||
`ip_mobile_mnc` VARCHAR(100) NOT NULL,
|
||||
`ip_mobile_mcc` VARCHAR(100) NOT NULL,
|
||||
`ip_mobile_brand` VARCHAR(100) NOT NULL,
|
||||
`ip_netspeed` VARCHAR(10) NOT NULL,
|
||||
`ip_isp_name` VARCHAR(50) NOT NULL,
|
||||
`ip_usage_type` VARCHAR(30) NOT NULL,
|
||||
`is_free_email` CHAR(2) NOT NULL,
|
||||
`is_new_domain_name` CHAR(2) NOT NULL,
|
||||
`is_proxy_ip_address` CHAR(2) NOT NULL,
|
||||
`is_bin_found` CHAR(2) NOT NULL,
|
||||
`is_bin_country_match` CHAR(2) NOT NULL,
|
||||
`is_bin_name_match` CHAR(2) NOT NULL,
|
||||
`is_bin_phone_match` CHAR(2) NOT NULL,
|
||||
`is_bin_prepaid` CHAR(2) NOT NULL,
|
||||
`is_address_ship_forward` CHAR(2) NOT NULL,
|
||||
`is_bill_ship_city_match` CHAR(2) NOT NULL,
|
||||
`is_bill_ship_state_match` CHAR(2) NOT NULL,
|
||||
`is_bill_ship_country_match` CHAR(2) NOT NULL,
|
||||
`is_bill_ship_postal_match` CHAR(2) NOT NULL,
|
||||
`is_ip_blacklist` CHAR(2) NOT NULL,
|
||||
`is_email_blacklist` CHAR(2) NOT NULL,
|
||||
`is_credit_card_blacklist` CHAR(2) NOT NULL,
|
||||
`is_device_blacklist` CHAR(2) NOT NULL,
|
||||
`is_user_blacklist` CHAR(2) NOT NULL,
|
||||
`fraudlabspro_score` CHAR(3) NOT NULL,
|
||||
`fraudlabspro_distribution` CHAR(3) NOT NULL,
|
||||
`fraudlabspro_status` CHAR(10) NOT NULL,
|
||||
`fraudlabspro_id` CHAR(15) NOT NULL,
|
||||
`fraudlabspro_error` CHAR(3) NOT NULL,
|
||||
`fraudlabspro_message` VARCHAR(50) NOT NULL,
|
||||
`fraudlabspro_credits` VARCHAR(10) NOT NULL,
|
||||
`api_key` CHAR(32) NOT NULL,
|
||||
PRIMARY KEY (`order_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
|
||||
");
|
||||
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_status` (`language_id`, `name`) VALUES (1, 'Fraud');");
|
||||
$status_fraud_id = $this->db->getLastId();
|
||||
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_status` (`language_id`, `name`) VALUES (1, 'Fraud Review');");
|
||||
|
||||
$status_fraud_review_id = $this->db->getLastId();
|
||||
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "setting` (`code`, `key`, `value`, `serialized`) VALUES ('fraudlabspro', 'fraud_fraudlabspro_score', '80', '0');");
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "setting` (`code`, `key`, `value`, `serialized`) VALUES ('fraudlabspro', 'fraud_fraudlabspro_order_status_id', '" . (int)$status_fraud_id . "', '0');");
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "setting` (`code`, `key`, `value`, `serialized`) VALUES ('fraudlabspro', 'fraud_fraudlabspro_review_status_id', '" . (int)$status_fraud_review_id . "', '0');");
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "setting` (`code`, `key`, `value`, `serialized`) VALUES ('fraudlabspro', 'fraud_fraudlabspro_approve_status_id', '2', '0');");
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "setting` (`code`, `key`, `value`, `serialized`) VALUES ('fraudlabspro', 'fraud_fraudlabspro_reject_status_id', '8', '0');");
|
||||
|
||||
$this->cache->delete('order_status.' . (int)$this->config->get('config_language_id'));
|
||||
}
|
||||
|
||||
public function uninstall() {
|
||||
//$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "fraudlabspro`");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "order_status` WHERE `name` = 'Fraud'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "order_status` WHERE `name` = 'Fraud Review'");
|
||||
}
|
||||
|
||||
public function getOrder($order_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "fraudlabspro` WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function addOrderHistory($order_id, $data, $store_id = 0) {
|
||||
$json = array();
|
||||
|
||||
$this->load->model('setting/store');
|
||||
|
||||
$store_info = $this->model_setting_store->getStore($store_id);
|
||||
|
||||
if ($store_info) {
|
||||
$url = $store_info['ssl'];
|
||||
} else {
|
||||
$url = HTTPS_CATALOG;
|
||||
}
|
||||
|
||||
if (isset($this->session->data['cookie'])) {
|
||||
$curl = curl_init();
|
||||
|
||||
// Set SSL if required
|
||||
if (substr($url, 0, 5) == 'https') {
|
||||
curl_setopt($curl, CURLOPT_PORT, 443);
|
||||
}
|
||||
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, $this->request->server['HTTP_USER_AGENT']);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_URL, $url . 'index.php?route=api/order/history&order_id=' . $order_id);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||
curl_setopt($curl, CURLOPT_COOKIE, session_name() . '=' . $this->session->data['cookie'] . ';');
|
||||
|
||||
$json = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class ModelExtensionFraudIp extends Model {
|
||||
public function install() {
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "fraud_ip` (
|
||||
`ip` varchar(40) NOT NULL,
|
||||
`date_added` datetime NOT NULL,
|
||||
PRIMARY KEY (`ip`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
|
||||
");
|
||||
}
|
||||
|
||||
public function uninstall() {
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "fraud_ip`");
|
||||
}
|
||||
|
||||
public function addIp($ip) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "fraud_ip` SET `ip` = '" . $this->db->escape($ip) . "', date_added = NOW()");
|
||||
}
|
||||
|
||||
public function removeIp($ip) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "fraud_ip` WHERE `ip` = '" . $this->db->escape($ip) . "'");
|
||||
}
|
||||
|
||||
public function getIps($start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "fraud_ip` ORDER BY `ip` ASC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalIps() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "fraud_ip`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalIpsByIp($ip) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "fraud_ip` WHERE ip = '" . $this->db->escape($ip) . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
class ModelExtensionFraudMaxMind extends Model {
|
||||
public function install() {
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "maxmind` (
|
||||
`order_id` int(11) NOT NULL,
|
||||
`customer_id` int(11) NOT NULL,
|
||||
`country_match` varchar(3) NOT NULL,
|
||||
`country_code` varchar(2) NOT NULL,
|
||||
`high_risk_country` varchar(3) NOT NULL,
|
||||
`distance` int(11) NOT NULL,
|
||||
`ip_region` varchar(255) NOT NULL,
|
||||
`ip_city` varchar(255) NOT NULL,
|
||||
`ip_latitude` decimal(10,6) NOT NULL,
|
||||
`ip_longitude` decimal(10,6) NOT NULL,
|
||||
`ip_isp` varchar(255) NOT NULL,
|
||||
`ip_org` varchar(255) NOT NULL,
|
||||
`ip_asnum` int(11) NOT NULL,
|
||||
`ip_user_type` varchar(255) NOT NULL,
|
||||
`ip_country_confidence` varchar(3) NOT NULL,
|
||||
`ip_region_confidence` varchar(3) NOT NULL,
|
||||
`ip_city_confidence` varchar(3) NOT NULL,
|
||||
`ip_postal_confidence` varchar(3) NOT NULL,
|
||||
`ip_postal_code` varchar(10) NOT NULL,
|
||||
`ip_accuracy_radius` int(11) NOT NULL,
|
||||
`ip_net_speed_cell` varchar(255) NOT NULL,
|
||||
`ip_metro_code` int(3) NOT NULL,
|
||||
`ip_area_code` int(3) NOT NULL,
|
||||
`ip_time_zone` varchar(255) NOT NULL,
|
||||
`ip_region_name` varchar(255) NOT NULL,
|
||||
`ip_domain` varchar(255) NOT NULL,
|
||||
`ip_country_name` varchar(255) NOT NULL,
|
||||
`ip_continent_code` varchar(2) NOT NULL,
|
||||
`ip_corporate_proxy` varchar(3) NOT NULL,
|
||||
`anonymous_proxy` varchar(3) NOT NULL,
|
||||
`proxy_score` int(3) NOT NULL,
|
||||
`is_trans_proxy` varchar(3) NOT NULL,
|
||||
`free_mail` varchar(3) NOT NULL,
|
||||
`carder_email` varchar(3) NOT NULL,
|
||||
`high_risk_username` varchar(3) NOT NULL,
|
||||
`high_risk_password` varchar(3) NOT NULL,
|
||||
`bin_match` varchar(10) NOT NULL,
|
||||
`bin_country` varchar(2) NOT NULL,
|
||||
`bin_name_match` varchar(3) NOT NULL,
|
||||
`bin_name` varchar(255) NOT NULL,
|
||||
`bin_phone_match` varchar(3) NOT NULL,
|
||||
`bin_phone` varchar(32) NOT NULL,
|
||||
`customer_phone_in_billing_location` varchar(8) NOT NULL,
|
||||
`ship_forward` varchar(3) NOT NULL,
|
||||
`city_postal_match` varchar(3) NOT NULL,
|
||||
`ship_city_postal_match` varchar(3) NOT NULL,
|
||||
`score` decimal(10,5) NOT NULL,
|
||||
`explanation` text NOT NULL,
|
||||
`risk_score` decimal(10,5) NOT NULL,
|
||||
`queries_remaining` int(11) NOT NULL,
|
||||
`maxmind_id` varchar(8) NOT NULL,
|
||||
`error` text NOT NULL,
|
||||
`date_added` datetime NOT NULL,
|
||||
PRIMARY KEY (`order_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
|
||||
");
|
||||
}
|
||||
|
||||
public function uninstall() {
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "maxmind`");
|
||||
}
|
||||
|
||||
public function getOrder($order_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "maxmind` WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
class ModelExtensionModuleOc3xStorageCleaner extends Model {
|
||||
public function getSize() {
|
||||
$dirs = array(
|
||||
'cache-system' => DIR_CACHE,
|
||||
'cache-modification' => DIR_MODIFICATION,
|
||||
'cache-image' => DIR_IMAGE . 'cache/',
|
||||
'log-error' => DIR_LOGS . 'error.log',
|
||||
'log-modification' => DIR_LOGS . 'ocmod.log',
|
||||
);
|
||||
|
||||
foreach ($dirs as $key => $dir) {
|
||||
$sizes[$key] = 0;
|
||||
|
||||
$files = array();
|
||||
|
||||
$path = array($dir . '*');
|
||||
|
||||
while (count($path) != 0) {
|
||||
$next = array_shift($path);
|
||||
|
||||
if (is_array(glob($next))) {
|
||||
foreach (glob($next) as $file) {
|
||||
if (is_dir($file)) {
|
||||
$path[] = $file . '/*';
|
||||
}
|
||||
|
||||
$files[] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($files)) {
|
||||
rsort($files);
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($file != $dir . 'index.html' && $file != $dir . '.htaccess') {
|
||||
if (is_file($file)) {
|
||||
$sizes[$key] += filesize($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($sizes as $key => $size) {
|
||||
$output[$key] = $this->formatSize($size);
|
||||
}
|
||||
|
||||
$output['all'] = $this->formatSize(array_sum($sizes));
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected function formatSize($size) {
|
||||
$sizenames = array(' B', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', 'YB');
|
||||
|
||||
$item = 0;
|
||||
|
||||
while ($size >= 1024) {
|
||||
$size /= 1024;
|
||||
|
||||
$item++;
|
||||
}
|
||||
|
||||
if ($item > 2) {
|
||||
$output = round($size, 2) . $sizenames[$item];
|
||||
} else {
|
||||
$output = round($size, 0) . $sizenames[$item];
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
class ModelExtensionReportActivity extends Model {
|
||||
public function getActivities() {
|
||||
$query = $this->db->query("SELECT a.key, a.data, a.date_added FROM ((SELECT CONCAT('customer_', ca.key) AS `key`, ca.data, ca.date_added FROM `" . DB_PREFIX . "customer_activity` ca) UNION (SELECT CONCAT('affiliate_', aa.key) AS `key`, aa.data, aa.date_added FROM `" . DB_PREFIX . "affiliate_activity` aa)) a ORDER BY a.date_added DESC LIMIT 0,5");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
class ModelExtensionReportCoupon extends Model {
|
||||
public function getCoupons($data = array()) {
|
||||
$sql = "SELECT ch.coupon_id, c.name, c.code, COUNT(DISTINCT ch.order_id) AS `orders`, SUM(ch.amount) AS total FROM `" . DB_PREFIX . "coupon_history` ch LEFT JOIN `" . DB_PREFIX . "coupon` c ON (ch.coupon_id = c.coupon_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$implode[] = "DATE(ch.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$implode[] = "DATE(ch.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY ch.coupon_id ORDER BY total DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalCoupons($data = array()) {
|
||||
$sql = "SELECT COUNT(DISTINCT coupon_id) AS total FROM `" . DB_PREFIX . "coupon_history`";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$implode[] = "DATE(date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$implode[] = "DATE(date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
<?php
|
||||
class ModelExtensionReportCustomer extends Model {
|
||||
public function getTotalCustomersByDay() {
|
||||
$customer_data = array();
|
||||
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$customer_data[$i] = array(
|
||||
'hour' => $i,
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, HOUR(date_added) AS hour FROM `" . DB_PREFIX . "customer` WHERE DATE(date_added) = DATE(NOW()) GROUP BY HOUR(date_added) ORDER BY date_added ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$customer_data[$result['hour']] = array(
|
||||
'hour' => $result['hour'],
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $customer_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomersByWeek() {
|
||||
$customer_data = array();
|
||||
|
||||
$date_start = strtotime('-' . date('w') . ' days');
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$date = date('Y-m-d', $date_start + ($i * 86400));
|
||||
|
||||
$customer_data[date('w', strtotime($date))] = array(
|
||||
'day' => date('D', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "customer` WHERE DATE(date_added) >= DATE('" . $this->db->escape(date('Y-m-d', $date_start)) . "') GROUP BY DAYNAME(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$customer_data[date('w', strtotime($result['date_added']))] = array(
|
||||
'day' => date('D', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $customer_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomersByMonth() {
|
||||
$customer_data = array();
|
||||
|
||||
for ($i = 1; $i <= date('t'); $i++) {
|
||||
$date = date('Y') . '-' . date('m') . '-' . $i;
|
||||
|
||||
$customer_data[date('j', strtotime($date))] = array(
|
||||
'day' => date('d', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "customer` WHERE DATE(date_added) >= '" . $this->db->escape(date('Y') . '-' . date('m') . '-1') . "' GROUP BY DATE(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$customer_data[date('j', strtotime($result['date_added']))] = array(
|
||||
'day' => date('d', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $customer_data;
|
||||
}
|
||||
|
||||
public function getTotalCustomersByYear() {
|
||||
$customer_data = array();
|
||||
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$customer_data[$i] = array(
|
||||
'month' => date('M', mktime(0, 0, 0, $i)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "customer` WHERE YEAR(date_added) = YEAR(NOW()) GROUP BY MONTH(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$customer_data[date('n', strtotime($result['date_added']))] = array(
|
||||
'month' => date('M', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $customer_data;
|
||||
}
|
||||
|
||||
public function getOrders($data = array()) {
|
||||
$sql = "SELECT c.customer_id, CONCAT(c.firstname, ' ', c.lastname) AS customer, c.email, cgd.name AS customer_group, c.status, o.order_id, SUM(op.quantity) as products, o.total AS total FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "order_product` op ON (o.order_id = op.order_id) LEFT JOIN `" . DB_PREFIX . "customer` c ON (o.customer_id = c.customer_id) LEFT JOIN `" . DB_PREFIX . "customer_group_description` cgd ON (c.customer_group_id = cgd.customer_group_id) WHERE o.customer_id > 0 AND cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$sql .= " AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY o.order_id";
|
||||
|
||||
$sql = "SELECT t.customer_id, t.customer, t.email, t.customer_group, t.status, COUNT(DISTINCT t.order_id) AS orders, SUM(t.products) AS products, SUM(t.total) AS total FROM (" . $sql . ") AS t GROUP BY t.customer_id ORDER BY total DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalOrders($data = array()) {
|
||||
$sql = "SELECT COUNT(DISTINCT o.customer_id) AS total FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "customer` c ON (o.customer_id = c.customer_id) WHERE o.customer_id > '0'";
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$sql .= " AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getRewardPoints($data = array()) {
|
||||
$sql = "SELECT cr.customer_id, CONCAT(c.firstname, ' ', c.lastname) AS customer, c.email, cgd.name AS customer_group, c.status, SUM(cr.points) AS points, COUNT(o.order_id) AS orders, SUM(o.total) AS total FROM " . DB_PREFIX . "customer_reward cr LEFT JOIN `" . DB_PREFIX . "customer` c ON (cr.customer_id = c.customer_id) LEFT JOIN " . DB_PREFIX . "customer_group_description cgd ON (c.customer_group_id = cgd.customer_group_id) LEFT JOIN `" . DB_PREFIX . "order` o ON (cr.order_id = o.order_id) WHERE cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(cr.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(cr.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$sql .= " AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY cr.customer_id ORDER BY points DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalRewardPoints($data = array()) {
|
||||
$sql = "SELECT COUNT(DISTINCT cr.customer_id) AS total FROM `" . DB_PREFIX . "customer_reward` cr LEFT JOIN `" . DB_PREFIX . "customer` c ON (cr.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$implode[] = "DATE(cr.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$implode[] = "DATE(cr.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getCustomerActivities($data = array()) {
|
||||
$sql = "SELECT ca.customer_activity_id, ca.customer_id, ca.key, ca.data, ca.ip, ca.date_added FROM " . DB_PREFIX . "customer_activity ca LEFT JOIN " . DB_PREFIX . "customer c ON (ca.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$implode[] = "DATE(ca.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$implode[] = "DATE(ca.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_ip'])) {
|
||||
$implode[] = "ca.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY ca.date_added DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalCustomerActivities($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_activity` ca LEFT JOIN " . DB_PREFIX . "customer c ON (ca.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$implode[] = "DATE(ca.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$implode[] = "DATE(ca.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_ip'])) {
|
||||
$implode[] = "ca.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getCustomerSearches($data = array()) {
|
||||
$sql = "SELECT cs.customer_id, cs.keyword, cs.category_id, cs.products, cs.ip, cs.date_added, CONCAT(c.firstname, ' ', c.lastname) AS customer FROM " . DB_PREFIX . "customer_search cs LEFT JOIN " . DB_PREFIX . "customer c ON (cs.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$implode[] = "DATE(cs.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$implode[] = "DATE(cs.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_keyword'])) {
|
||||
$implode[] = "cs.keyword LIKE '" . $this->db->escape($data['filter_keyword']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_ip'])) {
|
||||
$implode[] = "cs.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY cs.date_added DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalCustomerSearches($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_search` cs LEFT JOIN " . DB_PREFIX . "customer c ON (cs.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$implode[] = "DATE(cs.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$implode[] = "DATE(cs.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_keyword'])) {
|
||||
$implode[] = "cs.keyword LIKE '" . $this->db->escape($data['filter_keyword']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_ip'])) {
|
||||
$implode[] = "cs.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
class ModelExtensionReportCustomerTransaction extends Model {
|
||||
public function getTransactions($data = array()) {
|
||||
$sql = "SELECT ct.customer_id, CONCAT(c.firstname, ' ', c.lastname) AS customer, c.email, cgd.name AS customer_group, c.status, SUM(ct.amount) AS total FROM `" . DB_PREFIX . "customer_transaction` ct LEFT JOIN `" . DB_PREFIX . "customer` c ON (ct.customer_id = c.customer_id) LEFT JOIN `" . DB_PREFIX . "customer_group_description` cgd ON (c.customer_group_id = cgd.customer_group_id) WHERE cgd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(ct.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(ct.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$sql .= " AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY ct.customer_id ORDER BY total DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalTransactions($data = array()) {
|
||||
$sql = "SELECT COUNT(DISTINCT ct.customer_id) AS total FROM `" . DB_PREFIX . "customer_transaction` ct LEFT JOIN `" . DB_PREFIX . "customer` c ON (ct.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$implode[] = "DATE(ct.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$implode[] = "DATE(ct.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
class ModelExtensionReportMarketing extends Model {
|
||||
public function getMarketing($data = array()) {
|
||||
$sql = "SELECT m.marketing_id, m.name AS campaign, m.code, m.clicks AS clicks, (SELECT COUNT(DISTINCT order_id) FROM `" . DB_PREFIX . "order` o1 WHERE o1.marketing_id = m.marketing_id";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o1.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o1.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o1.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o1.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$sql .= ") AS `orders`, (SELECT SUM(total) FROM `" . DB_PREFIX . "order` o2 WHERE o2.marketing_id = m.marketing_id";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o2.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o2.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o2.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o2.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY o2.marketing_id) AS `total` FROM `" . DB_PREFIX . "marketing` m ORDER BY m.date_added 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;
|
||||
}
|
||||
|
||||
public function getTotalMarketing($data = array()) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "marketing`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
class ModelExtensionReportProduct extends Model {
|
||||
public function getProductsViewed($data = array()) {
|
||||
$sql = "SELECT pd.name, p.model, p.viewed FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.viewed > 0 ORDER BY p.viewed DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalProductViews() {
|
||||
$query = $this->db->query("SELECT SUM(viewed) AS total FROM " . DB_PREFIX . "product");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalProductsViewed() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "product WHERE viewed > 0");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function reset() {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "product SET viewed = '0'");
|
||||
}
|
||||
|
||||
public function getPurchased($data = array()) {
|
||||
$sql = "SELECT op.name, op.model, SUM(op.quantity) AS quantity, SUM((op.price + op.tax) * op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id)";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " WHERE o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY op.product_id ORDER BY total DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalPurchased($data) {
|
||||
$sql = "SELECT COUNT(DISTINCT op.product_id) AS total FROM `" . DB_PREFIX . "order_product` op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id)";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " WHERE o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
class ModelExtensionReportReturn extends Model {
|
||||
public function getReturns($data = array()) {
|
||||
$sql = "SELECT MIN(r.date_added) AS date_start, MAX(r.date_added) AS date_end, COUNT(r.return_id) AS `returns` FROM `" . DB_PREFIX . "return` r";
|
||||
|
||||
if (!empty($data['filter_return_status_id'])) {
|
||||
$sql .= " WHERE r.return_status_id = '" . (int)$data['filter_return_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE r.return_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(r.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(r.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql .= " GROUP BY YEAR(r.date_added), MONTH(r.date_added), DAY(r.date_added)";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql .= " GROUP BY YEAR(r.date_added), WEEK(r.date_added)";
|
||||
break;
|
||||
case 'month':
|
||||
$sql .= " GROUP BY YEAR(r.date_added), MONTH(r.date_added)";
|
||||
break;
|
||||
case 'year':
|
||||
$sql .= " GROUP BY YEAR(r.date_added)";
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalReturns($data = array()) {
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added), MONTH(date_added), DAY(date_added)) AS total FROM `" . DB_PREFIX . "return`";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added), WEEK(date_added)) AS total FROM `" . DB_PREFIX . "return`";
|
||||
break;
|
||||
case 'month':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added), MONTH(date_added)) AS total FROM `" . DB_PREFIX . "return`";
|
||||
break;
|
||||
case 'year':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added)) AS total FROM `" . DB_PREFIX . "return`";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($data['filter_return_status_id'])) {
|
||||
$sql .= " WHERE return_status_id = '" . (int)$data['filter_return_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE return_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,438 @@
|
||||
<?php
|
||||
class ModelExtensionReportSale extends Model {
|
||||
public function getTotalSales($data = array()) {
|
||||
$sql = "SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0'";
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalOrdersByCountry() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, SUM(o.total) AS amount, c.iso_code_2 FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "country` c ON (o.payment_country_id = c.country_id) WHERE o.order_status_id > '0' GROUP BY o.payment_country_id");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByDay() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
$order_data[$i] = array(
|
||||
'hour' => $i,
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, HOUR(date_added) AS hour FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND DATE(date_added) = DATE(NOW()) GROUP BY HOUR(date_added) ORDER BY date_added ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[$result['hour']] = array(
|
||||
'hour' => $result['hour'],
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByWeek() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
$date_start = strtotime('-' . date('w') . ' days');
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$date = date('Y-m-d', $date_start + ($i * 86400));
|
||||
|
||||
$order_data[date('w', strtotime($date))] = array(
|
||||
'day' => date('D', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND DATE(date_added) >= DATE('" . $this->db->escape(date('Y-m-d', $date_start)) . "') GROUP BY DAYNAME(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[date('w', strtotime($result['date_added']))] = array(
|
||||
'day' => date('D', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByMonth() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
for ($i = 1; $i <= date('t'); $i++) {
|
||||
$date = date('Y') . '-' . date('m') . '-' . $i;
|
||||
|
||||
$order_data[date('j', strtotime($date))] = array(
|
||||
'day' => date('d', strtotime($date)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND DATE(date_added) >= '" . $this->db->escape(date('Y') . '-' . date('m') . '-1') . "' GROUP BY DATE(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[date('j', strtotime($result['date_added']))] = array(
|
||||
'day' => date('d', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getTotalOrdersByYear() {
|
||||
$implode = array();
|
||||
|
||||
foreach ($this->config->get('config_complete_status') as $order_status_id) {
|
||||
$implode[] = "'" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$order_data = array();
|
||||
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$order_data[$i] = array(
|
||||
'month' => date('M', mktime(0, 0, 0, $i)),
|
||||
'total' => 0
|
||||
);
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total, date_added FROM `" . DB_PREFIX . "order` WHERE order_status_id IN(" . implode(",", $implode) . ") AND YEAR(date_added) = YEAR(NOW()) GROUP BY MONTH(date_added)");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_data[date('n', strtotime($result['date_added']))] = array(
|
||||
'month' => date('M', strtotime($result['date_added'])),
|
||||
'total' => $result['total']
|
||||
);
|
||||
}
|
||||
|
||||
return $order_data;
|
||||
}
|
||||
|
||||
public function getOrders($data = array()) {
|
||||
$sql = "SELECT MIN(o.date_added) AS date_start, MAX(o.date_added) AS date_end, COUNT(*) AS `orders`, SUM((SELECT SUM(op.quantity) FROM `" . DB_PREFIX . "order_product` op WHERE op.order_id = o.order_id GROUP BY op.order_id)) AS products, SUM((SELECT SUM(ot.value) FROM `" . DB_PREFIX . "order_total` ot WHERE ot.order_id = o.order_id AND ot.code = 'tax' GROUP BY ot.order_id)) AS tax, SUM(o.total) AS `total` FROM `" . DB_PREFIX . "order` o";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " WHERE o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added)";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), WEEK(o.date_added)";
|
||||
break;
|
||||
case 'month':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added)";
|
||||
break;
|
||||
case 'year':
|
||||
$sql .= " GROUP BY YEAR(o.date_added)";
|
||||
break;
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY o.date_added DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalOrders($data = array()) {
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added), MONTH(date_added), DAY(date_added)) AS total FROM `" . DB_PREFIX . "order`";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added), WEEK(date_added)) AS total FROM `" . DB_PREFIX . "order`";
|
||||
break;
|
||||
case 'month':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added), MONTH(date_added)) AS total FROM `" . DB_PREFIX . "order`";
|
||||
break;
|
||||
case 'year':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(date_added)) AS total FROM `" . DB_PREFIX . "order`";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " WHERE order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTaxes($data = array()) {
|
||||
$sql = "SELECT MIN(o.date_added) AS date_start, MAX(o.date_added) AS date_end, ot.title, SUM(ot.value) AS total, COUNT(o.order_id) AS `orders` FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "order_total` ot ON (ot.order_id = o.order_id) WHERE ot.code = 'tax'";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added), ot.title";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), WEEK(o.date_added), ot.title";
|
||||
break;
|
||||
case 'month':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), ot.title";
|
||||
break;
|
||||
case 'year':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), ot.title";
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalTaxes($data = array()) {
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), WEEK(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
case 'month':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), MONTH(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
case 'year':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
}
|
||||
|
||||
$sql .= " LEFT JOIN `" . DB_PREFIX . "order_total` ot ON (o.order_id = ot.order_id) WHERE ot.code = 'tax'";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getShipping($data = array()) {
|
||||
$sql = "SELECT MIN(o.date_added) AS date_start, MAX(o.date_added) AS date_end, ot.title, SUM(ot.value) AS total, COUNT(o.order_id) AS `orders` FROM `" . DB_PREFIX . "order` o LEFT JOIN `" . DB_PREFIX . "order_total` ot ON (o.order_id = ot.order_id) WHERE ot.code = 'shipping'";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added), ot.title";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), WEEK(o.date_added), ot.title";
|
||||
break;
|
||||
case 'month':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), MONTH(o.date_added), ot.title";
|
||||
break;
|
||||
case 'year':
|
||||
$sql .= " GROUP BY YEAR(o.date_added), ot.title";
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalShipping($data = array()) {
|
||||
if (!empty($data['filter_group'])) {
|
||||
$group = $data['filter_group'];
|
||||
} else {
|
||||
$group = 'week';
|
||||
}
|
||||
|
||||
switch($group) {
|
||||
case 'day';
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), MONTH(o.date_added), DAY(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
default:
|
||||
case 'week':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), WEEK(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
case 'month':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), MONTH(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
case 'year':
|
||||
$sql = "SELECT COUNT(DISTINCT YEAR(o.date_added), ot.title) AS total FROM `" . DB_PREFIX . "order` o";
|
||||
break;
|
||||
}
|
||||
|
||||
$sql .= " LEFT JOIN `" . DB_PREFIX . "order_total` ot ON (o.order_id = ot.order_id) WHERE ot.code = 'shipping'";
|
||||
|
||||
if (!empty($data['filter_order_status_id'])) {
|
||||
$sql .= " AND order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " AND order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_start'])) {
|
||||
$sql .= " AND DATE(o.date_added) >= '" . $this->db->escape($data['filter_date_start']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_end'])) {
|
||||
$sql .= " AND DATE(o.date_added) <= '" . $this->db->escape($data['filter_date_end']) . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
class ModelExtensionThemeCallback extends Model {
|
||||
|
||||
public function editCallback($callback_id,$data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "callback SET comment = '" . $this->db->escape($data['comment']) . "', status_id = '" . (int)$data['status_id'] . "', date_modified = NOW() WHERE call_id = '" . (int)$callback_id . "'");
|
||||
}
|
||||
|
||||
|
||||
public function editCallbacks($callback_id) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "callback SET status_id = '1', date_modified = NOW() WHERE call_id = '" . (int)$callback_id . "'");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function deleteCallback($callback_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "callback WHERE call_id = '" . (int)$callback_id . "'");
|
||||
|
||||
|
||||
$this->cache->delete('callback');
|
||||
}
|
||||
|
||||
public function getCallback($callback_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "callback WHERE call_id = '" . (int)$callback_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCallbackNew() {
|
||||
$query = $this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "callback (call_id int(11) NOT NULL
|
||||
primary key AUTO_INCREMENT,name varchar(30) NOT NULL,telephone varchar(30) NOT NULL,
|
||||
date_added datetime NOT NULL,date_modified datetime NOT NULL,
|
||||
status_id int(11) NOT NULL,comment text NOT NULL)");
|
||||
$query = $this->db->query("SELECT COUNT(status_id) as total FROM " . DB_PREFIX . "callback WHERE status_id = '0'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCallbacks($data = array()) {
|
||||
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "callback";
|
||||
|
||||
$sort_data = array(
|
||||
'call_id',
|
||||
'name',
|
||||
'telephone'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY call_id";
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
$callback_data = $this->cache->get('callback');
|
||||
|
||||
if (!$callback_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "callback ORDER BY call_id");
|
||||
|
||||
$callback_data = $query->rows;
|
||||
|
||||
$this->cache->set('callback', $callback_data);
|
||||
}
|
||||
|
||||
return $callback_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getManufacturerStores($manufacturer_id) {
|
||||
$manufacturer_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "manufacturer_to_store WHERE manufacturer_id = '" . (int)$manufacturer_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$manufacturer_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $manufacturer_store_data;
|
||||
}
|
||||
|
||||
public function getTotalManufacturersByImageId($image_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "manufacturer WHERE image_id = '" . (int)$image_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalCallbacks() {
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "callback");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,805 @@
|
||||
HR+cPzTDtfw6VoFHBo9BlHGdatliWEaBSQRkTwd8XXdT+jKSpPP0JYjcIK/Z9ME6DHlpHznVET+j
|
||||
WtwHPj31veSQ23bksLANsjQpIajmhmW0A2Vw6ectzk+FGBCQBFZtrtC3ywmb7j83sPVwBveXPQ0b
|
||||
ccblokZDK9mfhPSfge24jbt7WGiqncrPC6+zXKPYDzonZzhmLHk4bMa6XUs52Z0FCAOCBexnqJ6t
|
||||
vWT0zTaFL2dj0VZyDYdvDu9vFu9xelsubbT0xzlucB1W1dt+4nLZeG2UPA+OgL9fzNH1dvcKSSvt
|
||||
HMcqS3eIynJBBeYSXzYdkH6I0sFWZ7e6wzg2lVantSwAIxGoCAsuiiIt56yWV9U/bjcry2l26F8f
|
||||
M1l0jUeRG49stlD9pax1KWw3aRL4KTI446roZd7jraoQqVqaxzWFexVA0uQmLT0zhCC8svGnckUo
|
||||
vrX9EwE3ys5qKX62f5Nj8iZSK2xPjt6ElnzVe+h0Kcqj5pBJ8wKXXTepX0dqnmTQc2319v+iVv7V
|
||||
SPhDKqn+IoEzNKxLB+7CUyLq+AYCiFglGpjoCvCSa9fM83FYLgillxUHrUYriDpkbYLP4U/mAnpS
|
||||
zokBg3MHJFvaXXc1yq4c7fY2CEeXnuyobpYVTljiZ0UWlS/fYXBKe9QcO42PG9vhDAtqsVaZY3MI
|
||||
dK6ViqhE6/2khcPMWajyICON2jIF4oXqFZyPl3K6DLxKf/icKy/M0A8R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0EX8hSvRRD4f5OTXzYQ/8EK3t2rv1bOz/MsEn43XlbWSRhc1jQbti0LX5ioUJMzBSHT
|
||||
9HBVlwJ0BV10UNBXNbbTthWtetydPm3/fFALx2TfOFUIBm76fukQSDwZ+ktlIuCY48xTSD1sKc2k
|
||||
L4gfxyqtfDyzqO+0tRr9JEBGTD5F+AQ34X3MllEz77PrSLpfea56ly3t3IMo3gkArFi+YRD7Lwyt
|
||||
GMc/BrYYXmajs0LCqfJhUB3eENuA0oW8X8iRaeVkT+/illm+QFY6qbWFfF/xEUD6+27NMpgWx8JG
|
||||
IOHzxjB5A26cealB7SFq/8cRwCjzmUocADWBT544ShUSBYhp4K620MOFtv2a/PAAne3/6KMNyowL
|
||||
YkHxhhiRpPqIxIH1f0hi6UN3oWuWPyh0raxB6PrBmD6+AoXRsKZ6dIz2Lhscjnsh+Mv2MWn2Zvqn
|
||||
d7cOOYtLzYsQALA3XcAnD49nhiTfRSE0obtYFyOc2z04MP65osmEt8Z/R9h297cUCzQ54OefejuP
|
||||
gliZw+jwjfumhZ+vpNGczONFzER4VFisXNjX22rArxIYjDYTz271rInT+ttIrOnyXTtDhqOfMTvt
|
||||
8cEz2B1QXSogZupKyOEIrJeD2EQGDUl/oToWltQI571k5xtx2ngIdUXUhcV8XLvrp2tP3VZMV9Yt
|
||||
GCnjS28tgADRa8qg/U0vXsAKj9+SjyTKabti8rPDmhPOTDQNEMXee5nltisQE59GSpDQLh2Cob1/
|
||||
lzKb7OHEfpk5Ud3aghuPP46v7mD8ch13kP7hBIC9/qcu/7175Dkq2Ahr9fmSWApSyixM1uxBcwmb
|
||||
WwUu6YRbbwR8PecE0oaTNvAsDWymd7FC07cxNg7PEnWG594kNOdzKkqucPdzrusDy7NYkSDCpv41
|
||||
V8pbhpNmryZxKzjXpAG65b4CoQMPyuvZzW5EcpvjKXFbsc9R93umuiyE7DzHVa6XqO5ngxFUjpJu
|
||||
TOCixW+pfNXF707iOpl8Twa+yomIs+64u9B5PFnq7XnIK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5ytDiGDuW1vROV4mI9z
|
||||
lFi+jXifdu44Ewcnnhkjdgt9WbTN856nqeF3TIMSfHmLs9wuo2PVbh9kSuDuukiSgWnqxCDqzEqg
|
||||
zWq15k64Y7Y+zZJLZ5o46l9zp5cgP6mbWhqerIilLHHucr+Kwcqtuo+dmtiKRjvOixG9lJk25uxZ
|
||||
ELmV+GuTSm5zihe4qL3SNNUOPqhmuHmn34TWt1zoxhURNekrLbIGgo1ugK5MBwpQBfdt1LE36z3+
|
||||
JZlwv5/FRBnL0cNpoSLGnLYTXe/aLApnRdkSee9QBWaD5yDfIMua+V5HuWIEK2HUvhoCqGCZ46dO
|
||||
VlxSESnmu6K2/x2rte9CfVtcQ8bVXWaEUodrnhhKDBQ3ypqt/8APRGJ2e5cWeI881dWgCq35n66j
|
||||
bkk3zLyLNXD2IejavBOWTrQWwsIjl5dNS4JzGowJ8+UrvUEoKOSvoB9wTixAQZsyf/pOkecglKKI
|
||||
xTdixIC0RdqtyalTuSB7Th21h7DBiT0vAprnf4Yt8oK+7ikWWphDqQFxCHAUo0GoQ4pOKUg5GjVG
|
||||
dUIk/54PZ88XG5UD32vN9kgWq0Q5mTGwQNpMFMDx3YrBO/10hrWdXpJnQmwoMspuSsWXlQSTVDpg
|
||||
3zV6nMNaQROCPhsQs8DYXCM9siDAv0CYy/ai8dVm6vqCaQTq9rj7vuwNIHZGRHBAkkrYTEjXKm7S
|
||||
mCCLqQRI1ctmf9D4qLAau/8Nm1RV1pid/+GlGRnLxaKNy9nPD8d7QDgKpGHhVrN7XnyHyqweWTE+
|
||||
x0==
|
||||
@@ -0,0 +1,413 @@
|
||||
<?php
|
||||
class ModelExtensionThemeLightshopBlog extends Model {
|
||||
public function addBlog($data) {
|
||||
if($data['date_added']){
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog SET sort_order = 0, bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "'");
|
||||
}else{
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog SET sort_order = 0, bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "', date_added = NOW()");
|
||||
}
|
||||
$blog_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "lightshop_blog SET image = '" . $this->db->escape($data['image']) . "' WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
}
|
||||
|
||||
foreach ($data['blog_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_description SET blog_id = '" . (int)$blog_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
if($value['tag']){
|
||||
foreach (explode(',',$value['tag']) as $tag) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_tag SET blog_id = '" . (int)$blog_id . "', language_id = '" . (int)$language_id . "', tag = '" . $this->db->escape(trim($tag)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['blog_store'])) {
|
||||
foreach ($data['blog_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_to_store SET blog_id = '" . (int)$blog_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['blog_related'])) {
|
||||
foreach ($data['blog_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_related WHERE blog_id = '" . (int)$blog_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_related SET blog_id = '" . (int)$blog_id . "', related_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_related_prod WHERE blog_id = '" . (int)$blog_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_related_prod SET blog_id = '" . (int)$blog_id . "', related_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['blog_layout'])) {
|
||||
foreach ($data['blog_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_to_layout SET blog_id = '" . (int)$blog_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
if (isset($data['blog_seo_url'])) {
|
||||
foreach ($data['blog_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'blog_id=" . (int)$blog_id . "', keyword = '" . $this->db->escape($keyword) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['main_category_id']) && $data['main_category_id'] > 0) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_to_category WHERE blog_id = '" . (int)$blog_id . "' AND category_id = '" . (int)$data['main_category_id'] . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_to_category SET blog_id = '" . (int)$blog_id . "', category_id = '" . (int)$data['main_category_id'] . "', main_category = 1");
|
||||
}
|
||||
|
||||
$this->cache->delete('blog');
|
||||
|
||||
return $blog_id;
|
||||
}
|
||||
|
||||
public function editBlog($blog_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "lightshop_blog SET sort_order = 0, bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "' WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "lightshop_blog SET image = '" . $this->db->escape($data['image']) . "' WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_description WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_tag WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
foreach ($data['blog_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_description SET blog_id = '" . (int)$blog_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
if($value['tag']){
|
||||
foreach (explode(',',$value['tag']) as $tag) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_tag SET blog_id = '" . (int)$blog_id . "', language_id = '" . (int)$language_id . "', tag = '" . $this->db->escape(trim($tag)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_to_store WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
if (isset($data['blog_store'])) {
|
||||
foreach ($data['blog_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_to_store SET blog_id = '" . (int)$blog_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_to_layout WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
if (isset($data['blog_layout'])) {
|
||||
foreach ($data['blog_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_to_layout SET blog_id = '" . (int)$blog_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_related WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
|
||||
if (isset($data['blog_related'])) {
|
||||
foreach ($data['blog_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_related WHERE blog_id = '" . (int)$blog_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_related SET blog_id = '" . (int)$blog_id . "', related_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_related_prod WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_related_prod WHERE blog_id = '" . (int)$blog_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_related_prod SET blog_id = '" . (int)$blog_id . "', related_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'blog_id=" . (int)$blog_id . "'");
|
||||
|
||||
// SEO URL
|
||||
if (isset($data['blog_seo_url'])) {
|
||||
foreach ($data['blog_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'blog_id=" . (int)$blog_id . "', keyword = '" . $this->db->escape($keyword) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_to_category WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
if(isset($data['main_category_id']) && $data['main_category_id'] > 0) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_to_category SET blog_id = '" . (int)$blog_id . "', category_id = '" . (int)$data['main_category_id'] . "', main_category = 1");
|
||||
}
|
||||
|
||||
$this->cache->delete('blog');
|
||||
}
|
||||
|
||||
public function deleteBlog($blog_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_description WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_to_store WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_to_category WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_to_layout WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'blog_id=" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_related WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_tag WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_related WHERE related_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_related_prod WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_comment WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
$this->cache->delete('blog');
|
||||
}
|
||||
|
||||
public function getBlog($blog_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT *, (SELECT keyword FROM " . DB_PREFIX . "seo_url WHERE query = 'blog_id=" . (int)$blog_id . "' LIMIT 1) AS keyword FROM " . DB_PREFIX . "lightshop_blog i LEFT JOIN " . DB_PREFIX . "lightshop_blog_description id ON (i.blog_id = id.blog_id) WHERE i.blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getBlogTag($blog_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_tag WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getBlogSeoUrls($blog_id) {
|
||||
$blog_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'blog_id=" . (int)$blog_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$blog_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
|
||||
return $blog_seo_url_data;
|
||||
}
|
||||
|
||||
public function getBlogs($data = array()) {
|
||||
|
||||
$this->createTable();
|
||||
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "lightshop_blog i LEFT JOIN " . DB_PREFIX . "lightshop_blog_description id ON (i.blog_id = id.blog_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND id.title LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'id.title',
|
||||
'i.sort_order',
|
||||
'i.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY i.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;
|
||||
} else {
|
||||
$blog_data = $this->cache->get('blog.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$blog_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog i LEFT JOIN " . DB_PREFIX . "lightshop_blog_description id ON (i.blog_id = id.blog_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY id.title");
|
||||
|
||||
$blog_data = $query->rows;
|
||||
|
||||
$this->cache->set('blog.' . (int)$this->config->get('config_language_id'), $blog_data);
|
||||
}
|
||||
|
||||
return $blog_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlogDescriptions($blog_id) {
|
||||
$blog_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_description WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
|
||||
$tag = '';
|
||||
$temp = array();
|
||||
$query1 = $this->db->query("SELECT tag FROM " . DB_PREFIX . "lightshop_blog_tag WHERE blog_id = '" . (int)$blog_id . "' AND language_id = '" . (int)$result['language_id'] . "'");
|
||||
|
||||
if($query1->num_rows){
|
||||
foreach ($query1->rows as $value) {
|
||||
$temp[] = $value['tag'];
|
||||
}
|
||||
$tag = implode(',', $temp);
|
||||
}
|
||||
|
||||
$blog_description_data[$result['language_id']] = array(
|
||||
'title' => $result['title'],
|
||||
'description' => $result['description'],
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword'],
|
||||
'tag' => $tag
|
||||
);
|
||||
}
|
||||
|
||||
return $blog_description_data;
|
||||
}
|
||||
|
||||
public function getBlogStores($blog_id) {
|
||||
$blog_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_to_store WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$blog_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $blog_store_data;
|
||||
}
|
||||
|
||||
public function getBlogLayouts($blog_id) {
|
||||
$blog_layout_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_to_layout WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$blog_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
|
||||
return $blog_layout_data;
|
||||
}
|
||||
|
||||
public function getTotalBlogs() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalBlogsByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getBlogRelated($blog_id) {
|
||||
$blog_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_related WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$blog_related_data[] = $result['related_id'];
|
||||
}
|
||||
|
||||
return $blog_related_data;
|
||||
}
|
||||
|
||||
public function getBlogRelatedProds($blog_id) {
|
||||
$product_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_blog_related_prod WHERE blog_id = '" . (int)$blog_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_related_data[] = $result['related_id'];
|
||||
}
|
||||
|
||||
return $product_related_data;
|
||||
}
|
||||
|
||||
public function getBlogMainCategoryId($blog_id) {
|
||||
$query = $this->db->query("SELECT category_id FROM " . DB_PREFIX . "lightshop_blog_to_category WHERE blog_id = '" . (int)$blog_id . "' AND main_category = '1' LIMIT 1");
|
||||
|
||||
return ($query->num_rows ? (int)$query->row['category_id'] : 0);
|
||||
}
|
||||
|
||||
public function getCommentNewCount() {
|
||||
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_blog_comment (
|
||||
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`blog_id` int(11) NOT NULL,
|
||||
`customer_id` int(11) NOT NULL,
|
||||
`author` varchar(64) NOT NULL,
|
||||
`text` text NOT NULL,
|
||||
`rating` int(1) NOT NULL,
|
||||
`status` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`date_added` datetime NOT NULL,
|
||||
`date_modified` datetime NOT NULL,
|
||||
PRIMARY KEY (`comment_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(status) as total FROM " . DB_PREFIX . "lightshop_blog_comment WHERE status = '0'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function createTable() {
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_blog (
|
||||
`blog_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`bottom` int(1) NOT NULL DEFAULT '0',
|
||||
`sort_order` int(3) NOT NULL DEFAULT '0',
|
||||
`status` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`date_added` date NOT NULL,
|
||||
PRIMARY KEY (`blog_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_blog_description (
|
||||
`blog_id` int(11) NOT NULL,
|
||||
`language_id` int(11) NOT NULL,
|
||||
`title` varchar(200) NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`meta_title` varchar(255) NOT NULL,
|
||||
`meta_h1` varchar(255) NOT NULL,
|
||||
`meta_description` varchar(255) NOT NULL,
|
||||
`meta_keyword` varchar(255) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_blog_to_layout (
|
||||
`blog_id` int(11) NOT NULL,
|
||||
`store_id` int(11) NOT NULL,
|
||||
`layout_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`blog_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_blog_to_store (
|
||||
`blog_id` int(11) NOT NULL,
|
||||
`store_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`blog_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_blog_related (
|
||||
`news_id` int(11) NOT NULL,
|
||||
`related_id` int(11) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
class ModelExtensionThemeLightshopblogReview extends Model {
|
||||
public function addReview($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_blog_comment SET author = '" . $this->db->escape($data['author']) . "', blog_id = '" . (int)$data['blog_id'] . "', text = '" . $this->db->escape(strip_tags($data['text'])) . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "'");
|
||||
|
||||
$comment_id = $this->db->getLastId();
|
||||
|
||||
$this->cache->delete('blog');
|
||||
|
||||
return $comment_id;
|
||||
}
|
||||
|
||||
public function editReview($comment_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "lightshop_blog_comment SET author = '" . $this->db->escape($data['author']) . "', blog_id = '" . (int)$data['blog_id'] . "', text = '" . $this->db->escape(strip_tags($data['text'])) . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "', date_modified = NOW() WHERE comment_id = '" . (int)$comment_id . "'");
|
||||
|
||||
$this->cache->delete('blog');
|
||||
}
|
||||
|
||||
public function deleteReview($comment_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_comment WHERE comment_id = '" . (int)$comment_id . "'");
|
||||
|
||||
$this->cache->delete('blog');
|
||||
}
|
||||
|
||||
public function getReview($comment_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT *, (SELECT pd.title FROM " . DB_PREFIX . "lightshop_blog_description pd WHERE pd.blog_id = r.blog_id AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS blog FROM " . DB_PREFIX . "lightshop_blog_comment r WHERE r.comment_id = '" . (int)$comment_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getReviews($data = array()) {
|
||||
$sql = "SELECT r.comment_id, pd.title, r.author, r.status, r.date_added FROM " . DB_PREFIX . "lightshop_blog_comment r LEFT JOIN " . DB_PREFIX . "lightshop_blog_description pd ON (r.blog_id = pd.blog_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_blog'])) {
|
||||
$sql .= " AND pd.title LIKE '" . $this->db->escape($data['filter_blog']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_author'])) {
|
||||
$sql .= " AND r.author LIKE '" . $this->db->escape($data['filter_author']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
|
||||
$sql .= " AND r.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(r.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'pd.title',
|
||||
'r.author',
|
||||
'r.status',
|
||||
'r.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY r.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;
|
||||
}
|
||||
|
||||
public function getTotalReviews($data = array()) {
|
||||
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_blog_comment (
|
||||
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`blog_id` int(11) NOT NULL,
|
||||
`customer_id` int(11) NOT NULL,
|
||||
`author` varchar(64) NOT NULL,
|
||||
`text` text NOT NULL,
|
||||
`rating` int(1) NOT NULL,
|
||||
`status` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`date_added` datetime NOT NULL,
|
||||
`date_modified` datetime NOT NULL,
|
||||
PRIMARY KEY (`comment_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
|
||||
$sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog_comment r LEFT JOIN " . DB_PREFIX . "lightshop_blog_description pd ON (r.blog_id = pd.blog_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_blog'])) {
|
||||
$sql .= " AND pd.title LIKE '" . $this->db->escape($data['filter_blog']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_author'])) {
|
||||
$sql .= " AND r.author LIKE '" . $this->db->escape($data['filter_author']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
|
||||
$sql .= " AND r.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(r.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalReviewsAwaitingApproval() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_blog_commentWHERE status = '0'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,365 @@
|
||||
<?php
|
||||
class ModelExtensionThemeLightshopcatblog extends Model {
|
||||
public function addCategoryBlog($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshopcat_blog SET parent_id = '" . (int)$data['parent_id'] . "', `top` = '" . (isset($data['top']) ? (int)$data['top'] : 0) . "', `column` = '" . (int)$data['column'] . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', date_modified = NOW(), date_added = NOW()");
|
||||
|
||||
$category_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "lightshopcat_blog SET image = '" . $this->db->escape($data['image']) . "' WHERE category_id = '" . (int)$category_id . "'");
|
||||
}
|
||||
|
||||
foreach ($data['lightshopcatblog_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshopcat_blog_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
// MySQL Hierarchical Data Closure Table Pattern
|
||||
$level = 0;
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "lightshopcat_blog_path` WHERE category_id = '" . (int)$data['parent_id'] . "' ORDER BY `level` ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "lightshopcat_blog_path` SET `category_id` = '" . (int)$category_id . "', `path_id` = '" . (int)$result['path_id'] . "', `level` = '" . (int)$level . "'");
|
||||
|
||||
$level++;
|
||||
}
|
||||
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "lightshopcat_blog_path` SET `category_id` = '" . (int)$category_id . "', `path_id` = '" . (int)$category_id . "', `level` = '" . (int)$level . "'");
|
||||
|
||||
if (isset($data['category_filter'])) {
|
||||
foreach ($data['category_filter'] as $filter_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshopcat_blog_filter SET category_id = '" . (int)$category_id . "', filter_id = '" . (int)$filter_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['lightshopcatblog_store'])) {
|
||||
foreach ($data['lightshopcatblog_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshopcat_blog_to_store SET category_id = '" . (int)$category_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// Set which layout to use with this category
|
||||
if (isset($data['category_layout'])) {
|
||||
foreach ($data['category_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshopcat_blog_to_layout SET category_id = '" . (int)$category_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'lightshopcatblog_id=" . (int)$category_id . "'");
|
||||
|
||||
// SEO URL
|
||||
if (isset($data['category_seo_url'])) {
|
||||
foreach ($data['category_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'lightshopcatblog_id=" . (int)$category_id . "', keyword = '" . $this->db->escape($keyword) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('category');
|
||||
|
||||
return $category_id;
|
||||
}
|
||||
|
||||
public function editCategoryBlog($category_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "lightshopcat_blog SET parent_id = '" . (int)$data['parent_id'] . "', `top` = '" . (isset($data['top']) ? (int)$data['top'] : 0) . "', `column` = '" . (int)$data['column'] . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "', date_modified = NOW() WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "lightshopcat_blog SET image = '" . $this->db->escape($data['image']) . "' WHERE category_id = '" . (int)$category_id . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog_description WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($data['lightshopcatblog_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshopcat_blog_description SET category_id = '" . (int)$category_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
// MySQL Hierarchical Data Closure Table Pattern
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "lightshopcat_blog_path` WHERE path_id = '" . (int)$category_id . "' ORDER BY level ASC");
|
||||
|
||||
if ($query->rows) {
|
||||
foreach ($query->rows as $category_path) {
|
||||
// Delete the path below the current one
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "lightshopcat_blog_path` WHERE category_id = '" . (int)$category_path['category_id'] . "' AND level < '" . (int)$category_path['level'] . "'");
|
||||
|
||||
$path = array();
|
||||
|
||||
// Get the nodes new parents
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "lightshopcat_blog_path` WHERE category_id = '" . (int)$data['parent_id'] . "' ORDER BY level ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$path[] = $result['path_id'];
|
||||
}
|
||||
|
||||
// Get whats left of the nodes current path
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "lightshopcat_blog_path` WHERE category_id = '" . (int)$category_path['category_id'] . "' ORDER BY level ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$path[] = $result['path_id'];
|
||||
}
|
||||
|
||||
// Combine the paths with a new level
|
||||
$level = 0;
|
||||
|
||||
foreach ($path as $path_id) {
|
||||
$this->db->query("REPLACE INTO `" . DB_PREFIX . "lightshopcat_blog_path` SET category_id = '" . (int)$category_path['category_id'] . "', `path_id` = '" . (int)$path_id . "', level = '" . (int)$level . "'");
|
||||
|
||||
$level++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Delete the path below the current one
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "lightshopcat_blog_path` WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
// Fix for records with no paths
|
||||
$level = 0;
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "lightshopcat_blog_path` WHERE category_id = '" . (int)$data['parent_id'] . "' ORDER BY level ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "lightshopcat_blog_path` SET category_id = '" . (int)$category_id . "', `path_id` = '" . (int)$result['path_id'] . "', level = '" . (int)$level . "'");
|
||||
|
||||
$level++;
|
||||
}
|
||||
|
||||
$this->db->query("REPLACE INTO `" . DB_PREFIX . "lightshopcat_blog_path` SET category_id = '" . (int)$category_id . "', `path_id` = '" . (int)$category_id . "', level = '" . (int)$level . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog_filter WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['category_filter'])) {
|
||||
foreach ($data['category_filter'] as $filter_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshopcat_blog_filter SET category_id = '" . (int)$category_id . "', filter_id = '" . (int)$filter_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog_to_store WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['lightshopcatblog_store'])) {
|
||||
foreach ($data['lightshopcatblog_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshopcat_blog_to_store SET category_id = '" . (int)$category_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog_to_layout WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
if (isset($data['category_layout'])) {
|
||||
foreach ($data['category_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshopcat_blog_to_layout SET category_id = '" . (int)$category_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'lightshopcatblog_id=" . (int)$category_id . "'");
|
||||
|
||||
// SEO URL
|
||||
if (isset($data['category_seo_url'])) {
|
||||
foreach ($data['category_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'lightshopcatblog_id=" . (int)$category_id . "', keyword = '" . $this->db->escape($keyword) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('category');
|
||||
}
|
||||
|
||||
public function deleteCategoryBlog($category_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog_path WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshopcat_blog_path WHERE path_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$this->deleteCategory($result['category_id']);
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog_description WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog_filter WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog_to_store WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshopcat_blog_to_layout WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_blog_to_category WHERE category_id = '" . (int)$category_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'lightshopcatblog_id=" . (int)$category_id . "'");
|
||||
|
||||
$this->cache->delete('category');
|
||||
}
|
||||
|
||||
public function repairCategoriesBlog($parent_id = 0) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshopcat_blog WHERE parent_id = '" . (int)$parent_id . "'");
|
||||
|
||||
foreach ($query->rows as $category) {
|
||||
// Delete the path below the current one
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "lightshopcat_blog_path` WHERE category_id = '" . (int)$category['category_id'] . "'");
|
||||
|
||||
// Fix for records with no paths
|
||||
$level = 0;
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "lightshopcat_blog_path` WHERE category_id = '" . (int)$parent_id . "' ORDER BY level ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "lightshopcat_blog_path` SET category_id = '" . (int)$category['category_id'] . "', `path_id` = '" . (int)$result['path_id'] . "', level = '" . (int)$level . "'");
|
||||
|
||||
$level++;
|
||||
}
|
||||
|
||||
$this->db->query("REPLACE INTO `" . DB_PREFIX . "lightshopcat_blog_path` SET category_id = '" . (int)$category['category_id'] . "', `path_id` = '" . (int)$category['category_id'] . "', level = '" . (int)$level . "'");
|
||||
|
||||
$this->repairCategories($category['category_id']);
|
||||
}
|
||||
}
|
||||
|
||||
public function getCategorySeoUrls($category_id) {
|
||||
$category_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'lightshopcatblog_id=" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
|
||||
return $category_seo_url_data;
|
||||
}
|
||||
|
||||
public function getCategoryBlog($category_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT *, (SELECT GROUP_CONCAT(cd1.name ORDER BY level SEPARATOR ' > ') FROM " . DB_PREFIX . "lightshopcat_blog_path cp LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_description cd1 ON (cp.path_id = cd1.category_id AND cp.category_id != cp.path_id) WHERE cp.category_id = c.category_id AND cd1.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY cp.category_id) AS path FROM " . DB_PREFIX . "lightshopcat_blog c LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_description cd2 ON (c.category_id = cd2.category_id) WHERE c.category_id = '" . (int)$category_id . "' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCategoriesBlogByParentId($parent_id = 0) {
|
||||
$query = $this->db->query("SELECT *, (SELECT COUNT(parent_id) FROM " . DB_PREFIX . "lightshopcat_blog WHERE parent_id = c.category_id) AS children FROM " . DB_PREFIX . "lightshopcat_blog c LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_description cd ON (c.category_id = cd.category_id) WHERE c.parent_id = '" . (int)$parent_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY c.sort_order, cd.name");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getCategoriesBlog($data = array()) {
|
||||
$sql = "SELECT cp.category_id AS category_id, GROUP_CONCAT(cd1.name ORDER BY cp.level SEPARATOR ' > ') AS name, c1.parent_id, c1.sort_order, c1.status,(select count(product_id) as product_count from " . DB_PREFIX . "product_to_category pc where pc.category_id = c1.category_id) as product_count FROM " . DB_PREFIX . "lightshopcat_blog_path cp LEFT JOIN " . DB_PREFIX . "lightshopcat_blog c1 ON (cp.category_id = c1.category_id) LEFT JOIN " . DB_PREFIX . "lightshopcat_blog c2 ON (cp.path_id = c2.category_id) LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_description cd1 ON (cp.path_id = cd1.category_id) LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_description cd2 ON (cp.category_id = cd2.category_id) WHERE cd1.language_id = '" . (int)$this->config->get('config_language_id') . "' AND cd2.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND cd2.name LIKE '%" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY cp.category_id";
|
||||
|
||||
$sort_data = array(
|
||||
'product_count',
|
||||
'name',
|
||||
'sort_order'
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getCategoryBlogDescriptions($category_id) {
|
||||
$category_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshopcat_blog_description WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_description_data[$result['language_id']] = array(
|
||||
'name' => $result['name'],
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword'],
|
||||
'description' => $result['description']
|
||||
);
|
||||
}
|
||||
|
||||
return $category_description_data;
|
||||
}
|
||||
|
||||
public function getCategoryBlogPath($category_id) {
|
||||
$query = $this->db->query("SELECT category_id, path_id, level FROM " . DB_PREFIX . "lightshopcat_blog_path WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getCategoryBlogFilters($category_id) {
|
||||
$category_filter_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshopcat_blog_filter WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_filter_data[] = $result['filter_id'];
|
||||
}
|
||||
|
||||
return $category_filter_data;
|
||||
}
|
||||
|
||||
public function getCategoryBlogStores($category_id) {
|
||||
$category_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshopcat_blog_to_store WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $category_store_data;
|
||||
}
|
||||
|
||||
public function getCategoryBlogLayouts($category_id) {
|
||||
$category_layout_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshopcat_blog_to_layout WHERE category_id = '" . (int)$category_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$category_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
|
||||
return $category_layout_data;
|
||||
}
|
||||
|
||||
public function getTotalCategoriesBlog() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshopcat_blog");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getAllCategoriesBlog() {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshopcat_blog c LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "lightshopcat_blog_to_store c2s ON (c.category_id = c2s.category_id) WHERE cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY c.parent_id, c.sort_order, cd.name");
|
||||
|
||||
$category_data = array();
|
||||
foreach ($query->rows as $row) {
|
||||
$category_data[$row['parent_id']][$row['category_id']] = $row;
|
||||
}
|
||||
|
||||
return $category_data;
|
||||
}
|
||||
|
||||
public function getTotalCategoriesBlogByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshopcat_blog_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
class ModelExtensionThemeLightshopNews extends Model {
|
||||
public function addNews($data) {
|
||||
if($data['date_added']){
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news SET sort_order = 0, bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "'");
|
||||
}else{
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news SET sort_order = 0, bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "', date_added = NOW()");
|
||||
}
|
||||
$news_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['news_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news_description SET news_id = '" . (int)$news_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['news_store'])) {
|
||||
foreach ($data['news_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news_to_store SET news_id = '" . (int)$news_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_related WHERE news_id = '" . (int)$news_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news_related SET news_id = '" . (int)$news_id . "', related_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['news_layout'])) {
|
||||
foreach ($data['news_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news_to_layout SET news_id = '" . (int)$news_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
// SEO URL
|
||||
if (isset($data['news_seo_url'])) {
|
||||
foreach ($data['news_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'news_id=" . (int)$news_id . "', keyword = '" . $this->db->escape($keyword) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('news');
|
||||
|
||||
return $news_id;
|
||||
}
|
||||
|
||||
public function editNews($news_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "lightshop_news SET sort_order = 0, bottom = '" . (isset($data['bottom']) ? (int)$data['bottom'] : 0) . "', status = '" . (int)$data['status'] . "', date_added = '" . $this->db->escape($data['date_added']) . "' WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_description WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
foreach ($data['news_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news_description SET news_id = '" . (int)$news_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_to_store WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
if (isset($data['news_store'])) {
|
||||
foreach ($data['news_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news_to_store SET news_id = '" . (int)$news_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_to_layout WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
if (isset($data['news_layout'])) {
|
||||
foreach ($data['news_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news_to_layout SET news_id = '" . (int)$news_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_related WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_related WHERE news_id = '" . (int)$news_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_news_related SET news_id = '" . (int)$news_id . "', related_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'news_id=" . (int)$news_id . "'");
|
||||
|
||||
if (isset($data['news_seo_url'])) {
|
||||
foreach ($data['news_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (trim($keyword)) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "seo_url` SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'news_id=" . (int)$news_id . "', keyword = '" . $this->db->escape($keyword) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('news');
|
||||
}
|
||||
|
||||
public function deleteNews($news_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news WHERE news_id = '" . (int)$news_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_description WHERE news_id = '" . (int)$news_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_to_store WHERE news_id = '" . (int)$news_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_to_layout WHERE news_id = '" . (int)$news_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'news_id=" . (int)$news_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_related WHERE news_id = '" . (int)$news_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_news_related WHERE related_id = '" . (int)$news_id . "'");
|
||||
|
||||
$this->cache->delete('news');
|
||||
}
|
||||
|
||||
public function getNews($news_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT *, (SELECT keyword FROM " . DB_PREFIX . "seo_url WHERE query = 'news_id=" . (int)$news_id . "' LIMIT 1) AS keyword FROM " . DB_PREFIX . "lightshop_news WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getNewsSeoUrls($news_id) {
|
||||
$news_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'news_id=" . (int)$news_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$news_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
|
||||
return $news_seo_url_data;
|
||||
}
|
||||
|
||||
public function getNewss($data = array()) {
|
||||
|
||||
$this->createTable();
|
||||
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "lightshop_news i LEFT JOIN " . DB_PREFIX . "lightshop_news_description id ON (i.news_id = id.news_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sort_data = array(
|
||||
'id.title',
|
||||
'i.sort_order',
|
||||
'i.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY i.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;
|
||||
} else {
|
||||
$news_data = $this->cache->get('news.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$news_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_news i LEFT JOIN " . DB_PREFIX . "lightshop_news_description id ON (i.news_id = id.news_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY id.title");
|
||||
|
||||
$news_data = $query->rows;
|
||||
|
||||
$this->cache->set('news.' . (int)$this->config->get('config_language_id'), $news_data);
|
||||
}
|
||||
|
||||
return $news_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getNewsDescriptions($news_id) {
|
||||
$news_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_news_description WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$news_description_data[$result['language_id']] = array(
|
||||
'title' => $result['title'],
|
||||
'description' => $result['description'],
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword']
|
||||
);
|
||||
}
|
||||
|
||||
return $news_description_data;
|
||||
}
|
||||
|
||||
public function getNewsStores($news_id) {
|
||||
$news_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_news_to_store WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$news_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $news_store_data;
|
||||
}
|
||||
|
||||
public function getNewsLayouts($news_id) {
|
||||
$news_layout_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_news_to_layout WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$news_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
|
||||
return $news_layout_data;
|
||||
}
|
||||
|
||||
public function getTotalNewss() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_news");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalNewssByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_news_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getProductRelated($news_id) {
|
||||
$product_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_news_related WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_related_data[] = $result['related_id'];
|
||||
}
|
||||
|
||||
return $product_related_data;
|
||||
}
|
||||
|
||||
public function createTable() {
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_news (
|
||||
`news_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`bottom` int(1) NOT NULL DEFAULT '0',
|
||||
`sort_order` int(3) NOT NULL DEFAULT '0',
|
||||
`status` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`date_added` date NOT NULL,
|
||||
PRIMARY KEY (`news_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_news_description (
|
||||
`news_id` int(11) NOT NULL,
|
||||
`language_id` int(11) NOT NULL,
|
||||
`title` varchar(200) NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`meta_title` varchar(255) NOT NULL,
|
||||
`meta_h1` varchar(255) NOT NULL,
|
||||
`meta_description` varchar(255) NOT NULL,
|
||||
`meta_keyword` varchar(255) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_news_to_layout (
|
||||
`news_id` int(11) NOT NULL,
|
||||
`store_id` int(11) NOT NULL,
|
||||
`layout_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`news_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_news_to_store (
|
||||
`news_id` int(11) NOT NULL,
|
||||
`store_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`news_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_news_related (
|
||||
`news_id` int(11) NOT NULL,
|
||||
`related_id` int(11) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
class ModelExtensionThemeLightshopSets extends Model {
|
||||
public function addSet($data) {
|
||||
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_set SET sort_order = 0, mode = '" . (isset($data['mode']) ? (int)$data['mode'] : 0) . "', discount = '" . (isset($data['discount']) ? (int)$data['discount'] : 0) . "', status = '" . (int)$data['status'] . "', date_added = NOW()");
|
||||
|
||||
$set_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['set_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_set_description SET set_id = '" . (int)$set_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['set_store'])) {
|
||||
foreach ($data['set_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_set_to_store SET set_id = '" . (int)$set_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product'])) {
|
||||
foreach ($data['product'] as $key => $rowProducts) {
|
||||
if(!isset($rowProducts['items'])){ continue; }
|
||||
foreach ($rowProducts['items'] as $product) {
|
||||
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_product_to_set SET set_id = '" . (int)$set_id . "', row_id = '" . (int)$key . "', product_id = '" . (int)$product['id'] . "', quantity = '" . (int)$rowProducts['qty'] . "', sort_order = " . (int)$rowProducts['sort_order'] . "");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$this->cache->delete('set');
|
||||
|
||||
return $set_id;
|
||||
}
|
||||
|
||||
public function editSet($set_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "lightshop_set SET mode = '" . (isset($data['mode']) ? (int)$data['mode'] : 0) . "', discount = '" . (isset($data['discount']) ? (int)$data['discount'] : 0) . "', status = '" . (int)$data['status'] . "' WHERE set_id = '" . (int)$set_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_set_description WHERE set_id = '" . (int)$set_id . "'");
|
||||
|
||||
foreach ($data['set_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_set_description SET set_id = '" . (int)$set_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_set_to_store WHERE set_id = '" . (int)$set_id . "'");
|
||||
|
||||
if (isset($data['set_store'])) {
|
||||
foreach ($data['set_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_set_to_store SET set_id = '" . (int)$set_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_product_to_set WHERE set_id = '" . (int)$set_id . "'");
|
||||
|
||||
|
||||
if (isset($data['product'])) {
|
||||
foreach ($data['product'] as $key => $rowProducts) {
|
||||
if(!isset($rowProducts['items'])){ continue; }
|
||||
foreach ($rowProducts['items'] as $product) {
|
||||
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "lightshop_product_to_set SET set_id = '" . (int)$set_id . "', row_id = '" . (int)$key . "', product_id = '" . (int)$product['id'] . "', quantity = '" . (int)$rowProducts['qty'] . "', sort_order = " . (int)$rowProducts['sort_order'] . "");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'set_id=" . (int)$set_id . "'");
|
||||
|
||||
|
||||
$this->cache->delete('set');
|
||||
}
|
||||
|
||||
public function deleteSet($set_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_set WHERE set_id = '" . (int)$set_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_set_description WHERE set_id = '" . (int)$set_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_set_to_store WHERE set_id = '" . (int)$set_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_set_to_layout WHERE set_id = '" . (int)$set_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "lightshop_product_to_set WHERE set_id = '" . (int)$set_id . "'");
|
||||
|
||||
$this->cache->delete('set');
|
||||
}
|
||||
|
||||
public function getSet($set_id) {
|
||||
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "lightshop_set i LEFT JOIN " . DB_PREFIX . "lightshop_set_description id ON (i.set_id = id.set_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' AND i.set_id = '" . (int)$set_id . "'";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row;
|
||||
|
||||
}
|
||||
|
||||
public function getSetProduct($set_id) {
|
||||
$products = array();
|
||||
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "lightshop_product_to_set WHERE set_id = '" . (int)$set_id . "' ORDER BY row_id,set_product_id ASC";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
foreach ($query->rows as $key => $product) {
|
||||
$products[$product['row_id']][] = array(
|
||||
'id' => $product['product_id'],
|
||||
'qty' => $product['quantity'],
|
||||
'sort_order' => $product['sort_order']
|
||||
);
|
||||
}
|
||||
|
||||
return $products;
|
||||
|
||||
}
|
||||
|
||||
public function getSets($data = array()) {
|
||||
|
||||
$this->createTable();
|
||||
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "lightshop_set i LEFT JOIN " . DB_PREFIX . "lightshop_set_description id ON (i.set_id = id.set_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sort_data = array(
|
||||
'id.title',
|
||||
'i.sort_order',
|
||||
'i.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY i.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;
|
||||
} else {
|
||||
$set_data = $this->cache->get('lightshopset.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$set_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_set i LEFT JOIN " . DB_PREFIX . "lightshop_set_description id ON (i.set_id = id.set_id) WHERE id.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY id.title");
|
||||
|
||||
$set_data = $query->rows;
|
||||
|
||||
$this->cache->set('lightshopset.' . (int)$this->config->get('config_language_id'), $set_data);
|
||||
}
|
||||
|
||||
return $set_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSetDescriptions($set_id) {
|
||||
$set_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_set_description WHERE set_id = '" . (int)$set_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$set_description_data[$result['language_id']] = array(
|
||||
'title' => $result['title'],
|
||||
);
|
||||
}
|
||||
|
||||
return $set_description_data;
|
||||
}
|
||||
|
||||
public function getSetStores($set_id) {
|
||||
$set_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_set_to_store WHERE set_id = '" . (int)$set_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$set_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $set_store_data;
|
||||
}
|
||||
|
||||
|
||||
public function getTotalSets() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_set");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalNewssByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "lightshop_news_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getProductRelated($news_id) {
|
||||
$product_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "lightshop_news_related WHERE news_id = '" . (int)$news_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$product_related_data[] = $result['related_id'];
|
||||
}
|
||||
|
||||
return $product_related_data;
|
||||
}
|
||||
|
||||
public function createTable() {
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_set (
|
||||
`set_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`mode` int(1) NOT NULL DEFAULT '0',
|
||||
`discount` int(11) NOT NULL DEFAULT '0',
|
||||
`sort_order` int(3) NOT NULL DEFAULT '0',
|
||||
`status` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`date_added` date NOT NULL,
|
||||
PRIMARY KEY (`set_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_set_description (
|
||||
`set_id` int(11) NOT NULL,
|
||||
`language_id` int(11) NOT NULL,
|
||||
`title` varchar(200) NOT NULL,
|
||||
`description` text NOT NULL,
|
||||
`meta_title` varchar(255) NOT NULL,
|
||||
`meta_h1` varchar(255) NOT NULL,
|
||||
`meta_description` varchar(255) NOT NULL,
|
||||
`meta_keyword` varchar(255) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_product_to_set (
|
||||
`set_product_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`set_id` int(11) NOT NULL,
|
||||
`row_id` int(11) NOT NULL,
|
||||
`product_id` int(11) NOT NULL,
|
||||
`quantity` int(11) NOT NULL DEFAULT '0',
|
||||
`sort_order` int(3) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`set_product_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_set_to_layout (
|
||||
`set_id` int(11) NOT NULL,
|
||||
`store_id` int(11) NOT NULL,
|
||||
`layout_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`set_id`,`store_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_set_to_store (
|
||||
`set_id` int(11) NOT NULL,
|
||||
`store_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`set_id`,`store_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS " . DB_PREFIX . "lightshop_news_related (
|
||||
`news_id` int(11) NOT NULL,
|
||||
`related_id` int(11) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
class ModelExtensionThemeSubscribe extends Model {
|
||||
|
||||
public function getSubscribe($subscribe_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "subscribe WHERE subscribe_id='" . (int) $subscribe_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getEmailDescription() {
|
||||
$subscribe_descriptions = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "subscribe_email_description");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$subscribe_descriptions[$result['language_id']] = $result['subscribe_descriptions'];
|
||||
}
|
||||
|
||||
return $subscribe_descriptions;
|
||||
}
|
||||
|
||||
public function addEmailDescription($descriptions) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "subscribe_email_description");
|
||||
|
||||
foreach ($descriptions as $language_id => $description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "subscribe_email_description SET subscribe_descriptions = '" . $this->db->escape($description) . "', language_id = '" . (int) $language_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function getAuthDescription() {
|
||||
$subscribe_authorization = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "subscribe_auth_description");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$subscribe_authorization[$result['language_id']] = $result['subscribe_authorization'];
|
||||
}
|
||||
|
||||
return $subscribe_authorization;
|
||||
}
|
||||
|
||||
public function addAuthDescription($descriptions) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "subscribe_auth_description");
|
||||
|
||||
foreach ($descriptions as $language_id => $description) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "subscribe_auth_description SET subscribe_authorization = '" . $this->db->escape($description) . "', language_id = '" . (int) $language_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function addSubscribe($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "subscribe SET email = '" . $this->db->escape($data['email']) . "', status = '" . (int) $data['status'] . "'");
|
||||
}
|
||||
|
||||
public function editSubscribe($subscribe_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "subscribe SET email = '" . $this->db->escape($data['email']) . "', status = '" . (int) $data['status'] . "' WHERE subscribe_id = '" . (int) $subscribe_id . "'");
|
||||
}
|
||||
|
||||
public function deleteSubscribe($subscribe_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "subscribe WHERE subscribe_id = '" . (int) $subscribe_id . "'");
|
||||
}
|
||||
|
||||
public function getSubscribers($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "subscribe ";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'status'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= "ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY email";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalSubscibe($data = array()) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "subscribe`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function checkEmail($email, $subscribe_id) {
|
||||
$sql = "SELECT email FROM " . DB_PREFIX . "subscribe WHERE email='" . $this->db->escape($email) . "'";
|
||||
|
||||
if ($subscribe_id) {
|
||||
$sql .= " AND subscribe_id !='" . $subscribe_id . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return isset($query->row['email']) ? $query->row['email'] : 0;
|
||||
}
|
||||
|
||||
public function tableExists() {
|
||||
$query = $this->db->query("SHOW TABLES LIKE '" . DB_PREFIX . "subscribe'");
|
||||
|
||||
return $query->num_rows;
|
||||
}
|
||||
|
||||
public function installSubscribe() {
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "subscribe` (
|
||||
`subscribe_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`email` text NOT NULL ,
|
||||
`status` tinyint(1) NOT NULL,
|
||||
PRIMARY KEY (`subscribe_id`)
|
||||
) DEFAULT COLLATE=utf8_general_ci;");
|
||||
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "subscribe_email_description` (
|
||||
`subscribe_desc_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`language_id` int(2) NOT NULL,
|
||||
`subscribe_descriptions` MEDIUMTEXT NOT NULL,
|
||||
PRIMARY KEY (`subscribe_desc_id`)
|
||||
) DEFAULT COLLATE=utf8_general_ci;");
|
||||
|
||||
$this->db->query("
|
||||
CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "subscribe_auth_description` (
|
||||
`subscribe_auth_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`language_id` int(2) NOT NULL,
|
||||
`subscribe_authorization` MEDIUMTEXT NOT NULL,
|
||||
PRIMARY KEY (`subscribe_auth_id`)
|
||||
) DEFAULT COLLATE=utf8_general_ci;");
|
||||
}
|
||||
|
||||
public function uninstallSubscribe() {
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "subscribe`");
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "subscribe_email_description`");
|
||||
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "subscribe_auth_description`");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
class ModelLocalisationCountry extends Model {
|
||||
public function addCountry($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "country SET name = '" . $this->db->escape($data['name']) . "', iso_code_2 = '" . $this->db->escape($data['iso_code_2']) . "', iso_code_3 = '" . $this->db->escape($data['iso_code_3']) . "', address_format = '" . $this->db->escape($data['address_format']) . "', postcode_required = '" . (int)$data['postcode_required'] . "', status = '" . (int)$data['status'] . "'");
|
||||
|
||||
$this->cache->delete('country');
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function editCountry($country_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "country SET name = '" . $this->db->escape($data['name']) . "', iso_code_2 = '" . $this->db->escape($data['iso_code_2']) . "', iso_code_3 = '" . $this->db->escape($data['iso_code_3']) . "', address_format = '" . $this->db->escape($data['address_format']) . "', postcode_required = '" . (int)$data['postcode_required'] . "', status = '" . (int)$data['status'] . "' WHERE country_id = '" . (int)$country_id . "'");
|
||||
|
||||
$this->cache->delete('country');
|
||||
}
|
||||
|
||||
public function deleteCountry($country_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "country WHERE country_id = '" . (int)$country_id . "'");
|
||||
|
||||
$this->cache->delete('country');
|
||||
}
|
||||
|
||||
public function getCountry($country_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "country WHERE country_id = '" . (int)$country_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCountries($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "country";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'iso_code_2',
|
||||
'iso_code_3'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY name";
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
$country_data = $this->cache->get('country.admin');
|
||||
|
||||
if (!$country_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "country ORDER BY name ASC");
|
||||
|
||||
$country_data = $query->rows;
|
||||
|
||||
$this->cache->set('country.admin', $country_data);
|
||||
}
|
||||
|
||||
return $country_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTotalCountries() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "country");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
class ModelLocalisationCurrency extends Model {
|
||||
public function addCurrency($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "currency SET title = '" . $this->db->escape($data['title']) . "', code = '" . $this->db->escape($data['code']) . "', symbol_left = '" . $this->db->escape($data['symbol_left']) . "', symbol_right = '" . $this->db->escape($data['symbol_right']) . "', decimal_place = '" . $this->db->escape($data['decimal_place']) . "', value = '" . $this->db->escape($data['value']) . "', status = '" . (int)$data['status'] . "', date_modified = NOW()");
|
||||
|
||||
$currency_id = $this->db->getLastId();
|
||||
|
||||
if ($this->config->get('config_currency_auto')) {
|
||||
$this->refresh(true);
|
||||
}
|
||||
|
||||
$this->cache->delete('currency');
|
||||
|
||||
return $currency_id;
|
||||
}
|
||||
|
||||
public function editCurrency($currency_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "currency SET title = '" . $this->db->escape($data['title']) . "', code = '" . $this->db->escape($data['code']) . "', symbol_left = '" . $this->db->escape($data['symbol_left']) . "', symbol_right = '" . $this->db->escape($data['symbol_right']) . "', decimal_place = '" . $this->db->escape($data['decimal_place']) . "', value = '" . $this->db->escape($data['value']) . "', status = '" . (int)$data['status'] . "', date_modified = NOW() WHERE currency_id = '" . (int)$currency_id . "'");
|
||||
|
||||
$this->cache->delete('currency');
|
||||
}
|
||||
|
||||
public function deleteCurrency($currency_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "currency WHERE currency_id = '" . (int)$currency_id . "'");
|
||||
|
||||
$this->cache->delete('currency');
|
||||
}
|
||||
|
||||
public function getCurrency($currency_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "currency WHERE currency_id = '" . (int)$currency_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCurrencyByCode($currency) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "currency WHERE code = '" . $this->db->escape($currency) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function editValueByCode($code, $value) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "currency` SET `value` = '" . (float)$value . "', `date_modified` = NOW() WHERE `code` = '" . $this->db->escape((string)$code) . "'");
|
||||
|
||||
$this->cache->delete('currency');
|
||||
}
|
||||
|
||||
public function getCurrencies($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "currency";
|
||||
|
||||
$sort_data = array(
|
||||
'title',
|
||||
'code',
|
||||
'value',
|
||||
'date_modified'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY title";
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
$currency_data = $this->cache->get('currency');
|
||||
|
||||
if (!$currency_data) {
|
||||
$currency_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency ORDER BY title ASC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$currency_data[$result['code']] = array(
|
||||
'currency_id' => $result['currency_id'],
|
||||
'title' => $result['title'],
|
||||
'code' => $result['code'],
|
||||
'symbol_left' => $result['symbol_left'],
|
||||
'symbol_right' => $result['symbol_right'],
|
||||
'decimal_place' => $result['decimal_place'],
|
||||
'value' => $result['value'],
|
||||
'status' => $result['status'],
|
||||
'date_modified' => $result['date_modified']
|
||||
);
|
||||
}
|
||||
|
||||
$this->cache->set('currency', $currency_data);
|
||||
}
|
||||
|
||||
return $currency_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function refresh($force = false) {
|
||||
$currency_data = array();
|
||||
|
||||
if ($force) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'");
|
||||
} else {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified < '" . $this->db->escape(date('Y-m-d H:i:s', strtotime('-1 day'))) . "'");
|
||||
}
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$currency_data[] = $this->config->get('config_currency') . $result['code'] . '=X';
|
||||
$currency_data[] = $result['code'] . $this->config->get('config_currency') . '=X';
|
||||
}
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $currency_data) . '&f=sl1&e=.json');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
|
||||
|
||||
$content = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
$line = explode("\n", trim($content));
|
||||
|
||||
for ($i = 0; $i < count($line); $i = $i + 2) {
|
||||
$currency = utf8_substr($line[$i], 4, 3);
|
||||
$value = utf8_substr($line[$i], 11, 6);
|
||||
|
||||
if ((float)$value < 1 && isset($line[$i + 1])) {
|
||||
if((float)utf8_substr($line[$i + 1], 11, 6) > 0) {
|
||||
$value = (1 / (float)utf8_substr($line[$i + 1], 11, 6));
|
||||
} else {
|
||||
$value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((float)$value) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (float)$value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
|
||||
|
||||
$this->cache->delete('currency');
|
||||
}
|
||||
|
||||
public function getTotalCurrencies() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "currency");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
class ModelLocalisationGeoZone extends Model {
|
||||
public function addGeoZone($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "geo_zone SET name = '" . $this->db->escape($data['name']) . "', description = '" . $this->db->escape($data['description']) . "', date_added = NOW()");
|
||||
|
||||
$geo_zone_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['zone_to_geo_zone'])) {
|
||||
foreach ($data['zone_to_geo_zone'] as $value) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$geo_zone_id . "' AND country_id = '" . (int)$value['country_id'] . "' AND zone_id = '" . (int)$value['zone_id'] . "'");
|
||||
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "zone_to_geo_zone SET country_id = '" . (int)$value['country_id'] . "', zone_id = '" . (int)$value['zone_id'] . "', geo_zone_id = '" . (int)$geo_zone_id . "', date_added = NOW()");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('geo_zone');
|
||||
|
||||
return $geo_zone_id;
|
||||
}
|
||||
|
||||
public function editGeoZone($geo_zone_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "geo_zone SET name = '" . $this->db->escape($data['name']) . "', description = '" . $this->db->escape($data['description']) . "', date_modified = NOW() WHERE geo_zone_id = '" . (int)$geo_zone_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$geo_zone_id . "'");
|
||||
|
||||
if (isset($data['zone_to_geo_zone'])) {
|
||||
foreach ($data['zone_to_geo_zone'] as $value) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$geo_zone_id . "' AND country_id = '" . (int)$value['country_id'] . "' AND zone_id = '" . (int)$value['zone_id'] . "'");
|
||||
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "zone_to_geo_zone SET country_id = '" . (int)$value['country_id'] . "', zone_id = '" . (int)$value['zone_id'] . "', geo_zone_id = '" . (int)$geo_zone_id . "', date_added = NOW()");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('geo_zone');
|
||||
}
|
||||
|
||||
public function deleteGeoZone($geo_zone_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "geo_zone WHERE geo_zone_id = '" . (int)$geo_zone_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$geo_zone_id . "'");
|
||||
|
||||
$this->cache->delete('geo_zone');
|
||||
}
|
||||
|
||||
public function getGeoZone($geo_zone_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "geo_zone WHERE geo_zone_id = '" . (int)$geo_zone_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getGeoZones($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "geo_zone";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'description'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY name";
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
$geo_zone_data = $this->cache->get('geo_zone');
|
||||
|
||||
if (!$geo_zone_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "geo_zone ORDER BY name ASC");
|
||||
|
||||
$geo_zone_data = $query->rows;
|
||||
|
||||
$this->cache->set('geo_zone', $geo_zone_data);
|
||||
}
|
||||
|
||||
return $geo_zone_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTotalGeoZones() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "geo_zone");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getZoneToGeoZones($geo_zone_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$geo_zone_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalZoneToGeoZoneByGeoZoneId($geo_zone_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$geo_zone_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalZoneToGeoZoneByCountryId($country_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "zone_to_geo_zone WHERE country_id = '" . (int)$country_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalZoneToGeoZoneByZoneId($zone_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "zone_to_geo_zone WHERE zone_id = '" . (int)$zone_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
class ModelLocalisationLanguage extends Model {
|
||||
public function addLanguage($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "language SET name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', locale = '" . $this->db->escape($data['locale']) . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "'");
|
||||
|
||||
$this->cache->delete('catalog.language');
|
||||
$this->cache->delete('admin.language');
|
||||
|
||||
$language_id = $this->db->getLastId();
|
||||
|
||||
// Attribute
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "attribute_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $attribute) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_description SET attribute_id = '" . (int)$attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($attribute['name']) . "'");
|
||||
}
|
||||
|
||||
// Attribute Group
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "attribute_group_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $attribute_group) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "attribute_group_description SET attribute_group_id = '" . (int)$attribute_group['attribute_group_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($attribute_group['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('attribute');
|
||||
|
||||
// Banner
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner_image WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $banner_image) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "banner_image SET banner_id = '" . (int)$banner_image['banner_id'] . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($banner_image['title']) . "', link = '" . $this->db->escape($banner_image['link']) . "', image = '" . $this->db->escape($banner_image['image']) . "', sort_order = '" . (int)$banner_image['sort_order'] . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('banner');
|
||||
|
||||
// Category
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $category) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "category_description SET category_id = '" . (int)$category['category_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($category['name']) . "', description = '" . $this->db->escape($category['description']) . "', meta_title = '" . $this->db->escape($category['meta_title']) . "', meta_description = '" . $this->db->escape($category['meta_description']) . "', meta_keyword = '" . $this->db->escape($category['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('category');
|
||||
|
||||
// Customer Group
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_group_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $customer_group) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_group_description SET customer_group_id = '" . (int)$customer_group['customer_group_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($customer_group['name']) . "', description = '" . $this->db->escape($customer_group['description']) . "'");
|
||||
}
|
||||
|
||||
// Custom Field
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "custom_field_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $custom_field) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_description SET custom_field_id = '" . (int)$custom_field['custom_field_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($custom_field['name']) . "'");
|
||||
}
|
||||
|
||||
// Custom Field Value
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "custom_field_value_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $custom_field_value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "custom_field_value_description SET custom_field_value_id = '" . (int)$custom_field_value['custom_field_value_id'] . "', language_id = '" . (int)$language_id . "', custom_field_id = '" . (int)$custom_field_value['custom_field_id'] . "', name = '" . $this->db->escape($custom_field_value['name']) . "'");
|
||||
}
|
||||
|
||||
// Download
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "download_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $download) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "download_description SET download_id = '" . (int)$download['download_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($download['name']) . "'");
|
||||
}
|
||||
|
||||
// Filter
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "filter_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $filter) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "filter_description SET filter_id = '" . (int)$filter['filter_id'] . "', language_id = '" . (int)$language_id . "', filter_group_id = '" . (int)$filter['filter_group_id'] . "', name = '" . $this->db->escape($filter['name']) . "'");
|
||||
}
|
||||
|
||||
// Filter Group
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "filter_group_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $filter_group) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "filter_group_description SET filter_group_id = '" . (int)$filter_group['filter_group_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($filter_group['name']) . "'");
|
||||
}
|
||||
|
||||
// Information
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "information_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $information) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "information_description SET information_id = '" . (int)$information['information_id'] . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($information['title']) . "', description = '" . $this->db->escape($information['description']) . "', meta_title = '" . $this->db->escape($information['meta_title']) . "', meta_description = '" . $this->db->escape($information['meta_description']) . "', meta_keyword = '" . $this->db->escape($information['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('information');
|
||||
|
||||
// Length
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $length) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "length_class_description SET length_class_id = '" . (int)$length['length_class_id'] . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($length['title']) . "', unit = '" . $this->db->escape($length['unit']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('length_class');
|
||||
|
||||
// Option
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $option) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "option_description SET option_id = '" . (int)$option['option_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($option['name']) . "'");
|
||||
}
|
||||
|
||||
// Option Value
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "option_value_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $option_value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "option_value_description SET option_value_id = '" . (int)$option_value['option_value_id'] . "', language_id = '" . (int)$language_id . "', option_id = '" . (int)$option_value['option_id'] . "', name = '" . $this->db->escape($option_value['name']) . "'");
|
||||
}
|
||||
|
||||
// Order Status
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $order_status) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "order_status SET order_status_id = '" . (int)$order_status['order_status_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($order_status['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('order_status');
|
||||
|
||||
// Product
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $product) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product['product_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($product['name']) . "', description = '" . $this->db->escape($product['description']) . "', tag = '" . $this->db->escape($product['tag']) . "', meta_title = '" . $this->db->escape($product['meta_title']) . "', meta_description = '" . $this->db->escape($product['meta_description']) . "', meta_keyword = '" . $this->db->escape($product['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('product');
|
||||
|
||||
// Product Attribute
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_attribute WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $product_attribute) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_attribute['product_id'] . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" . $this->db->escape($product_attribute['text']) . "'");
|
||||
}
|
||||
|
||||
// Return Action
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_action WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $return_action) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_action SET return_action_id = '" . (int)$return_action['return_action_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($return_action['name']) . "'");
|
||||
}
|
||||
|
||||
// Return Reason
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_reason WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $return_reason) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_reason SET return_reason_id = '" . (int)$return_reason['return_reason_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($return_reason['name']) . "'");
|
||||
}
|
||||
|
||||
// Return Status
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $return_status) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_status SET return_status_id = '" . (int)$return_status['return_status_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($return_status['name']) . "'");
|
||||
}
|
||||
|
||||
// Stock Status
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "stock_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $stock_status) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "stock_status SET stock_status_id = '" . (int)$stock_status['stock_status_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($stock_status['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('stock_status');
|
||||
|
||||
// Voucher Theme
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "voucher_theme_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $voucher_theme) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "voucher_theme_description SET voucher_theme_id = '" . (int)$voucher_theme['voucher_theme_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($voucher_theme['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('voucher_theme');
|
||||
|
||||
// Weight Class
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $weight_class) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "weight_class_description SET weight_class_id = '" . (int)$weight_class['weight_class_id'] . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($weight_class['title']) . "', unit = '" . $this->db->escape($weight_class['unit']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('weight_class');
|
||||
|
||||
// Profiles
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "recurring_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
foreach ($query->rows as $recurring) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "recurring_description SET recurring_id = '" . (int)$recurring['recurring_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($recurring['name']));
|
||||
}
|
||||
|
||||
return $language_id;
|
||||
}
|
||||
|
||||
public function editLanguage($language_id, $data) {
|
||||
$language_query = $this->db->query("SELECT `code` FROM " . DB_PREFIX . "language WHERE language_id = '" . (int)$language_id . "'");
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "language SET name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', locale = '" . $this->db->escape($data['locale']) . "', sort_order = '" . (int)$data['sort_order'] . "', status = '" . (int)$data['status'] . "' WHERE language_id = '" . (int)$language_id . "'");
|
||||
|
||||
if ($language_query->row['code'] != $data['code']) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "setting SET value = '" . $this->db->escape($data['code']) . "' WHERE `key` = 'config_language' AND value = '" . $this->db->escape($language_query->row['code']) . "'");
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "setting SET value = '" . $this->db->escape($data['code']) . "' WHERE `key` = 'config_admin_language' AND value = '" . $this->db->escape($language_query->row['code']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('catalog.language');
|
||||
$this->cache->delete('admin.language');
|
||||
}
|
||||
|
||||
public function deleteLanguage($language_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "language WHERE language_id = '" . (int)$language_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE language_id = '" . (int)$language_id . "'");
|
||||
|
||||
$this->cache->delete('catalog.language');
|
||||
$this->cache->delete('admin.language');
|
||||
|
||||
}
|
||||
|
||||
public function getLanguage($language_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "language WHERE language_id = '" . (int)$language_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getLanguages($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "language";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'code',
|
||||
'sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY sort_order, name";
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
$language_data = $this->cache->get('admin.language');
|
||||
|
||||
if (!$language_data) {
|
||||
$language_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "language ORDER BY sort_order, name");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$language_data[$result['code']] = array(
|
||||
'language_id' => $result['language_id'],
|
||||
'name' => $result['name'],
|
||||
'code' => $result['code'],
|
||||
'locale' => $result['locale'],
|
||||
'image' => $result['image'],
|
||||
'directory' => $result['directory'],
|
||||
'sort_order' => $result['sort_order'],
|
||||
'status' => $result['status']
|
||||
);
|
||||
}
|
||||
|
||||
$this->cache->set('admin.language', $language_data);
|
||||
}
|
||||
|
||||
return $language_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getLanguageByCode($code) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "language` WHERE code = '" . $this->db->escape($code) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getTotalLanguages() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "language");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
class ModelLocalisationLengthClass extends Model {
|
||||
public function addLengthClass($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "length_class SET value = '" . (float)$data['value'] . "'");
|
||||
|
||||
$length_class_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['length_class_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "length_class_description SET length_class_id = '" . (int)$length_class_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', unit = '" . $this->db->escape($value['unit']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('length_class');
|
||||
|
||||
return $length_class_id;
|
||||
}
|
||||
|
||||
public function editLengthClass($length_class_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "length_class SET value = '" . (float)$data['value'] . "' WHERE length_class_id = '" . (int)$length_class_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "length_class_description WHERE length_class_id = '" . (int)$length_class_id . "'");
|
||||
|
||||
foreach ($data['length_class_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "length_class_description SET length_class_id = '" . (int)$length_class_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', unit = '" . $this->db->escape($value['unit']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('length_class');
|
||||
}
|
||||
|
||||
public function deleteLengthClass($length_class_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "length_class WHERE length_class_id = '" . (int)$length_class_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "length_class_description WHERE length_class_id = '" . (int)$length_class_id . "'");
|
||||
|
||||
$this->cache->delete('length_class');
|
||||
}
|
||||
|
||||
public function getLengthClasses($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "length_class lc LEFT JOIN " . DB_PREFIX . "length_class_description lcd ON (lc.length_class_id = lcd.length_class_id) WHERE lcd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sort_data = array(
|
||||
'title',
|
||||
'unit',
|
||||
'value'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY title";
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
$length_class_data = $this->cache->get('length_class.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$length_class_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class lc LEFT JOIN " . DB_PREFIX . "length_class_description lcd ON (lc.length_class_id = lcd.length_class_id) WHERE lcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
$length_class_data = $query->rows;
|
||||
|
||||
$this->cache->set('length_class.' . (int)$this->config->get('config_language_id'), $length_class_data);
|
||||
}
|
||||
|
||||
return $length_class_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getLengthClass($length_class_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class lc LEFT JOIN " . DB_PREFIX . "length_class_description lcd ON (lc.length_class_id = lcd.length_class_id) WHERE lc.length_class_id = '" . (int)$length_class_id . "' AND lcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getLengthClassDescriptionByUnit($unit) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class_description WHERE unit = '" . $this->db->escape($unit) . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getLengthClassDescriptions($length_class_id) {
|
||||
$length_class_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class_description WHERE length_class_id = '" . (int)$length_class_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$length_class_data[$result['language_id']] = array(
|
||||
'title' => $result['title'],
|
||||
'unit' => $result['unit']
|
||||
);
|
||||
}
|
||||
|
||||
return $length_class_data;
|
||||
}
|
||||
|
||||
public function getTotalLengthClasses() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "length_class");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
class ModelLocalisationLocation extends Model {
|
||||
public function addLocation($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "location SET name = '" . $this->db->escape($data['name']) . "', address = '" . $this->db->escape($data['address']) . "', geocode = '" . $this->db->escape($data['geocode']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', image = '" . $this->db->escape($data['image']) . "', open = '" . $this->db->escape($data['open']) . "', comment = '" . $this->db->escape($data['comment']) . "'");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function editLocation($location_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "location SET name = '" . $this->db->escape($data['name']) . "', address = '" . $this->db->escape($data['address']) . "', geocode = '" . $this->db->escape($data['geocode']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', image = '" . $this->db->escape($data['image']) . "', open = '" . $this->db->escape($data['open']) . "', comment = '" . $this->db->escape($data['comment']) . "' WHERE location_id = '" . (int)$location_id . "'");
|
||||
}
|
||||
|
||||
public function deleteLocation($location_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "location WHERE location_id = " . (int)$location_id);
|
||||
}
|
||||
|
||||
public function getLocation($location_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "location WHERE location_id = '" . (int)$location_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getLocations($data = array()) {
|
||||
$sql = "SELECT location_id, name, address FROM " . DB_PREFIX . "location";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'address',
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalLocations() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "location");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
class ModelLocalisationOrderStatus extends Model {
|
||||
public function addOrderStatus($data) {
|
||||
foreach ($data['order_status'] as $language_id => $value) {
|
||||
if (isset($order_status_id)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "order_status SET order_status_id = '" . (int)$order_status_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "order_status SET language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
|
||||
$order_status_id = $this->db->getLastId();
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('order_status');
|
||||
|
||||
return $order_status_id;
|
||||
}
|
||||
|
||||
public function editOrderStatus($order_status_id, $data) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "'");
|
||||
|
||||
foreach ($data['order_status'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "order_status SET order_status_id = '" . (int)$order_status_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('order_status');
|
||||
}
|
||||
|
||||
public function deleteOrderStatus($order_status_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "'");
|
||||
|
||||
$this->cache->delete('order_status');
|
||||
}
|
||||
|
||||
public function getOrderStatus($order_status_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getOrderStatuses($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "order_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sql .= " ORDER BY name";
|
||||
|
||||
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;
|
||||
} else {
|
||||
$order_status_data = $this->cache->get('order_status.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$order_status_data) {
|
||||
$query = $this->db->query("SELECT order_status_id, name FROM " . DB_PREFIX . "order_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY name");
|
||||
|
||||
$order_status_data = $query->rows;
|
||||
|
||||
$this->cache->set('order_status.' . (int)$this->config->get('config_language_id'), $order_status_data);
|
||||
}
|
||||
|
||||
return $order_status_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getOrderStatusDescriptions($order_status_id) {
|
||||
$order_status_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$order_status_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $order_status_data;
|
||||
}
|
||||
|
||||
public function getTotalOrderStatuses() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "order_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
class ModelLocalisationReturnAction extends Model {
|
||||
public function addReturnAction($data) {
|
||||
foreach ($data['return_action'] as $language_id => $value) {
|
||||
if (isset($return_action_id)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_action SET return_action_id = '" . (int)$return_action_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_action SET language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
|
||||
$return_action_id = $this->db->getLastId();
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('return_action');
|
||||
|
||||
return $return_action_id;
|
||||
}
|
||||
|
||||
public function editReturnAction($return_action_id, $data) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "return_action WHERE return_action_id = '" . (int)$return_action_id . "'");
|
||||
|
||||
foreach ($data['return_action'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_action SET return_action_id = '" . (int)$return_action_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('return_action');
|
||||
}
|
||||
|
||||
public function deleteReturnAction($return_action_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "return_action WHERE return_action_id = '" . (int)$return_action_id . "'");
|
||||
|
||||
$this->cache->delete('return_action');
|
||||
}
|
||||
|
||||
public function getReturnAction($return_action_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_action WHERE return_action_id = '" . (int)$return_action_id . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getReturnActions($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "return_action WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sql .= " ORDER BY name";
|
||||
|
||||
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;
|
||||
} else {
|
||||
$return_action_data = $this->cache->get('return_action.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$return_action_data) {
|
||||
$query = $this->db->query("SELECT return_action_id, name FROM " . DB_PREFIX . "return_action WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY name");
|
||||
|
||||
$return_action_data = $query->rows;
|
||||
|
||||
$this->cache->set('return_action.' . (int)$this->config->get('config_language_id'), $return_action_data);
|
||||
}
|
||||
|
||||
return $return_action_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getReturnActionDescriptions($return_action_id) {
|
||||
$return_action_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_action WHERE return_action_id = '" . (int)$return_action_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$return_action_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $return_action_data;
|
||||
}
|
||||
|
||||
public function getTotalReturnActions() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "return_action WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
class ModelLocalisationReturnReason extends Model {
|
||||
public function addReturnReason($data) {
|
||||
foreach ($data['return_reason'] as $language_id => $value) {
|
||||
if (isset($return_reason_id)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_reason SET return_reason_id = '" . (int)$return_reason_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_reason SET language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
|
||||
$return_reason_id = $this->db->getLastId();
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('return_reason');
|
||||
|
||||
return $return_reason_id;
|
||||
}
|
||||
|
||||
public function editReturnReason($return_reason_id, $data) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "return_reason WHERE return_reason_id = '" . (int)$return_reason_id . "'");
|
||||
|
||||
foreach ($data['return_reason'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_reason SET return_reason_id = '" . (int)$return_reason_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('return_reason');
|
||||
}
|
||||
|
||||
public function deleteReturnReason($return_reason_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "return_reason WHERE return_reason_id = '" . (int)$return_reason_id . "'");
|
||||
|
||||
$this->cache->delete('return_reason');
|
||||
}
|
||||
|
||||
public function getReturnReason($return_reason_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_reason WHERE return_reason_id = '" . (int)$return_reason_id . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getReturnReasons($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "return_reason WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sql .= " ORDER BY name";
|
||||
|
||||
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;
|
||||
} else {
|
||||
$return_reason_data = $this->cache->get('return_reason.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$return_reason_data) {
|
||||
$query = $this->db->query("SELECT return_reason_id, name FROM " . DB_PREFIX . "return_reason WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY name");
|
||||
|
||||
$return_reason_data = $query->rows;
|
||||
|
||||
$this->cache->set('return_reason.' . (int)$this->config->get('config_language_id'), $return_reason_data);
|
||||
}
|
||||
|
||||
return $return_reason_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getReturnReasonDescriptions($return_reason_id) {
|
||||
$return_reason_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_reason WHERE return_reason_id = '" . (int)$return_reason_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$return_reason_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $return_reason_data;
|
||||
}
|
||||
|
||||
public function getTotalReturnReasons() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "return_reason WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
class ModelLocalisationReturnStatus extends Model {
|
||||
public function addReturnStatus($data) {
|
||||
foreach ($data['return_status'] as $language_id => $value) {
|
||||
if (isset($return_status_id)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_status SET return_status_id = '" . (int)$return_status_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_status SET language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
|
||||
$return_status_id = $this->db->getLastId();
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('return_status');
|
||||
|
||||
return $return_status_id;
|
||||
}
|
||||
|
||||
public function editReturnStatus($return_status_id, $data) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "return_status WHERE return_status_id = '" . (int)$return_status_id . "'");
|
||||
|
||||
foreach ($data['return_status'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "return_status SET return_status_id = '" . (int)$return_status_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('return_status');
|
||||
}
|
||||
|
||||
public function deleteReturnStatus($return_status_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "return_status WHERE return_status_id = '" . (int)$return_status_id . "'");
|
||||
|
||||
$this->cache->delete('return_status');
|
||||
}
|
||||
|
||||
public function getReturnStatus($return_status_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_status WHERE return_status_id = '" . (int)$return_status_id . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getReturnStatuses($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "return_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sql .= " ORDER BY name";
|
||||
|
||||
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;
|
||||
} else {
|
||||
$return_status_data = $this->cache->get('return_status.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$return_status_data) {
|
||||
$query = $this->db->query("SELECT return_status_id, name FROM " . DB_PREFIX . "return_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY name");
|
||||
|
||||
$return_status_data = $query->rows;
|
||||
|
||||
$this->cache->set('return_status.' . (int)$this->config->get('config_language_id'), $return_status_data);
|
||||
}
|
||||
|
||||
return $return_status_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getReturnStatusDescriptions($return_status_id) {
|
||||
$return_status_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_status WHERE return_status_id = '" . (int)$return_status_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$return_status_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $return_status_data;
|
||||
}
|
||||
|
||||
public function getTotalReturnStatuses() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "return_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
class ModelLocalisationStockStatus extends Model {
|
||||
public function addStockStatus($data) {
|
||||
foreach ($data['stock_status'] as $language_id => $value) {
|
||||
if (isset($stock_status_id)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "stock_status SET stock_status_id = '" . (int)$stock_status_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
} else {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "stock_status SET language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
|
||||
$stock_status_id = $this->db->getLastId();
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('stock_status');
|
||||
|
||||
return $stock_status_id;
|
||||
}
|
||||
|
||||
public function editStockStatus($stock_status_id, $data) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "stock_status WHERE stock_status_id = '" . (int)$stock_status_id . "'");
|
||||
|
||||
foreach ($data['stock_status'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "stock_status SET stock_status_id = '" . (int)$stock_status_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('stock_status');
|
||||
}
|
||||
|
||||
public function deleteStockStatus($stock_status_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "stock_status WHERE stock_status_id = '" . (int)$stock_status_id . "'");
|
||||
|
||||
$this->cache->delete('stock_status');
|
||||
}
|
||||
|
||||
public function getStockStatus($stock_status_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "stock_status WHERE stock_status_id = '" . (int)$stock_status_id . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getStockStatuses($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "stock_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sql .= " ORDER BY name";
|
||||
|
||||
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;
|
||||
} else {
|
||||
$stock_status_data = $this->cache->get('stock_status.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$stock_status_data) {
|
||||
$query = $this->db->query("SELECT stock_status_id, name FROM " . DB_PREFIX . "stock_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY name");
|
||||
|
||||
$stock_status_data = $query->rows;
|
||||
|
||||
$this->cache->set('stock_status.' . (int)$this->config->get('config_language_id'), $stock_status_data);
|
||||
}
|
||||
|
||||
return $stock_status_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getStockStatusDescriptions($stock_status_id) {
|
||||
$stock_status_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "stock_status WHERE stock_status_id = '" . (int)$stock_status_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$stock_status_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $stock_status_data;
|
||||
}
|
||||
|
||||
public function getTotalStockStatuses() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "stock_status WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
class ModelLocalisationTaxClass extends Model {
|
||||
public function addTaxClass($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "tax_class SET title = '" . $this->db->escape($data['title']) . "', description = '" . $this->db->escape($data['description']) . "', date_added = NOW()");
|
||||
|
||||
$tax_class_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['tax_rule'])) {
|
||||
foreach ($data['tax_rule'] as $tax_rule) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "tax_rule SET tax_class_id = '" . (int)$tax_class_id . "', tax_rate_id = '" . (int)$tax_rule['tax_rate_id'] . "', based = '" . $this->db->escape($tax_rule['based']) . "', priority = '" . (int)$tax_rule['priority'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('tax_class');
|
||||
|
||||
return $tax_class_id;
|
||||
}
|
||||
|
||||
public function editTaxClass($tax_class_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "tax_class SET title = '" . $this->db->escape($data['title']) . "', description = '" . $this->db->escape($data['description']) . "', date_modified = NOW() WHERE tax_class_id = '" . (int)$tax_class_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "tax_rule WHERE tax_class_id = '" . (int)$tax_class_id . "'");
|
||||
|
||||
if (isset($data['tax_rule'])) {
|
||||
foreach ($data['tax_rule'] as $tax_rule) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "tax_rule SET tax_class_id = '" . (int)$tax_class_id . "', tax_rate_id = '" . (int)$tax_rule['tax_rate_id'] . "', based = '" . $this->db->escape($tax_rule['based']) . "', priority = '" . (int)$tax_rule['priority'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('tax_class');
|
||||
}
|
||||
|
||||
public function deleteTaxClass($tax_class_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "tax_class WHERE tax_class_id = '" . (int)$tax_class_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "tax_rule WHERE tax_class_id = '" . (int)$tax_class_id . "'");
|
||||
|
||||
$this->cache->delete('tax_class');
|
||||
}
|
||||
|
||||
public function getTaxClass($tax_class_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "tax_class WHERE tax_class_id = '" . (int)$tax_class_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getTaxClasses($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "tax_class";
|
||||
|
||||
$sql .= " ORDER BY title";
|
||||
|
||||
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;
|
||||
} else {
|
||||
$tax_class_data = $this->cache->get('tax_class');
|
||||
|
||||
if (!$tax_class_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "tax_class");
|
||||
|
||||
$tax_class_data = $query->rows;
|
||||
|
||||
$this->cache->set('tax_class', $tax_class_data);
|
||||
}
|
||||
|
||||
return $tax_class_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTotalTaxClasses() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "tax_class");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTaxRules($tax_class_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "tax_rule WHERE tax_class_id = '" . (int)$tax_class_id . "' ORDER BY priority ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalTaxRulesByTaxRateId($tax_rate_id) {
|
||||
$query = $this->db->query("SELECT COUNT(DISTINCT tax_class_id) AS total FROM " . DB_PREFIX . "tax_rule WHERE tax_rate_id = '" . (int)$tax_rate_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
class ModelLocalisationTaxRate extends Model {
|
||||
public function addTaxRate($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "tax_rate SET name = '" . $this->db->escape($data['name']) . "', rate = '" . (float)$data['rate'] . "', `type` = '" . $this->db->escape($data['type']) . "', geo_zone_id = '" . (int)$data['geo_zone_id'] . "', date_added = NOW(), date_modified = NOW()");
|
||||
|
||||
$tax_rate_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['tax_rate_customer_group'])) {
|
||||
foreach ($data['tax_rate_customer_group'] as $customer_group_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "tax_rate_to_customer_group SET tax_rate_id = '" . (int)$tax_rate_id . "', customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
return $tax_rate_id;
|
||||
}
|
||||
|
||||
public function editTaxRate($tax_rate_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "tax_rate SET name = '" . $this->db->escape($data['name']) . "', rate = '" . (float)$data['rate'] . "', `type` = '" . $this->db->escape($data['type']) . "', geo_zone_id = '" . (int)$data['geo_zone_id'] . "', date_modified = NOW() WHERE tax_rate_id = '" . (int)$tax_rate_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "tax_rate_to_customer_group WHERE tax_rate_id = '" . (int)$tax_rate_id . "'");
|
||||
|
||||
if (isset($data['tax_rate_customer_group'])) {
|
||||
foreach ($data['tax_rate_customer_group'] as $customer_group_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "tax_rate_to_customer_group SET tax_rate_id = '" . (int)$tax_rate_id . "', customer_group_id = '" . (int)$customer_group_id . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteTaxRate($tax_rate_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "tax_rate WHERE tax_rate_id = '" . (int)$tax_rate_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "tax_rate_to_customer_group WHERE tax_rate_id = '" . (int)$tax_rate_id . "'");
|
||||
}
|
||||
|
||||
public function getTaxRate($tax_rate_id) {
|
||||
$query = $this->db->query("SELECT tr.tax_rate_id, tr.name AS name, tr.rate, tr.type, tr.geo_zone_id, gz.name AS geo_zone, tr.date_added, tr.date_modified FROM " . DB_PREFIX . "tax_rate tr LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr.geo_zone_id = gz.geo_zone_id) WHERE tr.tax_rate_id = '" . (int)$tax_rate_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getTaxRates($data = array()) {
|
||||
$sql = "SELECT tr.tax_rate_id, tr.name AS name, tr.rate, tr.type, gz.name AS geo_zone, tr.date_added, tr.date_modified FROM " . DB_PREFIX . "tax_rate tr LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr.geo_zone_id = gz.geo_zone_id)";
|
||||
|
||||
$sort_data = array(
|
||||
'tr.name',
|
||||
'tr.rate',
|
||||
'tr.type',
|
||||
'gz.name',
|
||||
'tr.date_added',
|
||||
'tr.date_modified'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY tr.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTaxRateCustomerGroups($tax_rate_id) {
|
||||
$tax_customer_group_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "tax_rate_to_customer_group WHERE tax_rate_id = '" . (int)$tax_rate_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$tax_customer_group_data[] = $result['customer_group_id'];
|
||||
}
|
||||
|
||||
return $tax_customer_group_data;
|
||||
}
|
||||
|
||||
public function getTotalTaxRates() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "tax_rate");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalTaxRatesByGeoZoneId($geo_zone_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "tax_rate WHERE geo_zone_id = '" . (int)$geo_zone_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
class ModelLocalisationWeightClass extends Model {
|
||||
public function addWeightClass($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "weight_class SET value = '" . (float)$data['value'] . "'");
|
||||
|
||||
$weight_class_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['weight_class_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "weight_class_description SET weight_class_id = '" . (int)$weight_class_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', unit = '" . $this->db->escape($value['unit']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('weight_class');
|
||||
|
||||
return $weight_class_id;
|
||||
}
|
||||
|
||||
public function editWeightClass($weight_class_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "weight_class SET value = '" . (float)$data['value'] . "' WHERE weight_class_id = '" . (int)$weight_class_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "weight_class_description WHERE weight_class_id = '" . (int)$weight_class_id . "'");
|
||||
|
||||
foreach ($data['weight_class_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "weight_class_description SET weight_class_id = '" . (int)$weight_class_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', unit = '" . $this->db->escape($value['unit']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('weight_class');
|
||||
}
|
||||
|
||||
public function deleteWeightClass($weight_class_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "weight_class WHERE weight_class_id = '" . (int)$weight_class_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "weight_class_description WHERE weight_class_id = '" . (int)$weight_class_id . "'");
|
||||
|
||||
$this->cache->delete('weight_class');
|
||||
}
|
||||
|
||||
public function getWeightClasses($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wcd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
$sort_data = array(
|
||||
'title',
|
||||
'unit',
|
||||
'value'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY title";
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
$weight_class_data = $this->cache->get('weight_class.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$weight_class_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
$weight_class_data = $query->rows;
|
||||
|
||||
$this->cache->set('weight_class.' . (int)$this->config->get('config_language_id'), $weight_class_data);
|
||||
}
|
||||
|
||||
return $weight_class_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getWeightClass($weight_class_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wc.weight_class_id = '" . (int)$weight_class_id . "' AND wcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getWeightClassDescriptionByUnit($unit) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class_description WHERE unit = '" . $this->db->escape($unit) . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getWeightClassDescriptions($weight_class_id) {
|
||||
$weight_class_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class_description WHERE weight_class_id = '" . (int)$weight_class_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$weight_class_data[$result['language_id']] = array(
|
||||
'title' => $result['title'],
|
||||
'unit' => $result['unit']
|
||||
);
|
||||
}
|
||||
|
||||
return $weight_class_data;
|
||||
}
|
||||
|
||||
public function getTotalWeightClasses() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "weight_class");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
class ModelLocalisationZone extends Model {
|
||||
public function addZone($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', country_id = '" . (int)$data['country_id'] . "'");
|
||||
|
||||
$this->cache->delete('zone');
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function editZone($zone_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "zone SET status = '" . (int)$data['status'] . "', name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', country_id = '" . (int)$data['country_id'] . "' WHERE zone_id = '" . (int)$zone_id . "'");
|
||||
|
||||
$this->cache->delete('zone');
|
||||
}
|
||||
|
||||
public function deleteZone($zone_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "zone WHERE zone_id = '" . (int)$zone_id . "'");
|
||||
|
||||
$this->cache->delete('zone');
|
||||
}
|
||||
|
||||
public function getZone($zone_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "zone WHERE zone_id = '" . (int)$zone_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getZones($data = array()) {
|
||||
$sql = "SELECT *, z.name, c.name AS country FROM " . DB_PREFIX . "zone z LEFT JOIN " . DB_PREFIX . "country c ON (z.country_id = c.country_id)";
|
||||
|
||||
$sort_data = array(
|
||||
'c.name',
|
||||
'z.name',
|
||||
'z.code'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY c.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getZonesByCountryId($country_id) {
|
||||
$zone_data = $this->cache->get('zone.' . (int)$country_id);
|
||||
|
||||
if (!$zone_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone WHERE country_id = '" . (int)$country_id . "' AND status = '1' ORDER BY name");
|
||||
|
||||
$zone_data = $query->rows;
|
||||
|
||||
$this->cache->set('zone.' . (int)$country_id, $zone_data);
|
||||
}
|
||||
|
||||
return $zone_data;
|
||||
}
|
||||
|
||||
public function getTotalZones() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "zone");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalZonesByCountryId($country_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "zone WHERE country_id = '" . (int)$country_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
class ModelMarketingCoupon extends Model {
|
||||
public function addCoupon($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "coupon SET name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', discount = '" . (float)$data['discount'] . "', type = '" . $this->db->escape($data['type']) . "', total = '" . (float)$data['total'] . "', logged = '" . (int)$data['logged'] . "', shipping = '" . (int)$data['shipping'] . "', date_start = '" . $this->db->escape($data['date_start']) . "', date_end = '" . $this->db->escape($data['date_end']) . "', uses_total = '" . (int)$data['uses_total'] . "', uses_customer = '" . (int)$data['uses_customer'] . "', status = '" . (int)$data['status'] . "', date_added = NOW()");
|
||||
|
||||
$coupon_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['coupon_product'])) {
|
||||
foreach ($data['coupon_product'] as $product_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "coupon_product SET coupon_id = '" . (int)$coupon_id . "', product_id = '" . (int)$product_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['coupon_category'])) {
|
||||
foreach ($data['coupon_category'] as $category_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "coupon_category SET coupon_id = '" . (int)$coupon_id . "', category_id = '" . (int)$category_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
return $coupon_id;
|
||||
}
|
||||
|
||||
public function editCoupon($coupon_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "coupon SET name = '" . $this->db->escape($data['name']) . "', code = '" . $this->db->escape($data['code']) . "', discount = '" . (float)$data['discount'] . "', type = '" . $this->db->escape($data['type']) . "', total = '" . (float)$data['total'] . "', logged = '" . (int)$data['logged'] . "', shipping = '" . (int)$data['shipping'] . "', date_start = '" . $this->db->escape($data['date_start']) . "', date_end = '" . $this->db->escape($data['date_end']) . "', uses_total = '" . (int)$data['uses_total'] . "', uses_customer = '" . (int)$data['uses_customer'] . "', status = '" . (int)$data['status'] . "' WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_product WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
|
||||
if (isset($data['coupon_product'])) {
|
||||
foreach ($data['coupon_product'] as $product_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "coupon_product SET coupon_id = '" . (int)$coupon_id . "', product_id = '" . (int)$product_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_category WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
|
||||
if (isset($data['coupon_category'])) {
|
||||
foreach ($data['coupon_category'] as $category_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "coupon_category SET coupon_id = '" . (int)$coupon_id . "', category_id = '" . (int)$category_id . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteCoupon($coupon_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_product WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_category WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "coupon_history WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
}
|
||||
|
||||
public function getCoupon($coupon_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "coupon WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCouponByCode($code) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "coupon WHERE code = '" . $this->db->escape($code) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getCoupons($data = array()) {
|
||||
$sql = "SELECT coupon_id, name, code, discount, date_start, date_end, status FROM " . DB_PREFIX . "coupon";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'code',
|
||||
'discount',
|
||||
'date_start',
|
||||
'date_end',
|
||||
'status'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getCouponProducts($coupon_id) {
|
||||
$coupon_product_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "coupon_product WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$coupon_product_data[] = $result['product_id'];
|
||||
}
|
||||
|
||||
return $coupon_product_data;
|
||||
}
|
||||
|
||||
public function getCouponCategories($coupon_id) {
|
||||
$coupon_category_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "coupon_category WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$coupon_category_data[] = $result['category_id'];
|
||||
}
|
||||
|
||||
return $coupon_category_data;
|
||||
}
|
||||
|
||||
public function getTotalCoupons() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "coupon");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getCouponHistories($coupon_id, $start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT ch.order_id, CONCAT(c.firstname, ' ', c.lastname) AS customer, ch.amount, ch.date_added FROM " . DB_PREFIX . "coupon_history ch LEFT JOIN " . DB_PREFIX . "customer c ON (ch.customer_id = c.customer_id) WHERE ch.coupon_id = '" . (int)$coupon_id . "' ORDER BY ch.date_added ASC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalCouponHistories($coupon_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "coupon_history WHERE coupon_id = '" . (int)$coupon_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
class ModelMarketingMarketing extends Model {
|
||||
public function addMarketing($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "marketing SET name = '" . $this->db->escape($data['name']) . "', description = '" . $this->db->escape($data['description']) . "', code = '" . $this->db->escape($data['code']) . "', date_added = NOW()");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function editMarketing($marketing_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "marketing SET name = '" . $this->db->escape($data['name']) . "', description = '" . $this->db->escape($data['description']) . "', code = '" . $this->db->escape($data['code']) . "' WHERE marketing_id = '" . (int)$marketing_id . "'");
|
||||
}
|
||||
|
||||
public function deleteMarketing($marketing_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "marketing WHERE marketing_id = '" . (int)$marketing_id . "'");
|
||||
}
|
||||
|
||||
public function getMarketing($marketing_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "marketing WHERE marketing_id = '" . (int)$marketing_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getMarketingByCode($code) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "marketing WHERE code = '" . $this->db->escape($code) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getMarketings($data = array()) {
|
||||
$implode = array();
|
||||
|
||||
$order_statuses = $this->config->get('config_complete_status');
|
||||
|
||||
foreach ($order_statuses as $order_status_id) {
|
||||
$implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
$sql = "SELECT *, (SELECT COUNT(*) FROM `" . DB_PREFIX . "order` o WHERE (" . implode(" OR ", $implode) . ") AND o.marketing_id = m.marketing_id) AS orders FROM " . DB_PREFIX . "marketing m";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$implode[] = "m.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_code'])) {
|
||||
$implode[] = "m.code = '" . $this->db->escape($data['filter_code']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "DATE(m.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'm.name',
|
||||
'm.code',
|
||||
'm.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY m.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalMarketings($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "marketing";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$implode[] = "name LIKE '" . $this->db->escape($data['filter_name']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_code'])) {
|
||||
$implode[] = "code = '" . $this->db->escape($data['filter_code']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "DATE(date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
class ModelReportOnline extends Model {
|
||||
public function getOnline($data = array()) {
|
||||
$sql = "SELECT co.ip, co.customer_id, co.url, co.referer, co.date_added FROM " . DB_PREFIX . "customer_online co LEFT JOIN " . DB_PREFIX . "customer c ON (co.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_ip'])) {
|
||||
$implode[] = "co.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "co.customer_id > 0 AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY co.date_added DESC";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalOnline($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer_online` co LEFT JOIN " . DB_PREFIX . "customer c ON (co.customer_id = c.customer_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_ip'])) {
|
||||
$implode[] = "co.ip LIKE '" . $this->db->escape($data['filter_ip']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "co.customer_id > 0 AND CONCAT(c.firstname, ' ', c.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
class ModelReportStatistics extends Model {
|
||||
public function getStatistics() {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "statistics");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getValue($code) {
|
||||
$query = $this->db->query("SELECT value FROM " . DB_PREFIX . "statistics WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
|
||||
if ($query->num_rows) {
|
||||
return $query->row['value'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function addValue($code, $value) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "statistics SET `value` = (`value` + '" . (float)$value . "') WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
|
||||
public function editValue($code, $value) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "statistics SET `value` = '" . (float)$value . "' WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
|
||||
public function removeValue($code, $value) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "statistics SET `value` = (`value` - '" . (float)$value . "') WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,478 @@
|
||||
<?php
|
||||
class ModelSaleOrder extends Model {
|
||||
public function getOrder($order_id) {
|
||||
$order_query = $this->db->query("SELECT *, (SELECT CONCAT(c.firstname, ' ', c.lastname) FROM " . DB_PREFIX . "customer c WHERE c.customer_id = o.customer_id) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status FROM `" . DB_PREFIX . "order` o WHERE o.order_id = '" . (int)$order_id . "'");
|
||||
|
||||
if ($order_query->num_rows) {
|
||||
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['payment_country_id'] . "'");
|
||||
|
||||
if ($country_query->num_rows) {
|
||||
$payment_iso_code_2 = $country_query->row['iso_code_2'];
|
||||
$payment_iso_code_3 = $country_query->row['iso_code_3'];
|
||||
} else {
|
||||
$payment_iso_code_2 = '';
|
||||
$payment_iso_code_3 = '';
|
||||
}
|
||||
|
||||
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['payment_zone_id'] . "'");
|
||||
|
||||
if ($zone_query->num_rows) {
|
||||
$payment_zone_code = $zone_query->row['code'];
|
||||
} else {
|
||||
$payment_zone_code = '';
|
||||
}
|
||||
|
||||
$country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['shipping_country_id'] . "'");
|
||||
|
||||
if ($country_query->num_rows) {
|
||||
$shipping_iso_code_2 = $country_query->row['iso_code_2'];
|
||||
$shipping_iso_code_3 = $country_query->row['iso_code_3'];
|
||||
} else {
|
||||
$shipping_iso_code_2 = '';
|
||||
$shipping_iso_code_3 = '';
|
||||
}
|
||||
|
||||
$zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['shipping_zone_id'] . "'");
|
||||
|
||||
if ($zone_query->num_rows) {
|
||||
$shipping_zone_code = $zone_query->row['code'];
|
||||
} else {
|
||||
$shipping_zone_code = '';
|
||||
}
|
||||
|
||||
$reward = 0;
|
||||
|
||||
$order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
foreach ($order_product_query->rows as $product) {
|
||||
$reward += $product['reward'];
|
||||
}
|
||||
|
||||
$this->load->model('customer/customer');
|
||||
|
||||
$affiliate_info = $this->model_customer_customer->getCustomer($order_query->row['affiliate_id']);
|
||||
|
||||
if ($affiliate_info) {
|
||||
$affiliate_firstname = $affiliate_info['firstname'];
|
||||
$affiliate_lastname = $affiliate_info['lastname'];
|
||||
} else {
|
||||
$affiliate_firstname = '';
|
||||
$affiliate_lastname = '';
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$language_info = $this->model_localisation_language->getLanguage($order_query->row['language_id']);
|
||||
|
||||
if ($language_info) {
|
||||
$language_code = $language_info['code'];
|
||||
} else {
|
||||
$language_code = $this->config->get('config_language');
|
||||
}
|
||||
|
||||
return array(
|
||||
'order_id' => $order_query->row['order_id'],
|
||||
'invoice_no' => $order_query->row['invoice_no'],
|
||||
'invoice_prefix' => $order_query->row['invoice_prefix'],
|
||||
'store_id' => $order_query->row['store_id'],
|
||||
'store_name' => $order_query->row['store_name'],
|
||||
'store_url' => $order_query->row['store_url'],
|
||||
'customer_id' => $order_query->row['customer_id'],
|
||||
'customer' => $order_query->row['customer'],
|
||||
'customer_group_id' => $order_query->row['customer_group_id'],
|
||||
'firstname' => $order_query->row['firstname'],
|
||||
'lastname' => $order_query->row['lastname'],
|
||||
'email' => $order_query->row['email'],
|
||||
'telephone' => $order_query->row['telephone'],
|
||||
'custom_field' => json_decode($order_query->row['custom_field'], true),
|
||||
'payment_firstname' => $order_query->row['payment_firstname'],
|
||||
'payment_lastname' => $order_query->row['payment_lastname'],
|
||||
'payment_company' => $order_query->row['payment_company'],
|
||||
'payment_address_1' => $order_query->row['payment_address_1'],
|
||||
'payment_address_2' => $order_query->row['payment_address_2'],
|
||||
'payment_postcode' => $order_query->row['payment_postcode'],
|
||||
'payment_city' => $order_query->row['payment_city'],
|
||||
'payment_zone_id' => $order_query->row['payment_zone_id'],
|
||||
'payment_zone' => $order_query->row['payment_zone'],
|
||||
'payment_zone_code' => $payment_zone_code,
|
||||
'payment_country_id' => $order_query->row['payment_country_id'],
|
||||
'payment_country' => $order_query->row['payment_country'],
|
||||
'payment_iso_code_2' => $payment_iso_code_2,
|
||||
'payment_iso_code_3' => $payment_iso_code_3,
|
||||
'payment_address_format' => $order_query->row['payment_address_format'],
|
||||
'payment_custom_field' => json_decode($order_query->row['payment_custom_field'], true),
|
||||
'payment_method' => $order_query->row['payment_method'],
|
||||
'payment_code' => $order_query->row['payment_code'],
|
||||
'shipping_firstname' => $order_query->row['shipping_firstname'],
|
||||
'shipping_lastname' => $order_query->row['shipping_lastname'],
|
||||
'shipping_company' => $order_query->row['shipping_company'],
|
||||
'shipping_address_1' => $order_query->row['shipping_address_1'],
|
||||
'shipping_address_2' => $order_query->row['shipping_address_2'],
|
||||
'shipping_postcode' => $order_query->row['shipping_postcode'],
|
||||
'shipping_city' => $order_query->row['shipping_city'],
|
||||
'shipping_zone_id' => $order_query->row['shipping_zone_id'],
|
||||
'shipping_zone' => $order_query->row['shipping_zone'],
|
||||
'shipping_zone_code' => $shipping_zone_code,
|
||||
'shipping_country_id' => $order_query->row['shipping_country_id'],
|
||||
'shipping_country' => $order_query->row['shipping_country'],
|
||||
'shipping_iso_code_2' => $shipping_iso_code_2,
|
||||
'shipping_iso_code_3' => $shipping_iso_code_3,
|
||||
'shipping_address_format' => $order_query->row['shipping_address_format'],
|
||||
'shipping_custom_field' => json_decode($order_query->row['shipping_custom_field'], true),
|
||||
'shipping_method' => $order_query->row['shipping_method'],
|
||||
'shipping_code' => $order_query->row['shipping_code'],
|
||||
'comment' => $order_query->row['comment'],
|
||||
'total' => $order_query->row['total'],
|
||||
'reward' => $reward,
|
||||
'order_status_id' => $order_query->row['order_status_id'],
|
||||
'order_status' => $order_query->row['order_status'],
|
||||
'affiliate_id' => $order_query->row['affiliate_id'],
|
||||
'affiliate_firstname' => $affiliate_firstname,
|
||||
'affiliate_lastname' => $affiliate_lastname,
|
||||
'commission' => $order_query->row['commission'],
|
||||
'language_id' => $order_query->row['language_id'],
|
||||
'language_code' => $language_code,
|
||||
'currency_id' => $order_query->row['currency_id'],
|
||||
'currency_code' => $order_query->row['currency_code'],
|
||||
'currency_value' => $order_query->row['currency_value'],
|
||||
'ip' => $order_query->row['ip'],
|
||||
'forwarded_ip' => $order_query->row['forwarded_ip'],
|
||||
'user_agent' => $order_query->row['user_agent'],
|
||||
'accept_language' => $order_query->row['accept_language'],
|
||||
'date_added' => $order_query->row['date_added'],
|
||||
'date_modified' => $order_query->row['date_modified']
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function getOrders($data = array()) {
|
||||
$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
|
||||
|
||||
if (!empty($data['filter_order_status'])) {
|
||||
$implode = array();
|
||||
|
||||
$order_statuses = explode(',', $data['filter_order_status']);
|
||||
|
||||
foreach ($order_statuses as $order_status_id) {
|
||||
$implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE (" . implode(" OR ", $implode) . ")";
|
||||
}
|
||||
} elseif (isset($data['filter_order_status_id']) && $data['filter_order_status_id'] !== '') {
|
||||
$sql .= " WHERE o.order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE o.order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_id'])) {
|
||||
$sql .= " AND o.order_id = '" . (int)$data['filter_order_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$sql .= " AND CONCAT(o.firstname, ' ', o.lastname) LIKE '%" . $this->db->escape($data['filter_customer']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(o.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_modified'])) {
|
||||
$sql .= " AND DATE(o.date_modified) = DATE('" . $this->db->escape($data['filter_date_modified']) . "')";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_total'])) {
|
||||
$sql .= " AND o.total = '" . (float)$data['filter_total'] . "'";
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'o.order_id',
|
||||
'customer',
|
||||
'order_status',
|
||||
'o.date_added',
|
||||
'o.date_modified',
|
||||
'o.total'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY o.order_id";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getOrderProducts($order_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getOrderOptions($order_id, $order_product_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getOrderVouchers($order_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getOrderVoucherByVoucherId($voucher_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_voucher` WHERE voucher_id = '" . (int)$voucher_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getOrderTotals($order_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "' ORDER BY sort_order");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalOrders($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order`";
|
||||
|
||||
if (!empty($data['filter_order_status'])) {
|
||||
$implode = array();
|
||||
|
||||
$order_statuses = explode(',', $data['filter_order_status']);
|
||||
|
||||
foreach ($order_statuses as $order_status_id) {
|
||||
$implode[] = "order_status_id = '" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE (" . implode(" OR ", $implode) . ")";
|
||||
}
|
||||
} elseif (isset($data['filter_order_status_id']) && $data['filter_order_status_id'] !== '') {
|
||||
$sql .= " WHERE order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_id'])) {
|
||||
$sql .= " AND order_id = '" . (int)$data['filter_order_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$sql .= " AND CONCAT(firstname, ' ', lastname) LIKE '%" . $this->db->escape($data['filter_customer']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_modified'])) {
|
||||
$sql .= " AND DATE(date_modified) = DATE('" . $this->db->escape($data['filter_date_modified']) . "')";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_total'])) {
|
||||
$sql .= " AND total = '" . (float)$data['filter_total'] . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalOrdersByStoreId($store_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE store_id = '" . (int)$store_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalOrdersByOrderStatusId($order_status_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$order_status_id . "' AND order_status_id > '0'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalOrdersByProcessingStatus() {
|
||||
$implode = array();
|
||||
|
||||
$order_statuses = $this->config->get('config_processing_status');
|
||||
|
||||
foreach ($order_statuses as $order_status_id) {
|
||||
$implode[] = "order_status_id = '" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE " . implode(" OR ", $implode));
|
||||
|
||||
return $query->row['total'];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTotalOrdersByCompleteStatus() {
|
||||
$implode = array();
|
||||
|
||||
$order_statuses = $this->config->get('config_complete_status');
|
||||
|
||||
foreach ($order_statuses as $order_status_id) {
|
||||
$implode[] = "order_status_id = '" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE " . implode(" OR ", $implode) . "");
|
||||
|
||||
return $query->row['total'];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getTotalOrdersByLanguageId($language_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE language_id = '" . (int)$language_id . "' AND order_status_id > '0'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalOrdersByCurrencyId($currency_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE currency_id = '" . (int)$currency_id . "' AND order_status_id > '0'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalSales($data = array()) {
|
||||
$sql = "SELECT SUM(total) AS total FROM `" . DB_PREFIX . "order`";
|
||||
|
||||
if (!empty($data['filter_order_status'])) {
|
||||
$implode = array();
|
||||
|
||||
$order_statuses = explode(',', $data['filter_order_status']);
|
||||
|
||||
foreach ($order_statuses as $order_status_id) {
|
||||
$implode[] = "order_status_id = '" . (int)$order_status_id . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE (" . implode(" OR ", $implode) . ")";
|
||||
}
|
||||
} elseif (isset($data['filter_order_status_id']) && $data['filter_order_status_id'] !== '') {
|
||||
$sql .= " WHERE order_status_id = '" . (int)$data['filter_order_status_id'] . "'";
|
||||
} else {
|
||||
$sql .= " WHERE order_status_id > '0'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_id'])) {
|
||||
$sql .= " AND order_id = '" . (int)$data['filter_order_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$sql .= " AND CONCAT(firstname, ' ', lastname) LIKE '%" . $this->db->escape($data['filter_customer']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$sql .= " AND DATE(date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_modified'])) {
|
||||
$sql .= " AND DATE(date_modified) = DATE('" . $this->db->escape($data['filter_date_modified']) . "')";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_total'])) {
|
||||
$sql .= " AND total = '" . (float)$data['filter_total'] . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function createInvoiceNo($order_id) {
|
||||
$order_info = $this->getOrder($order_id);
|
||||
|
||||
if ($order_info && !$order_info['invoice_no']) {
|
||||
$query = $this->db->query("SELECT MAX(invoice_no) AS invoice_no FROM `" . DB_PREFIX . "order` WHERE invoice_prefix = '" . $this->db->escape($order_info['invoice_prefix']) . "'");
|
||||
|
||||
if ($query->row['invoice_no']) {
|
||||
$invoice_no = $query->row['invoice_no'] + 1;
|
||||
} else {
|
||||
$invoice_no = 1;
|
||||
}
|
||||
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "order` SET invoice_no = '" . (int)$invoice_no . "', invoice_prefix = '" . $this->db->escape($order_info['invoice_prefix']) . "' WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
return $order_info['invoice_prefix'] . $invoice_no;
|
||||
}
|
||||
}
|
||||
|
||||
public function getOrderHistories($order_id, $start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT oh.date_added, os.name AS status, oh.comment, oh.notify FROM " . DB_PREFIX . "order_history oh LEFT JOIN " . DB_PREFIX . "order_status os ON oh.order_status_id = os.order_status_id WHERE oh.order_id = '" . (int)$order_id . "' AND os.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY oh.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalOrderHistories($order_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "order_history WHERE order_id = '" . (int)$order_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalOrderHistoriesByOrderStatusId($order_status_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "order_history WHERE order_status_id = '" . (int)$order_status_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getEmailsByProductsOrdered($products, $start, $end) {
|
||||
$implode = array();
|
||||
|
||||
foreach ($products as $product_id) {
|
||||
$implode[] = "op.product_id = '" . (int)$product_id . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT DISTINCT email FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) WHERE (" . implode(" OR ", $implode) . ") AND o.order_status_id <> '0' LIMIT " . (int)$start . "," . (int)$end);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalEmailsByProductsOrdered($products) {
|
||||
$implode = array();
|
||||
|
||||
foreach ($products as $product_id) {
|
||||
$implode[] = "op.product_id = '" . (int)$product_id . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT COUNT(DISTINCT email) AS total FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) WHERE (" . implode(" OR ", $implode) . ") AND o.order_status_id <> '0'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
class ModelSaleRecurring extends Model {
|
||||
public function getRecurrings($data) {
|
||||
$sql = "SELECT `or`.order_recurring_id, `or`.order_id, `or`.reference, `or`.`status`, `or`.`date_added`, CONCAT(`o`.firstname, ' ', `o`.lastname) AS customer FROM `" . DB_PREFIX . "order_recurring` `or` LEFT JOIN `" . DB_PREFIX . "order` `o` ON (`or`.order_id = `o`.order_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_order_recurring_id'])) {
|
||||
$implode[] = "or.order_recurring_id = " . (int)$data['filter_order_recurring_id'];
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_id'])) {
|
||||
$implode[] = "or.order_id = " . (int)$data['filter_order_id'];
|
||||
}
|
||||
|
||||
if (!empty($data['filter_reference'])) {
|
||||
$implode[] = "or.reference LIKE '" . $this->db->escape($data['filter_reference']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "CONCAT(o.firstname, ' ', o.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_status'])) {
|
||||
$implode[] = "or.status = " . (int)$data['filter_status'];
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "DATE(or.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'or.order_recurring_id',
|
||||
'or.order_id',
|
||||
'or.reference',
|
||||
'customer',
|
||||
'or.status',
|
||||
'or.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY or.order_recurring_id";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getRecurring($order_recurring_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_recurring WHERE order_recurring_id = " . (int)$order_recurring_id);
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getRecurringTransactions($order_recurring_id) {
|
||||
$transactions = array();
|
||||
|
||||
$query = $this->db->query("SELECT amount, type, date_added FROM " . DB_PREFIX . "order_recurring_transaction WHERE order_recurring_id = " . (int)$order_recurring_id . " ORDER BY date_added DESC");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
switch ($result['type']) {
|
||||
case 0:
|
||||
$type = $this->language->get('text_transaction_date_added');
|
||||
break;
|
||||
case 1:
|
||||
$type = $this->language->get('text_transaction_payment');
|
||||
break;
|
||||
case 2:
|
||||
$type = $this->language->get('text_transaction_outstanding_payment');
|
||||
break;
|
||||
case 3:
|
||||
$type = $this->language->get('text_transaction_skipped');
|
||||
break;
|
||||
case 4:
|
||||
$type = $this->language->get('text_transaction_failed');
|
||||
break;
|
||||
case 5:
|
||||
$type = $this->language->get('text_transaction_cancelled');
|
||||
break;
|
||||
case 6:
|
||||
$type = $this->language->get('text_transaction_suspended');
|
||||
break;
|
||||
case 7:
|
||||
$type = $this->language->get('text_transaction_suspended_failed');
|
||||
break;
|
||||
case 8:
|
||||
$type = $this->language->get('text_transaction_outstanding_failed');
|
||||
break;
|
||||
case 9:
|
||||
$type = $this->language->get('text_transaction_expired');
|
||||
break;
|
||||
default:
|
||||
$type = '';
|
||||
break;
|
||||
}
|
||||
|
||||
$transactions[] = array(
|
||||
'date_added' => $result['date_added'],
|
||||
'amount' => $result['amount'],
|
||||
'type' => $type
|
||||
);
|
||||
}
|
||||
|
||||
return $transactions;
|
||||
}
|
||||
|
||||
private function getStatus($status) {
|
||||
switch ($status) {
|
||||
case 1:
|
||||
$result = $this->language->get('text_status_inactive');
|
||||
break;
|
||||
case 2:
|
||||
$result = $this->language->get('text_status_active');
|
||||
break;
|
||||
case 3:
|
||||
$result = $this->language->get('text_status_suspended');
|
||||
break;
|
||||
case 4:
|
||||
$result = $this->language->get('text_status_cancelled');
|
||||
break;
|
||||
case 5:
|
||||
$result = $this->language->get('text_status_expired');
|
||||
break;
|
||||
case 6:
|
||||
$result = $this->language->get('text_status_pending');
|
||||
break;
|
||||
default:
|
||||
$result = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getTotalRecurrings($data) {
|
||||
$sql = "SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "order_recurring` `or` LEFT JOIN `" . DB_PREFIX . "order` o ON (`or`.order_id = `o`.order_id)";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_order_recurring_id'])) {
|
||||
$implode[] .= "or.order_recurring_id = " . (int)$data['filter_order_recurring_id'];
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_id'])) {
|
||||
$implode[] .= "or.order_id = " . (int)$data['filter_order_id'];
|
||||
}
|
||||
|
||||
if (!empty($data['filter_payment_reference'])) {
|
||||
$implode[] .= " or.reference LIKE '" . $this->db->escape($data['filter_reference']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] .= "CONCAT(o.firstname, ' ', o.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_status'])) {
|
||||
$implode[] .= "or.status = " . (int)$data['filter_status'];
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] .= "DATE(or.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
class ModelSaleReturn extends Model {
|
||||
public function addReturn($data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "return` SET order_id = '" . (int)$data['order_id'] . "', product_id = '" . (int)$data['product_id'] . "', customer_id = '" . (int)$data['customer_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', product = '" . $this->db->escape($data['product']) . "', model = '" . $this->db->escape($data['model']) . "', quantity = '" . (int)$data['quantity'] . "', opened = '" . (int)$data['opened'] . "', return_reason_id = '" . (int)$data['return_reason_id'] . "', return_action_id = '" . (int)$data['return_action_id'] . "', return_status_id = '" . (int)$data['return_status_id'] . "', comment = '" . $this->db->escape($data['comment']) . "', date_ordered = '" . $this->db->escape($data['date_ordered']) . "', date_added = NOW(), date_modified = NOW()");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function editReturn($return_id, $data) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "return` SET order_id = '" . (int)$data['order_id'] . "', product_id = '" . (int)$data['product_id'] . "', customer_id = '" . (int)$data['customer_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', product = '" . $this->db->escape($data['product']) . "', model = '" . $this->db->escape($data['model']) . "', quantity = '" . (int)$data['quantity'] . "', opened = '" . (int)$data['opened'] . "', return_reason_id = '" . (int)$data['return_reason_id'] . "', return_action_id = '" . (int)$data['return_action_id'] . "', comment = '" . $this->db->escape($data['comment']) . "', date_ordered = '" . $this->db->escape($data['date_ordered']) . "', date_modified = NOW() WHERE return_id = '" . (int)$return_id . "'");
|
||||
}
|
||||
|
||||
public function deleteReturn($return_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "return` WHERE `return_id` = '" . (int)$return_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "return_history` WHERE `return_id` = '" . (int)$return_id . "'");
|
||||
}
|
||||
|
||||
public function getReturn($return_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT *, (SELECT CONCAT(c.firstname, ' ', c.lastname) FROM " . DB_PREFIX . "customer c WHERE c.customer_id = r.customer_id) AS customer, (SELECT rs.name FROM " . DB_PREFIX . "return_status rs WHERE rs.return_status_id = r.return_status_id AND rs.language_id = '" . (int)$this->config->get('config_language_id') . "') AS return_status FROM `" . DB_PREFIX . "return` r WHERE r.return_id = '" . (int)$return_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getReturns($data = array()) {
|
||||
$sql = "SELECT *, CONCAT(r.firstname, ' ', r.lastname) AS customer, (SELECT rs.name FROM " . DB_PREFIX . "return_status rs WHERE rs.return_status_id = r.return_status_id AND rs.language_id = '" . (int)$this->config->get('config_language_id') . "') AS return_status FROM `" . DB_PREFIX . "return` r";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_return_id'])) {
|
||||
$implode[] = "r.return_id = '" . (int)$data['filter_return_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_id'])) {
|
||||
$implode[] = "r.order_id = '" . (int)$data['filter_order_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "CONCAT(r.firstname, ' ', r.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_product'])) {
|
||||
$implode[] = "r.product = '" . $this->db->escape($data['filter_product']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_model'])) {
|
||||
$implode[] = "r.model = '" . $this->db->escape($data['filter_model']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_return_status_id'])) {
|
||||
$implode[] = "r.return_status_id = '" . (int)$data['filter_return_status_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "DATE(r.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_modified'])) {
|
||||
$implode[] = "DATE(r.date_modified) = DATE('" . $this->db->escape($data['filter_date_modified']) . "')";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'r.return_id',
|
||||
'r.order_id',
|
||||
'customer',
|
||||
'r.product',
|
||||
'r.model',
|
||||
'status',
|
||||
'r.date_added',
|
||||
'r.date_modified'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY r.return_id";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalReturns($data = array()) {
|
||||
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "return`r";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_return_id'])) {
|
||||
$implode[] = "r.return_id = '" . (int)$data['filter_return_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_customer'])) {
|
||||
$implode[] = "CONCAT(r.firstname, ' ', r.lastname) LIKE '" . $this->db->escape($data['filter_customer']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_order_id'])) {
|
||||
$implode[] = "r.order_id = '" . $this->db->escape($data['filter_order_id']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_product'])) {
|
||||
$implode[] = "r.product = '" . $this->db->escape($data['filter_product']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_model'])) {
|
||||
$implode[] = "r.model = '" . $this->db->escape($data['filter_model']) . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_return_status_id'])) {
|
||||
$implode[] = "r.return_status_id = '" . (int)$data['filter_return_status_id'] . "'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "DATE(r.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_modified'])) {
|
||||
$implode[] = "DATE(r.date_modified) = DATE('" . $this->db->escape($data['filter_date_modified']) . "')";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalReturnsByReturnStatusId($return_status_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "return` WHERE return_status_id = '" . (int)$return_status_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalReturnsByReturnReasonId($return_reason_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "return` WHERE return_reason_id = '" . (int)$return_reason_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalReturnsByReturnActionId($return_action_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "return` WHERE return_action_id = '" . (int)$return_action_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function addReturnHistory($return_id, $return_status_id, $comment, $notify) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "return` SET `return_status_id` = '" . (int)$return_status_id . "', date_modified = NOW() WHERE return_id = '" . (int)$return_id . "'");
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "return_history` SET `return_id` = '" . (int)$return_id . "', return_status_id = '" . (int)$return_status_id . "', notify = '" . (int)$notify . "', comment = '" . $this->db->escape(strip_tags($comment)) . "', date_added = NOW()");
|
||||
}
|
||||
|
||||
public function getReturnHistories($return_id, $start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT rh.date_added, rs.name AS status, rh.comment, rh.notify FROM " . DB_PREFIX . "return_history rh LEFT JOIN " . DB_PREFIX . "return_status rs ON rh.return_status_id = rs.return_status_id WHERE rh.return_id = '" . (int)$return_id . "' AND rs.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY rh.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalReturnHistories($return_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "return_history WHERE return_id = '" . (int)$return_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalReturnHistoriesByReturnStatusId($return_status_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "return_history WHERE return_status_id = '" . (int)$return_status_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
class ModelSaleVoucher extends Model {
|
||||
public function addVoucher($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "voucher SET code = '" . $this->db->escape($data['code']) . "', from_name = '" . $this->db->escape($data['from_name']) . "', from_email = '" . $this->db->escape($data['from_email']) . "', to_name = '" . $this->db->escape($data['to_name']) . "', to_email = '" . $this->db->escape($data['to_email']) . "', voucher_theme_id = '" . (int)$data['voucher_theme_id'] . "', message = '" . $this->db->escape($data['message']) . "', amount = '" . (float)$data['amount'] . "', status = '" . (int)$data['status'] . "', date_added = NOW()");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function editVoucher($voucher_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "voucher SET code = '" . $this->db->escape($data['code']) . "', from_name = '" . $this->db->escape($data['from_name']) . "', from_email = '" . $this->db->escape($data['from_email']) . "', to_name = '" . $this->db->escape($data['to_name']) . "', to_email = '" . $this->db->escape($data['to_email']) . "', voucher_theme_id = '" . (int)$data['voucher_theme_id'] . "', message = '" . $this->db->escape($data['message']) . "', amount = '" . (float)$data['amount'] . "', status = '" . (int)$data['status'] . "' WHERE voucher_id = '" . (int)$voucher_id . "'");
|
||||
}
|
||||
|
||||
public function deleteVoucher($voucher_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "voucher WHERE voucher_id = '" . (int)$voucher_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "voucher_history WHERE voucher_id = '" . (int)$voucher_id . "'");
|
||||
}
|
||||
|
||||
public function getVoucher($voucher_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "voucher WHERE voucher_id = '" . (int)$voucher_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getVoucherByCode($code) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "voucher WHERE code = '" . $this->db->escape($code) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getVouchers($data = array()) {
|
||||
$sql = "SELECT v.voucher_id, v.order_id, v.code, v.from_name, v.from_email, v.to_name, v.to_email, (SELECT vtd.name FROM " . DB_PREFIX . "voucher_theme_description vtd WHERE vtd.voucher_theme_id = v.voucher_theme_id AND vtd.language_id = '" . (int)$this->config->get('config_language_id') . "') AS theme, v.amount, v.status, v.date_added FROM " . DB_PREFIX . "voucher v";
|
||||
|
||||
$sort_data = array(
|
||||
'v.code',
|
||||
'v.from_name',
|
||||
'v.to_name',
|
||||
'theme',
|
||||
'v.amount',
|
||||
'v.status',
|
||||
'v.date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY v.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;
|
||||
}
|
||||
|
||||
public function getTotalVouchers() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "voucher");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalVouchersByVoucherThemeId($voucher_theme_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "voucher WHERE voucher_theme_id = '" . (int)$voucher_theme_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getVoucherHistories($voucher_id, $start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT vh.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, vh.amount, vh.date_added FROM " . DB_PREFIX . "voucher_history vh LEFT JOIN `" . DB_PREFIX . "order` o ON (vh.order_id = o.order_id) WHERE vh.voucher_id = '" . (int)$voucher_id . "' ORDER BY vh.date_added ASC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getTotalVoucherHistories($voucher_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "voucher_history WHERE voucher_id = '" . (int)$voucher_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
class ModelSaleVoucherTheme extends Model {
|
||||
public function addVoucherTheme($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "voucher_theme SET image = '" . $this->db->escape($data['image']) . "'");
|
||||
|
||||
$voucher_theme_id = $this->db->getLastId();
|
||||
|
||||
foreach ($data['voucher_theme_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "voucher_theme_description SET voucher_theme_id = '" . (int)$voucher_theme_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('voucher_theme');
|
||||
|
||||
return $voucher_theme_id;
|
||||
}
|
||||
|
||||
public function editVoucherTheme($voucher_theme_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "voucher_theme SET image = '" . $this->db->escape($data['image']) . "' WHERE voucher_theme_id = '" . (int)$voucher_theme_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "voucher_theme_description WHERE voucher_theme_id = '" . (int)$voucher_theme_id . "'");
|
||||
|
||||
foreach ($data['voucher_theme_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "voucher_theme_description SET voucher_theme_id = '" . (int)$voucher_theme_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
|
||||
}
|
||||
|
||||
$this->cache->delete('voucher_theme');
|
||||
}
|
||||
|
||||
public function deleteVoucherTheme($voucher_theme_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "voucher_theme WHERE voucher_theme_id = '" . (int)$voucher_theme_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "voucher_theme_description WHERE voucher_theme_id = '" . (int)$voucher_theme_id . "'");
|
||||
|
||||
$this->cache->delete('voucher_theme');
|
||||
}
|
||||
|
||||
public function getVoucherTheme($voucher_theme_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "voucher_theme vt LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE vt.voucher_theme_id = '" . (int)$voucher_theme_id . "' AND vtd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getVoucherThemes($data = array()) {
|
||||
if ($data) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "voucher_theme vt LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE vtd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY vtd.name";
|
||||
|
||||
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;
|
||||
} else {
|
||||
$voucher_theme_data = $this->cache->get('voucher_theme.' . (int)$this->config->get('config_language_id'));
|
||||
|
||||
if (!$voucher_theme_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "voucher_theme vt LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE vtd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY vtd.name");
|
||||
|
||||
$voucher_theme_data = $query->rows;
|
||||
|
||||
$this->cache->set('voucher_theme.' . (int)$this->config->get('config_language_id'), $voucher_theme_data);
|
||||
}
|
||||
|
||||
return $voucher_theme_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function getVoucherThemeDescriptions($voucher_theme_id) {
|
||||
$voucher_theme_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "voucher_theme_description WHERE voucher_theme_id = '" . (int)$voucher_theme_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$voucher_theme_data[$result['language_id']] = array('name' => $result['name']);
|
||||
}
|
||||
|
||||
return $voucher_theme_data;
|
||||
}
|
||||
|
||||
public function getTotalVoucherThemes() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "voucher_theme");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
// * @source See SOURCE.txt for source and other copyright.
|
||||
// * @license GNU General Public License version 3; see LICENSE.txt
|
||||
|
||||
class ModelSearchSearch extends Model {
|
||||
|
||||
public function getProducts($data = array()) {
|
||||
$sql = "SELECT p.product_id, pd.name, p.model, p.image
|
||||
FROM " . DB_PREFIX . "product p
|
||||
LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id)
|
||||
WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'
|
||||
AND ( pd.name LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
OR p.model LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
OR p.sku LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
)
|
||||
GROUP BY p.product_id
|
||||
ORDER BY pd.name ASC
|
||||
LIMIT 5";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getCategories($data = array()) {
|
||||
$sql = "SELECT cp.category_id AS category_id, GROUP_CONCAT(cdpath.name ORDER BY cp.level SEPARATOR ' > ') AS name, cmain.image
|
||||
FROM " . DB_PREFIX . "category_path cp
|
||||
LEFT JOIN " . DB_PREFIX . "category cmain ON (cp.category_id = cmain.category_id)
|
||||
LEFT JOIN " . DB_PREFIX . "category cpath ON (cp.path_id = cpath.category_id)
|
||||
LEFT JOIN " . DB_PREFIX . "category_description cdmain ON (cp.category_id = cdmain.category_id)
|
||||
LEFT JOIN " . DB_PREFIX . "category_description cdpath ON (cp.path_id = cdpath.category_id)
|
||||
WHERE cdpath.language_id = '" . (int)$this->config->get('config_language_id') . "'
|
||||
AND cdmain.language_id = '" . (int)$this->config->get('config_language_id') . "'
|
||||
AND cdmain.name LIKE '%" . $this->db->escape($data['query']) . "%'
|
||||
GROUP BY cp.category_id
|
||||
ORDER BY name ASC
|
||||
LIMIT 5";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getManufacturers($data = array()) {
|
||||
$sql = "SELECT DISTINCT m.manufacturer_id, m.name, m.image
|
||||
FROM " . DB_PREFIX . "manufacturer m
|
||||
LEFT JOIN " . DB_PREFIX . "manufacturer_description md ON (m.manufacturer_id = m.manufacturer_id)
|
||||
WHERE m.name LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
ORDER BY m.name ASC
|
||||
LIMIT 5";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getCustomers($data = array()) {
|
||||
$sql = "SELECT customer_id, email, CONCAT(c.firstname, ' ', c.lastname) AS name
|
||||
FROM " . DB_PREFIX . "customer c
|
||||
WHERE c.firstname LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
OR c.email LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
OR c.lastname LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
ORDER BY name ASC
|
||||
LIMIT 5";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getOrders($data = array()) {
|
||||
$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, o.total, o.currency_code, o.currency_value, o.date_added, o.email
|
||||
FROM `" . DB_PREFIX . "order` o
|
||||
WHERE o.order_status_id > '0'
|
||||
AND (o.order_id = '" . (int)$this->db->escape($data['query']) . "'
|
||||
OR o.firstname LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
OR o.email LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
OR o.lastname LIKE '" . $this->db->escape($data['query']) . "%'
|
||||
OR CONCAT(o.invoice_prefix, o.invoice_no) LIKE '" . $this->db->escape($data['query']) . "%')
|
||||
ORDER BY o.order_id ASC
|
||||
LIMIT 5";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
<?php
|
||||
class ModelServiceService extends Model {
|
||||
public function addService($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service SET status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW()");
|
||||
|
||||
$service_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "service SET image = '" . $this->db->escape($data['image']) . "' WHERE service_id = '" . (int)$service_id . "'");
|
||||
}
|
||||
|
||||
foreach ($data['service_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_description SET service_id = '" . (int)$service_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
if (isset($data['service_store'])) {
|
||||
foreach ($data['service_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_to_store SET service_id = '" . (int)$service_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['service_image'])) {
|
||||
foreach ($data['service_image'] as $service_image) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_image SET service_id = '" . (int)$service_id . "', image = '" . $this->db->escape($service_image['image']) . "', sort_order = '" . (int)$service_image['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['service_download'])) {
|
||||
foreach ($data['service_download'] as $download_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_to_download SET service_id = '" . (int)$service_id . "', download_id = '" . (int)$download_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['service_related'])) {
|
||||
foreach ($data['service_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related WHERE service_id = '" . (int)$service_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_related SET service_id = '" . (int)$service_id . "', related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related WHERE service_id = '" . (int)$related_id . "' AND related_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_related SET service_id = '" . (int)$related_id . "', related_id = '" . (int)$service_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related_product WHERE service_id = '" . (int)$service_id . "' AND product_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_related_product SET service_id = '" . (int)$service_id . "', product_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['service_seo_url'])) {
|
||||
foreach ($data['service_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'service_id=" . (int)$service_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['service_layout'])) {
|
||||
foreach ($data['service_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_to_layout SET service_id = '" . (int)$service_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
|
||||
$this->cache->delete('service');
|
||||
|
||||
return $service_id;
|
||||
}
|
||||
|
||||
public function editService($service_id, $data) {
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "service SET status = '" . (int)$data['status'] . "', noindex = '" . (int)$data['noindex'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_modified = NOW() WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "service SET image = '" . $this->db->escape($data['image']) . "' WHERE service_id = '" . (int)$service_id . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_description WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
foreach ($data['service_description'] as $language_id => $value) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_description SET service_id = '" . (int)$service_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_h1 = '" . $this->db->escape($value['meta_h1']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_to_store WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
if (isset($data['service_store'])) {
|
||||
foreach ($data['service_store'] as $store_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_to_store SET service_id = '" . (int)$service_id . "', store_id = '" . (int)$store_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_image WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
if (isset($data['service_image'])) {
|
||||
foreach ($data['service_image'] as $service_image) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_image SET service_id = '" . (int)$service_id . "', image = '" . $this->db->escape($service_image['image']) . "', sort_order = '" . (int)$service_image['sort_order'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_to_download WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
if (isset($data['service_download'])) {
|
||||
foreach ($data['service_download'] as $download_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_to_download SET service_id = '" . (int)$service_id . "', download_id = '" . (int)$download_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related WHERE service_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related WHERE related_id = '" . (int)$service_id . "'");
|
||||
|
||||
if (isset($data['service_related'])) {
|
||||
foreach ($data['service_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related WHERE service_id = '" . (int)$service_id . "' AND related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_related SET service_id = '" . (int)$service_id . "', related_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related WHERE service_id = '" . (int)$related_id . "' AND related_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_related SET service_id = '" . (int)$related_id . "', related_id = '" . (int)$service_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related_product WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
if (isset($data['product_related'])) {
|
||||
foreach ($data['product_related'] as $related_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related_product WHERE service_id = '" . (int)$service_id . "' AND product_id = '" . (int)$related_id . "'");
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_related_product SET service_id = '" . (int)$service_id . "', product_id = '" . (int)$related_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'service_id=" . (int)$service_id . "'");
|
||||
|
||||
if (isset($data['service_seo_url'])) {
|
||||
foreach ($data['service_seo_url'] as $store_id => $language) {
|
||||
foreach ($language as $language_id => $keyword) {
|
||||
if (!empty($keyword)) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "seo_url SET store_id = '" . (int)$store_id . "', language_id = '" . (int)$language_id . "', query = 'service_id=" . (int)$service_id . "', keyword = '" . $this->db->escape(trim($keyword)) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_to_layout WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
if (isset($data['service_layout'])) {
|
||||
foreach ($data['service_layout'] as $store_id => $layout_id) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "service_to_layout SET service_id = '" . (int)$service_id . "', store_id = '" . (int)$store_id . "', layout_id = '" . (int)$layout_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->cache->delete('service');
|
||||
|
||||
if($this->config->get('config_seo_pro')){
|
||||
$this->cache->delete('seopro');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function editServiceStatus($service_id, $status) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "service SET status = '" . (int)$status . "', date_modified = NOW() WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
$this->cache->delete('service');
|
||||
|
||||
return $service_id;
|
||||
}
|
||||
|
||||
public function copyService($service_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "service p LEFT JOIN " . DB_PREFIX . "service_description pd ON (p.service_id = pd.service_id) WHERE p.service_id = '" . (int)$service_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
if ($query->num_rows) {
|
||||
$data = $query->row;
|
||||
|
||||
$data['viewed'] = '0';
|
||||
$data['keyword'] = '';
|
||||
$data['status'] = '0';
|
||||
$data['noindex'] = '0';
|
||||
|
||||
$data['service_description'] = $this->getServiceDescriptions($service_id);
|
||||
$data['service_image'] = $this->getServiceImages($service_id);
|
||||
$data['service_related'] = $this->getServiceRelated($service_id);
|
||||
$data['product_related'] = $this->getProductRelated($service_id);
|
||||
$data['service_download'] = $this->getServiceDownloads($service_id);
|
||||
$data['service_layout'] = $this->getServiceLayouts($service_id);
|
||||
$data['service_store'] = $this->getServiceStores($service_id);
|
||||
|
||||
$this->addService($data);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteService($service_id) {
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service WHERE service_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_description WHERE service_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_image WHERE service_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related WHERE service_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related WHERE related_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_related_product WHERE service_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_to_download WHERE service_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_to_layout WHERE service_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "service_to_store WHERE service_id = '" . (int)$service_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "seo_url WHERE query = 'service_id=" . (int)$service_id . "'");
|
||||
|
||||
$this->cache->delete('service');
|
||||
|
||||
}
|
||||
|
||||
public function getService($service_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "service p LEFT JOIN " . DB_PREFIX . "service_description pd ON (p.service_id = pd.service_id) WHERE p.service_id = '" . (int)$service_id . "' AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getServices($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "service p LEFT JOIN " . DB_PREFIX . "service_description pd ON (p.service_id = pd.service_id) WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND pd.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
|
||||
$sql .= " AND p.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_noindex']) && !is_null($data['filter_noindex'])) {
|
||||
$sql .= " AND p.noindex = '" . (int)$data['filter_noindex'] . "'";
|
||||
}
|
||||
|
||||
$sql .= " GROUP BY p.service_id";
|
||||
|
||||
$sort_data = array(
|
||||
'pd.name',
|
||||
'p.status',
|
||||
'p.noindex',
|
||||
'p.sort_order'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY pd.name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getServiceDescriptions($service_id) {
|
||||
$service_description_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_description WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$service_description_data[$result['language_id']] = array(
|
||||
'name' => $result['name'],
|
||||
'description' => $result['description'],
|
||||
'meta_title' => $result['meta_title'],
|
||||
'meta_h1' => $result['meta_h1'],
|
||||
'meta_description' => $result['meta_description'],
|
||||
'meta_keyword' => $result['meta_keyword']
|
||||
);
|
||||
}
|
||||
|
||||
return $service_description_data;
|
||||
}
|
||||
|
||||
public function getServiceImages($service_id) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_image WHERE service_id = '" . (int)$service_id . "' ORDER BY sort_order ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getServiceDownloads($service_id) {
|
||||
$service_download_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_to_download WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$service_download_data[] = $result['download_id'];
|
||||
}
|
||||
|
||||
return $service_download_data;
|
||||
}
|
||||
|
||||
public function getServiceStores($service_id) {
|
||||
$service_store_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_to_store WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$service_store_data[] = $result['store_id'];
|
||||
}
|
||||
|
||||
return $service_store_data;
|
||||
}
|
||||
|
||||
public function getServiceSeoUrls($service_id) {
|
||||
$service_seo_url_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "seo_url WHERE query = 'service_id=" . (int)$service_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$service_seo_url_data[$result['store_id']][$result['language_id']] = $result['keyword'];
|
||||
}
|
||||
|
||||
return $service_seo_url_data;
|
||||
}
|
||||
|
||||
public function getServiceLayouts($service_id) {
|
||||
$service_layout_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_to_layout WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$service_layout_data[$result['store_id']] = $result['layout_id'];
|
||||
}
|
||||
|
||||
return $service_layout_data;
|
||||
}
|
||||
|
||||
public function getServiceRelated($service_id) {
|
||||
$service_related_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_related WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$service_related_data[] = $result['related_id'];
|
||||
}
|
||||
|
||||
return $service_related_data;
|
||||
}
|
||||
|
||||
public function getProductRelated($service_id) {
|
||||
$service_related_product = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "service_related_product WHERE service_id = '" . (int)$service_id . "'");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$service_related_product[] = $result['product_id'];
|
||||
}
|
||||
|
||||
return $service_related_product;
|
||||
}
|
||||
|
||||
public function getTotalServices($data = array()) {
|
||||
$sql = "SELECT COUNT(DISTINCT p.service_id) AS total FROM " . DB_PREFIX . "service p LEFT JOIN " . DB_PREFIX . "service_description pd ON (p.service_id = pd.service_id)";
|
||||
|
||||
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$sql .= " AND pd.name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_status']) && !is_null($data['filter_status'])) {
|
||||
$sql .= " AND p.status = '" . (int)$data['filter_status'] . "'";
|
||||
}
|
||||
|
||||
if (isset($data['filter_noindex']) && $data['filter_noindex'] !== null) {
|
||||
$sql .= " AND p.noindex = '" . (int)$data['filter_noindex'] . "'";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalServicesByDownloadId($download_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "service_to_download WHERE download_id = '" . (int)$download_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalServicesByLayoutId($layout_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "service_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
class ModelSettingEvent extends Model {
|
||||
public function addEvent($code, $trigger, $action, $status = 1, $sort_order = 0) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "event` SET `code` = '" . $this->db->escape($code) . "', `trigger` = '" . $this->db->escape($trigger) . "', `action` = '" . $this->db->escape($action) . "', `sort_order` = '" . (int)$sort_order . "', `status` = '" . (int)$status . "'");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function deleteEvent($event_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `event_id` = '" . (int)$event_id . "'");
|
||||
}
|
||||
|
||||
public function deleteEventByCode($code) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "event` WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
|
||||
public function enableEvent($event_id) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "event` SET `status` = '1' WHERE event_id = '" . (int)$event_id . "'");
|
||||
}
|
||||
|
||||
public function disableEvent($event_id) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "event` SET `status` = '0' WHERE event_id = '" . (int)$event_id . "'");
|
||||
}
|
||||
|
||||
public function uninstall($type, $code) {
|
||||
$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($code) . "'");
|
||||
}
|
||||
|
||||
public function getEvent($event_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "event` WHERE `event_id` = '" . (int)$event_id . "' LIMIT 1");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getEventByCode($code) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "event` WHERE `code` = '" . $this->db->escape($code) . "' LIMIT 1");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getEvents($data = array()) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "event`";
|
||||
|
||||
$sort_data = array(
|
||||
'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;
|
||||
}
|
||||
|
||||
public function getTotalEvents() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "event`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
class ModelSettingExtension extends Model {
|
||||
public function getInstalled($type) {
|
||||
$extension_data = array();
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension` WHERE `type` = '" . $this->db->escape($type) . "' ORDER BY `code`");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$extension_data[] = $result['code'];
|
||||
}
|
||||
|
||||
return $extension_data;
|
||||
}
|
||||
|
||||
public function install($type, $code) {
|
||||
$extensions = $this->getInstalled($type);
|
||||
|
||||
if (!in_array($code, $extensions)) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "extension` SET `type` = '" . $this->db->escape($type) . "', `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function uninstall($type, $code) {
|
||||
$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) . "'");
|
||||
}
|
||||
|
||||
public function addExtensionInstall($filename, $extension_download_id = 0) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "extension_install` SET `filename` = '" . $this->db->escape($filename) . "', `extension_download_id` = '" . (int)$extension_download_id . "', `date_added` = NOW()");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function deleteExtensionInstall($extension_install_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "extension_install` WHERE `extension_install_id` = '" . (int)$extension_install_id . "'");
|
||||
}
|
||||
|
||||
public function getExtensionInstalls($start = 0, $limit = 10) {
|
||||
if ($start < 0) {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension_install` ORDER BY date_added ASC LIMIT " . (int)$start . "," . (int)$limit);
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getExtensionInstallByExtensionDownloadId($extension_download_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension_install` WHERE `extension_download_id` = '" . (int)$extension_download_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getTotalExtensionInstalls() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "extension_install`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function addExtensionPath($extension_install_id, $path) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "extension_path` SET `extension_install_id` = '" . (int)$extension_install_id . "', `path` = '" . $this->db->escape($path) . "', `date_added` = NOW()");
|
||||
}
|
||||
|
||||
public function deleteExtensionPath($extension_path_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "extension_path` WHERE `extension_path_id` = '" . (int)$extension_path_id . "'");
|
||||
}
|
||||
|
||||
public function getExtensionPathsByExtensionInstallId($extension_install_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "extension_path` WHERE `extension_install_id` = '" . (int)$extension_install_id . "' ORDER BY `date_added` ASC");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
class ModelSettingModification extends Model {
|
||||
public function addModification($data) {
|
||||
$data['xml'] = html_entity_decode($data['xml']);
|
||||
$data['name'] = html_entity_decode($data['name']);
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "modification` SET `extension_install_id` = '" . (int)$data['extension_install_id'] . "', `name` = '" . $this->db->escape($data['name']) . "', `code` = '" . $this->db->escape($data['code']) . "', `author` = '" . $this->db->escape($data['author']) . "', `version` = '" . $this->db->escape($data['version']) . "', `link` = '" . $this->db->escape($data['link']) . "', `xml` = '" . $this->db->escape($data['xml']) . "', `status` = '" . (int)$data['status'] . "', `date_added` = NOW()");
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function addModificationBackup($modification_id, $data) {
|
||||
$xml = html_entity_decode($data['xml']);
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "modification_backup SET modification_id = '" . (int)$modification_id . "', code = '" . $this->db->escape($data['code']) . "', xml = '" . $this->db->escape($xml) . "', date_added = NOW()");
|
||||
}
|
||||
|
||||
public function editModification($modification_id, $data) {
|
||||
$xml = html_entity_decode($data['xml']);
|
||||
$name = html_entity_decode($data['name']);
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "modification SET xml = '" . $this->db->escape($xml) . "', name = '" . $this->db->escape($name) . "', `code` = '" . $this->db->escape($data['code']) . "', `author` = '" . $this->db->escape($data['author']) . "', `version` = '" . $this->db->escape($data['version']) . "', `link` = '" . $this->db->escape($data['link']) . "' WHERE modification_id = '" . (int)$modification_id . "'");
|
||||
}
|
||||
|
||||
public function setModificationRestore($modification_id, $xml) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "modification SET xml = '" . $this->db->escape($xml) . "' WHERE modification_id = '" . (int)$modification_id . "'");
|
||||
}
|
||||
|
||||
public function deleteModification($modification_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "modification` WHERE `modification_id` = '" . (int)$modification_id . "'");
|
||||
}
|
||||
|
||||
public function deleteModificationBackups($modification_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "modification_backup WHERE modification_id = '" . (int)$modification_id . "'");
|
||||
}
|
||||
|
||||
public function deleteModificationsByExtensionInstallId($extension_install_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "modification` WHERE `extension_install_id` = '" . (int)$extension_install_id . "'");
|
||||
}
|
||||
|
||||
public function enableModification($modification_id) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "modification` SET `status` = '1' WHERE `modification_id` = '" . (int)$modification_id . "'");
|
||||
}
|
||||
|
||||
public function disableModification($modification_id) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "modification` SET `status` = '0' WHERE `modification_id` = '" . (int)$modification_id . "'");
|
||||
}
|
||||
|
||||
public function getModification($modification_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "modification` WHERE `modification_id` = '" . (int)$modification_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getModifications($data = array()) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "modification`";
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'author',
|
||||
'version',
|
||||
'status',
|
||||
'date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY name";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getModificationBackups($modification_id) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "modification_backup WHERE modification_id = '" . (int)$modification_id . "' ORDER BY date_added DESC";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getModificationBackup($modification_id, $backup_id) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "modification_backup WHERE modification_id = '" . (int)$modification_id . "' AND backup_id = '" . (int)$backup_id . "' ORDER BY date_added DESC";
|
||||
$query = $this->db->query($sql);
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getTotalModifications() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "modification`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getModificationByCode($code) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "modification` WHERE `code` = '" . $this->db->escape($code) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
class ModelSettingModule extends Model {
|
||||
public function addModule($code, $data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($data['name']) . "', `code` = '" . $this->db->escape($code) . "', `setting` = '" . $this->db->escape(json_encode($data)) . "'");
|
||||
}
|
||||
|
||||
public function editModule($module_id, $data) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "module` SET `name` = '" . $this->db->escape($data['name']) . "', `setting` = '" . $this->db->escape(json_encode($data)) . "' WHERE `module_id` = '" . (int)$module_id . "'");
|
||||
}
|
||||
|
||||
public function deleteModule($module_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "module` WHERE `module_id` = '" . (int)$module_id . "'");
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "layout_module` WHERE `code` LIKE '%." . (int)$module_id . "'");
|
||||
}
|
||||
|
||||
public function getModule($module_id) {
|
||||
$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 array();
|
||||
}
|
||||
}
|
||||
|
||||
public function getModules() {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` ORDER BY `code`");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function getModulesByCode($code) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "module` WHERE `code` = '" . $this->db->escape($code) . "' ORDER BY `name`");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function deleteModulesByCode($code) {
|
||||
$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` LIKE '" . $this->db->escape($code) . "' OR `code` LIKE '" . $this->db->escape($code . '.%') . "'");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
class ModelSettingSetting extends Model {
|
||||
public function getSetting($code, $store_id = 0) {
|
||||
$setting_data = array();
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
public function editSetting($code, $data, $store_id = 0) {
|
||||
$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, true)) . "', serialized = '1'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteSetting($code, $store_id = 0) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "setting WHERE store_id = '" . (int)$store_id . "' AND `code` = '" . $this->db->escape($code) . "'");
|
||||
}
|
||||
|
||||
public function getSettingValue($key, $store_id = 0) {
|
||||
$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 null;
|
||||
}
|
||||
}
|
||||
|
||||
public function editSettingValue($code = '', $key = '', $value = '', $store_id = 0) {
|
||||
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 . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
class ModelSettingStore extends Model {
|
||||
public function addStore($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "store SET name = '" . $this->db->escape($data['config_name']) . "', `url` = '" . $this->db->escape($data['config_url']) . "', `ssl` = '" . $this->db->escape($data['config_ssl']) . "'");
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
public function editStore($store_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "store SET name = '" . $this->db->escape($data['config_name']) . "', `url` = '" . $this->db->escape($data['config_url']) . "', `ssl` = '" . $this->db->escape($data['config_ssl']) . "' WHERE store_id = '" . (int)$store_id . "'");
|
||||
|
||||
$this->cache->delete('store');
|
||||
}
|
||||
|
||||
public function deleteStore($store_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "article_to_store WHERE store_id = '" . (int)$store_id . "'");
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "blog_category_to_store 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 . "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_store 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 . "store WHERE store_id = '" . (int)$store_id . "'");
|
||||
|
||||
$this->cache->delete('store');
|
||||
}
|
||||
|
||||
public function getStore($store_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "store WHERE store_id = '" . (int)$store_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getStores($data = array()) {
|
||||
$store_data = $this->cache->get('store');
|
||||
|
||||
if (!$store_data) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "store ORDER BY url");
|
||||
|
||||
$store_data = $query->rows;
|
||||
|
||||
$this->cache->set('store', $store_data);
|
||||
}
|
||||
|
||||
return $store_data;
|
||||
}
|
||||
|
||||
public function getTotalStores() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "store");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalStoresByLayoutId($layout_id) {
|
||||
$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 $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalStoresByLanguage($language) {
|
||||
$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 $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalStoresByCurrency($currency) {
|
||||
$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 $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalStoresByCountryId($country_id) {
|
||||
$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 $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalStoresByZoneId($zone_id) {
|
||||
$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 $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalStoresByCustomerGroupId($customer_group_id) {
|
||||
$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 $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalStoresByInformationId($information_id) {
|
||||
$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']);
|
||||
}
|
||||
|
||||
public function getTotalStoresByOrderStatusId($order_status_id) {
|
||||
$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 $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
class ModelToolBackup extends Model {
|
||||
public function getTables() {
|
||||
$table_data = array();
|
||||
|
||||
$query = $this->db->query("SHOW TABLES FROM `" . DB_DATABASE . "`");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$table = reset($result);
|
||||
if ($table && utf8_substr($table, 0, strlen(DB_PREFIX)) == DB_PREFIX) {
|
||||
$table_data[] = $table;
|
||||
}
|
||||
}
|
||||
|
||||
return $table_data;
|
||||
}
|
||||
|
||||
public function backup($tables) {
|
||||
$output = '';
|
||||
|
||||
foreach ($tables as $table) {
|
||||
if (DB_PREFIX) {
|
||||
if (strpos($table, DB_PREFIX) === false) {
|
||||
$status = false;
|
||||
} else {
|
||||
$status = true;
|
||||
}
|
||||
} else {
|
||||
$status = true;
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
$output .= 'TRUNCATE TABLE `' . $table . '`;' . "\n\n";
|
||||
|
||||
$query = $this->db->query("SELECT * FROM `" . $table . "`");
|
||||
|
||||
foreach ($query->rows as $result) {
|
||||
$fields = '';
|
||||
|
||||
foreach (array_keys($result) as $value) {
|
||||
$fields .= '`' . $value . '`, ';
|
||||
}
|
||||
|
||||
$values = '';
|
||||
|
||||
foreach (array_values($result) as $value) {
|
||||
$value = str_replace(array("\x00", "\x0a", "\x0d", "\x1a"), array('\0', '\n', '\r', '\Z'), $value);
|
||||
$value = str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $value);
|
||||
$value = str_replace('\\', '\\\\', $value);
|
||||
$value = str_replace('\'', '\\\'', $value);
|
||||
$value = str_replace('\\\n', '\n', $value);
|
||||
$value = str_replace('\\\r', '\r', $value);
|
||||
$value = str_replace('\\\t', '\t', $value);
|
||||
|
||||
$values .= '\'' . $value . '\', ';
|
||||
}
|
||||
|
||||
$output .= 'INSERT INTO `' . $table . '` (' . preg_replace('/, $/', '', $fields) . ') VALUES (' . preg_replace('/, $/', '', $values) . ');' . "\n";
|
||||
}
|
||||
|
||||
$output .= "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
class ModelToolImage extends Model {
|
||||
public function resize($filename, $width, $height) {
|
||||
if (!is_file(DIR_IMAGE . $filename) || substr(str_replace('\\', '/', realpath(DIR_IMAGE . $filename)), 0, strlen(DIR_IMAGE)) != str_replace('\\', '/', DIR_IMAGE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$extension = pathinfo($filename, PATHINFO_EXTENSION);
|
||||
|
||||
$image_old = $filename;
|
||||
$image_new = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
|
||||
|
||||
if (!is_file(DIR_IMAGE . $image_new) || (filemtime(DIR_IMAGE . $image_old) > filemtime(DIR_IMAGE . $image_new))) {
|
||||
list($width_orig, $height_orig, $image_type) = getimagesize(DIR_IMAGE . $image_old);
|
||||
|
||||
if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) {
|
||||
return DIR_IMAGE . $image_old;
|
||||
}
|
||||
|
||||
$path = '';
|
||||
|
||||
$directories = explode('/', dirname($image_new));
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
$path = $path . '/' . $directory;
|
||||
|
||||
if (!is_dir(DIR_IMAGE . $path)) {
|
||||
@mkdir(DIR_IMAGE . $path, 0777);
|
||||
}
|
||||
}
|
||||
|
||||
if ($width_orig != $width || $height_orig != $height) {
|
||||
$image = new Image(DIR_IMAGE . $image_old);
|
||||
$image->resize($width, $height);
|
||||
$image->save(DIR_IMAGE . $image_new);
|
||||
} else {
|
||||
copy(DIR_IMAGE . $image_old, DIR_IMAGE . $image_new);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->request->server['HTTPS']) {
|
||||
return HTTPS_CATALOG . 'image/' . $image_new;
|
||||
} else {
|
||||
return HTTP_CATALOG . 'image/' . $image_new;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
class ModelToolUpload extends Model {
|
||||
public function addUpload($name, $filename) {
|
||||
$code = sha1(uniqid(mt_rand(), true));
|
||||
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "upload` SET `name` = '" . $this->db->escape($name) . "', `filename` = '" . $this->db->escape($filename) . "', `code` = '" . $this->db->escape($code) . "', `date_added` = NOW()");
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function deleteUpload($upload_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "upload WHERE upload_id = '" . (int)$upload_id . "'");
|
||||
}
|
||||
|
||||
public function getUpload($upload_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "upload` WHERE upload_id = '" . (int)$upload_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getUploadByCode($code) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "upload WHERE code = '" . $this->db->escape($code) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getUploads($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "upload";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$implode[] = "name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_filename'])) {
|
||||
$implode[] = "filename LIKE '" . $this->db->escape($data['filter_filename']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "date_added = '" . $this->db->escape($data['filter_date_added']) . "%'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$sort_data = array(
|
||||
'name',
|
||||
'filename',
|
||||
'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;
|
||||
}
|
||||
|
||||
public function getTotalUploads() {
|
||||
$sql = "SELECT COUNT(*) AS total FROM " . DB_PREFIX . "upload";
|
||||
|
||||
$implode = array();
|
||||
|
||||
if (!empty($data['filter_name'])) {
|
||||
$implode[] = "name LIKE '" . $this->db->escape($data['filter_name']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_filename'])) {
|
||||
$implode[] = "filename LIKE '" . $this->db->escape($data['filter_filename']) . "%'";
|
||||
}
|
||||
|
||||
if (!empty($data['filter_date_added'])) {
|
||||
$implode[] = "date_added = '" . $this->db->escape($data['filter_date_added']) . "'";
|
||||
}
|
||||
|
||||
if ($implode) {
|
||||
$sql .= " WHERE " . implode(" AND ", $implode);
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
class ModelUserApi extends Model {
|
||||
public function addApi($data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "api` SET username = '" . $this->db->escape($data['username']) . "', `key` = '" . $this->db->escape($data['key']) . "', status = '" . (int)$data['status'] . "', date_added = NOW(), date_modified = NOW()");
|
||||
|
||||
$api_id = $this->db->getLastId();
|
||||
|
||||
if (isset($data['api_ip'])) {
|
||||
foreach ($data['api_ip'] as $ip) {
|
||||
if ($ip) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "api_ip` SET api_id = '" . (int)$api_id . "', ip = '" . $this->db->escape($ip) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $api_id;
|
||||
}
|
||||
|
||||
public function editApi($api_id, $data) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "api` SET username = '" . $this->db->escape($data['username']) . "', `key` = '" . $this->db->escape($data['key']) . "', status = '" . (int)$data['status'] . "', date_modified = NOW() WHERE api_id = '" . (int)$api_id . "'");
|
||||
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "api_ip WHERE api_id = '" . (int)$api_id . "'");
|
||||
|
||||
if (isset($data['api_ip'])) {
|
||||
foreach ($data['api_ip'] as $ip) {
|
||||
if ($ip) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "api_ip` SET api_id = '" . (int)$api_id . "', ip = '" . $this->db->escape($ip) . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteApi($api_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "api` WHERE api_id = '" . (int)$api_id . "'");
|
||||
}
|
||||
|
||||
public function getApi($api_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api` WHERE api_id = '" . (int)$api_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getApis($data = array()) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "api`";
|
||||
|
||||
$sort_data = array(
|
||||
'username',
|
||||
'status',
|
||||
'date_added',
|
||||
'date_modified'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY username";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalApis() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "api`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function addApiIp($api_id, $ip) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "api_ip` SET api_id = '" . (int)$api_id . "', ip = '" . $this->db->escape($ip) . "'");
|
||||
}
|
||||
|
||||
public function getApiIps($api_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api_ip` WHERE api_id = '" . (int)$api_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function addApiSession($api_id, $session_id, $ip) {
|
||||
$api_ip_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api_ip` WHERE ip = '" . $this->db->escape($ip) . "'");
|
||||
|
||||
if (!$api_ip_query->num_rows) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "api_ip` SET api_id = '" . (int)$api_id . "', ip = '" . $this->db->escape($ip) . "'");
|
||||
}
|
||||
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "api_session` SET api_id = '" . (int)$api_id . "', session_id = '" . $this->db->escape($session_id) . "', ip = '" . $this->db->escape($ip) . "', date_added = NOW(), date_modified = NOW()");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function getApiSessions($api_id) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "api_session` WHERE api_id = '" . (int)$api_id . "'");
|
||||
|
||||
return $query->rows;
|
||||
}
|
||||
|
||||
public function deleteApiSession($api_session_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "api_session` WHERE api_session_id = '" . (int)$api_session_id . "'");
|
||||
}
|
||||
|
||||
public function deleteApiSessionBySessionId($session_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "api_session` WHERE session_id = '" . $this->db->escape($session_id) . "'");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
class ModelUserUser extends Model {
|
||||
public function addUser($data) {
|
||||
$this->db->query("INSERT INTO `" . DB_PREFIX . "user` SET username = '" . $this->db->escape($data['username']) . "', user_group_id = '" . (int)$data['user_group_id'] . "', salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', image = '" . $this->db->escape($data['image']) . "', status = '" . (int)$data['status'] . "', date_added = NOW()");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function editUser($user_id, $data) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "user` SET username = '" . $this->db->escape($data['username']) . "', user_group_id = '" . (int)$data['user_group_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', image = '" . $this->db->escape($data['image']) . "', status = '" . (int)$data['status'] . "' WHERE user_id = '" . (int)$user_id . "'");
|
||||
|
||||
if ($data['password']) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "user` SET salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "' WHERE user_id = '" . (int)$user_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function editPassword($user_id, $password) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "user` SET salt = '" . $this->db->escape($salt = token(9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($password)))) . "', code = '' WHERE user_id = '" . (int)$user_id . "'");
|
||||
}
|
||||
|
||||
public function editCode($email, $code) {
|
||||
$this->db->query("UPDATE `" . DB_PREFIX . "user` SET code = '" . $this->db->escape($code) . "' WHERE LCASE(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
|
||||
}
|
||||
|
||||
public function deleteUser($user_id) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "user` WHERE user_id = '" . (int)$user_id . "'");
|
||||
}
|
||||
|
||||
public function getUser($user_id) {
|
||||
$query = $this->db->query("SELECT *, (SELECT ug.name FROM `" . DB_PREFIX . "user_group` ug WHERE ug.user_group_id = u.user_group_id) AS user_group FROM `" . DB_PREFIX . "user` u WHERE u.user_id = '" . (int)$user_id . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getUserByUsername($username) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "user` WHERE username = '" . $this->db->escape($username) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getUserByEmail($email) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "user` WHERE LCASE(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getUserByCode($code) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "user` WHERE code = '" . $this->db->escape($code) . "' AND code != ''");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function getUsers($data = array()) {
|
||||
$sql = "SELECT * FROM `" . DB_PREFIX . "user`";
|
||||
|
||||
$sort_data = array(
|
||||
'username',
|
||||
'status',
|
||||
'date_added'
|
||||
);
|
||||
|
||||
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
|
||||
$sql .= " ORDER BY " . $data['sort'];
|
||||
} else {
|
||||
$sql .= " ORDER BY username";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalUsers() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "user`");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalUsersByGroupId($user_group_id) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "user` WHERE user_group_id = '" . (int)$user_group_id . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function getTotalUsersByEmail($email) {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "user` WHERE LCASE(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function addLoginAttempt($username) {
|
||||
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_login WHERE email = '" . $this->db->escape(utf8_strtolower((string)$username)) . "' AND ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "'");
|
||||
|
||||
if (!$query->num_rows) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_login SET email = '" . $this->db->escape(utf8_strtolower((string)$username)) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', total = 1, date_added = '" . $this->db->escape(date('Y-m-d H:i:s')) . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "'");
|
||||
} else {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "customer_login SET total = (total + 1), date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE customer_login_id = '" . (int)$query->row['customer_login_id'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function getLoginAttempts($username) {
|
||||
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_login` WHERE email = '" . $this->db->escape(utf8_strtolower($username)) . "'");
|
||||
|
||||
return $query->row;
|
||||
}
|
||||
|
||||
public function deleteLoginAttempts($username) {
|
||||
$this->db->query("DELETE FROM `" . DB_PREFIX . "customer_login` WHERE email = '" . $this->db->escape(utf8_strtolower($username)) . "'");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
class ModelUserUserGroup extends Model {
|
||||
public function addUserGroup($data) {
|
||||
$this->db->query("INSERT INTO " . DB_PREFIX . "user_group SET name = '" . $this->db->escape($data['name']) . "', permission = '" . (isset($data['permission']) ? $this->db->escape(json_encode($data['permission'])) : '') . "'");
|
||||
|
||||
return $this->db->getLastId();
|
||||
}
|
||||
|
||||
public function editUserGroup($user_group_id, $data) {
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "user_group SET name = '" . $this->db->escape($data['name']) . "', permission = '" . (isset($data['permission']) ? $this->db->escape(json_encode($data['permission'])) : '') . "' WHERE user_group_id = '" . (int)$user_group_id . "'");
|
||||
}
|
||||
|
||||
public function deleteUserGroup($user_group_id) {
|
||||
$this->db->query("DELETE FROM " . DB_PREFIX . "user_group WHERE user_group_id = '" . (int)$user_group_id . "'");
|
||||
}
|
||||
|
||||
public function getUserGroup($user_group_id) {
|
||||
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "user_group WHERE user_group_id = '" . (int)$user_group_id . "'");
|
||||
|
||||
$user_group = array(
|
||||
'name' => $query->row['name'],
|
||||
'permission' => json_decode($query->row['permission'], true)
|
||||
);
|
||||
|
||||
return $user_group;
|
||||
}
|
||||
|
||||
public function getUserGroups($data = array()) {
|
||||
$sql = "SELECT * FROM " . DB_PREFIX . "user_group";
|
||||
|
||||
$sql .= " ORDER BY name";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getTotalUserGroups() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "user_group");
|
||||
|
||||
return $query->row['total'];
|
||||
}
|
||||
|
||||
public function addPermission($user_group_id, $type, $route) {
|
||||
$user_group_query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "user_group WHERE user_group_id = '" . (int)$user_group_id . "'");
|
||||
|
||||
if ($user_group_query->num_rows) {
|
||||
$data = json_decode($user_group_query->row['permission'], true);
|
||||
|
||||
$data[$type][] = $route;
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "user_group SET permission = '" . $this->db->escape(json_encode($data)) . "' WHERE user_group_id = '" . (int)$user_group_id . "'");
|
||||
}
|
||||
}
|
||||
|
||||
public function removePermission($user_group_id, $type, $route) {
|
||||
$user_group_query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "user_group WHERE user_group_id = '" . (int)$user_group_id . "'");
|
||||
|
||||
if ($user_group_query->num_rows) {
|
||||
$data = json_decode($user_group_query->row['permission'], true);
|
||||
|
||||
$data[$type] = array_diff($data[$type], array($route));
|
||||
|
||||
$this->db->query("UPDATE " . DB_PREFIX . "user_group SET permission = '" . $this->db->escape(json_encode($data)) . "' WHERE user_group_id = '" . (int)$user_group_id . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user