mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 17:13:03 +01:00
Merge pull request #9468 from jmarsac/numericextrafields9464
Convert localized numeric extrafields value before inserting/updating
This commit is contained in:
@@ -4851,6 +4851,9 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
//dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG);
|
||||
//dol_syslog("attributeType=".$attributeType, LOG_DEBUG);
|
||||
|
||||
switch ($attributeType)
|
||||
{
|
||||
case 'int':
|
||||
@@ -4864,6 +4867,21 @@ abstract class CommonObject
|
||||
$new_array_options[$key] = null;
|
||||
}
|
||||
break;
|
||||
case 'double':
|
||||
$value = price2num($value);
|
||||
if (!is_numeric($value) && $value!='')
|
||||
{
|
||||
dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
|
||||
$this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
|
||||
return -1;
|
||||
}
|
||||
elseif ($value=='')
|
||||
{
|
||||
$new_array_options[$key] = null;
|
||||
}
|
||||
//dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG);
|
||||
$new_array_options[$key] = $value;
|
||||
break;
|
||||
/*case 'select': // Not required, we chosed value='0' for undefined values
|
||||
if ($value=='-1')
|
||||
{
|
||||
@@ -5058,6 +5076,9 @@ abstract class CommonObject
|
||||
$attributeParam = $extrafields->attributes[$this->table_element]['param'][$key];
|
||||
$attributeRequired = $extrafields->attributes[$this->table_element]['required'][$key];
|
||||
|
||||
//dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG);
|
||||
//dol_syslog("attributeType=".$attributeType, LOG_DEBUG);
|
||||
|
||||
switch ($attributeType)
|
||||
{
|
||||
case 'int':
|
||||
@@ -5071,6 +5092,21 @@ abstract class CommonObject
|
||||
$this->array_options["options_".$key] = null;
|
||||
}
|
||||
break;
|
||||
case 'double':
|
||||
$value = price2num($value);
|
||||
if (!is_numeric($value) && $value!='')
|
||||
{
|
||||
dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
|
||||
$this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
|
||||
return -1;
|
||||
}
|
||||
elseif ($value=='')
|
||||
{
|
||||
$this->array_options["options_".$key] = null;
|
||||
}
|
||||
//dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG);
|
||||
$this->array_options["options_".$key] = $value;
|
||||
break;
|
||||
/*case 'select': // Not required, we chosed value='0' for undefined values
|
||||
if ($value=='-1')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user