From 29a3ac38f90702e9d04c81d8ab9feccd8576d112 Mon Sep 17 00:00:00 2001 From: DanielHaefliger Date: Sun, 28 Jun 2026 12:40:34 +0200 Subject: [PATCH] no message --- Abrechnung/module.php | 48 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/Abrechnung/module.php b/Abrechnung/module.php index 6a2128b..8549a33 100644 --- a/Abrechnung/module.php +++ b/Abrechnung/module.php @@ -100,6 +100,12 @@ class Abrechnung extends IPSModule private function RegisterTariffWebhook() { $webhook = $this->GetTariffWebhookPath(); + + if (method_exists($this, 'RegisterHook')) { + $this->RegisterHook($webhook); + return; + } + $ids = @IPS_GetInstanceListByModuleID('{015A6EB8-D6E5-4B93-B496-0D3F77AE9FE1}'); if (empty($ids)) { return; @@ -464,8 +470,7 @@ form.onsubmit=function(){ } }); form.querySelector('input[name=payload]').value=JSON.stringify(rows); - status.textContent='Speichern...'; - window.setTimeout(function(){status.textContent='Gesendet. Tabelle wird nach dem Speichern aktualisiert.';},800); + status.textContent='Speichern gesendet.'; return true; }; })(); @@ -484,10 +489,10 @@ form.onsubmit=function(){ } return '' - . '' - . '' - . '' - . '' + . '' + . '' + . '' + . '' . '' . ''; } @@ -543,6 +548,31 @@ form.onsubmit=function(){ return count($tariffs) . ' Tarif(e) gespeichert.'; } + private function SaveTariffTableFromPost(array $post) + { + $types = $post['unit_type'] ?? []; + $starts = $post['start'] ?? []; + $ends = $post['end'] ?? []; + $prices = $post['price'] ?? []; + + if (!is_array($types) || !is_array($starts) || !is_array($ends) || !is_array($prices)) { + throw new Exception('Ungültige Formularwerte.'); + } + + $rows = []; + $count = max(count($types), count($starts), count($ends), count($prices)); + for ($i = 0; $i < $count; $i++) { + $rows[] = [ + 'unit_type' => $types[$i] ?? '', + 'start' => $starts[$i] ?? '', + 'end' => $ends[$i] ?? '', + 'price' => $prices[$i] ?? '' + ]; + } + + return $this->SaveTariffTableFromPayload(json_encode($rows)); + } + private function FormatDateInput($timestamp) { return $timestamp ? date('Y-m-d', (int)$timestamp) : ''; @@ -645,7 +675,11 @@ form.onsubmit=function(){ $message = ''; try { $payload = $_POST['payload'] ?? ''; - $message = $this->SaveTariffTableFromPayload($payload); + if (trim((string)$payload) !== '') { + $message = $this->SaveTariffTableFromPayload($payload); + } else { + $message = $this->SaveTariffTableFromPost($_POST); + } SetValue($this->GetIDForIdent('VisuTariffStatus'), $message); $this->UpdateTariffOverview(); } catch (Throwable $e) {