continuing braderie upgrade
This commit is contained in:
parent
ffe2e24a7a
commit
58d2b92b0c
@ -248,20 +248,20 @@ class AdminProducts extends AdminTab
|
|||||||
|
|
||||||
if (Tools::isSubmit('reorderproduct') || Tools::isSubmit('reordersubproduct')) {
|
if (Tools::isSubmit('reorderproduct') || Tools::isSubmit('reordersubproduct')) {
|
||||||
global $cookie, $currentIndex;
|
global $cookie, $currentIndex;
|
||||||
|
|
||||||
// Position mise à 0
|
// Position mise à 0
|
||||||
Db::getInstance()->Execute('
|
Db::getInstance()->Execute('
|
||||||
UPDATE `'._DB_PREFIX_.'category_product`
|
UPDATE `'._DB_PREFIX_.'category_product`
|
||||||
SET `position` = 0
|
SET `position` = 0
|
||||||
WHERE `id_category` = '.(int)$this->_category->id
|
WHERE `id_category` = '.(int)$this->_category->id
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Tools::isSubmit('reorderproduct')) {
|
if (Tools::isSubmit('reorderproduct')) {
|
||||||
// Récupération de tous les produits de la catégorie ordonée
|
// Récupération de tous les produits de la catégorie ordonée
|
||||||
// selon la position de la sous-catégorie puis de la position dans la sous catégorie et sinon par id_product
|
// selon la position de la sous-catégorie puis de la position dans la sous catégorie et sinon par id_product
|
||||||
$first_products = Db::getInstance()->ExecuteS('
|
$first_products = Db::getInstance()->ExecuteS('
|
||||||
SELECT cp.*
|
SELECT cp.*
|
||||||
FROM `'._DB_PREFIX_.'category_product` cp
|
FROM `'._DB_PREFIX_.'category_product` cp
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.id_parent = cp.id_category)
|
LEFT JOIN `'._DB_PREFIX_.'category` c ON (c.id_parent = cp.id_category)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp2 ON (cp2.id_category = c.id_category AND cp2.id_product=cp.id_product)
|
LEFT JOIN `'._DB_PREFIX_.'category_product` cp2 ON (cp2.id_category = c.id_category AND cp2.id_product=cp.id_product)
|
||||||
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
||||||
@ -272,20 +272,20 @@ class AdminProducts extends AdminTab
|
|||||||
');
|
');
|
||||||
$second_products = Db::getInstance()->ExecuteS('
|
$second_products = Db::getInstance()->ExecuteS('
|
||||||
SELECT cp.*
|
SELECT cp.*
|
||||||
FROM `'._DB_PREFIX_.'category_product` cp
|
FROM `'._DB_PREFIX_.'category_product` cp
|
||||||
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product=p.id_product AND pl.`id_lang` = 1)
|
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product=p.id_product AND pl.`id_lang` = 1)
|
||||||
WHERE cp.id_category ='.(int)$this->_category->id.'
|
WHERE cp.id_category ='.(int)$this->_category->id.'
|
||||||
AND cp.id_product NOT IN
|
AND cp.id_product NOT IN
|
||||||
(
|
(
|
||||||
SELECT cp2.id_product
|
SELECT cp2.id_product
|
||||||
FROM `'._DB_PREFIX_.'category_product` cp2
|
FROM `'._DB_PREFIX_.'category_product` cp2
|
||||||
WHERE cp2.id_category IN
|
WHERE cp2.id_category IN
|
||||||
(
|
(
|
||||||
SELECT id_category
|
SELECT id_category
|
||||||
FROM `'._DB_PREFIX_.'category`
|
FROM `'._DB_PREFIX_.'category`
|
||||||
WHERE id_parent ='.(int)$this->_category->id.'
|
WHERE id_parent ='.(int)$this->_category->id.'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
ORDER BY pl.`name`
|
ORDER BY pl.`name`
|
||||||
');
|
');
|
||||||
@ -295,7 +295,7 @@ class AdminProducts extends AdminTab
|
|||||||
} else {
|
} else {
|
||||||
$products = Db::getInstance()->ExecuteS('
|
$products = Db::getInstance()->ExecuteS('
|
||||||
SELECT cp.*
|
SELECT cp.*
|
||||||
FROM `'._DB_PREFIX_.'category_product` cp
|
FROM `'._DB_PREFIX_.'category_product` cp
|
||||||
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
RIGHT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product=cp.id_product)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product=p.id_product AND pl.`id_lang` = 1)
|
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.id_product=p.id_product AND pl.`id_lang` = 1)
|
||||||
WHERE cp.id_category ='.(int)$this->_category->id.'
|
WHERE cp.id_category ='.(int)$this->_category->id.'
|
||||||
@ -310,7 +310,7 @@ class AdminProducts extends AdminTab
|
|||||||
}
|
}
|
||||||
Db::getInstance()->Execute('
|
Db::getInstance()->Execute('
|
||||||
UPDATE `'._DB_PREFIX_.'category_product`
|
UPDATE `'._DB_PREFIX_.'category_product`
|
||||||
SET `position` = '. (int)($key) .'
|
SET `position` = '. (int)($key) .'
|
||||||
WHERE `id_product` = '.(int)($product['id_product']).'
|
WHERE `id_product` = '.(int)($product['id_product']).'
|
||||||
AND `id_category`='.(int)$this->_category->id
|
AND `id_category`='.(int)$this->_category->id
|
||||||
);
|
);
|
||||||
@ -1133,7 +1133,7 @@ class AdminProducts extends AdminTab
|
|||||||
elseif (isset($_FILES['image_product']['tmp_name']) AND $_FILES['image_product']['tmp_name'] != NULL)
|
elseif (isset($_FILES['image_product']['tmp_name']) AND $_FILES['image_product']['tmp_name'] != NULL)
|
||||||
$this->copySingleImage($product->id, $image->id, $_FILES['image_product'], $method);
|
$this->copySingleImage($product->id, $image->id, $_FILES['image_product'], $method);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($image) AND Validate::isLoadedObject($image) AND !file_exists(_PS_PROD_IMG_DIR_.$image->getExistingImgPath().'.'.$image->image_format))
|
if (isset($image) AND Validate::isLoadedObject($image) AND !file_exists(_PS_PROD_IMG_DIR_.$image->getExistingImgPath().'.'.$image->image_format))
|
||||||
$image->delete();
|
$image->delete();
|
||||||
if (sizeof($this->_errors))
|
if (sizeof($this->_errors))
|
||||||
@ -1146,8 +1146,8 @@ class AdminProducts extends AdminTab
|
|||||||
|
|
||||||
/* Adding new product images */
|
/* Adding new product images */
|
||||||
elseif (isset($_FILES['image_product']['name']) && is_array($_FILES['image_product']['name'])) {
|
elseif (isset($_FILES['image_product']['name']) && is_array($_FILES['image_product']['name'])) {
|
||||||
|
|
||||||
// ensure there is actually any file to process
|
// ensure there is actually any file to process
|
||||||
$has_any_file = false;
|
$has_any_file = false;
|
||||||
foreach ($_FILES['image_product']['name'] as $value) {
|
foreach ($_FILES['image_product']['name'] as $value) {
|
||||||
$has_any_file = $has_any_file || !empty($value);
|
$has_any_file = $has_any_file || !empty($value);
|
||||||
@ -1161,7 +1161,7 @@ class AdminProducts extends AdminTab
|
|||||||
// reorganise the array into an indexed array
|
// reorganise the array into an indexed array
|
||||||
$images_product = [];
|
$images_product = [];
|
||||||
for ($i=sizeof($_FILES['image_product']['name']); $i>0; $i--) {
|
for ($i=sizeof($_FILES['image_product']['name']); $i>0; $i--) {
|
||||||
|
|
||||||
$images_product[] = [
|
$images_product[] = [
|
||||||
'name' => '',
|
'name' => '',
|
||||||
'type' => '',
|
'type' => '',
|
||||||
@ -1174,14 +1174,14 @@ class AdminProducts extends AdminTab
|
|||||||
|
|
||||||
|
|
||||||
foreach ($_FILES['image_product'] as $key => $array_values) {
|
foreach ($_FILES['image_product'] as $key => $array_values) {
|
||||||
$i=0;
|
$i=0;
|
||||||
foreach ($array_values as $value) {
|
foreach ($array_values as $value) {
|
||||||
$images_product[$i][$key] = $value;
|
$images_product[$i][$key] = $value;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!Validate::isLoadedObject($product)) {
|
if (!Validate::isLoadedObject($product)) {
|
||||||
$this->_errors[] = Tools::displayError('Cannot add image because product add failed.');
|
$this->_errors[] = Tools::displayError('Cannot add image because product add failed.');
|
||||||
}
|
}
|
||||||
@ -1244,8 +1244,8 @@ class AdminProducts extends AdminTab
|
|||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uploadImageZip($product)
|
public function uploadImageZip($product)
|
||||||
@ -1369,7 +1369,7 @@ class AdminProducts extends AdminTab
|
|||||||
|
|
||||||
@unlink($tmpName);
|
@unlink($tmpName);
|
||||||
Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_product));
|
Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_product));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1532,13 +1532,13 @@ class AdminProducts extends AdminTab
|
|||||||
$preview_url .= 'adtoken='.$token.'&ad='.$admin_dir;
|
$preview_url .= 'adtoken='.$token.'&ad='.$admin_dir;
|
||||||
}
|
}
|
||||||
Tools::redirectAdmin($preview_url);
|
Tools::redirectAdmin($preview_url);
|
||||||
}
|
}
|
||||||
// Save and stay on same form
|
// Save and stay on same form
|
||||||
elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay')
|
elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay')
|
||||||
OR ($id_image AND $id_image !== true))
|
OR ($id_image AND $id_image !== true))
|
||||||
{
|
{
|
||||||
// Save and stay on same form
|
// Save and stay on same form
|
||||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
|
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
|
||||||
{
|
{
|
||||||
Tools::redirectAdmin($currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&addproduct&conf=4&tabs='.(int)(Tools::getValue('tabs')).'&token='.($token ? $token : $this->token));
|
Tools::redirectAdmin($currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&addproduct&conf=4&tabs='.(int)(Tools::getValue('tabs')).'&token='.($token ? $token : $this->token));
|
||||||
}
|
}
|
||||||
@ -1814,6 +1814,7 @@ class AdminProducts extends AdminTab
|
|||||||
echo '<input type="checkbox" name="blocks[]" value="short_description"> Description courte ';
|
echo '<input type="checkbox" name="blocks[]" value="short_description"> Description courte ';
|
||||||
echo '<input type="checkbox" name="blocks[]" value="description"> Bon à savoir ';
|
echo '<input type="checkbox" name="blocks[]" value="description"> Bon à savoir ';
|
||||||
echo '<input type="checkbox" name="blocks[]" value="description_more"> Les plus ';
|
echo '<input type="checkbox" name="blocks[]" value="description_more"> Les plus ';
|
||||||
|
echo '<input type="checkbox" name="blocks[]" value="description_comment"> Commentaires (braderie) ';
|
||||||
echo '<input type="checkbox" name="blocks[]" value="videos"> Vidéos ';
|
echo '<input type="checkbox" name="blocks[]" value="videos"> Vidéos ';
|
||||||
echo '<input type="checkbox" name="blocks[]" value="description_delivery"> Livraison ';
|
echo '<input type="checkbox" name="blocks[]" value="description_delivery"> Livraison ';
|
||||||
|
|
||||||
@ -3401,6 +3402,16 @@ class AdminProducts extends AdminTab
|
|||||||
echo ' <div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').';float: left;">
|
echo ' <div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').';float: left;">
|
||||||
<textarea class="other_textarea" cols="100" rows="3" id="description_more_'.$language['id_lang'].'" name="description_more_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($obj, 'description_more', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
|
<textarea class="other_textarea" cols="100" rows="3" id="description_more_'.$language['id_lang'].'" name="description_more_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($obj, 'description_more', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
|
||||||
</div>';
|
</div>';
|
||||||
|
echo ' </td>
|
||||||
|
</tr>
|
||||||
|
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td class="col-left">'.$this->l('Comments :').'<br /><br /></td>
|
||||||
|
<td style="padding-bottom:5px;" class="translatable">';
|
||||||
|
foreach ($this->_languages as $language)
|
||||||
|
echo ' <div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').';float: left;">
|
||||||
|
<textarea class="other_textarea" cols="100" rows="3" id="description_comment_'.$language['id_lang'].'" name="description_comment_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($obj, 'description_comment', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
|
||||||
|
</div>';
|
||||||
echo ' </td>
|
echo ' </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
|
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
|
||||||
|
@ -1,344 +1,406 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('_PS_VERSION_')) {
|
if(!defined('_PS_VERSION_')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AdminBraderie extends AdminTab
|
class AdminBraderie extends AdminTab
|
||||||
{
|
{
|
||||||
private $_html = '';
|
private $_html = '';
|
||||||
private $error = '';
|
private $error = '';
|
||||||
|
|
||||||
public function display()
|
public function display()
|
||||||
{
|
{
|
||||||
global $cookie;
|
global $cookie;
|
||||||
|
|
||||||
$this->_html .= '<style type="text/css">
|
$this->_html .= '<style type="text/css">
|
||||||
@import "'.__PS_BASE_URI__.'css/custom_admin.css";
|
@import "'.__PS_BASE_URI__.'css/custom_admin.css";
|
||||||
</style>';
|
</style>';
|
||||||
|
|
||||||
$id_category = Tools::getValue('id_category', 1);
|
$id_category = Tools::getValue('id_category', 1);
|
||||||
$id_product = Tools::getValue('id_product', false);
|
$id_product = Tools::getValue('id_product', false);
|
||||||
|
|
||||||
$db = Db::getInstance();
|
$db = Db::getInstance();
|
||||||
/*$sql_category = '
|
/*$sql_category = '
|
||||||
SELECT * FROM `'._DB_PREFIX_.'privatesale` ps
|
SELECT * FROM `'._DB_PREFIX_.'privatesale` ps
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ps.`id_category` = cl.`id_category`
|
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ps.`id_category` = cl.`id_category`
|
||||||
WHERE ps.`braderie` = 1
|
WHERE ps.`braderie` = 1
|
||||||
AND cl.`id_lang` = '.(int) $cookie->id_lang;*/
|
AND cl.`id_lang` = '.(int) $cookie->id_lang;*/
|
||||||
$sql_category = '
|
$sql_category = '
|
||||||
SELECT c.`id_category`, cl.`name` FROM `'._DB_PREFIX_.'category` c
|
SELECT c.`id_category`, cl.`name` FROM `'._DB_PREFIX_.'category` c
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`
|
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category`
|
||||||
WHERE c.`id_parent` = 1
|
WHERE c.`id_parent` = 1
|
||||||
AND cl.`id_lang` = '.(int) $cookie->id_lang.'
|
AND cl.`id_lang` = '.(int) $cookie->id_lang.'
|
||||||
ORDER BY c.`id_category` DESC';
|
ORDER BY c.`id_category` DESC';
|
||||||
$categories = $db->ExecuteS($sql_category);
|
$categories = $db->ExecuteS($sql_category);
|
||||||
|
|
||||||
$ids_categories = array();
|
$ids_categories = array();
|
||||||
foreach ($categories as $key => $category) {
|
foreach ($categories as $key => $category) {
|
||||||
$ids_categories[] = (int) $category["id_category"];
|
$ids_categories[] = (int) $category["id_category"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$small_titles = array();
|
$small_titles = array();
|
||||||
foreach (Db::getInstance()->executeS('
|
foreach (Db::getInstance()->executeS('
|
||||||
SELECT ex.`value`, ps.`id_category`
|
SELECT ex.`value`, ps.`id_category`
|
||||||
FROM `'._DB_PREFIX_.'privatesale_extrafield_sale` ex
|
FROM `'._DB_PREFIX_.'privatesale_extrafield_sale` ex
|
||||||
LEFT JOIN `'._DB_PREFIX_.'privatesale` ps on ex.`id_sale` = ps.`id_sale`
|
LEFT JOIN `'._DB_PREFIX_.'privatesale` ps on ex.`id_sale` = ps.`id_sale`
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category` c on c.`id_category` = ps.`id_category`
|
LEFT JOIN `'._DB_PREFIX_.'category` c on c.`id_category` = ps.`id_category`
|
||||||
WHERE ex.`id_field` = 1
|
WHERE ex.`id_field` = 1
|
||||||
AND ex.`id_lang` = '. (int) $cookie->id_lang.'
|
AND ex.`id_lang` = '. (int) $cookie->id_lang.'
|
||||||
AND c.`id_category` IN ('.implode(',', $ids_categories).')
|
AND c.`id_category` IN ('.implode(',', $ids_categories).')
|
||||||
') as $key => $data) {
|
') as $key => $data) {
|
||||||
$small_titles[(int) $data['id_category']] = $data['value'];
|
$small_titles[(int) $data['id_category']] = $data['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_html .= $this->_buildHtmlCategoryBlock($categories, $small_titles);
|
$this->_html .= $this->_buildHtmlCategoryBlock($categories, $small_titles);
|
||||||
|
|
||||||
$this->_html .= '<link type="text/css" rel="stylesheet" href="'._MODULE_DIR_.'bulkupdate/chosen.min.css" />';
|
$this->_html .= '<link type="text/css" rel="stylesheet" href="'._MODULE_DIR_.'bulkupdate/chosen.min.css" />';
|
||||||
$this->_html .= '<script type="text/javascript" src="'._MODULE_DIR_.'bulkupdate/chosen.jquery.min.js"></script>';
|
$this->_html .= '<script type="text/javascript" src="'._MODULE_DIR_.'bulkupdate/chosen.jquery.min.js"></script>';
|
||||||
$this->_html .= '<script type="text/javascript">
|
$this->_html .= '<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
$(".chosen-select").chosen(
|
$(".chosen-select").chosen(
|
||||||
{
|
{
|
||||||
allow_single_deselect:true,
|
allow_single_deselect:true,
|
||||||
placeholder_text_single : "Choisir une vente",
|
placeholder_text_single : "Choisir une vente",
|
||||||
no_results_text : "Aucun résultat",
|
no_results_text : "Aucun résultat",
|
||||||
enable_split_word_search : true,
|
enable_split_word_search : true,
|
||||||
search_contains : true,
|
search_contains : true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var $token = "'.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'";
|
var $token = "'.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)($cookie->id_employee)).'";
|
||||||
var $product_id = 0;
|
var $product_id = 0;
|
||||||
|
|
||||||
$(\'#sale\').change(function() {
|
$(\'#sale\').change(function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: \'POST\',
|
type: \'POST\',
|
||||||
url: \''._MODULE_DIR_.'braderie/ajax.php?action=getCategories'.'\',
|
url: \''._MODULE_DIR_.'braderie/ajax.php?action=getCategories'.'\',
|
||||||
dataType: \'json\',
|
dataType: \'json\',
|
||||||
data: { sale: $(this).val() },
|
data: { sale: $(this).val() },
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
$(\'#category\').empty();
|
$(\'#category\').empty();
|
||||||
for (var i in response) {
|
for (var i in response) {
|
||||||
var html = \'<option value="\'+ response[i].id_category +\'">\'+ response[i].id_category +\' - \'+ response[i].name +\'</option>\';
|
var html = \'<option value="\'+ response[i].id_category +\'">\'+ response[i].id_category +\' - \'+ response[i].name +\'</option>\';
|
||||||
$(\'#category\').append(html);
|
$(\'#category\').append(html);
|
||||||
}
|
}
|
||||||
$(".chosen-select").trigger("chosen:updated");
|
$(".chosen-select").trigger("chosen:updated");
|
||||||
$("#divider, #category_input_group, #ean_input_group, #storage_input_group, #button_input_group, #show_current_category_button, #quantity_input_group").show();
|
$("#divider, #category_input_group, #ean_input_group, #storage_input_group, #button_input_group, #show_current_category_button, #quantity_input_group").show();
|
||||||
$("#error").empty();
|
$("#error").empty();
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
$("#ean_from_product").empty();
|
$("#ean_from_product").empty();
|
||||||
$("#error").empty().append(JSON.parse(xhr.responseText));
|
$("#error").empty().append(JSON.parse(xhr.responseText));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#category").change(function(event) {
|
$("#category").change(function(event) {
|
||||||
$("#show_current_category_button").show();
|
$("#show_current_category_button").show();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#input_ean").change(function(event) {
|
$("#input_ean").change(function(event) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: \'POST\',
|
type: \'POST\',
|
||||||
url: \''._MODULE_DIR_.'braderie/ajax.php?action=getProductId'.'\',
|
url: \''._MODULE_DIR_.'braderie/ajax.php?action=getProductId'.'\',
|
||||||
dataType: \'json\',
|
dataType: \'json\',
|
||||||
data: { ean: $(this).val() },
|
data: { ean: $(this).val() },
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response.name == null) {
|
if (response.name == null) {
|
||||||
$("#error").empty().append("'.$this->l('Aucun produit n\'a été trouvé. Vérifier le code EAN').'");
|
$("#error").empty().append("'.$this->l('Aucun produit n\'a été trouvé. Vérifier le code EAN').'");
|
||||||
$("#ean_from_product").empty();
|
$("#ean_from_product").empty();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$product_id = response.id_product;
|
$product_id = response.id_product;
|
||||||
$attibute_id = response.id_product_attribute;
|
$attibute_id = response.id_product_attribute;
|
||||||
if (response.id_image == null) {
|
if (response.id_image == null) {
|
||||||
image = \'\';
|
image = \'\';
|
||||||
} else {
|
} else {
|
||||||
image = \'<img src="'._THEME_PROD_DIR_.'\'+response.img_path+\'-small.jpg" />\';
|
image = \'<img src="'._THEME_PROD_DIR_.'\'+response.img_path+\'-small.jpg" />\';
|
||||||
}
|
}
|
||||||
if (response.attribute_name) {
|
if (response.attribute_name) {
|
||||||
$("#ean_from_product").empty().append(image+"<p>"+response.name+" - "+response.attribute_name+"</p>");
|
$("#ean_from_product").empty().append(image+"<p>"+response.name+" - "+response.attribute_name+"</p>");
|
||||||
} else {
|
} else {
|
||||||
$("#ean_from_product").empty().append(image+"<p>"+response.name+"</p>");
|
$("#ean_from_product").empty().append(image+"<p>"+response.name+"</p>");
|
||||||
}
|
}
|
||||||
if ($attibute_id) {
|
if ($attibute_id) {
|
||||||
$("#hidden_attribute_id").val($attibute_id);
|
$("#hidden_attribute_id").val($attibute_id);
|
||||||
} else {
|
} else {
|
||||||
$("#hidden_attribute_id").val(0);
|
$("#hidden_attribute_id").val(0);
|
||||||
}
|
}
|
||||||
$("#hidden_product_id").val($product_id);
|
$("#hidden_product_id").val($product_id);
|
||||||
$("#error").empty();
|
if(response.comments != null){
|
||||||
$("#input_storage").focus();
|
tinymce.activeEditor.setContent(response.comments);
|
||||||
},
|
} else {
|
||||||
error: function(xhr) {
|
tinymce.activeEditor.setContent("");
|
||||||
$("#ean_from_product").empty();
|
}
|
||||||
$("#error").empty().append(JSON.parse(xhr.responseText));
|
$("#comment_input_group").show();
|
||||||
}
|
$("#error").empty();
|
||||||
});
|
$("#input_storage").focus();
|
||||||
});
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
$("#ean_from_product").empty();
|
||||||
|
$("#input_comment").val("");
|
||||||
|
$("#comment_input_group").hide();
|
||||||
|
$("#error").empty().append(JSON.parse(xhr.responseText));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$("#check_button").click(function(event) {
|
$("#check_button").click(function(event) {
|
||||||
|
|
||||||
if ($product_id == undefined || $product_id == 0) {
|
if ($product_id == undefined || $product_id == 0) {
|
||||||
$("#error").empty().append("'.$this->l('Aucun produit n\'a été trouvé. Vérifier le code EAN').'");
|
$("#error").empty().append("'.$this->l('Aucun produit n\'a été trouvé. Vérifier le code EAN').'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($token.length == 0) {
|
if ($token.length == 0) {
|
||||||
$("#error").empty().append("'.$this->l('Un problème de sécurité est survenu. Merci de réinitialisé la page').'");
|
$("#error").empty().append("'.$this->l('Un problème de sécurité est survenu. Merci de réinitialisé la page').'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.open("?tab=AdminCatalog&updateproduct&id_product=" + $product_id + "&token=" + $token);
|
window.open("?tab=AdminCatalog&updateproduct&id_product=" + $product_id + "&token=" + $token);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#input_storage").change(function(event) {
|
// $("#input_comment").change(function(event) {
|
||||||
event.preventDefault();
|
// $("#input_storage").focus();
|
||||||
if ($product_id == undefined || $product_id == 0) {
|
// });
|
||||||
$("#error").empty().append("'.$this->l('Aucun produit n\'a été trouvé. Vérifier le code EAN').'");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var emplacement = $("#input_storage").val();
|
$("#input_storage").change(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if ($product_id == undefined || $product_id == 0) {
|
||||||
|
$("#error").empty().append("'.$this->l('Aucun produit n\'a été trouvé. Vérifier le code EAN').'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (emplacement.length == 0 || emplacement>205) {
|
var emplacement = $("#input_storage").val();
|
||||||
$("#error").empty().append("'.$this->l('L\'emplacement n\'est pas renseigné ou est mal renseigné').'");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($("#input_quantity").val().length == 0) {
|
if (emplacement.length == 0 || emplacement>205) {
|
||||||
$("#error").empty().append("'.$this->l('La quantité n\'est pas renseignée').'");
|
$("#error").empty().append("'.$this->l('L\'emplacement n\'est pas renseigné ou est mal renseigné').'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#hidden_product_id").val($product_id);
|
if ($("#input_quantity").val().length == 0) {
|
||||||
|
$("#error").empty().append("'.$this->l('La quantité n\'est pas renseignée').'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$.ajax({
|
$("#hidden_product_id").val($product_id);
|
||||||
type: \'POST\',
|
$.ajax({
|
||||||
url: \''._MODULE_DIR_.'braderie/ajax.php?action=addToSellout'.'\',
|
type: \'POST\',
|
||||||
dataType: \'json\',
|
url: \''._MODULE_DIR_.'braderie/ajax.php?action=addToSellout'.'\',
|
||||||
data: {
|
dataType: \'json\',
|
||||||
parent_category: $("#sale").val(),
|
data: {
|
||||||
category: $("#category").val(),
|
parent_category: $("#sale").val(),
|
||||||
ean: $("#input_ean").val(),
|
category: $("#category").val(),
|
||||||
storage: $("#input_storage").val(),
|
ean: $("#input_ean").val(),
|
||||||
product: $("#hidden_product_id").val(),
|
storage: $("#input_storage").val(),
|
||||||
quantity: $("#input_quantity").val(),
|
product: $("#hidden_product_id").val(),
|
||||||
attribute: $("#hidden_attribute_id").val()
|
quantity: $("#input_quantity").val(),
|
||||||
},
|
attribute: $("#hidden_attribute_id").val(),
|
||||||
success: function(response) {
|
comment: tinymce.activeEditor.getContent()
|
||||||
$("#error").empty().append(response);
|
},
|
||||||
$("#input_ean, #input_storage").val("");
|
success: function(response) {
|
||||||
$("#input_quantity").val(1);
|
$("#error").empty().append(response);
|
||||||
$("#ean_from_product").empty();
|
$("#input_ean, #input_storage").val("");
|
||||||
$("#input_ean").focus();
|
$("#comment_input_group").hide();
|
||||||
},
|
$("#input_quantity").val(1);
|
||||||
error: function(xhr) {
|
$("#ean_from_product").empty();
|
||||||
$("#error").empty().append(JSON.parse(xhr.responseText));
|
$("#input_ean").focus();
|
||||||
}
|
},
|
||||||
});
|
error: function(xhr) {
|
||||||
return false;
|
$("#error").empty().append(JSON.parse(xhr.responseText));
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
$("#add_button").click(function(event) {
|
$("#add_button").click(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ($product_id == undefined || $product_id == 0) {
|
if ($product_id == undefined || $product_id == 0) {
|
||||||
$("#error").empty().append("'.$this->l('Aucun produit n\'a été trouvé. Vérifier le code EAN').'");
|
$("#error").empty().append("'.$this->l('Aucun produit n\'a été trouvé. Vérifier le code EAN').'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var emplacement = $("#input_storage").val();
|
var emplacement = $("#input_storage").val();
|
||||||
|
|
||||||
if (emplacement.length == 0 || emplacement>205) {
|
if (emplacement.length == 0 || emplacement>205) {
|
||||||
$("#error").empty().append("'.$this->l('L\'emplacement n\'est pas renseigné ou est mal renseigné').'");
|
$("#error").empty().append("'.$this->l('L\'emplacement n\'est pas renseigné ou est mal renseigné').'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#input_quantity").val().length == 0) {
|
if ($("#input_quantity").val().length == 0) {
|
||||||
$("#error").empty().append("'.$this->l('La quantité n\'est pas renseignée').'");
|
$("#error").empty().append("'.$this->l('La quantité n\'est pas renseignée').'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#hidden_product_id").val($product_id);
|
$("#hidden_product_id").val($product_id);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: \'POST\',
|
type: \'POST\',
|
||||||
url: \''._MODULE_DIR_.'braderie/ajax.php?action=addToSellout'.'\',
|
url: \''._MODULE_DIR_.'braderie/ajax.php?action=addToSellout'.'\',
|
||||||
dataType: \'json\',
|
dataType: \'json\',
|
||||||
data: {
|
data: {
|
||||||
parent_category: $("#sale").val(),
|
parent_category: $("#sale").val(),
|
||||||
category: $("#category").val(),
|
category: $("#category").val(),
|
||||||
ean: $("#input_ean").val(),
|
ean: $("#input_ean").val(),
|
||||||
storage: $("#input_storage").val(),
|
storage: $("#input_storage").val(),
|
||||||
product: $("#hidden_product_id").val(),
|
product: $("#hidden_product_id").val(),
|
||||||
quantity: $("#input_quantity").val(),
|
quantity: $("#input_quantity").val(),
|
||||||
attribute: $("#hidden_attribute_id").val()
|
attribute: $("#hidden_attribute_id").val()
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
$("#error").empty().append(response);
|
$("#error").empty().append(response);
|
||||||
$("#input_ean, #input_storage").val("");
|
$("#input_ean, #input_storage").val("");
|
||||||
$("#ean_from_product").empty();
|
$("#ean_from_product").empty();
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
$("#error").empty().append(JSON.parse(xhr.responseText));
|
$("#error").empty().append(JSON.parse(xhr.responseText));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#show_current_category_button").click(function() {
|
$("#show_current_category_button").click(function() {
|
||||||
$category = $("#category").val();
|
$category = $("#category").val();
|
||||||
if ($category.length == 0) {
|
if ($category.length == 0) {
|
||||||
$("#error").empty().append("'.$this->l('Catégorie invalide').'");
|
$("#error").empty().append("'.$this->l('Catégorie invalide').'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
window.open("?tab=AdminCatalog&viewcategory&id_category=" + $category + "&token=" + $token, "_blank");
|
window.open("?tab=AdminCatalog&viewcategory&id_category=" + $category + "&token=" + $token, "_blank");
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
echo $this->_html;
|
$iso = Language::getIsoById((int)($cookie->id_lang));
|
||||||
}
|
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en');
|
||||||
|
$ad = dirname($_SERVER["PHP_SELF"]);
|
||||||
|
$this->_html.= '
|
||||||
|
<script type="text/javascript">
|
||||||
|
var iso = \''.$isoTinyMCE.'\' ;
|
||||||
|
var pathCSS = \''._THEME_CSS_DIR_.'\' ;
|
||||||
|
var ad = \''.$ad.'\' ;
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
|
||||||
|
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
// other_textarea different config
|
||||||
|
$(function() {
|
||||||
|
tinymce.init({
|
||||||
|
mode : "specific_textareas",
|
||||||
|
theme : "advanced",
|
||||||
|
skin:"cirkuit",
|
||||||
|
editor_selector : "other_textarea",
|
||||||
|
editor_deselector : "noEditor",
|
||||||
|
plugins : "safari,pagebreak,style,table,advimage,advlink,inlinepopups,media,contextmenu,paste,fullscreen,xhtmlxtras,preview",
|
||||||
|
// Theme options
|
||||||
|
theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
|
||||||
|
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,,|,forecolor,backcolor",
|
||||||
|
theme_advanced_buttons3 : "",
|
||||||
|
theme_advanced_buttons4 : "",
|
||||||
|
theme_advanced_toolbar_location : "top",
|
||||||
|
theme_advanced_toolbar_align : "left",
|
||||||
|
theme_advanced_statusbar_location : "bottom",
|
||||||
|
theme_advanced_resizing : false,
|
||||||
|
content_css : pathCSS+"global.css",
|
||||||
|
document_base_url : ad,
|
||||||
|
width: "200",
|
||||||
|
height: "200",
|
||||||
|
font_size_style_values : "8pt, 10pt, 12pt, 14pt, 18pt, 24pt, 36pt",
|
||||||
|
elements : "nourlconvert,ajaxfilemanager",
|
||||||
|
file_browser_callback : "ajaxfilemanager",
|
||||||
|
entity_encoding: "raw",
|
||||||
|
convert_urls : false,
|
||||||
|
language : iso,
|
||||||
|
extended_valid_elements: "iframe[src,width,height,frameborder,marginwidth,marginheight],script[type,src]",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
echo $this->_html;
|
||||||
|
}
|
||||||
|
|
||||||
private function _buildHtmlCategoryBlock($categories, $small_titles)
|
private function _buildHtmlCategoryBlock($categories, $small_titles)
|
||||||
{
|
{
|
||||||
global $cookie;
|
global $cookie;
|
||||||
|
|
||||||
$token = Tools::getAdminToken('AdminBraderie'.(int)(Tab::getIdFromClassName('AdminBraderie')).(int)($cookie->id_employee));
|
$token = Tools::getAdminToken('AdminBraderie'.(int)(Tab::getIdFromClassName('AdminBraderie')).(int)($cookie->id_employee));
|
||||||
|
|
||||||
$html = '
|
$html = '
|
||||||
<style>
|
<style>
|
||||||
.chosen-container { width: 315px !important; }
|
.chosen-container { width: 315px !important; }
|
||||||
.button-container input { margin: 10px 25px; }
|
.button-container input { margin: 10px 25px; }
|
||||||
#ean_from_product {
|
#ean_from_product {
|
||||||
background-color: rgba(86,84,133,0.7);
|
background-color: rgba(86,84,133,0.7);
|
||||||
color:#fff;
|
color:#fff;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
#ean_from_product p{width: 200px;text-align: center;}
|
#ean_from_product p{width: 200px;text-align: center;}
|
||||||
#ean_from_product p,#ean_from_product img{
|
#ean_from_product p,#ean_from_product img{
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
vertical-align:middle;
|
vertical-align:middle;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
}
|
}
|
||||||
#error, #ean_from_product { margin-left: 210px; width: 312px;}
|
#error, #ean_from_product { margin-left: 205px; width: 312px;}
|
||||||
#error { font-weight: bold; margin-bottom: 20px; color: #CC0000; }
|
#error { font-weight: bold; margin-bottom: 20px; color: #CC0000; }
|
||||||
</style>
|
.margin-form {padding: 0 0 1em 10px;}
|
||||||
<fieldset>
|
</style>
|
||||||
<legend>'.$this->l('Braderie').'</legend>';
|
<fieldset>
|
||||||
if ($this->error) {
|
<legend>'.$this->l('Braderie').'</legend>';
|
||||||
$html .= '<p class="margin-form" id="error">'.$this->error.'</p>';
|
if ($this->error) {
|
||||||
} else {
|
$html .= '<p class="margin-form" id="error">'.$this->error.'</p>';
|
||||||
$html .= '<p class="margin-form" id="error">'.$this->error.'</p>';
|
} else {
|
||||||
}
|
$html .= '<p class="margin-form" id="error">'.$this->error.'</p>';
|
||||||
$html .= '<div class="margin-form">
|
}
|
||||||
<label>'.$this->l('Ventes').' : </label>
|
$html .= '<div class="margin-form">
|
||||||
<select class="chosen-select" id="sale" name="sale">
|
<label>'.$this->l('Ventes').' : </label>
|
||||||
<option value=""></option>';
|
<select class="chosen-select" id="sale" name="sale">
|
||||||
|
<option value=""></option>';
|
||||||
|
|
||||||
foreach ($categories as $key => $value) {
|
foreach ($categories as $key => $value) {
|
||||||
$html .= '<option value="'.$value['id_category'].'">'.$value['id_category'].' - '.$value['name'].(!empty($small_titles[(int)$value['id_category']])?' - '.$small_titles[(int)$value['id_category']]:'').'</option>';
|
$html .= '<option value="'.$value['id_category'].'">'.$value['id_category'].' - '.$value['name'].(!empty($small_titles[(int)$value['id_category']])?' - '.$small_titles[(int)$value['id_category']]:'').'</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= ' </select>
|
$html .= ' </select>
|
||||||
</div>
|
</div>
|
||||||
<hr id="divider" style="display: none;">
|
<hr id="divider" style="display: none;">
|
||||||
<div class="margin-form" id="category_input_group" style="display: none;">
|
<div class="margin-form" id="category_input_group" style="display: none;">
|
||||||
<label>'.$this->l('Catégories').' : </label>
|
<label>'.$this->l('Catégories').' : </label>
|
||||||
<select class="chosen-select" id="category" name="category">
|
<select class="chosen-select" id="category" name="category">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" class="button" id="show_current_category_button" value="'.$this->l('Voir cette catégorie').'" style="margin-left: 20px; display: none">
|
<input type="submit" class="button" id="show_current_category_button" value="'.$this->l('Voir cette catégorie').'" style="margin-left: 20px; display: none">
|
||||||
</div>
|
</div>
|
||||||
<form id="formBraderie" action="?tab=AdminBraderie&token='.$token.'" method="POST">
|
<form id="formBraderie" action="?tab=AdminBraderie&token='.$token.'" method="POST">
|
||||||
<div class="margin-form" id="ean_input_group" style="display: none;">
|
<div class="margin-form" id="ean_input_group" style="display: none;">
|
||||||
<label>'.$this->l('Code EAN').' : </label>
|
<label>'.$this->l('Code EAN').' : </label>
|
||||||
<input type="text" name="ean" id="input_ean">
|
<input type="text" name="ean" id="input_ean">
|
||||||
<div id="ean_from_product"></div>
|
<div id="ean_from_product"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="margin-form" id="storage_input_group" style="display: none;">
|
<div class="margin-form" id="comment_input_group" style="display: none;">
|
||||||
<label>'.$this->l('Emplacement').' : </label>
|
<label>'.$this->l('Commentaires').' : </label>
|
||||||
<input type="text" name="storage" id="input_storage">
|
<textarea class="other_textarea" cols="49" rows="3" id="input_comment" name="input_comment"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="margin-form" id="quantity_input_group" style="display: none;">
|
<div class="margin-form" id="storage_input_group" style="display: none;">
|
||||||
<label>'.$this->l('Quantité').' : </label>
|
<label>'.$this->l('Emplacement').' : </label>
|
||||||
<input type="number" name="quantity" id="input_quantity" value="1">
|
<input type="text" name="storage" id="input_storage">
|
||||||
</div>
|
</div>
|
||||||
<div class="margin-form button-container" id="button_input_group" style="display: none;">
|
<div class="margin-form" id="quantity_input_group" style="display: none;">
|
||||||
<input type="submit" class="button" name="adminbraderie" value="'.$this->l('Ajouter').'" style="margin-left: 200px;" id="add_button">
|
<label>'.$this->l('Quantité').' : </label>
|
||||||
<input type="submit" class="button" id="check_button" value="'.$this->l('Vérifier').'">
|
<input type="number" name="quantity" id="input_quantity" value="1">
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="product" id="hidden_product_id">
|
<div class="margin-form button-container" id="button_input_group" style="display: none;">
|
||||||
<input type="hidden" name="attribute" id="hidden_attribute_id">
|
<input type="submit" class="button" name="adminbraderie" value="'.$this->l('Ajouter').'" style="margin-left: 200px;" id="add_button">
|
||||||
</form>
|
<input type="submit" class="button" id="check_button" value="'.$this->l('Vérifier').'">
|
||||||
</fieldset>';
|
</div>
|
||||||
return $html;
|
<input type="hidden" name="product" id="hidden_product_id">
|
||||||
}
|
<input type="hidden" name="attribute" id="hidden_attribute_id">
|
||||||
|
</form>
|
||||||
|
</fieldset>';
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ function getProductId()
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = Db::getInstance()->getRow('
|
$result = Db::getInstance()->getRow('
|
||||||
SELECT p.`id_product`, p.`reference`, pl.`name`, i.`id_image`
|
SELECT p.`id_product`, p.`reference`, pl.`name`, pl.`description_comment` as comments, i.`id_image`
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
|
||||||
@ -71,7 +71,7 @@ function getProductId()
|
|||||||
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
$result = Db::getInstance()->getRow('
|
$result = Db::getInstance()->getRow('
|
||||||
SELECT pa.*, pl.`name`, p.`reference` as product_reference, al.`name` as attribute_name, ia.`id_image` as id_image_attribute, i.`id_image`
|
SELECT pa.*, pl.`name`, pl.`description_comment` as comments, p.`reference` as product_reference, al.`name` as attribute_name, ia.`id_image` as id_image_attribute, i.`id_image`
|
||||||
FROM `'._DB_PREFIX_.'product_attribute` pa
|
FROM `'._DB_PREFIX_.'product_attribute` pa
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = pa.`id_product`)
|
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = pa.`id_product`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = p.`id_product`)
|
||||||
@ -183,6 +183,8 @@ function addToSellout()
|
|||||||
return Tools::displayError('L\'emplacement n\'est pas valide');
|
return Tools::displayError('L\'emplacement n\'est pas valide');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$comment = Tools::getValue('comment', false);
|
||||||
|
|
||||||
//$category_name = Tools::getValue('category_name', false);
|
//$category_name = Tools::getValue('category_name', false);
|
||||||
//$product_name = Tools::getValue('product_name', false);
|
//$product_name = Tools::getValue('product_name', false);
|
||||||
$ean13 = Tools::getValue('ean', false);
|
$ean13 = Tools::getValue('ean', false);
|
||||||
@ -199,17 +201,6 @@ function addToSellout()
|
|||||||
|
|
||||||
$languages = Language::getLanguages(false);
|
$languages = Language::getLanguages(false);
|
||||||
foreach ($languages as $key => $language) {
|
foreach ($languages as $key => $language) {
|
||||||
/*if(!$category_name) {
|
|
||||||
$category_name = Db::getInstance()->getRow('
|
|
||||||
SELECT cl.`name`
|
|
||||||
FROM `'._DB_PREFIX_.'category_lang` cl
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'privatesale` ps ON (ps.`id_category` = cl.`id_category`)
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` pps ON (pps.`id_sale` = ps.`id_sale`)
|
|
||||||
WHERE pps.`id_product` = '.(int)$id_product_old.'
|
|
||||||
AND cl.`id_lang` = '.(int)$language['id_lang']
|
|
||||||
);
|
|
||||||
$category_name = $category_name['name'];
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// récupération de la catégorie originale (nom de la première catégorie)
|
// récupération de la catégorie originale (nom de la première catégorie)
|
||||||
$category_name = Db::getInstance()->getRow('
|
$category_name = Db::getInstance()->getRow('
|
||||||
@ -267,6 +258,9 @@ function addToSellout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
$product->id_category_default = (int)$category;
|
$product->id_category_default = (int)$category;
|
||||||
|
if ($comment) {
|
||||||
|
$product->description_comment[2] = $comment;
|
||||||
|
}
|
||||||
|
|
||||||
if ($product->add()) {
|
if ($product->add()) {
|
||||||
if (!$id_attribute) {
|
if (!$id_attribute) {
|
||||||
@ -283,28 +277,12 @@ function addToSellout()
|
|||||||
|
|
||||||
$product->UpdateCategories(array((int)$category,(int)$parent_category));
|
$product->UpdateCategories(array((int)$category,(int)$parent_category));
|
||||||
|
|
||||||
/*$max_position = Db::getInstance()->getValue("SELECT MAX(cp.`position`) AS max FROM `"._DB_PREFIX_."category_product` cp WHERE cp.`id_category`=" . (int)$category);
|
|
||||||
$add_category = Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."category_product` (`id_product`, `id_category`, `position`)
|
|
||||||
VALUES (
|
|
||||||
'". $product->id ."',
|
|
||||||
'". (int)$category ."',
|
|
||||||
'". (int)($max_position + 1 ) ."'
|
|
||||||
)");
|
|
||||||
|
|
||||||
$max_position_in_parent = Db::getInstance()->getValue("SELECT MAX(cp.`position`) AS max FROM `"._DB_PREFIX_."category_product` cp WHERE cp.`id_category`=" . (int)$parent_category);
|
|
||||||
$add_parent_category = Db::getInstance()->Execute("INSERT INTO `"._DB_PREFIX_."category_product` (`id_product`, `id_category`, `position`)
|
|
||||||
VALUES (
|
|
||||||
'". $product->id ."',
|
|
||||||
'". (int)$parent_category ."',
|
|
||||||
'". (int)($max_position_in_parent + 1 ) ."'
|
|
||||||
)");*/
|
|
||||||
|
|
||||||
if ($product->hasAttributes())
|
if ($product->hasAttributes())
|
||||||
Product::updateDefaultAttribute($product->id);
|
Product::updateDefaultAttribute($product->id);
|
||||||
|
|
||||||
Image::duplicateProductImages($id_product_old, $product->id, $combinationImages);
|
Image::duplicateProductImages($id_product_old, $product->id, $combinationImages);
|
||||||
}
|
}
|
||||||
return Tools::displayError('Le produit à été mis dans la braderie');
|
return Tools::displayError('Le produit ajoute dans la braderie');
|
||||||
}
|
}
|
||||||
|
|
||||||
function pSQLArray($data)
|
function pSQLArray($data)
|
||||||
|
@ -8,16 +8,17 @@ class AdminEditFast extends AdminTab {
|
|||||||
|
|
||||||
public function postProcess(){
|
public function postProcess(){
|
||||||
if (Tools::isSubmit('submitEditFast')){
|
if (Tools::isSubmit('submitEditFast')){
|
||||||
$products = json_decode(Tools::getValue('id_product'), 0);
|
$products = json_decode(Tools::getValue('id_product'), 0);
|
||||||
$title = Tools::getValue('title');
|
$title = Tools::getValue('title');
|
||||||
$short_description = Tools::getValue('short_description', array());
|
$short_description = Tools::getValue('short_description', array());
|
||||||
$description = Tools::getValue('description', array());
|
$description = Tools::getValue('description', array());
|
||||||
$description_more = Tools::getValue('description_more', array());
|
$description_more = Tools::getValue('description_more', array());
|
||||||
|
$description_comment = Tools::getValue('description_comment', array());
|
||||||
$description_delivery = Tools::getValue('description_delivery', array());
|
$description_delivery = Tools::getValue('description_delivery', array());
|
||||||
$videos = Tools::getValue('videos', array());
|
$videos = Tools::getValue('videos', array());
|
||||||
$reference = Tools::getValue('reference');
|
$reference = Tools::getValue('reference');
|
||||||
$id_lang_fast = Tools::getValue('id_lang_fast');
|
$id_lang_fast = Tools::getValue('id_lang_fast');
|
||||||
$nbProduct = 0;
|
$nbProduct = 0;
|
||||||
|
|
||||||
foreach ($products as $key => $product) {
|
foreach ($products as $key => $product) {
|
||||||
if (Validate::isLoadedObject($product = new Product((int)$product))) {
|
if (Validate::isLoadedObject($product = new Product((int)$product))) {
|
||||||
@ -26,7 +27,7 @@ class AdminEditFast extends AdminTab {
|
|||||||
// $product->name[$language['id_lang']] = $title[$product->id];
|
// $product->name[$language['id_lang']] = $title[$product->id];
|
||||||
// }
|
// }
|
||||||
// if(isset($short_description[$product->id])){
|
// if(isset($short_description[$product->id])){
|
||||||
// $product->description_short[$language['id_lang']] = $short_description[$product->id];
|
// $product->description_short[$language['id_lang']] = $short_description[$product->id];
|
||||||
// }
|
// }
|
||||||
// if(isset($description[$product->id])){
|
// if(isset($description[$product->id])){
|
||||||
// $product->description[$language['id_lang']] = $description[$product->id];
|
// $product->description[$language['id_lang']] = $description[$product->id];
|
||||||
@ -36,7 +37,7 @@ class AdminEditFast extends AdminTab {
|
|||||||
$product->name[(int) $id_lang_fast] = $title[$product->id];
|
$product->name[(int) $id_lang_fast] = $title[$product->id];
|
||||||
}
|
}
|
||||||
if (isset($short_description[$product->id])) {
|
if (isset($short_description[$product->id])) {
|
||||||
$product->description_short[(int) $id_lang_fast] = $short_description[$product->id];
|
$product->description_short[(int) $id_lang_fast] = $short_description[$product->id];
|
||||||
}
|
}
|
||||||
if(isset($description[$product->id])){
|
if(isset($description[$product->id])){
|
||||||
$product->description[(int) $id_lang_fast] = $description[$product->id];
|
$product->description[(int) $id_lang_fast] = $description[$product->id];
|
||||||
@ -44,6 +45,9 @@ class AdminEditFast extends AdminTab {
|
|||||||
if(isset($description_more[$product->id])){
|
if(isset($description_more[$product->id])){
|
||||||
$product->description_more[(int) $id_lang_fast] = $description_more[$product->id];
|
$product->description_more[(int) $id_lang_fast] = $description_more[$product->id];
|
||||||
}
|
}
|
||||||
|
if(isset($description_comment[$product->id])){
|
||||||
|
$product->description_comment[(int) $id_lang_fast] = $description_comment[$product->id];
|
||||||
|
}
|
||||||
if(isset($description_delivery[$product->id])){
|
if(isset($description_delivery[$product->id])){
|
||||||
$product->description_delivery[(int) $id_lang_fast] = $description_delivery[$product->id];
|
$product->description_delivery[(int) $id_lang_fast] = $description_delivery[$product->id];
|
||||||
}
|
}
|
||||||
@ -57,7 +61,7 @@ class AdminEditFast extends AdminTab {
|
|||||||
if ($product->save()) {
|
if ($product->save()) {
|
||||||
$nbProduct++;
|
$nbProduct++;
|
||||||
} else {
|
} else {
|
||||||
$this->_html .= $product . " erreur";
|
$this->_html .= $product . " erreur";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->_html .= $product . " erreur";
|
$this->_html .= $product . " erreur";
|
||||||
@ -78,6 +82,7 @@ class AdminEditFast extends AdminTab {
|
|||||||
'short_description',
|
'short_description',
|
||||||
'description',
|
'description',
|
||||||
'description_more',
|
'description_more',
|
||||||
|
'description_comment',
|
||||||
'description_delivery',
|
'description_delivery',
|
||||||
'videos'
|
'videos'
|
||||||
);
|
);
|
||||||
@ -103,7 +108,7 @@ class AdminEditFast extends AdminTab {
|
|||||||
$this->_html .= '<input type="submit" class="button" value="Mettre à jour" name="submitEditFast">';
|
$this->_html .= '<input type="submit" class="button" value="Mettre à jour" name="submitEditFast">';
|
||||||
$this->_html .= '</div>';
|
$this->_html .= '</div>';
|
||||||
$this->_html .= '</form>';
|
$this->_html .= '</form>';
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$this->_html .= "<div class='error'>Vous devez choisir des produits dans l'onglet Catalogue</div>";
|
$this->_html .= "<div class='error'>Vous devez choisir des produits dans l'onglet Catalogue</div>";
|
||||||
}
|
}
|
||||||
@ -119,7 +124,7 @@ class AdminEditFast extends AdminTab {
|
|||||||
var pathCSS = \''._THEME_CSS_DIR_.'\' ;
|
var pathCSS = \''._THEME_CSS_DIR_.'\' ;
|
||||||
var ad = \''.$ad.'\' ;
|
var ad = \''.$ad.'\' ;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<link type="text/css" rel="stylesheet" href="'.__PS_BASE_URI__.'js/jquery/accordion/accordion.css" />
|
<link type="text/css" rel="stylesheet" href="'.__PS_BASE_URI__.'js/jquery/accordion/accordion.css" />
|
||||||
|
|
||||||
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
|
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
|
||||||
@ -160,6 +165,11 @@ class AdminEditFast extends AdminTab {
|
|||||||
$form .= '<textarea name="description_more['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->description_more.'</textarea>';
|
$form .= '<textarea name="description_more['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->description_more.'</textarea>';
|
||||||
$form .= '<br /><br />';
|
$form .= '<br /><br />';
|
||||||
}
|
}
|
||||||
|
if (in_array('description_comment',$blocks)) {
|
||||||
|
$form .= '<label>Commentaires (braderie)</label>';
|
||||||
|
$form .= '<textarea name="description_comment['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->description_comment.'</textarea>';
|
||||||
|
$form .= '<br /><br />';
|
||||||
|
}
|
||||||
if (in_array('videos',$blocks)) {
|
if (in_array('videos',$blocks)) {
|
||||||
$form .= '<label>Videos</label>';
|
$form .= '<label>Videos</label>';
|
||||||
$form .= '<textarea name="videos['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->videos.'</textarea>';
|
$form .= '<textarea name="videos['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->videos.'</textarea>';
|
||||||
@ -170,7 +180,7 @@ class AdminEditFast extends AdminTab {
|
|||||||
$form .= '<textarea name="description_delivery['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->description_delivery.'</textarea>';
|
$form .= '<textarea name="description_delivery['. (int) $product->id.']" class="rte" id="" cols="10" rows="10">'.$product->description_delivery.'</textarea>';
|
||||||
$form .= '<br /><br />';
|
$form .= '<br /><br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
$form .= '</fieldset>';
|
$form .= '</fieldset>';
|
||||||
$form .= '</div>';
|
$form .= '</div>';
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
class Product extends ProductCore
|
class Product extends ProductCore
|
||||||
{
|
{
|
||||||
public $description_more;
|
public $description_more;
|
||||||
|
public $description_comment;
|
||||||
public $description_delivery;
|
public $description_delivery;
|
||||||
public $videos;
|
public $videos;
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ class Product extends ProductCore
|
|||||||
'meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName',
|
'meta_description' => 'isGenericName', 'meta_keywords' => 'isGenericName',
|
||||||
'meta_title' => 'isGenericName', 'link_rewrite' => 'isLinkRewrite', 'name' => 'isCatalogName',
|
'meta_title' => 'isGenericName', 'link_rewrite' => 'isLinkRewrite', 'name' => 'isCatalogName',
|
||||||
'description' => 'isString', 'description_short' => 'isString', 'available_now' => 'isGenericName', 'available_later' => 'IsGenericName',
|
'description' => 'isString', 'description_short' => 'isString', 'available_now' => 'isGenericName', 'available_later' => 'IsGenericName',
|
||||||
'description_more' => 'isString','videos' => 'isString', 'description_delivery' => 'isString');
|
'description_more' => 'isString', 'description_comment' => 'isString', 'videos' => 'isString', 'description_delivery' => 'isString');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Override
|
* @Override
|
||||||
@ -35,6 +36,7 @@ class Product extends ProductCore
|
|||||||
$fields[$language['id_lang']]['description'] = (isset($this->description[$language['id_lang']])) ? pSQL($this->description[$language['id_lang']], true) : '';
|
$fields[$language['id_lang']]['description'] = (isset($this->description[$language['id_lang']])) ? pSQL($this->description[$language['id_lang']], true) : '';
|
||||||
$fields[$language['id_lang']]['description_short'] = (isset($this->description_short[$language['id_lang']])) ? pSQL($this->description_short[$language['id_lang']], true) : '';
|
$fields[$language['id_lang']]['description_short'] = (isset($this->description_short[$language['id_lang']])) ? pSQL($this->description_short[$language['id_lang']], true) : '';
|
||||||
$fields[$language['id_lang']]['description_more'] = (isset($this->description_more[$language['id_lang']])) ? pSQL($this->description_more[$language['id_lang']], true) : '';
|
$fields[$language['id_lang']]['description_more'] = (isset($this->description_more[$language['id_lang']])) ? pSQL($this->description_more[$language['id_lang']], true) : '';
|
||||||
|
$fields[$language['id_lang']]['description_comment'] = (isset($this->description_comment[$language['id_lang']])) ? pSQL($this->description_comment[$language['id_lang']], true) : '';
|
||||||
$fields[$language['id_lang']]['videos'] = (isset($this->videos[$language['id_lang']])) ? pSQL($this->videos[$language['id_lang']], true) : '';
|
$fields[$language['id_lang']]['videos'] = (isset($this->videos[$language['id_lang']])) ? pSQL($this->videos[$language['id_lang']], true) : '';
|
||||||
$fields[$language['id_lang']]['description_delivery'] = (isset($this->description_delivery[$language['id_lang']])) ? pSQL($this->description_delivery[$language['id_lang']], true) : '';
|
$fields[$language['id_lang']]['description_delivery'] = (isset($this->description_delivery[$language['id_lang']])) ? pSQL($this->description_delivery[$language['id_lang']], true) : '';
|
||||||
foreach ($fieldsArray as $field)
|
foreach ($fieldsArray as $field)
|
||||||
@ -69,7 +71,7 @@ class Product extends ProductCore
|
|||||||
/**
|
/**
|
||||||
* @Override
|
* @Override
|
||||||
* Admin panel product search
|
* Admin panel product search
|
||||||
*
|
*
|
||||||
* @param integer $id_lang Language id
|
* @param integer $id_lang Language id
|
||||||
* @param string $query Search query
|
* @param string $query Search query
|
||||||
* @return array Matching products
|
* @return array Matching products
|
||||||
|
Loading…
Reference in New Issue
Block a user