mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Add decimal separator to all pandora csv
This commit is contained in:
parent
f869fbb7cd
commit
aeb7a7e9c6
@ -1482,7 +1482,7 @@ $row++;
|
|||||||
'.' => '.',
|
'.' => '.',
|
||||||
',' => ',',
|
',' => ',',
|
||||||
];
|
];
|
||||||
$table_other->data[$row][0] = __('CSV decimal separator').ui_print_help_tip(__('Only for csv reports'), true);
|
$table_other->data[$row][0] = __('CSV decimal separator');
|
||||||
$table_other->data[$row][1] = html_print_select($decimal_separator, 'csv_decimal_separator', $config['csv_decimal_separator'], '', '', '', true, false, false);
|
$table_other->data[$row][1] = html_print_select($decimal_separator, 'csv_decimal_separator', $config['csv_decimal_separator'], '', '', '', true, false, false);
|
||||||
|
|
||||||
$row++;
|
$row++;
|
||||||
|
@ -409,6 +409,8 @@ class ModuleTemplates extends HTML
|
|||||||
case 'export':
|
case 'export':
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
enterprise_include_once('include/functions_reporting_csv.php');
|
||||||
|
|
||||||
$id_network_profile = safe_int($this->id_np);
|
$id_network_profile = safe_int($this->id_np);
|
||||||
if (empty($id_network_profile)) {
|
if (empty($id_network_profile)) {
|
||||||
return false;
|
return false;
|
||||||
@ -500,7 +502,7 @@ class ModuleTemplates extends HTML
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then print the first line (row names)
|
// Then print the first line (row names)
|
||||||
echo '"'.implode('","', $row_names).'"';
|
echo '"'.implode('"'.$config['csv_divider'].'"', $row_names).'"';
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
// Then print the rest of the data. Encapsulate in quotes in case we have comma's in any of the descriptions
|
// Then print the rest of the data. Encapsulate in quotes in case we have comma's in any of the descriptions
|
||||||
@ -509,7 +511,19 @@ class ModuleTemplates extends HTML
|
|||||||
unset($row[$bad_key]);
|
unset($row[$bad_key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '"'.implode('","', $row).'"';
|
if ($config['csv_decimal_separator'] !== '.') {
|
||||||
|
foreach ($row as $name => $data) {
|
||||||
|
if (is_numeric($data)) {
|
||||||
|
// Get the number of decimals, if > 0, format dec comma.
|
||||||
|
$decimals = strlen(substr(strrchr($data, '.'), 1));
|
||||||
|
if ($decimals !== 0) {
|
||||||
|
$row[$name] = csv_format_numeric((float) $data, $decimals, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '"'.implode('"'.$config['csv_divider'].'"', $row).'"';
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -845,7 +859,7 @@ class ModuleTemplates extends HTML
|
|||||||
$row['id_np'],
|
$row['id_np'],
|
||||||
'',
|
'',
|
||||||
true,
|
true,
|
||||||
['title' => 'Export to CSV']
|
['title' => 'Export tdaso CSV']
|
||||||
);
|
);
|
||||||
$data[3] = '<a href="'.$this->baseUrl.'&action=delete&id_np='.$row['id_np'].'" onclick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
|
$data[3] = '<a href="'.$this->baseUrl.'&action=delete&id_np='.$row['id_np'].'" onclick="if (!confirm(\''.__('Are you sure?').'\')) return false;">'.html_print_image('images/cross.png', true, ['title' => __('Delete')]).'</a>';
|
||||||
$data[3] .= '<a href="'.$this->baseUrl.'&action=export&id_np='.$row['id_np'].'">'.html_print_image('images/csv.png', true, ['title' => __('Export to CSV')]).'</a>';
|
$data[3] .= '<a href="'.$this->baseUrl.'&action=export&id_np='.$row['id_np'].'">'.html_print_image('images/csv.png', true, ['title' => __('Export to CSV')]).'</a>';
|
||||||
|
@ -3904,17 +3904,23 @@ function series_type_graph_array($data, $show_elements_graph)
|
|||||||
$data_return['legend'][$key] .= __('Min:').remove_right_zeros(
|
$data_return['legend'][$key] .= __('Min:').remove_right_zeros(
|
||||||
number_format(
|
number_format(
|
||||||
$value['min'],
|
$value['min'],
|
||||||
$config['graph_precision']
|
$config['graph_precision'],
|
||||||
|
$config['csv_decimal_separator'],
|
||||||
|
$config['csv_decimal_separator'] == ',' ? '.' : ','
|
||||||
)
|
)
|
||||||
).' '.__('Max:').remove_right_zeros(
|
).' '.__('Max:').remove_right_zeros(
|
||||||
number_format(
|
number_format(
|
||||||
$value['max'],
|
$value['max'],
|
||||||
$config['graph_precision']
|
$config['graph_precision'],
|
||||||
|
$config['csv_decimal_separator'],
|
||||||
|
$config['csv_decimal_separator'] == ',' ? '.' : ','
|
||||||
)
|
)
|
||||||
).' '._('Avg:').remove_right_zeros(
|
).' '._('Avg:').remove_right_zeros(
|
||||||
number_format(
|
number_format(
|
||||||
$value['avg'],
|
$value['avg'],
|
||||||
$config['graph_precision']
|
$config['graph_precision'],
|
||||||
|
$config['csv_decimal_separator'],
|
||||||
|
$config['csv_decimal_separator'] == ',' ? '.' : ','
|
||||||
)
|
)
|
||||||
).' '.$str;
|
).' '.$str;
|
||||||
|
|
||||||
@ -3978,7 +3984,8 @@ function series_type_graph_array($data, $show_elements_graph)
|
|||||||
$data_return['legend'][$key] .= remove_right_zeros(
|
$data_return['legend'][$key] .= remove_right_zeros(
|
||||||
number_format(
|
number_format(
|
||||||
$value['avg'],
|
$value['avg'],
|
||||||
$config['graph_precision']
|
$config['graph_precision'],
|
||||||
|
$config['csv_decimal_separator']
|
||||||
)
|
)
|
||||||
).' '.$str;
|
).' '.$str;
|
||||||
}
|
}
|
||||||
@ -5911,4 +5918,5 @@ function send_test_email(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
// This file only uses data retrieved in a request.
|
// This file only uses data retrieved in a request.
|
||||||
require_once '../../include/config.php';
|
require_once '../../include/config.php';
|
||||||
require_once '../../include/functions.php';
|
require_once '../../include/functions.php';
|
||||||
|
enterprise_include_once('include/functions_reporting_csv.php');
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
@ -49,7 +50,10 @@ $filename = io_safe_output($filename);
|
|||||||
* );
|
* );
|
||||||
*/
|
*/
|
||||||
$output_csv = function ($data, $filename) {
|
$output_csv = function ($data, $filename) {
|
||||||
$separator = (string) get_parameter('separator', ';');
|
global $config;
|
||||||
|
|
||||||
|
$separator = (string) $config['csv_divider'];
|
||||||
|
|
||||||
$excel_encoding = (bool) get_parameter('excel_encoding', false);
|
$excel_encoding = (bool) get_parameter('excel_encoding', false);
|
||||||
|
|
||||||
// CSV Output
|
// CSV Output
|
||||||
@ -68,9 +72,15 @@ $output_csv = function ($data, $filename) {
|
|||||||
throw new Exception(__('An error occured exporting the data'));
|
throw new Exception(__('An error occured exporting the data'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get key for item value.
|
||||||
|
$value_key = array_search('value', $items['head']);
|
||||||
|
|
||||||
$head_line = implode($separator, $items['head']);
|
$head_line = implode($separator, $items['head']);
|
||||||
echo $head_line."\n";
|
echo $head_line."\n";
|
||||||
foreach ($items['data'] as $item) {
|
foreach ($items['data'] as $item) {
|
||||||
|
// Find value and replace csv decimal separator.
|
||||||
|
$item[$value_key] = csv_format_numeric($item[$value_key]);
|
||||||
|
|
||||||
$item = str_replace('--> '.__('Selected'), '', $item);
|
$item = str_replace('--> '.__('Selected'), '', $item);
|
||||||
$line = implode($separator, $item);
|
$line = implode($separator, $item);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user