<?php $pageTitle='My Expenses'; ?>
<div class="driver-page"><div class="page-heading"><div><p class="eyebrow">Driver Portal</p><h1>Expenses & Receipts</h1><p>Submit fuel, toll, parking, border, challan, and trip expenses from your phone.</p></div><a class="btn btn-light" href="<?= url('/driver/finances') ?>">Payments</a></div>
<form class="panel form-stack" method="post" action="<?= url('/driver/expenses/store') ?>" enctype="multipart/form-data" data-location-form><?= csrf_field() ?><input type="hidden" name="latitude" data-latitude><input type="hidden" name="longitude" data-longitude><div class="form-grid two"><label><span>Date</span><input type="date" name="expense_date" value="<?= date('Y-m-d') ?>" required></label><label><span>Category</span><select name="category_id" required><option value="">Select</option><?php foreach($categories as$c):?><option value="<?= e((string)$c['id']) ?>"><?= e($c['name']) ?></option><?php endforeach;?></select></label><label><span>Load</span><select name="load_id"><option value="">Not load-specific</option><?php foreach($loads as$l):?><option value="<?= e((string)$l['id']) ?>"><?= e($l['load_number']) ?></option><?php endforeach;?></select></label><label><span>Amount</span><input type="number" step="0.01" min="0" name="amount" required></label><label><span>Tax</span><input type="number" step="0.01" name="tax_amount" value="0"></label><label><span>Payment Method</span><input name="payment_method" placeholder="Cash / card / fuel card"></label></div><label><span>Receipt / Challan Photo</span><input type="file" name="receipt" accept="image/*,application/pdf" capture="environment"></label><label><span>Location</span><input name="location_address" data-location-address placeholder="Auto or manual"></label><label><span>Description</span><textarea name="description" rows="3" placeholder="Receipt number, gallons, challan details, or notes"></textarea></label><button class="btn btn-primary btn-block">Submit Expense</button></form>
<div class="panel"><div class="panel-header"><div><p class="eyebrow">History</p><h2>My Submitted Expenses</h2></div></div><div class="mobile-card-list"><?php foreach($expenses as$x):?><div class="mobile-record-card"><div><strong><?= e($x['expense_number'].' · '.($x['category_name']??'Expense')) ?></strong><span><?= e(date_display($x['expense_date'])) ?> · <?= money((float)$x['amount']+(float)$x['tax_amount']) ?></span></div><span class="badge badge-<?= status_class($x['status']) ?>"><?= e(readable_status($x['status'])) ?></span></div><?php endforeach;?><?php if(!$expenses):?><p class="empty">No expenses submitted.</p><?php endif;?></div></div></div>
