Merge remote-tracking branch 'origin/ticket/r16492-bulkupdate'
This commit is contained in:
commit
ffe8c187e8
@ -285,22 +285,22 @@ class TaxCore extends ObjectModel
|
||||
$id_state = 0;
|
||||
$id_county = 0;
|
||||
$rate = 0;
|
||||
if (!empty($id_address))
|
||||
{
|
||||
if (!empty($id_address)) {
|
||||
$address_infos = Address::getCountryAndState($id_address);
|
||||
if ($address_infos['id_country'])
|
||||
{
|
||||
if ($address_infos['id_country']) {
|
||||
$id_country = (int)($address_infos['id_country']);
|
||||
$id_state = (int)$address_infos['id_state'];
|
||||
$id_county = (int)County::getIdCountyByZipCode($address_infos['id_state'], $address_infos['postcode']);
|
||||
}
|
||||
|
||||
if (!empty($address_infos['vat_number']) AND $address_infos['id_country'] != Configuration::get('VATNUMBER_COUNTRY') AND Configuration::get('VATNUMBER_MANAGEMENT'))
|
||||
if (!empty($address_infos['vat_number']) AND $address_infos['id_country'] != Configuration::get('VATNUMBER_COUNTRY') AND Configuration::get('VATNUMBER_MANAGEMENT')) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($rate = Tax::getProductTaxRateViaRules((int)$id_product, (int)$id_country, (int)$id_state, (int)$id_county))
|
||||
if ($rate = Tax::getProductTaxRateViaRules((int)$id_product, (int)$id_country, (int)$id_state, (int)$id_county)) {
|
||||
return $rate;
|
||||
}
|
||||
|
||||
return $rate;
|
||||
}
|
||||
|
@ -537,7 +537,10 @@ class AdminBulkUpdate extends AdminTab {
|
||||
}
|
||||
|
||||
$output .= '<p class="conf">'.$this->l('Products updated').'</p>';
|
||||
} elseif(Tools::isSubmit('submitUploadPrices')) {
|
||||
}
|
||||
// MAJ Rapide produits (Reduction, Prix d'achat HT, Prix d'achat TTC)
|
||||
elseif(Tools::isSubmit('submitUploadPrices'))
|
||||
{
|
||||
$f = fopen($_FILES['csvfile']['tmp_name'], 'r');
|
||||
fgetcsv($f, 0, ';');
|
||||
|
||||
@ -552,8 +555,9 @@ class AdminBulkUpdate extends AdminTab {
|
||||
|
||||
$products[] = (int) $line[0];
|
||||
}
|
||||
} elseif(Tools::getValue('price_process') == 3
|
||||
|| Tools::getValue('price_process') == 4){
|
||||
}
|
||||
// Prix d'achat HT || Prix public TTC
|
||||
elseif (Tools::getValue('price_process') == 3 || Tools::getValue('price_process') == 4) {
|
||||
while ($line = fgetcsv($f, 0, ';')) {
|
||||
if (empty($line[0])) {
|
||||
continue;
|
||||
@ -564,7 +568,9 @@ class AdminBulkUpdate extends AdminTab {
|
||||
$line[1]
|
||||
);
|
||||
}
|
||||
}else {
|
||||
}
|
||||
// Reduction
|
||||
else {
|
||||
while ($line = fgetcsv($f, 0, ';')) {
|
||||
if (empty($line[0])) {
|
||||
continue;
|
||||
@ -585,14 +591,15 @@ class AdminBulkUpdate extends AdminTab {
|
||||
|
||||
fclose($f);
|
||||
|
||||
if(Tools::getValue('price_process') == 1
|
||||
|| Tools::getValue('price_process') == 2) {
|
||||
// Reduction || ...
|
||||
if (Tools::getValue('price_process') == 1 || Tools::getValue('price_process') == 2) {
|
||||
Db::getInstance()->ExecuteS('
|
||||
DELETE FROM `'._DB_PREFIX_.'specific_price`
|
||||
WHERE `id_product` IN ('.implode(', ', $products).')
|
||||
');
|
||||
}
|
||||
|
||||
// Reduction
|
||||
if (Tools::getValue('price_process') == 1) {
|
||||
foreach ($prices as $price) {
|
||||
if ((int) $price[0] != 0) {
|
||||
@ -617,6 +624,8 @@ class AdminBulkUpdate extends AdminTab {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prix d'achat HT
|
||||
if (Tools::getValue('price_process') == 3) {
|
||||
foreach ($prices as $price) {
|
||||
if ((int) $price[0] != 0){
|
||||
@ -631,11 +640,21 @@ class AdminBulkUpdate extends AdminTab {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prix public TTC
|
||||
if (Tools::getValue('price_process') == 4) {
|
||||
foreach ($prices as $price) {
|
||||
if ((int) $price[0] != 0){
|
||||
$price[1] = str_replace(',', '.', $price[1]);
|
||||
$price_ht = floatval($price[1] / 1.20);
|
||||
// Find Tax for this id product
|
||||
// product.id_tax_rules_group => tax_rules_group => tax_rule => tax.rate
|
||||
$tax = new Tax();
|
||||
$taxValue = $tax->getProductTaxRate((int)$price[0]);
|
||||
if ($taxValue == 0) {
|
||||
$taxValue = 20;
|
||||
}
|
||||
|
||||
$price_ht = floatval($price[1] / (1 + $taxValue / 100) );
|
||||
Db::getInstance()->ExecuteS('
|
||||
UPDATE `'._DB_PREFIX_.'product`
|
||||
SET price = '. (float)$price_ht .'
|
||||
@ -647,7 +666,8 @@ class AdminBulkUpdate extends AdminTab {
|
||||
}
|
||||
|
||||
$output .= '<p class="conf">'.$this->l('Products updated').'</p>';
|
||||
} elseif(Tools::isSubmit('submitUploadProductDescriptions')) {
|
||||
}
|
||||
elseif (Tools::isSubmit('submitUploadProductDescriptions')) {
|
||||
$id_lang = Tools::getValue('description_process');
|
||||
$f = fopen($_FILES['csvfile']['tmp_name'], 'r');
|
||||
fgetcsv($f, 0, ';');
|
||||
@ -675,7 +695,8 @@ class AdminBulkUpdate extends AdminTab {
|
||||
|
||||
fclose($f);
|
||||
$output .= '<p class="conf">'.$this->l('Products updated').'</p>';
|
||||
} elseif(Tools::isSubmit('submitUploadCombinations')) {
|
||||
}
|
||||
elseif (Tools::isSubmit('submitUploadCombinations')) {
|
||||
$f = fopen($_FILES['csvfile']['tmp_name'], 'r');
|
||||
fgetcsv($f, 0, ';');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user