@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

@php
  $isAddPage = request()->routeIs('managers_add'); // 新規ページなら true
@endphp

<div class="card-body">
  <div class="row">

    @if($isInfo || $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="{{ $manager_id }}"
                 class="form-control form-control-lg"
                 readonly />
        </div>
      </div>
    @endif

    {{-- 駐車場管理者名 --}}
    <div class="form-group col-3">
      <label @if(!$isInfo) class="required" @endif>{{ __('駐車場管理者名') }}</label>
    </div>
    <div class="form-group col-9">
      <div class="input-group">
        <input type="text"
               name="manager_name"
               value="{{ old('manager_name', $manager_name) }}"
               placeholder="{{ __('validation.attributes.manager_name') }}"
               class="form-control form-control-lg" @if($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="manager_type"
               value="{{ old('manager_type', $manager_type) }}"
               placeholder="{{ __('validation.attributes.manager_type') }}"
               class="form-control form-control-lg" @if($isInfo) readonly @endif />
      </div>
    </div>

    {{-- 所属駐輪場 --}}
    <div class="form-group col-3">
      <label @if(!$isInfo) class="required" @endif>{{ __('駐輪場名') }}</label>
    </div>
    <div class="form-group col-9">
      <select class="form-control form-control-lg mb10"
              name="manager_parkid" @if($isInfo) disabled @endif>
        <option value="">{{ __('validation.attributes.park_name') }}</option>
        @foreach($parks as $key => $val)
          <option value="{{ $key }}"
            @if((string)old('manager_parkid', $manager_parkid) === (string)$key) selected @endif>
            {{ $val }}
          </option>
        @endforeach
      </select>
    </div>

    {{-- 管理デバイス1 --}}
    <div class="form-group col-3">
      <label @if(!$isInfo) class="required" @endif>{{ __('管理デバイス1') }}</label>
    </div>
    <div class="form-group col-9">
      <select class="form-control form-control-lg mb10"
              name="manager_device1" @if($isInfo) disabled @endif>
        <option value="">{{ __('validation.attributes.manager_device1') }}</option>
        @foreach($devices as $key => $val)
          <option value="{{ $key }}"
            @if((string)old('manager_device1', $manager_device1) === (string)$key) selected @endif>
            {{ $val }}
          </option>
        @endforeach
      </select>
    </div>

    {{-- 管理デバイス2 --}}
    <div class="form-group col-3">
      <label @if(!$isInfo) class="required" @endif>{{ __('管理デバイス2') }}</label>
    </div>
    <div class="form-group col-9">
      <select class="form-control form-control-lg mb10"
              name="manager_device2" @if($isInfo) disabled @endif>
        <option value="">{{ __('validation.attributes.manager_device2') }}</option>
        @foreach($devices as $key => $val)
          <option value="{{ $key }}"
            @if((string)old('manager_device2', $manager_device2) === (string)$key) selected @endif>
            {{ $val }}
          </option>
        @endforeach
      </select>
    </div>

    {{-- メールアドレス --}}
    <div class="form-group col-3">
      <label>{{ __('メールアドレス') }}</label>
    </div>
    <div class="form-group col-9">
      <div class="input-group">
        <input type="text"
               name="manager_mail"
               value="{{ old('manager_mail', $manager_mail) }}"
               class="form-control form-control-lg" @if($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="manager_tel"
               value="{{ old('manager_tel', $manager_tel) }}"
               class="form-control form-control-lg" @if($isInfo) readonly @endif />
      </div>
    </div>

    {{-- アラート1送信（checkbox + hidden 0） --}}
    <div class="form-group col-3">
      <label>{{ __('アラート1') }}</label>
    </div>
    <div class="form-group col-9">
      <div class="input-group align-items-center">
        @if(!$isInfo)<input type="hidden" name="manager_alert1" value="0">@endif
        <input type="checkbox" class="minimal"
               name="manager_alert1" value="1"
               {{ old('manager_alert1', $manager_alert1) ? 'checked' : '' }}
               @if($isInfo) disabled @endif>
      </div>
    </div>

    {{-- アラート2送信（checkbox + hidden 0） --}}
    <div class="form-group col-3">
      <label>{{ __('アラート2') }}</label>
    </div>
    <div class="form-group col-9">
      <div class="input-group align-items-center">
        @if(!$isInfo)<input type="hidden" name="manager_alert2" value="0">@endif
        <input type="checkbox" class="minimal"
               name="manager_alert2" value="1"
               {{ old('manager_alert2', $manager_alert2) ? 'checked' : '' }}
               @if($isInfo) disabled @endif>
      </div>
    </div>

    {{-- 退職フラグ --}}
    <div class="form-group col-3">
      <label>{{ __('退職フラグ') }}</label>
    </div>
    <div class="form-group col-9">
      <div class="row">
        <div class="col-2 offset-1 form-check">
          <input type="radio" class="minimal"
                 name="manager_quit_flag" value="1"
                 {{ (string)old('manager_quit_flag', $manager_quit_flag) === '1' ? 'checked' : '' }}
                 @if($isInfo) disabled @endif>
          <label class="form-check-label">{{ __('退職') }}</label>
        </div>
        <div class="col-3 form-check">
          <input type="radio" class="minimal"
                 name="manager_quit_flag" value="0"
                 {{ (string)old('manager_quit_flag', $manager_quit_flag) === '0' ? 'checked' : '' }}
                 @if($isInfo) disabled @endif>
          <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="manager_quitday"
               value="{{ old('manager_quitday', $manager_quitday) }}"
               class="form-control form-control-lg" @if($isInfo) readonly @endif />
      </div>
    </div>

  </div>

 {{-- 下部ボタン --}}
<div class="card-footer bg-white border-0">
  <div class="d-flex justify-content-start align-items-center">
    @if($isInfo)
      <a href="{{ route('managers_add') }}" class="btn btn-lg btn-success mr-2">{{ __('登録') }}</a>
      <a href="{{ route('managers_edit', ['id' => $manager_id]) }}" class="btn btn-lg btn-danger">{{ __('編集') }}</a>
    @else
      <button type="submit" class="btn btn-lg btn-success mr-2">
        {{ $isAddPage ? __('登録') : __('保存') }}
      </button>
      <a href="{{ route('managers') }}" class="btn btn-lg btn-secondary">{{ __('戻る') }}</a>
    @endif
  </div>
</div>
