<!DOCTYPE html><html lang="nl"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Nieuwe Factuur — Mek-Tech</title><link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet"><link rel="stylesheet" href="/css/style.css"><link rel="stylesheet" href="/css/dynamic.css"><link rel="icon" href="/img/favicon.svg"><script src="https://unpkg.com/lucide@latest"></script></head><body>
<nav class="navbar"><div class="nav-inner"><a href="/" class="nav-brand"><img src="/img/logo.svg" class="nav-logo" alt="Mek-Tech"></a><div style="display:flex;align-items:center;gap:.4rem"><a href="/" class="nav-icon-btn" title="Dashboard"><i data-lucide="layout-dashboard" style="width:15px;height:15px"></i> Dashboard</a><button class="theme-toggle" id="themeToggle" onclick="toggleTheme()"></button><a href="/auth/logout" class="nav-icon-btn" style="color:var(--red)"><i data-lucide="log-out" style="width:15px;height:15px"></i> Uitloggen</a></div></div></nav>
<div class="container" style="max-width:800px">
<a href="javascript:history.back()" class="back-link"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 18 9 12 15 6"/></svg> Terug</a>
<div class="page-header"></a>
<h1>Nieuwe Factuur</h1></div>
<% if (error) { %><div class="alert alert-error"><%= error %></div><% } %>
<form method="POST" action="/invoices/new">
<div class="form-card">
<div class="form-grid">
<div class="field"><label>Cliënt</label><select name="client_id" required><option value="">Kies cliënt...</option><% clients.forEach(function(c){ %><option value="<%= c.id %>" <%= (selectedClient && String(selectedClient) === String(c.id)) ? 'selected' : '' %>><%= c.name %></option><% }) %></select></div>
<div class="field"><label>Factuurdatum</label><input type="date" name="date" value="<%= new Date().toISOString().split('T')[0] %>"></div>
<div class="field"><label>Vervaldatum</label><input type="date" name="due_date"></div>
</div>
</div>
<div class="form-card" style="margin-top:.75rem">
<h3 style="font-size:.8rem;color:var(--text-muted);margin-bottom:.5rem">Factuurregels</h3>
<div id="items"><div class="item-row" style="display:flex;gap:.35rem;margin-bottom:.35rem"><input type="text" name="items[0][description]" placeholder="Omschrijving" style="flex:1"><input type="number" name="items[0][quantity]" placeholder="Aantal" value="1" style="width:70px" step="0.01"><input type="number" name="items[0][unit_price]" placeholder="Prijs" style="width:100px" step="0.01"><button type="button" class="btn-small" onclick="this.parentElement.remove()">✕</button></div></div>
<button type="button" class="btn btn-secondary" onclick="addItem()" style="margin-top:.35rem">+ Regel toevoegen</button>
</div>
<div class="form-card" style="margin-top:.75rem">
<div class="form-grid">
<div class="field"><label>Subtotaal</label><input type="number" name="subtotal" step="0.01" value="0"></div>
<div class="field"><label>BTW</label><input type="number" name="tax" step="0.01" value="0"></div>
<div class="field" style="grid-column:1/-1"><label>Notities</label><textarea name="notes" rows="3"></textarea></div>
</div>
</div>
<div class="form-actions"><button class="btn btn-primary">Factuur aanmaken</button><a href="/invoices" class="btn btn-secondary">Annuleren</a></div>
</form></div>
<script>function addItem(){var i=document.querySelectorAll('.item-row').length;var d=document.createElement('div');d.className='item-row';d.style.cssText='display:flex;gap:.35rem;margin-bottom:.35rem';d.innerHTML='<input type="text" name="items['+i+'][description]" placeholder="Omschrijving" style="flex:1"><input type="number" name="items['+i+'][quantity]" placeholder="Aantal" value="1" style="width:70px" step="0.01"><input type="number" name="items['+i+'][unit_price]" placeholder="Prijs" style="width:100px" step="0.01"><button type="button" class="btn-small" onclick="this.parentElement.remove()">✕</button>';document.getElementById('items').appendChild(d)}</script>
<script src="/js/theme.js"></script><script>lucide.createIcons()</script></body></html>
