@extends('admin.layouts.app')
@section('title','Accounts & Finance')
@section('content')
<div class="page-shell">
    <div class="page-head"><div><h1 class="page-title">Accounts & Finance Module</h1><div class="page-subtitle">Cash flow, manual receive/payment and summary</div></div></div>
    <div class="grid-4">
        <div class="stat"><div class="k">Sales</div><div class="v">{{ number_format($totals['sales'],2) }}</div></div>
        <div class="stat"><div class="k">Receives</div><div class="v">{{ number_format($totals['receives'],2) }}</div></div>
        <div class="stat"><div class="k">Supplier Payments</div><div class="v">{{ number_format($totals['supplier_payments'],2) }}</div></div>
        <div class="stat"><div class="k">Expenses</div><div class="v">{{ number_format($totals['expenses'],2) }}</div></div>
    </div>
    <form method="POST" action="{{ route('admin.accounts.store') }}" class="card panel-tight grid-3">@csrf
        <div><label>Date</label><input type="date" name="txn_date" value="{{ now()->toDateString() }}" required></div>
        <div><label>Type</label><select name="type"><option>Customer Receive</option><option>Supplier Payment</option><option>Expense</option><option>Income</option><option>Bank Deposit</option><option>Bank Withdraw</option></select></div>
        <div><label>Amount</label><input type="number" step="0.01" min="0.01" name="amount" required></div>
        <div><label>Category</label><input type="text" name="category"></div>
        <div><label>Reference</label><input type="text" name="reference_no"></div>
        <div><label>Party Name</label><input type="text" name="party_name"></div>
        <div><label>Payment Method</label><select name="payment_method"><option>Cash</option><option>Bank</option><option>Mobile Banking</option><option>Card</option></select></div>
        <div style="grid-column:1/-1"><label>Notes</label><textarea name="notes" rows="3"></textarea></div>
        <div class="form-actions" style="grid-column:1/-1"><button class="btn primary">Save Transaction</button></div>
    </form>
    <div class="card panel-tight table-wrap"><table class="table"><thead><tr><th>Date</th><th>Type</th><th>Category</th><th>Ref</th><th>Party</th><th>Payment</th><th>Amount</th></tr></thead><tbody>@forelse($transactions as $txn)<tr><td>{{ $txn->txn_date }}</td><td>{{ $txn->type }}</td><td>{{ $txn->category }}</td><td>{{ $txn->reference_no }}</td><td>{{ $txn->party_name }}</td><td>{{ $txn->payment_method }}</td><td>{{ number_format($txn->amount,2) }}</td></tr>@empty<tr><td colspan="7">No transaction found.</td></tr>@endforelse</tbody></table></div>
    {{ $transactions->links() }}
</div>
@endsection
