Fix more robust function

This commit is contained in:
Laurent Destailleur 2015-04-06 16:50:26 +02:00
parent b49705d5d0
commit 3d161deb17

View File

@ -3010,8 +3010,7 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
} }
/** /**
* Function that return a number with universal decimal format (decimal separator is '.') from * Function that return a number with universal decimal format (decimal separator is '.') from an amount typed by a user.
* an amount typed by a user.
* Function to use on each input amount before any numeric test or database insert * Function to use on each input amount before any numeric test or database insert
* *
* @param float $amount Amount to convert/clean * @param float $amount Amount to convert/clean
@ -4992,7 +4991,15 @@ function natural_search($fields, $value, $numeric=0)
} }
if ($newcrit != '') if ($newcrit != '')
{ {
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' '.$operator.' '.price2num($newcrit); $numnewcrit = price2num($newcrit);
if (is_numeric($numnewcrit))
{
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' '.$operator.' '.$numnewcrit;
}
else
{
$newres .= ($i2 > 0 ? ' OR ' : '') . '1 = 2'; // force false
}
$i2++; // a criteria was added to string $i2++; // a criteria was added to string
} }
} }