98 lines
4.4 KiB
PHP
98 lines
4.4 KiB
PHP
<?php
|
|
/** @var array $offer */
|
|
$offer = $offer ?? [];
|
|
$lineItems = $offer['items'] ?? [];
|
|
$customer = $offer['customer'] ?? [];
|
|
$offerNumber = $offer['number'] ?? '';
|
|
$title = 'Tilbud #' . ($offerNumber !== '' ? $offerNumber : 'Udkast');
|
|
ob_start();
|
|
?>
|
|
<h2 style="margin-top:0;">Tilbud <?= htmlspecialchars($offerNumber !== '' ? $offerNumber : 'Udkast') ?></h2>
|
|
<p style="margin:0 0 16px; color:rgba(148,163,184,0.85);">
|
|
Udstedt: <?= htmlspecialchars($offer['issued_at'] ?? date('Y-m-d')) ?> ·
|
|
Gyldig til: <?= htmlspecialchars($offer['valid_until'] ?? date('Y-m-d', strtotime('+14 days'))) ?>
|
|
</p>
|
|
<table class="meta">
|
|
<tr>
|
|
<th style="width:180px;">Kunde</th>
|
|
<td><?= htmlspecialchars($customer['name'] ?? 'Angiv kunde') ?></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Kontaktperson</th>
|
|
<td><?= htmlspecialchars($customer['contact'] ?? $customer['email'] ?? 'Angiv kontakt') ?></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Projekt</th>
|
|
<td><?= htmlspecialchars($offer['project'] ?? 'Angiv projekt') ?></td>
|
|
</tr>
|
|
</table>
|
|
<table style="width:100%; border-collapse:collapse;">
|
|
<thead>
|
|
<tr style="text-align:left; color:rgba(226,232,240,0.85);">
|
|
<th style="padding:12px 0; border-bottom:1px solid rgba(148,163,184,0.25);">Beskrivelse</th>
|
|
<th style="padding:12px 0; border-bottom:1px solid rgba(148,163,184,0.25); width:100px;">Antal</th>
|
|
<th style="padding:12px 0; border-bottom:1px solid rgba(148,163,184,0.25); width:140px;">Enhedspris</th>
|
|
<th style="padding:12px 0; border-bottom:1px solid rgba(148,163,184,0.25); width:140px;">Beløb</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($lineItems)): ?>
|
|
<tr>
|
|
<td colspan="4" style="padding:24px 0; color:rgba(148,163,184,0.8); text-align:center;">Tilføj linjeelementer for at færdiggøre tilbuddet.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($lineItems as $item): ?>
|
|
<?php $qty = (float) ($item['quantity'] ?? 0); $price = (float) ($item['unit_price'] ?? 0); ?>
|
|
<tr>
|
|
<td style="padding:16px 0; border-bottom:1px solid rgba(148,163,184,0.12);">
|
|
<strong><?= htmlspecialchars($item['name'] ?? 'Ydelse') ?></strong><br>
|
|
<span style="color:rgba(148,163,184,0.75); font-size:0.9rem;">
|
|
<?= nl2br(htmlspecialchars($item['description'] ?? 'Beskriv ydelsen.')) ?>
|
|
</span>
|
|
</td>
|
|
<td style="padding:16px 0; border-bottom:1px solid rgba(148,163,184,0.12);">
|
|
<?= number_format($qty, 2, ',', '.') ?>
|
|
</td>
|
|
<td style="padding:16px 0; border-bottom:1px solid rgba(148,163,184,0.12);">
|
|
<?= number_format($price, 2, ',', '.') ?> kr.
|
|
</td>
|
|
<td style="padding:16px 0; border-bottom:1px solid rgba(148,163,184,0.12); font-weight:600;">
|
|
<?= number_format($qty * $price, 2, ',', '.') ?> kr.
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
<div class="totals">
|
|
<?php
|
|
$subtotal = array_reduce($lineItems, fn ($carry, $item) => $carry + (float) ($item['quantity'] ?? 0) * (float) ($item['unit_price'] ?? 0), 0.0);
|
|
$vatRate = (float) ($offer['vat_rate'] ?? 25);
|
|
$vatAmount = $subtotal * ($vatRate / 100);
|
|
$total = $subtotal + $vatAmount;
|
|
?>
|
|
<table>
|
|
<tr>
|
|
<td class="label">Subtotal</td>
|
|
<td><?= number_format($subtotal, 2, ',', '.') ?> kr.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="label">Moms (<?= number_format($vatRate, 0) ?>%)</td>
|
|
<td><?= number_format($vatAmount, 2, ',', '.') ?> kr.</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="label" style="font-weight:600;">Total</td>
|
|
<td style="font-weight:700;"><?= number_format($total, 2, ',', '.') ?> kr.</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<?php if (!empty($offer['notes'])): ?>
|
|
<section style="margin-top:32px;">
|
|
<h3 style="margin-bottom:8px;">Bemærkninger</h3>
|
|
<p style="color:rgba(148,163,184,0.85);"><?= nl2br(htmlspecialchars($offer['notes'])) ?></p>
|
|
</section>
|
|
<?php endif; ?>
|
|
<?php
|
|
$content = ob_get_clean();
|
|
include base_path('resources/views/documents/layout.php');
|