no message
This commit is contained in:
+60
-29
@@ -127,39 +127,45 @@ public function GenerateInvoices()
|
|||||||
$pdf->SetAutoPageBreak(true, 20);
|
$pdf->SetAutoPageBreak(true, 20);
|
||||||
$pdf->SetFont('dejavusans', '', 10);
|
$pdf->SetFont('dejavusans', '', 10);
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$pdf->AddPage();
|
IPS_LogMessage('Abrechnung', '→ Erstelle Seite für Benutzer: ' . $user['name']);
|
||||||
$pdf->writeHTML("<h2>Rechnung für {$user['name']}</h2>");
|
$pdf->AddPage();
|
||||||
$pdf->writeHTML("<p>{$user['address']}<br>{$user['city']}</p>");
|
|
||||||
$pdf->Ln(4);
|
|
||||||
|
|
||||||
$pdf->writeHTML("<table border='1' cellpadding='5'>
|
// 🔽 Hier fügst du den neuen HTML-Block ein:
|
||||||
<tr style='background-color:#e0e0e0;'>
|
$html = "
|
||||||
<th>Zähler</th>
|
<h2>Rechnung für {$user['name']}</h2>
|
||||||
<th>Typ</th>
|
<p>{$user['address']}<br>{$user['city']}</p>
|
||||||
<th>Start</th>
|
<table border='1' cellpadding='5'>
|
||||||
<th>Ende</th>
|
<tr style='background-color:#e0e0e0;'>
|
||||||
<th>Verbrauch</th>
|
<th>Zähler</th>
|
||||||
<th>Tarif (Rp)</th>
|
<th>Typ</th>
|
||||||
<th>Kosten (CHF)</th>
|
<th>Start</th>
|
||||||
</tr>");
|
<th>Ende</th>
|
||||||
|
<th>Verbrauch</th>
|
||||||
|
<th>Tarif (Rp)</th>
|
||||||
|
<th>Kosten (CHF)</th>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
|
||||||
$total = 0.0;
|
$total = 0.0;
|
||||||
|
foreach ($power as $m) {
|
||||||
|
if ($m['user_id'] != $user['id']) continue;
|
||||||
|
$cost = $this->AddMeterToPDFRow($m, $tariffs, $from, $to, 'Strombezug');
|
||||||
|
$html .= $cost['row'];
|
||||||
|
$total += $cost['value'];
|
||||||
|
}
|
||||||
|
foreach ($water as $m) {
|
||||||
|
if ($m['user_id'] != $user['id']) continue;
|
||||||
|
$type = $m['meter_type'] ?? 'Warmwasser';
|
||||||
|
$cost = $this->AddMeterToPDFRow($m, $tariffs, $from, $to, $type);
|
||||||
|
$html .= $cost['row'];
|
||||||
|
$total += $cost['value'];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($power as $m) {
|
$html .= "</table><h3>Gesamtsumme: " . number_format($total, 2) . " CHF</h3>";
|
||||||
if ($m['user_id'] != $user['id']) continue;
|
$pdf->writeHTML($html);
|
||||||
$total += $this->AddMeterToPDF($pdf, $m, $tariffs, $from, $to, 'Strombezug');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($water as $m) {
|
|
||||||
if ($m['user_id'] != $user['id']) continue;
|
|
||||||
$type = $m['meter_type'] ?? 'Warmwasser';
|
|
||||||
$total += $this->AddMeterToPDF($pdf, $m, $tariffs, $from, $to, $type);
|
|
||||||
}
|
|
||||||
|
|
||||||
$pdf->writeHTML("</table>");
|
|
||||||
$pdf->Ln(5);
|
|
||||||
$pdf->writeHTML("<h3>Gesamtsumme: " . number_format($total, 2) . " CHF</h3>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IPS_LogMessage('Abrechnung', '✅ PDF-Daten fertiggestellt');
|
IPS_LogMessage('Abrechnung', '✅ PDF-Daten fertiggestellt');
|
||||||
@@ -220,4 +226,29 @@ public function GenerateInvoices()
|
|||||||
}
|
}
|
||||||
return floatval(GetValue($varId));
|
return floatval(GetValue($varId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function AddMeterToPDFRow($meter, $tariffs, $from, $to, $type)
|
||||||
|
{
|
||||||
|
$start = $this->GetValueAt($meter['var_consumption'], $from);
|
||||||
|
$end = $this->GetValueAt($meter['var_consumption'], $to);
|
||||||
|
if ($start === null || $end === null) return ['row' => '', 'value' => 0];
|
||||||
|
|
||||||
|
$diff = max(0, $end - $start);
|
||||||
|
$tariffRp = $this->GetTariff($tariffs, $type, $from, $to);
|
||||||
|
$cost = ($tariffRp / 100) * $diff;
|
||||||
|
|
||||||
|
$row = "
|
||||||
|
<tr>
|
||||||
|
<td>{$meter['name']}</td>
|
||||||
|
<td>$type</td>
|
||||||
|
<td>$start</td>
|
||||||
|
<td>$end</td>
|
||||||
|
<td>$diff</td>
|
||||||
|
<td>$tariffRp</td>
|
||||||
|
<td>" . number_format($cost, 2) . "</td>
|
||||||
|
</tr>";
|
||||||
|
|
||||||
|
return ['row' => $row, 'value' => $cost];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user