From 0cadf187db26f483811b6980b8f444063cf2d82b Mon Sep 17 00:00:00 2001 From: Sunnyka <71286632+Sunnyka98@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:32:09 +0200 Subject: [PATCH 1/5] Add option of Decimal seperator --- CSVZipExport/form.json | 5 +++++ CSVZipExport/locale.json | 1 + CSVZipExport/module.php | 8 ++++++-- library.json | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CSVZipExport/form.json b/CSVZipExport/form.json index 6e3e780..5ae9712 100644 --- a/CSVZipExport/form.json +++ b/CSVZipExport/form.json @@ -25,6 +25,11 @@ "width": "700px", "requiredLogging": 1 }, + { + "type": "CheckBox", + "caption": "Decimal Separator Comma", + "name": "DecimalSeparator" + }, { "type": "SelectDateTime", "caption": "Aggregation Start", diff --git a/CSVZipExport/locale.json b/CSVZipExport/locale.json index 0f4577e..757e8ff 100644 --- a/CSVZipExport/locale.json +++ b/CSVZipExport/locale.json @@ -26,6 +26,7 @@ "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 Comma": "Dezimaltrennzeichen Komma", "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/" } diff --git a/CSVZipExport/module.php b/CSVZipExport/module.php index 9dee7e0..b973a13 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->RegisterPropertyBoolean('DecimalSeparator', true); //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->ReadPropertyBoolean('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 = $separator && is_numeric($loggedValues[$j]['Avg']) ? str_replace(".", ",", "".$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 = $separator && is_numeric($loggedValues[$j]['Value']) ? str_replace(".", ",", "".$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 From e9b8a7f897a2a02dde3b0d8834579d1b037f7247 Mon Sep 17 00:00:00 2001 From: Sunnyka <71286632+Sunnyka98@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:46:04 +0200 Subject: [PATCH 2/5] :cookie: Fix style --- CSVZipExport/module.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CSVZipExport/module.php b/CSVZipExport/module.php index b973a13..e81f82e 100644 --- a/CSVZipExport/module.php +++ b/CSVZipExport/module.php @@ -113,13 +113,13 @@ public function Export(int $ArchiveVariable, int $AggregationStage, string $Aggr if ($AggregationStage != 7) { $loggedValues = AC_GetAggregatedValues($archiveControlID, $ArchiveVariable, $AggregationStage, $startTimeStamp, $endTimeStamp, 0); for ($j = 0; $j < count($loggedValues); $j++) { - $value = $separator && is_numeric($loggedValues[$j]['Avg']) ? str_replace(".", ",", "".$loggedValues[$j]['Avg']) : $loggedValues[$j]['Avg']; + $value = $separator && is_numeric($loggedValues[$j]['Avg']) ? str_replace('.', ',', '' . $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++) { - $value = $separator && is_numeric($loggedValues[$j]['Value']) ? str_replace(".", ",", "".$loggedValues[$j]['Value']) : $loggedValues[$j]['Value']; + $value = $separator && is_numeric($loggedValues[$j]['Value']) ? str_replace('.', ',', '' . $loggedValues[$j]['Value']) : $loggedValues[$j]['Value']; $content .= date('d.m.Y H:i:s', $loggedValues[$j]['TimeStamp']) . ';' . $value . "\n"; } } From ba36a739a94ac74ed2b5fb1b16b39dbe8c2d04a9 Mon Sep 17 00:00:00 2001 From: Sunnyka <71286632+Sunnyka98@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:47:50 +0200 Subject: [PATCH 3/5] :cookie: fix style --- CSVZipExport/form.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSVZipExport/form.json b/CSVZipExport/form.json index 5ae9712..e67525e 100644 --- a/CSVZipExport/form.json +++ b/CSVZipExport/form.json @@ -29,7 +29,7 @@ "type": "CheckBox", "caption": "Decimal Separator Comma", "name": "DecimalSeparator" - }, + }, { "type": "SelectDateTime", "caption": "Aggregation Start", From c40c1600aea54c505b822a3f8b2c15152a610392 Mon Sep 17 00:00:00 2001 From: Sunnyka <71286632+Sunnyka98@users.noreply.github.com> Date: Fri, 16 Aug 2024 16:42:30 +0200 Subject: [PATCH 4/5] Checkbox to Select --- CSVZipExport/form.json | 16 +++++++++++++--- CSVZipExport/locale.json | 4 +++- CSVZipExport/module.php | 8 ++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CSVZipExport/form.json b/CSVZipExport/form.json index e67525e..bb9182a 100644 --- a/CSVZipExport/form.json +++ b/CSVZipExport/form.json @@ -26,9 +26,19 @@ "requiredLogging": 1 }, { - "type": "CheckBox", - "caption": "Decimal Separator Comma", - "name": "DecimalSeparator" + "type": "Select", + "caption": "Decimal Separator", + "name": "DecimalSeparator", + "options": [ + { + "caption": "Comma", + "value": "," + }, + { + "caption": "Dot", + "value": "." + } + ] }, { "type": "SelectDateTime", diff --git a/CSVZipExport/locale.json b/CSVZipExport/locale.json index 757e8ff..369d36d 100644 --- a/CSVZipExport/locale.json +++ b/CSVZipExport/locale.json @@ -28,7 +28,9 @@ "The selected SMTP-Instance doesn't exist": "Die ausgewählte SMTP-Instanz existiert nicht", "Decimal Separator Comma": "Dezimaltrennzeichen Komma", "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 e81f82e..290eebe 100644 --- a/CSVZipExport/module.php +++ b/CSVZipExport/module.php @@ -26,7 +26,7 @@ public function Create() $this->RegisterPropertyInteger('SMTPInstance', 0); $this->RegisterPropertyBoolean('IntervalStatus', false); $this->RegisterPropertyString('MailTime', '{"hour":12,"minute":0,"second":0}'); - $this->RegisterPropertyBoolean('DecimalSeparator', true); + $this->RegisterPropertyString('DecimalSeparator', ','); //Timer $this->RegisterTimer('DeleteZipTimer', 0, 'CSV_DeleteZip($_IPS[\'TARGET\']);'); @@ -107,19 +107,19 @@ 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->ReadPropertyBoolean('DecimalSeparator'); + $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++) { - $value = $separator && is_numeric($loggedValues[$j]['Avg']) ? str_replace('.', ',', '' . $loggedValues[$j]['Avg']) : $loggedValues[$j]['Avg']; + $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++) { - $value = $separator && is_numeric($loggedValues[$j]['Value']) ? str_replace('.', ',', '' . $loggedValues[$j]['Value']) : $loggedValues[$j]['Value']; + $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"; } } From dd34b8a7d279ab2f6d8fba78dd67d7a05ee572ee Mon Sep 17 00:00:00 2001 From: Sunnyka <71286632+Sunnyka98@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:25:55 +0200 Subject: [PATCH 5/5] fix translation --- CSVZipExport/locale.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CSVZipExport/locale.json b/CSVZipExport/locale.json index 369d36d..592ef8d 100644 --- a/CSVZipExport/locale.json +++ b/CSVZipExport/locale.json @@ -26,7 +26,7 @@ "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 Comma": "Dezimaltrennzeichen Komma", + "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/", "Dot": "Punkt",