<?php $pageTitle='Expenses'; ?>
<div class="page-heading"><div><p class="eyebrow">Accounting</p><h1>Expenses & Reimbursements</h1><p>Review receipts, approve spending, and connect every cost to a load, driver, or truck.</p></div><a class="btn btn-primary" href="<?= url('/accounting/expenses/create') ?>">New Expense</a></div>
<?php require app_path('Views/components/search_header.php'); ?>
<div class="panel"><div class="table-wrap"><table><thead><tr><th>Expense</th><th>Category / Vendor</th><th>Related</th><th>Submitted By</th><th>Amount</th><th>Status</th><th>Action</th></tr></thead><tbody><?php foreach($expenses as $x):?><tr><td><strong><?= e($x['expense_number']) ?></strong><br><small><?= e(date_display($x['expense_date'])) ?> · <?= e($x['payment_method']??'-') ?></small></td><td><?= e($x['category_name']??'Other') ?><br><small><?= e($x['vendor_name']??'-') ?></small></td><td><?= e($x['load_number']?'Load '.$x['load_number']:'-') ?><br><small><?= e($x['driver_name']??$x['unit_number']??'') ?></small></td><td><?= e($x['driver_name']??'Team') ?></td><td><strong><?= money((float)$x['amount']+(float)$x['tax_amount']) ?></strong></td><td><span class="badge badge-<?= status_class($x['status']) ?>"><?= e(readable_status($x['status'])) ?></span></td><td><?php if(can('accounting.manage')):?><form method="post" action="<?= url('/accounting/expenses/status') ?>" class="inline-form"><?= csrf_field() ?><input type="hidden" name="id" value="<?= e((string)$x['id']) ?>"><select name="status"><option>submitted</option><option>under_review</option><option>approved</option><option>rejected</option><option>reimbursed</option><option>posted</option></select><button class="btn btn-light btn-sm">Update</button></form><?php endif;?></td></tr><?php endforeach;?><?php if(!$expenses):?><tr><td colspan="7" class="empty">No expenses found.</td></tr><?php endif;?></tbody></table></div></div>
