// Fix shop association in admin on attributes page
This commit is contained in:
@@ -54,11 +54,15 @@ $().ready(function() {
|
||||
|
||||
function check_group_shop_status(id_group) {
|
||||
var groupChecked = true;
|
||||
var total = 0;
|
||||
$('.input_shop[value='+id_group+']').each(function(k, v) {
|
||||
total++;
|
||||
if (!$(v).attr('checked'))
|
||||
groupChecked = false;
|
||||
});
|
||||
$('.input_group_shop[value='+id_group+']').attr('checked', groupChecked);
|
||||
|
||||
if (total > 0)
|
||||
$('.input_group_shop[value='+id_group+']').attr('checked', groupChecked);
|
||||
}
|
||||
|
||||
function check_all_shop() {
|
||||
@@ -93,7 +97,7 @@ function check_all_shop() {
|
||||
<label class="t">
|
||||
<input class="input_group_shop"
|
||||
type="checkbox"
|
||||
name="checkBoxGroupShopAsso_{$table}[{$form_id}|intval][{$groupID|intval}]"
|
||||
name="checkBoxGroupShopAsso_{$table}[{$form_id}][{$groupID}]"
|
||||
value="{$groupID}"
|
||||
{if $groupChecked} checked="checked"{/if} />
|
||||
{$groupData['name']}
|
||||
@@ -116,7 +120,7 @@ function check_all_shop() {
|
||||
<input class="input_shop"
|
||||
type="checkbox"
|
||||
value="{$groupID}"
|
||||
name="checkBoxShopAsso_{$table}[{$form_id|intval}][{$shopID|intval}]"
|
||||
name="checkBoxShopAsso_{$table}[{$form_id}][{$shopID}]"
|
||||
id="checkedBox_{$shopID}"
|
||||
{if $checked} checked="checked"{/if} />
|
||||
{$shopData['name']}
|
||||
|
||||
@@ -714,6 +714,7 @@ class AdminControllerCore extends Controller
|
||||
// Save and back to parent
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndBackToParent'))
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.$parent_id.'&conf=4&token='.$token;
|
||||
|
||||
// Default behavior (save and back)
|
||||
if (empty($this->redirect_after))
|
||||
$this->redirect_after = self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=4&token='.$token;
|
||||
@@ -2275,7 +2276,7 @@ class AdminControllerCore extends Controller
|
||||
* @param string $table
|
||||
* @param int $id_object
|
||||
*/
|
||||
protected static function getAssoShop($table, $id_object = false)
|
||||
protected function getAssoShop($table, $id_object = false)
|
||||
{
|
||||
$shop_asso = Shop::getAssoTables();
|
||||
$group_shop_asso = GroupShop::getAssoTables();
|
||||
|
||||
@@ -377,7 +377,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
if ($this->display == 'add')
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&conf=3&update'.$this->table.'&token='.$token;
|
||||
else
|
||||
$this->redirect_after = self::$currentIndex.'&id_attribute_group='.(int)Tools::getValue('id_attribute_group').'&'.$this->identifier.'&conf=3&update'.$this->table.'&token='.$token;
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.(int)Tools::getValue($this->identifier).'&conf=3&update'.$this->table.'&token='.$token;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
if ($this->display == 'add')
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&conf=3&update'.$this->table.'&token='.$token;
|
||||
else
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&id_attribute_group='.(int)Tools::getValue('id_attribute_group').'&conf=3&update'.$this->table.'&token='.$token;
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.(int)Tools::getValue($this->identifier).'&conf=4&update'.$this->table.'&token='.$token;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,6 +516,20 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
$this->toolbar_title = $bread;
|
||||
}
|
||||
|
||||
public function initProcess()
|
||||
{
|
||||
if (Tools::getValue('id_attribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute'))
|
||||
{
|
||||
$this->table = 'attribute';
|
||||
$this->className = 'Attribute';
|
||||
$this->identifier = 'id_attribute';
|
||||
}
|
||||
|
||||
parent::initProcess();
|
||||
if ($this->table == 'attribute')
|
||||
$this->display = 'editAttributes';
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the right method for creating or updating object
|
||||
*
|
||||
@@ -526,11 +540,8 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
{
|
||||
if ($this->display == 'add' || $this->display == 'edit')
|
||||
$this->identifier = 'id_attribute_group';
|
||||
else
|
||||
$this->identifier = 'id_attribute';
|
||||
|
||||
if ((int)Tools::getValue('id_attribute_group') >= 0 && ($this->display == 'add' || $this->display == 'editAttributes')
|
||||
|| (int)Tools::getValue('id_attribute_group') == 0 && $this->display != 'add')
|
||||
if (!$this->id_object)
|
||||
return $this->processAdd($token);
|
||||
else
|
||||
return $this->processUpdate($token);
|
||||
|
||||
@@ -372,7 +372,7 @@ class AdminEmployeesControllerCore extends AdminController
|
||||
return false;
|
||||
}
|
||||
|
||||
$assos = AdminEmployeesController::getAssoShop($this->table);
|
||||
$assos = $this->getAssoShop($this->table);
|
||||
|
||||
if (count($assos[0]) == 0 && $this->table = 'employee')
|
||||
if (Shop::isFeatureActive() && _PS_ADMIN_PROFILE_ != $_POST['id_profile'])
|
||||
|
||||
Reference in New Issue
Block a user