Merge branch 'ticket-10805' into develop
This commit is contained in:
commit
5edc9724a3
@ -245,6 +245,47 @@ class AdminProducts extends AdminTab
|
|||||||
Tools::redirectAdmin($currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&token='.($token ? $token : $this->token));
|
Tools::redirectAdmin($currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&token='.($token ? $token : $this->token));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Tools::isSubmit('clean_positionproduct')) {
|
||||||
|
global $cookie, $currentIndex;
|
||||||
|
|
||||||
|
if ($cookie->id_employee == 1) {
|
||||||
|
$category_products = Db::getInstance()->ExecuteS('
|
||||||
|
SELECT cp.`id_product`, cp.`position`, cp.`id_category`
|
||||||
|
FROM `'._DB_PREFIX_.'category_product` cp
|
||||||
|
WHERE cp.`id_category` = '.(int)$this->_category->id.'
|
||||||
|
ORDER BY cp.`position` ASC
|
||||||
|
');
|
||||||
|
|
||||||
|
// Position mise à 0
|
||||||
|
Db::getInstance()->Execute('
|
||||||
|
UPDATE `'._DB_PREFIX_.'category_product`
|
||||||
|
SET `position` = 0
|
||||||
|
WHERE `id_category` = '.(int)$this->_category->id
|
||||||
|
);
|
||||||
|
|
||||||
|
$pos = 0;
|
||||||
|
foreach ($category_products as $key => $cat_product) {
|
||||||
|
if(Validate::isLoadedObject($product = new Product((int)$cat_product['id_product']))){
|
||||||
|
Db::getInstance()->Execute('
|
||||||
|
UPDATE `'._DB_PREFIX_.'category_product`
|
||||||
|
SET `position` = '. (int)($pos) .'
|
||||||
|
WHERE `id_product` = '.(int)$cat_product['id_product'].'
|
||||||
|
AND `id_category`='.(int)$this->_category->id
|
||||||
|
);
|
||||||
|
$pos++;
|
||||||
|
} else {
|
||||||
|
Db::getInstance()->Execute('
|
||||||
|
DELETE FROM `'._DB_PREFIX_.'category_product`
|
||||||
|
WHERE `id_category` = '.(int)$this->_category->id.'
|
||||||
|
AND `id_product` = '.(int)$cat_product['id_product'].'
|
||||||
|
');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Tools::redirectAdmin($currentIndex.(Tools::getValue('id_category') ? '&id_category='.Tools::getValue('id_category') : '').'&token='.($token ? $token : $this->token));
|
||||||
|
}
|
||||||
|
|
||||||
if (Tools::isSubmit('reorderproduct') || Tools::isSubmit('reordersubproduct')) {
|
if (Tools::isSubmit('reorderproduct') || Tools::isSubmit('reordersubproduct')) {
|
||||||
global $cookie, $currentIndex;
|
global $cookie, $currentIndex;
|
||||||
|
|
||||||
@ -1939,6 +1980,10 @@ class AdminProducts extends AdminTab
|
|||||||
echo '<p><input type="submit" class="button" name="reordersub'.$this->table.'" value="'.$this->l('Order products').'" /></p>';
|
echo '<p><input type="submit" class="button" name="reordersub'.$this->table.'" value="'.$this->l('Order products').'" /></p>';
|
||||||
echo '<p>'.$this->l('Order by product name').'</p>';
|
echo '<p>'.$this->l('Order by product name').'</p>';
|
||||||
}
|
}
|
||||||
|
if((int)$this->_category->id_oarent !=1 && $cookie->id_employee==1){
|
||||||
|
echo '<p><input type="submit" class="button" name="clean_position'.$this->table.'" value="'.$this->l('Order products').'" /></p>';
|
||||||
|
echo '<p>'.$this->l('Re-Order by product position, clean all position of the category').'</p>';
|
||||||
|
}
|
||||||
|
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
if (isset($this->_includeTab) AND sizeof($this->_includeTab))
|
if (isset($this->_includeTab) AND sizeof($this->_includeTab))
|
||||||
@ -4497,6 +4542,12 @@ class AdminProducts extends AdminTab
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getFieldValue($obj, $data, $id_lang) {
|
public function getFieldValue($obj, $data, $id_lang) {
|
||||||
|
global $cookie;
|
||||||
|
|
||||||
|
// if ($id_lang == 0) {
|
||||||
|
// $id_lang = (int)($cookie->id_lang);
|
||||||
|
// }
|
||||||
|
|
||||||
$customs_data = Db::getInstance()->getRow('
|
$customs_data = Db::getInstance()->getRow('
|
||||||
SELECT `nc8`, `id_country`
|
SELECT `nc8`, `id_country`
|
||||||
FROM `'._DB_PREFIX_.'product_customs`
|
FROM `'._DB_PREFIX_.'product_customs`
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 2007-2011 PrestaShop
|
* 2007-2011 PrestaShop
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* NOTICE OF LICENSE
|
||||||
*
|
*
|
||||||
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('table.tableDnD').tableDnD({
|
$('table.tableDnD').tableDnD({
|
||||||
|
|
||||||
onDragStart: function(table, row) {
|
onDragStart: function(table, row) {
|
||||||
originalOrder = $.tableDnD.serialize();
|
originalOrder = $.tableDnD.serialize();
|
||||||
reOrder = ':even';
|
reOrder = ':even';
|
||||||
@ -38,7 +38,7 @@ $(document).ready(function() {
|
|||||||
onDragClass: 'myDragClass',
|
onDragClass: 'myDragClass',
|
||||||
onDrop: function(table, row) {
|
onDrop: function(table, row) {
|
||||||
if (originalOrder != $.tableDnD.serialize()) {
|
if (originalOrder != $.tableDnD.serialize()) {
|
||||||
|
var url_params = $.tableDnD.serialize();
|
||||||
var way = (originalOrder.indexOf(row.id) < $.tableDnD.serialize().indexOf(row.id))? 1 : 0;
|
var way = (originalOrder.indexOf(row.id) < $.tableDnD.serialize().indexOf(row.id))? 1 : 0;
|
||||||
var ids = row.id.split('_');
|
var ids = row.id.split('_');
|
||||||
var tableDrag = $('#' + table.id);
|
var tableDrag = $('#' + table.id);
|
||||||
@ -76,19 +76,25 @@ $(document).ready(function() {
|
|||||||
token: token
|
token: token
|
||||||
};
|
};
|
||||||
if (table.id == 'product') {
|
if (table.id == 'product') {
|
||||||
|
// @Override Antadis - Passing product array in Post to prevent bug when too many products on list (url request too long)
|
||||||
|
var post_params = url_params.replace(/&/g,"");
|
||||||
|
post_params = post_params.split("product[]=");
|
||||||
|
post_params.splice(0, 1);;
|
||||||
params = {
|
params = {
|
||||||
ajaxProductsPositions: true,
|
ajaxProductsPositions: true,
|
||||||
id_category: ids[1],
|
id_category: ids[1],
|
||||||
id_product: ids[2],
|
id_product: ids[2],
|
||||||
way: way,
|
way: way,
|
||||||
token: token
|
token: token,
|
||||||
|
product : post_params
|
||||||
};
|
};
|
||||||
|
url_params = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
async: false,
|
async: false,
|
||||||
url: 'ajax.php?' + $.tableDnD.serialize(),
|
url: 'ajax.php?'+url_params,
|
||||||
data: params,
|
data: params,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (come_from == 'AdminModulesPositions') {
|
if (come_from == 'AdminModulesPositions') {
|
||||||
@ -105,21 +111,21 @@ $(document).ready(function() {
|
|||||||
var reg = /_[0-9][0-9]*$/g;
|
var reg = /_[0-9][0-9]*$/g;
|
||||||
tableDrag.find('tbody tr').each(function(i) {
|
tableDrag.find('tbody tr').each(function(i) {
|
||||||
$(this).attr('id', $(this).attr('id').replace(reg, '_' + i));
|
$(this).attr('id', $(this).attr('id').replace(reg, '_' + i));
|
||||||
|
|
||||||
// Update link position
|
// Update link position
|
||||||
var up_reg = new RegExp('position=[-]?[0-9]+&');
|
var up_reg = new RegExp('position=[-]?[0-9]+&');
|
||||||
|
|
||||||
// Up links
|
// Up links
|
||||||
$(this).find('td.dragHandle a:odd').attr('href', $(this).find('td.dragHandle a:odd').attr('href').replace(up_reg, 'position='+ (i - 1) +'&'));
|
$(this).find('td.dragHandle a:odd').attr('href', $(this).find('td.dragHandle a:odd').attr('href').replace(up_reg, 'position='+ (i - 1) +'&'));
|
||||||
|
|
||||||
// Down links
|
// Down links
|
||||||
$(this).find('td.dragHandle a:even').attr('href', $(this).find('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&'));
|
$(this).find('td.dragHandle a:even').attr('href', $(this).find('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&'));
|
||||||
|
|
||||||
});
|
});
|
||||||
tableDrag.find('tr').not('.nodrag').removeClass('alt_row');
|
tableDrag.find('tr').not('.nodrag').removeClass('alt_row');
|
||||||
tableDrag.find('tr:not(".nodrag"):odd').addClass('alt_row');
|
tableDrag.find('tr:not(".nodrag"):odd').addClass('alt_row');
|
||||||
tableDrag.find('tr td.dragHandle a:hidden').show();
|
tableDrag.find('tr td.dragHandle a:hidden').show();
|
||||||
|
|
||||||
if (alternate) {
|
if (alternate) {
|
||||||
tableDrag.find('tr td.dragHandle:first a:odd').hide();
|
tableDrag.find('tr td.dragHandle:first a:odd').hide();
|
||||||
tableDrag.find('tr td.dragHandle:last a:even').hide();
|
tableDrag.find('tr td.dragHandle:last a:even').hide();
|
||||||
@ -129,27 +135,27 @@ $(document).ready(function() {
|
|||||||
tableDrag.find('tr td.dragHandle:last a:odd').hide();
|
tableDrag.find('tr td.dragHandle:last a:odd').hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var reg = /_[0-9]$/g;
|
var reg = /_[0-9]$/g;
|
||||||
tableDrag.find('tbody tr').each(function(i) {
|
tableDrag.find('tbody tr').each(function(i) {
|
||||||
$(this).attr('id', $(this).attr('id').replace(reg, '_' + i));
|
$(this).attr('id', $(this).attr('id').replace(reg, '_' + i));
|
||||||
|
|
||||||
// Update link position
|
// Update link position
|
||||||
var up_reg = new RegExp('position=[-]?[0-9]+&');
|
var up_reg = new RegExp('position=[-]?[0-9]+&');
|
||||||
|
|
||||||
// Up links
|
// Up links
|
||||||
$(this).find('td.dragHandle a:odd').attr('href', $(this).find('td.dragHandle a:odd').attr('href').replace(up_reg, 'position='+ (i - 1) +'&'));
|
$(this).find('td.dragHandle a:odd').attr('href', $(this).find('td.dragHandle a:odd').attr('href').replace(up_reg, 'position='+ (i - 1) +'&'));
|
||||||
|
|
||||||
// Down links
|
// Down links
|
||||||
$(this).find('td.dragHandle a:even').attr('href', $(this).find('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&'));
|
$(this).find('td.dragHandle a:even').attr('href', $(this).find('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&'));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tableDrag.find('tr').not('.nodrag').removeClass('alt_row');
|
tableDrag.find('tr').not('.nodrag').removeClass('alt_row');
|
||||||
tableDrag.find('tr:not(".nodrag"):odd').addClass('alt_row');
|
tableDrag.find('tr:not(".nodrag"):odd').addClass('alt_row');
|
||||||
tableDrag.find('tr td.dragHandle a:hidden').show();
|
tableDrag.find('tr td.dragHandle a:hidden').show();
|
||||||
|
|
||||||
if (alternate) {
|
if (alternate) {
|
||||||
tableDrag.find('tr td.dragHandle:first a:odd').hide();
|
tableDrag.find('tr td.dragHandle:first a:odd').hide();
|
||||||
tableDrag.find('tr td.dragHandle:last a:even').hide();
|
tableDrag.find('tr td.dragHandle:last a:even').hide();
|
||||||
|
@ -212,6 +212,10 @@ class AdminBraderie extends AdminTab
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// $("#formBraderie").submit(function(){
|
||||||
|
// return false;
|
||||||
|
// });
|
||||||
|
|
||||||
$("#add_button").click(function(event) {
|
$("#add_button").click(function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
@ -374,7 +378,7 @@ class AdminBraderie extends AdminTab
|
|||||||
<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">
|
<a href="?tab=AdminCatalog" class="button" id="show_current_category_button" style="margin-left: 20px; display: none">'.$this->l('Voir cette catégorie').'</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="margin-form" id="quantity_input_group" style="display: none;">
|
<div class="margin-form" id="quantity_input_group" style="display: none;">
|
||||||
<label>'.$this->l('Quantité').' : </label>
|
<label>'.$this->l('Quantité').' : </label>
|
||||||
@ -389,8 +393,8 @@ class AdminBraderie extends AdminTab
|
|||||||
<textarea class="other_textarea" cols="49" rows="3" id="input_comment" name="input_comment"></textarea>
|
<textarea class="other_textarea" cols="49" rows="3" id="input_comment" name="input_comment"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="margin-form button-container" id="button_input_group" style="display: none;">
|
<div class="margin-form button-container" id="button_input_group" style="display: none;">
|
||||||
<!--input type="submit" class="button" name="adminbraderie" value="'.$this->l('Ajouter').'" style="margin-left: 200px;" id="add_button"-->
|
<input type="submit" class="button" name="adminbraderie" value="'.$this->l('Ajouter').'" style="margin-left: 200px;" id="add_button">
|
||||||
<input type="submit" class="button" id="check_button" value="'.$this->l('Vérifier').'" style="margin-left: 200px;">
|
<input type="submit" class="button" id="check_button" value="'.$this->l('Vérifier').'">
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="product" id="hidden_product_id">
|
<input type="hidden" name="product" id="hidden_product_id">
|
||||||
<input type="hidden" name="attribute" id="hidden_attribute_id">
|
<input type="hidden" name="attribute" id="hidden_attribute_id">
|
||||||
|
@ -282,7 +282,7 @@ function addToSellout()
|
|||||||
|
|
||||||
Image::duplicateProductImages($id_product_old, $product->id, $combinationImages);
|
Image::duplicateProductImages($id_product_old, $product->id, $combinationImages);
|
||||||
}
|
}
|
||||||
return Tools::displayError('Le produit ajoute dans la braderie');
|
return Tools::displayError('Le produit a été ajouté à la braderie');
|
||||||
}
|
}
|
||||||
|
|
||||||
function pSQLArray($data)
|
function pSQLArray($data)
|
||||||
|
Loading…
Reference in New Issue
Block a user