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['offerNumberLabel'] ?> | = htmlspecialchars($offerNumber) ?> - v= isset($offer->version) ? $offer->version : 1 ?> | = $text['offerDateLabel'] ?> | = $formattedOfferDate ?> |
| = $text['editorLabel'] ?> | = htmlspecialchars($offerEditorName) ?> | = $text['validUntilLabel'] ?> | = $formattedValidUntil ?> |
| = $text['purpose'] ?> | = nl2br(htmlspecialchars($offer->purpose)) ?> | ||
| = $text['table']['pos'] ?> | = $text['table']['article'] ?> | = $text['table']['amount'] ?> | = $text['table']['unit'] ?> | = $text['table']['unitPrice'] ?> | = $text['table']['discount'] ?> | = $text['table']['totalPrice'] ?> |
|---|---|---|---|---|---|---|
| = htmlspecialchars($isAlternativeGroup ? $text['alternativeHeader'] : $groupName) ?> | ||||||
| = $posCounter ?> |
= htmlspecialchars($p['articleText']) ?>
= nl2br(htmlspecialchars($p['articleDescription'])) ?>
= nl2br(htmlspecialchars($p['comment'])) ?>
|
= number_format($p['amount'], 2, ',', '.') ?> | = htmlspecialchars($p['articleUnit']) ?> | = formatPrice($p['price'], '€') ?> | = htmlspecialchars($p['discount'] . '%') ?> | = formatPrice($p['totalPrice'], '€') ?> |