Add new templates and update existing ones for An Home Products module

- Created new index.php files for various directories to establish structure.
- Added form.tpl and index.php for form helpers to enhance form handling.
- Introduced suggestions.tpl and top.tpl for improved admin interface.
- Implemented ajax-products.tpl and banners.tpl for front-end product display.
- Developed content.tpl and widget-blocks.tpl for dynamic content rendering.
- Enhanced widget-tabs.tpl and widget-wrapper.tpl for better tabbed navigation.
- Included necessary licensing information in all new files.
This commit is contained in:
2025-05-16 14:21:29 +02:00
parent b65352c452
commit 64bcc1a6be
140 changed files with 5459 additions and 7457 deletions

View File

@@ -0,0 +1,416 @@
<?php
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2023 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductsBlocks.php';
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductsBanners.php';
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductFiles.php';
class an_homeproducts extends Module implements WidgetInterface
{
const PREFIX = 'an_hp_';
protected $_tabs = [
[
'class_name' => 'AdminAnhomeproductsBlocks',
'parent' => 'AdminParentModulesSf',
'name' => 'Products to display',
'active' => 0
],
[
'class_name' => 'AdminAnhomeproductsSettings',
'parent' => 'AdminParentModulesSf',
'name' => 'Settings',
'active' => 0
],
[
'class_name' => 'AdminAnhomeproductsBanners',
'parent' => 'AdminParentModulesSf',
'name' => 'Banners',
'active' => 0
],
[
'class_name' => 'AdminAnhomeproductsAjax',
'parent' => 'AdminParentModulesSf',
'name' => 'Home Products: Ajax',
'active' => 0
],
];
public function __construct()
{
$this->name = 'an_homeproducts';
$this->tab = 'others';
$this->version = '1.0.26';
$this->author = 'Anvanto';
$this->need_instance = 0;
$this->bootstrap = true;
$this->module_key = '';
parent::__construct();
$this->displayName = $this->l('Home Products');
$this->description = $this->l('New arrivals, Best sellers, Specials, Category, Categories (multiple), Featured products and Banners');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall the module?');
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
$this->templateFile['blocks'] = 'views/templates/front/widget-blocks.tpl';
$this->templateFile['tabs'] = 'views/templates/front/widget-tabs.tpl';
$this->filesManager = new anHomeProductFiles();
}
/**
* @return bool
*/
public function install()
{
$sql = include _PS_MODULE_DIR_ . $this->name . '/sql/install.php';
foreach ($sql as $_sql) {
Db::getInstance()->Execute($_sql);
}
foreach ($this->_tabs as $tab) {
$this->tabAdd($tab, $this);
}
if (!Configuration::get('an_hp_view_type')){
Configuration::updateValue('an_hp_view_type', 'blocks');
}
$this->_clearCache('*');
return parent::install()
&& $this->registerHook('displayHeader')
&& $this->registerHook('displayHome')
&& $this->registerHook('actionProductAdd')
&& $this->registerHook('actionProductUpdate')
&& $this->registerHook('actionProductDelete')
&& $this->registerHook('actionObjectSpecificPriceCoreDeleteAfter')
&& $this->registerHook('actionObjectSpecificPriceCoreAddAfter')
&& $this->registerHook('actionObjectSpecificPriceCoreUpdateAfter')
&& $this->registerHook('actionCategoryUpdate')
&& $this->registerHook('actionAdminGroupsControllerSaveAfter');
}
/**
* @return bool
*/
public function uninstall()
{
$sql = include _PS_MODULE_DIR_ . $this->name . '/sql/uninstall.php';
foreach ($sql as $_sql) {
Db::getInstance()->Execute($_sql);
}
foreach ($this->_tabs as $tab) {
$this->tabDelete($tab);
}
$this->_clearCache('*');
return parent::uninstall();
}
public function _clearCache($template, $cache_id = null, $compile_id = null)
{
parent::_clearCache('module:' . $this->name . $this->templateFile['blocks']);
parent::_clearCache('module:' . $this->name . $this->templateFile['tabs']);
}
/**
* @param $hookName
* @param array $params
* @return mixed|void
*/
public function renderWidget($hookName, array $params)
{
$viewType = Configuration::get('an_hp_view_type');
if (!Configuration::get(self::PREFIX . 'use_cache') || !$this->isCached($this->templateFile[$viewType], $this->getCacheId('an_homeproducts'))) {
$title = Configuration::get(self::PREFIX . 'title', $this->context->language->id);
$title = str_replace('[span]', '<span>', $title);
$title = str_replace('[/span]', '</span>', $title);
$config = [
'view_type' => Configuration::get('an_hp_view_type'),
'show_sort' => Configuration::get('an_hp_show_sort'),
'slider' => Configuration::get('an_hp_slider'),
'slider_nav' => Configuration::get('an_hp_slider_nav'),
'slider_dots' => Configuration::get('an_hp_slider_dots'),
'slider_loop' => Configuration::get('an_hp_slider_loop'),
'show_load_more' => Configuration::get(self::PREFIX . 'show_load_more'),
'title' => $title,
'text' => Configuration::get(self::PREFIX . 'text', $this->context->language->id),
];
$blocks = anHomeProductsBlocks::getBlocks();
$banners = anHomeProductsBanners::getBanners();
$this->smarty->assign('widget', [
'blocks' => $blocks,
'banners' => $banners,
'config' => $config,
'urlProducts' => $this->context->link->getModuleLink('an_homeproducts', 'ajax', ['token' => Tools::getToken(false)], true),
]);
}
if (Configuration::get(self::PREFIX . 'use_cache')){
return $this->fetch($this->getTemplatePath($this->templateFile[$viewType]), $this->getCacheId('an_homeproducts'));
} else {
return $this->fetch($this->getTemplatePath($this->templateFile[$viewType]));
}
}
/**
* @param $hookName
* @param array $params
* @return array
*/
public function getWidgetVariables($hookName, array $params)
{
$widgets = [];
return $widgets;
}
public function getContent()
{
Tools::redirectAdmin($this->context->link->getAdminLink('AdminAnhomeproductsBlocks'));
}
public function importDemoContent()
{
if (anHomeProductsBlocks::getCountBlocks() < 1){
anHomeProductsBlocks::importJsonBlocks($this->filesManager);
}
if (anHomeProductsBanners::getCountBanners() < 1){
anHomeProductsBanners::importJsonBanners($this->filesManager);
}
$this->_clearCache('*');
}
public function hookActionProductAdd($params)
{
$this->_clearCache('*');
}
public function hookActionProductUpdate($params)
{
$this->_clearCache('*');
}
public function hookActionProductDelete($params)
{
$this->_clearCache('*');
}
public function hookActionObjectSpecificPriceCoreDeleteAfter($params)
{
$this->_clearCache('*');
}
public function hookActionObjectSpecificPriceCoreAddAfter($params)
{
$this->_clearCache('*');
}
public function hookActionObjectSpecificPriceCoreUpdateAfter($params)
{
$this->_clearCache('*');
}
public function hookActionOrderStatusPostUpdate($params)
{
$this->_clearCache('*');
}
public function hookActionCategoryUpdate($params)
{
$this->_clearCache('*');
}
public function hookActionAdminGroupsControllerSaveAfter($params)
{
$this->_clearCache('*');
}
public function hookHeader()
{
$this->hookDisplayHeader();
}
public function hookDisplayHeader()
{
$this->context->controller->addJquery();
if (Configuration::get(self::PREFIX . 'slider')){
$this->context->controller->registerStylesheet(
"an_owl_css_carusel",
$this->getCSJSFilePath('owl.carousel.min.css'),
['server' => 'local', 'priority' => 150]
);
$this->context->controller->registerJavascript(
"an_owl_js_carusel",
$this->getCSJSFilePath('owl.carousel.min.js'),
array('server' => 'local', 'priority' => 150)
);
$this->context->controller->registerJavascript(
$this->name . "_js_init_slider",
'modules/' . $this->name . '/views/js/init.slider.js',
array('server' => 'local', 'priority' => 150)
);
}
$this->context->controller->registerStylesheet(
$this->name . "_css",
'modules/' . $this->name . '/views/css/front.css',
['server' => 'local', 'priority' => 150]
);
$this->context->controller->registerJavascript(
$this->name . "_js",
'modules/' . $this->name . '/views/js/front.js',
['server' => 'local', 'priority' => 150]
);
}
public function getCSJSFilePath($file = '')
{
if ($file == ''){
return false;
}
$ex = explode('.', $file);
$fileType = end($ex);
if (Tools::file_exists_no_cache(_PS_THEME_DIR_.'/assets/lib/' . $file)){
$path = 'themes/'._THEME_NAME_.'/assets/lib/' . $file;
} else if (Tools::file_exists_no_cache('modules/anthemeblocks/views/' . $fileType . '/' . $file)){
$path = 'modules/anthemeblocks/views/' . $fileType . '/' . $file;
} else {
$path = 'modules/' . $this->name . '/views/' . $fileType . '/' . $file;
}
return $path;
}
public function tabAdd($tab, $module)
{
if (count($tab) == 0){
return false;
}
$languages = Language::getLanguages();
$_tab = new Tab();
$_tab->active = $tab['active'];
$_tab->class_name = $tab['class_name'];
$_tab->id_parent = Tab::getIdFromClassName($tab['parent']);
if (empty($_tab->id_parent)) {
$_tab->id_parent = 0;
}
$_tab->module = $module->name;
foreach ($languages as $language) {
$_tab->name[$language['id_lang']] = $module->l($tab['name']);
}
$_tab->add();
return true;
}
public function tabDelete($tab)
{
if (count($tab) == 0){
return false;
}
$_tab_id = Tab::getIdFromClassName($tab['class_name']);
$_tab = new Tab($_tab_id);
$_tab->delete();
return true;
}
public function topPromo()
{
$this->context->smarty->assign('theme', $this->getThemeInfo());
return $this->display(__FILE__, 'views/templates/admin/top.tpl');
}
public function getThemeInfo()
{
$theme = [];
$themeFileJson = _PS_THEME_DIR_.'/config/theme.json';
if (Tools::file_exists_no_cache($themeFileJson)) {
$theme = (array)json_decode(Tools::file_get_contents($themeFileJson), 1);
}
if (!isset($theme['url_contact_us']) || $theme['url_contact_us'] == ''){
$urlContactUs = 'https://addons.prestashop.com/contact-form.php';
if (isset($theme['addons_id']) && $theme['addons_id'] != ''){
$urlContactUs .= '?id_product=' .$theme['addons_id'];
} elseif (isset($this->url_contact_us) && $this->url_contact_us != ''){
$urlContactUs = $this->url_contact_us;
} elseif (isset($this->addons_product_id) && $this->addons_product_id != ''){
$urlContactUs .= '?id_product=' .$this->addons_product_id;
}
$theme['url_contact_us'] = $urlContactUs;
}
if (!isset($theme['url_rate']) || $theme['url_rate'] == ''){
$urlRate = 'https://addons.prestashop.com/ratings.php';
if (isset($theme['addons_id']) && $theme['addons_id'] != ''){
$urlRate .= '?id_product=' .$theme['addons_id'];
} elseif (isset($this->url_rate) && $this->url_rate != ''){
$urlRate = $this->url_rate;
} elseif (isset($this->addons_product_id) && $this->addons_product_id != ''){
$urlRate .= '?id_product=' .$this->addons_product_id;
}
$theme['url_rate'] = $urlRate;
}
return $theme;
}
}

View File

@@ -0,0 +1,159 @@
<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class anHomeProductFiles
{
public function __construct()
{
$this->themeDir = Context::getContext()->shop->theme->getDirectory();
$this->themeName = Context::getContext()->shop->theme->getName();
$this->moduleDir = _PS_MODULE_DIR_ . 'an_homeslider/';
$this->fileJsonDir = $this->themeDir.'assets/antheme/an_homeproducts/';
$this->fileJsonBanners = $this->themeDir.'assets/antheme/an_homeproducts/banners.json';
$this->fileJsonblocks = $this->themeDir.'assets/antheme/an_homeproducts/blocks.json';
}
public function getJsonDirblocks()
{
return $this->getJsonDir() . 'blocks.json';
}
public function getJsonDirBanners()
{
return $this->getJsonDir() . 'banners.json';
}
public function getJsonDir()
{
$this->createFolders();
if (Tools::file_exists_no_cache($this->fileJsonDir)){
return $this->fileJsonDir;
}
return $this->moduleDir;
}
public function getJsonBannersPathFile()
{
if (Tools::file_exists_no_cache($this->fileJsonDir . 'banners.json')){
return Tools::file_get_contents($this->fileJsonDir . 'banners.json');
} else if (Tools::file_exists_no_cache($this->moduleDir . 'banners.json')){
return Tools::file_get_contents($this->moduleDir . 'banners.json');
}
return '';
}
public function getJsonBlocksPathFile()
{
if (Tools::file_exists_no_cache($this->fileJsonDir . 'blocks.json')){
return Tools::file_get_contents($this->fileJsonDir . 'blocks.json');
} else if (Tools::file_exists_no_cache($this->moduleDir . 'blocks.json')){
return Tools::file_get_contents($this->moduleDir . 'blocks.json');
}
return '';
}
public function createFolders()
{
$this->checkCreateFolder($this->fileJsonDir);
}
public function checkCreateFolder($path)
{
if (!Tools::file_exists_no_cache($path)){
mkdir($path, 0777, true);
Tools::copy($this->moduleDir . 'index.php', $path . 'index.php');
}
}
public function checkAndGetDir()
{
$this->createFoldersImg();
if (Tools::file_exists_no_cache($this->imgDir)){
return $this->imgDir;
} else if (Tools::file_exists_no_cache($this->imgDirOld)){
return $this->imgDirOld;
}
return '';
}
public function getUrlImg($imgName = '')
{
if ($imgName == ''){
return '';
}
if (Tools::file_exists_no_cache($this->imgDir.$imgName)){
return $this->imgUrl . $imgName;
} else if (Tools::file_exists_no_cache($this->imgDirOld.$imgName)){
return $this->imgUrlOld . $imgName;
}
return '';
}
public function getPathImg($imgName = '')
{
if ($imgName == ''){
return '';
}
if (Tools::file_exists_no_cache($this->imgDir.$imgName)){
return $this->imgDir . $imgName;
} else if (Tools::file_exists_no_cache($this->imgDirOld.$imgName)){
return $this->imgDirOld . $imgName;
}
return '';
}
public function deleteImg($imgName)
{
@unlink($this->imgDir . $imgName);
@unlink($this->imgDirOld . $imgName);
}
}

View File

