first commit

This commit is contained in:
2025-01-06 20:47:25 +01:00
commit 3bdbd78c2f
25591 changed files with 3586440 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,198 @@
<?PHP
/**
* PrestaShop module created by VEKIA, a guy from official PrestaShop community ;-)
*
* @author VEKIA.PL VATEU: PL9730945634
* @copyright 2010-2023 VEKIA
* @license This program is not free software and you can't resell and redistribute it
*
* Search Tool
* version 1.7.1
*
* CONTACT WITH DEVELOPER http://mypresta.eu
* support@mypresta.eu
*/
class searchToolhtmlboxpro extends htmlboxpro
{
public $addon;
public $name;
public $tab;
public $context;
public static function jsonEncode($data, $options = 0, $depth = 512)
{
return json_encode($data, $options, $depth);
}
public function __construct($addon = null, $tab = null)
{
$this->tab = $tab;
$this->addon = $addon;
$this->name = $addon;
$this->context = Context::getContext();
if (Tools::getValue('searchType', 'false') != 'false' && Tools::getValue('ajax') == 1) {
if (Tools::getValue('searchType') == 'manufacturer') {
echo self::jsonencode($this->searchForID('manufacturer', 'name', trim(Tools::getValue('q')), false));
die();
} elseif (Tools::getValue('searchType') == 'product') {
echo self::jsonencode($this->searchForID('product_lang', 'name', trim(Tools::getValue('q')), true));
die();
} elseif (Tools::getValue('searchType') == 'category') {
echo self::jsonencode($this->searchForID('category_lang', 'name', trim(Tools::getValue('q')), true));
die();
} elseif (Tools::getValue('searchType') == 'supplier') {
echo self::jsonencode($this->searchForID('supplier', 'name', trim(Tools::getValue('q')), false));
die();
} elseif (Tools::getValue('searchType') == 'cms_category') {
echo self::jsonencode($this->searchForID('cms_category_lang', 'name', trim(Tools::getValue('q')), true));
die();
} elseif (Tools::getValue('searchType') == 'cms') {
echo self::jsonencode($this->searchForID('cms_lang', 'meta_title', trim(Tools::getValue('q')), true));
die();
} elseif (Tools::getValue('searchType') == 'customer') {
echo self::jsonencode($this->searchForID('customer', array('email', 'firstname', 'lastname'), trim(Tools::getValue('q')), true));
die();
} elseif (Tools::getValue('searchType') == 'group') {
echo self::jsonencode($this->searchForID('group_lang', 'name', trim(Tools::getValue('q')), false));
die();
} elseif (Tools::getValue('searchType') == 'feature_value') {
$result = $this->searchForID('feature_value_lang', 'value', trim(Tools::getValue('q')), false);
if (is_array($result)) {
if (count($result) > 0) {
foreach ($result AS $k => $v) {
$fv = new FeatureValue($v['id_feature_value'], Context::getContext()->language->id);
$f = new Feature($fv->id_feature, Context::getContext()->language->id);
if ($f != false) {
$result[$k]['feature_name'] = $f->name;
$result[$k]['value'] = $result[$k]['value'] . $this->productsFound('feature', $v['id_feature_value']);
}
}
}
}
echo self::jsonencode($result);
die();
} elseif (Tools::getValue('searchType') == 'attribute_value') {
$result = $this->searchForID('attribute_lang', 'name', trim(Tools::getValue('q')), false);
if (is_array($result)) {
if (count($result) > 0) {
foreach ($result AS $k => $v) {
$attr = new Attribute($v['id_attribute'], Context::getContext()->language->id);
$attrg = new AttributeGroup($attr->id_attribute_group, Context::getContext()->language->id);
if ($attrg != false) {
$result[$k]['attribute_name'] = $attrg->public_name;
$result[$k]['name'] = $result[$k]['name'] . (Tools::getValue('showCounter') == true ? $this->productsFound('attribute', $v['id_attribute']) : '');
}
}
}
}
echo self::jsonencode($result);
die();
}
} elseif (Tools::getValue('getCombinations') == 1 && Tools::getValue('searchByID', 'false') != 'false' && Tools::getValue('ajax') == 1) {
echo $this->returnCombinations(Tools::getValue('searchByID'), Tools::getValue('combinationsClass'));
}
}
public function initTool()
{
$this->context->smarty->assign('SearchToolLink', $this->context->link->getAdminLink('AdminModules', false) . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&ajax=1&module_name=' . $this->name);
return $this->context->smarty->fetch(_PS_MODULE_DIR_ . $this->addon . '/lib/searchTool/views/scripts.tpl');
}
public function productsFound($type, $id)
{
if ($type == 'attribute') {
$result = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'product_attribute_combination` pac INNER JOIN ' . _DB_PREFIX_ . 'product_attribute_shop pas ON (pas.id_product_attribute = pac.id_product_attribute) WHERE pac.id_attribute="' . $id . '" GROUP BY pas.id_product');
if (isset($result[0]['id_product'])) {
return ' | ' . $this->l('Products found:') . ' ' . count($result);
} else {
return '';
}
}
if ($type == 'feature') {
$result = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'feature_product` fp WHERE fp.id_feature_value="'.$id.'" ');
if (isset($result[0]['id_feature_value'])) {
return ' | ' . $this->l('Products found:') . ' ' . count($result);
} else {
return '';
}
}
}
public function searchTool($type, $resultInput, $replacementType = 'replace', $returnBox = false, $object = false, $combinations = false, $combination_input = '', $selected_combination = false, $showCounter = false)
{
$array = array();
if ($returnBox == true) {
if ($object != false) {
$objectClass = ucfirst($type);
if ($objectClass == 'Cms_category') {
$objectClass = 'CMSCategory';
} elseif ($objectClass == 'Cms') {
$objectClass = 'CMS';
} elseif ($objectClass == 'Feature_value') {
$objectClass = 'FeatureValue';
}
if (class_exists($objectClass)) {
$object_exploded = explode(',', $object);
foreach ($object_exploded AS $object_item) {
if ($type == 'product') {
$object_to_display = new $objectClass($object_item, false, $this->context->language->id);
} elseif ($type == 'feature_value') {
$object_to_display = new FeatureValue($object_item, $this->context->language->id);
$f = new Feature($object_to_display->id_feature, $this->context->language->id);
$object_to_display->value = $f->name . ': ' . $object_to_display->value;
} elseif ($type == 'attribute_value') {
$object_to_display = new Attribute($object_item, $this->context->language->id);
$ag = new Feature($object_to_display->id_attribute_group, $this->context->language->id);
$object_to_display->value = $ag->public_name . ': ' . $object_to_display->name;
} else {
$object_to_display = new $objectClass($object_item, $this->context->language->id);
}
$array[] = '<div class="' . $type . $resultInput . $object_item . '"><span class="btn btn-default" onclick="SearchToolRemoveItem(\'' . $type . $resultInput . $object_item . '\',\'' . $type . '\',\'' . $resultInput . '\',\'' . $object_item . '\');"><i class="icon-remove"></i></span> #' . $object_to_display->id . ' ' . (isset($object_to_display->firstname) ? $object_to_display->firstname . ' ' . $object_to_display->lastname . ' ' . $object_to_display->email : (isset($object_to_display->name) ? $object_to_display->name : (isset($object_to_display->meta_title) ? $object_to_display->meta_title : (isset($object_to_display->value) ? $object_to_display->value : '')))) . '</div>';
}
}
}
return '<div class="' . $resultInput . '_' . $type . 'sBox">' . implode('', $array) . '</div>' . ($type == 'product' ? (isset($object_to_display->id) ? (($combinations == true) ? (($selected_combination != false) ? $this->returnCombinations($object_to_display->id, $combination_input, $selected_combination) : '') : '') : '') : '');
}
return '<input style="width: 80px; font-size: 10px; margin: 0px; height: 17px;" type="text" placeholder="' . $this->l('Search') . '" id="searchTool_' . $type . '" data-replacementtype="' . $replacementType . '" data-resultinput="' . $resultInput . '" data-type="' . $type . '" data-combinations="' . (int)$combinations . '" data-combinations-class="' . $combination_input . '" data-toggle="tooltip" data-showCounter="' . (bool)$showCounter . '" data-original-title="' . $this->l('Search for name of: ') . $type . '" class="label-tooltip searchToolInput searchTool_' . $type . '"/>';
}
public function searchForID($table, $field, $term, $shop = false)
{
$result = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . $table . '` WHERE ' . (is_array($field) ? $this->returnArrayFields($field, $term) : ($field . " LIKE '%" . psql($term) . "%' ")) . ($shop != false ? 'AND id_shop="' . $shop . '"' : '') . ' GROUP BY id_' . str_replace('_lang', '', $table));
return $result;
}
public function returnArrayFields($field, $term)
{
$return = array();
foreach ($field AS $f) {
$return[] = $f . " LIKE '%" . psql($term) . "%' ";
}
return implode("OR ", $return);
}
public function returnCombinations($id = 0, $class = 'class', $preselected = false)
{
$product = new Product($id, false, $this->context->language->id);
$combinations = $product->getAttributeCombinations($this->context->language->id);
$combinations_array = array();
if (count($combinations) > 0) {
foreach ($combinations AS $key => $combination) {
$cb = new Combination($combination['id_product_attribute'], $this->context->language->id);
$cb_name = $cb->getAttributesName($this->context->language->id);
$combination_name = '';
if (count($cb_name) > 0) {
foreach ($cb_name AS $cb_name) {
$combination_name .= $cb_name['name'] . ' ';
}
}
$combinations_array[$combination['id_product_attribute']] = "<div class='form-control-static margin-form '><div class='btn btn-default " . $class . "Buttons " . (($preselected != false) ? (($preselected == $combination['id_product_attribute']) ? 'active' : '') : '') . "' onclick=\"$('." . $class . "Buttons').removeClass('active'); $(this).addClass('active'); $('#" . $class . "').val(" . $combination['id_product_attribute'] . ")\" >" . $this->l('select') . "</div> " . $combination_name . " " . ($combination['reference'] != '' ? '(' . $combination['reference'] . ')' : '') . "</div>";
}
return '<div class="panel ' . $class . 'selectedCombinations" style="margin-top:20px"><h3>' . $this->l('Select combination') . '</h3>' . implode('', $combinations_array) . '</div>';
}
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Location: ../");
exit;

View File

@@ -0,0 +1,187 @@
{*
* PrestaShop module created by VEKIA, a guy from official PrestaShop community ;-)
*
* @author VEKIA.PL VATEU: PL9730945634
* @copyright 2010-2023 VEKIA
* @license This program is not free software and you can't resell and redistribute it
*
* Search Tool
* version 1.7.1
*
* CONTACT WITH DEVELOPER http://mypresta.eu
* support@mypresta.eu
*}
<script>
{literal}
function SearchToolRemoveItem(css, what, where, id) {
var current = $('input[name="' + where + '"]').val();
var current_exploded = current.split(",");
current_exploded.forEach(function (item, index, object) {
if (item === id) {
object.splice(index, 1);
}
});
$('input[name="' + where + '"]').val(current_exploded);
$('.' + css).remove();
}
function SearchToolFormatItem(what, where, data) {
return '<div class="clearfix ' + what + where + data.id + '"><span class="btn btn-default" onclick="SearchToolRemoveItem(\'' + what + '' + where + '' + data.id + '\',\'' + what + '\',\'' + where + '\',\'' + data.id + '\');"><i class="icon-remove"></i></span> #' + data.id + ' - ' + data.name + '</div>';
}
$(document).ready(function () {
var link = "{/literal}{$SearchToolLink}{literal}";
var lang = {/literal}{Context::getContext()->language->id}{literal};
$(".searchToolInput").each(function () {
var searchInput = $(this);
$(this).autocomplete(
link, {
minChars: 1,
max: 15,
width: 500,
selectFirst: false,
scroll: false,
dataType: "json",
formatItem: function (data, i, max, value, term) {
return value;
},
parse: function (data) {
var mytab = new Array();
for (var i = 0; i < data.length; i++) {
if (typeof data[i].id_customer !== 'undefined') {
data[i].id = data[i].id_customer;
data[i].name = data[i].firstname+' '+data[i].lastname+' '+data[i].email;
}
if (typeof data[i].id_manufacturer !== 'undefined') {
data[i].id = data[i].id_manufacturer;
}
if (typeof data[i].id_product !== 'undefined') {
data[i].id = data[i].id_product;
}
if (typeof data[i].id_category !== 'undefined') {
data[i].id = data[i].id_category;
}
if (typeof data[i].id_supplier !== 'undefined') {
data[i].id = data[i].id_supplier;
}
if (typeof data[i].id_cms_category !== 'undefined') {
data[i].id = data[i].id_cms_category;
}
if (typeof data[i].id_group !== 'undefined') {
data[i].id = data[i].id_group;
}
if (typeof data[i].id_feature_value !== 'undefined') {
data[i].id = data[i].id_feature_value;
data[i].name = data[i].feature_name+': '+data[i].value;
}
if (typeof data[i].id_attribute !== 'undefined') {
data[i].id = data[i].id_attribute;
data[i].name = data[i].attribute_name+': '+data[i].name;
}
if (typeof data[i].id_cms !== 'undefined') {
data[i].id = data[i].id_cms;
data[i].name = data[i].meta_title;
}
mytab[mytab.length] = {
data: data[i],
value: '#' + data[i].id + ' - ' + data[i].name
};
}
return mytab;
},
extraParams: {
searchType: searchInput.data('type'),
limit: 20,
id_lang: lang,
showCounter: searchInput.data('showcounter'),
}
}
).result(function (event, data, formatted) {
if (+data.id > 0) {
if (searchInput.data('replacementtype') == 'replace') {
$('input[name="' + searchInput.data('resultinput') + '"]').val(data.id);
if ($('.' + searchInput.data('resultinput') + '_' + searchInput.data('type') + 'sBox').length) {
$('.' + searchInput.data('resultinput') + '_' + searchInput.data('type') + 'sBox').html(SearchToolFormatItem(searchInput.data('type'), searchInput.data('resultinput'), data));
}
} else {
var current = $('input[name="' + searchInput.data('resultinput') + '"]').val();
var current_exploded = current.split(",");
current_exploded.push(data.id);
var filtered_current_exploded = current_exploded.filter(function (e) {
return e
});
$('input[name="' + searchInput.data('resultinput') + '"]').val(filtered_current_exploded.join(","));
if ($('.' + searchInput.data('resultinput') + '_' + searchInput.data('type') + 'sBox').length) {
$('.' + searchInput.data('resultinput') + '_' + searchInput.data('type') + 'sBox').append(SearchToolFormatItem(searchInput.data('type'), searchInput.data('resultinput'), data));
}
}
if (searchInput.data('combinations') == "1" && searchInput.data('type') == "product") {
$.ajax({
type: "POST",
url: "{/literal}{$SearchToolLink}{literal}",
data: "getCombinations=1&searchByID="+data.id+"&combinationsClass="+searchInput.data('combinations-class'),
beforeSend: function(){
$('.' + searchInput.data('resultinput') + '_' + searchInput.data('type') + 'sBox').prepend("<div class='loaderSearchTool'><div class='loader-wheel'></div><div class='loader-text'></div></div>");
},
success: function(dat) {
if (dat.length == 0) {
$('input[name="' + searchInput.data('combinations-class') + '"]').val(0);
}
$('.' + searchInput.data('combinations-class') + 'selectedCombinations').remove();
$('.' + searchInput.data('resultinput') + '_' + searchInput.data('type') + 'sBox').append(dat);
$('.loaderSearchTool').fadeOut("100", function(){$(this).remove()});
}
});
}
}
});
});
});
{/literal}
</script>
<style>
#fieldset_0, #fieldset_1_1 {
clear: both; display:block; overflow:hidden;
}
.loaderSearchTool {
width: 300px;
background: #efefef;
border-radius: 10px;
text-align: center;
padding: 10px;
margin-bottom: 20px;
}
.loader-wheel {
animation: spin 1s infinite linear;
border: 2px solid rgba(30, 30, 30, 0.5);
border-left: 4px solid #fff;
border-radius: 50%;
height: 50px;
margin: 10px auto;
width: 50px;
}
.loader-text {
font-family: arial, sans-serif;
}
.loader-text:after {
content: '{l s='Waiting for combinations' mod='htmlboxpro'}';
animation: load 2s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>