

<div class="card-body">
    {{-- ===== エラーメッセージ ===== --}}
    @if(Session::has('success'))
        <div class="alert alert-success alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            {{ Session::get('success') }}
        </div>
    @endif

    @if($errors->any())
        <div class="alert alert-danger alert-dismissible">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4><i class="icon fa fa-ban"></i> {{ __('入力内容に不備があります') }}:</h4>
            <ul>
                @foreach($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif


    <div class="row">
        {{-- キューID（編集時のみ表示） --}}
        @if($isEdit)
        <div class="form-group col-3">
            <label>{{ __('validation.attributes.que_id') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="text"
                       value="{{ $que_id }}"
                       placeholder="{{ __('validation.attributes.que_id') }}"
                       class="form-control form-control-lg"
                       readonly />
            </div>
        </div>
        @endif

        {{-- 利用者名 --}}
        <div class="form-group col-3">
            <label class="required">{{ __('validation.attributes.user_name') }}</label>
        </div>
        <div class="form-group col-9">
            <select class="form-control form-control-lg"
                    id="select_user"
                    name="user_id"
                    @if($isEdit) disabled @endif>
                <option value="">{{ __('validation.attributes.user_name') }}</option>
                @foreach($users as $item)
                    <option value="{{ $item->user_seq }}"
                            mobile="{{ $item->user_mobile }}"
                            homePhone="{{ $item->user_homephone }}"
                            @if($item->user_seq == $user_id) selected @endif>
                        {{ $item->user_name }}
                    </option>
                @endforeach
            </select>

            {{-- 編集時でも値を保持するための hidden --}}
            @if($isEdit)
                <input type="hidden" name="user_id" value="{{ $user_id }}">
            @endif
        </div>

        {{-- 携帯電話番号 --}}
        <div class="form-group col-3">
            <label>{{ __('validation.attributes.user_mobile') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="text"
                       id="mobile"
                       value=""
                       placeholder="{{ __('validation.attributes.user_mobile') }}"
                       class="form-control form-control-lg"
                       readonly />
            </div>
        </div>

        {{-- 自宅電話番号 --}}
        <div class="form-group col-3">
            <label>{{ __('validation.attributes.user_homephone') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="text"
                       id="homephone"
                       value=""
                       placeholder="{{ __('validation.attributes.user_homephone') }}"
                       class="form-control form-control-lg"
                       readonly />
            </div>
        </div>

        {{-- 定期契約ID --}}
        <div class="form-group col-3">
            <label>{{ __('validation.attributes.contract_id') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="text"
                    name="contract_id"
                    value="{{ old('contract_id', $contract_id ?? '') }}"
                    class="form-control form-control-lg"
                    placeholder="{{ __('validation.attributes.contract_id') }}"
                    @if($isEdit) readonly @endif>
            </div>
        </div>


        {{-- 駐輪場 --}}
        <div class="form-group col-3">
            <label class="required">{{ __('validation.attributes.park_name') }}</label>
        </div>
        <div class="form-group col-9">
            <select class="form-control form-control-lg"
                    name="park_id"
                    @if($isEdit) disabled @endif>
                <option value="">{{ __('validation.attributes.park_name') }}</option>
                @foreach($parks as $key => $item)
                    <option value="{{ $key }}" @if($key == $park_id) selected @endif>
                        {{ $item }}
                    </option>
                @endforeach
            </select>

            {{-- 編集時でも値を保持するための hidden --}}
            @if($isEdit)
                <input type="hidden" name="park_id" value="{{ $park_id }}">
            @endif
        </div>

        {{-- キュー種別 --}}
        <div class="form-group col-3">
            <label class="required">{{ __('validation.attributes.que_class') }}</label>
        </div>
        <div class="form-group col-9">
            <select class="form-control form-control-lg" name="que_class">
                <option value="">{{ __('validation.attributes.que_class') }}</option>
                @foreach(\App\Models\OperatorQue::QueClass as $key => $item)
                    <option value="{{ $key }}" @if($key == $que_class) selected @endif>
                        {{ $item }}
                    </option>
                @endforeach
            </select>
        </div>

        {{-- キューコメント --}}
        <div class="form-group col-3">
            <label>{{ __('validation.attributes.que_comment') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <textarea class="form-control form-control-lg"
                          rows="5"
                          name="que_comment"
                          placeholder="{{ __('validation.attributes.que_comment') }}">{{ $que_comment }}</textarea>
            </div>
        </div>

        {{-- キューステータス --}}
        <div class="form-group col-3">
            <label class="required">{{ __('validation.attributes.que_status') }}</label>
        </div>
        <div class="form-group col-9">
            <select class="form-control form-control-lg" name="que_status">
                <option value="">{{ __('validation.attributes.que_status') }}</option>
                @foreach(\App\Models\OperatorQue::QueStatus as $key => $item)
                    <option value="{{ $key }}" @if($key == $que_status) selected @endif>
                        {{ $item }}
                    </option>
                @endforeach
            </select>
        </div>

        {{-- キューステータスコメント --}}
        <div class="form-group col-3">
            <label>{{ __('validation.attributes.que_status_comment') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <textarea class="form-control form-control-lg"
                          rows="5"
                          name="que_status_comment"
                          placeholder="{{ __('validation.attributes.que_status_comment') }}">{{ $que_status_comment }}</textarea>
            </div>
        </div>

    </div>

    {{-- ▼ 下部ボタン --}}
    <div class="row mt-4">
        <div class="form-group col-md-10 d-flex align-items-center gap-2 justify-content-start">

            {{-- 登録ボタン --}}
            @if($isEdit)
                <button type="button" id="register_edit" class="btn btn-lg btn-success mr-2">
                    {{ __('登録') }}
                </button>
            @else
                <button type="button" id="register" class="btn btn-lg btn-success mr-2 register">
                    {{ __('登録') }}
                </button>
            @endif

            {{-- 削除ボタン（編集時のみ表示） --}}
            @if($isEdit)
                <button type="button" id="delete_edit" class="btn btn-lg btn-danger">
                    {{ __('削除') }}
                </button>
            @endif

        </div>
    </div>
</div>
