@extends('admin.layouts.app')
@section('title', isset($expense) ? 'Edit Expense' : 'Add Expense')
@section('content')
<div class="card">
    <div class="card-head"><h3 style="margin:0;">{{ isset($expense) ? 'Edit Expense' : 'Add Expense' }}</h3></div>
    <form method="POST" action="{{ isset($expense) ? route('admin.expenses.update', $expense->id) : route('admin.expenses.store') }}">
        @csrf
        @if(isset($expense)) @method('PUT') @endif
        <div class="grid cols-2">
            <div><label>Bill Date</label><input class="input" type="date" name="bill_date" value="{{ old('bill_date', isset($expense) ? \Illuminate\Support\Carbon::parse($expense->bill_date)->toDateString() : now()->toDateString()) }}" required></div>
            <div><label>Employee Name</label><input class="input" name="employee_name" value="{{ old('employee_name', $expense->employee_name ?? '') }}"></div>
            <div><label>Purpose</label><input class="input" name="purpose" value="{{ old('purpose', $expense->purpose ?? '') }}" required></div>
            <div><label>Amount</label><input class="input" type="number" min="0" step="0.01" name="amount" value="{{ old('amount', $expense->amount ?? '') }}" required></div>
            <div style="grid-column:1/-1;"><label>Note</label><textarea class="input" rows="4" name="note">{{ old('note', $expense->note ?? '') }}</textarea></div>
        </div>
        <div style="margin-top:14px;"><button class="btn btn-primary">{{ isset($expense) ? 'Update Expense' : 'Save Expense' }}</button></div>
    </form>
</div>
@endsection