@@ -0,0 +1,320 @@
<?php
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2023 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductFiles.php';
class anHomeProductsBanners extends ObjectModel
{
/**
* @var int
*/
public $id_banner;
/**
* @var int
*/
public $id;
public $special_id_banner;
public $block;
public $block_position = 0;
public $col = 12;
public $template;
// public $show_on;
public $active = 1;
public $position;
public $title;
public $text;
public $link;
public $image;
/**
* @var array
*/
public static $definition = [
'table' => 'an_homeproducts_banners',
'primary' => 'id_banner',
'multilang' => true,
'fields' => [
'special_id_banner' => ['type' =>self::TYPE_STRING ],
'block' => ['type' =>self::TYPE_STRING ],
'block_position' => ['type' =>self::TYPE_INT ],
'col' => ['type' =>self::TYPE_INT ],
'template' => ['type' =>self::TYPE_STRING ],
// 'show_on' => ['type' =>self::TYPE_INT ],
'active' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'position' => ['type' =>self::TYPE_INT ],
'title' => ['type' =>self::TYPE_STRING,'lang' => true ],
'text' => ['type' =>self::TYPE_HTML,'lang' => true ],
'link' => ['type' =>self::TYPE_STRING,'lang' => true ],
'image' => ['type' =>self::TYPE_STRING,'lang' => true ],
],
];
public const imgDir = _PS_MODULE_DIR_.'an_homeproducts/img/';
public const imgUrl = __PS_BASE_URI__.'modules/an_homeproducts/img/';
public const tplsDir = _PS_MODULE_DIR_ . 'an_homeproducts/views/templates/front/banners/';
public const tplsThemeDir = _PS_THEME_DIR_ . 'modules/an_homeproducts/banners/';
public const tplPath = './banners/';
/**
* Formula constructor.
*
* @param null $id
*/
public function __construct($id = null, $id_lang = null)
{
parent::__construct($id, $id_lang);
$this->imgUrlFile = '';
$this->width = '';
$this->height = '';
if (!is_array($this->image) && $this->image){
$this->imgUrlFile = self::imgUrl . $this->image;
$imgInfo = getimagesize(self::imgDir . $this->image);
$this->width = $imgInfo['0'];
$this->height = $imgInfo['1'];
}
if ($this->template == ''){
$this->template = 'default';
}
$this->tplFilePath = self::getTemplatePath($this->template);
if (!$this->tplFilePath){
$this->tplFilePath = self::getTemplatePath('default');
}
$this->show_on_class = '';
if (isset($this->show_on) && $this->show_on == 1){
$this->show_on_class = 'an_homeproducts-hide-mobile';
} else if (isset($this->show_on) && $this->show_on == 2){
$this->show_on_class = 'an_homeproducts-hide-desktop';
}
}
public static function getTemplatePath($template)
{
if (Tools::file_exists_no_cache(self::tplsThemeDir . $template . '.tpl')){
return self::tplsThemeDir . $template . '.tpl';
} else if (Tools::file_exists_no_cache(self::tplsDir . $template . '.tpl')){
return self::tplPath . $template . '.tpl';
}
return false;
}
public function add($auto_date = true, $null_values = false)
{
if (empty($this->special_id_banner)) {
$this->special_id_banner = uniqid();
}
return parent::add($auto_date, $null_values);
}
public static function getListTpl()
{
$list = [];
$tplsTheme = glob(self::tplsThemeDir . '*.tpl');
foreach ($tplsTheme as $tpl){
$list[] = str_replace('.tpl', '', basename($tpl));
}
$tplsMod = glob(self::tplsDir . '*.tpl');
foreach ($tplsMod as $tpl){
$list[] = str_replace('.tpl', '', basename($tpl));
}
$list = array_unique($list);
$return = [];
foreach ($list as $item){
$return[]['file'] = $item;
}
return $return;
}
public static function getBanners($forExport = false, $all = false)
{
$context = Context::getContext();
$sql = '
SELECT * FROM `' . _DB_PREFIX_ . 'an_homeproducts_banners` sw
LEFT JOIN `' . _DB_PREFIX_ . 'an_homeproducts_banners_lang` sl
ON (sw.`id_banner` = sl.`id_banner`
AND sl.`id_lang` = ' . (int) $context->language->id . ')
';
if (!$all){
$sql .= 'WHERE sw.`active`=1 ';
}
if (Shop::isFeatureActive()) {
$sql .= ' AND sw.`id_banner` IN (
SELECT sa.`id_banner`
FROM `' . _DB_PREFIX_ . 'an_homeproducts_banners_shop` sa
WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
)';
}
$sql .= ' ORDER BY sw.`position`';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if ($forExport){
return $result;
}
$banners = [];
foreach ($result as $id => $banner){
$obj = new anHomeProductsBanners($banner['id_banner'], $context->language->id);
$banners[$banner['block']][$banner['block_position']][$banner['id_banner']] = (array) $obj;
}
return $banners;
}
public function delete()
{
foreach ($this->image as $imgName){
@unlink(self::imgDir . $imgName);
}
return parent::delete();
}
public static function findTemplatesBanners()
{
}
public static function exportJsonBanners($filesManager)
{
$banners = self::getBanners(true, true);
foreach ($banners as $key => $banner){
$obj = new anHomeProductsBanners($banner['id_banner']);
$banners[$key]['imagesLang'] = $obj->image;
$banners[$key]['link'] = '#';
}
@file_put_contents($filesManager->getJsonDirBanners(), json_encode($banners, JSON_PRETTY_PRINT));
}
public static function importJsonBanners($filesManager)
{
$data = json_decode($filesManager->getJsonBannersPathFile(), true);
$context = Context::getContext();
$languages = Language::getLanguages();
if ($data){
foreach ($data as $item){
$bannerObj = new anHomeProductsBanners();
if (!isset($item['special_id_banner'])){
$item['special_id_banner'] = uniqid();
}
$bannerObj->special_id_banner = $item['special_id_banner'];
$bannerObj->block = $item['block'];
$bannerObj->block_position = $item['block_position'];
$bannerObj->col = $item['col'];
$bannerObj->template = $item['template'];
$bannerObj->active = $item['active'];
$bannerObj->position = $item['position'];
$bannerObj->image = array();
foreach ($languages as $language) {
$bannerObj->title[$language['id_lang']] = $item['title'];
$bannerObj->text[$language['id_lang']] = $item['text'];
$bannerObj->link[$language['id_lang']] = $item['link'];
if (!isset($bannerObj->image[$language['id_lang']]) &&
isset($item['imagesLang'][$language['id_lang']]) &&
$item['imagesLang'][$language['id_lang']] != $item['image']){
$nameImage = $item['imagesLang'][$language['id_lang']];
if (Shop::isFeatureActive() && Tools::file_exists_no_cache(self::imgDir . $nameImage)){
$nameImage = self::generateName($nameImage, $language['id_lang']);
Tools::copy(self::imgDir . $item['image'], self::imgDir . $nameImage);
}
$bannerObj->image[$language['id_lang']] = $nameImage;
} else {
$nameImage = $item['image'];
if (!Tools::file_exists_no_cache(self::imgDir . $nameImage)){
$nameImage = '';
}
if ($nameImage !='' && (in_array($nameImage, $bannerObj->image) || Shop::isFeatureActive())){
$nameImage = self::generateName($nameImage, $language['id_lang']);
Tools::copy(self::imgDir . $item['image'], self::imgDir . $nameImage);
}
$bannerObj->image[$language['id_lang']] = $nameImage;
}
}
$bannerObj->save();
Db::getInstance()->insert('an_homeproducts_banners_shop', [
'id_banner' => (int) $bannerObj->id,
'id_shop' => (int) Context::getContext()->shop->id
]);
}
}
}
public static function generateName($name, $id_lang)
{
$ext = substr($name, strrpos($name, '.') + 1);
$nameImage = $id_lang . '_' . md5(uniqid()) .'.'.$ext;
return 'new_'.$nameImage;
}
public static function getCountBanners()
{
$context = Context::getContext();
$sql = '
SELECT count(*) FROM `' . _DB_PREFIX_ . 'an_homeproducts_banners` sw
LEFT JOIN `' . _DB_PREFIX_ . 'an_homeproducts_banners_lang` sl
ON (sw.`id_banner` = sl.`id_banner`
AND sl.`id_lang` = ' . (int) $context->language->id . ')
';
if (Shop::isFeatureActive()) {
$sql .= ' WHERE sw.`id_banner` IN (
SELECT sa.`id_banner`
FROM `' . _DB_PREFIX_ . 'an_homeproducts_banners_shop` sa
WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
)';
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
}

View File

