<?php use App\Core\Csrf;$h=static fn($v)=>htmlspecialchars((string)$v,ENT_QUOTES,'UTF-8'); ?>
<main class="billing"><header class="billing-head"><div><a href="/public/facturation/voir?id=<?=(int)$invoice['id']?>">← Retour</a><h1>Modifier le brouillon #<?=(int)$invoice['id']?></h1><p>Les réductions restent sous la responsabilité du module Facturation.</p></div></header>
<form method="post" action="/public/facturation/modifier"><?=Csrf::field()?><input type="hidden" name="id" value="<?=(int)$invoice['id']?>"><label>Échéance<input type="date" name="due_date" value="<?=$h($invoice['due_date']??'')?>"></label><div class="table-wrap"><table><tr><th>Libellé</th><th>Montant brut</th><th>Réduction</th><th>Net actuel</th></tr><?php foreach($invoice['lines'] as$l):?><tr><td><input name="description[<?=(int)$l['id']?>]" value="<?=$h($l['description'])?>" required></td><td><input type="number" step="0.01" min="0" name="gross_amount[<?=(int)$l['id']?>]" value="<?=$h($l['gross_amount'])?>" required></td><td><input type="number" step="0.01" min="0" name="discount_amount[<?=(int)$l['id']?>]" value="<?=$h($l['discount_amount'])?>"></td><td><?=number_format((float)$l['net_amount'],2,',',' ')?> €</td></tr><?php endforeach?></table></div><button class="btn">Enregistrer les modifications</button></form></main>
