From 5e407db21e3e30a1a5fa94b9558314ffa21af407 Mon Sep 17 00:00:00 2001 From: djfm Date: Mon, 14 Oct 2013 09:30:45 +0000 Subject: [PATCH 01/11] [*] LO : Fixed a few bugs with currency formats in Back-Office orders --- admin-dev/themes/default/template/controllers/orders/form.tpl | 4 ++-- controllers/admin/AdminCartsController.php | 2 ++ js/tools.js | 2 +- themes/default/js/tools.js | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/orders/form.tpl b/admin-dev/themes/default/template/controllers/orders/form.tpl index 34a5d7cec..6e4597092 100755 --- a/admin-dev/themes/default/template/controllers/orders/form.tpl +++ b/admin-dev/themes/default/template/controllers/orders/form.tpl @@ -656,11 +656,11 @@ var id_product = Number(this.id_product); var id_product_attribute = Number(this.id_product_attribute); cart_quantity[Number(this.id_product)+'_'+Number(this.id_product_attribute)+'_'+Number(this.id_customization)] = this.cart_quantity; - cart_content += ''+this.name+'
'+this.attributes_small+''+this.reference+''; + cart_content += ''+this.name+'
'+this.attributes_small+''+this.reference+''; cart_content += (!this.id_customization ? '

