Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option 'Dezimal Separator' hinzugefügt #15

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}