no message

This commit is contained in:
2025-12-12 09:26:01 +01:00
parent 4e6f5f6fb7
commit 422ea912b0

View File

@@ -399,64 +399,26 @@ class Abrechnung extends IPSModule
}
private function GetCalculatedPowerCosts($userId)
{
// Inline-styles + TCPDF-kompatible Struktur
$html = "
<style>
table.powercost {
width: 100%;
border-collapse: collapse;
font-size: 10px;
}
table.powercost th {
background-color: #444;
color: white;
padding: 4px;
text-align: center;
font-weight: bold;
border: 1px solid #777;
}
table.powercost td {
padding: 3px 4px;
border: 1px solid #ccc;
}
.row-even { background-color: #f7f7f7; }
.row-odd { background-color: #ffffff; }
.row-empty { background-color: #e0e0e0; height: 5px; }
/* Neue Formatierungen */
.num {
text-align: right;
font-family: monospace;
width: 90px;
}
.subtotal-row {
border-top: 1px solid black;
font-weight: bold;
}
.total-row {
border-top: 3px double black;
font-weight: bold;
background-color: #ddd;
}
</style>
<table class='powercost'>
<table width='100%' cellpadding='4' cellspacing='0' style='font-size:10px; border-collapse: collapse;'>
<tr>
<th>ID</th>
<th>Import (kWh)</th>
<th>Export (kWh)</th>
<th>ZEV-Haus (kWh)</th>
<th>Netz-Haus (kWh)</th>
<th>Solar-Netz (kWh)</th>
<th>Solar-ZEV (kWh)</th>
<th>Kauf Solar (CHF)</th>
<th>Kauf Netz (CHF)</th>
<th>Verkauf Netz (CHF)</th>
<th>Verkauf ZEV (CHF)</th>
<th>Total CHF</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:left;'>ID</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Import (kWh)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Export (kWh)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>ZEV-Haus (kWh)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Netz-Haus (kWh)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Solar-Netz (kWh)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Solar-ZEV (kWh)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Kauf Solar (CHF)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Kauf Netz (CHF)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Verkauf Netz (CHF)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Verkauf ZEV (CHF)</th>
<th style='background-color:#444; color:#fff; padding:6px; border:1px solid #777; text-align:right;'>Total CHF</th>
</tr>";
if (empty($this->powerCostCache) || !isset($this->powerCostCache[$userId])) {
$html .= "<tr><td colspan='12' align='center'>Keine Stromzähler für diesen Benutzer</td></tr></table>";
$html .= "<tr><td colspan='12' align='center' style='padding:10px;'>Keine Stromzähler für diesen Benutzer</td></tr></table>";
return ['html' => $html, 'sum' => 0.0];
}
@@ -468,36 +430,94 @@ private function GetCalculatedPowerCosts($userId)
$subtotal = $a['cost_grid'] + $a['cost_solar'] - ($a['rev_feedin'] + $a['rev_zev']);
$sum += $subtotal;
$rowClass = ($rowIndex % 2 === 0) ? "row-even" : "row-odd";
// Alternierende Hintergrundfarbe (einfach über inline style)
$bg = ($rowIndex % 2 === 0) ? '#f7f7f7' : '#ffffff';
$rowIndex++;
// Datenzeile
$html .= "<tr class='{$rowClass}'>
<td>{$a['name']}</td>
<td class='num'>" . number_format($a['imp'], 3) . "</td>
<td class='num'>" . number_format($a['exp'], 3) . "</td>
<td class='num'>" . number_format($a['solar_bezug'], 3) . "</td>
<td class='num'>" . number_format($a['netz_bezug'], 3) . "</td>
<td class='num'>" . number_format($a['solareinspeisung'], 3) . "</td>
<td class='num'>" . number_format($a['solarverkauf'], 3) . "</td>
<td class='num'>" . number_format($a['cost_solar'], 2) . "</td>
<td class='num'>" . number_format($a['cost_grid'], 2) . "</td>
<td class='num'>" . number_format($a['rev_feedin'], 2) . "</td>
<td class='num'>" . number_format($a['rev_zev'], 2) . "</td>
<td class='num'>" . number_format($subtotal, 2) . "</td>
// 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 .= "<tr style='background-color:{$bg};'>
<td style='border:1px solid #ccc; padding:6px; vertical-align:top;'>{$a['name']}</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtKwh($a['imp']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtKwh($a['exp']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtKwh($a['solar_bezug']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtKwh($a['netz_bezug']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtKwh($a['solareinspeisung']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtKwh($a['solarverkauf']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtChf($a['cost_solar']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtChf($a['cost_grid']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtChf($a['rev_feedin']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtChf($a['rev_zev']) . "</span>
</td>
<td style='border:1px solid #ccc; padding:6px; text-align:right; vertical-align:top;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . $fmtChf($subtotal) . "</span>
</td>
</tr>";
// Leerzeile
$html .= "<tr class='row-empty'><td colspan='12'></td></tr>";
// Leerzeile zwischen Zählern (leichter grauer Hintergrund)
$html .= "<tr><td colspan='12' style='background-color:#e9e9e9; height:8px; padding:0; border:none;'></td></tr>";
}
// Gesamttotal
// Subtotal - einzeilige obere Linie (in gleicher Spalte wie subtotal)
$html .= "
<tr class='total-row'>
<td colspan='11' align='right'><b>Gesamttotal</b></td>
<td class='num'><b>" . number_format($sum, 2) . "</b></td>
</tr>
</table>";
<tr>
<td colspan='11' style='text-align:right; padding:6px; border-top:1px solid #000; font-weight:bold;'>Subtotal</td>
<td style='text-align:right; padding:6px; border-top:1px solid #000; font-weight:bold;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . number_format($sum, 2, '.', "'") . "</span>
</td>
</tr>";
// 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 .= "
<tr>
<td colspan='12' style='padding:0; border:none;'>
<div style='height:4px; border-top:1px solid #000;'></div>
<div style='height:4px; border-top:3px solid #000; margin-top:-3px;'></div>
</td>
</tr>";
// Gesamttotal-Zeile (gleich Spalte wie Subtotal)
$html .= "
<tr>
<td colspan='11' style='text-align:right; padding:6px; font-weight:bold;'>Gesamttotal</td>
<td style='text-align:right; padding:6px; font-weight:bold;'>
<span style='font-family:Courier, monospace; display:inline-block; min-width:90px;'>" . number_format($sum, 2, '.', "'") . "</span>
</td>
</tr>
</table>";
return ['html' => $html, 'sum' => $sum];
}