diff --git a/admin-dev/init.php b/admin-dev/init.php index d575ab0a4..e94d227dc 100644 --- a/admin-dev/init.php +++ b/admin-dev/init.php @@ -95,4 +95,5 @@ else $context->cookie = $cookie; $context->link = $link; $context->language = $language; + $context->country = new Country(Configuration::get('PS_COUNTRY_DEFAULT')); } diff --git a/admin-dev/tabs/AdminProducts.php b/admin-dev/tabs/AdminProducts.php index 4288d3fa0..a591e31ff 100644 --- a/admin-dev/tabs/AdminProducts.php +++ b/admin-dev/tabs/AdminProducts.php @@ -36,7 +36,8 @@ class AdminProducts extends AdminTab public function __construct() { global $currentIndex; - + $context = Context::getContext(); + $this->table = 'product'; $this->className = 'Product'; $this->lang = true; @@ -63,7 +64,7 @@ class AdminProducts extends AdminTab LEFT JOIN '._DB_PREFIX_.'stock stock ON stock.id_product = a.id_product AND stock.id_product_attribute = 0 '.Shop::sqlSharedStock('stock').' LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = a.`id_product` AND i.`cover` = 1) LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product`) - LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)Country::getDefaultCountryId().' AND tr.`id_state` = 0) + LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)$context->country->id.' AND tr.`id_state` = 0) LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)'; $this->_filter = 'AND cp.`id_category` = '.(int)($this->_category->id); $this->_select = 'cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final, stock.quantity AS quantity'; @@ -1017,6 +1018,8 @@ class AdminProducts extends AdminTab throw new Exception(Tools::displayError('Image format not recognized, allowed formats are: .gif, .jpg, .png')); } + if (!$image->createImgFolder()) + throw new Exception(Tools::displayError('An error occurred during new folder creation')); if (!imageResize($subdir.$file, _PS_PROD_IMG_DIR_.$image->getImgPath().'.jpg')) { $image->delete(); @@ -1662,13 +1665,13 @@ class AdminProducts extends AdminTab protected function _displaySpecificPriceModificationForm($defaultCurrency, $shops, $currencies, $countries, $groups) { global $currentIndex; - + $context = Context::getContext(); if (!($obj = $this->loadObject())) return; $specificPrices = SpecificPrice::getByProductId((int)($obj->id)); $specificPricePriorities = SpecificPrice::getPriority((int)($obj->id)); - $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); - $taxRate = TaxRulesGroup::getTaxesRate($obj->id_tax_rules_group, Configuration::get('PS_COUNTRY_DEFAULT'), 0, 0); + + $taxRate = TaxRulesGroup::getTaxesRate($obj->id_tax_rules_group, $context->country->id, 0, 0); $tmp = array(); foreach ($shops as $shop) @@ -1699,11 +1702,11 @@ class AdminProducts extends AdminTab '.$this->l('Currency').' '.$this->l('Country').' '.$this->l('Group').' - '.$this->l('Price').' '.($default_country->display_tax_label ? $this->l('(tax excl.)') : '').' + '.$this->l('Price').' '.($context->country->display_tax_label ? $this->l('(tax excl.)') : '').' '.$this->l('Reduction').' '.$this->l('Period').' '.$this->l('From (quantity)').' - '.$this->l('Final price').' '.($default_country->display_tax_label ? $this->l('(tax excl.)') : '').' + '.$this->l('Final price').' '.($context->country->display_tax_label ? $this->l('(tax excl.)') : '').' '.$this->l('Action').' @@ -1818,8 +1821,7 @@ class AdminProducts extends AdminTab { if (!($product = $this->loadObject())) return; - $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); - $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); + $context = Context::getContext(); echo ' '.$this->l('Add a new specific price').' @@ -1869,7 +1871,7 @@ class AdminProducts extends AdminTab
@@ -2102,9 +2104,9 @@ class AdminProducts extends AdminTab { parent::displayForm(false); global $currentIndex, $cookie, $link; + $context = Context::getContext(); - $default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT')); - $iso = Language::getIsoById((int)($cookie->id_lang)); + $context->country->getIsoById((int)($cookie->id_lang)); $has_attribute = $obj->hasAttributes(); $qty = $obj->getStock(); $cover = Product::getCover($obj->id); @@ -2525,7 +2527,7 @@ class AdminProducts extends AdminTab '; $tax_rules_groups = TaxRulesGroup::getTaxRulesGroups(true); - $taxesRatesByGroup = TaxRulesGroup::getAssociatedTaxRatesByIdCountry(Country::getDefaultCountryId()); + $taxesRatesByGroup = TaxRulesGroup::getAssociatedTaxRatesByIdCountry($context->country->id); $ecotaxTaxRate = Tax::getProductEcotaxRate(); echo '