<?php $pageTitle='General Ledger'; ?>
<div class="page-heading"><div><p class="eyebrow">Double-Entry Accounting</p><h1>Journal Entries</h1><p>Posted entries cannot be silently deleted; corrections should be recorded as reversals.</p></div></div><div class="content-grid two-col"><form class="panel form-stack" method="post" action="<?= url('/accounting/journals/store') ?>"><?= csrf_field() ?><h2>Manual Journal</h2><div class="form-grid two"><label><span>Entry Number</span><input name="entry_number" placeholder="Auto if blank"></label><label><span>Date</span><input type="date" name="entry_date" value="<?= date('Y-m-d') ?>"></label></div><label><span>Memo</span><input name="memo"></label><div id="journal-lines"><?php for($i=0;$i<2;$i++):?><div class="line-item-row journal-line"><select name="account_id[]"><?php foreach($accounts as $a):?><option value="<?= e((string)$a['id']) ?>"><?= e($a['code'].' '.$a['name']) ?></option><?php endforeach;?></select><input name="line_description[]" placeholder="Description"><input type="number" step="0.01" name="debit[]" placeholder="Debit"><input type="number" step="0.01" name="credit[]" placeholder="Credit"></div><?php endfor;?></div><button class="btn btn-primary">Post Balanced Entry</button></form><div class="panel"><div class="table-wrap"><table><thead><tr><th>Entry</th><th>Date</th><th>Source</th><th>Memo</th><th>Debit</th><th>Credit</th></tr></thead><tbody><?php foreach($journals as $j):?><tr><td><strong><?= e($j['entry_number']) ?></strong></td><td><?= e(date_display($j['entry_date'])) ?></td><td><?= e(readable_status($j['source_type']??'manual')) ?></td><td><?= e($j['memo']??'') ?></td><td><?= money($j['total_debit']) ?></td><td><?= money($j['total_credit']) ?></td></tr><?php endforeach;?></tbody></table></div></div></div>
