no message

This commit is contained in:
2026-06-28 12:40:34 +02:00
parent d478aeca38
commit 29a3ac38f9
+40 -6
View File
@@ -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 '<tr>'
. '<td><select data-field="unit_type">' . $options . '</select></td>'
. '<td><input data-field="start" type="date" value="' . $this->h($start) . '"></td>'
. '<td><input data-field="end" type="date" value="' . $this->h($end) . '"></td>'
. '<td><input data-field="price" class="num" type="number" min="0" step="0.001" value="' . $this->h($price) . '"></td>'
. '<td><select data-field="unit_type" name="unit_type[]">' . $options . '</select></td>'
. '<td><input data-field="start" name="start[]" type="date" value="' . $this->h($start) . '"></td>'
. '<td><input data-field="end" name="end[]" type="date" value="' . $this->h($end) . '"></td>'
. '<td><input data-field="price" name="price[]" class="num" type="number" min="0" step="0.001" value="' . $this->h($price) . '"></td>'
. '<td><button type="button" class="danger" data-action="delete">Löschen</button></td>'
. '</tr>';
}
@@ -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'] ?? '';
if (trim((string)$payload) !== '') {
$message = $this->SaveTariffTableFromPayload($payload);
} else {
$message = $this->SaveTariffTableFromPost($_POST);
}
SetValue($this->GetIDForIdent('VisuTariffStatus'), $message);
$this->UpdateTariffOverview();
} catch (Throwable $e) {