<?php $pageTitle='New Expense'; ?>
<div class="page-heading"><div><p class="eyebrow">Accounting</p><h1>Record Expense</h1><p>Attach the receipt and link the cost to the correct operational record.</p></div><a class="btn btn-light" href="<?= url('/accounting/expenses') ?>">Back</a></div>
<form class="panel form-stack" method="post" action="<?= url('/accounting/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 three"><label><span>Expense 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>Vendor</span><select name="vendor_id"><option value="">Optional</option><?php foreach($vendors as $v):?><option value="<?= e((string)$v['id']) ?>"><?= e($v['company_name']) ?></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" min="0" name="tax_amount" value="0"></label><label><span>Payment Method</span><input name="payment_method" placeholder="Cash, card, fuel card"></label>
<label><span>Load</span><select name="load_id"><option value="">None</option><?php foreach($loads as $r):?><option value="<?= e((string)$r['id']) ?>"><?= e($r['load_number']) ?></option><?php endforeach;?></select></label><label><span>Driver</span><select name="driver_id"><option value="">None</option><?php foreach($drivers as $r):?><option value="<?= e((string)$r['id']) ?>"><?= e($r['name']) ?></option><?php endforeach;?></select></label><label><span>Truck</span><select name="truck_id"><option value="">None</option><?php foreach($trucks as $r):?><option value="<?= e((string)$r['id']) ?>"><?= e($r['unit_number']) ?></option><?php endforeach;?></select></label><label><span>Trailer</span><select name="trailer_id"><option value="">None</option><?php foreach($trailers as $r):?><option value="<?= e((string)$r['id']) ?>"><?= e($r['trailer_number']) ?></option><?php endforeach;?></select></label><label><span>Border Crossing</span><select name="border_crossing_id"><option value="">None</option><?php foreach($crossings as $r):?><option value="<?= e((string)$r['id']) ?>"><?= e($r['crossing_number']) ?></option><?php endforeach;?></select></label><label><span>Receipt</span><input type="file" name="receipt" accept="image/*,application/pdf" capture="environment"></label></div>
<label><span>Location / Address</span><input name="location_address" data-location-address></label><label><span>Description</span><textarea name="description" rows="4"></textarea></label><div class="form-actions"><button class="btn btn-primary">Save Expense</button></div></form>
