{{--
# ────────────── lee_gwena ──────────────
# Code by: ashley_gwena
# Created: 2026-03-12
# Notes: Cashbook create form
# ───────────────────────────────────────
--}}
@extends('layouts.master')

@section('title', 'Create Cashbook')

@section('content')
@include('chart_of_accounts.partials.form-styles')
<div class="container py-4 coa-form">
    <div class="coa-header">
        <div>
            <h1 class="h3 mb-1">Add Cashbook</h1>
            <p>Bank setup and GL linkage.</p>
        </div>
        <div class="coa-actions">
            <a href="{{ route('cashbooks.index') }}" class="btn btn-outline-secondary">Back</a>
        </div>
    </div>

    <form method="POST" action="{{ route('cashbooks.store') }}" class="card p-4 coa-card">
        @csrf
        <div class="row g-3">
            <div class="col-md-6">
                <label class="form-label">Cashbook Name</label>
                <input type="text" name="name" value="{{ old('name') }}" class="form-control" required>
            </div>
            <div class="col-md-6">
                <label class="form-label">Account Number</label>
                <input type="text" name="account_number" value="{{ old('account_number') }}" class="form-control" required>
            </div>
            <div class="col-md-3">
                <label class="form-label">Currency</label>
                <select name="currency" class="form-select" required>
                    <option value="" disabled {{ old('currency') ? '' : 'selected' }}>Select</option>
                    @foreach($currencies as $currency)
                        <option value="{{ $currency->currency_code }}" {{ old('currency') == $currency->currency_code ? 'selected' : '' }}>
                            {{ $currency->currency_code }} - {{ $currency->currency_name }}
                        </option>
                    @endforeach
                </select>
            </div>
            <div class="col-md-6">
                <label class="form-label">Default GL Account</label>
                <select name="default_gl_account_id" class="form-select" required>
                    <option value="" disabled {{ old('default_gl_account_id') ? '' : 'selected' }}>Select GL Account</option>
                    @foreach($glAccounts as $account)
                        <option value="{{ $account->id }}" {{ old('default_gl_account_id') == $account->id ? 'selected' : '' }}>
                            {{ $account->account_code }} - {{ $account->account_name }}
                        </option>
                    @endforeach
                </select>
            </div>
            <div class="col-md-3 form-check">
                <input type="checkbox" class="form-check-input" id="is_trust" name="is_trust" value="1" {{ old('is_trust') ? 'checked' : '' }}>
                <label class="form-check-label" for="is_trust">Trust Cashbook</label>
            </div>
        </div>
        <div class="mt-4">
            <button class="btn btn-primary" type="submit">Save Cashbook</button>
        </div>
    </form>
</div>

@endsection

