no message

This commit is contained in:
2026-06-28 13:13:28 +02:00
parent 29a3ac38f9
commit 5446da8c68
+27 -7
View File
@@ -655,16 +655,17 @@ form.onsubmit=function(){
try { try {
$pdfContent = $this->GenerateInvoices(); $pdfContent = $this->GenerateInvoices();
if (!$pdfContent) { if (!$pdfContent) {
echo "❌ Fehler bei der PDF-Erstellung"; echo 'Abrechnung Fehler';
return; return;
} }
$mediaID = $this->GetIDForIdent('InvoicePDF'); $mediaID = $this->GetIDForIdent('InvoicePDF');
IPS_SetMediaContent($mediaID, base64_encode($pdfContent)); IPS_SetMediaContent($mediaID, base64_encode($pdfContent));
SetValue($this->GetIDForIdent('LastResult'), 'Abrechnung vom ' . date('d.m.Y H:i')); SetValue($this->GetIDForIdent('LastResult'), 'Abrechnung erfolgreich erstellt');
echo "✅ PDF erfolgreich erstellt."; echo 'Abrechnung erfolgreich erstellt';
} catch (Throwable $e) { } catch (Throwable $e) {
echo "❌ Ausnahmefehler: " . $e->getMessage(); SetValue($this->GetIDForIdent('LastResult'), 'Abrechnung Fehler');
echo 'Abrechnung Fehler: ' . $e->getMessage();
} }
break; break;
} }
@@ -771,11 +772,16 @@ public function GenerateInvoices()
$periodText = date('d.m.Y', $from) . ' - ' . date('d.m.Y', $to); $periodText = date('d.m.Y', $from) . ' - ' . date('d.m.Y', $to);
$meterText = empty($meterNames) ? '-' : implode("\n", $meterNames); $meterText = empty($meterNames) ? '-' : implode("\n", $meterNames);
$addressText = trim(($user['name'] ?? '') . "\n" . ($user['address'] ?? '') . "\n" . ($user['city'] ?? '')); $addressText = trim(($user['name'] ?? '') . "\n" . ($user['address'] ?? '') . "\n" . ($user['city'] ?? ''));
$infoBoxHeight = max(
32,
18 + $pdf->getStringHeight(82, $meterText),
8 + $pdf->getStringHeight(82, $addressText)
);
$y = $pdf->GetY(); $y = $pdf->GetY();
$pdf->SetFillColor(248, 249, 250); $pdf->SetFillColor(248, 249, 250);
$pdf->Rect(15, $y, 88, 32, 'DF'); $pdf->Rect(15, $y, 88, $infoBoxHeight, 'DF');
$pdf->Rect(107, $y, 88, 32, 'D'); $pdf->Rect(107, $y, 88, $infoBoxHeight, 'D');
$pdf->SetFont('dejavusans', 'B', 8); $pdf->SetFont('dejavusans', 'B', 8);
$pdf->SetXY(18, $y + 3); $pdf->SetXY(18, $y + 3);
$pdf->MultiCell(82, 4, "Abrechnungszeitraum", 0, 'L'); $pdf->MultiCell(82, 4, "Abrechnungszeitraum", 0, 'L');
@@ -795,7 +801,7 @@ public function GenerateInvoices()
$pdf->SetFont('dejavusans', '', 8); $pdf->SetFont('dejavusans', '', 8);
$pdf->SetX(110); $pdf->SetX(110);
$pdf->MultiCell(82, 4, $addressText, 0, 'L'); $pdf->MultiCell(82, 4, $addressText, 0, 'L');
$pdf->SetY($y + 38); $pdf->SetY($y + $infoBoxHeight + 6);
$this->PdfSectionTitle($pdf, 'Elektrizität'); $this->PdfSectionTitle($pdf, 'Elektrizität');
$powerResult = $this->GetCalculatedPowerCosts($user['id']); $powerResult = $this->GetCalculatedPowerCosts($user['id']);
@@ -981,6 +987,13 @@ public function GenerateInvoices()
$this->FormatCurrency($row['rev_zev'], false), $this->FormatCurrency($row['rev_zev'], false),
$this->FormatCurrency($row['subtotal'], false) $this->FormatCurrency($row['subtotal'], false)
]); ]);
$this->PdfTableRow($pdf, [
['width' => 154, 'align' => 'R'],
['width' => 26, 'align' => 'R']
], [
'Zwischentotal ' . $row['name'],
$this->FormatCurrency($row['subtotal'], false)
], true, true);
} }
$this->PdfTableRow($pdf, $amountColumns, [ $this->PdfTableRow($pdf, $amountColumns, [
'Zwischentotal Elektrizität', '', '', '', '', $this->FormatCurrency($result['sum'], false) 'Zwischentotal Elektrizität', '', '', '', '', $this->FormatCurrency($result['sum'], false)
@@ -1015,6 +1028,13 @@ public function GenerateInvoices()
number_format($row['tariff_price'], 3, '.', "'"), number_format($row['tariff_price'], 3, '.', "'"),
$this->FormatCurrency($row['cost'], false) $this->FormatCurrency($row['cost'], false)
]); ]);
$this->PdfTableRow($pdf, [
['width' => 158, 'align' => 'R'],
['width' => 22, 'align' => 'R']
], [
'Zwischentotal ' . $row['name'],
$this->FormatCurrency($row['cost'], false)
], true, true);
} }
} }