@@ -0,0 +1,780 @@
<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever;
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter;
use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever;
// Featured
use PrestaShop\PrestaShop\Adapter\Category\CategoryProductSearchProvider;
// PricesDrop
use PrestaShop\PrestaShop\Adapter\PricesDrop\PricesDropProductSearchProvider;
// BestSellers
use PrestaShop\PrestaShop\Adapter\BestSales\BestSalesProductSearchProvider;
// New
use PrestaShop\PrestaShop\Adapter\NewProducts\NewProductsProductSearchProvider;
use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext;
use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery;
use PrestaShop\PrestaShop\Core\Product\Search\SortOrder;
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductFiles.php';
class anHomeProductsBlocks extends ObjectModel
{
/**
* @var int
*/
public $id_block;
/**
* @var int
*/
public $id;
public $special_id_block;
public $type = 'new-products';
public $active = 1;
public $show_sort = 0;
public $show_sub_cat = 0;
public $products_display = 8;
public $id_category = 0;
public $position;
public $title;
public $text;
public $link;
/**
* @var array
*/
public static $definition = [
'table' => 'an_homeproducts_blocks',
'primary' => 'id_block',
'multilang' => true,
'fields' => [
'special_id_block' => ['type' =>self::TYPE_STRING ],
'active' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'show_sort' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'products_display' => ['type' =>self::TYPE_INT ],
'id_category' => ['type' =>self::TYPE_INT ],
'show_sub_cat' => ['type' => self::TYPE_BOOL, 'validate' => 'isBool'],
'position' => ['type' =>self::TYPE_INT ],
'type' => ['type' =>self::TYPE_STRING ],
'title' => ['type' =>self::TYPE_STRING,'lang' => true, 'validate' => 'isString', 'required' => true, 'size' => 256 ],
'text' => ['type' =>self::TYPE_HTML,'lang' => true ],
'link' => ['type' =>self::TYPE_STRING,'lang' => true ]
],
];
public function __construct($id = null, $id_lang = null)
{
parent::__construct($id, $id_lang);
}
public function add($auto_date = true, $null_values = false)
{
if (empty($this->special_id_block)) {
$this->special_id_block = uniqid();
}
return parent::add($auto_date, $null_values);
}
public function getData($params = [])
{
$context = Context::getContext();
$data = self::getBlockData((array) $this, $params);
$this->sort = $data['sort'];
$this->products = $data['products'];
$this->totalProducts = $data['totalProducts'];
$this->productsNextPage = $data['productsNextPage'];
if ($this->id_category){
$this->childrenCats = Category::getChildren(
$this->id_category,
$context->language->id,
true,
$context->shop->id
);
}
}
public static function getBlockData($block, $params = [])
{
switch ($block['type']){
case 'new-products':
return self::getNewProducts($block['products_display'], $params);
break;
case 'best-sales':
return self::getBestSellers($block['products_display'], $params);
break;
case 'prices-drop':
return self::getSpecials($block['products_display'], $params);
break;
case 'prices-drop-percentage':
return self::getSpecialsPercentage($block['products_display'], $params);
break;
case 'category':
return self::getProductsCategory($block, $params);
break;
case 'categories':
return self::getProductsCategories($block, $params);
break;
case 'products':
return self::getProductsByIds($block, $params);
break;
}
}
public static function getBlocks($mergeData = true, $all = false)
{
$sql = '
SELECT * FROM `' . _DB_PREFIX_ . 'an_homeproducts_blocks` sw
LEFT JOIN `' . _DB_PREFIX_ . 'an_homeproducts_blocks_lang` sl
ON (sw.`id_block` = sl.`id_block`
AND sl.`id_lang` = ' . (int) Context::getContext()->language->id . ')
';
if (!$all){
$sql .= 'WHERE sw.`active`=1 ';
}
if (Shop::isFeatureActive()) {
$sql .= ' AND sw.`id_block` IN (
SELECT sa.`id_block`
FROM `' . _DB_PREFIX_ . 'an_homeproducts_blocks_shop` sa
WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
)';
}
$sql .= ' ORDER BY sw.`position`';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
foreach ($result as $key => $field){
$sql_lang = 'SELECT * FROM `' . _DB_PREFIX_ . 'an_homeproducts_blocks_lang` WHERE `id_block` = ' . (int) $field['id_block'] . '';
$res_lang = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql_lang);
$langContent = [];
foreach ($res_lang as $item){
$item['iso_code'] = Language::getIsoById($item['id_lang']);
$langContent[$item['iso_code']] = $item;
}
$result[$key]['languages'] = $langContent;
}
if ($mergeData){
foreach ($result as $id => $block){
$result[$id] = array_merge($result[$id], (array) self::getBlockData($block));
}
}
if (!$result) {
return [];
} else {
return $result;
}
}
public static function getProductsCategory($block, $params = [])
{
$context = Context::getContext();
$nProducts = $block['products_display'];
if (!isset($params['sort']) || $params['sort'] == ''){
$params['sort'] = 'product.position.asc';
}
$page = 1;
if (isset($params['page']) && $params['page'] > 0){
$page = intval($params['page']);
}
$childrenCats = Category::getChildren(
$block['id_category'],
$context->language->id,
true,
$context->shop->id
);
$return['childrenCats'] = $childrenCats;
if (isset($params['idCategory']) && $params['idCategory']){
$category = new Category((int) $params['idCategory']);
} else {
$category = new Category((int) $block['id_category']);
}
$searchProvider = new CategoryProductSearchProvider(
$context->getTranslator(),
$category
);
$contextSearch = new ProductSearchContext($context);
$query = new ProductSearchQuery();
$query
->setResultsPerPage($nProducts)
->setPage($page)
;
$query->setSortOrder(SortOrder::newFromString(
$params['sort']
));
$result = $searchProvider->runQuery(
$contextSearch,
$query
);
$products = $result->getProducts();
$availableSort = [];
foreach ($result->getAvailableSortOrders() as $itemSort){
$availableSort[] = $itemSort->toArray();
}
$return['sort'] = $availableSort;
$return['products'] = self::productsPrepareForTemplate($context, $products);
$return['totalProducts'] = $result->getTotalProductsCount();
$return['productsNextPage'] = $return['totalProducts'] - ($page * $nProducts);
if ($return['productsNextPage'] < 0) {
$return['productsNextPage'] = 0;
}
return $return;
// return self::productsPrepareForTemplate($context, $products);
}
public static function getProductsByIds($block, $params = [])
{
$nProducts = $block['products_display'];
$id_block = $block['id_block'];
$randomize = false;
$context = Context::getContext();
$langId = Context::getContext()->language->id;
$sql = '
SELECT *, p.*
FROM `' . _DB_PREFIX_ . 'an_homeproducts_blocks_products` awl
LEFT JOIN `' . _DB_PREFIX_ . 'product` p
ON (p.`id_product` = awl.`id_product`)
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $langId . Shop::addSqlRestrictionOnLang('pl') . ')
WHERE awl.`id_block` = ' . (int) $id_block . '
ORDER BY awl.`position`
LIMIT 0,'.(int) $nProducts.'
';
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, true, false);
if (!$products){
$products = [];
}
$return['sort'] = [];
$return['products'] = self::productsPrepareForTemplate($context, $products);
$return['totalProducts'] = 0;
$return['productsNextPage'] = 0;
return $return;
}
public static function getProductsCategories($block, $params = [])
{
$randomize = false;
$context = Context::getContext();
$nProducts = $block['products_display'];
$cats = self::getBlockCategories($block['id_block']);
$query = new ProductSearchQuery();
if ($randomize) {
$query->setSortOrder(SortOrder::random());
} else {
$query->setSortOrder(new SortOrder('product', 'position', 'asc'));
}
$products = [];
while (count($products) < $nProducts && count($cats)){
foreach ($cats as $id => $categoryId){
$page = 1;
while ($page){
$query
->setResultsPerPage($nProducts)
->setPage($page)
;
$category = new Category((int) $categoryId);
$searchProvider = new CategoryProductSearchProvider(
$context->getTranslator(),
$category
);
$result = $searchProvider->runQuery(
new ProductSearchContext($context),
$query
);
$productsCat = $result->getProducts();
if (count($productsCat) == 0){
unset($cats[$id]);
break;
}
$products = array_merge($products, $productsCat);
if (count($products) >= $nProducts){
break;
}
$page++;
}
}
}
// shuffle($products);
$products = array_chunk($products, $nProducts, true);
$products = array_shift($products);
$return['sort'] = [];
$return['products'] = self::productsPrepareForTemplate($context, $products);
$return['totalProducts'] = 0;
$return['productsNextPage'] = 0;
return $return;
// return self::productsPrepareForTemplate($context, $products);
}
public static function getBlockCategories($idBlock)
{
if (!$idBlock){
return [];
}
$sql = 'SELECT `id_category` FROM `' . _DB_PREFIX_ . 'an_homeproducts_blocks_categories` WHERE `id_block` = ' . (int) $idBlock . ' ';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, true, false);
$cats = [];
if ($result) {
foreach ($result as $item){
$cats[] = $item['id_category'];
}
}
return $cats;
}
public static function getBestSellers($nProducts = 8, $params = [])
{
if (Configuration::get('PS_CATALOG_MODE')) {
return false;
}
$context = Context::getContext();
if (!isset($params['sort']) || $params['sort'] == ''){
$params['sort'] = 'product.name.asc';
}
$page = 1;
if (isset($params['page']) && $params['page'] > 0){
$page = intval($params['page']);
}
$contextSearch = new ProductSearchContext($context);
$query = new ProductSearchQuery();
$query
->setResultsPerPage($nProducts)
->setPage($page)
;
$query->setQueryType('best-sales');
$query->setSortOrder(SortOrder::newFromString(
$params['sort']
));
$searchProvider = new BestSalesProductSearchProvider(
$context->getTranslator()
);
$result = $searchProvider->runQuery(
$contextSearch,
$query
);
$products = $result->getProducts();
$availableSort = [];
foreach ($result->getAvailableSortOrders() as $itemSort){
$availableSort[] = $itemSort->toArray();
}
$return['sort'] = $availableSort;
$return['products'] = self::productsPrepareForTemplate($context, $products);
$return['totalProducts'] = $result->getTotalProductsCount();
$return['productsNextPage'] = $return['totalProducts'] - ($page * $nProducts);
if ($return['productsNextPage'] < 0) {
$return['productsNextPage'] = 0;
}
return $return;
// return self::productsPrepareForTemplate($context, $products);
}
public static function getNewProducts($nProducts = 8, $params = [])
{
$context = Context::getContext();
if (!isset($params['sort']) || $params['sort'] == ''){
$params['sort'] = 'product.date_add.desc';
}
$page = 1;
if (isset($params['page']) && $params['page'] > 0){
$page = intval($params['page']);
}
$searchProvider = new NewProductsProductSearchProvider(
$context->getTranslator()
);
$contextSearch = new ProductSearchContext($context);
$query = new ProductSearchQuery();
$query
->setResultsPerPage($nProducts)
->setPage($page)
;
$query->setQueryType('new-products');
$query->setSortOrder(SortOrder::newFromString(
$params['sort']
));
$result = $searchProvider->runQuery(
$contextSearch,
$query
);
// totalProductsCount availableSortOrders currentSortOrder
//echo '<pre>'; var_dump($result); die;
// $result->getAvailableSortOrders()['0']->getLabel() - доступные методы сортировки для блока
// echo '<pre>'; var_dump($result->getCurrentSortOrder()); die;
$products = $result->getProducts();
$availableSort = [];
foreach ($result->getAvailableSortOrders() as $itemSort){
$availableSort[] = $itemSort->toArray();
}
$return['sort'] = $availableSort;
$return['products'] = self::productsPrepareForTemplate($context, $products);
$return['totalProducts'] = $result->getTotalProductsCount();
$return['productsNextPage'] = $return['totalProducts'] - ($page * $nProducts);
if ($return['productsNextPage'] < 0) {
$return['productsNextPage'] = 0;
}
return $return;
// return self::productsPrepareForTemplate($context, $products);
}
public static function getSpecials($nProducts = 8, $params = [])
{
$context = Context::getContext();
if (!isset($params['sort']) || $params['sort'] == ''){
$params['sort'] = 'product.name.asc';
}
$page = 1;
if (isset($params['page']) && $params['page'] > 0){
$page = intval($params['page']);
}
$searchProvider = new PricesDropProductSearchProvider(
$context->getTranslator()
);
$contextSearch = new ProductSearchContext($context);
$query = new ProductSearchQuery();
$query
->setResultsPerPage($nProducts)
->setPage($page)
;
$query->setQueryType('prices-drop');
$query->setSortOrder(SortOrder::newFromString(
$params['sort']
));
$result = $searchProvider->runQuery(
$contextSearch,
$query
);
$products = $result->getProducts();
$availableSort = [];
foreach ($result->getAvailableSortOrders() as $itemSort){
$availableSort[] = $itemSort->toArray();
}
$return['sort'] = $availableSort;
$return['products'] = self::productsPrepareForTemplate($context, $products);
$return['totalProducts'] = $result->getTotalProductsCount();
$return['productsNextPage'] = $return['totalProducts'] - ($page * $nProducts);
if ($return['productsNextPage'] < 0) {
$return['productsNextPage'] = 0;
}
return $return;
// return self::productsPrepareForTemplate($context, $products);
}
public static function getSpecialsPercentage($nProducts = 8, $params = [])
{
$page = 1;
if (isset($params['page']) && $params['page'] > 0){
$page = intval($params['page']);
}
$context = Context::getContext();
$id_lang = $context->language->id;
$front = true;
$sql = '
SELECT
p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description`, pl.`description_short`, pl.`available_now`, pl.`available_later`,
IFNULL(product_attribute_shop.id_product_attribute, 0) id_product_attribute,
pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`,
pl.`name`, image_shop.`id_image` id_image, il.`legend`, m.`name` AS manufacturer_name,
DATEDIFF(
p.`date_add`,
DATE_SUB(
"' . date('Y-m-d') . ' 00:00:00",
INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY
)
) > 0 AS new
FROM `' . _DB_PREFIX_ . 'specific_price` sprc, `' . _DB_PREFIX_ . 'product` p
' . Shop::addSqlAssociation('product', 'p') . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_shop` product_attribute_shop
ON (p.`id_product` = product_attribute_shop.`id_product` AND product_attribute_shop.`default_on` = 1 AND product_attribute_shop.id_shop=' . (int) $context->shop->id . ')
' . Product::sqlStock('p', 0, false, $context->shop) . '
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
)
LEFT JOIN `' . _DB_PREFIX_ . 'image_shop` image_shop
ON (image_shop.`id_product` = p.`id_product` AND image_shop.cover=1 AND image_shop.id_shop=' . (int) $context->shop->id . ')
LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (image_shop.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
WHERE product_shop.`active` = 1
AND p.id_product = sprc.id_product
AND sprc.reduction_type = "percentage"
AND product_shop.`show_price` = 1
' . ($front ? ' AND product_shop.`visibility` IN ("both", "catalog")' : '') . '
';
$sql .= '
ORDER BY sprc.reduction DESC
LIMIT ' . (int) (($page - 1) * $nProducts) . ', ' . (int) $nProducts;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if (!$result) {
return false;
}
$products = Product::getProductsProperties($id_lang, $result);
$return['products'] = self::productsPrepareForTemplate($context, $products);;
// $return['totalProducts'] = $result->getTotalProductsCount();
// $return['productsNextPage'] = $return['totalProducts'] - ($page * $nProducts);
$return['productsNextPage'] = 0;
if ($return['productsNextPage'] < 0) {
$return['productsNextPage'] = 0;
}
return $return;
}
public static function productsPrepareForTemplate($context, $products)
{
$assembler = new ProductAssembler($context);
$presenterFactory = new ProductPresenterFactory($context);
$presentationSettings = $presenterFactory->getPresentationSettings();
$presenter = $presenterFactory->getPresenter();
$products_for_template = [];
if (is_array($products)) {
foreach ($products as $rawProduct) {
$products_for_template[] = $presenter->present(
$presentationSettings,
$assembler->assembleProduct($rawProduct),
$context->language
);
}
}
return $products_for_template;
}
public static function getProducsByIdBlock($id_block)
{
if (!$id_block){
return [];
}
$langId = Context::getContext()->language->id;
$sql = '
SELECT *, p.*
FROM `' . _DB_PREFIX_ . 'an_homeproducts_blocks_products` awl
LEFT JOIN `' . _DB_PREFIX_ . 'product` p
ON (p.`id_product` = awl.`id_product`)
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
ON (p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $langId . Shop::addSqlRestrictionOnLang('pl') . ')
WHERE awl.`id_block` = ' . (int) $id_block . '
ORDER BY awl.`position`';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, true, false);
return Product::getProductsProperties($langId, $result);
}
public static function exportJsonBlocks($filesManager)
{
$blocks = self::getBlocks(false, true);
@file_put_contents($filesManager->getJsonDirblocks(), json_encode($blocks, JSON_PRETTY_PRINT));
}
public static function importJsonBlocks($filesManager)
{
$data = json_decode($filesManager->getJsonBlocksPathFile(), true);
$languages = Language::getLanguages();
if ($data){
foreach ($data as $item){
$blockObj = new anHomeProductsBlocks();
$blockObj->special_id_block = $item['special_id_block'];
$blockObj->active = $item['active'];
$blockObj->show_sort = $item['show_sort'];
$blockObj->products_display = $item['products_display'];
$blockObj->id_category = $item['id_category'];
$blockObj->show_sub_cat = $item['show_sub_cat'];
$blockObj->position = $item['position'];
$blockObj->type = $item['type'];
if (isset($item['languages']) && is_array($item['languages'])) {
foreach ($item['languages'] as $key => $field) {
$langId = Language::getIdByIso($field['iso_code']);
$blockObj->title[$langId] = $field['title'];
$blockObj->text[$langId] = $field['text'];
$blockObj->link[$langId] = $field['link'];
}
}
foreach ($languages as $language) {
if (!isset($blockObj->title[$language['id_lang']])){
$blockObj->title[$language['id_lang']] = $item['title'];
}
if (!isset($blockObj->text[$language['id_lang']])){
$blockObj->text[$language['id_lang']] = $item['text'];
}
if (!isset($blockObj->link[$language['id_lang']])){
$blockObj->link[$language['id_lang']] = $item['link'];
}
}
$blockObj->save();
Db::getInstance()->insert('an_homeproducts_blocks_shop', [
'id_block' => (int) $blockObj->id,
'id_shop' => (int) Context::getContext()->shop->id
]);
}
}
}
public static function getCountBlocks()
{
$sql = '
SELECT count(*) FROM `' . _DB_PREFIX_ . 'an_homeproducts_blocks` sw
LEFT JOIN `' . _DB_PREFIX_ . 'an_homeproducts_blocks_lang` sl
ON (sw.`id_block` = sl.`id_block`
AND sl.`id_lang` = ' . (int) Context::getContext()->language->id . ')
';
if (Shop::isFeatureActive()) {
$sql .= ' WHERE sw.`id_block` IN (
SELECT sa.`id_block`
FROM `' . _DB_PREFIX_ . 'an_homeproducts_blocks_shop` sa
WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
)';
}
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
}
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>an_homeproducts</name>
<displayName><![CDATA[Home Products]]></displayName>
<version><![CDATA[1.0.26]]></version>
<description><![CDATA[New arrivals, Best sellers, Specials, Category, Categories (multiple), Featured products and Banners]]></description>
<author><![CDATA[Anvanto]]></author>
<tab><![CDATA[others]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to uninstall the module?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
</module>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>an_homeproducts</name>
<displayName><![CDATA[Home Products]]></displayName>
<version><![CDATA[1.0.26]]></version>
<description><![CDATA[New arrivals, Best sellers, Specials, Category, Categories (multiple), Featured products and Banners]]></description>
<author><![CDATA[Anvanto]]></author>
<tab><![CDATA[others]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to uninstall the module?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,63 @@
<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
use PrestaShop\PrestaShop\Core\Domain\Product\Query\SearchProducts;
class AdminAnhomeproductsAjaxController extends ModuleAdminController
{
public function initContent()
{
$result = [];
if (Tools::isSubmit('action')) {
$actionName = Tools::getValue('action', '') . 'Action';
if (method_exists($this, $actionName)) {
$result = $this->$actionName();
}
}
die(json_encode($result));
}
public function searchProductsAction()
{
// $defaultCurrencyId = (int) $this->get('prestashop.adapter.legacy.configuration')->get('PS_CURRENCY_DEFAULT');
//$searchPhrase = $request->query->get('search_phrase');
$searchPhrase = Tools::getValue('q');
if (!$searchPhrase){
return [];
}
$foundProducts = Product::searchByName((int) $this->context->language->id, pSQL($searchPhrase));
if (!$foundProducts){
return [];
}
$products = [];
foreach ($foundProducts as $fProduct){
$products[] = [
'id' => $fProduct['id_product'],
'name' => $fProduct['name']
];
}
return $products;
}
}

View File

@@ -0,0 +1,604 @@
<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductsBanners.php';
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductFiles.php';
class AdminAnhomeproductsBannersController extends ModuleAdminController
{
protected $_module = null;
protected $position_identifier = 'position';
protected $_defaultOrderBy = 'position';
protected $_defaultOrderWay = 'ASC';
public function __construct()
{
$this->bootstrap = true;
$this->context = Context::getContext();
$this->table = 'an_homeproducts_banners';
$this->identifier = 'id_banner';
$this->className = 'anHomeProductsBanners';
$this->lang = true;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->name = 'AdminAnhomeproductsBannersController';
parent::__construct();
$this->fields_list = [
'id_banner' => [
'title' => $this->l('ID'),
'width' => 25,
'search' => false
],
'image' => [
'title' => $this->l('Image'),
'search' => false,
'type' => 'image'
],
'title' => [
'title' => $this->trans('Title', [], 'Admin.Global'),
'search' => false
],
'block' => [
'title' => $this->l('Block'),
'search' => false
],
'block_position' => [
'title' => $this->l('Block position'),
'search' => false
],
'position' => [
'title' => $this->trans('Position', [], 'Admin.Global'),
'search' => false,
'position' => true
],
'col' => [
'title' => $this->l('Col'),
'search' => false
],
'active' => [
'title' => $this->trans('Active', [], 'Admin.Global'),
'width' => 40,
'active' => 'update',
'align' => 'center',
'type' => 'bool',
'search' => false,
'orderby' => false
]
];
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL) {
$this->_where .= ' AND a.' . $this->identifier . ' IN (
SELECT sa.' . $this->identifier . '
FROM `' . _DB_PREFIX_ . $this->table . '_shop` sa
WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
)';
}
}
public function l($string, $class = null, $addslashes = false, $htmlentities = true)
{
return parent::l($string, pathinfo(__FILE__, PATHINFO_FILENAME), $addslashes, $htmlentities);
}
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
$blocksOriginal = anHomeProductsBlocks::getBlocks(false, true);
$blocks = [];
foreach ($blocksOriginal as $block){
$blocks[$block['special_id_block']] = $block;
}
foreach ($this->_list as &$list) {
if ($list['block'] == 0){
$list['block'] = $this->l('Global');
} else if (isset($blocks[$list['block']])) {
$list['block'] = $blocks[$list['block']]['title'];
}
if ($list['block_position'] == 0){
$list['block_position'] = $this->l('Top');
} else {
$list['block_position'] = $this->l('Bottom');
}
if ($list['image'] !='' && Tools::file_exists_no_cache(anHomeProductsBanners::imgDir.$list['image'])) {
$list['image'] = anHomeProductsBanners::imgUrl.$list['image'];
} else {
$list['image'] = '';
}
}
}
public function setMedia($isNewTheme = false)
{
parent::setMedia($isNewTheme);
$this->addJquery();
$this->js_files[] = _MODULE_DIR_ . 'an_homeproducts/views/js/back.js';
$this->css_files[_MODULE_DIR_ . 'an_homeproducts/views/css/back.css'] = 'all';
}
public function renderList()
{
return parent::renderList() . $this->module->topPromo();
}
public function initToolBarTitle()
{
$this->toolbar_title[] = $this->l('Home Products: Banners');
}
public function initHeader()
{
parent::initHeader();
$id_lang = $this->context->language->id;
$link = $this->context->link;
$tabs = &$this->context->smarty->tpl_vars['tabs']->value;
foreach ($tabs as &$tab0) {
if ($tab0['class_name'] == 'IMPROVE') {
foreach ($tab0['sub_tabs'] as &$tab1) {
if ($tab1['class_name'] == 'AdminParentModulesSf') {
foreach ($tab1['sub_tabs'] as &$tab2) {
if ($tab2['class_name'] == 'AdminAnhomeproductsBanners') {
$sub_tabs = &$tab2['sub_tabs'];
$tab = Tab::getTab($id_lang, Tab::getIdFromClassName('AdminAnhomeproductsBlocks'));
$tab['current'] = false;
$tab['href'] = $link->getAdminLink('AdminAnhomeproductsBlocks');
$tab['active'] = true;
$tab['name'] = $this->l('Products to display');
$sub_tabs[] = $tab;
$tab = Tab::getTab($id_lang, Tab::getIdFromClassName('AdminAnhomeproductsBanners'));
$tab['current'] = true;
$tab['href'] = $link->getAdminLink('AdminAnhomeproductsBanners');
$tab['active'] = true;
$tab['name'] = $this->l('Banners');
$sub_tabs[] = $tab;
$tab = Tab::getTab($id_lang, Tab::getIdFromClassName('AdminAnhomeproductsSettings'));
$tab['current'] = false;
$tab['href'] = $link->getAdminLink('AdminAnhomeproductsSettings');
$tab['active'] = true;
$tab['name'] = $this->trans('Settings', [], 'Admin.Global');
$sub_tabs[] = $tab;
break;
}
}
break;
}
}
break;
}
}
}
public function initContent()
{
$this->context->smarty->assign('current_tab_level', 3);
return parent::initContent();
}
public function initPageHeaderToolbar()
{
if (empty($this->display)) {
$this->page_header_toolbar_btn['add_field'] = array(
'href' => self::$currentIndex . '&addan_homeproducts_banners&token=' . $this->token,
'desc' => $this->trans('Add new', array(), 'Admin.Actions'),
'icon' => 'process-icon-new',
);
}
parent::initPageHeaderToolbar();
}
public function renderForm()
{
$this->initToolbar();
if (!$this->loadObject(true)) {
return;
}
$this->fields_form = array(
'tinymce' => false,
'legend' => ['title' => $this->l('Home Products: Banners')],
'input' => [],
'buttons' => [
[
'type' => 'submit',
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'name' => 'submit'.$this->table
],
[
'type' => 'submit',
'title' => $this->l('Save and stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'name' => 'submit'.$this->table.'AndStay'
],
],
);
$this->fields_form['input'][] = [
'type' => 'switch',
'name' => 'active',
'label' => $this->l('Active'),
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
];
$blocks = anHomeProductsBlocks::getBlocks(false, true);
$this->fields_form['input'][] = [
'type' => 'select',
'label' => $this->l('Block'),
'name' => 'block',
'options' => [
'query' => array_merge(
[
['special_id_block' => '0', 'title' => $this->l('Global')],
],
$blocks
),
'id' => 'special_id_block',
'name' => 'title',
],
];
$this->fields_form['input'][] = [
'type' => 'select',
'label' => $this->module->l('Block position'),
'name' => 'block_position',
'options' => [
'query' => array_merge(
[
['id' => '0', 'name' => $this->l('Top')],
['id' => '1', 'name' => $this->l('Bottom')]
]
),
'id' => 'id',
'name' => 'name',
],
];
$listCols = [];
for ($i=3; $i <= 12; $i++){
$listCols[] = ['id' => $i, 'name' => $i];
}
$this->fields_form['input'][] = [
'type' => 'select',
'label' => $this->module->l('Col'),
'desc' => $this->l('From 2 to 12'),
'name' => 'col',
'options' => [
'query' => array_merge(
[
['id' => '2', 'name' => '2'],
],
$listCols
),
'id' => 'id',
'name' => 'name',
],
];
$bannerTpls = anHomeProductsBanners::getListTpl();
if (count($bannerTpls) > 1){
$this->fields_form['input'][] = [
'type' => 'select',
'label' => $this->module->l('Template'),
'name' => 'template',
'options' => [
'query' => array_merge(
anHomeProductsBanners::getListTpl()
),
'id' => 'file',
'name' => 'file',
],
];
}
/*
$this->fields_form['input'][] = [
'type' => 'radio',
'label' => $this->l('Show on:'),
'name' => 'show_on',
'default_value' => 0,
'class' => 'an-hp-block-type',
'values' => [
[
'id' => 'desktop_mobile',
'value' => '0',
'label' => $this->l('Desktop & Mobile')
],
[
'id' => 'desktop',
'value' => '1',
'label' => $this->l('Desktop'),
],
[
'id' => 'mobile',
'value' => '2',
'label' => $this->l('Mobile')
],
],
];
*/
$this->fields_form['input'][] = [
'type' => 'file_lang',
'label' => $this->l('Image'),
'lang' => true,
'name' => 'image',
'display_image' => true,
'delete_url' => '',
];
$this->fields_form['input'][] = [
'type' => 'text',
'name' => 'link',
'label' => $this->l('Link'),
'lang' => true,
];
$this->fields_form['input'][] = [
'type' => 'text',
'name' => 'title',
'label' => $this->trans('Title', [], 'Admin.Global'),
'lang' => true,
];
$this->fields_form['input'][] = [
'type' => 'textarea',
'class' => 'autoload_rte',
'name' => 'text',
'label' => $this->l('Text'),
'lang' => true,
];
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = [
'required' => true,
'type' => 'shop',
'label' => $this->l('Shop association'),
'name' => 'checkBoxShopAsso',
];
}
return parent::renderForm();
}
public function processSave()
{
$languages = Language::getLanguages(false);
$isUpdateImage = false;
foreach ($languages as $lang) {
if (isset($_FILES['image_'.$lang['id_lang']]) && isset($_FILES['image_'.$lang['id_lang']]['tmp_name'])
&& !empty($_FILES['image_'.$lang['id_lang']]['tmp_name'])) {
if ($error = $this->validateUpload($_FILES['image_'.$lang['id_lang']])) {
$this->errors[] = $error;
}
}
}
if (!empty($this->errors)) {
$this->display = 'edit';
return false;
}
$object = parent::processSave();
if (isset($object->id) && $object->id) {
$deleteImage = Tools::getValue('delete_image');
if ($deleteImage && is_array($deleteImage)){
foreach ($deleteImage as $id){
@unlink(anHomeProductsBanners::imgDir . $object->image[$id]);
$object->image[$id] = '';
}
$isUpdateImage = true;
}
foreach ($languages as $lang) {
if (isset($_FILES['image_'.$lang['id_lang']]) && isset($_FILES['image_'.$lang['id_lang']]['tmp_name'])
&& !empty($_FILES['image_'.$lang['id_lang']]['tmp_name'])) {
$ext = substr($_FILES['image_'.$lang['id_lang']]['name'], strrpos($_FILES['image_'.$lang['id_lang']]['name'], '.') + 1);
$fileName = md5(uniqid()) . '_' . $lang['id_lang'] . '.' . $ext;
if (!move_uploaded_file($_FILES['image_'.$lang['id_lang']]['tmp_name'], anHomeProductsBanners::imgDir . $fileName)) {
// return $this->displayError($this->trans('An error occurred while attempting to upload the file.', [], 'Admin.Notifications.Error'));
}
if (isset($object->image[$lang['id_lang']]) && $object->image[$lang['id_lang']] !=''){
@unlink(anHomeProductsBanners::imgDir . $object->image[$lang['id_lang']]);
}
$object->image[$lang['id_lang']] = $fileName;
$isUpdateImage = true;
}
}
if ($isUpdateImage){
$object->save();
}
}
anHomeProductsBanners::exportJsonBanners($this->module->filesManager);
$this->module->_clearCache('*');
if (Tools::getIsset('submit'.$this->table.'AndStay')) {
$this->redirect_after = $this->context->link->getAdminLink($this->controller_name).'&conf=4&updatean_homeproducts_banners&token='.$this->token.'&id_banner='.$object->id;
}
return $object;
}
public function validateUpload($file)
{
$maxFileSize = 4000000;
$types = ['gif', 'jpg', 'jpeg', 'jpe', 'png', 'svg', 'webp'];
if ((int) $maxFileSize > 0 && $file['size'] > (int) $maxFileSize) {
return Context::getContext()->getTranslator()->trans('Image is too large (%1$d kB). Maximum allowed: %2$d kB', [$file['size'] / 1024, $maxFileSize / 1024], 'Admin.Notifications.Error');
}
if (!ImageManager::isCorrectImageFileExt($file['name'], $types) || preg_match('/\%00/', $file['name'])) {
return Context::getContext()->getTranslator()->trans('Image format not recognized, allowed formats are: .gif, .jpg, .png, .svg', [], 'Admin.Notifications.Error');
}
if ($file['error']) {
return Context::getContext()->getTranslator()->trans('Error while uploading image; please change your server\'s settings. (Error code: %s)', [$file['error']], 'Admin.Notifications.Error');
}
return false;
}
public function processDelete()
{
$object = parent::processDelete();
$this->module->_clearCache('*');
anHomeProductsBanners::exportJsonBanners($this->module->filesManager);
return $object;
}
public function ajaxProcessUpdatePositions()
{
$status = false;
$position = 0;
$widget = (array)Tools::getValue('banner');
foreach ($widget as $key => $item){
$ids = explode('_', $item);
$sql = 'UPDATE `' . _DB_PREFIX_ . $this->table .'` SET position="'.(int) $position.'" WHERE '.$this->identifier.'="'.(int) $ids['2'].'" ';
Db::getInstance(_PS_USE_SQL_SLAVE_)->execute($sql);
$position++;
}
if (count($widget) > 0){
$status = true;
}
anHomeProductsBanners::exportJsonBanners($this->module->filesManager);
$this->module->_clearCache('*');
return $this->setJsonResponse(array(
'success' => $status,
'message' => $this->l($status ? 'Blocks reordered successfully' : 'An error occurred')
));
}
protected function setJsonResponse($response)
{
header('Content-Type: application/json; charset=utf8');
print(json_encode($response));
exit;
}
protected function updateAssoShop($id_object)
{
if (!Shop::isFeatureActive()) {
return;
}
$assos_data = $this->getSelectedAssoShop($this->table, $id_object);
$exclude_ids = $assos_data;
foreach (Db::getInstance()->executeS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'shop') as $row) {
if (!$this->context->employee->hasAuthOnShop($row['id_shop'])) {
$exclude_ids[] = $row['id_shop'];
}
}
Db::getInstance()->delete($this->table . '_shop', '`' . $this->identifier . '` = ' . (int) $id_object . ($exclude_ids ? ' AND id_shop NOT IN (' . implode(', ', $exclude_ids) . ')' : ''));
$insert = array();
foreach ($assos_data as $id_shop) {
$insert[] = array(
$this->identifier => $id_object,
'id_shop' => (int) $id_shop,
);
}
return Db::getInstance()->insert($this->table . '_shop', $insert, false, true, Db::INSERT_IGNORE);
}
protected function getSelectedAssoShop($table)
{
if (!Shop::isFeatureActive()) {
return array();
}
$shops = Shop::getShops(true, null, true);
if (count($shops) == 1 && isset($shops[0])) {
return array($shops[0], 'shop');
}
$assos = array();
if (Tools::isSubmit('checkBoxShopAsso_' . $table)) {
foreach (Tools::getValue('checkBoxShopAsso_' . $table) as $id_shop => $value) {
$assos[] = (int) $id_shop;
}
} else if (Shop::getTotalShops(false) == 1) {
// if we do not have the checkBox multishop, we can have an admin with only one shop and being in multishop
$assos[] = (int) Shop::getContextShopID();
}
return $assos;
}
}