' : ''); cart_content += (!this.id_customization ? '
' : ''); cart_content += (!this.id_customization ? '
' : ''); - cart_content += '' + formatCurrency(parseFloat(this.total.replace(',', '.')), currency_format, currency_sign, currency_blank) + ''; + cart_content += '' + formatCurrency(this.numeric_total, currency_format, currency_sign, currency_blank) + ''; if (this.id_customization && this.id_customization != 0) { diff --git a/controllers/admin/AdminCartsController.php b/controllers/admin/AdminCartsController.php index 309c37e40..517934d9a 100755 --- a/controllers/admin/AdminCartsController.php +++ b/controllers/admin/AdminCartsController.php @@ -551,6 +551,8 @@ class AdminCartsControllerCore extends AdminController if (count($summary['products'])) foreach ($summary['products'] as &$product) { + $product['numeric_price'] = $product['price']; + $product['numeric_total'] = $product['total']; $product['price'] = str_replace($currency->sign, '', Tools::displayPrice($product['price'], $currency)); $product['total'] = str_replace($currency->sign, '', Tools::displayPrice($product['total'], $currency)); $product['image_link'] = $this->context->link->getImageLink($product['link_rewrite'], $product['id_image'], 'small_default'); diff --git a/js/tools.js b/js/tools.js index 4da024b8c..276eaf27c 100644 --- a/js/tools.js +++ b/js/tools.js @@ -73,7 +73,7 @@ function formatCurrency(price, currencyFormat, currencySign, currencyBlank) if (currencyFormat == 4) return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign); if (currencyFormat == 5) - return (formatNumber(price, priceDisplayPrecision, ' ', '.') + blank + currencySign); + return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '\'', '.')); return price; } diff --git a/themes/default/js/tools.js b/themes/default/js/tools.js index 4215f7a88..7b670168c 100644 --- a/themes/default/js/tools.js +++ b/themes/default/js/tools.js @@ -95,7 +95,7 @@ function formatCurrency(price, currencyFormat, currencySign, currencyBlank) if (currencyFormat == 4) return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign); if (currencyFormat == 5) - return (formatNumber(price, priceDisplayPrecision, ' ', '.') + blank + currencySign); + return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '\'', '.')); return price; } From 5d8c0a0fc2c07028e7a786078cd829265a025174 Mon Sep 17 00:00:00 2001 From: Samy Rabih Date: Mon, 21 Oct 2013 14:08:30 +0200 Subject: [PATCH 02/11] duplicateFeatures doesn't protect feature values The features values are not protected using pSQL during the features duplication --- classes/Product.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/Product.php b/classes/Product.php index 5d7330cff..0d54b9752 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3590,6 +3590,7 @@ class ProductCore extends ObjectModel if ($result3) { $result3['id_feature_value'] = $new_id_feature_value; + $result3['value'] = pSQL($result3['value']); $return &= Db::getInstance()->insert('feature_value_lang', $result3); } } From ce8d01ad4c8a56a9fb0631881607bf85dc690eb0 Mon Sep 17 00:00:00 2001 From: Gaelle ITZKOVITZ Date: Tue, 22 Oct 2013 11:09:53 +0200 Subject: [PATCH 03/11] [-] MO : if customer is logged we do not recreate it --- modules/loyalty/LoyaltyModule.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/loyalty/LoyaltyModule.php b/modules/loyalty/LoyaltyModule.php index 5d8ef5c9a..c4511439c 100644 --- a/modules/loyalty/LoyaltyModule.php +++ b/modules/loyalty/LoyaltyModule.php @@ -87,7 +87,9 @@ class LoyaltyModule extends ObjectModel { $context = Context::getContext(); $context->cart = $cart; - $context->customer = new Customer($context->cart->id_customer); + // if customer is logged we do not recreate it + if(!$context->customer->isLogged(true)) + $context->customer = new Customer($context->cart->id_customer); $context->language = new Language($context->cart->id_lang); $context->shop = new Shop($context->cart->id_shop); $context->currency = new Currency($context->cart->id_currency, null, $context->shop->id); From e857fb59781eed1f5c431825bc5ec65abbb4793f Mon Sep 17 00:00:00 2001 From: PhpMadman Date: Tue, 22 Oct 2013 13:34:52 +0200 Subject: [PATCH 04/11] [*] FO: Removed missplaced on mobile theme --- themes/default/mobile/order-detail.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/default/mobile/order-detail.tpl b/themes/default/mobile/order-detail.tpl index feaf3fee9..c51274600 100644 --- a/themes/default/mobile/order-detail.tpl +++ b/themes/default/mobile/order-detail.tpl @@ -51,7 +51,7 @@ {if $invoice AND $invoiceAllowed}
  • - {l s='Download your invoice as a PDF file.'}
  • + {l s='Download your invoice as a PDF file.'} {/if} {if $order->recyclable} From 7cbaada8443edbb1089f32b16ca6d7c233239fc8 Mon Sep 17 00:00:00 2001 From: ldecoker Date: Tue, 22 Oct 2013 17:00:56 +0200 Subject: [PATCH 05/11] [BO][-] Notice messages when accessing the BO translation page When accessing the translation part with "core translation" , you got 2 errors: Notice: Use of undefined constant _PS_THEME_SELECTED_DIR_ - assumed '_PS_THEME_SELECTED_DIR_' in controllers\admin\AdminTranslationsController.php on line 1018 Notice: Use of undefined constant _PS_THEME_SELECTED_DIR_ - assumed '_PS_THEME_SELECTED_DIR_' in \controllers\admin\AdminTranslationsController.php on line 1026 It's because the variable $this->theme_selected is not set for that case. --- controllers/admin/AdminTranslationsController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 57ad71856..d5fe4b7db 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -1221,6 +1221,8 @@ class AdminTranslationsControllerCore extends AdminController // Set the path of selected theme if ($this->theme_selected) define('_PS_THEME_SELECTED_DIR_', _PS_ROOT_DIR_.'/themes/'.$this->theme_selected.'/'); + else + define('_PS_THEME_SELECTED_DIR_', ''); // Get type of translation if (($type = Tools::getValue('type')) && !is_array($type)) From e6e2db8400133b2c54dabb61ab01057b54dd7f51 Mon Sep 17 00:00:00 2001 From: ldecoker Date: Tue, 22 Oct 2013 18:55:32 +0200 Subject: [PATCH 06/11] [PDF] [-] {else if} instead of {elseif} --- pdf/invoice.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdf/invoice.tpl b/pdf/invoice.tpl index 1f48322ce..918cdb15d 100755 --- a/pdf/invoice.tpl +++ b/pdf/invoice.tpl @@ -147,7 +147,7 @@ {if (isset($order_detail.reduction_amount) && $order_detail.reduction_amount > 0)} -{displayPrice currency=$order->id_currency price=$order_detail.reduction_amount} - {else if (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)} + {elseif (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)} -{$order_detail.reduction_percent}% {else} -- From ce4170574c3b2b01c125f27dbda6ea466f4b68d2 Mon Sep 17 00:00:00 2001 From: ldecoker Date: Tue, 22 Oct 2013 18:57:12 +0200 Subject: [PATCH 07/11] [PDF] [-] {else if} instead of {elseif} (B2B invoice template) --- pdf/invoice-b2b.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pdf/invoice-b2b.tpl b/pdf/invoice-b2b.tpl index 0fc86cba0..6f7ba9462 100755 --- a/pdf/invoice-b2b.tpl +++ b/pdf/invoice-b2b.tpl @@ -151,7 +151,7 @@ {if (isset($order_detail.reduction_amount) && $order_detail.reduction_amount > 0)} -{displayPrice currency=$order->id_currency price=$order_detail.reduction_amount} - {else if (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)} + {elseif (isset($order_detail.reduction_percent) && $order_detail.reduction_percent > 0)} -{$order_detail.reduction_percent}% {else} -- @@ -289,4 +289,4 @@ {/if} - \ No newline at end of file + From 5d28d38a2250f497a78b4c6b7b855578aab4d7be Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 23 Oct 2013 01:18:09 +0200 Subject: [PATCH 08/11] [-] BO : Fix bug #PSCFV-7907 AdminImport, add custom field to features --- classes/FeatureValue.php | 24 ++++++++++++--------- controllers/admin/AdminImportController.php | 15 ++++++------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/classes/FeatureValue.php b/classes/FeatureValue.php index 25c0fb4fd..b43abfb58 100644 --- a/classes/FeatureValue.php +++ b/classes/FeatureValue.php @@ -128,32 +128,36 @@ class FeatureValueCore extends ObjectModel return $tab['value']; } - public static function addFeatureValueImport($id_feature, $value, $id_product = null, $id_lang = null) + public static function addFeatureValueImport($id_feature, $value, $id_product, $id_lang = null, $custom = false) { $id_feature_value = false; if (!is_null($id_product) && $id_product) { $id_feature_value = Db::getInstance()->getValue(' - SELECT `id_feature_value` - FROM '._DB_PREFIX_.'feature_product - WHERE `id_feature` = '.(int)$id_feature.' - AND `id_product` = '.(int)$id_product); + SELECT fp.`id_feature_value` + FROM '._DB_PREFIX_.'feature_product fp + INNER JOIN '._DB_PREFIX_.'feature_value fv USING (`id_feature_value`) + WHERE fp.`id_feature` = '.(int)$id_feature.' + AND fv.`custom` = '.(int)$custom.' + AND fp.`id_product` = '.(int)$id_product); - if ($id_feature_value && !is_null($id_lang) && $id_lang) + if ($custom && $id_feature_value && !is_null($id_lang) && $id_lang) Db::getInstance()->execute(' UPDATE '._DB_PREFIX_.'feature_value_lang SET `value` = \''.pSQL($value).'\' WHERE `id_feature_value` = '.(int)$id_feature_value.' + AND `value` != \''.pSQL($value).'\' AND `id_lang` = '.(int)$id_lang); } - - if (!$id_feature_value) + + if (!$custom) $id_feature_value = Db::getInstance()->getValue(' SELECT fv.`id_feature_value` FROM '._DB_PREFIX_.'feature_value fv - LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value`) + LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.`id_feature_value` = fv.`id_feature_value` AND fvl.`id_lang` = '.(int)$id_lang.') WHERE `value` = \''.pSQL($value).'\' AND fv.`id_feature` = '.(int)$id_feature.' + AND fv.`custom` = 0 GROUP BY fv.`id_feature_value`'); if ($id_feature_value) @@ -162,7 +166,7 @@ class FeatureValueCore extends ObjectModel // Feature doesn't exist, create it $feature_value = new FeatureValue(); $feature_value->id_feature = (int)$id_feature; - $feature_value->custom = 0; + $feature_value->custom = (bool)$custom; foreach (Language::getLanguages() as $language) $feature_value->value[$language['id_lang']] = $value; $feature_value->add(); diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index 8ae22ff07..e80ce48c0 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -247,7 +247,7 @@ class AdminImportControllerCore extends AdminController 'delete_existing_images' => array( 'label' => $this->l('Delete existing images (0 = No, 1 = Yes)') ), - 'features' => array('label' => $this->l('Feature(Name:Value:Position)')), + 'features' => array('label' => $this->l('Feature(Name:Value:Position:Customized)')), 'online_only' => array('label' => $this->l('Available online only (0 = No, 1 = Yes)')), 'condition' => array('label' => $this->l('Condition')), 'customizable' => array('label' => $this->l('Customizable (0 = No, 1 = Yes)')), @@ -472,9 +472,8 @@ class AdminImportControllerCore extends AdminController } - $this->separator = Tools::substr(strval(trim(Tools::getValue('separator', ','))), 0, 1); - $this->multiple_value_separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator', ';'))), 0, 1); - + $this->separator = ($separator = Tools::substr(strval(trim(Tools::getValue('separator'))), 0, 1)) ? $separator : ';'; + $this->multiple_value_separator = ($separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator'))), 0, 1)) ? $separator : ','; parent::__construct(); } @@ -569,8 +568,8 @@ class AdminImportControllerCore extends AdminController $this->context->cookie->entity_selected = (int)Tools::getValue('entity'); $this->context->cookie->iso_lang_selected = base64_encode(Tools::getValue('iso_lang')); - $this->context->cookie->separator_selected = base64_encode(Tools::getValue('separator')); - $this->context->cookie->multiple_value_separator_selected = base64_encode(Tools::getValue('multiple_value_separator')); + $this->context->cookie->separator_selected = base64_encode($this->separator); + $this->context->cookie->multiple_value_separator_selected = base64_encode($this->multiple_value_separator); $this->context->cookie->csv_selected = base64_encode(Tools::getValue('csv')); $this->tpl_view_vars = array( @@ -1602,13 +1601,14 @@ class AdminImportControllerCore extends AdminController $feature_name = isset($tab_feature[0]) ? trim($tab_feature[0]) : ''; $feature_value = isset($tab_feature[1]) ? trim($tab_feature[1]) : ''; $position = isset($tab_feature[2]) ? (int)$tab_feature[2] : false; + $custom = isset($tab_feature[3]) ? (int)$tab_feature[3] : false; if(!empty($feature_name) && !empty($feature_value)) { $id_feature = (int)Feature::addFeatureImport($feature_name, $position); $id_product = null; if (Tools::getValue('forceIDs') || Tools::getValue('match_ref')) $id_product = (int)$product->id; - $id_feature_value = (int)FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang); + $id_feature_value = (int)FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang, $custom); Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value); } } @@ -1626,7 +1626,6 @@ class AdminImportControllerCore extends AdminController StockAvailable::setQuantity((int)$product->id, 0, $product->quantity, $this->context->shop->id); } - $this->closeCsvFile($handle); } From feca06417f58cbc5f431662b56495ee19beb95da Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 23 Oct 2013 01:23:35 +0200 Subject: [PATCH 09/11] // definition on addFeatureValueImport --- classes/FeatureValue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/FeatureValue.php b/classes/FeatureValue.php index b43abfb58..4580966c3 100644 --- a/classes/FeatureValue.php +++ b/classes/FeatureValue.php @@ -128,7 +128,7 @@ class FeatureValueCore extends ObjectModel return $tab['value']; } - public static function addFeatureValueImport($id_feature, $value, $id_product, $id_lang = null, $custom = false) + public static function addFeatureValueImport($id_feature, $value, $id_product = null, $id_lang = null, $custom = false) { $id_feature_value = false; if (!is_null($id_product) && $id_product) From ae63336a378a2831614a4b9008f02980fbb075f2 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Wed, 23 Oct 2013 01:41:05 +0200 Subject: [PATCH 10/11] [-] BO : Fix bug #PSCFV-10638, Admin Import by reference moves products to home category --- controllers/admin/AdminImportController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/admin/AdminImportController.php b/controllers/admin/AdminImportController.php index e80ce48c0..c8ea39bb2 100644 --- a/controllers/admin/AdminImportController.php +++ b/controllers/admin/AdminImportController.php @@ -1137,7 +1137,7 @@ class AdminImportControllerCore extends AdminController else $product = new Product(); - if (array_key_exists('id', $info) && (int)$info['id'] && Product::existsInDatabase((int)$info['id'], 'product')) + if (isset($product->id) && $product->id && Product::existsInDatabase((int)$product->id, 'product')) { $product->loadStockData(); $category_data = Product::getProductCategories((int)$product->id); From 6cddb57ce3b8ab3e3a83a64f734a636e7f48fd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Wed, 23 Oct 2013 10:34:00 +0200 Subject: [PATCH 11/11] [-] BO: Synchronize stock available after receipt supply order items #PSCFV-10724 --- controllers/admin/AdminSupplyOrdersController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/admin/AdminSupplyOrdersController.php b/controllers/admin/AdminSupplyOrdersController.php index 5d581be0f..659d8fc07 100644 --- a/controllers/admin/AdminSupplyOrdersController.php +++ b/controllers/admin/AdminSupplyOrdersController.php @@ -1387,7 +1387,9 @@ class AdminSupplyOrdersControllerCore extends AdminController true, $supply_order->id); - if (!$res) + if ($res) + StockAvailable::synchronize($supply_order_detail->id_product); + else $this->errors[] = Tools::displayError($this->l('Something went wrong when adding products to the warehouse.')); $location = Warehouse::getProductLocation($supply_order_detail->id_product,