[*] BO : #PSFV-865 - it is now possible to use drag and drop positions in custom controllers using HelperList
This commit is contained in:
@@ -92,171 +92,6 @@ if (Tools::isSubmit('getAvailableFields') AND Tools::isSubmit('entity'))
|
|||||||
die('['.implode(',', $jsonArray).']');
|
die('['.implode(',', $jsonArray).']');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Tools::isSubmit('ajaxModulesPositions'))
|
|
||||||
{
|
|
||||||
$id_module = (int)(Tools::getValue('id_module'));
|
|
||||||
$id_hook = (int)(Tools::getValue('id_hook'));
|
|
||||||
$way = (int)(Tools::getValue('way'));
|
|
||||||
$positions = Tools::getValue(strval($id_hook));
|
|
||||||
$position = (is_array($positions)) ? array_search($id_hook.'_'.$id_module, $positions) : null;
|
|
||||||
$module = Module::getInstanceById($id_module);
|
|
||||||
if (Validate::isLoadedObject($module))
|
|
||||||
if ($module->updatePosition($id_hook, $way, $position))
|
|
||||||
die(true);
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, "errors" : "Can not update module position"}');
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, "errors" : "This module can not be loaded"}');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Tools::isSubmit('ajaxCategoriesPositions'))
|
|
||||||
{
|
|
||||||
$id_category_to_move = (int)(Tools::getValue('id_category_to_move'));
|
|
||||||
$id_category_parent = (int)(Tools::getValue('id_category_parent'));
|
|
||||||
$way = (int)(Tools::getValue('way'));
|
|
||||||
$positions = Tools::getValue('category');
|
|
||||||
if (is_array($positions))
|
|
||||||
foreach ($positions AS $key => $value)
|
|
||||||
{
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
if ((isset($pos[1]) AND isset($pos[2])) AND ($pos[1] == $id_category_parent AND $pos[2] == $id_category_to_move))
|
|
||||||
{
|
|
||||||
$position = $key + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$category = new Category($id_category_to_move);
|
|
||||||
if (Validate::isLoadedObject($category))
|
|
||||||
{
|
|
||||||
if (isset($position) && $category->updatePosition($way, $position))
|
|
||||||
{
|
|
||||||
Hook::exec('actionCategoryUpdate');
|
|
||||||
die(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, errors : "Can not update categories position"}');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, "errors" : "This category can not be loaded"}');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Tools::isSubmit('ajaxCMSCategoriesPositions'))
|
|
||||||
{
|
|
||||||
$id_cms_category_to_move = (int)(Tools::getValue('id_cms_category_to_move'));
|
|
||||||
$id_cms_category_parent = (int)(Tools::getValue('id_cms_category_parent'));
|
|
||||||
$way = (int)(Tools::getValue('way'));
|
|
||||||
$positions = Tools::getValue('cms_category');
|
|
||||||
if (is_array($positions))
|
|
||||||
foreach ($positions AS $key => $value)
|
|
||||||
{
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
if ((isset($pos[1]) AND isset($pos[2])) AND ($pos[1] == $id_cms_category_parent AND $pos[2] == $id_cms_category_to_move))
|
|
||||||
{
|
|
||||||
$position = $key;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$cms_category = new CMSCategory($id_cms_category_to_move);
|
|
||||||
if (Validate::isLoadedObject($cms_category))
|
|
||||||
{
|
|
||||||
if (isset($position) && $cms_category->updatePosition($way, $position))
|
|
||||||
die(true);
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, "errors" : "Can not update cms categories position"}');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, "errors" : "This cms category can not be loaded"}');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Tools::isSubmit('ajaxCMSPositions'))
|
|
||||||
{
|
|
||||||
$id_cms = (int)(Tools::getValue('id_cms'));
|
|
||||||
$id_category = (int)(Tools::getValue('id_cms_category'));
|
|
||||||
$way = (int)(Tools::getValue('way'));
|
|
||||||
$positions = Tools::getValue('cms');
|
|
||||||
if (is_array($positions))
|
|
||||||
foreach ($positions AS $key => $value)
|
|
||||||
{
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
if ((isset($pos[1]) AND isset($pos[2])) AND ($pos[1] == $id_category AND $pos[2] == $id_cms))
|
|
||||||
{
|
|
||||||
$position = $key;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$cms = new CMS($id_cms);
|
|
||||||
if (Validate::isLoadedObject($cms))
|
|
||||||
{
|
|
||||||
if (isset($position) && $cms->updatePosition($way, $position))
|
|
||||||
die(true);
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, "errors" : "Can not update cms position"}');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, "errors" : "This cms can not be loaded"}');
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modify product position in catalog */
|
|
||||||
if (Tools::isSubmit('ajaxProductsPositions'))
|
|
||||||
{
|
|
||||||
$way = (int)(Tools::getValue('way'));
|
|
||||||
$id_product = (int)(Tools::getValue('id_product'));
|
|
||||||
$id_category = (int)(Tools::getValue('id_category'));
|
|
||||||
$positions = Tools::getValue('product');
|
|
||||||
|
|
||||||
if (is_array($positions))
|
|
||||||
foreach ($positions AS $position => $value)
|
|
||||||
{
|
|
||||||
// pos[1] = id_categ, pos[2] = id_product, pos[3]=old position
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
|
|
||||||
if ((isset($pos[1]) AND isset($pos[2])) AND ($pos[1] == $id_category AND (int)$pos[2] === $id_product))
|
|
||||||
{
|
|
||||||
if ($product = new Product((int)$pos[2]))
|
|
||||||
if (isset($position) && $product->updatePosition($way, $position))
|
|
||||||
echo "ok position ".(int)$position." for product ".(int)$pos[2]."\r\n";
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "Can not update product '. (int)$id_product . ' to position '.(int)$position.' "}';
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "This product ('.(int)$id_product.') can t be loaded"}';
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Tools::isSubmit('ajaxProductImagesPositions'))
|
|
||||||
{
|
|
||||||
$id_image = (int)(Tools::getValue('id_image'));
|
|
||||||
$way = (int)(Tools::getValue('way'));
|
|
||||||
$positions = Tools::getValue('imageTable');
|
|
||||||
|
|
||||||
if (is_array($positions))
|
|
||||||
foreach ($positions AS $key => $value)
|
|
||||||
{
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
if ((isset($pos[1])) AND ($pos[1] == $id_image))
|
|
||||||
{
|
|
||||||
// +1 is added because images position range starts from 1 instead of 0 for other objects (products, categories...)
|
|
||||||
$position = ($key + 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$image = new Image($id_image);
|
|
||||||
if (Validate::isLoadedObject($image))
|
|
||||||
{
|
|
||||||
if (isset($position) && $image->updatePosition($way, $position))
|
|
||||||
die(true);
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, "errors" : "Cannot update image position"}');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
die('{"hasError" : true, "errors" : "This image cannot be loaded"}');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (Tools::isSubmit('ajaxProductPackItems'))
|
if (Tools::isSubmit('ajaxProductPackItems'))
|
||||||
{
|
{
|
||||||
$jsonArray = array();
|
$jsonArray = array();
|
||||||
@@ -740,126 +575,6 @@ if (Tools::isSubmit('syncImapMail'))
|
|||||||
die('{"hasError" : false, "errors" : ["'.$str_errors.$str_error_delete.'"]}');
|
die('{"hasError" : false, "errors" : ["'.$str_errors.$str_error_delete.'"]}');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modify attribute position */
|
|
||||||
if (Tools::isSubmit('ajaxAttributesPositions'))
|
|
||||||
{
|
|
||||||
$way = (int)Tools::getValue('way');
|
|
||||||
$id_attribute = (int)Tools::getValue('id_attribute');
|
|
||||||
$id_attribute_group = (int)Tools::getValue('id_attribute_group');
|
|
||||||
$positions = Tools::getValue('attribute');
|
|
||||||
|
|
||||||
if (is_array($positions))
|
|
||||||
foreach ($positions as $position => $value)
|
|
||||||
{
|
|
||||||
// pos[1] = id_attribute_group, pos[2] = id_attribute, pos[3]=old position
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
|
|
||||||
if ((isset($pos[1]) && isset($pos[2])) && ($pos[1] == $id_attribute_group && (int)$pos[2] === $id_attribute))
|
|
||||||
{
|
|
||||||
if ($attribute = new Attribute((int)$pos[2]))
|
|
||||||
if (isset($position) && $attribute->updatePosition($way, $position))
|
|
||||||
echo "ok position ".(int)$position." for attribute ".(int)$pos[2]."\r\n";
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "Can not update attribute '. (int)$id_attribute . ' to position '.(int)$position.' "}';
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "This attribute ('.(int)$id_attribute.') can t be loaded"}';
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modify group attribute position */
|
|
||||||
if (Tools::isSubmit('ajaxGroupsAttributesPositions'))
|
|
||||||
{
|
|
||||||
$way = (int)Tools::getValue('way');
|
|
||||||
$id_attribute_group = (int)Tools::getValue('id_attribute_group');
|
|
||||||
$positions = Tools::getValue('attribute_group');
|
|
||||||
|
|
||||||
$new_positions = array();
|
|
||||||
foreach($positions as $k => $v)
|
|
||||||
if (count(explode('_', $v)) == 4)
|
|
||||||
$new_positions[] = $v;
|
|
||||||
|
|
||||||
foreach ($new_positions as $position => $value)
|
|
||||||
{
|
|
||||||
// pos[1] = id_attribute_group, pos[2] = old position
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
|
|
||||||
if (isset($pos[2]) && (int)$pos[2] === $id_attribute_group)
|
|
||||||
{
|
|
||||||
if ($group_attribute = new AttributeGroup((int)$pos[2]))
|
|
||||||
if (isset($position) && $group_attribute->updatePosition($way, $position))
|
|
||||||
echo "ok position ".(int)$position." for group attribute ".(int)$pos[2]."\r\n";
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "Can not update group attribute '. (int)$id_attribute_group . ' to position '.(int)$position.' "}';
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "This group attribute ('.(int)$id_attribute_group.') can t be loaded"}';
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modify feature position */
|
|
||||||
if (Tools::isSubmit('ajaxFeaturesPositions'))
|
|
||||||
{
|
|
||||||
$way = (int)Tools::getValue('way');
|
|
||||||
$id_feature = (int)Tools::getValue('id_feature');
|
|
||||||
$positions = Tools::getValue('feature');
|
|
||||||
|
|
||||||
$new_positions = array();
|
|
||||||
foreach($positions as $k => $v)
|
|
||||||
if (!empty($v))
|
|
||||||
$new_positions[] = $v;
|
|
||||||
|
|
||||||
foreach ($new_positions as $position => $value)
|
|
||||||
{
|
|
||||||
// pos[2] = id_feature, pos[3] = old position
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
|
|
||||||
if (isset($pos[2]) && (int)$pos[2] === $id_feature)
|
|
||||||
{
|
|
||||||
if ($feature = new Feature((int)$pos[2]))
|
|
||||||
if (isset($position) && $feature->updatePosition($way, $position))
|
|
||||||
echo "ok position ".(int)$position." for feature ".(int)$pos[1]."\r\n";
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "Can not update feature '. (int)$id_feature . ' to position '.(int)$position.' "}';
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "This feature ('.(int)$id_feature.') can t be loaded"}';
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modify carrier position */
|
|
||||||
if (Tools::isSubmit('ajaxCarriersPositions'))
|
|
||||||
{
|
|
||||||
$way = (int)(Tools::getValue('way'));
|
|
||||||
$id_carrier = (int)(Tools::getValue('id_carrier'));
|
|
||||||
$positions = Tools::getValue('carrier');
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($positions as $position => $value)
|
|
||||||
{
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
|
|
||||||
if (isset($pos[2]) && (int)$pos[2] === $id_carrier)
|
|
||||||
{
|
|
||||||
if ($carrier = new Carrier((int)$pos[2]))
|
|
||||||
if (isset($position) && $carrier->updatePosition($way, $position))
|
|
||||||
echo "ok position ".(int)$position." for carrier ".(int)$pos[1]."\r\n";
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "Can not update carrier '. (int)$id_carrier . ' to position '.(int)$position.' "}';
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "This carrier ('.(int)$id_carrier.') can t be loaded"}';
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Tools::isSubmit('searchCategory'))
|
if (Tools::isSubmit('searchCategory'))
|
||||||
{
|
{
|
||||||
$q = Tools::getValue('q');
|
$q = Tools::getValue('q');
|
||||||
@@ -912,37 +627,3 @@ if (Tools::isSubmit('getZones'))
|
|||||||
$array = array('hasError' => false, 'errors' => '', 'data' => $html);
|
$array = array('hasError' => false, 'errors' => '', 'data' => $html);
|
||||||
die(Tools::jsonEncode($html));
|
die(Tools::jsonEncode($html));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modify carrier position */
|
|
||||||
if (Tools::isSubmit('ajaxTabsPositions'))
|
|
||||||
{
|
|
||||||
$way = (int)(Tools::getValue('way'));
|
|
||||||
$id_tab = (int)(Tools::getValue('id_tab'));
|
|
||||||
$positions = Tools::getValue('tab');
|
|
||||||
|
|
||||||
// when changing positions in a tab sub-list, the first array value is empty and needs to be removed
|
|
||||||
if (!$positions[0])
|
|
||||||
{
|
|
||||||
unset($positions[0]);
|
|
||||||
// reset indexation from 0
|
|
||||||
$positions = array_merge($positions);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($positions as $position => $value)
|
|
||||||
{
|
|
||||||
$pos = explode('_', $value);
|
|
||||||
|
|
||||||
if (isset($pos[2]) && (int)$pos[2] === $id_tab)
|
|
||||||
{
|
|
||||||
if ($tab = new Tab((int)$pos[2]))
|
|
||||||
if (isset($position) && $tab->updatePosition($way, $position))
|
|
||||||
echo "ok position ".(int)$position." for tab ".(int)$pos[1]."\r\n";
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "Can not update tab '. (int)$id_tab . ' to position '.(int)$position.' "}';
|
|
||||||
else
|
|
||||||
echo '{"hasError" : true, "errors" : "This tab ('.(int)$id_tab.') can t be loaded"}';
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -65,6 +65,7 @@
|
|||||||
var token_admin_orders = '{getAdminToken tab='AdminOrders' slashes=1 }';
|
var token_admin_orders = '{getAdminToken tab='AdminOrders' slashes=1 }';
|
||||||
var token_admin_customers = '{getAdminToken tab='AdminCustomers' slashes=1 }';
|
var token_admin_customers = '{getAdminToken tab='AdminCustomers' slashes=1 }';
|
||||||
var token_admin_customer_threads = '{getAdminToken tab='AdminCustomerThreads' slashes=1 }';
|
var token_admin_customer_threads = '{getAdminToken tab='AdminCustomerThreads' slashes=1 }';
|
||||||
|
var currentIndex = '{$currentIndex}';
|
||||||
</script>
|
</script>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -263,12 +263,12 @@ class FeatureCore extends ObjectModel
|
|||||||
* @param integer $position
|
* @param integer $position
|
||||||
* @return boolean Update result
|
* @return boolean Update result
|
||||||
*/
|
*/
|
||||||
public function updatePosition($way, $position)
|
public function updatePosition($way, $position, $id_feature)
|
||||||
{
|
{
|
||||||
if (!$res = Db::getInstance()->executeS('
|
if (!$res = Db::getInstance()->executeS('
|
||||||
SELECT `position`, `id_feature`
|
SELECT `position`, `id_feature`
|
||||||
FROM `'._DB_PREFIX_.'feature`
|
FROM `'._DB_PREFIX_.'feature`
|
||||||
WHERE `id_feature` = '.(int)Tools::getValue('id_feature', 1).'
|
WHERE `id_feature` = '.(int)($id_feature ? $id_feature : 1).'
|
||||||
ORDER BY `position` ASC'
|
ORDER BY `position` ASC'
|
||||||
))
|
))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1289,6 +1289,7 @@ class AdminControllerCore extends Controller
|
|||||||
'multishop_context' => $this->multishop_context,
|
'multishop_context' => $this->multishop_context,
|
||||||
'pic_dir' => _THEME_PROD_PIC_DIR_,
|
'pic_dir' => _THEME_PROD_PIC_DIR_,
|
||||||
'controller_name' => htmlentities(Tools::getValue('controller')),
|
'controller_name' => htmlentities(Tools::getValue('controller')),
|
||||||
|
'currentIndex' => self::$currentIndex
|
||||||
));
|
));
|
||||||
|
|
||||||
// Shop context
|
// Shop context
|
||||||
|
|||||||
@@ -430,7 +430,6 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// toolbar (save, cancel, new, ..)
|
// toolbar (save, cancel, new, ..)
|
||||||
$this->initToolbar();
|
$this->initToolbar();
|
||||||
if ($this->display == 'edit' || $this->display == 'add')
|
if ($this->display == 'edit' || $this->display == 'add')
|
||||||
@@ -544,7 +543,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
|
|
||||||
protected function setTypeAttribute()
|
protected function setTypeAttribute()
|
||||||
{
|
{
|
||||||
if (Tools::getValue('id_attribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute') || Tools::isSubmit('submitBulkdeleteattribute'))
|
if (Tools::getValue('updateattribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute') || Tools::isSubmit('submitBulkdeleteattribute'))
|
||||||
{
|
{
|
||||||
$this->table = 'attribute';
|
$this->table = 'attribute';
|
||||||
$this->className = 'Attribute';
|
$this->className = 'Attribute';
|
||||||
@@ -577,11 +576,8 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// If it's an attribute, load object Attribute()
|
// If it's an attribute, load object Attribute()
|
||||||
if (Tools::getValue('id_attribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute'))
|
if (Tools::getValue('updateattribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute'))
|
||||||
{
|
{
|
||||||
/* Hook */
|
|
||||||
Hook::exec('actionObjectAttributeAddBefore');
|
|
||||||
|
|
||||||
// Override var of Controller
|
// Override var of Controller
|
||||||
$this->table = 'attribute';
|
$this->table = 'attribute';
|
||||||
$this->className = 'Attribute';
|
$this->className = 'Attribute';
|
||||||
@@ -609,6 +605,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
else if (Tools::isSubmit('submitAddattribute'))
|
else if (Tools::isSubmit('submitAddattribute'))
|
||||||
{
|
{
|
||||||
|
Hook::exec('actionObjectAttributeAddBefore');
|
||||||
$this->action = 'save';
|
$this->action = 'save';
|
||||||
$id_attribute = (int)Tools::getValue('id_attribute');
|
$id_attribute = (int)Tools::getValue('id_attribute');
|
||||||
// Adding last position to the attribute if not exist
|
// Adding last position to the attribute if not exist
|
||||||
@@ -627,9 +624,6 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Hook */
|
|
||||||
Hook::exec('actionObjectAttributeGroupAddBefore');
|
|
||||||
|
|
||||||
if (Tools::getValue('submitDel'.$this->table))
|
if (Tools::getValue('submitDel'.$this->table))
|
||||||
{
|
{
|
||||||
if ($this->tabAccess['delete'] === '1')
|
if ($this->tabAccess['delete'] === '1')
|
||||||
@@ -651,6 +645,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
else if (Tools::isSubmit('submitAdd'.$this->table))
|
else if (Tools::isSubmit('submitAdd'.$this->table))
|
||||||
{
|
{
|
||||||
|
Hook::exec('actionObjectAttributeGroupAddBefore');
|
||||||
$id_attribute_group = (int)Tools::getValue('id_attribute_group');
|
$id_attribute_group = (int)Tools::getValue('id_attribute_group');
|
||||||
// Adding last position to the attribute if not exist
|
// Adding last position to the attribute if not exist
|
||||||
if ($id_attribute_group <= 0)
|
if ($id_attribute_group <= 0)
|
||||||
@@ -727,4 +722,63 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Modify group attribute position */
|
||||||
|
public function ajaxProcessUpdateGroupsPositions()
|
||||||
|
{
|
||||||
|
$way = (int)Tools::getValue('way');
|
||||||
|
$id_attribute_group = (int)Tools::getValue('id_attribute_group');
|
||||||
|
$positions = Tools::getValue('attribute_group');
|
||||||
|
|
||||||
|
$new_positions = array();
|
||||||
|
foreach ($positions as $k => $v)
|
||||||
|
if (count(explode('_', $v)) == 4)
|
||||||
|
$new_positions[] = $v;
|
||||||
|
|
||||||
|
foreach ($new_positions as $position => $value)
|
||||||
|
{
|
||||||
|
$pos = explode('_', $value);
|
||||||
|
|
||||||
|
if (isset($pos[2]) && (int)$pos[2] === $id_attribute_group)
|
||||||
|
{
|
||||||
|
if ($group_attribute = new AttributeGroup((int)$pos[2]))
|
||||||
|
if (isset($position) && $group_attribute->updatePosition($way, $position))
|
||||||
|
echo 'ok position '.(int)$position.' for group attribute '.(int)$pos[2].'\r\n';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "Can not update group attribute '.(int)$id_attribute_group.' to position '.(int)$position.' "}';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "This group attribute ('.(int)$id_attribute_group.') can t be loaded"}';
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Modify attribute position */
|
||||||
|
public function ajaxProcessUpdateAttributesPositions()
|
||||||
|
{
|
||||||
|
$way = (int)Tools::getValue('way');
|
||||||
|
$id_attribute = (int)Tools::getValue('id_attribute');
|
||||||
|
$id_attribute_group = (int)Tools::getValue('id_attribute_group');
|
||||||
|
$positions = Tools::getValue('attribute');
|
||||||
|
|
||||||
|
if (is_array($positions))
|
||||||
|
foreach ($positions as $position => $value)
|
||||||
|
{
|
||||||
|
$pos = explode('_', $value);
|
||||||
|
|
||||||
|
if ((isset($pos[1]) && isset($pos[2])) && ($pos[1] == $id_attribute_group && (int)$pos[2] === $id_attribute))
|
||||||
|
{
|
||||||
|
if ($attribute = new Attribute((int)$pos[2]))
|
||||||
|
if (isset($position) && $attribute->updatePosition($way, $position))
|
||||||
|
echo 'ok position '.(int)$position.' for attribute '.(int)$pos[2].'\r\n';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "Can not update attribute '.(int)$id_attribute.' to position '.(int)$position.' "}';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "This attribute ('.(int)$id_attribute.') can t be loaded"}';
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -649,6 +649,32 @@ class AdminCarriersControllerCore extends AdminController
|
|||||||
if ($list['name'] == '0')
|
if ($list['name'] == '0')
|
||||||
$this->_list[$key]['name'] = Configuration::get('PS_SHOP_NAME');
|
$this->_list[$key]['name'] = Configuration::get('PS_SHOP_NAME');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ajaxProcessUpdatePositions()
|
||||||
|
{
|
||||||
|
$way = (int)(Tools::getValue('way'));
|
||||||
|
$id_carrier = (int)(Tools::getValue('id'));
|
||||||
|
$positions = Tools::getValue($this->table);
|
||||||
|
|
||||||
|
foreach ($positions as $position => $value)
|
||||||
|
{
|
||||||
|
$pos = explode('_', $value);
|
||||||
|
|
||||||
|
if (isset($pos[2]) && (int)$pos[2] === $id_carrier)
|
||||||
|
{
|
||||||
|
if ($carrier = new Carrier((int)$pos[2]))
|
||||||
|
if (isset($position) && $carrier->updatePosition($way, $position))
|
||||||
|
echo 'ok position '.(int)$position.' for carrier '.(int)$pos[1].'\r\n';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "Can not update carrier '.(int)$id_carrier.' to position '.(int)$position.' "}';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "This carrier ('.(int)$id_carrier.') can t be loaded"}';
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -651,6 +651,37 @@ class AdminCategoriesControllerCore extends AdminController
|
|||||||
INSERT INTO '._DB_PREFIX_.$this->table.'_'.$type.' (`'.pSQL($this->identifier).'`, `id_'.$type.'`)
|
INSERT INTO '._DB_PREFIX_.$this->table.'_'.$type.' (`'.pSQL($this->identifier).'`, `id_'.$type.'`)
|
||||||
VALUES '.pSQL($insert));
|
VALUES '.pSQL($insert));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ajaxProcessUpdatePositions()
|
||||||
|
{
|
||||||
|
$id_category_to_move = (int)(Tools::getValue('id_category_to_move'));
|
||||||
|
$id_category_parent = (int)(Tools::getValue('id_category_parent'));
|
||||||
|
$way = (int)(Tools::getValue('way'));
|
||||||
|
$positions = Tools::getValue('category');
|
||||||
|
if (is_array($positions))
|
||||||
|
foreach ($positions as $key => $value)
|
||||||
|
{
|
||||||
|
$pos = explode('_', $value);
|
||||||
|
if ((isset($pos[1]) && isset($pos[2])) && ($pos[1] == $id_category_parent && $pos[2] == $id_category_to_move))
|
||||||
|
{
|
||||||
|
$position = $key + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$category = new Category($id_category_to_move);
|
||||||
|
if (Validate::isLoadedObject($category))
|
||||||
|
{
|
||||||
|
if (isset($position) && $category->updatePosition($way, $position))
|
||||||
|
{
|
||||||
|
Hook::exec('actionCategoryUpdate');
|
||||||
|
die(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
die('{"hasError" : true, errors : "Can not update categories position"}');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
die('{"hasError" : true, "errors" : "This category can not be loaded"}');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ class AdminCmsContentControllerCore extends AdminController
|
|||||||
|| (Tools::isSubmit('statuscms_category') && Tools::isSubmit('id_cms_category'))
|
|| (Tools::isSubmit('statuscms_category') && Tools::isSubmit('id_cms_category'))
|
||||||
|| (Tools::isSubmit('position') && Tools::isSubmit('id_cms_category_to_move')))
|
|| (Tools::isSubmit('position') && Tools::isSubmit('id_cms_category_to_move')))
|
||||||
$this->adminCMSCategories->postProcess();
|
$this->adminCMSCategories->postProcess();
|
||||||
|
|
||||||
|
parent::postProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMedia()
|
public function setMedia()
|
||||||
@@ -146,4 +148,60 @@ class AdminCmsContentControllerCore extends AdminController
|
|||||||
$this->addJqueryUi('ui.widget');
|
$this->addJqueryUi('ui.widget');
|
||||||
$this->addJqueryPlugin('tagify');
|
$this->addJqueryPlugin('tagify');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ajaxProcessUpdateCmsPositions()
|
||||||
|
{
|
||||||
|
$id_cms = (int)(Tools::getValue('id_cms'));
|
||||||
|
$id_category = (int)(Tools::getValue('id_cms_category'));
|
||||||
|
$way = (int)(Tools::getValue('way'));
|
||||||
|
$positions = Tools::getValue('cms');
|
||||||
|
if (is_array($positions))
|
||||||
|
foreach ($positions as $key => $value)
|
||||||
|
{
|
||||||
|
$pos = explode('_', $value);
|
||||||
|
if ((isset($pos[1]) && isset($pos[2])) && ($pos[1] == $id_category && $pos[2] == $id_cms))
|
||||||
|
{
|
||||||
|
$position = $key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$cms = new CMS($id_cms);
|
||||||
|
if (Validate::isLoadedObject($cms))
|
||||||
|
{
|
||||||
|
if (isset($position) && $cms->updatePosition($way, $position))
|
||||||
|
die(true);
|
||||||
|
else
|
||||||
|
die('{"hasError" : true, "errors" : "Can not update cms position"}');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
die('{"hasError" : true, "errors" : "This cms can not be loaded"}');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ajaxProcessUpdateCmsCategoriesPositions()
|
||||||
|
{
|
||||||
|
$id_cms_category_to_move = (int)(Tools::getValue('id_cms_category_to_move'));
|
||||||
|
$id_cms_category_parent = (int)(Tools::getValue('id_cms_category_parent'));
|
||||||
|
$way = (int)(Tools::getValue('way'));
|
||||||
|
$positions = Tools::getValue('cms_category');
|
||||||
|
if (is_array($positions))
|
||||||
|
foreach ($positions as $key => $value)
|
||||||
|
{
|
||||||
|
$pos = explode('_', $value);
|
||||||
|
if ((isset($pos[1]) && isset($pos[2])) && ($pos[1] == $id_cms_category_parent && $pos[2] == $id_cms_category_to_move))
|
||||||
|
{
|
||||||
|
$position = $key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$cms_category = new CMSCategory($id_cms_category_to_move);
|
||||||
|
if (Validate::isLoadedObject($cms_category))
|
||||||
|
{
|
||||||
|
if (isset($position) && $cms_category->updatePosition($way, $position))
|
||||||
|
die(true);
|
||||||
|
else
|
||||||
|
die('{"hasError" : true, "errors" : "Can not update cms categories position"}');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
die('{"hasError" : true, "errors" : "This cms category can not be loaded"}');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -471,4 +471,33 @@ class AdminFeaturesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ajaxProcessUpdatePositions()
|
||||||
|
{
|
||||||
|
$way = (int)Tools::getValue('way');
|
||||||
|
$id_feature = (int)Tools::getValue('id');
|
||||||
|
$positions = Tools::getValue('feature');
|
||||||
|
|
||||||
|
$new_positions = array();
|
||||||
|
foreach ($positions as $k => $v)
|
||||||
|
if (!empty($v))
|
||||||
|
$new_positions[] = $v;
|
||||||
|
|
||||||
|
foreach ($new_positions as $position => $value)
|
||||||
|
{
|
||||||
|
$pos = explode('_', $value);
|
||||||
|
|
||||||
|
if (isset($pos[2]) && (int)$pos[2] === $id_feature)
|
||||||
|
{
|
||||||
|
if ($feature = new Feature((int)$pos[2]))
|
||||||
|
if (isset($position) && $feature->updatePosition($way, $position, $id_feature))
|
||||||
|
echo 'ok position '.(int)$position.' for feature '.(int)$pos[1].'\r\n';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "Can not update feature '.(int)$id_feature.' to position '.(int)$position.' "}';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "This feature ('.(int)$id_feature.') can t be loaded"}';
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1100,5 +1100,4 @@ class AdminModulesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
$smarty->assign($tpl_vars);
|
$smarty->assign($tpl_vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -391,4 +391,21 @@ class AdminModulesPositionsControllerCore extends AdminController
|
|||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ajaxProcessUpdatePositions()
|
||||||
|
{
|
||||||
|
$id_module = (int)(Tools::getValue('id_module'));
|
||||||
|
$id_hook = (int)(Tools::getValue('id_hook'));
|
||||||
|
$way = (int)(Tools::getValue('way'));
|
||||||
|
$positions = Tools::getValue(strval($id_hook));
|
||||||
|
$position = (is_array($positions)) ? array_search($id_hook.'_'.$id_module, $positions) : null;
|
||||||
|
$module = Module::getInstanceById($id_module);
|
||||||
|
if (Validate::isLoadedObject($module))
|
||||||
|
if ($module->updatePosition($id_hook, $way, $position))
|
||||||
|
die(true);
|
||||||
|
else
|
||||||
|
die('{"hasError" : true, "errors" : "Can not update module position"}');
|
||||||
|
else
|
||||||
|
die('{"hasError" : true, "errors" : "This module can not be loaded"}');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4178,4 +4178,31 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
LIMIT '.(int)$limit);
|
LIMIT '.(int)$limit);
|
||||||
die(Tools::jsonEncode($result));
|
die(Tools::jsonEncode($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ajaxProcessUpdatePositions()
|
||||||
|
{
|
||||||
|
$way = (int)(Tools::getValue('way'));
|
||||||
|
$id_product = (int)(Tools::getValue('id_product'));
|
||||||
|
$id_category = (int)(Tools::getValue('id_category'));
|
||||||
|
$positions = Tools::getValue('product');
|
||||||
|
|
||||||
|
if (is_array($positions))
|
||||||
|
foreach ($positions as $position => $value)
|
||||||
|
{
|
||||||
|
$pos = explode('_', $value);
|
||||||
|
|
||||||
|
if ((isset($pos[1]) && isset($pos[2])) && ($pos[1] == $id_category && (int)$pos[2] === $id_product))
|
||||||
|
{
|
||||||
|
if ($product = new Product((int)$pos[2]))
|
||||||
|
if (isset($position) && $product->updatePosition($way, $position))
|
||||||
|
echo 'ok position '.(int)$position.' for product '.(int)$pos[2].'\r\n';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "Can not update product '.(int)$id_product.' to position '.(int)$position.' "}';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "This product ('.(int)$id_product.') can t be loaded"}';
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -281,4 +281,37 @@ class AdminTabsControllerCore extends AdminController
|
|||||||
return;
|
return;
|
||||||
@rename(_PS_IMG_DIR_.'t/'.$obj->id.'.gif', _PS_IMG_DIR_.'t/'.$obj->class_name.'.gif');
|
@rename(_PS_IMG_DIR_.'t/'.$obj->id.'.gif', _PS_IMG_DIR_.'t/'.$obj->class_name.'.gif');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ajaxProcessUpdatePositions()
|
||||||
|
{
|
||||||
|
$way = (int)(Tools::getValue('way'));
|
||||||
|
$id_tab = (int)(Tools::getValue('id'));
|
||||||
|
$positions = Tools::getValue('tab');
|
||||||
|
|
||||||
|
// when changing positions in a tab sub-list, the first array value is empty and needs to be removed
|
||||||
|
if (!$positions[0])
|
||||||
|
{
|
||||||
|
unset($positions[0]);
|
||||||
|
// reset indexation from 0
|
||||||
|
$positions = array_merge($positions);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($positions as $position => $value)
|
||||||
|
{
|
||||||
|
$pos = explode('_', $value);
|
||||||
|
|
||||||
|
if (isset($pos[2]) && (int)$pos[2] === $id_tab)
|
||||||
|
{
|
||||||
|
if ($tab = new Tab((int)$pos[2]))
|
||||||
|
if (isset($position) && $tab->updatePosition($way, $position))
|
||||||
|
echo 'ok position '.(int)$position.' for tab '.(int)$pos[1].'\r\n';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "Can not update tab '.(int)$id_tab.' to position '.(int)$position.' "}';
|
||||||
|
else
|
||||||
|
echo '{"hasError" : true, "errors" : "This tab ('.(int)$id_tab.') can t be loaded"}';
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+50
-99
@@ -49,30 +49,7 @@ function initTableDnD(table)
|
|||||||
var ids = row.id.split('_');
|
var ids = row.id.split('_');
|
||||||
var tableDrag = table;
|
var tableDrag = table;
|
||||||
var params = '';
|
var params = '';
|
||||||
if (table.id == 'cms_category')
|
|
||||||
params = {
|
|
||||||
ajaxCMSCategoriesPositions: true,
|
|
||||||
id_cms_category_parent: ids[1],
|
|
||||||
id_cms_category_to_move: ids[2],
|
|
||||||
way: way,
|
|
||||||
token: token
|
|
||||||
};
|
|
||||||
if (table.id == 'category')
|
|
||||||
params = {
|
|
||||||
ajaxCategoriesPositions: true,
|
|
||||||
id_category_parent: ids[1],
|
|
||||||
id_category_to_move: ids[2],
|
|
||||||
way: way,
|
|
||||||
token: token
|
|
||||||
};
|
|
||||||
if (table.id == 'cms')
|
|
||||||
params = {
|
|
||||||
ajaxCMSPositions: true,
|
|
||||||
id_cms_category: ids[1],
|
|
||||||
id_cms: ids[2],
|
|
||||||
way: way,
|
|
||||||
token: token
|
|
||||||
};
|
|
||||||
if (table.id == 'cms_block_0')
|
if (table.id == 'cms_block_0')
|
||||||
params = {
|
params = {
|
||||||
ajaxCMSBlockPositions: true,
|
ajaxCMSBlockPositions: true,
|
||||||
@@ -89,81 +66,73 @@ function initTableDnD(table)
|
|||||||
way: way,
|
way: way,
|
||||||
token: token
|
token: token
|
||||||
};
|
};
|
||||||
if (come_from == 'AdminModulesPositions')
|
|
||||||
|
if (table.id == 'category')
|
||||||
params = {
|
params = {
|
||||||
ajaxModulesPositions: true,
|
action: 'updatePositions',
|
||||||
|
id_category_parent: ids[1],
|
||||||
|
id_category_to_move: ids[2],
|
||||||
|
way: way
|
||||||
|
};
|
||||||
|
else if (table.id == 'cms_category')
|
||||||
|
params = {
|
||||||
|
action: 'updateCmsCategoriesPositions',
|
||||||
|
id_cms_category_parent: ids[1],
|
||||||
|
id_cms_category_to_move: ids[2],
|
||||||
|
way: way
|
||||||
|
};
|
||||||
|
else if (table.id == 'cms')
|
||||||
|
params = {
|
||||||
|
action: 'updateCmsPositions',
|
||||||
|
id_cms_category: ids[1],
|
||||||
|
id_cms: ids[2],
|
||||||
|
way: way
|
||||||
|
};
|
||||||
|
else if (come_from == 'AdminModulesPositions')
|
||||||
|
params = {
|
||||||
|
action: 'updatePositions',
|
||||||
id_hook: ids[0],
|
id_hook: ids[0],
|
||||||
id_module: ids[1],
|
id_module: ids[1],
|
||||||
way: way,
|
way: way
|
||||||
token: token
|
|
||||||
};
|
};
|
||||||
if (table.id == 'product') {
|
else if (table.id.indexOf('attribute') != -1 && table.id != 'attribute_group') {
|
||||||
params = {
|
params = {
|
||||||
ajaxProductsPositions: true,
|
action: 'updateAttributesPositions',
|
||||||
|
id_attribute_group: ids[1],
|
||||||
|
id_attribute: ids[2],
|
||||||
|
way: way
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (table.id == 'attribute_group') {
|
||||||
|
params = {
|
||||||
|
action: 'updateGroupsPositions',
|
||||||
|
id_attribute_group: ids[2],
|
||||||
|
way: way
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (table.id == 'product') {
|
||||||
|
params = {
|
||||||
|
action: 'updatePositions',
|
||||||
id_category: ids[1],
|
id_category: ids[1],
|
||||||
id_product: ids[2],
|
id_product: ids[2],
|
||||||
way: way,
|
way: way
|
||||||
token: token
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (table.id == 'imageTable') {
|
|
||||||
params = {
|
|
||||||
ajaxProductImagesPositions: true,
|
|
||||||
id_image: ids[1],
|
|
||||||
way: way,
|
|
||||||
token: token
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (table.id.indexOf('attribute') != -1 && table.id != 'attribute_group') {
|
|
||||||
params = {
|
|
||||||
ajaxAttributesPositions: true,
|
|
||||||
id_attribute_group: ids[2],
|
|
||||||
id_attribute: ids[3],
|
|
||||||
way: way,
|
|
||||||
token: token
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table.id == 'attribute_group') {
|
if (!params) {
|
||||||
params = {
|
params = {
|
||||||
ajaxGroupsAttributesPositions: true,
|
action : 'updatePositions',
|
||||||
id_attribute_group: ids[2],
|
id : ids[2],
|
||||||
way: way,
|
way: way
|
||||||
token: token
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table.id == 'feature') {
|
params['ajax'] = 1;
|
||||||
params = {
|
|
||||||
ajaxFeaturesPositions: true,
|
|
||||||
id_feature : ids[2],
|
|
||||||
way: way,
|
|
||||||
token: token
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (table.id == 'carrier') {
|
|
||||||
params = {
|
|
||||||
ajaxCarriersPositions: true,
|
|
||||||
id_carrier : ids[2],
|
|
||||||
way: way,
|
|
||||||
token: token
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (table.id == 'tab') {
|
|
||||||
params = {
|
|
||||||
ajaxTabsPositions: true,
|
|
||||||
id_tab : ids[2],
|
|
||||||
way: way,
|
|
||||||
token: token
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
async: false,
|
async: false,
|
||||||
url: 'ajax.php?' + $.tableDnD.serialize(),
|
url: currentIndex + '&token=' + token + '&' + $.tableDnD.serialize(),
|
||||||
data: params,
|
data: params,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (come_from == 'AdminModulesPositions')
|
if (come_from == 'AdminModulesPositions')
|
||||||
@@ -177,24 +146,6 @@ function initTableDnD(table)
|
|||||||
tableDrag.find('td.dragHandle:first a:even').hide();
|
tableDrag.find('td.dragHandle:first a:even').hide();
|
||||||
tableDrag.find('td.dragHandle:last a:odd').hide();
|
tableDrag.find('td.dragHandle:last a:odd').hide();
|
||||||
}
|
}
|
||||||
else if (table.id == 'imageTable')
|
|
||||||
{
|
|
||||||
var reg = /_[0-9]$/g;
|
|
||||||
var up_reg = new RegExp('imgPosition=[0-9]+&');
|
|
||||||
tableDrag.find('tbody tr').each(function(i) {
|
|
||||||
// Update link position
|
|
||||||
// Up links
|
|
||||||
$(this).find('td.dragHandle a:first').attr('href', $(this).find('td.dragHandle a:first').attr('href').replace(up_reg, 'imgPosition='+ i +'&'));//, 'imgPosition='+ (i - 1) +'&'));
|
|
||||||
// Down links
|
|
||||||
$(this).find('td.dragHandle a:last').attr('href', $(this).find('td.dragHandle a:last').attr('href').replace(up_reg, 'imgPosition='+ (i + 2) +'&'));
|
|
||||||
// Position image cell
|
|
||||||
$(this).find('td.positionImage').html(i + 1);
|
|
||||||
|
|
||||||
});
|
|
||||||
tableDrag.find('tr td.dragHandle a:hidden').show();
|
|
||||||
tableDrag.find('tr td.dragHandle:first a:first').hide();
|
|
||||||
tableDrag.find('tr td.dragHandle:last a:last').hide();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (table.id == 'product' || table.id.indexOf('attribute') != -1 || table.id == 'attribute_group' || table.id == 'feature')
|
if (table.id == 'product' || table.id.indexOf('attribute') != -1 || table.id == 'attribute_group' || table.id == 'feature')
|
||||||
|
|||||||
Reference in New Issue
Block a user