Fixed error when creating a price selecting a expression without filling the numeric price
This commit is contained in:
parent
4ce8719d98
commit
004d88fe0b
@ -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<br>ExtraFields are variables like "#options_myextrafieldkey# * 2"<br>There are special variables like #quantity# and #tva_tx#
|
||||
PriceExpressionEditorHelp="price = 2 + 2" or "2 + 2" for setting the price<br>ExtraFields are variables like "#options_myextrafieldkey# * 2"<br>There are special variables like #quantity# and #tva_tx#<br>Use ; to separate expressions
|
||||
PriceMode=Price mode
|
||||
PriceNumeric=Number
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user