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

@section('title', 'Create GL Account')

@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 GL Account</h1>
            <p>Parent GL accounts for the chart of accounts.</p>
        </div>
        <div class="coa-actions">
            <a href="{{ route('gl-accounts.index') }}" class="btn btn-outline-secondary">Back</a>
        </div>
    </div>
    @if ($errors->any())
        <div class="alert alert-danger mb-3">
            @foreach ($errors->all() as $error)
                <div>{{ $error }}</div>
            @endforeach
        </div>
    @endif

    <form method="POST" action="{{ route('gl-accounts.store') }}" class="card p-4 coa-card">
        @csrf
        <div class="row g-3">
            <div class="col-md-4">
                <label class="form-label">Account Code</label>
                <input type="text" name="account_code" value="{{ old('account_code') }}" class="form-control" required>
            </div>
            <div class="col-md-8">
                <label class="form-label">Account Name</label>
                <input type="text" name="account_name" value="{{ old('account_name') }}" class="form-control" required>
            </div>
            <div class="col-md-3">
                <label class="form-label">Account Type</label>
                <select name="account_type_id" class="form-select" required>
                    <option value="" disabled {{ old('account_type_id') ? '' : 'selected' }}>Select type</option>
                    @foreach($accountTypes as $type)
                        <option value="{{ $type->id }}" {{ old('account_type_id') == $type->id ? 'selected' : '' }}>
                            {{ $type->name }}
                        </option>
                    @endforeach
                </select>
            </div>
            <div class="col-md-3">
                <label class="form-label">Financial Category</label>
                <select name="financial_category" class="form-select" required>
                    <option value="" disabled {{ old('financial_category') ? '' : 'selected' }}>Select category</option>
                    <option value="income_statement" {{ old('financial_category') === 'income_statement' ? 'selected' : '' }}>Income Statement</option>
                    <option value="balance_sheet" {{ old('financial_category') === 'balance_sheet' ? 'selected' : '' }}>Balance Sheet</option>
                </select>
            </div>
            <div class="col-md-4 form-check">
                <input type="checkbox" class="form-check-input" id="is_business" name="is_business" value="1" {{ old('is_business') ? 'checked' : '' }}>
                <label class="form-check-label" for="is_business">Business Account</label>
            </div>
            <div class="col-md-4 form-check">
                <input type="checkbox" class="form-check-input" id="is_trust_account" name="is_trust_account" value="1" {{ old('is_trust_account') ? 'checked' : '' }}>
                <label class="form-check-label" for="is_trust_account">Trust Account</label>
            </div>
            <div class="col-md-4 form-check">
                <input type="checkbox" class="form-check-input" id="is_active" name="is_active" value="1" {{ old('is_active', true) ? 'checked' : '' }}>
                <label class="form-check-label" for="is_active">Active</label>
            </div>
        </div>
        <div class="mt-4">
            <button class="btn btn-primary" type="submit">Save Account</button>
        </div>
    </form>
</div>

@endsection


