[-] Installer : Fixed #PSCFI-5182
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14636 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -27,21 +27,23 @@
|
||||
|
||||
function generate_tax_rules()
|
||||
{
|
||||
$ps_lang_default = Db::getInstance()->getValue('SELECT value FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="PS_LANG_DEFAULT"');
|
||||
$taxes = Db::getInstance('SELECT * from `'._DB_PREFIX_.'tax` WHERE active = 1');
|
||||
$res = true;
|
||||
$taxes = Db::getInstance()->executeS('SELECT * from `'._DB_PREFIX_.'tax` WHERE active = 1');
|
||||
|
||||
// if no tax found, nothing to do, return true
|
||||
if (!is_array($taxes))
|
||||
return true;
|
||||
|
||||
foreach ($taxes AS $tax)
|
||||
{
|
||||
$insert = '';
|
||||
$id_tax = $tax['id_tax'];
|
||||
$row = array(
|
||||
'active' => 1,
|
||||
'id_tax' => $id_tax,
|
||||
'id_tax_rules_group' => $id_tax,
|
||||
'name' => 'Rule '.$tax['rate'].'%',
|
||||
);
|
||||
Db::getInstance()->insert('category_group', $row);
|
||||
$id_tax_rules_group = Db::getInstance()->insert_id;
|
||||
$res &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'tax_rules_group', $row, 'INSERT');
|
||||
$id_tax_rules_group = Db::getInstance()->insert_id();
|
||||
|
||||
|
||||
$countries = Db::getInstance()->executeS('
|
||||
@@ -54,64 +56,58 @@ function generate_tax_rules()
|
||||
{
|
||||
foreach ($countries AS $country)
|
||||
{
|
||||
$res = Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'tax_rule` (`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
|
||||
VALUES (
|
||||
'.(int)$id_tax_rules_group.',
|
||||
'.(int)$country['id_country'].',
|
||||
0,
|
||||
0,
|
||||
'.(int)$id_tax.
|
||||
')');
|
||||
|
||||
$res &= Db::getInstance()->execute('INSERT INTO `'._DB_PREFIX_.'tax_rule`
|
||||
(`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
|
||||
VALUES
|
||||
('.$id_tax_rules_group.', '.(int)$country['id_country'].', 0, 0, '.(int)$id_tax. ')');
|
||||
}
|
||||
}
|
||||
|
||||
$states = Db::getInstance()->executeS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'states s
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_state ts ON (ts.`id_state` = s.`id_state`)
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
WHERE `id_tax` = '.(int)$id_tax);
|
||||
|
||||
if ($states)
|
||||
{
|
||||
foreach ($states AS $state)
|
||||
{
|
||||
if (!in_array($state['tax_behavior'], array(PS_PRODUCT_TAX, PS_STATE_TAX, PS_BOTH_TAX)))
|
||||
$tax_behavior = PS_PRODUCT_TAX;
|
||||
else
|
||||
$tax_behavior = $state['tax_behavior'];
|
||||
|
||||
$res = Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'tax_rule` (`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
|
||||
VALUES (
|
||||
'.(int)$id_tax_rules_group.',
|
||||
'.(int)$state['id_country'].',
|
||||
'.(int)$state['id_state'].',
|
||||
'.(int)$tax_behavior.',
|
||||
'.(int)$id_tax.
|
||||
')');
|
||||
if (!in_array($state['tax_behavior'], array(PS_PRODUCT_TAX, PS_STATE_TAX, PS_BOTH_TAX)))
|
||||
$tax_behavior = PS_PRODUCT_TAX;
|
||||
else
|
||||
$tax_behavior = $state['tax_behavior'];
|
||||
$res &= Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'tax_rule`
|
||||
(`id_tax_rules_group`, `id_country`, `id_state`, `state_behavior`, `id_tax`)
|
||||
VALUES (
|
||||
'.$id_tax_rules_group.',
|
||||
'.(int)$state['id_country'].',
|
||||
'.(int)$state['id_state'].',
|
||||
'.(int)$tax_behavior.',
|
||||
'.(int)$id_tax.
|
||||
')');
|
||||
}
|
||||
}
|
||||
|
||||
Db::getInstance()->execute('
|
||||
$res &= Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'product`
|
||||
SET `id_tax_rules_group` = '.(int)$id_tax_rules_group.'
|
||||
SET `id_tax_rules_group` = '.$id_tax_rules_group.'
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
|
||||
Db::getInstance()->execute('
|
||||
$res &= Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'carrier`
|
||||
SET `id_tax_rules_group` = '.(int)$id_tax_rules_group.'
|
||||
SET `id_tax_rules_group` = '.$id_tax_rules_group.'
|
||||
WHERE `id_tax` = '.(int)$id_tax
|
||||
);
|
||||
|
||||
|
||||
$socolissimo_overcost_tax = Db::getInstance()->getValue('SELECT value FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="SOCOLISSIMO_OVERCOST_TAX"');
|
||||
$socolissimo_overcost_tax = Db::getInstance()->getValue('SELECT value
|
||||
FROM `'._DB_PREFIX_.'configuration`
|
||||
WHERE name="SOCOLISSIMO_OVERCOST_TAX"');
|
||||
if ($socolissimo_overcost_tax == $id_tax)
|
||||
$res &= Db::getInstance()->getValue('REPLACE INTO `'._DB_PREFIX_.'configuration`
|
||||
(name, value) VALUES ("PS_POUET", "'.$id_tax_rules_group.'"');
|
||||
$res &= Db::getInstance()->getValue('UPDATE `'._DB_PREFIX_.'configuration`
|
||||
set value="'.$id_tax_rules_group.'" WHERE name="SOCOLISSIMO_OVERCOST_TAX"');
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user