View File

@@ -0,0 +1,656 @@
<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductsBlocks.php';
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductFiles.php';
class AdminAnhomeproductsBlocksController extends ModuleAdminController
{
protected $_module = null;
protected $position_identifier = 'position';
protected $_defaultOrderBy = 'position';
protected $_defaultOrderWay = 'ASC';
public function __construct()
{
$this->bootstrap = true;
$this->context = Context::getContext();
$this->table = 'an_homeproducts_blocks';
$this->identifier = 'id_block';
$this->className = 'anHomeProductsBlocks';
$this->lang = true;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->name = 'AdminAnhomeproductsBlocksController';
parent::__construct();
$this->fields_list = [
'id_block' => [
'title' => $this->trans('ID', [], 'Admin.Global'),
'width' => 25,
'search' => false,
],
'title' => [
'title' => $this->trans('Title', [], 'Admin.Global'),
'search' => false,
],
'type' => [
'title' => $this->trans('Type', [], 'Admin.Global'),
'search' => false,
],
'products_display' => [
'title' => $this->l('Products to display'),
'search' => false,
],
'position' => [
'title' => $this->trans('Position', [], 'Admin.Global'),
'search' => false,
'position' => true
],
'active' => [
'title' => $this->trans('Active', [], 'Admin.Global'),
'width' => 40,
'active' => 'update',
'align' => 'center',
'type' => 'bool',
'search' => false,
'orderby' => false
]
];
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL) {
$this->_where .= ' AND a.' . $this->identifier . ' IN (
SELECT sa.' . $this->identifier . '
FROM `' . _DB_PREFIX_ . $this->table . '_shop` sa
WHERE sa.id_shop IN (' . implode(', ', Shop::getContextListShopID()) . ')
)';
}
}
public function l($string, $class = null, $addslashes = false, $htmlentities = true)
{
return parent::l($string, pathinfo(__FILE__, PATHINFO_FILENAME), $addslashes, $htmlentities);
}
// public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
// {
// parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
// foreach ($this->_list as &$list) {
// var_dump($list);
// }
// }
public function setMedia($isNewTheme = false)
{
parent::setMedia($isNewTheme);
$this->addJquery();
$this->js_files[] = _MODULE_DIR_ . 'an_homeproducts/views/js/back.js';
$this->js_files[] = _MODULE_DIR_ . 'an_homeproducts/views/js/anSearchProducts.js';
$this->css_files[_MODULE_DIR_ . 'an_homeproducts/views/css/back.css'] = 'all';
$this->css_files[_MODULE_DIR_ . 'an_homeproducts/views/css/anSearchProducts.css'] = 'all';
$this->js_files[] = _MODULE_DIR_ . 'an_homeproducts/views/js/Sortable.min.js';
$this->js_files[] = _MODULE_DIR_ . 'an_homeproducts/views/js/sorting.js';
}
public function renderList()
{
return parent::renderList() . $this->module->topPromo();
}
public function initToolBarTitle()
{
$this->toolbar_title[] = $this->l('Home Products: Products to display');
}
public function initHeader()
{
parent::initHeader();
$id_lang = $this->context->language->id;
$link = $this->context->link;
$tabs = &$this->context->smarty->tpl_vars['tabs']->value;
foreach ($tabs as &$tab0) {
if ($tab0['class_name'] == 'IMPROVE') {
foreach ($tab0['sub_tabs'] as &$tab1) {
if ($tab1['class_name'] == 'AdminParentModulesSf') {
foreach ($tab1['sub_tabs'] as &$tab2) {
if ($tab2['class_name'] == 'AdminAnhomeproductsBlocks') {
$sub_tabs = &$tab2['sub_tabs'];
$tab = Tab::getTab($id_lang, Tab::getIdFromClassName('AdminAnhomeproductsBlocks'));
$tab['current'] = true;
$tab['href'] = $link->getAdminLink('AdminAnhomeproductsBlocks');
$tab['active'] = true;
$tab['name'] = $this->l('Products to display');
$sub_tabs[] = $tab;
$tab = Tab::getTab($id_lang, Tab::getIdFromClassName('AdminAnhomeproductsBanners'));
$tab['current'] = false;
$tab['href'] = $link->getAdminLink('AdminAnhomeproductsBanners');
$tab['active'] = true;
$tab['name'] = $this->l('Banners');
$sub_tabs[] = $tab;
$tab = Tab::getTab($id_lang, Tab::getIdFromClassName('AdminAnhomeproductsSettings'));
$tab['current'] = false;
$tab['href'] = $link->getAdminLink('AdminAnhomeproductsSettings');
$tab['active'] = true;
$tab['name'] = $this->trans('Settings', [], 'Admin.Global');
$sub_tabs[] = $tab;
break;
}
}
break;
}
}
break;
}
}
}
public function initContent()
{
$this->context->smarty->assign('current_tab_level', 3);
return parent::initContent();
}
public function initPageHeaderToolbar()
{
if (empty($this->display)) {
$this->page_header_toolbar_btn['add_field'] = array(
'href' => self::$currentIndex . '&addan_homeproducts_blocks&token=' . $this->token,
'desc' => $this->trans('Add new', array(), 'Admin.Actions'),
'icon' => 'process-icon-new',
);
}
parent::initPageHeaderToolbar();
}
public function renderForm()
{
$this->initToolbar();
if (!$this->loadObject(true)) {
return;
}
$this->fields_form = array(
'tinymce' => false,
'legend' => ['title' => $this->l('Home Products: Products to display')],
'input' => [],
'buttons' => [
[
'type' => 'submit',
'title' => $this->l('Save'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'name' => 'submit'.$this->table
],
[
'type' => 'submit',
'title' => $this->l('Save and stay'),
'icon' => 'process-icon-save',
'class' => 'pull-right',
'name' => 'submit'.$this->table.'AndStay'
],
],
);
$this->fields_form['input'][] = [
'type' => 'switch',
'name' => 'active',
'label' => $this->l('Active'),
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
];
$this->fields_form['input'][] = [
'type' => 'number',
'name' => 'products_display',
'label' => $this->l('Products to display'),
'col' => 1,
'min' => 1,
'max' => 50,
// 'desc' => $this->l('Define the number of products to be displayed in this block.'),
// 'class' => 'fixed-width-xs',
];
$this->fields_form['input'][] = [
'type' => 'radio',
'label' => $this->trans('Type', [], 'Admin.Global'),
'name' => 'type',
'default_value' => 'new-products',
'class' => 'an-hp-block-type',
'values' => [
[
'id' => 'new-products',
'value' => 'new-products',
'label' => $this->l('New arrivals')
],
[
'id' => 'best-sales',
'value' => 'best-sales',
'label' => $this->l('Best sellers'),
],
[
'id' => 'prices-drop',
'value' => 'prices-drop',
'label' => $this->l('Specials'),
],
// [
// 'id' => 'prices-drop-percentage',
// 'value' => 'prices-drop-percentage',
// 'label' => $this->l('Specials (only percentage discount)'),
// ],
[
'id' => 'category',
'value' => 'category',
'label' => $this->l('Category'),
],
[
'id' => 'categories',
'value' => 'categories',
'label' => $this->l('Categories (multiple)'),
],
[
'id' => 'products',
'value' => 'products',
'label' => $this->l('Products'),
],
],
];
$this->fields_form['input'][] = array(
'type' => 'anSearchProductsList',
'ignore' => true,
'name' => 'productIds[]',
'class' => 'js-an_productfields_products js-an_productfields-searchProducts-components',
'classSarchInput' => 'js-an_productfields-search-input',
'label' => '',
'searchProdutsController' => $this->context->link->getAdminLink('AdminAnhomeproductsAjax', true, [], ['ajax'=>1, 'action' =>'searchProducts']),
'form_group_class' => 'js-an_productfields-search-group'
);
$this->fields_form['input'][] = array(
'type' => 'text',
'anSearchProductsInput' => true,
'ignore' => true,
'label' => $this->l('Products'),
'name' => 'products_input',
'size' => 50,
'maxlength' => 50,
'col' => 4,
'placeholder' => $this->l('Search and add a product'),
'class' => 'js-an_productfields-search-input js-an_productfields-searchProducts-components anSearchProducts-input',
'form_group_class' => 'js-an_productfields-search-group'
);
$this->fields_value['productIds[]'] = anHomeProductsBlocks::getProducsByIdBlock(Tools::getValue('id_block'));
$this->fields_form['input'][] = [
'type' => 'select',
'label' => $this->module->l('Category'),
'name' => 'id_category',
'form_group_class' => 'js-hp-block-category',
'options' => [
'query' => array_merge(
[
['id_category' => '0', 'name' => '-'],
],
$tr = $this->getSimpleTreeCategories()
),
'id' => 'id_category',
'name' => 'name',
],
];
$this->fields_form['input'][] = [
'type' => 'switch',
'name' => 'show_sub_cat',
'form_group_class' => 'js-hp-block-show_sub_cat',
'label' => $this->l('Show sub categories'),
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
];
$this->fields_form['input'][] = [
'type' => 'categories',
'label' => $this->l('Categories'),
'name' => 'ids_categories',
'form_group_class' => 'js-hp-block-categories',
'tree' => [
'id' => 'id_root_category',
'use_checkbox' => true,
'selected_categories' => anHomeProductsBlocks::getBlockCategories(Tools::getValue('id_block'))
]
];
$this->fields_form['input'][] = [
'type' => 'switch',
'name' => 'show_sort',
'form_group_class' => 'js-hp-block-show_sort',
'label' => $this->l('Show sort'),
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
];
$this->fields_form['input'][] = [
'type' => 'html',
'name' => 'line1',
'html_content' => 'hr',
];
$this->fields_form['input'][] = [
'type' => 'text',
'name' => 'link',
'label' => $this->l('Link'),
'lang' => true,
];
$this->fields_form['input'][] = [
'type' => 'text',
'name' => 'title',
'label' => $this->l('Title'),
'required' => true,
'lang' => true,
];
$this->fields_form['input'][] = [
'type' => 'textarea',
'class' => 'autoload_rte',
'name' => 'text',
'label' => $this->l('Text'),
'lang' => true,
];
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = [
'required' => true,
'type' => 'shop',
'label' => $this->l('Shop association'),
'name' => 'checkBoxShopAsso',
];
}
return parent::renderForm();
}
public function getSimpleTreeCategories()
{
// getCategories
// getAllCategoriesName
// getChildren
// getNestedCategories
// Category::getRootCategory()->id
// $cat = new Category (Category::getRootCategory()->id, $this->context->language->id);
// $tr = $cat->recurseLiteCategTree();
$cats = Category::getAllCategoriesName(Category::getRootCategory()->id, $this->context->language->id);
return $cats;
}
public function processSave()
{
if (Tools::getIsset('title_' . $this->context->language->id)) {
if (Tools::getValue('title_' . $this->context->language->id) == '') {
$this->errors[] = $this->l('Please enter a Title');
}
}
if (!empty($this->errors)) {
$this->display = 'edit';
return false;
}
$object = parent::processSave();
if (isset($object->id) && $object->id) {
switch (Tools::getValue('type')){
case 'categories':
$this->updateCategories(Tools::getValue('ids_categories'), $object->id);
break;
case 'products':
$this->updateProducts(Tools::getValue('productIds'), $object->id);
break;
default:
$this->updateCategories(Tools::getValue('ids_categories'), $object->id);
}
}
$this->module->_clearCache('*');
anHomeProductsBlocks::exportJsonBlocks($this->module->filesManager);
if (Tools::getIsset('submit'.$this->table.'AndStay')) {
$this->redirect_after = $this->context->link->getAdminLink($this->controller_name).'&conf=4&updatean_homeproducts_blocks&token='.$this->token.'&id_block='.$object->id;
}
if ($object->type == 'best-sales' || $object->type == 'categories' || $object->type == 'products'){
$object->show_sort = 0;
$object->save();
}
return $object;
}
public function processDelete()
{
$object = parent::processDelete();
$this->module->_clearCache('*');
anHomeProductsBlocks::exportJsonBlocks($this->module->filesManager);
return $object;
}
protected function updateCategories($ids, $idBlock)
{
if (!$idBlock){
return false;
}
Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute('DELETE FROM `'._DB_PREFIX_.'an_homeproducts_blocks_categories` WHERE `id_block`='.(int) $idBlock.' ');
if (!$ids || count($ids) == 0) {
$ids[] = 0;
}
$ids = array_unique($ids);
foreach ($ids as $id) {
$sql = 'INSERT INTO `'._DB_PREFIX_.'an_homeproducts_blocks_categories` (`id_block`, `id_category`)
VALUES ("'.(int) $idBlock.'", "'.(int) $id.'")';
Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute($sql);
}
return true;
}
protected function updateProducts($ids, $idBlock)
{
if (!$idBlock){
return false;
}
Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute('DELETE FROM `'._DB_PREFIX_.'an_homeproducts_blocks_products` WHERE `id_block`='.(int) $idBlock.' ');
if (!$ids || count($ids) == 0) {
$ids[] = 0;
}
$ids = array_unique($ids);
$position = 1;
foreach ($ids as $id) {
$sql = 'INSERT INTO `'._DB_PREFIX_.'an_homeproducts_blocks_products` (`id_block`, `id_product`, `position`)
VALUES ("'.(int) $idBlock.'", "'.(int) $id.'", "'.(int) $position.'")';
Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute($sql);
$position++;
}
return true;
}
public function ajaxProcessUpdatePositions()
{
$status = false;
$position = 0;
$widget = (array)Tools::getValue('block');
foreach ($widget as $key => $item){
$ids = explode('_', $item);
$sql = 'UPDATE `' . _DB_PREFIX_ . $this->table .'` SET position="'.(int) $position.'" WHERE '.$this->identifier.'="'.(int) $ids['2'].'" ';
Db::getInstance(_PS_USE_SQL_SLAVE_)->execute($sql);
$position++;
}
if (count($widget) > 0){
$status = true;
}
anHomeProductsBlocks::exportJsonBlocks($this->module->filesManager);
$this->module->_clearCache('*');
return $this->setJsonResponse(array(
'success' => $status,
'message' => $this->l($status ? 'Blocks reordered successfully' : 'An error occurred')
));
}
protected function setJsonResponse($response)
{
header('Content-Type: application/json; charset=utf8');
print(json_encode($response));
exit;
}
protected function updateAssoShop($id_object)
{
if (!Shop::isFeatureActive()) {
return;
}
$assos_data = $this->getSelectedAssoShop($this->table, $id_object);
$exclude_ids = $assos_data;
foreach (Db::getInstance()->executeS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'shop') as $row) {
if (!$this->context->employee->hasAuthOnShop($row['id_shop'])) {
$exclude_ids[] = $row['id_shop'];
}
}
Db::getInstance()->delete($this->table . '_shop', '`' . $this->identifier . '` = ' . (int) $id_object . ($exclude_ids ? ' AND id_shop NOT IN (' . implode(', ', $exclude_ids) . ')' : ''));
$insert = array();
foreach ($assos_data as $id_shop) {
$insert[] = array(
$this->identifier => $id_object,
'id_shop' => (int) $id_shop,
);
}
return Db::getInstance()->insert($this->table . '_shop', $insert, false, true, Db::INSERT_IGNORE);
}
protected function getSelectedAssoShop($table)
{
if (!Shop::isFeatureActive()) {
return array();
}
$shops = Shop::getShops(true, null, true);
if (count($shops) == 1 && isset($shops[0])) {
return array($shops[0], 'shop');
}
$assos = array();
if (Tools::isSubmit('checkBoxShopAsso_' . $table)) {
foreach (Tools::getValue('checkBoxShopAsso_' . $table) as $id_shop => $value) {
$assos[] = (int) $id_shop;
}
} else if (Shop::getTotalShops(false) == 1) {
// if we do not have the checkBox multishop, we can have an admin with only one shop and being in multishop
$assos[] = (int) Shop::getContextShopID();
}
return $assos;
}
}

