mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Understand user number preference when importing and exporting floats
This commit is contained in:
parent
addb422abe
commit
580d8c15a3
@ -391,9 +391,13 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
if (empty($dec_separator)) $dec_separator = '.';
|
||||
$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
|
||||
}
|
||||
if($record->name && (string)$record->$name != '')
|
||||
if($record->$name && (string)$record->$name != '')
|
||||
{
|
||||
$record->name = number_format(str_replace(' ','',$record->name), 2,
|
||||
if(!is_numeric($record->$name))
|
||||
{
|
||||
$record->$name = floatval(str_replace($dec_separator, '.', preg_replace('/[^\d'.preg_quote($dec_separator).']/', '', $record->$name)));
|
||||
}
|
||||
$record->$name = number_format(str_replace(' ','',$record->$name), 2,
|
||||
$dec_separator,$thousands_separator
|
||||
);
|
||||
}
|
||||
|
@ -465,6 +465,14 @@ class importexport_import_csv implements importexport_iface_import_record { //,
|
||||
$record[$name] = null;
|
||||
}
|
||||
}
|
||||
foreach((array)$fields['float'] as $name)
|
||||
{
|
||||
if($record[$name] != null && $record[$name] != '') {
|
||||
$dec_point = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
|
||||
if (empty($dec_point)) $dec_point = '.';
|
||||
$record[$name] = floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $record[$name])));
|
||||
}
|
||||
}
|
||||
|
||||
// Some custom methods for conversion
|
||||
foreach((array)$methods as $name => $method) {
|
||||
|
Loading…
Reference in New Issue
Block a user