@extends('admin.layouts.app')

@section('title', __('admin/invoice-billings.buttons_create'))

@section('content')
<div class="container-fluid px-4">
    <x-admin.page-header
        :title="__('admin/invoice-billings.buttons_create')"
        icon="fas fa-file-invoice"
        :buttons="[
            ['label' => __('admin/invoice-billings.buttons_back'), 'route' => route('admin.invoice-billings.index'), 'icon' => 'fas fa-arrow-left', 'color' => 'outline-secondary'],
        ]"
    />

    <x-admin.alert />

    <x-admin.card>
        <form action="{{ route('admin.invoice-billings.store') }}" method="POST" id="createInvoiceBillingForm">
            @csrf

            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="create_name">{{ __('admin/invoice-billings.fields_name') }} <span class="text-danger">*</span></label>
                        <input type="text" class="form-control @error('name') is-invalid @enderror"
                               id="create_name" name="name" value="{{ old('name') }}"
                               placeholder="gib, logo, parasut">
                        @error('name')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                        <small class="form-text text-muted">{{ __('admin/invoice-billings.help_name') }}</small>
                    </div>
                </div>

                <div class="col-md-6">
                    <div class="form-group">
                        <label for="create_display_name">{{ __('admin/invoice-billings.fields_display_name') }} <span class="text-danger">*</span></label>
                        <input type="text" class="form-control @error('display_name') is-invalid @enderror"
                               id="create_display_name" name="display_name" value="{{ old('display_name') }}"
                               placeholder="GİB E-Fatura, Logo E-Fatura">
                        @error('display_name')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                        <small class="form-text text-muted">{{ __('admin/invoice-billings.help_display_name') }}</small>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="create_type">{{ __('admin/invoice-billings.fields_type') }} <span class="text-danger">*</span></label>
                        <select class="form-control @error('type') is-invalid @enderror" id="create_type" name="type">
                            <option value="">{{ __('admin/common.select') }}</option>
                            @foreach($types as $value => $label)
                                <option value="{{ $value }}" @selected(old('type') == $value)>
                                    {{ $label }}
                                </option>
                            @endforeach
                        </select>
                        @error('type')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                        <small class="form-text text-muted">{{ __('admin/invoice-billings.help_type') }}</small>
                    </div>
                </div>

                <div class="col-md-6">
                    <div class="form-group">
                        <label for="create_status">{{ __('admin/invoice-billings.fields_status') }}</label>
                        <select class="form-control @error('status') is-invalid @enderror" id="create_status" name="status">
                            @foreach($statuses as $value => $label)
                                <option value="{{ $value }}" @selected(old('status', 'active') == $value)>
                                    {{ $label }}
                                </option>
                            @endforeach
                        </select>
                        @error('status')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <div class="custom-control custom-switch">
                            <input type="checkbox" class="custom-control-input" id="create_is_active" name="is_active" value="1" {{ old('is_active', true) ? 'checked' : '' }}>
                            <label class="custom-control-label" for="create_is_active">
                                {{ __('admin/invoice-billings.fields_is_active') }}
                            </label>
                        </div>
                        <small class="form-text text-muted">{{ __('admin/invoice-billings.help_is_active') }}</small>
                    </div>
                </div>

                <div class="col-md-6">
                    <div class="form-group">
                        <div class="custom-control custom-switch">
                            <input type="checkbox" class="custom-control-input" id="create_is_automatic" name="is_automatic" value="1" {{ old('is_automatic') ? 'checked' : '' }}>
                            <label class="custom-control-label" for="create_is_automatic">
                                {{ __('admin/invoice-billings.fields_is_automatic') }}
                            </label>
                        </div>
                        <small class="form-text text-muted">{{ __('admin/invoice-billings.help_is_automatic') }}</small>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label for="create_settings">{{ __('admin/invoice-billings.fields_settings') }}</label>
                <textarea class="form-control @error('settings') is-invalid @enderror"
                          id="create_settings" name="settings" rows="5"
                          placeholder='{"api_url": "https://api.example.com", "api_key": "your-api-key"}'>{{ old('settings') }}</textarea>
                @error('settings')
                    <div class="invalid-feedback">{{ $message }}</div>
                @enderror
                <small class="form-text text-muted">{{ __('admin/invoice-billings.help_settings') }}</small>
            </div>

            <div class="form-group">
                <label for="create_mapping_fields">{{ __('admin/invoice-billings.fields_mapping_fields') }}</label>
                <textarea class="form-control @error('mapping_fields') is-invalid @enderror"
                          id="create_mapping_fields" name="mapping_fields" rows="5"
                          placeholder='{"client_tax_number": "client.tax_number", "client_name": "client.company_name"}'>{{ old('mapping_fields') }}</textarea>
                @error('mapping_fields')
                    <div class="invalid-feedback">{{ $message }}</div>
                @enderror
                <small class="form-text text-muted">{{ __('admin/invoice-billings.help_mapping_fields') }}</small>
            </div>

            <x-slot:footer>
                <x-admin.form-actions :cancel-url="route('admin.invoice-billings.index')" form-id="createInvoiceBillingForm" />
            </x-slot:footer>
        </form>
    </x-admin.card>
</div>
@endsection

@push('scripts')
@vite('resources/js/admin/invoice-billings/create.js')
@endpush