@extends('layouts.admin.app')

@section('title', translate('Add Expense'))

@section('content')
    <div class="content container-fluid">
        <div class="page-header">
            <h1 class="page-header-title">
                <span class="page-header-icon">
                    <i class="tio-add-circle"></i>
                </span>
                <span>{{ translate('Add Expense') }}</span>
            </h1>
            <div class="page-header-right">
                <a href="{{ route('admin.business-expense.index') }}" class="btn btn--light">{{ translate('Back to Expense History') }}</a>
            </div>
        </div>

        <div class="card">
            <div class="card-body">
                <form action="{{ route('admin.business-expense.store') }}" method="post">
                    @csrf
                    <div class="row g-3">
                        <div class="col-md-4">
                            <label class="input-label">{{ translate('Expense Date') }}</label>
                            <input type="date" name="expense_date" value="{{ old('expense_date', now()->toDateString()) }}" class="form-control" required>
                            @error('expense_date')<small class="text-danger">{{ $message }}</small>@enderror
                        </div>
                        <div class="col-md-4">
                            <label class="input-label">{{ translate('Category') }}</label>
                            <select name="category" class="form-control" required>
                                @foreach($categories as $key => $label)
                                    <option value="{{ $key }}" {{ old('category') === $key ? 'selected' : '' }}>{{ translate($label) }}</option>
                                @endforeach
                            </select>
                            @error('category')<small class="text-danger">{{ $message }}</small>@enderror
                        </div>
                        <div class="col-md-4">
                            <label class="input-label">{{ translate('Amount') }}</label>
                            <input type="number" step="0.01" min="0.01" name="amount" value="{{ old('amount') }}" class="form-control" required>
                            @error('amount')<small class="text-danger">{{ $message }}</small>@enderror
                        </div>
                        <div class="col-md-12">
                            <label class="input-label">{{ translate('Reference') }}</label>
                            <input type="text" name="reference" value="{{ old('reference') }}" class="form-control">
                            @error('reference')<small class="text-danger">{{ $message }}</small>@enderror
                        </div>
                        <div class="col-12">
                            <label class="input-label">{{ translate('Note') }}</label>
                            <textarea name="note" rows="5" class="form-control">{{ old('note') }}</textarea>
                            @error('note')<small class="text-danger">{{ $message }}</small>@enderror
                        </div>
                    </div>
                    <div class="d-flex justify-content-end gap-3 mt-4">
                        <a href="{{ route('admin.business-expense.index') }}" class="btn btn--reset">{{ translate('Cancel') }}</a>
                        <button type="submit" class="btn btn--primary">{{ translate('Save Expense') }}</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection
