[-] BO: Fix PSFV-630 tax rules group on product
This commit is contained in:
1 parent
c684af0cb7
commit
846f592744
3 files changed
+48
-36
No files matched your search
+26
-18
@@ -837,6 +837,12 @@ class CarrierCore extends ObjectModel
|
|||||||
UPDATE `'._DB_PREFIX_.$this->def['table'].'`
|
UPDATE `'._DB_PREFIX_.$this->def['table'].'`
|
||||||
SET `id_reference` = '.(int)$id_reference.'
|
SET `id_reference` = '.(int)$id_reference.'
|
||||||
WHERE `id_carrier` = '.(int)$this->id);
|
WHERE `id_carrier` = '.(int)$this->id);
|
||||||
|
|
||||||
|
// Copy tax rules group
|
||||||
|
Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'carrier_tax_rules_group_shop` (`id_carrier`, `id_tax_rules_group`, `id_shop`)
|
||||||
|
(SELECT '.(int)$this->id.', `id_tax_rules_group`, `id_shop`
|
||||||
|
FROM `'._DB_PREFIX_.'carrier_tax_rules_group_shop`
|
||||||
|
WHERE `id_carrier`='.(int)$old_id.')');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -936,34 +942,36 @@ class CarrierCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function deleteTaxRulesGroup($all_shops = false)
|
public function deleteTaxRulesGroup($shops = false)
|
||||||
{
|
{
|
||||||
$shop = '';
|
if (!$shops)
|
||||||
if (!$all_shops)
|
$shops = Shop::getContextListShopID();
|
||||||
$shop = ' AND `id_shop`='.(int)Context::getContext()->shop->id;
|
|
||||||
|
$shop = ' AND `id_shop` IN (';
|
||||||
|
|
||||||
|
foreach ($shops as $id_shop)
|
||||||
|
$shop .= (int)$id_shop.',';
|
||||||
|
$shop = rtrim($shop, ',').')';
|
||||||
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_tax_rules_group_shop
|
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_tax_rules_group_shop
|
||||||
WHERE id_carrier='.(int)$this->id.$shop);
|
WHERE id_carrier='.(int)$this->id.$shop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTaxRulesGroup($id_tax_rules_group, $all_shops = false)
|
public function setTaxRulesGroup($id_tax_rules_group, $all_shops = false)
|
||||||
{
|
{
|
||||||
if (!Validate::isInt($id_tax_rules_group))
|
if (!Validate::isUnsignedId($id_tax_rules_group))
|
||||||
die(Tools::displayError());
|
die(Tools::displayError());
|
||||||
|
|
||||||
if (Shop::getContext() != Shop::CONTEXT_SHOP)
|
if (!$all_shops)
|
||||||
$all_shops = true;
|
$shops = Shop::getContextListShopID();
|
||||||
|
|
||||||
$this->deleteTaxRulesGroup($all_shops);
|
|
||||||
|
|
||||||
if ($all_shops)
|
|
||||||
{
|
|
||||||
$values = '';
|
|
||||||
$shops = Shop::getShops(false, null, true);
|
|
||||||
foreach ($shops as $id_shop)
|
|
||||||
$values .= '('.(int)$this->id.','.(int)$id_tax_rules_group.','.(int)$id_shop.'),';
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
$values = '('.(int)$this->id.','.(int)$id_tax_rules_group.','.(int)Context::getContext()->shop->id.')';
|
$shops = Shop::getShops(true, null, true);
|
||||||
|
|
||||||
|
$this->deleteTaxRulesGroup($shops);
|
||||||
|
|
||||||
|
$values = '';
|
||||||
|
foreach ($shops as $id_shop)
|
||||||
|
$values .= '('.(int)$this->id.','.(int)$id_tax_rules_group.','.(int)$id_shop.'),';
|
||||||
|
|
||||||
return Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'carrier_tax_rules_group_shop (`id_carrier`, `id_tax_rules_group`, `id_shop`) VALUES '.rtrim($values, ','));
|
return Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'carrier_tax_rules_group_shop (`id_carrier`, `id_tax_rules_group`, `id_shop`) VALUES '.rtrim($values, ','));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-17
@@ -4112,33 +4112,37 @@ class ProductCore extends ObjectModel
|
|||||||
FROM '._DB_PREFIX_.'product_tax_rules_group_shop WHERE `id_product`='.(int)$id_old_product.')');
|
FROM '._DB_PREFIX_.'product_tax_rules_group_shop WHERE `id_product`='.(int)$id_old_product.')');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteTaxRulesGroup($all_shops = false)
|
public function deleteTaxRulesGroup($shops = false)
|
||||||
{
|
{
|
||||||
$shop = '';
|
if (!$shops)
|
||||||
if (!$all_shops)
|
$shops = Shop::getContextListShopID();
|
||||||
$shop = ' AND `id_shop`='.(int)Context::getContext()->shop->id;
|
|
||||||
|
$shop = ' AND `id_shop` IN (';
|
||||||
|
|
||||||
|
foreach ($shops as $id_shop)
|
||||||
|
$shop .= (int)$id_shop.',';
|
||||||
|
$shop = rtrim($shop, ',').')';
|
||||||
|
|
||||||
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'product_tax_rules_group_shop
|
return Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'product_tax_rules_group_shop
|
||||||
WHERE id_product='.(int)$this->id.$shop);
|
WHERE id_product='.(int)$this->id.$shop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTaxRulesGroup($id_tax_rules_group, $all_shops = false)
|
public function setTaxRulesGroup($id_tax_rules_group, $all_shops = false)
|
||||||
{
|
{
|
||||||
if (!Validate::isInt($id_tax_rules_group))
|
if (!Validate::isUnsignedId($id_tax_rules_group))
|
||||||
die(Tools::displayError());
|
die(Tools::displayError());
|
||||||
$this->deleteTaxRulesGroup($all_shops);
|
|
||||||
|
|
||||||
if (Shop::getContext() != Shop::CONTEXT_SHOP)
|
if (!$all_shops)
|
||||||
$all_shops = true;
|
$shops = Shop::getContextListShopID();
|
||||||
|
|
||||||
if ($all_shops)
|
|
||||||
{
|
|
||||||
$values = '';
|
|
||||||
$shops = Shop::getShops(false, null, true);
|
|
||||||
foreach ($shops as $id_shop)
|
|
||||||
$values .= '('.(int)$this->id.','.(int)$id_tax_rules_group.','.(int)$id_shop.'),';
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
$values = '('.(int)$this->id.','.(int)$id_tax_rules_group.','.(int)Context::getContext()->shop->id.')';
|
$shops = Shop::getShops(true, null, true);
|
||||||
|
|
||||||
|
$this->deleteTaxRulesGroup($shops);
|
||||||
|
|
||||||
|
$values = '';
|
||||||
|
foreach ($shops as $id_shop)
|
||||||
|
$values .= '('.(int)$this->id.','.(int)$id_tax_rules_group.','.(int)$id_shop.'),';
|
||||||
|
|
||||||
return Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'product_tax_rules_group_shop (`id_product`, `id_tax_rules_group`, `id_shop`) VALUES '.rtrim($values, ','));
|
return Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'product_tax_rules_group_shop (`id_product`, `id_tax_rules_group`, `id_shop`) VALUES '.rtrim($values, ','));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ class AdminCarriersControllerCore extends AdminController
|
|||||||
|
|
||||||
$this->postImage($new_carrier->id);
|
$this->postImage($new_carrier->id);
|
||||||
$this->changeZones($new_carrier->id);
|
$this->changeZones($new_carrier->id);
|
||||||
$new_carrier->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group'), true);
|
$new_carrier->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group'));
|
||||||
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$current_carrier->id.'&conf=4&token='.$this->token);
|
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$current_carrier->id.'&conf=4&token='.$this->token);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in new issue
Block a user