From 353b8afb3d6678522fb0cc7dac3bfe3c2feda387 Mon Sep 17 00:00:00 2001 From: DanielHaefliger Date: Fri, 5 Dec 2025 11:59:01 +0100 Subject: [PATCH] no message --- Abrechnung/form.json | 11 +++++++++++ Abrechnung/module.php | 25 ++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Abrechnung/form.json b/Abrechnung/form.json index d5fc2f5..04d47c5 100644 --- a/Abrechnung/form.json +++ b/Abrechnung/form.json @@ -4,6 +4,17 @@ "type": "Label", "caption": "🧾 Abrechnungseinstellungen" }, + { + "type": "Image", + "name": "Logo", + "caption": "Firmenlogo" + }, + { + "type": "ValidationTextBox", + "name": "FooterText", + "caption": "Fusszeile" + }, + { diff --git a/Abrechnung/module.php b/Abrechnung/module.php index 7826d2c..340239c 100644 --- a/Abrechnung/module.php +++ b/Abrechnung/module.php @@ -3,6 +3,19 @@ declare(strict_types=1); include_once __DIR__ . '/libs/vendor/autoload.php'; // TCPDF via Composer + +class PDFWithFooter extends TCPDF { + public $footerText = ''; + + public function Footer() { + $this->SetY(-15); + $this->SetFont('dejavusans', '', 8); + $this->Cell(0, 10, $this->footerText, 0, 0, 'C'); + } +} + + + class Abrechnung extends IPSModule { public function Create() @@ -13,6 +26,8 @@ class Abrechnung extends IPSModule $this->RegisterPropertyString('PowerMeters', '[]'); $this->RegisterPropertyString('WaterMeters', '[]'); $this->RegisterPropertyString('Tariffs', '[]'); + $this->RegisterPropertyString('Logo', ''); + $this->RegisterPropertyString('FooterText', 'Belevo AG • 6122 Menznau • www.belevo.ch'); $this->RegisterVariableInteger('FromDate', 'Startdatum', '~UnixTimestamp', 1); $this->RegisterVariableInteger('ToDate', 'Enddatum', '~UnixTimestamp', 2); @@ -92,7 +107,8 @@ class Abrechnung extends IPSModule // Stromkosten einmal für alle User berechnen (15-Minuten-Logik) $this->CalculateAllPowerCosts($power, $tariffs, $from, $to); - $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); + $pdf = new PDFWithFooter('P', 'mm', 'A4', true, 'UTF-8', false); + $pdf->footerText = $this->ReadPropertyString('FooterText'); $pdf->SetCreator('IPSymcon Abrechnung'); $pdf->SetMargins(15, 15, 15); $pdf->SetAutoPageBreak(true, 20); @@ -107,6 +123,13 @@ class Abrechnung extends IPSModule private function BuildUserInvoice($pdf, $user, $power, $water, $tariffs, $from, $to) { + $logoData = $this->ReadPropertyString('Logo'); +if ($logoData !== '') { + $img = base64_decode($logoData); + $pdf->Image('@' . $img, 15, 10, 40); + $pdf->Ln(25); +} + $pdf->AddPage(); // Kopfbereich