diff --git a/Abrechnung/module.php b/Abrechnung/module.php index afb0b6a..7394b7a 100644 --- a/Abrechnung/module.php +++ b/Abrechnung/module.php @@ -399,26 +399,64 @@ class Abrechnung extends IPSModule } private function GetCalculatedPowerCosts($userId) { - // Inline-styles + TCPDF-kompatible Struktur $html = " - + + +
- - - - - - - - - - - - + + + + + + + + + + + + "; if (empty($this->powerCostCache) || !isset($this->powerCostCache[$userId])) { - $html .= "
IDImport (kWh)Export (kWh)ZEV-Haus (kWh)Netz-Haus (kWh)Solar-Netz (kWh)Solar-ZEV (kWh)Kauf Solar (CHF)Kauf Netz (CHF)Verkauf Netz (CHF)Verkauf ZEV (CHF)Total CHFIDImport (kWh)Export (kWh)ZEV-Haus (kWh)Netz-Haus (kWh)Solar-Netz (kWh)Solar-ZEV (kWh)Kauf Solar (CHF)Kauf Netz (CHF)Verkauf Netz (CHF)Verkauf ZEV (CHF)Total CHF
Keine Stromzähler für diesen Benutzer
"; + $html .= "Keine Stromzähler für diesen Benutzer"; return ['html' => $html, 'sum' => 0.0]; } @@ -430,94 +468,45 @@ private function GetCalculatedPowerCosts($userId) $subtotal = $a['cost_grid'] + $a['cost_solar'] - ($a['rev_feedin'] + $a['rev_zev']); $sum += $subtotal; - // Alternierende Hintergrundfarbe (einfach über inline style) - $bg = ($rowIndex % 2 === 0) ? '#f7f7f7' : '#ffffff'; + $rowClass = ($rowIndex % 2 === 0) ? "row-even" : "row-odd"; $rowIndex++; - // Funktion zum formatieren mit monospace-alignment (Breite anpassen falls nötig) - $fmtKwh = function($v) { return number_format($v, 3, '.', "'"); }; // Tausendertrenner ' optional - $fmtChf = function($v) { return number_format($v, 2, '.', "'"); }; - - $html .= " - {$a['name']} - - - " . $fmtKwh($a['imp']) . " - - - - " . $fmtKwh($a['exp']) . " - - - - " . $fmtKwh($a['solar_bezug']) . " - - - - " . $fmtKwh($a['netz_bezug']) . " - - - - " . $fmtKwh($a['solareinspeisung']) . " - - - - " . $fmtKwh($a['solarverkauf']) . " - - - - " . $fmtChf($a['cost_solar']) . " - - - - " . $fmtChf($a['cost_grid']) . " - - - - " . $fmtChf($a['rev_feedin']) . " - - - - " . $fmtChf($a['rev_zev']) . " - - - - " . $fmtChf($subtotal) . " - + // Datenzeile + $html .= " + {$a['name']} + " . number_format($a['imp'], 3) . " + " . number_format($a['exp'], 3) . " + " . number_format($a['solar_bezug'], 3) . " + " . number_format($a['netz_bezug'], 3) . " + " . number_format($a['solareinspeisung'], 3) . " + " . number_format($a['solarverkauf'], 3) . " + " . number_format($a['cost_solar'], 2) . " + " . number_format($a['cost_grid'], 2) . " + " . number_format($a['rev_feedin'], 2) . " + " . number_format($a['rev_zev'], 2) . " + " . number_format($subtotal, 2) . " "; - // Leerzeile zwischen Zählern (leichter grauer Hintergrund) - $html .= ""; + // Leerzeile + $html .= ""; } - // Subtotal - einzeilige obere Linie (in gleicher Spalte wie subtotal) + // Gesamttotal $html .= " - - Subtotal - - " . number_format($sum, 2, '.', "'") . " - - "; - - // Doppel-Linie: wir fügen eine sehr dünne Linie und direkt darunter eine dickere Linie ein, - // da 'double' nicht immer zuverlässig in TCPDF gerendert wird. - $html .= " - - -
-
- - "; - - // Gesamttotal-Zeile (gleich Spalte wie Subtotal) - $html .= " - - Gesamttotal - - " . number_format($sum, 2, '.', "'") . " - - - "; + + Total + + + + + + + + + + " . number_format($sum, 2) . " + + "; return ['html' => $html, 'sum' => $sum]; }