diff --git a/CSVZipExport/form.json b/CSVZipExport/form.json index 6e3e780..bb9182a 100644 --- a/CSVZipExport/form.json +++ b/CSVZipExport/form.json @@ -25,6 +25,21 @@ "width": "700px", "requiredLogging": 1 }, + { + "type": "Select", + "caption": "Decimal Separator", + "name": "DecimalSeparator", + "options": [ + { + "caption": "Comma", + "value": "," + }, + { + "caption": "Dot", + "value": "." + } + ] + }, { "type": "SelectDateTime", "caption": "Aggregation Start", diff --git a/CSVZipExport/locale.json b/CSVZipExport/locale.json index 0f4577e..592ef8d 100644 --- a/CSVZipExport/locale.json +++ b/CSVZipExport/locale.json @@ -26,8 +26,11 @@ "Summary of %s (%s to %s)": "Zusammenfassung von %s (%s bis %s)", "In the appendix you can find the created CSV-File.": "Im Anhang finden Sie die erstellte CSV-Datei.", "The selected SMTP-Instance doesn't exist": "Die ausgewählte SMTP-Instanz existiert nicht", + "Decimal Separator": "Dezimaltrennzeichen", "Variable is not selected": "Variable ist nicht ausgewählt", - "https://www.symcon.de/en/service/documentation/module-reference/csv-zip-export/": "https://www.symcon.de/de/service/dokumentation/modulreferenz/csv-zip-export/" + "https://www.symcon.de/en/service/documentation/module-reference/csv-zip-export/": "https://www.symcon.de/de/service/dokumentation/modulreferenz/csv-zip-export/", + "Dot": "Punkt", + "Comma": "Komma" } } } \ No newline at end of file diff --git a/CSVZipExport/module.php b/CSVZipExport/module.php index 9dee7e0..290eebe 100644 --- a/CSVZipExport/module.php +++ b/CSVZipExport/module.php @@ -26,6 +26,7 @@ public function Create() $this->RegisterPropertyInteger('SMTPInstance', 0); $this->RegisterPropertyBoolean('IntervalStatus', false); $this->RegisterPropertyString('MailTime', '{"hour":12,"minute":0,"second":0}'); + $this->RegisterPropertyString('DecimalSeparator', ','); //Timer $this->RegisterTimer('DeleteZipTimer', 0, 'CSV_DeleteZip($_IPS[\'TARGET\']);'); @@ -106,17 +107,20 @@ public function Export(int $ArchiveVariable, int $AggregationStage, string $Aggr //Generate zip with aggregated values $tempfile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $this->GenerateFileName($ArchiveVariable); $zip = new ZipArchive(); + $separator = $this->ReadPropertyString('DecimalSeparator'); if ($zip->open($tempfile, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) { $content = ''; if ($AggregationStage != 7) { $loggedValues = AC_GetAggregatedValues($archiveControlID, $ArchiveVariable, $AggregationStage, $startTimeStamp, $endTimeStamp, 0); for ($j = 0; $j < count($loggedValues); $j++) { - $content .= date('d.m.Y H:i:s', $loggedValues[$j]['TimeStamp']) . ';' . $loggedValues[$j]['Avg'] . "\n"; + $value = is_numeric($loggedValues[$j]['Avg']) ? str_replace('.', $separator, '' . $loggedValues[$j]['Avg']) : $loggedValues[$j]['Avg']; + $content .= date('d.m.Y H:i:s', $loggedValues[$j]['TimeStamp']) . ';' . $value . "\n"; } } else { $loggedValues = AC_GetLoggedValues($archiveControlID, $ArchiveVariable, $startTimeStamp, $endTimeStamp, 0); for ($j = 0; $j < count($loggedValues); $j++) { - $content .= date('d.m.Y H:i:s', $loggedValues[$j]['TimeStamp']) . ';' . $loggedValues[$j]['Value'] . "\n"; + $value = is_numeric($loggedValues[$j]['Value']) ? str_replace('.', $separator, '' . $loggedValues[$j]['Value']) : $loggedValues[$j]['Value']; + $content .= date('d.m.Y H:i:s', $loggedValues[$j]['TimeStamp']) . ';' . $value . "\n"; } } $zip->addFromString($this->GenerateFileName($ArchiveVariable, '.csv'), $content); diff --git a/library.json b/library.json index 350d8e1..51d5d34 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "5.0" }, - "version": "1.2", + "version": "1.3", "build": 0, "date": 0 } \ No newline at end of file