createPDFAction */ // --- Helper Functions --- function formatPrice($price, $currency = '€') { return number_format($price, 2, ',', '.') . ' ' . $currency; } // --- Text Elements --- $texts = [ 'DE' => [ 'title' => 'Angebot', 'offerNumberLabel' => 'Angebotsnr.:', 'offerDateLabel' => 'Datum:', 'editorLabel' => 'Sachbearbeiter:', 'validUntilLabel' => 'Gültig bis:', 'table' => [ 'pos' => 'Pos', 'article' => 'Artikel / Beschreibung', 'amount' => 'Menge', 'unit' => 'Einheit', 'unitPrice' => 'Einzelpreis', 'discount' => 'Rabatt', 'totalPrice' => 'Gesamtpreis' ], 'summary' => [ 'subTotal' => 'Nettobetrag', 'discount' => 'Rabatt', 'vatFormatted' => 'zzgl. {VAT_RATE}% MwSt.', 'total' => 'Gesamtbetrag', 'alternativeTotal' => 'Summe Alternativpositionen' ], 'purpose' => 'Zweck / Projekt', 'alternativeHeader' => 'Alternativpositionen', 'notes' => 'Anmerkungen & Konditionen', 'defaultOfferText' => 'Vielen Dank für Ihre Anfrage. Es gelten unsere Allgemeinen Geschäftsbedingungen.', ] ]; $lang = 'DE'; $text = $texts[$lang]; // --- Calculations --- $discountAmount = 0; $subTotalAfterDiscount = $subTotal; $vatAmount = 0; if (isset($offer->totalDiscount) && $offer->totalDiscount > 0) { $discountPercentage = $offer->totalDiscount; $discountAmount = round(($subTotal * $discountPercentage) / 100, 2, PHP_ROUND_HALF_UP); $subTotalAfterDiscount = round($subTotal - $discountAmount, 2, PHP_ROUND_HALF_UP); } $grandTotal = $subTotalAfterDiscount; if ($includeTax) { $vatAmount = round($subTotalAfterDiscount * $vatRate, 2, PHP_ROUND_HALF_UP); $grandTotal = round($subTotalAfterDiscount + $vatAmount, 2, PHP_ROUND_HALF_UP); } $formattedOfferDate = date("d.m.Y", $offerDate); $validityDays = isset($validity) ? (int)$validity : 31; // Use versionDate (when this version was created) for validity calculation, fallback to offerDate $validityBaseDate = isset($versionDate) ? $versionDate : $offerDate; $formattedValidUntil = date("d.m.Y", strtotime("+$validityDays days", $validityBaseDate)); ?> <?= $text['title'] ?> <?= $offerNumber ?>

purpose)): ?>
- vversion) ? $offer->version : 1 ?>
purpose)) ?>
$positions): $isAlternativeGroup = ($groupName === 'Alternativpositionen'); if (!empty($groupName)): ?>