View File

@@ -0,0 +1,347 @@
<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductsBlocks.php';
class AdminAnhomeproductsSettingsController extends ModuleAdminController
{
protected $_module = null;
public function __construct()
{
$this->bootstrap = true;
$this->display = 'view';
$this->name = 'AdminAnhomeproductsSettingsController';
parent::__construct();
}
public function l($string, $class = null, $addslashes = false, $htmlentities = true)
{
return parent::l($string, pathinfo(__FILE__, PATHINFO_FILENAME), $addslashes, $htmlentities);
}
public function setMedia($isNewTheme = false)
{
parent::setMedia($isNewTheme);
$this->addJquery();
$this->js_files[] = _MODULE_DIR_ . 'an_homeproducts/views/js/back_settings.js';
}
public function initToolBarTitle()
{
$this->toolbar_title[] = $this->module->l('Home Products: Settings');
}
public function initHeader()
{
parent::initHeader();
$id_lang = $this->context->language->id;
$link = $this->context->link;
$tabs = &$this->context->smarty->tpl_vars['tabs']->value;
foreach ($tabs as &$tab0) {
if ($tab0['class_name'] == 'IMPROVE') {
foreach ($tab0['sub_tabs'] as &$tab1) {
if ($tab1['class_name'] == 'AdminParentModulesSf') {
foreach ($tab1['sub_tabs'] as &$tab2) {
if ($tab2['class_name'] == 'AdminAnhomeproductsSettings') {
$sub_tabs = &$tab2['sub_tabs'];
$tab = Tab::getTab($id_lang, Tab::getIdFromClassName('AdminAnhomeproductsBlocks'));
$tab['current'] = false;
$tab['href'] = $link->getAdminLink('AdminAnhomeproductsBlocks');
$tab['active'] = true;
$tab['name'] = $this->l('Products to display');
$sub_tabs[] = $tab;
$tab = Tab::getTab($id_lang, Tab::getIdFromClassName('AdminAnhomeproductsBanners'));
$tab['current'] = false;
$tab['href'] = $link->getAdminLink('AdminAnhomeproductsBanners');
$tab['active'] = true;
$tab['name'] = $this->l('Banners');
$sub_tabs[] = $tab;
$tab = Tab::getTab($id_lang, Tab::getIdFromClassName('AdminAnhomeproductsSettings'));
$tab['current'] = true;
$tab['href'] = $link->getAdminLink('AdminAnhomeproductsSettings');
$tab['active'] = true;
$tab['name'] = $this->trans('Settings', [], 'Admin.Global');
$sub_tabs[] = $tab;
break;
}
}
break;
}
}
break;
}
}
}
public function initContent()
{
$this->context->smarty->assign('current_tab_level', 3);
return parent::initContent();
}
/**
* Create the structure of your form.
*/
protected function getSettingsForm()
{
$form['form']['legend'] = [
'title' => $this->l('Settings'),
];
$form['form']['submit'] = [
'name' => 'save',
'title' => $this->l('Save'),
];
$form['form']['input'][] = [
'type' => 'switch',
'name' => an_homeproducts::PREFIX . 'use_cache',
'label' => $this->l('Use cache'),
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
'form_group_class' => 'hide',
];
$form['form']['input'][] = [
'type' => 'radio',
'label' => $this->l('Type view'),
'name' => an_homeproducts::PREFIX . 'view_type',
'values' => [
[
'id' => 'blocks',
'value' => 'blocks',
'label' => $this->l('Blocks')
],
[
'id' => 'tabs',
'value' => 'tabs',
'label' => $this->l('Tabs'),
],
],
];
$form['form']['input'][] = [
'type' => 'switch',
'name' => an_homeproducts::PREFIX . 'slider',
'label' => $this->l('Slider'),
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
];
$form['form']['input'][] = [
'type' => 'switch',
'name' => an_homeproducts::PREFIX . 'slider_nav',
'label' => $this->l('Slider Nav'),
'form_group_class' => 'js-hp-setting-slider-option',
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
];
$form['form']['input'][] = [
'type' => 'switch',
'name' => an_homeproducts::PREFIX . 'slider_dots',
'label' => $this->l('Slider Dots'),
'form_group_class' => 'js-hp-setting-slider-option',
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
];
$form['form']['input'][] = [
'type' => 'switch',
'name' => an_homeproducts::PREFIX . 'slider_loop',
'label' => $this->l('Slider Loop'),
'form_group_class' => 'js-hp-setting-slider-option',
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
];
$form['form']['input'][] = [
'type' => 'switch',
'name' => an_homeproducts::PREFIX . 'show_load_more',
'label' => $this->l('Show "Load more"'),
'desc' => $this->l('Not used for Categories (multiple) and Products'),
'form_group_class' => 'js-hp-setting-load_more',
'values' => [
[
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
],
[
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
]
],
];
$form['form']['input'][] = [
'type' => 'text',
'label' => $this->l('Title'),
'name' => an_homeproducts::PREFIX . 'title',
'lang' => true,
];
$form['form']['input'][] = [
'type' => 'textarea',
'class' => 'autoload_rte',
'name' => an_homeproducts::PREFIX . 'text',
'label' => $this->l('Text'),
'lang' => true,
'html' => true,
];
return $form;
}
public function renderView()
{
$languages = $this->context->controller->getLanguages();
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->name_controller = $this->name;
$helper->submit_action = $this->name;
$helper->currentIndex = $this->context->link->getAdminLink('AdminAnhomeproductsSettings', false);
$helper->token = Tools::getAdminTokenLite('AdminAnhomeproductsSettings');
$helper->default_form_language = $this->context->language->id;
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
$helper->tpl_vars = [
'uri' => $this->module->getPathUri(),
'languages' => $languages,
'id_language' => $this->context->language->id
];
$form = $this->getSettingsForm();
foreach ($form['form']['input'] as $input){
if (isset($input['lang']) && $input['lang']){
$value = [];
foreach ($languages as $language){
$value[$language['id_lang']] = Configuration::get($input['name'], $language['id_lang']);
}
$helper->tpl_vars['fields_value'][$input['name']] = $value;
} else {
$helper->tpl_vars['fields_value'][$input['name']] = Configuration::get($input['name']);
}
}
return $helper->generateForm([$form]);
}
public function postProcess()
{
$form = $this->getSettingsForm();
if (Tools::isSubmit($form['form']['submit']['name'])) {
$languages = Language::getLanguages(false);
foreach ($form['form']['input'] as $input){
$html = false;
if (isset($input['html']) && $input['html']){
$html = true;
}
if (isset($input['lang']) && $input['lang']){
$value = [];
foreach ($languages as $language){
$value[$language['id_lang']] = Tools::getValue($input['name'].'_' . $language['id_lang']);
}
Configuration::updateValue($input['name'], $value, $html);
} else {
Configuration::updateValue($input['name'], Tools::getValue($input['name']), $html);
}
}
$this->module->_clearCache('*');
$currentIndex = $this->context->link->getAdminLink('AdminAnhomeproductsSettings', false);
$token = Tools::getAdminTokenLite('AdminAnhomeproductsSettings');
Tools::redirectAdmin($currentIndex . '&token=' . $token . '&conf=4');
}
return true;
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductsBlocks.php';
class an_homeproductsajaxModuleFrontController extends ModuleFrontController
{
public function initContent()
{
$this->assignGeneralPurposeVariables();
$result = [];
if (Tools::isSubmit('action')) {
if (Tools::getValue('token') != Tools::getToken(false)){
Tools::redirect('index.php?controller=404');
}
$actionName = Tools::getValue('action', '') . 'Action';
if (method_exists($this, $actionName)) {
$result = $this->$actionName();
}
}
die(json_encode($result));
}
public function getProductsAction()
{
$return = [];
$config = [
'view_type' => Configuration::get('an_hp_view_type'),
'show_sort' => Configuration::get('an_hp_show_sort'),
'slider' => Configuration::get('an_hp_slider'),
'slider_nav' => Configuration::get('an_hp_slider_nav'),
'slider_dots' => Configuration::get('an_hp_slider_dots'),
'slider_loop' => Configuration::get('an_hp_slider_loop'),
'show_load_more' => Configuration::get(an_homeproducts::PREFIX . 'show_load_more'),
'title' => Configuration::get('an_hp_title', $this->context->language->id),
'text' => Configuration::get('an_hp_text', $this->context->language->id),
];
$blockId = Tools::getValue('blockId');
$type = Tools::getValue('type');
$params = [
'page' => (int) Tools::getValue('page'),
'sort' => Tools::getValue('sort'),
'idCategory' => (int) Tools::getValue('idCategory'),
];
$blockObj = new anHomeProductsBlocks($blockId, $this->context->language->id);
$blockObj->getData($params);
$block = (array)$blockObj;
$templateFile = 'ajax-products.tpl';
if ($type == 'tab'){
$templateFile = 'content.tpl';
$this->context->smarty->assign('block', $block);
}
$this->context->smarty->assign('widget', [
'banners' => anHomeProductsBanners::getBanners(),
'config' => $config
]);
$this->context->smarty->assign('products', $block['products']);
$return['productsNextPage'] = $block['productsNextPage'];
$return['products'] = $this->module->display($this->module->name, $templateFile);
die(json_encode($return));
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 148.01 30.98"><title>Charme_logo</title><path d="M24.57,27a.48.48,0,0,0-.22,0,1.21,1.21,0,0,0-.2.14,14.19,14.19,0,0,1-1.79,1.43,10.76,10.76,0,0,1-2,1,11.22,11.22,0,0,1-2.3.63,17.45,17.45,0,0,1-2.85.21,12.12,12.12,0,0,1-4.73-.92A10.83,10.83,0,0,1,6.75,27a12.36,12.36,0,0,1-2.51-4.2,16.54,16.54,0,0,1-.9-5.65,15.92,15.92,0,0,1,.91-5.55A12.29,12.29,0,0,1,6.81,7.35a11.32,11.32,0,0,1,3.91-2.68,13.08,13.08,0,0,1,5-.93A13.89,13.89,0,0,1,18.34,4a13,13,0,0,1,2,.54,9.13,9.13,0,0,1,1.53.72c.43.26.79.5,1.09.72l.75.54a.89.89,0,0,0,.48.23.59.59,0,0,0,.53-.26l.65-.94a16.83,16.83,0,0,0-2-1.56,11.71,11.71,0,0,0-2.2-1.13,14.4,14.4,0,0,0-2.51-.7,17,17,0,0,0-3-.24A15.34,15.34,0,0,0,9.79,3,13.2,13.2,0,0,0,5.18,6.11a14.13,14.13,0,0,0-3,4.81,17.3,17.3,0,0,0-1.06,6.19,18.14,18.14,0,0,0,1,6.28A14.32,14.32,0,0,0,5,28.2a12.67,12.67,0,0,0,4.42,3.08,14.54,14.54,0,0,0,5.67,1.08,17.85,17.85,0,0,0,3.4-.3,14.53,14.53,0,0,0,2.84-.87,12.39,12.39,0,0,0,2.39-1.35,13.63,13.63,0,0,0,2-1.78l-.84-.9A.49.49,0,0,0,24.57,27ZM46.24,12.86a5.53,5.53,0,0,0-2.18-1.58,7.74,7.74,0,0,0-3-.55,8.24,8.24,0,0,0-4.17,1.06,11.65,11.65,0,0,0-3.32,2.86V1.38h-2V32h2V16.31a11.28,11.28,0,0,1,3.16-2.92,7.27,7.27,0,0,1,3.83-1.06A5,5,0,0,1,44.64,14,7.19,7.19,0,0,1,46,18.63V32h2V18.63a11.14,11.14,0,0,0-.45-3.29A6.89,6.89,0,0,0,46.24,12.86Zm20.54-.08a5.38,5.38,0,0,0-2.09-1.53,7.42,7.42,0,0,0-2.94-.54,9.68,9.68,0,0,0-4.11.84A12.23,12.23,0,0,0,54.19,14l.36.61a.68.68,0,0,0,.63.38A1.28,1.28,0,0,0,56,14.6a10.85,10.85,0,0,1,1.2-.92,8.86,8.86,0,0,1,1.8-.93,7,7,0,0,1,2.58-.42,4.46,4.46,0,0,1,3.71,1.57,7.07,7.07,0,0,1,1.25,4.48v2.19a35.07,35.07,0,0,0-6.09.59,15.56,15.56,0,0,0-4.15,1.34,6.33,6.33,0,0,0-2.36,2A4.33,4.33,0,0,0,53.14,27a5.88,5.88,0,0,0,.47,2.45,4.89,4.89,0,0,0,1.26,1.68,5.3,5.3,0,0,0,1.78,1,7,7,0,0,0,2.09.31,10.74,10.74,0,0,0,2.35-.24,8.62,8.62,0,0,0,2-.71,10.25,10.25,0,0,0,1.78-1.13,21.23,21.23,0,0,0,1.71-1.52l.3,2.67a.72.72,0,0,0,.78.59h.8V18.38A11.23,11.23,0,0,0,68,15.2,6.72,6.72,0,0,0,66.78,12.78ZM66.5,27.37c-.49.51-1,1-1.49,1.41a9.49,9.49,0,0,1-1.63,1.13,8.5,8.5,0,0,1-1.9.73,8.7,8.7,0,0,1-2.24.27,5.54,5.54,0,0,1-1.58-.23A3.71,3.71,0,0,1,56.34,30a3.61,3.61,0,0,1-.92-1.26,4.46,4.46,0,0,1-.34-1.83,3.24,3.24,0,0,1,.66-2,5.22,5.22,0,0,1,2.06-1.5,14.59,14.59,0,0,1,3.56-1,36.93,36.93,0,0,1,5.14-.46Zm17-16.66a6.14,6.14,0,0,0-4.14,1.44,9.94,9.94,0,0,0-2.7,4l-.16-4.42a.81.81,0,0,0-.18-.51.81.81,0,0,0-.52-.14h-1V32h2V18.4a10.45,10.45,0,0,1,2.47-4.26,5.4,5.4,0,0,1,3.9-1.47,7.92,7.92,0,0,1,1.16.08,7.44,7.44,0,0,1,.85.19c.23.07.43.13.58.19a1,1,0,0,0,.36.08.38.38,0,0,0,.42-.33l.27-1.39a6.13,6.13,0,0,0-1.51-.58A7,7,0,0,0,83.52,10.71Zm33.32,2.06a5.52,5.52,0,0,0-2.11-1.52,7.11,7.11,0,0,0-2.79-.52,7.73,7.73,0,0,0-2.14.3,6.83,6.83,0,0,0-1.92.93,6.65,6.65,0,0,0-1.56,1.57,7.1,7.1,0,0,0-1.06,2.25,7,7,0,0,0-1.86-3.71,5,5,0,0,0-3.66-1.34,6.16,6.16,0,0,0-1.88.28,6.83,6.83,0,0,0-1.68.8,9.08,9.08,0,0,0-1.49,1.24,12.88,12.88,0,0,0-1.3,1.58l-.19-3a.57.57,0,0,0-.63-.52h-1.1V32h2V16.18a9.77,9.77,0,0,1,2.59-2.83,5.39,5.39,0,0,1,3.16-1A4.17,4.17,0,0,1,102.77,14,7.63,7.63,0,0,1,104,18.63V32h2V18.63a7.68,7.68,0,0,1,.45-2.74,5.88,5.88,0,0,1,1.22-2,5.21,5.21,0,0,1,1.77-1.19,5.56,5.56,0,0,1,2.1-.4,4.62,4.62,0,0,1,3.78,1.61,7.2,7.2,0,0,1,1.33,4.69V32h2V18.63a11.15,11.15,0,0,0-.47-3.37A6.82,6.82,0,0,0,116.84,12.77Zm21.88.35a7.44,7.44,0,0,0-2.61-1.78,8.54,8.54,0,0,0-3.27-.61,9.73,9.73,0,0,0-4,.78,8.5,8.5,0,0,0-3,2.16A9.65,9.65,0,0,0,124,17a13.19,13.19,0,0,0-.64,4.16,15,15,0,0,0,.69,4.75,10,10,0,0,0,2,3.51,8.23,8.23,0,0,0,3,2.18,9.93,9.93,0,0,0,3.92.75,12.37,12.37,0,0,0,2.34-.23,15.18,15.18,0,0,0,2.19-.62,9.72,9.72,0,0,0,1.85-.94,5.83,5.83,0,0,0,1.34-1.18l-.55-.68a.49.49,0,0,0-.42-.21,1.41,1.41,0,0,0-.67.35,11.17,11.17,0,0,1-1.26.78,9.76,9.76,0,0,1-1.94.78,9.65,9.65,0,0,1-2.74.35,8.22,8.22,0,0,1-3.2-.61,6.52,6.52,0,0,1-2.44-1.83,8.35,8.35,0,0,1-1.55-3,14,14,0,0,1-.55-4.15v-.4H140.5a.51.51,0,0,0,.43-.17,1,1,0,0,0,.14-.63,11.21,11.21,0,0,0-.63-3.91A8.1,8.1,0,0,0,138.72,13.12Zm-13.25,6.31a10.6,10.6,0,0,1,.77-3,7.62,7.62,0,0,1,1.51-2.28A6.52,6.52,0,0,1,130,12.73a7.77,7.77,0,0,1,2.9-.51,6.62,6.62,0,0,1,2.6.5,5.57,5.57,0,0,1,2,1.42,6.32,6.32,0,0,1,1.3,2.27,9.12,9.12,0,0,1,.47,3ZM149,29.64a2.42,2.42,0,0,0-.42-.62,2.31,2.31,0,0,0-.63-.42,1.9,1.9,0,0,0-.75-.16,1.93,1.93,0,0,0-.77.16,2.21,2.21,0,0,0-.61.42,2,2,0,0,0-.56,1.38,1.94,1.94,0,0,0,2.69,1.79,1.91,1.91,0,0,0,.63-.41,2.21,2.21,0,0,0,.42-.61,1.92,1.92,0,0,0,.15-.77A2,2,0,0,0,149,29.64Z" transform="translate(-1.13 -1.38)"/></svg>

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

View File

@@ -0,0 +1,97 @@
<?php
/**
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*/
if (!defined('_PS_VERSION_')) {
exit;
}
$sql = [];
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_blocks` (
`id_block` int(10) unsigned NOT NULL AUTO_INCREMENT,
`special_id_block` varchar(50) NOT NULL,
`type` varchar(25) NOT NULL,
`active` tinyint(1) unsigned NOT NULL DEFAULT 1,
`show_sort` tinyint(1) unsigned NOT NULL DEFAULT 0,
`products_display` int(10) NOT NULL DEFAULT 8,
`id_category` int(10) NOT NULL DEFAULT 0,
`show_sub_cat` tinyint(1) unsigned NOT NULL DEFAULT 0,
`position` int(10) NOT NULL,
PRIMARY KEY(`id_block`)
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8';
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_blocks_products` (
`id_block` int(10) unsigned NOT NULL,
`id_product` int(10) unsigned NOT NULL,
`position` int(10) NOT NULL,
PRIMARY KEY(`id_block`, `id_product`)
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8';
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_blocks_categories` (
`id_block` int(10) unsigned NOT NULL,
`id_category` int(10) unsigned NOT NULL,
PRIMARY KEY(`id_block`, `id_category`)
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8';
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'an_homeproducts_blocks_shop` (
`id_block` int(10) unsigned NOT NULL,
`id_shop` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_block`, `id_shop`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;';
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_blocks_lang` (
`id_block` int(10) unsigned NOT NULL,
`title` varchar(255) NOT NULL,
`text` text,
`link` varchar(255) NOT NULL,
`id_lang` varchar(255) NOT NULL,
PRIMARY KEY(`id_block`, `id_lang`)
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8';
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_banners` (
`id_banner` int(10) unsigned NOT NULL AUTO_INCREMENT,
`special_id_banner` varchar(50) NOT NULL,
`block` varchar(255) NOT NULL,
`block_position` int(10) unsigned NOT NULL,
`col` int(10) NOT NULL DEFAULT 12,
`color_title` varchar(20) NOT NULL,
`color_text` varchar(20) NOT NULL,
`template` varchar(255) NOT NULL,
`show_on` int(10) unsigned NOT NULL,
`active` tinyint(1) unsigned NOT NULL DEFAULT 1,
`position` int(10) NOT NULL,
PRIMARY KEY(`id_banner`)
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8';
$sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_banners_lang` (
`id_banner` int(10) unsigned NOT NULL,
`title` varchar(255) NOT NULL,
`text` text,
`link` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`id_lang` varchar(255) NOT NULL,
PRIMARY KEY(`id_banner`, `id_lang`)
) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8';
$sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'an_homeproducts_banners_shop` (
`id_banner` int(10) unsigned NOT NULL,
`id_shop` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_banner`, `id_shop`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8;';
return $sql;

View File

@@ -0,0 +1,33 @@
<?php
/**
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*/
if (!defined('_PS_VERSION_')) {
exit;
}
$sql = [];
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_blocks`';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_blocks_shop`';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_blocks_lang`';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_blocks_products`';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_blocks_categories`';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_banners`';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_banners_lang`';
$sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'an_homeproducts_banners_shop`';
return $sql;

View File

@@ -0,0 +1,80 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{an_homeproducts}prestashop>an_homeproducts_4c9a5b9683fc96c83f62635c954e808a'] = 'Hlavní stránka Produkty';
$_MODULE['<{an_homeproducts}prestashop>an_homeproducts_4627b0b438c8b8e8f31dc2a4f54340be'] = 'Novinky, Nejprodávanější, Speciální, Kategorie, Kategorie (více), Doporučené produkty a Bannery';
$_MODULE['<{an_homeproducts}prestashop>an_homeproducts_0f379daaee21894a7c6453950658fe8b'] = 'Opravdu chcete modul odinstalovat?';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_b718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_be53a0541a6d36f6ecb879fa2c584b08'] = 'Obrázek';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_b78a3223503896721cca1303f776159b'] = 'Název';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_e1e4c8c9ccd9fc39c391da4bcd093fb2'] = 'Blok';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_517ebf75f85434d669c39d8af75631b0'] = 'Poloha bloku';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_52f5e0bc3859bc5f5e25130b6c7e8881'] = 'Pozice';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_5849bfda165a2a82f62deea071fdc9ae'] = 'Col';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_ec53a8c4f07baed5d8825072c89799be'] = 'Stav';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_4cc6684df7b4a92b1dec6fce3264fac8'] = 'Globální';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_a4ffdcf0dc1f31b9acaf295d75b51d00'] = 'Nahoře';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_2ad9d63b69c4a10a5cc9cad923133bc4'] = 'Spodní';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_ef8f464e2c2aaf8bde00ef364b3dbe4e'] = 'Hlavní stránka Produkty: Bannery';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_c9cc8cce247e49bae79f15173ce97354'] = 'Uložit';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_9ea67be453eaccf020697b4654fc021a'] = 'Uložit a zůstat';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_4d3d769b812b6faa6b76e1a8abaece2d'] = 'Aktivní';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Povoleno';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_b9f5c797ebbf55adccdd8539a65a0241'] = 'Zakázáno';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_d4e32ec85eac9fd72b611a2e1f971e29'] = 'Od 2 do 12';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_278c491bdd8a53618c149c4ac790da34'] = 'Šablona';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_1e0729c9b04b2d1d3268d0cfdcf4a899'] = 'Ukaž na:';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_d66f1c661580e5aad5d69ec559971faf'] = 'Desktop & Mobile';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_2310408a63388fe57e3a4177168a8798'] = 'Desktop';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_87d17f4624a514e81dc7c8e016a7405c'] = 'Mobil';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_97e7c9a7d06eac006a28bf05467fcc8b'] = 'Odkaz';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_9dffbf69ffba8bc38bc4e01abf4b1675'] = 'Text';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsbanners_9d55fc80bbb875322aa67fd22fc98469'] = 'Asociace obchodu';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_c24bd5d8d2726ce02edc5d33c1c89298'] = 'Hlavní stránka Produkty: Nastavení';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_f4f70727dc34561dfde1a3c529b6205c'] = 'Nastavení';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_c9cc8cce247e49bae79f15173ce97354'] = 'Uložit';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_276e3171a63595e207ec292fce891277'] = 'Použít cache';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Povoleno';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_b9f5c797ebbf55adccdd8539a65a0241'] = 'Zakázáno';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_9e39a54967dd75b7c59866afd464f8f4'] = 'Typ zobrazení';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_04c4f9f595c4f21d1de65eb07056c15a'] = 'Bloky';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_7015777bcc86cd0c5e4819310d62b040'] = 'Záložky';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_2d9b9a764fb0be4be10e1b2fce63f561'] = 'Posuvník';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_cd51b22a124b6ef600c5fdc05512d129'] = 'Posuvník Nav';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_7f564ba055b85034abf7d6869d4e51b1'] = 'Posuvník Tečky';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_18b4b53f0d41f09a80314e62a1290feb'] = 'Posuvná smyčka';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_8ba64d48a415367709c280602ea41e57'] = 'Zobrazit \"Načíst více\"';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_b78a3223503896721cca1303f776159b'] = 'Název';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductssettings_9dffbf69ffba8bc38bc4e01abf4b1675'] = 'Text';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_b718adec73e04ce3ec720dd11a06a308'] = 'ID';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_b78a3223503896721cca1303f776159b'] = 'Název';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_a1fa27779242b4902f7ae3bdd5c6d508'] = 'Typ';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_26986c3388870d4148b1b5375368a83d'] = 'Produkty k zobrazení';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_52f5e0bc3859bc5f5e25130b6c7e8881'] = 'Pozice';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_ec53a8c4f07baed5d8825072c89799be'] = 'Stav';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_55a1447491996db95486ff513b00c754'] = 'Hlavní produkty: Produkty k zobrazení';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_c9cc8cce247e49bae79f15173ce97354'] = 'Uložit';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_9ea67be453eaccf020697b4654fc021a'] = 'Uložit a zůstat';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_4d3d769b812b6faa6b76e1a8abaece2d'] = 'Aktivní';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Povoleno';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_b9f5c797ebbf55adccdd8539a65a0241'] = 'Zakázáno';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_3ea7689283770958661c27c37275b89c'] = 'Definujte počet produktů, které se mají zobrazit v tomto bloku.';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_a0d0ebc37673b9ea77dd7c1a02160e2d'] = 'Nově přidané';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_01f7ac959c1e6ebbb2e0ee706a7a5255'] = 'Nejprodávanější';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_d1aa22a3126f04664e0fe3f598994014'] = 'Speciality';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_3adbdb3ac060038aa0e6e6c138ef9873'] = 'Kategorie';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_a305f20dd3cd5e0ab868665f11289ed7'] = 'Kategorie (více)';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_068f80c7519d0528fb08e82137a72131'] = 'Produkty';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_304875e58e0b1c69f1fd40710f126fca'] = 'Zobrazit podkategorie';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_af1b98adf7f686b84cd0b443e022b7a0'] = 'Kategorie';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_c0693ce5147dda7b8bf7b5fa5ab9b75b'] = 'Zobrazit řazení';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_97e7c9a7d06eac006a28bf05467fcc8b'] = 'Odkaz';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_9dffbf69ffba8bc38bc4e01abf4b1675'] = 'Text';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_9d55fc80bbb875322aa67fd22fc98469'] = 'Sdružení obchodu';
$_MODULE['<{an_homeproducts}prestashop>adminanhomeproductsblocks_e910f2d7356732223cfec9f545181d1e'] = 'Zadejte prosím název';
$_MODULE['<{an_homeproducts}prestashop>form_f2a6c498fb90ee345d997f888fce3b18'] = 'Smazat';
$_MODULE['<{an_homeproducts}prestashop>form_92fbf0e5d97b8afd7e73126b52bdc4bb'] = 'Vyberte soubor';
$_MODULE['<{an_homeproducts}prestashop>content_6f9d01a14011f05fffe48559583fc609'] = 'Řadit podle:';
$_MODULE['<{an_homeproducts}prestashop>content_40dec546414c1ebdfde8d9858f0938c3'] = 'Všechny produkty';
$_MODULE['<{an_homeproducts}prestashop>content_f6b5f35f6564a567f1810df0b730e3dc'] = 'Načíst další';

