<?php $pageTitle='Vendor Bills'; ?>
<div class="page-heading"><div><p class="eyebrow">Accounts Payable</p><h1>Vendor Bills</h1></div></div><div class="content-grid two-col"><form class="panel form-stack" method="post" action="<?= url('/accounting/bills/store') ?>"><?= csrf_field() ?><h2>Record Bill</h2><div class="form-grid two"><label><span>Bill Number</span><input name="bill_number" placeholder="Auto if blank"></label><label><span>Vendor</span><select name="vendor_id" required><?php foreach($vendors as $v):?><option value="<?= e((string)$v['id']) ?>"><?= e($v['company_name']) ?></option><?php endforeach;?></select></label><label><span>Bill Date</span><input type="date" name="bill_date" value="<?= date('Y-m-d') ?>"></label><label><span>Due Date</span><input type="date" name="due_date"></label><label><span>Subtotal</span><input type="number" step="0.01" name="subtotal" required></label><label><span>Tax</span><input type="number" step="0.01" name="tax" value="0"></label></div><label><span>Notes</span><textarea name="notes"></textarea></label><button class="btn btn-primary">Save Bill</button></form><div class="panel"><div class="table-wrap"><table><thead><tr><th>Bill</th><th>Vendor</th><th>Due</th><th>Balance</th><th>Payment</th></tr></thead><tbody><?php foreach($bills as $b):?><tr><td><strong><?= e($b['bill_number']) ?></strong><br><small><?= e(readable_status($b['status'])) ?></small></td><td><?= e($b['company_name']) ?></td><td><?= e(date_display($b['due_date'])) ?></td><td><?= money($b['balance_due']) ?></td><td><?php if((float)$b['balance_due']>0):?><form method="post" action="<?= url('/accounting/bills/pay') ?>" class="inline-form"><?= csrf_field() ?><input type="hidden" name="id" value="<?= e((string)$b['id']) ?>"><input type="number" step="0.01" name="amount" max="<?= e((string)$b['balance_due']) ?>" placeholder="Amount" required><input type="date" name="payment_date" value="<?= date('Y-m-d') ?>"><select name="bank_account_id"><option value="">No account</option><?php foreach($accounts as $a):?><option value="<?= e((string)$a['id']) ?>"><?= e($a['account_name']) ?></option><?php endforeach;?></select><button class="btn btn-light btn-sm">Pay</button></form><?php endif;?></td></tr><?php endforeach;?></tbody></table></div></div></div>
