Add MySQL schema dump for phpMyAdmin
This commit is contained in:
115
resources/views/documents/invoice.php
Normal file
115
resources/views/documents/invoice.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/** @var array $invoice */
|
||||
$invoice = $invoice ?? [];
|
||||
$lineItems = $invoice['items'] ?? [];
|
||||
$customer = $invoice['customer'] ?? [];
|
||||
$invoiceNumber = $invoice['number'] ?? '';
|
||||
$title = 'Faktura #' . ($invoiceNumber !== '' ? $invoiceNumber : 'Udkast');
|
||||
ob_start();
|
||||
?>
|
||||
<h2 style="margin-top:0;">Faktura <?= htmlspecialchars($invoiceNumber !== '' ? $invoiceNumber : 'Udkast') ?></h2>
|
||||
<p style="margin:0 0 16px; color:rgba(148,163,184,0.85);">
|
||||
Fakturadato: <?= htmlspecialchars($invoice['issued_at'] ?? date('Y-m-d')) ?> ·
|
||||
Forfaldsdato: <?= htmlspecialchars($invoice['due_at'] ?? 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>Reference</th>
|
||||
<td><?= htmlspecialchars($invoice['reference'] ?? 'Angiv reference') ?></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 fakturaen.</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) ($invoice['vat_rate'] ?? 25);
|
||||
$vatAmount = $subtotal * ($vatRate / 100);
|
||||
$total = $subtotal + $vatAmount;
|
||||
$paid = (float) ($invoice['paid'] ?? 0);
|
||||
$balance = $total - $paid;
|
||||
?>
|
||||
<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">Total</td>
|
||||
<td><?= number_format($total, 2, ',', '.') ?> kr.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Betalt</td>
|
||||
<td><?= number_format($paid, 2, ',', '.') ?> kr.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" style="font-weight:600;">Restbeløb</td>
|
||||
<td style="font-weight:700; color:#facc15;">
|
||||
<?= number_format($balance, 2, ',', '.') ?> kr.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php if (!empty($invoice['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($invoice['notes'])) ?></p>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($invoice['payment_details'])): ?>
|
||||
<section style="margin-top:32px;">
|
||||
<h3 style="margin-bottom:8px;">Betalingsinformation</h3>
|
||||
<p style="color:rgba(148,163,184,0.85);"><?= nl2br(htmlspecialchars($invoice['payment_details'])) ?></p>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$content = ob_get_clean();
|
||||
include base_path('resources/views/documents/layout.php');
|
||||
Reference in New Issue
Block a user