Skip to content

Commit

Permalink
Option 'Dezimal Separator' hinzugefügt (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunnyka98 authored Aug 26, 2024
1 parent 79a1edb commit 108ca9b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
15 changes: 15 additions & 0 deletions CSVZipExport/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion CSVZipExport/locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
8 changes: 6 additions & 2 deletions CSVZipExport/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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\']);');
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"compatibility": {
"version": "5.0"
},
"version": "1.2",
"version": "1.3",
"build": 0,
"date": 0
}

0 comments on commit 108ca9b

Please sign in to comment.