From cf756739fd36228bd4fcd22725db392f87e4b008 Mon Sep 17 00:00:00 2001 From: Wilkware Date: Wed, 8 Jan 2025 11:40:53 +0100 Subject: [PATCH] Update v4.3.20250107 --- AbfallNavi/README.md | 12 ++- AbfallNavi/form.json | 13 +++ AbfallNavi/locale.json | 4 + AbfallNavi/module.php | 23 +++++- Abfall_ICS/README.md | 17 +++- Abfall_ICS/form.json | 44 +++++++++- Abfall_ICS/locale.json | 10 ++- Abfall_ICS/module.php | 111 +++++++++++++++++++++----- Abfall_IO/README.md | 12 ++- Abfall_IO/form.json | 13 +++ Abfall_IO/locale.json | 4 + Abfall_IO/module.php | 38 ++++++--- Awido/README.md | 12 ++- Awido/form.json | 13 +++ Awido/locale.json | 4 + Awido/module.php | 22 ++++- MuellMax/README.md | 12 ++- MuellMax/form.json | 13 +++ MuellMax/locale.json | 4 + MuellMax/module.php | 23 +++++- MyMuell/README.md | 12 ++- MyMuell/form.json | 13 +++ MyMuell/locale.json | 4 + MyMuell/module.php | 26 ++++-- README.md | 3 +- WasteManagementConfigurator/README.md | 4 +- library.json | 6 +- libs/DebugHelper.php | 46 +++++++++++ libs/EventHelper.php | 19 +---- libs/ServiceHelper.php | 41 +++++++++- libs/VisualisationHelper.php | 24 +++--- 31 files changed, 500 insertions(+), 102 deletions(-) diff --git a/AbfallNavi/README.md b/AbfallNavi/README.md index 0b9f112..55d8e24 100644 --- a/AbfallNavi/README.md +++ b/AbfallNavi/README.md @@ -2,7 +2,7 @@ [![Version](https://img.shields.io/badge/Symcon-PHP--Modul-red.svg?style=flat-square)](https://www.symcon.de/service/dokumentation/entwicklerbereich/sdk-tools/sdk-php/) [![Product](https://img.shields.io/badge/Symcon%20Version-6.4-blue.svg?style=flat-square)](https://www.symcon.de/produkt/) -[![Version](https://img.shields.io/badge/Modul%20Version-2.2.20240702-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) +[![Version](https://img.shields.io/badge/Modul%20Version-2.3.20250107-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) [![License](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-green.svg?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/) [![Actions](https://img.shields.io/github/actions/workflow/status/wilkware/WasteManagement/style.yml?branch=main&label=CheckStyle&style=flat-square)](https://github.com/Wilkware/WasteManagement/actions) @@ -15,7 +15,7 @@ IP-Symcon Modul für die Visualisierung von Entsorgungsterminen. 3. [Installation](#user-content-3-installation) 4. [Einrichten der Instanzen in IP-Symcon](#user-content-4-einrichten-der-instanzen-in-ip-symcon) 5. [Statusvariablen und Profile](#user-content-5-statusvariablen-und-profile) -6. [WebFront](#user-content-6-webfront) +6. [Visualisierung](#user-content-6-visualisierung) 7. [PHP-Befehlsreferenz](#user-content-7-php-befehlsreferenz) 8. [Versionshistorie](#user-content-8-versionshistorie) @@ -55,6 +55,7 @@ _Einstellungsbereich:_ Name | Beschreibung ----------------------- | ---------------------------------- Anbieter | 'AbfallNavi (regioit.de)' +Land | Landesauswahl (derzeit nur DE) > Abfallwirtschaft ... @@ -99,7 +100,7 @@ Entsorgungsart(en) | String | Abhängig vom Entsorgungsgebiet und den angebot Es werden keine zusätzlichen Profile benötigt. -### 6. WebFront +### 6. Visualisierung Man kann die Statusvariablen(Strings) direkt im WF verlinken. Aber wie bei der Konfiguration beschrieben, muss man aufpassen wenn die Konfiguration geändert wird. Dann müssen gegebenenfalls die Links neu eingerichtet werden. @@ -126,6 +127,11 @@ __Beispiel__: `REGIO_Update(12345);` ### 8. Versionshistorie +v2.3.20250107 + +* _NEU_: Internationalisierte Anbieterauswahl +* _FIX_: Dokumentation verbessert + v2.2.20240702 * _NEU_: Fallback wenn Service fehlschlägt (keine Subdomain) diff --git a/AbfallNavi/form.json b/AbfallNavi/form.json index 5dc1b77..770e51c 100644 --- a/AbfallNavi/form.json +++ b/AbfallNavi/form.json @@ -38,6 +38,19 @@ "value": "null" } ] + }, + { + "type": "Select", + "name": "serviceCountry", + "caption": "Country:", + "width": "450px", + "onChange": "IPS_RequestAction($id,'OnChangeCountry',$serviceCountry);", + "options": [ + { + "label": "Germany", + "value": "de" + } + ] } ] }, diff --git a/AbfallNavi/locale.json b/AbfallNavi/locale.json index 76cb4f7..e78cbb3 100644 --- a/AbfallNavi/locale.json +++ b/AbfallNavi/locale.json @@ -7,6 +7,10 @@ "This module uses the data provided by the Regio IT online service to display upcoming disposal dates.": "Dieses Modul nutzt die vom Online-Dienst Regio IT bereitgestellten Daten zur Darstellung der bevorstehenden Entsorgungstermine.", "Online service ...": "Online Dienst ...", "Provider:": "Anbieter:", + "Country:": "Land:", + "Germany": "Deutschland", + "Austria": "Österreich", + "Switzerland": "Schweiz", "Waste management ...": "Abfallwirtschaft ...", "Please select ...": "Bitte wählen ...", "Disposal area:": "Entsorgungsgebiet:", diff --git a/AbfallNavi/module.php b/AbfallNavi/module.php index 0a97e83..43452c8 100644 --- a/AbfallNavi/module.php +++ b/AbfallNavi/module.php @@ -67,6 +67,7 @@ public function Create() parent::Create(); // Service Provider $this->RegisterPropertyString('serviceProvider', self::SERVICE_PROVIDER); + $this->RegisterPropertyString('serviceCountry', 'de'); // Waste Management $this->RegisterPropertyString('clientID', 'null'); $this->RegisterPropertyString('placeID', 'null'); @@ -105,6 +106,8 @@ public function GetConfigurationForm() { // Settings $activate = $this->ReadPropertyBoolean('settingsActivate'); + // Service Values + $country = $this->ReadPropertyString('serviceCountry'); // IO Values $cId = $this->ReadPropertyString('clientID'); $pId = $this->ReadPropertyString('placeID'); @@ -112,14 +115,13 @@ public function GetConfigurationForm() $aId = $this->ReadPropertyString('addonID'); // Debug output $this->SendDebug(__FUNCTION__, 'clientID=' . $cId . ', placeId=' . $pId . ', streetId=' . $sId . ', addonId=' . $aId); - // Get Basic Form $jsonForm = json_decode(file_get_contents(__DIR__ . '/form.json'), true); // Service Provider $jsonForm['elements'][self::ELEM_PROVI]['items'][0]['options'] = $this->GetProviderOptions(); + $jsonForm['elements'][self::ELEM_PROVI]['items'][1]['options'] = $this->GetCountryOptions(self::SERVICE_PROVIDER); // Waste Management - $jsonForm['elements'][self::ELEM_REGIO]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER); - + $jsonForm['elements'][self::ELEM_REGIO]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER, $country); // Prompt $prompt = ['caption' => $this->Translate('Please select ...') . str_repeat(' ', 79), 'value' => 'null']; // go throw the whole way @@ -460,6 +462,21 @@ public function Update() } } + /** + * User has selected a new waste management country. + * + * @param string $id Country ID. + */ + protected function OnChangeCountry($id) + { + $this->SendDebug(__FUNCTION__, $id); + $options = $this->GetClientOptions(self::SERVICE_PROVIDER, $id); + $this->UpdateFormField('clientID', 'options', json_encode($options)); + $this->UpdateFormField('clientID', 'visible', true); + $this->UpdateFormField('clientID', 'value', 'null'); + $this->OnChangeClient('null'); + } + /** * User has selected a new waste management. * diff --git a/Abfall_ICS/README.md b/Abfall_ICS/README.md index 85bac3d..c274a66 100644 --- a/Abfall_ICS/README.md +++ b/Abfall_ICS/README.md @@ -2,7 +2,7 @@ [![Version](https://img.shields.io/badge/Symcon-PHP--Modul-red.svg?style=flat-square)](https://www.symcon.de/service/dokumentation/entwicklerbereich/sdk-tools/sdk-php/) [![Product](https://img.shields.io/badge/Symcon%20Version-6.4-blue.svg?style=flat-square)](https://www.symcon.de/produkt/) -[![Version](https://img.shields.io/badge/Modul%20Version-1.1.20240702-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) +[![Version](https://img.shields.io/badge/Modul%20Version-1.2.20250107-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) [![License](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-green.svg?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/) [![Actions](https://img.shields.io/github/actions/workflow/status/wilkware/WasteManagement/style.yml?branch=main&label=CheckStyle&style=flat-square)](https://github.com/Wilkware/WasteManagement/actions) @@ -15,7 +15,7 @@ IP-Symcon Modul für die Visualisierung von Entsorgungsterminen. 3. [Installation](#user-content-3-installation) 4. [Einrichten der Instanzen in IP-Symcon](#user-content-4-einrichten-der-instanzen-in-ip-symcon) 5. [Statusvariablen und Profile](#user-content-5-statusvariablen-und-profile) -6. [WebFront](#user-content-6-webfront) +6. [Visualisierung](#user-content-6-visualisierung) 7. [PHP-Befehlsreferenz](#user-content-7-php-befehlsreferenz) 8. [Versionshistorie](#user-content-8-versionshistorie) @@ -53,6 +53,7 @@ _Einstellungsbereich:_ Name | Beschreibung ----------------------- | ---------------------------------- Anbieter | 'Abfall.ICS (asmium.de)' +Land | Landesauswahl (derzeit DE, AT) > Abfallwirtschaft ... @@ -60,7 +61,9 @@ Name | Beschreibung -------------------------------- | --------------------------------- Entsorgungsgebiet (vordefiniert) | Liste der vordefinierten Abfallwirtschaften WEITER | Öffnet im neuen Browser-Fenster die selektierte Abfallwirtschafts-Seite -Download URL (iCal-File) | Link zuum Herunterladen der Kalender-Datei (ICS) +Daten importieren | Auswahl via File oder Link (URL) +Datei auswählen | Auswahl einer Kalender-Datei (ICS) aus dem File-System +Download URL (iCal-File) | Link zum Herunterladen der Kalender-Datei (ICS) ANALYSIEREN | Analysiert die in der Kalenderdatei enthaltenen Entsorgungsarten Entsorgungen | Entsorgungsarten, d.h. was wird im Gebiet an Entsorgung angeboten @@ -97,7 +100,7 @@ Entsorgungsart(en) | String | Abhängig vom Entsorgungsgebiet und den angebot Es werden keine zusätzlichen Profile benötigt. -### 6. WebFront +### 6. Visualisierung Man kann die Statusvariablen(Strings) direkt im WF verlinken. Aber wie bei der Konfiguration beschrieben, muss man aufpassen wenn die Konfiguration geändert wird. Dann müssen gegebenenfalls die Links neu eingerichtet werden. @@ -125,6 +128,12 @@ __Beispiel__: `WMICS_Update(12345);` ### 8. Versionshistorie +v1.2.20250107 + +* _NEU_: Internationalisierte Anbieterauswahl +* _NEU_: ICS Datei kann vom Filesystem geladen werden +* _FIX_: Dokumentation verbessert + v1.1.20240702 * _NEU_: Vorrausschauende Anzeige diff --git a/Abfall_ICS/form.json b/Abfall_ICS/form.json index a3917e5..3a5a994 100644 --- a/Abfall_ICS/form.json +++ b/Abfall_ICS/form.json @@ -38,6 +38,19 @@ "value": "null" } ] + }, + { + "type": "Select", + "name": "serviceCountry", + "caption": "Country:", + "width": "450px", + "onChange": "IPS_RequestAction($id,'OnChangeCountry',$serviceCountry);", + "options": [ + { + "label": "Germany", + "value": "de" + } + ] } ] }, @@ -74,12 +87,37 @@ { "type": "RowLayout", "items": [ + { + "type": "Select", + "name": "clientTYPE", + "caption": "Import Data:", + "width": "450px", + "onChange": "IPS_RequestAction($id,'OnChangeType', $clientTYPE);", + "options": [ + { + "caption": "From a URL", + "value": 0 + }, + { + "caption": "From a file", + "value": 1 + } + ] + }, { "type": "ValidationTextBox", "name": "clientURL", "caption": "Download URL (iCal-File):", "width": "900px", - "validate": "^(http(s?):\\\/\\\/)?(((www\\.)?[a-zA-Z0-9\\.\\-\\_]+(\\.[a-zA-Z]{2,3})+)(:[0-9]{1,5})?|(\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b))(:[0-9]{1,5})?(\\\/[a-zA-Z0-9\\_\\-\\s\\,\\.\\\/\\?\\%\\#\\&\\=]*)?$" + "visible": false, + "validate": "^(http(s?):\\/\\/)?(((www\\.)?[a-zA-Z0-9\\.\\-\\_]+(\\.[a-zA-Z]{2,3})+)(:[0-9]{1,5})?|(\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b))(:[0-9]{1,5})?(\\/[a-zA-Z0-9\\_\\-\\s\\,\\.\\/\\?\\%\\#\\&\\=]*)?$" + }, + { + "type": "SelectFile", + "name": "clientFILE", + "caption": "Choose File", + "extensions": ".ics", + "visible": false } ] }, @@ -89,7 +127,7 @@ { "type": "Button", "caption": "Analyse", - "onClick": "IPS_RequestAction($id,'OnChangeLink',$clientURL);" + "onClick": "IPS_RequestAction($id,'OnChangeImport',serialize(['c'=>$clientID, 't'=>$clientTYPE, 'l'=>$clientURL, 'f'=>$clientFILE]));" }, { "type": "Label", @@ -439,7 +477,7 @@ { "code": 201, "icon": "inactive", - "caption": "Please enter a correct URL and analyse the waste types!" + "caption": "Please enter a correct URL or FILE and analyse the waste types!" }, { "code": 202, diff --git a/Abfall_ICS/locale.json b/Abfall_ICS/locale.json index 1ddb06f..99b5c1c 100644 --- a/Abfall_ICS/locale.json +++ b/Abfall_ICS/locale.json @@ -7,9 +7,17 @@ "This module uses the data provided as an iCalendar file (ICS) to display the upcoming disposal dates.": "Dieses Modul nutzt die als iCalendar Datei (ICS) bereitgestellten Daten zur Darstellung der bevorstehenden Entsorgungstermine.", "Online service ...": "Online Dienst ...", "Provider:": "Anbieter:", + "Country:": "Land:", + "Germany": "Deutschland", + "Austria": "Österreich", + "Switzerland": "Schweiz", "Please select ...": "Bitte wählen ...", "Disposal area: (predefined)": "Entsorgungsgebiet: (vordefinierte)", "Waste management ...": "Abfallwirtschaft ...", + "Import Data:": "Daten importieren:", + "From a file": "Von einer Datei", + "From a URL": "Von einer URL", + "Choose File": "Datei auswählen", "Analyse": "Analysieren", "More": "Weiter", "The button is used to analyse the calendar file and display the available waste types.": "Mit Hilfe der Schaltfläche wird die Kalenderdatei analysiert und die zur Verfügung stehenden Abfallarten angezeigt.", @@ -58,7 +66,7 @@ "Creating instance.": "Die Instanz wird erstellt.", "Instance active.": "Instanz ist aktiv.", "Instance inactive.": "Instanz ist inaktiv.", - "Please enter a correct URL and analyse the waste types!": "Bitte geben sie eine korrekte URL ein und analysieren Sie die Abfallarten!", + "Please enter a correct URL or FILE and analyse the waste types!": "Bitte geben sie eine korrekte URL oder Datei ein und analysieren Sie die Abfallarten!", "Please select a offered disposals!": "Bitte die angebotenen Entsorgungen auswählen!", "Could not load json data!": "Konnte JSON Daten nicht laden!", "No entries in data available!": "Keine Einträge in Daten vorhanden!", diff --git a/Abfall_ICS/module.php b/Abfall_ICS/module.php index f863059..729b251 100644 --- a/Abfall_ICS/module.php +++ b/Abfall_ICS/module.php @@ -23,9 +23,13 @@ class Abfall_ICS extends IPSModule private const SERVICE_PROVIDER = 'wmics'; private const SERVICE_USERAGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'; + // Import type + private const IMPORT_LINK = 0; + private const IMPORT_FILE = 1; + // IO keys private const IO_CLIENT = 'id'; - private const IO_LINK = 'url'; + private const IO_TYPE = 'type'; private const IO_FRACTIONS = 'fract'; // Form Elements Positions @@ -44,9 +48,12 @@ public function Create() parent::Create(); // Service Provider $this->RegisterPropertyString('serviceProvider', self::SERVICE_PROVIDER); + $this->RegisterPropertyString('serviceCountry', 'de'); // Waste Management $this->RegisterPropertyString('clientID', 'null'); - $this->RegisterPropertyString('clientURL', ''); + $this->RegisterPropertyInteger('clientTYPE', self::IMPORT_LINK); + $this->RegisterPropertyString('clientURL', ''); // => clientLINK !!! + $this->RegisterPropertyString('clientFILE', ''); for ($i = 1; $i <= static::$FRACTIONS; $i++) { $this->RegisterPropertyBoolean('fractionID' . $i, false); } @@ -79,17 +86,20 @@ public function GetConfigurationForm() { // Settings $activate = $this->ReadPropertyBoolean('settingsActivate'); + // Service Values + $country = $this->ReadPropertyString('serviceCountry'); // IO Values $id = $this->ReadPropertyString('clientID'); - $url = $this->ReadPropertyString('clientURL'); + $type = $this->ReadPropertyInteger('clientTYPE'); // Debug output - $this->SendDebug(__FUNCTION__, 'clientID=' . $id . ' ,clientURL=' . $url); + $this->SendDebug(__FUNCTION__, 'clientID=' . $id . ' ,clientTYPE=' . $type); // Get Basic Form $jsonForm = json_decode(file_get_contents(__DIR__ . '/form.json'), true); // Service Provider $jsonForm['elements'][self::ELEM_PROVI]['items'][0]['options'] = $this->GetProviderOptions(); + $jsonForm['elements'][self::ELEM_PROVI]['items'][1]['options'] = $this->GetCountryOptions(self::SERVICE_PROVIDER); // Waste Management - $jsonForm['elements'][self::ELEM_WMICS]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER); + $jsonForm['elements'][self::ELEM_WMICS]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER, $country); // IO Data $io = unserialize($this->ReadAttributeString('io')); $this->SendDebug(__FUNCTION__, $io); @@ -97,6 +107,9 @@ public function GetConfigurationForm() if ($io[self::IO_CLIENT] != 'null') { $jsonForm['elements'][self::ELEM_WMICS]['items'][0]['items'][1]['visible'] = true; } + // Type (File or Link) + $jsonForm['elements'][self::ELEM_WMICS]['items'][1]['items'][1]['visible'] = ($type == self::IMPORT_LINK); + $jsonForm['elements'][self::ELEM_WMICS]['items'][1]['items'][2]['visible'] = ($type == self::IMPORT_FILE); // Fractions if (!empty($io[self::IO_FRACTIONS])) { // Label @@ -124,25 +137,33 @@ public function ApplyChanges() //Never delete this line! parent::ApplyChanges(); $id = $this->ReadPropertyString('clientID'); - $url = $this->ReadPropertyString('clientURL'); + $type = $this->ReadPropertyInteger('clientTYPE'); $activate = $this->ReadPropertyBoolean('settingsActivate'); $tilevisu = $this->ReadPropertyBoolean('settingsTileVisu'); $loakahead = $this->ReadPropertyBoolean('settingsLookAhead'); - $this->SendDebug(__FUNCTION__, 'clientID=' . $id . ' ,clientURL=' . $url); + $this->SendDebug(__FUNCTION__, 'clientID=' . $id . ' ,clientTYPE=' . $type); // Safty default $this->SetTimerInterval('UpdateTimer', 0); $this->SetTimerInterval('LookAheadTimer', 0); - // IO Data - $io = unserialize($this->ReadAttributeString('io')); // Set status - if (($url == '') || ($url != $io[self::IO_LINK])) { - $this->WriteAttributeString('io', serialize($this->PrepareIO($id, $url))); - $status = 201; + $status = 102; + if ($type == self::IMPORT_LINK) { + $url = $this->ReadPropertyString('clientURL'); + if (($url == '')) { + $status = 201; + } } else { - $status = 102; + $file = $this->ReadPropertyString('clientFILE'); + if (($file == '')) { + $status = 201; + } } // take over the selected fractions if ($status == 102) { + // IO Type + $io = unserialize($this->ReadAttributeString('io')); + $io[self::IO_TYPE] = $type; + // IO Fractions $count = count($io[self::IO_FRACTIONS]); for ($i = 1; $i <= $count; $i++) { $enabled = $this->ReadPropertyBoolean('fractionID' . $i); @@ -250,7 +271,7 @@ public function Update() //$res = $this->GetBuffer('ics_cache'); try { - $ical = new ICal($io[self::IO_LINK], [ + $ical = new ICal(false, [ 'defaultSpan' => 2, // Default value 'defaultTimeZone' => 'UTC', 'defaultWeekStart' => 'MO', // Default value @@ -259,6 +280,11 @@ public function Update() 'filterDaysBefore' => null, // Default value 'skipRecurrence' => false, // Default value ]); + if ($io[self::IO_TYPE] == self::IMPORT_LINK) { + $ical->initUrl($this->ReadPropertyString('clientURL')); + } else { + $ical->initString(base64_decode($this->ReadPropertyString('clientFILE'))); + } } catch (Exception $e) { $this->SendDebug(__FUNCTION__, 'initICS: ' . $e); return; @@ -314,6 +340,21 @@ public function Update() } } + /** + * User has selected a new waste management country. + * + * @param string $id Country ID. + */ + protected function OnChangeCountry($id) + { + $this->SendDebug(__FUNCTION__, $id); + $options = $this->GetClientOptions(self::SERVICE_PROVIDER, $id); + $this->UpdateFormField('clientID', 'options', json_encode($options)); + $this->UpdateFormField('clientID', 'visible', true); + $this->UpdateFormField('clientID', 'value', 'null'); + $this->OnChangeClient('null'); + } + /** * User has clicked to analyse a new waste management (iCal file). * @@ -329,14 +370,25 @@ protected function OnChangeClient(string $id) * * @param string $url Client URL. */ - protected function OnChangeLink(string $url) + protected function OnChangeFile(string $file) + { + $this->SendDebug(__FUNCTION__, $file); + } + + /** + * User has clicked to analyse a new waste management (iCal url). + * + * @param string $url Client URL. + */ + protected function OnChangeImport(string $value) { - $this->SendDebug(__FUNCTION__, $url); + $this->SendDebug(__FUNCTION__, $value); + $data = unserialize($value); // Reset IO data - $io = $this->PrepareIO($url); + $io = $this->PrepareIO($data['c'], $data['t']); // ICS data try { - $ical = new ICal($url, [ + $ical = new ICal(false, [ 'defaultSpan' => 2, // Default value 'defaultTimeZone' => 'UTC', 'defaultWeekStart' => 'MO', // Default value @@ -345,6 +397,11 @@ protected function OnChangeLink(string $url) 'filterDaysBefore' => null, // Default value 'skipRecurrence' => false, // Default value ]); + if ($io[self::IO_TYPE] == self::IMPORT_LINK) { + $ical->initUrl($data['l']); + } else { + $ical->initString(base64_decode($data['f'])); + } } catch (Exception $e) { $this->SendDebug(__FUNCTION__, 'initICS: ' . $e); $this->EchoMessage($e->getMessage()); @@ -372,8 +429,6 @@ protected function OnChangeLink(string $url) foreach ($names as $ident => $name) { $io[self::IO_FRACTIONS][] = ['ident' => $ident, 'name' => $name, 'active' => true]; } - // take over the new URL - $io[self::IO_LINK] = $url; $this->SendDebug(__FUNCTION__, $io); // Hide or Unhide properties $this->UpdateForm($io); @@ -440,10 +495,10 @@ protected function CreateVariables() * @param string $c client url value * @return array IO interface */ - protected function PrepareIO(string $c = 'null', string $l = 'null') + protected function PrepareIO(string $c = 'null', int $t = 0) { $io[self::IO_CLIENT] = $c; - $io[self::IO_LINK] = ($l != 'null') ? $l : ''; + $io[self::IO_TYPE] = $t; $io[self::IO_FRACTIONS] = []; // data2array return $io; @@ -463,6 +518,18 @@ protected function CreateIdent(string $summary) return $ident; } + /** + * User has select an other kind of import type. + * + * @param int $value import type. + */ + private function OnChangeType(int $value) + { + $this->SendDebug(__FUNCTION__, 'Value: ' . $value); + $this->UpdateFormField('clientURL', 'visible', ($value == self::IMPORT_LINK)); + $this->UpdateFormField('clientFILE', 'visible', ($value == self::IMPORT_FILE)); + } + /** * Show message via popup * diff --git a/Abfall_IO/README.md b/Abfall_IO/README.md index 5d9fb9e..868356e 100644 --- a/Abfall_IO/README.md +++ b/Abfall_IO/README.md @@ -2,7 +2,7 @@ [![Version](https://img.shields.io/badge/Symcon-PHP--Modul-red.svg?style=flat-square)](https://www.symcon.de/service/dokumentation/entwicklerbereich/sdk-tools/sdk-php/) [![Product](https://img.shields.io/badge/Symcon%20Version-6.4-blue.svg?style=flat-square)](https://www.symcon.de/produkt/) -[![Version](https://img.shields.io/badge/Modul%20Version-2.3.20240702-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) +[![Version](https://img.shields.io/badge/Modul%20Version-2.4.20250107-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) [![License](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-green.svg?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/) [![Actions](https://img.shields.io/github/actions/workflow/status/wilkware/WasteManagement/style.yml?branch=main&label=CheckStyle&style=flat-square)](https://github.com/Wilkware/WasteManagement/actions) @@ -15,7 +15,7 @@ IP-Symcon Modul für die Visualisierung von Entsorgungsterminen. 3. [Installation](#user-content-3-installation) 4. [Einrichten der Instanzen in IP-Symcon](#user-content-4-einrichten-der-instanzen-in-ip-symcon) 5. [Statusvariablen und Profile](#user-content-5-statusvariablen-und-profile) -6. [WebFront](#user-content-6-webfront) +6. [Visualisierung](#user-content-6-visualisierung) 7. [PHP-Befehlsreferenz](#user-content-7-php-befehlsreferenz) 8. [Versionshistorie](#user-content-8-versionshistorie) @@ -55,6 +55,7 @@ _Einstellungsbereich:_ Name | Beschreibung ----------------------- | ---------------------------------- Anbieter | 'Abfall.IO (abfallplus.de)' +Land | Landesauswahl (derzeit DE, AT) > Abfallwirtschaft ... @@ -100,7 +101,7 @@ Entsorgungsart(en) | String | Abhängig vom Entsorgungsgebiet und den angebot Es werden keine zusätzlichen Profile benötigt. -### 6. WebFront +### 6. Visualisierung Man kann die Statusvariablen(Strings) direkt im WF verlinken. Aber wie bei der Konfiguration beschrieben, muss man aufpassen wenn die Konfiguration geändert wird. Dann müssen gegebenenfalls die Links neu eingerichtet werden. @@ -136,6 +137,11 @@ __Beispiel__: `ABPIO_FixWasteName(12345, 'Hausmüll', 'Hausmüll (2 wöchentlich ### 8. Versionshistorie +v2.4.20250107 + +* _NEU_: Internationalisierte Anbieterauswahl +* _FIX_: Dokumentation verbessert + v2.3.20240702 * _NEU_: Vorrausschauende Anzeige diff --git a/Abfall_IO/form.json b/Abfall_IO/form.json index a114378..04c8357 100644 --- a/Abfall_IO/form.json +++ b/Abfall_IO/form.json @@ -38,6 +38,19 @@ "value": "null" } ] + }, + { + "type": "Select", + "name": "serviceCountry", + "caption": "Country:", + "width": "450px", + "onChange": "IPS_RequestAction($id,'OnChangeCountry',$serviceCountry);", + "options": [ + { + "label": "Germany", + "value": "de" + } + ] } ] }, diff --git a/Abfall_IO/locale.json b/Abfall_IO/locale.json index 41d25c8..743afa7 100644 --- a/Abfall_IO/locale.json +++ b/Abfall_IO/locale.json @@ -7,6 +7,10 @@ "This module uses the data provided by the Abfall.IO online service to display upcoming disposal dates.": "Dieses Modul nutzt die vom Online-Dienst Abfall.IO bereitgestellten Daten zur Darstellung der bevorstehenden Entsorgungstermine.", "Online service ...": "Online Dienst ...", "Provider:": "Anbieter:", + "Country:": "Land:", + "Germany": "Deutschland", + "Austria": "Österreich", + "Switzerland": "Schweiz", "Waste management ...": "Abfallwirtschaft ...", "Please select ...": "Bitte wählen ...", "Disposal area:": "Entsorgungsgebiet:", diff --git a/Abfall_IO/module.php b/Abfall_IO/module.php index 77721d0..1e72f7c 100644 --- a/Abfall_IO/module.php +++ b/Abfall_IO/module.php @@ -62,6 +62,8 @@ public function Create() parent::Create(); // Service Provider $this->RegisterPropertyString('serviceProvider', self::SERVICE_PROVIDER); + $this->RegisterPropertyString('serviceCountry', 'de'); + // Waste Management $this->RegisterPropertyString('clientID', 'null'); $this->RegisterPropertyString('placeID', 'null'); @@ -101,6 +103,8 @@ public function GetConfigurationForm() { // Settings $activate = $this->ReadPropertyBoolean('settingsActivate'); + // Service Values + $country = $this->ReadPropertyString('serviceCountry'); // IO Values $cId = $this->ReadPropertyString('clientID'); $pId = $this->ReadPropertyString('placeID'); @@ -109,14 +113,13 @@ public function GetConfigurationForm() $aId = $this->ReadPropertyString('addonID'); // Debug output $this->SendDebug(__FUNCTION__, 'clientID=' . $cId . ', placeId=' . $pId . ', districtId=' . $dId . ', streetId=' . $sId . ', addonId=' . $aId); // . ', fractIds=' . $fId); - // Get Basic Form $jsonForm = json_decode(file_get_contents(__DIR__ . '/form.json'), true); // Service Provider $jsonForm['elements'][self::ELEM_PROVI]['items'][0]['options'] = $this->GetProviderOptions(); + $jsonForm['elements'][self::ELEM_PROVI]['items'][1]['options'] = $this->GetCountryOptions(self::SERVICE_PROVIDER); // Waste Management - $jsonForm['elements'][self::ELEM_ABPIO]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER); - + $jsonForm['elements'][self::ELEM_ABPIO]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER, $country); // Prompt $prompt = ['caption' => $this->Translate('Please select ...') . str_repeat(' ', 79), 'value' => 'null']; // go throw thw whole way @@ -563,15 +566,15 @@ public function Update() $csv = array_map(null, ...$csv); $now = date('Ymd'); // each events - foreach ($csv as $waste) { - $count = count($waste); - $name = utf8_encode($waste[0]); + foreach ($csv as $line) { + $count = count($line); + $name = mb_convert_encoding($line[0], 'UTF-8', 'ISO-8859-1'); $this->SendDebug(__FUNCTION__, 'Fraction name: ' . $name . ', count:' . $count); for ($i = 1; $i < $count; $i++) { - if (empty($waste[$i])) { + if (empty($line[$i])) { continue; } - $day = substr($waste[$i], 6) . substr($waste[$i], 3, 2) . substr($waste[$i], 0, 2); + $day = substr($line[$i], 6) . substr($line[$i], 3, 2) . substr($line[$i], 0, 2); if ($day < $now) { $this->SendDebug(__FUNCTION__, 'Fraction day: ' . $day); continue; @@ -587,8 +590,8 @@ public function Update() } } if (isset($waste[$name]) && $waste[$name]['date'] == '') { - $waste[$name]['date'] = $waste[$i]; - $this->SendDebug(__FUNCTION__, 'Fraction date: ' . $name . ' = ' . $waste[$i]); + $waste[$name]['date'] = $line[$i]; + $this->SendDebug(__FUNCTION__, 'Fraction date: ' . $name . ' = ' . $line[$i]); } } } @@ -625,6 +628,21 @@ public function Update() } } + /** + * User has selected a new waste management country. + * + * @param string $id Country ID. + */ + protected function OnChangeCountry($id) + { + $this->SendDebug(__FUNCTION__, $id); + $options = $this->GetClientOptions(self::SERVICE_PROVIDER, $id); + $this->UpdateFormField('clientID', 'options', json_encode($options)); + $this->UpdateFormField('clientID', 'visible', true); + $this->UpdateFormField('clientID', 'value', 'null'); + $this->OnChangeClient('null'); + } + /** * User has selected a new waste management. * diff --git a/Awido/README.md b/Awido/README.md index af5710e..dd9b38a 100644 --- a/Awido/README.md +++ b/Awido/README.md @@ -2,7 +2,7 @@ [![Version](https://img.shields.io/badge/Symcon-PHP--Modul-red.svg?style=flat-square)](https://www.symcon.de/service/dokumentation/entwicklerbereich/sdk-tools/sdk-php/) [![Product](https://img.shields.io/badge/Symcon%20Version-6.4-blue.svg?style=flat-square)](https://www.symcon.de/produkt/) -[![Version](https://img.shields.io/badge/Modul%20Version-4.2.20240702-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) +[![Version](https://img.shields.io/badge/Modul%20Version-4.2.20250107-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) [![License](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-green.svg?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/) [![Actions](https://img.shields.io/github/actions/workflow/status/wilkware/WasteManagement/style.yml?branch=main&label=CheckStyle&style=flat-square)](https://github.com/Wilkware/WasteManagement/actions) @@ -15,7 +15,7 @@ IP-Symcon Modul für die Visualisierung von Entsorgungsterminen. 3. [Installation](#user-content-3-installation) 4. [Einrichten der Instanzen in IP-Symcon](#user-content-4-einrichten-der-instanzen-in-ip-symcon) 5. [Statusvariablen und Profile](#user-content-5-statusvariablen-und-profile) -6. [WebFront](#user-content-6-webfront) +6. [Visualisierung](#user-content-6-visualisierung) 7. [PHP-Befehlsreferenz](#user-content-7-php-befehlsreferenz) 8. [Versionshistorie](#user-content-8-versionshistorie) @@ -56,6 +56,7 @@ _Einstellungsbereich:_ Name | Beschreibung ----------------------- | --------------------------------- Anbieter | 'AWIDO (awido-online.de)' +Land | Landesauswahl (derzeit nur DE) > Abfallwirtschaft ... @@ -100,7 +101,7 @@ Entsorgungsart(en) | String | Abhängig vom Entsorgungsgebiet und den angebot Es werden keine zusätzlichen Profile benötigt. -### 6. WebFront +### 6. Visualisierung Man kann die Statusvariablen(Strings) direkt im WF verlinken. Aber wie bei der Konfiguration beschrieben, muss man aufpassen wenn die Konfiguration geändert wird. Dann müssen gegebenenfalls die Links neu eingerichtet werden. @@ -127,6 +128,11 @@ __Beispiel__: `AWIDO_Update(12345);` ### 8. Versionshistorie +v4.3.20250107 + +* _NEU_: Internationalisierte Anbieterauswahl +* _FIX_: Dokumentation verbessert + v4.2.20240702 * _NEU_: Vorrausschauende Anzeige diff --git a/Awido/form.json b/Awido/form.json index af03a72..69d8be2 100644 --- a/Awido/form.json +++ b/Awido/form.json @@ -37,6 +37,19 @@ "value": "null" } ] + }, + { + "type": "Select", + "name": "serviceCountry", + "caption": "Country:", + "width": "450px", + "onChange": "IPS_RequestAction($id,'OnChangeCountry',$serviceCountry);", + "options": [ + { + "label": "Germany", + "value": "de" + } + ] } ] }, diff --git a/Awido/locale.json b/Awido/locale.json index 3a6e239..b9c8fa7 100644 --- a/Awido/locale.json +++ b/Awido/locale.json @@ -7,6 +7,10 @@ "This module uses the data provided by the AWIDO online service to display upcoming disposal dates.": "Dieses Modul nutzt die vom Online-Dienst AWIDO bereitgestellten Daten zur Darstellung der bevorstehenden Entsorgungstermine.", "Online service ...": "Online Dienst ...", "Provider:": "Anbieter:", + "Country:": "Land:", + "Germany": "Deutschland", + "Austria": "Österreich", + "Switzerland": "Schweiz", "Waste management ...": "Abfallwirtschaft ...", "Please select ...": "Bitte wählen ...", "Disposal area:": "Entsorgungsgebiet:", diff --git a/Awido/module.php b/Awido/module.php index ebc5ffa..63aa5a9 100644 --- a/Awido/module.php +++ b/Awido/module.php @@ -33,6 +33,8 @@ public function Create() parent::Create(); // Service Provider $this->RegisterPropertyString('serviceProvider', self::SERVICE_PROVIDER); + $this->RegisterPropertyString('serviceCountry', 'de'); + // Waste Management $this->RegisterPropertyString('clientID', 'null'); $this->RegisterPropertyString('placeGUID', 'null'); @@ -69,6 +71,8 @@ public function Create() */ public function GetConfigurationForm() { + // Service Values + $country = $this->ReadPropertyString('serviceCountry'); // Setup einlesen $clientId = $this->ReadPropertyString('clientID'); $placeId = $this->ReadPropertyString('placeGUID'); @@ -114,8 +118,9 @@ public function GetConfigurationForm() $jsonForm = json_decode(file_get_contents(__DIR__ . '/form.json'), true); // Service Provider $jsonForm['elements'][self::ELEM_PROVI]['items'][0]['options'] = $this->GetProviderOptions(); + $jsonForm['elements'][self::ELEM_PROVI]['items'][1]['options'] = $this->GetCountryOptions(self::SERVICE_PROVIDER); // Waste Management - $jsonForm['elements'][self::ELEM_AWIDO]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER); + $jsonForm['elements'][self::ELEM_AWIDO]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER, $country); $jsonForm['elements'][self::ELEM_AWIDO]['items'][1]['items'][0]['options'] = $this->GetPlaceOptions(); $jsonForm['elements'][self::ELEM_AWIDO]['items'][2]['items'][0]['options'] = $this->GetStreetOptions(); $jsonForm['elements'][self::ELEM_AWIDO]['items'][2]['items'][1]['options'] = $this->GetAddonOptions(); @@ -355,6 +360,21 @@ public function Update() } } + /** + * User has selected a new waste management country. + * + * @param string $id Country ID. + */ + protected function OnChangeCountry($id) + { + $this->SendDebug(__FUNCTION__, $id); + $options = $this->GetClientOptions(self::SERVICE_PROVIDER, $id); + $this->UpdateFormField('clientID', 'options', json_encode($options)); + $this->UpdateFormField('clientID', 'visible', true); + $this->UpdateFormField('clientID', 'value', 'null'); + $this->OnChangeClient('null'); + } + /** * User has selected a new waste management. * diff --git a/MuellMax/README.md b/MuellMax/README.md index eef7f8c..20a76ae 100644 --- a/MuellMax/README.md +++ b/MuellMax/README.md @@ -2,7 +2,7 @@ [![Version](https://img.shields.io/badge/Symcon-PHP--Modul-red.svg?style=flat-square)](https://www.symcon.de/service/dokumentation/entwicklerbereich/sdk-tools/sdk-php/) [![Product](https://img.shields.io/badge/Symcon%20Version-6.4-blue.svg?style=flat-square)](https://www.symcon.de/produkt/) -[![Version](https://img.shields.io/badge/Modul%20Version-1.2.20240702-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) +[![Version](https://img.shields.io/badge/Modul%20Version-1.3.20250107-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) [![License](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-green.svg?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/) [![Actions](https://img.shields.io/github/actions/workflow/status/wilkware/WasteManagement/style.yml?branch=main&label=CheckStyle&style=flat-square)](https://github.com/Wilkware/WasteManagement/actions) @@ -15,7 +15,7 @@ IP-Symcon Modul für die Visualisierung von Entsorgungsterminen. 3. [Installation](#user-content-3-installation) 4. [Einrichten der Instanzen in IP-Symcon](#user-content-4-einrichten-der-instanzen-in-ip-symcon) 5. [Statusvariablen und Profile](#user-content-5-statusvariablen-und-profile) -6. [WebFront](#user-content-6-webfront) +6. [Visualisierung](#user-content-6-visualisierung) 7. [PHP-Befehlsreferenz](#user-content-7-php-befehlsreferenz) 8. [Versionshistorie](#user-content-8-versionshistorie) @@ -55,6 +55,7 @@ _Einstellungsbereich:_ Name | Beschreibung ----------------------- | ---------------------------------- Anbieter | 'MüllMax (muellmax.de)' +Land | Landesauswahl (derzeit nur DE) > Abfallwirtschaft ... @@ -99,7 +100,7 @@ Entsorgungsart(en) | String | Abhängig vom Entsorgungsgebiet und den angebot Es werden keine zusätzlichen Profile benötigt. -### 6. WebFront +### 6. Visualisierung Man kann die Statusvariablen(Strings) direkt im WF verlinken. Aber wie bei der Konfiguration beschrieben, muss man aufpassen wenn die Konfiguration geändert wird. Dann müssen gegebenenfalls die Links neu eingerichtet werden. @@ -126,6 +127,11 @@ __Beispiel__: `MAXDE_Update(12345);` ### 8. Versionshistorie +v1.3.20250107 + +* _NEU_: Internationalisierte Anbieterauswahl +* _FIX_: Dokumentation verbessert + v1.2.20240702 * _NEU_: Vorrausschauende Anzeige diff --git a/MuellMax/form.json b/MuellMax/form.json index adfb624..626d8ed 100644 --- a/MuellMax/form.json +++ b/MuellMax/form.json @@ -38,6 +38,19 @@ "value": "null" } ] + }, + { + "type": "Select", + "name": "serviceCountry", + "caption": "Country:", + "width": "450px", + "onChange": "IPS_RequestAction($id,'OnChangeCountry',$serviceCountry);", + "options": [ + { + "label": "Germany", + "value": "de" + } + ] } ] }, diff --git a/MuellMax/locale.json b/MuellMax/locale.json index 1ce6ddc..c74ca5e 100644 --- a/MuellMax/locale.json +++ b/MuellMax/locale.json @@ -7,6 +7,10 @@ "This module uses the data provided by the MuellMax online service to display upcoming disposal dates.": "Dieses Modul nutzt die vom Online-Dienst MüllMax bereitgestellten Daten zur Darstellung der bevorstehenden Entsorgungstermine.", "Online service ...": "Online Dienst ...", "Provider:": "Anbieter:", + "Country:": "Land:", + "Germany": "Deutschland", + "Austria": "Österreich", + "Switzerland": "Schweiz", "Waste management ...": "Abfallwirtschaft ...", "Please select ...": "Bitte wählen ...", "Disposal area:": "Entsorgungsgebiet:", diff --git a/MuellMax/module.php b/MuellMax/module.php index e740012..4643efd 100644 --- a/MuellMax/module.php +++ b/MuellMax/module.php @@ -58,6 +58,7 @@ public function Create() parent::Create(); // Service Provider $this->RegisterPropertyString('serviceProvider', self::SERVICE_PROVIDER); + $this->RegisterPropertyString('serviceCountry', 'de'); // Waste Management $this->RegisterPropertyString('disposalID', 'null'); $this->RegisterPropertyString('cityID', 'null'); @@ -92,6 +93,8 @@ public function GetConfigurationForm() { // Settings $activate = $this->ReadPropertyBoolean('settingsActivate'); + // Service Values + $country = $this->ReadPropertyString('serviceCountry'); // IO Values $dId = $this->ReadPropertyString('disposalID'); $cId = $this->ReadPropertyString('cityID'); @@ -99,14 +102,13 @@ public function GetConfigurationForm() $aId = $this->ReadPropertyString('addonID'); // Debug output $this->SendDebug(__FUNCTION__, 'disposalID=' . $dId . ', cityID=' . $cId . ', streetId=' . $sId . ', addonId=' . $aId); - // Get Basic Form $jsonForm = json_decode(file_get_contents(__DIR__ . '/form.json'), true); // Service Provider $jsonForm['elements'][self::ELEM_PROVI]['items'][0]['options'] = $this->GetProviderOptions(); + $jsonForm['elements'][self::ELEM_PROVI]['items'][1]['options'] = $this->GetCountryOptions(self::SERVICE_PROVIDER); // Waste Management - $jsonForm['elements'][self::ELEM_WASTE]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER); - + $jsonForm['elements'][self::ELEM_WASTE]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER, $country); // Prompt $prompt = ['caption' => $this->Translate('Please select ...') . str_repeat(' ', 79), 'value' => 'null']; // go throw the whole way @@ -578,6 +580,21 @@ public function Update() } } + /** + * User has selected a new waste management country. + * + * @param string $id Country ID. + */ + protected function OnChangeCountry($id) + { + $this->SendDebug(__FUNCTION__, $id); + $options = $this->GetClientOptions(self::SERVICE_PROVIDER, $id); + $this->UpdateFormField('disposalID', 'options', json_encode($options)); + $this->UpdateFormField('disposalID', 'visible', true); + $this->UpdateFormField('disposalID', 'value', 'null'); + $this->OnChangeDisposal('null'); + } + /** * User has selected a new waste management. * diff --git a/MyMuell/README.md b/MyMuell/README.md index 9194cfa..7d76780 100644 --- a/MyMuell/README.md +++ b/MyMuell/README.md @@ -2,7 +2,7 @@ [![Version](https://img.shields.io/badge/Symcon-PHP--Modul-red.svg?style=flat-square)](https://www.symcon.de/service/dokumentation/entwicklerbereich/sdk-tools/sdk-php/) [![Product](https://img.shields.io/badge/Symcon%20Version-6.4-blue.svg?style=flat-square)](https://www.symcon.de/produkt/) -[![Version](https://img.shields.io/badge/Modul%20Version-3.2.20240702-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) +[![Version](https://img.shields.io/badge/Modul%20Version-3.3.20250107-orange.svg?style=flat-square)](https://github.com/Wilkware/WasteManagement) [![License](https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-green.svg?style=flat-square)](https://creativecommons.org/licenses/by-nc-sa/4.0/) [![Actions](https://img.shields.io/github/actions/workflow/status/wilkware/WasteManagement/style.yml?branch=main&label=CheckStyle&style=flat-square)](https://github.com/Wilkware/WasteManagement/actions) @@ -15,7 +15,7 @@ IP-Symcon Modul für die Visualisierung von Entsorgungsterminen. 3. [Installation](#user-content-3-installation) 4. [Einrichten der Instanzen in IP-Symcon](#user-content-4-einrichten-der-instanzen-in-ip-symcon) 5. [Statusvariablen und Profile](#user-content-5-statusvariablen-und-profile) -6. [WebFront](#user-content-6-webfront) +6. [Visualisierung](#user-content-6-visualisierung) 7. [PHP-Befehlsreferenz](#user-content-7-php-befehlsreferenz) 8. [Versionshistorie](#user-content-8-versionshistorie) @@ -55,6 +55,7 @@ _Einstellungsbereich:_ Name | Beschreibung ----------------------- | ---------------------------------- Anbieter | 'MyMüll.de (mymuell.de)' +Land | Landesauswahl (derzeit nur DE) > Abfallwirtschaft ... @@ -97,7 +98,7 @@ Entsorgungsart(en) | String | Abhängig vom Entsorgungsgebiet und den angebot Es werden keine zusätzlichen Profile benötigt. -### 6. WebFront +### 6. Visualisierung Man kann die Statusvariablen(Strings) direkt im WF verlinken. Aber wie bei der Konfiguration beschrieben, muss man aufpassen wenn die Konfiguration geändert wird. Dann müssen gegebenenfalls die Links neu eingerichtet werden. @@ -124,6 +125,11 @@ __Beispiel__: `MYMDE_Update(12345);` ### 8. Versionshistorie +v3.3.20250107 + +* _NEU_: Internationalisierte Anbieterauswahl +* _FIX_: Dokumentation verbessert + v3.2.20240702 * _NEU_: Vorrausschauende Anzeige diff --git a/MyMuell/form.json b/MyMuell/form.json index 29071b2..b0c36ab 100644 --- a/MyMuell/form.json +++ b/MyMuell/form.json @@ -38,6 +38,19 @@ "value": "null" } ] + }, + { + "type": "Select", + "name": "serviceCountry", + "caption": "Country:", + "width": "450px", + "onChange": "IPS_RequestAction($id,'OnChangeCountry',$serviceCountry);", + "options": [ + { + "label": "Germany", + "value": "de" + } + ] } ] }, diff --git a/MyMuell/locale.json b/MyMuell/locale.json index 8f3ca10..06efc99 100644 --- a/MyMuell/locale.json +++ b/MyMuell/locale.json @@ -7,6 +7,10 @@ "This module uses the data provided by the MyMüll online service to display upcoming disposal dates.": "Dieses Modul nutzt die vom Online-Dienst MyMüll bereitgestellten Daten zur Darstellung der bevorstehenden Entsorgungstermine.", "Online service ...": "Online Dienst ...", "Provider:": "Anbieter:", + "Country:": "Land:", + "Germany": "Deutschland", + "Austria": "Österreich", + "Switzerland": "Schweiz", "Waste management ...": "Abfallwirtschaft ...", "Please select ...": "Bitte wählen ...", "Disposal area:": "Entsorgungsgebiet:", diff --git a/MyMuell/module.php b/MyMuell/module.php index 32e9d8c..05e34c4 100644 --- a/MyMuell/module.php +++ b/MyMuell/module.php @@ -37,6 +37,7 @@ public function Create() parent::Create(); // Service Provider $this->RegisterPropertyString('serviceProvider', self::SERVICE_PROVIDER); + $this->RegisterPropertyString('serviceCountry', 'de'); // Waste Management $this->RegisterPropertyString('domainID', 'null'); $this->RegisterPropertyString('cityID', 'null'); @@ -70,23 +71,23 @@ public function GetConfigurationForm() { // Settings $activate = $this->ReadPropertyBoolean('settingsActivate'); + // Service Values + $country = $this->ReadPropertyString('serviceCountry'); // IO Values $dId = $this->ReadPropertyString('domainID'); $cId = $this->ReadPropertyString('cityID'); $aId = $this->ReadPropertyString('areaID'); // Debug output $this->SendDebug(__FUNCTION__, 'domainID=' . $dId . ',cityID=' . $cId . ', areaId=' . $aId); - // Get Basic Form $jsonForm = json_decode(file_get_contents(__DIR__ . '/form.json'), true); // Service Provider $jsonForm['elements'][self::ELEM_PROVI]['items'][0]['options'] = $this->GetProviderOptions(); + $jsonForm['elements'][self::ELEM_PROVI]['items'][1]['options'] = $this->GetCountryOptions(self::SERVICE_PROVIDER); // Waste Management - $jsonForm['elements'][self::ELEM_MYMDE]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER); - + $jsonForm['elements'][self::ELEM_MYMDE]['items'][0]['items'][0]['options'] = $this->GetClientOptions(self::SERVICE_PROVIDER, $country); // Prompt $prompt = ['caption' => $this->Translate('Please select ...') . str_repeat(' ', 79), 'value' => 'null']; - // Domain (client) if ($dId != 'null') { $options = $this->RequestCities($dId); @@ -112,7 +113,6 @@ public function GetConfigurationForm() } else { $aId = null; } - // Fractions if ($aId != null) { $options = $this->RequestFractions($dId, $cId, $aId); @@ -127,7 +127,6 @@ public function GetConfigurationForm() } } } - //Only add default element if we do not have anything in persistence $colors = json_decode($this->ReadPropertyString('settingsTileColors'), true); if (empty($colors)) { @@ -309,6 +308,21 @@ public function Update() } } + /** + * User has selected a new waste management country. + * + * @param string $id Country ID. + */ + protected function OnChangeCountry($id) + { + $this->SendDebug(__FUNCTION__, $id); + $options = $this->GetClientOptions(self::SERVICE_PROVIDER, $id); + $this->UpdateFormField('domainID', 'options', json_encode($options)); + $this->UpdateFormField('domainID', 'visible', true); + $this->UpdateFormField('domainID', 'value', 'null'); + $this->OnChangeDomain('null'); + } + /** * User has selected a new waste management domain. * diff --git a/README.md b/README.md index d4196d2..ab11806 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,8 @@ __HINWEIS:__ Über diese [Suchseite](https://asmium.de) kann man ganz schnell he ## Historie -- 2024-07-02: Look-Ahead Visualiserungeingebaut +- 2025-01-07: Internationalisierte Anbieterauswahl +- 2024-07-02: Look-Ahead Visualiserung eingebaut - 2024-03-04: Modul Abfall_ICS (Kalender ICS-Datei) - 2023-11-19: Modul MuellMax (MüllMax DE) - 2023-01-24: Modul Awido (Script-Fix) diff --git a/WasteManagementConfigurator/README.md b/WasteManagementConfigurator/README.md index 831991d..153edf1 100644 --- a/WasteManagementConfigurator/README.md +++ b/WasteManagementConfigurator/README.md @@ -15,7 +15,7 @@ IP-Symcon Modul für die Verwaltung von Online Diensten zur Bestimmung von Entso 3. [Installation](#user-content-3-installation) 4. [Einrichten der Instanzen in IP-Symcon](#user-content-4-einrichten-der-instanzen-in-ip-symcon) 5. [Statusvariablen und Profile](#user-content-5-statusvariablen-und-profile) -6. [WebFront](#user-content-6-webfront) +6. [Visualisierung](#user-content-6-visualisierung) 7. [PHP-Befehlsreferenz](#user-content-7-php-befehlsreferenz) 8. [Versionshistorie](#user-content-8-versionshistorie) @@ -72,7 +72,7 @@ Anbieter | Konfigurationsliste zum Verwalten der entsprechenden I Es werden keine zusätzlichen Variablen oder Profile benötigt. -### 6. WebFront +### 6. Visualisierung Es ist keine weitere Steuerung oder gesonderte Darstellung integriert. diff --git a/library.json b/library.json index 090542f..a4daec1 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "6.4" }, - "version": "4.2", - "build": 20240702, - "date": 1719921600 + "version": "4.3", + "build": 20250107, + "date": 1736251200 } \ No newline at end of file diff --git a/libs/DebugHelper.php b/libs/DebugHelper.php index c08cd1e..a8bd20d 100644 --- a/libs/DebugHelper.php +++ b/libs/DebugHelper.php @@ -43,6 +43,52 @@ protected function SendDebug($msg, $data, $format = 0) } } + /** + * DebugPrint + * + * @param mixed $arr Array to print. + * @return string Pretty formated array data. + */ + protected function DebugPrint($arr) + { + $retStr = ''; + if (is_array($arr)) { + foreach ($arr as $key=>$val) { + if (is_array($val)) { + $retStr .= '[' . $key . '] => ' . $this->PrettyPrint($val); + }else { + $retStr .= '[' . $key . '] => ' . $val . ', '; + } + } + } + return $retStr; + } + + /** + * Safe Print + * + * @param mixed $var Variable to log + */ + protected function SafePrint($var) + { + if (is_array($var)) { + // Arrays als JSON-String ausgeben + return json_encode($var); + } elseif (is_object($var)) { + // Objekte als JSON-String ausgeben + return json_encode($var); + } elseif (is_bool($var)) { + // Boolesche Werte als 'true' oder 'false' ausgeben + return $var ? 'true' : 'false'; + } elseif (is_null($var)) { + // Null-Werte als 'null' ausgeben + return 'null'; + } else { + // Andere Typen direkt ausgeben + return $var; + } + } + /** * Wrapper for default modul log messages * diff --git a/libs/EventHelper.php b/libs/EventHelper.php index 0f3566a..4f2a9d8 100644 --- a/libs/EventHelper.php +++ b/libs/EventHelper.php @@ -27,23 +27,12 @@ trait EventHelper * @param int $minute Start minute. * @param int $second Start second. */ - protected function UpdateTimerInterval($ident, $hour, $minute, $second, $days = 1) + protected function UpdateTimerInterval($ident, $hour, $minute, $second) { $now = new DateTime(); $target = new DateTime(); + $target->modify('+1 day'); $target->setTime($hour, $minute, $second); - - if ($days == 0) { - // Check if the target time is still reachable today - if ($now > $target) { - // If not, set days to 1 to move to the next day - $days = 1; - } - } - - if ($days > 0) { - $target->modify("+$days day"); - } $diff = $target->getTimestamp() - $now->getTimestamp(); $interval = $diff * 1000; $this->SetTimerInterval($ident, $interval); @@ -64,12 +53,12 @@ protected function CreateWeeklySchedule($id, $name, $ident, $datas, $pos = 0) $eid = @IPS_GetObjectIDByIdent($ident, $id); if ($eid === false) { $eid = IPS_CreateEvent(EVENTTYPE_SCHEDULE); - IPS_SetName($eid, $name); + IPS_SetName($eid, $this->Translate($name)); IPS_SetIdent($eid, $ident); IPS_SetParent($eid, $id); IPS_SetPosition($eid, $pos); foreach ($datas as $key => $value) { - IPS_SetEventScheduleAction($eid, $key, $value[0], $value[1], $value[2]); + IPS_SetEventScheduleAction($eid, $key, $this->Translate($value[0]), $value[1], $value[2]); } // Mo - So (1 + 2 + 4 + 8 + 16 + 32 + 64) = 127; Mo - Fr (1 + 2 + 4 + 8 + 16) = 31; Sa + So (32 + 64) = 96 IPS_SetEventScheduleGroup($eid, 0, 127); diff --git a/libs/ServiceHelper.php b/libs/ServiceHelper.php index 5422871..f2179ae 100644 --- a/libs/ServiceHelper.php +++ b/libs/ServiceHelper.php @@ -31,10 +31,22 @@ trait ServiceHelper 'wmics' => [6, '{9E99E213-F884-FC95-A8ED-4F3FCC368E70}', 'Abfall.ICS', 'asmium.de', 'Read out waste data via ICS calendar file.'], ]; + /** + * Supported Countries per Service + */ + private static $COUNTRIES = [ + 'awido' => ['de' => 'Germany'], + 'abpio' => ['de' => 'Germany', 'at' => 'Austria'], + 'mymde' => ['de' => 'Germany'], + 'regio' => ['de' => 'Germany'], + 'maxde' => ['de' => 'Germany'], + 'wmics' => ['de' => 'Germany', 'at' => 'Austria'], + ]; + /** * API URL for Client IDs */ - private static $CLIENTS = 'https://api.asmium.de/waste/de/'; + private static $CLIENTS = 'https://api.asmium.de/waste/'; /** * Maximale Anzahl an Entsorgungsarten @@ -58,12 +70,33 @@ protected function GetProviderOptions() return $options; } + /** + * Returns the list of available countries per services provider. + * + * @param string $provider Service provider identifier + * @return array Array of countries. + */ + protected function GetCountryOptions(string $provider) + { + $this->SendDebug(__FUNCTION__, $provider); + // Options + $options = []; + // Default key + foreach (static::$COUNTRIES[$provider] as $key => $value) { + $options[] = ['caption' => $this->Translate($value), 'value' => $key]; + } + $this->SendDebug(__FUNCTION__, $options); + return $options; + } + /** * Returns the list of available clients for the dropdown menu. * + * @param string $provider Service provider identifier + * @param string $country Service country identifier * @return array Array of clients. */ - protected function GetClientOptions($provider) + protected function GetClientOptions(string $provider, string $country = 'de') { $this->SendDebug(__FUNCTION__, $provider); // Options @@ -72,7 +105,7 @@ protected function GetClientOptions($provider) $options[] = ['caption' => $this->Translate('Please select ...') . str_repeat(' ', 79), 'value' => 'null']; // Build array if ($provider != 'null') { - $link = static::$CLIENTS . $provider; + $link = static::$CLIENTS . $country . '/' . $provider; $data = $this->ExtractClients($link); foreach ($data as $client) { $value = $client['client']; @@ -82,6 +115,8 @@ protected function GetClientOptions($provider) $options[] = ['caption' => $client['name'], 'value' => $value]; } } + // Debug + // $options[] = ['caption' => 'Testgebiet', 'value' => '12345678790']; //$this->SendDebug(__FUNCTION__, $options); return $options; } diff --git a/libs/VisualisationHelper.php b/libs/VisualisationHelper.php index 3bd339b..2c40a68 100644 --- a/libs/VisualisationHelper.php +++ b/libs/VisualisationHelper.php @@ -49,6 +49,7 @@ protected function GetWasteValues() * * @param array $waste Array with waste names and the next pick-up date. * @param array $custom Array with color mappings + * @param bool $lookahead Flag if look ahead is enabled or not. */ protected function BuildWidget(array $waste, array $custom, bool $lookahead = false) { @@ -71,7 +72,7 @@ protected function BuildWidget(array $waste, array $custom, bool $lookahead = fa // (*) Security Check if (empty($table)) { $table[] = ['name' => 'No DATA!', 'type' => 'red', 'date' => date('d.m.Y'), 'days' => 0]; - $this->SendDebug(__FUNCTION__, 'SECURITY CHECK: NO DATA!!!'); + $this->LogMessage('SECURITY CHECK: NO DATA!!!'); } // (*) sort waste by date usort($table, function ($a, $b) @@ -114,6 +115,7 @@ protected function BuildWidget(array $waste, array $custom, bool $lookahead = fa $wn .= ', '; } } + // (*) build html texts $next = ''; // show today only if no date tommorow @@ -253,22 +255,24 @@ protected function BuildWidget(array $waste, array $custom, bool $lookahead = fa /** * Calculate days up to a date * - * @param mixed $startDate - * @param null $endDate - * @return int Number of days + * @param string $start Start date + * @param string $end End date + * @return int Number of days to date */ - private function CalcDaysToDate($startDate, $endDate = null) + private function CalcDaysToDate(string $start, string $end = '') { - if (empty($endDate)) $endDate = date('Y-m-d'); - return round(abs(strtotime($endDate) - strtotime($startDate)) / (60 * 60 * 24)); + if (empty($end)) $end = date('Y-m-d'); + return intval(round(abs(strtotime($end) - strtotime($start)) / (60 * 60 * 24))); } /** - * Recognize waste type for given name + * Recognize waste type for given name. * - * @param mixed $name + * @param string $name Waste name + * @param array $matches Array of predefined colored waste types + * @return int Color of associated waste type */ - private function RecognizeWaste($name, $matches) + private function RecognizeWaste(string $name, array $matches) { foreach ($matches as $match) { $pm = '/(' . $match['Match'] . ')/i';