diff --git a/Abrechnung/module.php b/Abrechnung/module.php index 8549a33..4a2705b 100644 --- a/Abrechnung/module.php +++ b/Abrechnung/module.php @@ -655,16 +655,17 @@ form.onsubmit=function(){ try { $pdfContent = $this->GenerateInvoices(); if (!$pdfContent) { - echo "❌ Fehler bei der PDF-Erstellung"; + echo 'Abrechnung Fehler'; return; } $mediaID = $this->GetIDForIdent('InvoicePDF'); IPS_SetMediaContent($mediaID, base64_encode($pdfContent)); - SetValue($this->GetIDForIdent('LastResult'), 'Abrechnung vom ' . date('d.m.Y H:i')); - echo "✅ PDF erfolgreich erstellt."; + SetValue($this->GetIDForIdent('LastResult'), 'Abrechnung erfolgreich erstellt'); + echo 'Abrechnung erfolgreich erstellt'; } catch (Throwable $e) { - echo "❌ Ausnahmefehler: " . $e->getMessage(); + SetValue($this->GetIDForIdent('LastResult'), 'Abrechnung Fehler'); + echo 'Abrechnung Fehler: ' . $e->getMessage(); } break; } @@ -771,11 +772,16 @@ public function GenerateInvoices() $periodText = date('d.m.Y', $from) . ' - ' . date('d.m.Y', $to); $meterText = empty($meterNames) ? '-' : implode("\n", $meterNames); $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(); $pdf->SetFillColor(248, 249, 250); - $pdf->Rect(15, $y, 88, 32, 'DF'); - $pdf->Rect(107, $y, 88, 32, 'D'); + $pdf->Rect(15, $y, 88, $infoBoxHeight, 'DF'); + $pdf->Rect(107, $y, 88, $infoBoxHeight, 'D'); $pdf->SetFont('dejavusans', 'B', 8); $pdf->SetXY(18, $y + 3); $pdf->MultiCell(82, 4, "Abrechnungszeitraum", 0, 'L'); @@ -795,7 +801,7 @@ public function GenerateInvoices() $pdf->SetFont('dejavusans', '', 8); $pdf->SetX(110); $pdf->MultiCell(82, 4, $addressText, 0, 'L'); - $pdf->SetY($y + 38); + $pdf->SetY($y + $infoBoxHeight + 6); $this->PdfSectionTitle($pdf, 'Elektrizität'); $powerResult = $this->GetCalculatedPowerCosts($user['id']); @@ -981,6 +987,13 @@ public function GenerateInvoices() $this->FormatCurrency($row['rev_zev'], 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, [ 'Zwischentotal Elektrizität', '', '', '', '', $this->FormatCurrency($result['sum'], false) @@ -1015,6 +1028,13 @@ public function GenerateInvoices() number_format($row['tariff_price'], 3, '.', "'"), $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); } }