<?php use App\Core\Permission; ?>
<link rel="stylesheet" href="/public/assets/css/cda-accounting-ui-964.css?v=9.6.4">
<main class="accounting-page">
<section class="cda-hero accounting-hero"><div><span class="cda-eyebrow">AXIOM Studio · Traçabilité</span><h2>Journal de caisse</h2><p>Mouvements d’espèces, avances, remises, remboursements et dépôts.</p></div><div class="cda-actionbar"><a class="cda-btn cda-btn-secondary" href="/public/comptabilite/tresorerie">← Trésorerie</a></div></section>
<section class="cda-panel accounting-panel"><form class="journal-filter" method="get"><label>Du<input type="date" name="from" value="<?=htmlspecialchars($from)?>"></label><label>Au<input type="date" name="to" value="<?=htmlspecialchars($to)?>"></label><label>Caisse<select name="register_id"><option value="0">Toutes les caisses</option><?php foreach($registers as $r):?><option value="<?=$r['id']?>" <?=$registerId==(int)$r['id']?'selected':''?>><?=htmlspecialchars($r['name'])?></option><?php endforeach?></select></label><button class="cda-btn accounting-btn-primary">Afficher</button><a class="cda-btn accounting-btn-secondary" href="/public/comptabilite/tresorerie/journal.csv?from=<?=urlencode($from)?>&to=<?=urlencode($to)?>&register_id=<?=$registerId?>">Exporter CSV</a></form></section>
<section class="cda-panel accounting-panel"><div class="cda-panel-head"><div><span class="cda-eyebrow">Période sélectionnée</span><h3>Mouvements</h3></div><span class="accounting-count"><?=count($items)?></span></div><div class="accounting-table-wrap"><table class="accounting-table"><thead><tr><th>Date</th><th>Caisse</th><th>Type</th><th>Libellé</th><th>Adhérent</th><th>Montant</th><th>État</th></tr></thead><tbody><?php if(!$items):?><tr><td colspan="7" class="accounting-table-empty">Aucun mouvement sur cette période.</td></tr><?php endif?><?php foreach($items as $i):?><tr><td><?=htmlspecialchars($i['movement_date'])?></td><td><?=htmlspecialchars($i['register_name']??'—')?></td><td><span class="studio-badge"><?=htmlspecialchars($i['movement_type'])?></span></td><td><?=htmlspecialchars($i['label'])?></td><td><?=htmlspecialchars($i['client_label']??'—')?></td><td><strong><?=number_format((float)$i['amount'],2,',',' ')?> €</strong></td><td><?=htmlspecialchars($i['status'])?></td></tr><?php endforeach?></tbody></table></div></section>
<?php if(Permission::can('facturation.accounting')):?><section class="cda-panel accounting-panel"><div class="cda-panel-head"><div><span class="cda-eyebrow">Comptabilité</span><h3>Exporter toutes les écritures</h3></div></div><form class="journal-filter" method="get" action="/public/comptabilite/ecritures.csv"><label>Du<input type="date" name="from" value="<?=htmlspecialchars($from)?>"></label><label>Au<input type="date" name="to" value="<?=htmlspecialchars($to)?>"></label><label>Journal<select name="journal"><option value="">Tous</option><option>VE</option><option>CA</option><option>CM</option><option>CH</option><option>OD</option></select></label><button class="cda-btn accounting-btn-primary">Télécharger pour Excel</button></form></section><?php endif?>
</main>
