diff --git a/MailReport/form.json b/MailReport/form.json index 765e3b3..faa2919 100644 --- a/MailReport/form.json +++ b/MailReport/form.json @@ -7,10 +7,25 @@ "moduleID": "{375EAF21-35EF-4BC4-83B3-C780FD8BD88A}" }, { - "type": "Select", + "type": "SelectVariable", + "requireLogging": 1, "name": "Variable", - "caption": "Aggregated Variable", - "options": [] + "caption": "Aggregated Variable" + }, + { + "type": "Select", + "caption": "Decimal Separator", + "name": "DecimalSeparator", + "options": [ + { + "caption": "Comma", + "value": "," + }, + { + "caption": "Dot", + "value": "." + } + ] }, { "type": "Select", diff --git a/MailReport/locale.json b/MailReport/locale.json index 9b5cca5..11d728e 100644 --- a/MailReport/locale.json +++ b/MailReport/locale.json @@ -25,7 +25,10 @@ "December": "Dezember", "Mail Report active": "Mail Report aktiv", "None": "Keine", - "https://www.symcon.de/en/service/documentation/module-reference/symconreport/mailreport/": "https://www.symcon.de/de/service/dokumentation/modulreferenz/symconreport/mailreport/" + "Decimal Separator": "Dezimaltrennzeichen", + "https://www.symcon.de/en/service/documentation/module-reference/symconreport/mailreport/": "https://www.symcon.de/de/service/dokumentation/modulreferenz/symconreport/mailreport/", + "Dot": "Punkt", + "Comma": "Komma" } } } \ No newline at end of file diff --git a/MailReport/module.php b/MailReport/module.php index 63f7f03..5bb18ea 100644 --- a/MailReport/module.php +++ b/MailReport/module.php @@ -15,6 +15,7 @@ public function Create() $this->RegisterPropertyInteger('SMTP', 0); $this->RegisterPropertyInteger('Variable', 0); $this->RegisterPropertyInteger('Interval', 1); + $this->RegisterPropertyString('DecimalSeparator', ','); $this->RegisterPropertyInteger('ArchiveControlID', IPS_GetInstanceListByModuleID(ARCHIVE_CONTROL_MODULE_ID)[0]); $this->RegisterVariableBoolean('Active', $this->Translate('Mail Report active'), '~Switch'); @@ -49,36 +50,6 @@ public function ApplyChanges() } } - public function GetConfigurationForm() - { - $form = json_decode(file_get_contents(__DIR__ . '/form.json')); - - $variableIndex = $this->GetElementIndexByName('Variable'); - - $variableOptions = [['label' => $this->Translate('None'), 'value' => 0]]; - foreach (AC_GetAggregationVariables($this->ReadPropertyInteger('ArchiveControlID'), false) as $variable) { - if ($variable['AggregationActive'] && IPS_ObjectExists($variable['VariableID'])) { - $variableOptions[] = ['label' => $this->CreateLabel($variable['VariableID']), 'value' => $variable['VariableID']]; - } - } - - $compare = function ($a, $b) - { - if ($a['label'] == $b['label']) { - return 0; - } elseif ($a['label'] == $this->Translate('None')) { - return -1; - } elseif ($b['label'] == $this->Translate('None')) { - return 1; - } else { - return strcmp($a['label'], $b['label']); - } - }; - usort($variableOptions, $compare); - $form->elements[$variableIndex]->options = $variableOptions; - return json_encode($form); - } - public function RequestAction($Ident, $Value) { switch ($Ident) { @@ -128,14 +99,16 @@ public function SendInfo() $this->GetAggregationEnd(), 0 ); + $decimalSeparator = $this->ReadPropertyString('DecimalSeparator'); + $csvSeparator = $decimalSeparator == ',' ? ';' : ','; for ($i = count($aggregatedValues) - 1; $i >= 0; $i--) { $value = $aggregatedValues[$i]; - $dataString = date('j.n.Y H:i:s', $value['TimeStamp']) . ',' . - number_format($value['Avg'], $digits, '.', '') . ',' . - date('j.n.Y H:i:s', $value['MinTime']) . ',' . - number_format($value['Min'], $digits, '.', '') . ',' . - date('j.n.Y H:i:s', $value['MaxTime']) . ',' . - number_format($value['Max'], $digits, '.', '') . "\n"; + $dataString = date('j.n.Y H:i:s', $value['TimeStamp']) . $csvSeparator . + number_format($value['Avg'], $digits, $decimalSeparator, '') . $csvSeparator . + date('j.n.Y H:i:s', $value['MinTime']) . $csvSeparator . + number_format($value['Min'], $digits, $decimalSeparator, '') . $csvSeparator . + date('j.n.Y H:i:s', $value['MaxTime']) . $csvSeparator . + number_format($value['Max'], $digits, $decimalSeparator, '') . "\n"; fwrite($file, $dataString); } diff --git a/PDFReportEnergy/form.json b/PDFReportEnergy/form.json index c26dbac..bc18565 100644 --- a/PDFReportEnergy/form.json +++ b/PDFReportEnergy/form.json @@ -19,6 +19,21 @@ "name": "EnergyType", "value": "Gas" }, + { + "type": "Select", + "caption": "Decimal Separator", + "name": "DecimalSeparator", + "options": [ + { + "caption": "Comma", + "value": "," + }, + { + "caption": "Dot", + "value": "." + } + ] + }, { "type": "SelectVariable", "caption": "Outside temperature variable (optional)", diff --git a/PDFReportEnergy/locale.json b/PDFReportEnergy/locale.json index ce36293..b7aadf2 100644 --- a/PDFReportEnergy/locale.json +++ b/PDFReportEnergy/locale.json @@ -45,7 +45,10 @@ "Last year you used up %s.": "Im Vorjahr hatten sie einen Verbrauch von %s.", "https://www.symcon.de/en/service/documentation/module-reference/symconreport/pdfreport-energy/": "https://www.symcon.de/de/service/dokumentation/modulreferenz/symconreport/pdfreport-energie/", "PDFReportEnergy": "PDFReportEnergie", - "Report (PDF, Energy)": "Report (PDF, Energie)" + "Report (PDF, Energy)": "Report (PDF, Energie)", + "Decimal Separator Comma": "Dezimaltrennzeichen", + "Dot": "Punkt", + "Comma": "Komma" } } } \ No newline at end of file diff --git a/PDFReportEnergy/module.php b/PDFReportEnergy/module.php index 3f94185..4588909 100644 --- a/PDFReportEnergy/module.php +++ b/PDFReportEnergy/module.php @@ -17,6 +17,7 @@ public function Create() $this->RegisterPropertyInteger('TemperatureID', 1); $this->RegisterPropertyInteger('PredictionID', 1); $this->RegisterPropertyInteger('CO2Type', -1); + $this->RegisterPropertyString('DecimalSeparator', ','); $this->RegisterMediaDocument('ReportPDF', $this->Translate('Report (PDF)'), 'pdf'); } @@ -324,6 +325,16 @@ private function FetchData() $consumption = GetValueFormattedEx($counterID, $consumption); } + //Format all values if with comma + if ($this->ReadPropertyString('DecimalSeparator') == ',') { + $consumption = str_replace('.', ',', $consumption); + $consumptionLastYear = str_replace('.', ',', $consumptionLastYear); + $avgTemp = str_replace('.', ',', $avgTemp); + $prediction = str_replace('.', ',', $prediction); + $percent = str_replace('.', ',', $percent); + $co2 = str_replace('.', ',', '' . $co2); + } + $data = [ 'month' => $month, 'consumption' => $consumption, diff --git a/PDFReportMulti/form.json b/PDFReportMulti/form.json index c7740f5..7d6fc71 100644 --- a/PDFReportMulti/form.json +++ b/PDFReportMulti/form.json @@ -54,6 +54,21 @@ } ] }, + { + "type": "Select", + "caption": "Decimal Separator", + "name": "DecimalSeparator", + "options": [ + { + "caption": "Comma", + "value": "," + }, + { + "caption": "Dot", + "value": "." + } + ] + }, { "name": "DataAggregation", "type": "Select", diff --git a/PDFReportMulti/locale.json b/PDFReportMulti/locale.json index 1b977ca..0127885 100644 --- a/PDFReportMulti/locale.json +++ b/PDFReportMulti/locale.json @@ -24,7 +24,10 @@ "Skip current unfinished dataset": "Überspringe den aktuellen unvollständigen Datensatz", "Generate report now!": "Jetzt Report generieren!", "Done! Please open the media file beneath this instance!": "Fertig! Bitte öffnen Sie die Mediendatei unterhalb der Instanz!", - "https://www.symcon.de/en/service/documentation/module-reference/symconreport/pdfreport-multi/": "https://www.symcon.de/de/service/dokumentation/modulreferenz/symconreport/pdfreport-multi/" + "Decimal Separator Comma": "Dezimaltrennzeichen Komma", + "https://www.symcon.de/en/service/documentation/module-reference/symconreport/pdfreport-multi/": "https://www.symcon.de/de/service/dokumentation/modulreferenz/symconreport/pdfreport-multi/", + "Dot": "Punkt", + "Comma": "Komma" } } } \ No newline at end of file diff --git a/PDFReportMulti/module.php b/PDFReportMulti/module.php index e80f364..9360a6d 100644 --- a/PDFReportMulti/module.php +++ b/PDFReportMulti/module.php @@ -20,6 +20,7 @@ public function Create() $this->RegisterPropertyInteger('DataAggregation', 1); $this->RegisterPropertyInteger('DataCount', 7); $this->RegisterPropertyBoolean('DataSkipFirst', true); + $this->RegisterPropertyString('DecimalSeparator', ','); $this->RegisterMediaDocument('ReportPDF', $this->Translate('Report (PDF)'), 'pdf'); } @@ -196,7 +197,8 @@ private function GenerateHTMLRows() foreach ($json as $data) { $rows .= '