no message
This commit is contained in:
@@ -301,6 +301,49 @@ private function CalculatePowerCosts($powerMeters, $tariffs, $userId, $from, $to
|
||||
return ['html'=>$html, 'sum'=>$grand];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ====================== Nebenkosten ======================
|
||||
|
||||
private function CalculateAdditionalCosts($waterMeters, $tariffs, $userId, $from, $to)
|
||||
{
|
||||
$html = "<table border='1' cellspacing='0' cellpadding='3' width='100%' style='font-size:8px;'>
|
||||
<tr style='background-color:#f0f0f0;'>
|
||||
<th>Zähler</th><th>Typ</th><th>Start</th><th>Ende</th>
|
||||
<th>Zähler Start</th><th>Zähler Ende</th><th>Verbrauch</th><th>Tarif (Rp)</th><th>Kosten (CHF)</th>
|
||||
</tr>";
|
||||
|
||||
$total = 0.0;
|
||||
$usedTariffs = [];
|
||||
|
||||
foreach ($waterMeters as $m) {
|
||||
if ($m['user_id'] != $userId) continue;
|
||||
$type = $m['meter_type'] ?? 'Warmwasser';
|
||||
$cost = $this->AddMeterToPDFRow($m, $tariffs, $from, $to, $type);
|
||||
$html .= $cost['row'];
|
||||
$total += $cost['value'];
|
||||
$usedTariffs = array_merge($usedTariffs, $cost['tariffs']);
|
||||
}
|
||||
|
||||
$html .= "<tr style='background-color:#f9f9f9; font-weight:bold;'>
|
||||
<td colspan='8' align='right'>Total Nebenkosten:</td>
|
||||
<td align='right'>" . number_format($total, 2) . "</td>
|
||||
</tr></table><br>";
|
||||
|
||||
// 👇 Tarifliste anhängen
|
||||
if (!empty($usedTariffs)) {
|
||||
$html .= "<p><strong>Angewendete Nebenkostentarife:</strong></p><ul>";
|
||||
foreach ($usedTariffs as $t) {
|
||||
$html .= "<li>" . date('d.m.Y', $t['start']) . " – " . date('d.m.Y', $t['end']) . ": " .
|
||||
number_format($t['price'], 2) . " Rp</li>";
|
||||
}
|
||||
$html .= "</ul><br>";
|
||||
}
|
||||
|
||||
return ['html' => $html, 'sum' => $total];
|
||||
}
|
||||
|
||||
// ====================== Kernberechnung ======================
|
||||
|
||||
private function AddMeterToPDFRow($meter, $tariffs, $from, $to, $type)
|
||||
|
||||
Reference in New Issue
Block a user