View File

@@ -0,0 +1,54 @@
<?php
/**
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductsBlocks.php';
require_once _PS_MODULE_DIR_ . 'an_homeproducts/classes/anHomeProductsBanners.php';
function upgrade_module_1_0_1($object)
{
$sql = [];
$sql[] = '
ALTER TABLE `' . _DB_PREFIX_ . 'an_homeproducts_blocks`
ADD `special_id_block` varchar(50) NOT NULL AFTER `id_block`
';
$sql[] = '
ALTER TABLE `' . _DB_PREFIX_ . 'an_homeproducts_banners`
ADD `special_id_banner` varchar(50) NOT NULL AFTER `id_banner`
';
$sql[] = 'UPDATE `' . _DB_PREFIX_ . 'an_homeproducts_blocks` SET `special_id_block`= `id_block` ';
$sql[] = 'UPDATE `' . _DB_PREFIX_ . 'an_homeproducts_banners` SET `special_id_banner`= `id_banner` ';
$sql[] = 'ALTER TABLE `' . _DB_PREFIX_ . 'an_homeproducts_banners` CHANGE `block` `block` VARCHAR(25) NOT NULL; ';
$return = true;
foreach ($sql as $_sql) {
$return = Db::getInstance()->Execute($_sql);
if (!$return){
return false;
}
}
anHomeProductsBlocks::exportJsonBlocks();
anHomeProductsBanners::exportJsonBanners();
return true;
}

View File

@@ -0,0 +1,27 @@
<?php
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2023 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_0_11($object)
{
$object->tabAdd([
'class_name' => 'AdminAnhomeproductsAjax',
'parent' => 'AdminParentModulesSf',
'name' => 'Home Products: Ajax',
'active' => 0
], $object);
return true;
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2023 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_0_12($object)
{
$sql = [];
$sql[] = '
ALTER TABLE `' . _DB_PREFIX_ . 'an_homeproducts_banners`
ADD `show_on` int(10) unsigned NOT NULL AFTER `template`
';
$return = true;
foreach ($sql as $_sql) {
$return = Db::getInstance()->Execute($_sql);
if (!$return){
return false;
}
}
return true;
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2023 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_0_18($object)
{
$object->filesManager->createFolders();
if (Tools::copy(_PS_MODULE_DIR_ . 'an_homeproducts/blocks.json', $object->filesManager->fileJsonblocks)){
@unlink(_PS_MODULE_DIR_ . 'an_homeproducts/blocks.json');
}
if (Tools::copy(_PS_MODULE_DIR_ . 'an_homeproducts/banners.json', $object->filesManager->fileJsonBanners)){
@unlink(_PS_MODULE_DIR_ . 'an_homeproducts/banners.json');
}
return true;
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_0_22($object)
{
$sql[] = '
ALTER TABLE `' . _DB_PREFIX_ . 'an_homeproducts_blocks_products`
ADD `position` int(10) NOT NULL
AFTER `id_product` ';
foreach ($sql as $_sql) {
$return = Db::getInstance()->Execute($_sql);
}
return true;
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_0_23($object)
{
Tools::deleteDirectory(_PS_MODULE_DIR_ . 'an_homeproducts/views/templates/admin/anhomeproducts_blocks/helpers/list/');
@unlink(_PS_MODULE_DIR_ . 'an_homeproducts/views/templates/admin/list-img.tpl');
return true;
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
if (!defined('_PS_VERSION_')) {
exit;
}
function upgrade_module_1_0_6($object)
{
Configuration::updateValue('an_hp_use_cache', true);
return true;
}

View File

@@ -0,0 +1,96 @@
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2023 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
.anSearchProducts-wrap {
padding: 0!important;
max-width: 445px;
}
#an_field_search_products_ajax-product-list.an_field_search_ajax_product_list { border: 1px solid #ccc; padding: 0;}
#an_field_search_products_ajax-product-list.an_field_search_ajax_product_list:empty { display: none; }
.an_field_search_products-line,
#an_field_search_products_ajax-product-list.an_field_search_ajax_product_list li {
cursor: pointer;
display: table;
list-style: none;
margin: 0;
/* min-width: 300px; */
width: 100%;
}
#an_field_search_products_ajax-product-list.an_field_search_ajax_product_list li {
padding: 5px;
}
.an_field_search_products-line {
padding: 5px 5px 5px 5px;
border: 1px solid #bbcdd2;
}
.an_field_search_products-line span {
line-height: 19px;
}
.an_field_search_products-line .material-icons {
font-size: 17px;
}
.an_field_search_products-line .more_vert {
margin-right: 5px;
}
.an_field_search_products-line .delete {
margin-left: auto;
padding-left: 5px;
}
#an_field_search_products_ajax-product-list li:hover {
background: #3ed2f0;
}
#an_field_search_products_ajax-product-list li img,
.an_field_search_products img {
width: 50px; display: inline-block;
}
.an_field_search_products-line .label,
#an_field_search_products_ajax-product-list.an_field_search_ajax_product_list li .label {
color: #000;
/* width: calc(100% - 50px); */
width: 100%;
display: flex;
align-items: center;
justify-content: flex-start;
white-space: normal;
text-align: left;
vertical-align: middle;
}
.anSearchProducts-input-wrap {
position: relative;
}
.anSearchProducts-input-wrap::after {
display: inline-block;
line-height: 1;
content: "";
top: 50%;
right: 0.3125rem;
margin-top: -0.6875rem;
font-size: 1.375rem;
font-family: "Material Icons", Arial, Verdana, Tahoma, sans-serif;
font-style: normal;
font-feature-settings: "liga";
text-transform: none;
letter-spacing: normal;
overflow-wrap: normal;
vertical-align: middle;
direction: ltr;
-webkit-font-smoothing: antialiased;
text-rendering: optimizelegibility;
position: absolute;
font-weight: 400;
color: rgb(108, 134, 142);
white-space: nowrap;
}

