From 004d88fe0bae1adf909198e725e8fb415fbc25e2 Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Sun, 30 Nov 2014 02:15:16 +0100 Subject: [PATCH] Fixed error when creating a price selecting a expression without filling the numeric price --- htdocs/langs/en_US/products.lang | 2 +- htdocs/product/fournisseurs.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index f503ea8afe6..d3fa93e1702 100755 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -244,6 +244,6 @@ MinimumPriceLimit=Minimum price can't be lower that %s MinimumRecommendedPrice=Minimum recommended price is : %s PriceExpressionEditor=Price expression editor PriceExpressionSelected=Selected price expression -PriceExpressionEditorHelp="price = 2 + 2" or "2 + 2" for setting the price
ExtraFields are variables like "#options_myextrafieldkey# * 2"
There are special variables like #quantity# and #tva_tx# +PriceExpressionEditorHelp="price = 2 + 2" or "2 + 2" for setting the price
ExtraFields are variables like "#options_myextrafieldkey# * 2"
There are special variables like #quantity# and #tva_tx#
Use ; to separate expressions PriceMode=Price mode PriceNumeric=Number diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index bf5a268f22a..b0d07587996 100755 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -107,6 +107,7 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel")) $npr = preg_match('/\*/', $_POST['tva_tx']) ? 1 : 0 ; $tva_tx = str_replace('*','', GETPOST('tva_tx','alpha')); $tva_tx = price2num($tva_tx); + $price_expression = GETPOST('eid', 'int') == 0 ? 'NULL' : GETPOST('eid', 'int'); //Discard expression if not in expression mode if ($tva_tx == '') { @@ -130,8 +131,14 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel")) } if ($_POST["price"] < 0 || $_POST["price"] == '') { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")), 'errors'); + if ($price_expression == 'NULL') { //This is not because of using expression instead of numeric price + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")), 'errors'); + } + else + { + $_POST["price"] = 0; + } } $product = new ProductFournisseur($db); @@ -180,7 +187,6 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel")) } else { - $price_expression = GETPOST('eid', 'int') == 0 ? 'NULL' : GETPOST('eid', 'int'); //Discard expression if not in expression mode if ($price_expression != 'NULL') { //Check the expression validity by parsing it $priceparser = new PriceParser($db);