{{-- アラート --}}
@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>
@elseif(Session::has('error'))
    <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>
        {!! Session::get('error') !!}
    </div>
@elseif(isset($errorMsg))
    <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>
        {!! $errorMsg !!}
    </div>
@endif

{{-- ===== フォーム ===== --}}
<div class="card-body">
    <div class="row">

        @if(!empty($isInfo) || !empty($isEdit))
            {{-- デバイスID --}}
            <div class="form-group col-3">
                <label>{{ __('デバイスID') }}</label>
            </div>
            <div class="form-group col-9">
                <div class="input-group">
                    <input type="text"
                           value="{{ $device->device_id ?? '' }}"
                           class="form-control form-control-lg"
                           readonly/>
                </div>
            </div>
        @endif

        {{-- 駐輪場ID --}}
        <div class="form-group col-3">
            <label>{{ __('駐輪場ID') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="number"
                       name="park_id"
                       value="{{ old('park_id', $device->park_id ?? '') }}"
                       class="form-control form-control-lg"
                       @if(!empty($isInfo)) readonly @else placeholder="{{ __('validation.attributes.park_id') }}" @endif>
            </div>
        </div>

        {{-- デバイス種別 --}}
        <div class="form-group col-3">
            <label class="required">{{ __('デバイス種別') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="text"
                       name="device_type"
                       value="{{ old('device_type', $device->device_type ?? '') }}"
                       class="form-control form-control-lg"
                       @if(!empty($isInfo)) readonly @else placeholder="{{ __('validation.attributes.device_type') }}" @endif>
            </div>
        </div>

        {{-- デバイス名 --}}
        <div class="form-group col-3">
            <label class="required">{{ __('デバイス名') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="text"
                       name="device_subject"
                       value="{{ old('device_subject', $device->device_subject ?? '') }}"
                       class="form-control form-control-lg"
                       @if(!empty($isInfo)) readonly @else placeholder="{{ __('validation.attributes.device_subject') }}" @endif>
            </div>
        </div>

        {{-- 識別子 --}}
        <div class="form-group col-3">
            <label>{{ __('識別子') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="text"
                       name="device_identifier"
                       value="{{ old('device_identifier', $device->device_identifier ?? '') }}"
                       class="form-control form-control-lg"
                       @if(!empty($isInfo)) readonly @else placeholder="{{ __('validation.attributes.device_identifier') }}" @endif>
            </div>
        </div>

        {{-- 稼働/停止 --}}
        <div class="form-group col-3">
            <label>{{ __('稼働/停止') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="row">
                @php $work = old('device_work', $device->device_work ?? ''); @endphp
                <div class="col-3 offset-1 form-check">
                    <input type="radio" class="minimal" name="device_work" value="稼働"
                           @if(!empty($isInfo)) disabled @endif
                           {{ $work === '稼働' ? 'checked' : '' }}>
                    <label class="form-check-label">{{ __('稼働') }}</label>
                </div>
                <div class="col-3 form-check">
                    <input type="radio" class="minimal" name="device_work" value="停止"
                           @if(!empty($isInfo)) disabled @endif
                           {{ $work === '停止' ? 'checked' : '' }}>
                    <label class="form-check-label">{{ __('停止') }}</label>
                </div>
            </div>
        </div>

        {{-- 稼働開始日 --}}
        <div class="form-group col-3">
            <label>{{ __('稼働開始日') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="date"
                       name="device_workstart"
                       value="{{ old('device_workstart', optional($device->device_workstart)->toDateString()) }}"
                       class="form-control form-control-lg"
                       @if(!empty($isInfo)) readonly @endif>
            </div>
        </div>

        {{-- リプレース予約日 --}}
        <div class="form-group col-3">
            <label>{{ __('リプレース予約日') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="date"
                       name="device_replace"
                       value="{{ old('device_replace', optional($device->device_replace)->toDateString() ?? '') }}"
                       class="form-control form-control-lg"
                       @if(!empty($isInfo)) readonly @endif>
            </div>
        </div>

        {{-- 備考 --}}
        <div class="form-group col-3">
            <label>{{ __('備考') }}</label>
        </div>
        <div class="form-group col-9">
            <div class="input-group">
                <input type="text"
                       name="device_remarks"
                       value="{{ old('device_remarks', $device->device_remarks ?? '') }}"
                       class="form-control form-control-lg"
                       maxlength="255"
                       @if(!empty($isInfo)) readonly @else placeholder="{{ __('validation.attributes.device_remarks') }}" @endif>
            </div>
        </div>

    </div>
</div>

{{-- 下部ボタン --}}
 @if($isEdit)
    <button type="submit" class="btn btn-lg btn-success register">{{ __('保存') }}</button>
    <button type="submit" class="btn btn-lg btn-secondary register">{{ __('戻る') }}</button>
@else
    <button type="submit" class="btn btn-lg btn-success register">{{ __('登録') }}</button>
    <button type="submit" class="btn btn-lg btn-danger register">{{ __('削除') }}</button>
 @endif