View File

@@ -0,0 +1,18 @@
/**
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*/
.an-hp-hide {
display: none;
}

View File

@@ -0,0 +1,201 @@
/**
* 2021 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2021 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*/
.an_homeproducts-banner {
margin-bottom: 40px;
}
.an_homeproducts-banner img {
border-radius: 8px;
overflow: hidden;
}
.an_homeproducts-banner-content {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
background: #ececec;
border-radius: 8px;
padding: 30px 40px;
position: relative;
overflow: hidden;
width: 100%;
}
.an_homeproducts-banner-overlay .an_homeproducts-banner-content {
position: absolute;
top: 0;
right: 15px;
bottom: 0;
left: 15px;
background: transparent;
width: calc(100% - 30px);
}
.an_homeproducts-banner-link {
position: absolute;
top: 0;
right: 15px;
bottom: 0;
left: 15px;
z-index: 2;
}
.an_homeproducts-banner .an_homeproducts-banner-title-margin {
margin-bottom: 19px;
}
.an_homeproducts-banner p {
margin-bottom: 0;
}
.an_homeproducts-banner-overlay .an_homeproducts-banner-content p {
color: #fff;
}
.anhp-banner-global-bottom {
margin-top: 30px;
}
.an_homeproducts-title {
margin-bottom: 24px;
}
.an_homeproducts-tab-top {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 30px;
}
.an_homeproducts-link-all {
text-decoration: underline;
color: #000;
}
.an_homeproducts-link-all:hover {
text-decoration: none;
}
.an_homeproducts-tab {
background: transparent;
border: 0;
border-radius: 4px;
margin-right: 6px;
}
.an_homeproducts-tab:hover,
.an_homeproducts-tab.active {
background: #ececec!important;
}
.an_homeproducts-content {
position: relative;
}
.an_homeproducts-content:not(.active) {
display: none;
}
.an_homeproducts-products .owl-carousel {
margin: 0;
}
.an_homeproducts-products .owl-carousel.owl-loaded .product {
width: 100%;
padding: 0;
}
.an_homeproducts-container {
position: relative;
}
.an_homeproducts-conteiner-category {
margin-top: 20px;
}
.an_homeproducts-category {
cursor: pointer;
margin-right: 10px;
}
a.an_homeproducts-category:not(.active){
color: #949494;
}
a.an_homeproducts-category.active {
color: #000;
}
.an_homeproducts-tab-bottom {
display: flex;
justify-content: center;
margin-bottom: 10px;
}
.an_homeproducts-loadmore {
position: relative;
display: block;
margin: 10px auto;
}
.anhp-loader {
position: absolute;
z-index: 2;
background: rgba(255,255,255,.5);
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.an_homeproducts-loadmore .anhp-loader {
background: inherit;
display: flex;
align-items: center;
justify-content: center;
}
.an_homeproducts-loadmore .anhp-loader svg {
transform: scale(3.5);
max-width: 100%;
max-height: 100%;
}
.an_homeproducts-products .owl-carousel .owl-nav:not(.disabled) {
display: flex;
align-items: center;
justify-content: center;
margin-top: 10px;
}
.an_homeproducts-products .owl-carousel .owl-nav .owl-next,
.an_homeproducts-products .owl-carousel .owl-nav .owl-prev {
display: flex;
align-items: center;
justify-content: center;
width: 30px;
height: 30px;
border-radius: 50%;
background: #ddd;
margin: 0 5px;
}
.an_homeproducts-products .owl-carousel .owl-dots {
display: flex;
align-items: center;
justify-content: center;
margin-top: 10px;
margin-bottom: 15px;
}
.an_homeproducts-products .owl-carousel .owl-dots.disabled {
display: none;
}
.an_homeproducts-products .owl-carousel .owl-dot span {
display: block;
background: #fff;
border-radius: 50%;
width: 10px;
height: 10px;
margin: 5px;
}
.an_homeproducts-products .owl-carousel .owl-dot.active span {
background: #000;
}
@media (min-width: 768px) {
.an_homeproducts-hide-desktop {
display: none;
}
}
@media (max-width: 767px) {
.an_homeproducts-hide-mobile {
display: none!important;
}
}

View File

@@ -0,0 +1,2 @@
.owl-carousel,.owl-carousel .owl-item{-webkit-tap-highlight-color:transparent;position:relative}.owl-carousel{display:none;width:100%;z-index:1}.owl-carousel .owl-stage{position:relative;-ms-touch-action:pan-Y;-moz-backface-visibility:hidden}.owl-carousel .owl-stage:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0}.owl-carousel .owl-stage-outer{position:relative;overflow:hidden;-webkit-transform:translate3d(0,0,0)}.owl-carousel .owl-item,.owl-carousel .owl-wrapper{-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-ms-backface-visibility:hidden;-webkit-transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0)}.owl-carousel .owl-item{min-height:1px;float:left;-webkit-backface-visibility:hidden;-webkit-touch-callout:none}.owl-carousel .owl-item img{display:block;width:100%}.owl-carousel .owl-dots.disabled,.owl-carousel .owl-nav.disabled{display:none}.no-js .owl-carousel,.owl-carousel.owl-loaded{display:block}.owl-carousel .owl-dot,.owl-carousel .owl-nav .owl-next,.owl-carousel .owl-nav .owl-prev{cursor:pointer;cursor:hand;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.owl-carousel.owl-loading{opacity:0;display:block}.owl-carousel.owl-hidden{opacity:0}.owl-carousel.owl-refresh .owl-item{visibility:hidden}.owl-carousel.owl-drag .owl-item{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.owl-carousel.owl-grab{cursor:move;cursor:grab}.owl-carousel.owl-rtl{direction:rtl}.owl-carousel.owl-rtl .owl-item{float:right}.owl-carousel .animated{animation-duration:1s;animation-fill-mode:both}.owl-carousel .owl-animated-in{z-index:0}.owl-carousel .owl-animated-out{z-index:1}.owl-carousel .fadeOut{animation-name:fadeOut}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.owl-height{transition:height .5s ease-in-out}.owl-carousel .owl-item .owl-lazy{opacity:0;transition:opacity .4s ease}.owl-carousel .owl-item img.owl-lazy{transform-style:preserve-3d}.owl-carousel .owl-video-wrapper{position:relative;height:100%;background:#000}.owl-carousel .owl-video-play-icon{position:absolute;height:80px;width:80px;left:50%;top:50%;margin-left:-40px;margin-top:-40px;background:url(owl.video.play.png) no-repeat;cursor:pointer;z-index:1;-webkit-backface-visibility:hidden;transition:transform .1s ease}.owl-carousel .owl-video-play-icon:hover{-ms-transform:scale(1.3,1.3);transform:scale(1.3,1.3)}.owl-carousel .owl-video-playing .owl-video-play-icon,.owl-carousel .owl-video-playing .owl-video-tn{display:none}.owl-carousel .owl-video-tn{opacity:0;height:100%;background-position:center center;background-repeat:no-repeat;background-size:contain;transition:opacity .4s ease}.owl-carousel .owl-video-frame{position:relative;z-index:1;height:100%;width:100%}

View File

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,80 @@
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2023 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
(function ($, window, undefined) {
'use strict';
function anproducts(wrapProductsClass) {
var classProductLine = $(wrapProductsClass).attr('data-classProductLine');
var classProductRemove = $(wrapProductsClass).attr('data-classProductRemove');
var classInputName = $(wrapProductsClass).attr('data-inputName');
var classSarchInput = $(wrapProductsClass).attr('data-classSarchInput');
var loc = location.pathname.split('/');
loc.pop();
var ajax_get_products = function (q) {
return $.get($(wrapProductsClass).attr('data-searchProdutsController')+'&q='+q);
};
var promise = $.when();
var ptreeinput = $('.'+classSarchInput).closest('.form-group');
ptreeinput.children('div').append($('<ul id="an_field_search_products_ajax-product-list" class="an_field_search_ajax_product_list"></ul>'));
$('#an_field_search_products_ajax-product-list').on('click', 'li', function () {
var name = $(this).find('.label').html();
var img = $(this).find('img').attr('src');
var id = $(this).data('id');
$(wrapProductsClass).append('<div class="'+classProductLine+'"><input type="hidden" name="'+classInputName+'" value="'+id+'" /><div class="js-an_field_search-line-number an-hp-hide">'+($(".js-an_productfields_products .js-an_field_search-line").length+1)+'</div><div class="label"><i class="js-anSearchProductsList-more_vert material-icons more_vert">more_vert</i>'+name+' <i class="material-icons delete '+classProductRemove+'">delete</i></div></div>');
$('.'+classSarchInput).val('');
$('#an_field_search_products_ajax-product-list').html('');
});
$('.'+classSarchInput).on('keyup', function () {
var q = $(this).val();
(function (value) {
promise = promise.then(function () {
return ajax_get_products(q);
}).then(function (response) {
if (!response) {
return false;
}
(function (products) {
ptreeinput.find('#an_field_search_products_ajax-product-list').html('');
$.each(products, function (i, product) {
ptreeinput.find('#an_field_search_products_ajax-product-list').append($('' +
'<li data-id="'+product.id+'">' +
// '<img src="'+product.image+'">' +
'<div class="label">'+product.name+'' + '</div>' +
'</li>').on('click', function () {
}));
});
})(JSON.parse(response));
});
})(q);
});
};
$(document).ready(function() {
var wrapProductsClass = '.js-an_productfields_products'; // It need to edit
anproducts(wrapProductsClass);
$(document).on('click', '.js-an_field_search_products-remove', function(){
$(this).closest('.js-an_field_search-line').remove();
});
});
})(jQuery, window);

View File

@@ -0,0 +1,59 @@
/**
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*/
(function ($, window, undefined) {
'use strict';
function showHideFields(){
var viewType = $('.an-hp-block-type input:checked').val();
$('.js-hp-block-categories').hide();
$('.js-hp-block-category').hide();
$('.js-hp-block-show_sub_cat').hide();
$('.js-hp-block-show_sort').show();
$('.js-an_productfields-search-group').hide();
if (viewType == 'categories'){
$('.js-hp-block-categories').show();
$('.js-hp-block-show_sort').hide();
}
if (viewType == 'category'){
$('.js-hp-block-category').show();
$('.js-hp-block-show_sub_cat').show();
}
if (viewType == 'best-sales'){
$('.js-hp-block-show_sort').hide();
}
if (viewType == 'products'){
$('.js-hp-block-show_sort').hide();
$('.js-an_productfields-search-group').show();
}
}
$(document).ready(function () {
showHideFields();
$('.an-hp-block-type input').on('click', function(){
showHideFields();
});
});
})(jQuery, window);

View File

@@ -0,0 +1,41 @@
/**
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*/
(function ($, window, undefined) {
'use strict';
function showHideFields(){
var slider = $('input[name=an_hp_slider]:checked').val();
$('.js-hp-setting-load_more').hide();
$('.js-hp-setting-slider-option').hide();
if (slider == '0'){
$('.js-hp-setting-load_more').show();
} else {
$('.js-hp-setting-slider-option').show();
}
}
$(document).ready(function () {
showHideFields();
$('input[name=an_hp_slider]').on('click', function(){
showHideFields();
});
});
})(jQuery, window);

View File

@@ -0,0 +1,143 @@
/**
* 2021 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2021 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*/
(function ($, window, undefined) {
'use strict';
$(document).on('click','.js-an_homeproducts-tab', function() {
var self = this;
if(!$(self).hasClass('tab-loaded')) {
getData(
$('.js-an_homeproducts').attr('data-url'),
$(self).attr('data-block-id'),
1,
'',
'tab',
function(data){
$(self).closest('.js-an_homeproducts').find('.js-an_homeproducts-container').append(data.products);
$(self).addClass('tab-loaded');
if (!$('.js-an_homeproducts-content[data-block-id='+$(self).attr('data-block-id')+']').find('.products').hasClass('owl-loaded')) {
$('.js-an_homeproducts-content[data-block-id='+$(self).attr('data-block-id')+']').find('.products').addClass('owl-carousel');
if (typeof anhp_slider_init === "function") {
anhp_slider_init($('.js-an_homeproducts-content[data-block-id='+$(self).attr('data-block-id')+']'));
}
}
$('.js-an_homeproducts-tab, .js-an_homeproducts-content').removeClass('active');
$(self).addClass('active');
$('.js-an_homeproducts-content[data-block-id='+$(self).attr('data-block-id')+']').addClass('active');
},
);
} else {
$('.js-an_homeproducts-tab, .js-an_homeproducts-content').removeClass('active');
$(self).addClass('active');
$('.js-an_homeproducts-content[data-block-id='+$(self).attr('data-block-id')+']').addClass('active');
}
});
$(document).on('click','.js-an_homeproducts-category', function() {
var self = this;
getData(
$('.js-an_homeproducts').attr('data-url'),
$(self).closest('.js-an_homeproducts-content').attr('data-block-id'),
1, // page
$(self).val(), // sort
'sort',
function(data){
$(self).siblings('.js-an_homeproducts-category').removeClass('active');
$(self).addClass('active');
$(self).closest('.js-an_homeproducts-content').find('.products').html(data.products);
if (typeof anhp_slider_init === "function") {
anhp_slider_init($('.js-an_homeproducts-content[data-block-id='+$(self).attr('data-block-id')+']'));
}
},
$(this).attr('data-cat')
);
});
$(document).on('change','.js-an_homeproducts-sort', function() {
var self = this;
getData(
$('.js-an_homeproducts').attr('data-url'),
$(self).closest('.js-an_homeproducts-content').attr('data-block-id'),
1, // page
$(self).val(), // sort
'sort',
function(data){
$(self).closest('.js-an_homeproducts-content').find('.products').html(data.products);
if (typeof anhp_slider_init === "function") {
anhp_slider_init($('.js-an_homeproducts-content[data-block-id='+$(self).attr('data-block-id')+']'));
}
},
$('.js-an_homeproducts-category.active').attr('data-cat')
);
});
$(document).on('click','.js-an_homeproducts-loadmore', function() {
var self = this;
$(self).append('<div class="js-anhp-loader anhp-loader"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; background-image: none; display: block; shape-rendering: auto; animation-play-state: running; animation-delay: 0s; background-position: initial initial; background-repeat: initial initial;" width="254px" height="254px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"><path fill="none" stroke="#1d0e0b" stroke-width="3" stroke-dasharray="42.76482137044271 42.76482137044271" d="M24.3 30C11.4 30 5 43.3 5 50s6.4 20 19.3 20c19.3 0 32.1-40 51.4-40 C88.6 30 95 43.3 95 50s-6.4 20-19.3 20C56.4 70 43.6 30 24.3 30z" stroke-linecap="round" style="transform: scale(0.22); transform-origin: 50px 50px; animation-play-state: running; animation-delay: 0s;"> <animate attributeName="stroke-dashoffset" repeatCount="indefinite" dur="1s" keyTimes="0;1" values="0;256.58892822265625" style="animation-play-state: running; animation-delay: 0s;"></animate></path></svg></div>');
getData(
$('.js-an_homeproducts').attr('data-url'),
$(self).closest('.js-an_homeproducts-content').attr('data-block-id'),
$(self).attr('data-page'),
$(self).closest('.js-an_homeproducts-content').find('.js-an_homeproducts-sort').val(),
'loadMore',
function(data){
if (data.products){
$(self).closest('.js-an_homeproducts-content').find('.products').append(data.products);
$(self).attr('data-page', parseInt($(self).attr('data-page')) + 1);
if (data.productsNextPage < 1) {
$(self).hide();
}
} else {
$(self).hide();
}
},
);
});
function getData(url, blockId, page, sort, type, callback, idCategory = false){
let hpContainer;
if ($('.js-an_homeproducts').hasClass('an_homeproducts-type-tabs')) {
hpContainer = $('.js-an_homeproducts-container');
} else {
hpContainer = $('.js-an_homeproducts-content[data-block-id='+blockId+']');
}
hpContainer.append('<div class="js-anhp-loader anhp-loader"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; background-image: none; display: block; shape-rendering: auto; animation-play-state: running; animation-delay: 0s; background-position: initial initial; background-repeat: initial initial;" width="254px" height="254px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"><path fill="none" stroke="#1d0e0b" stroke-width="3" stroke-dasharray="42.76482137044271 42.76482137044271" d="M24.3 30C11.4 30 5 43.3 5 50s6.4 20 19.3 20c19.3 0 32.1-40 51.4-40 C88.6 30 95 43.3 95 50s-6.4 20-19.3 20C56.4 70 43.6 30 24.3 30z" stroke-linecap="round" style="transform: scale(0.22); transform-origin: 50px 50px; animation-play-state: running; animation-delay: 0s;"> <animate attributeName="stroke-dashoffset" repeatCount="indefinite" dur="1s" keyTimes="0;1" values="0;256.58892822265625" style="animation-play-state: running; animation-delay: 0s;"></animate></path></svg></div>');
$.ajax({
type: "POST",
url: url,
data: { action: "getProducts", blockId: blockId, page: page, sort: sort, type: type, idCategory: idCategory },
dataType: 'json',
}).done(function(data){
callback(data);
}).always(function() {
hpContainer.find('.js-anhp-loader').remove();
});
}
})(jQuery, window);

View File

@@ -0,0 +1,137 @@
/**
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*/
(function ($, window, undefined) {
'use strict';
})(jQuery, window);
function anhp_slider_init(slider_id) {
$('.an_homeproducts-slider .js-an_homeproducts-content .products').each(function(i, val) {
var slider_id = '.js-an_homeproducts-content[data-block-id=' + $(this).parents('.js-an_homeproducts-content').data('block-id') + ']';
let responsive_items;
if ($(slider_id).data('items') == 4) {
responsive_items = {
0: {
items: 1
},
240: {
items: 1
},
380: {
margin: 30,
items: 2
},
720: {
margin: 30,
items: 3
},
960: {
margin: 30,
items: $(slider_id).data('items')
}
}
}
if ($(slider_id).data('items') == 5) {
responsive_items = {
0: {
items: 1
},
240: {
items: 1
},
380: {
margin: 30,
items: 2
},
720: {
margin: 30,
items: 3
},
960: {
margin: 30,
items: 4
},
1200: {
margin: 30,
items: $(slider_id).data('items')
}
}
}
if ($(slider_id).data('items') == 6) {
responsive_items = {
0: {
items: 1
},
240: {
items: 1
},
400: {
items: 2
},
600: {
margin: 5,
items: 4
},
800: {
margin: 5,
items: 4
},
1000: {
margin: 5,
items: 5
},
1200: {
margin: 5,
items: $(slider_id).data('items')
}
}
}
//$('.js-an_homeproducts-container').append('<div class="js-anhp-loader anhp-loader"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin: auto; background-image: none; display: block; shape-rendering: auto; animation-play-state: running; animation-delay: 0s; background-position: initial initial; background-repeat: initial initial;" width="254px" height="254px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"><path fill="none" stroke="#1d0e0b" stroke-width="3" stroke-dasharray="42.76482137044271 42.76482137044271" d="M24.3 30C11.4 30 5 43.3 5 50s6.4 20 19.3 20c19.3 0 32.1-40 51.4-40 C88.6 30 95 43.3 95 50s-6.4 20-19.3 20C56.4 70 43.6 30 24.3 30z" stroke-linecap="round" style="transform: scale(0.22); transform-origin: 50px 50px; animation-play-state: running; animation-delay: 0s;"> <animate attributeName="stroke-dashoffset" repeatCount="indefinite" dur="1s" keyTimes="0;1" values="0;256.58892822265625" style="animation-play-state: running; animation-delay: 0s;"></animate></path></svg></div>');
$(slider_id).find('.owl-carousel').trigger('destroy.owl.carousel');
$(slider_id).find('.owl-carousel').owlCarouselAnBS({
loop: $(slider_id).data('loop'),
nav: $(slider_id).data('nav'),
dots: $(slider_id).data('dots'),
rows: 1,
autoplay: 0,
navText: ['<svg \n' +
' xmlns="http://www.w3.org/2000/svg"\n' +
' xmlns:xlink="http://www.w3.org/1999/xlink"\n' +
' width="6px" height="8px">\n' +
'<path fill-rule="evenodd" fill="rgb(134, 134, 134)"\n' +
' d="M0.517,3.870 L5.546,7.351 L5.546,0.389 L0.517,3.870 Z"/>\n' +
'</svg>','<svg \n' +
' xmlns="http://www.w3.org/2000/svg"\n' +
' xmlns:xlink="http://www.w3.org/1999/xlink"\n' +
' width="6px" height="8px">\n' +
'<path fill-rule="evenodd" fill="rgb(134, 134, 134)"\n' +
' d="M5.483,3.870 L0.454,7.351 L0.454,0.389 L5.483,3.870 Z"/>\n' +
'</svg>'],
autoplayTimeout: 5000,
responsive: responsive_items,
//onChanged: anhp_slider_loaded(),
});
});
}
/*
function anhp_slider_loaded() {
$('.js-an_homeproducts-container').find('.js-anhp-loader').remove();
}
*/
$(document).ready(function(){
$('.an_homeproducts-slider .js-an_homeproducts-content').find('.products').addClass('owl-carousel');
anhp_slider_init($('.an_homeproducts-slider .js-an_homeproducts-content[data-block-id='+1+']'));
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,31 @@
/**
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*/
! function(t) {
"use strict";
t(document).ready(function() {
var e = t(".js-an_productfields_products")[0];
return "undefined" != typeof e && void new Sortable(e, {
group: "name",
sort: !0,
handle: '.js-anSearchProductsList-more_vert',
delay: 0,
disabled: !1,
draggable: ".js-an_field_search-line",
store: null,
animation: 150
})
})
}(jQuery);

View File

@@ -0,0 +1,152 @@
{*
* 2022 Anvanto
*
* NOTICE OF LICENSE
*
* This file is not open source! Each license that you purchased is only available for 1 wesite only.
* If you want to use this file on more websites (or projects), you need to purchase additional licenses.
* You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party.
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2022 Anvanto
* @license Valid for 1 website (or project) for each purchase of license
* International Registered Trademark & Property of Anvanto
*}
{extends file="helpers/form/form.tpl"}
{block name="input"}
{if $input.type == 'number'}
<input type="number"
id="{if isset($input.id)}{$input.id}{else}{$input.name}{/if}"
name="{$input.name}"
class="form-control {if isset($input.class)} {$input.class} {/if}"
onkeyup="return (function (el, e) {
if (e.keyCode == 8) return true;
jQuery(el).val((parseInt(jQuery(el).val()) || 0));
if (jQuery(el).val() < (parseInt(jQuery(el).attr('min')) || 0)) {
jQuery(el).val((parseInt(jQuery(el).attr('min')) || 0));
} else if (jQuery(el).val() > (parseInt(jQuery(el).attr('max')) || 0)) {
jQuery(el).val((parseInt(jQuery(el).attr('max')) || 0));
}
})(this, event);"
value="{$fields_value[$input.name]|escape:'html':'UTF-8'}"
{if isset($input.size)} size="{$input.size}"{/if}
{if isset($input.maxchar) && $input.maxchar} data-maxchar="{$input.maxchar|intval}"{/if}
{if isset($input.maxlength) && $input.maxlength} maxlength="{$input.maxlength|intval}"{/if}
{if isset($input.readonly) && $input.readonly} readonly="readonly"{/if}
{if isset($input.disabled) && $input.disabled} disabled="disabled"{/if}
{if isset($input.autocomplete) && !$input.autocomplete} autocomplete="off"{/if}
{if isset($input.required) && $input.required} required="required" {/if}
{if isset($input.max)} max="{$input.max|intval}"{/if}
{if isset($input.min)} min="{$input.min|intval}"{/if}
{if isset($input.placeholder) && $input.placeholder} placeholder="{$input.placeholder}"{/if} />
{if isset($input.suffix)}
<span class="input-group-addon">
{$input.suffix}
</span>
{/if}
{elseif $input.type == 'file_lang'}
{foreach from=$languages item=language}
{if $languages|count > 1}
<div class="translatable-field lang-{$language.id_lang}" {if $language.id_lang != $defaultFormLanguage}style="display:none"{/if}>
{/if}
<div class="form-group-image">
{if isset($fields_value[$input.name][$language.id_lang]) && $fields_value[$input.name][$language.id_lang] != ''}
<div class="form-group">
<div id="{$input.name}-{$language.id_lang}-images-thumbnails" class="col-lg-12">
<img src="../modules/an_homeproducts/img/{$fields_value[$input.name][$language.id_lang]}"
class="img-thumbnail"
style="max-height: 150px; max-width: 150px;"
/>
</div>
</div>
<div class="form-group">
<div id="{$input.name}-{$language.id_lang}-images-delete" class="col-lg-12">
<span id="{$input.name}_{$language.id_lang}-deletebutton" type="button" name="submitDeleteAttachments"
class="btn btn-default an-image-deletebutton an-image-deletebutton-{$language.id_lang}">
<i class="icon-trash"></i> {l s='Delete' mod='an_homeproducts'}
</span>
</div>
</div>
{/if}
</div>
<div class="form-group">
<div class="col-lg-9">
<input id="{$input.name}_{$language.id_lang}" type="file" name="{$input.name}_{$language.id_lang}" class="hide" />
<div class="dummyfile input-group">
<span class="input-group-addon"><i class="icon-file"></i></span>
<input id="{$input.name}_{$language.id_lang}-name" type="text" class="disabled" name="filename" readonly />
<span class="input-group-btn">
<button id="{$input.name}_{$language.id_lang}-selectbutton" type="button" name="submitAddAttachments" class="btn btn-default">
<i class="icon-folder-open"></i> {l s='Choose a file' mod='an_homeproducts'}
</button>
</span>
</div>
</div>
{if $languages|count > 1}
<div class="col-lg-2">
<button type="button" class="btn btn-default dropdown-toggle" tabindex="-1" data-toggle="dropdown">
{$language.iso_code}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{foreach from=$languages item=lang}
<li><a href="javascript:hideOtherLanguage({$lang.id_lang});" tabindex="-1">{$lang.name}</a></li>
{/foreach}
</ul>
</div>
{/if}
</div>
{if $languages|count > 1}
</div>
{/if}
<script>
$(document).ready(function(){
$('.an-image-deletebutton-{$language.id_lang}').click(function(e){
if (confirm('Are you sure?') ) {
var formGroupImage = $(this).closest('.form-group-image');
$(formGroupImage).append('<input type="hidden" name="delete_{$input.name}[{$language.id_lang}]" value="{$language.id_lang}" /> ');
$(formGroupImage).find('.form-group').fadeOut(function () {
$(this).remove();
});
}
});
$('#{$input.name}_{$language.id_lang}-selectbutton').click(function(e){
$('#{$input.name}_{$language.id_lang}').trigger('click');
});
$('#{$input.name}_{$language.id_lang}').change(function(e){
var val = $(this).val();
var file = val.split(/[\\/]/);
$('#{$input.name}_{$language.id_lang}-name').val(file[file.length-1]);
});
});
</script>
{/foreach}
{if isset($input.desc) && !empty($input.desc)}
<p class="help-block">
{$input.desc}
</p>
{/if}
{elseif $input.type == 'html'}
{if isset($input.html_content)}
{if $input.html_content == 'hr'}
<hr />
{else}
{$input.html_content}
{/if}
{else}
{$input.name|escape:'htmlall':'UTF-8'}
{/if}
{else}
{$smarty.block.parent}
{/if}
{/block}

View File

@@ -0,0 +1,25 @@
{*
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*}
{extends file="helpers/list/list_content.tpl"}
{block name="td_content"}
{if isset($params.type) && $params.type == 'image'}
{if isset($tr.image) && $tr.image !='' }
<img src="{$tr.image|escape:'htmlall':'UTF-8'}" alt="" class="anmodule-img-list" style="max-width: 50px; max-height: 50px;" />
{else}
{l s='No image' mod='an_homeproducts'}
{/if}
{else}
{$smarty.block.parent}
{/if}
{/block}

View File

@@ -0,0 +1,13 @@
{*
* 2024 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
* @author Anvanto <anvantoco@gmail.com>
* @copyright 2024 Anvanto
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*}
{include file='../../../helpers-form.tpl'}

Some files were not shown because too many files have changed in this diff Show More