@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">
  @if ($errors->any())
      <div class="alert alert-danger">
          <ul class="mb-0">
              @foreach ($errors->all() as $error)
                  <li>{{ $error }}</li>
              @endforeach
          </ul>
      </div>
  @endif      

  <div class="row">
    {{-- 駐車場管理者ID（編集時のみ表示） --}}
    @if(!empty($manager_id))
      <div class="form-group col-3">
        <label>{{ __('駐車場管理者ID') }}</label>
      </div>
      <div class="form-group col-9">
        <input type="text"
               value="{{ $manager_id }}"
               class="form-control form-control-lg bg-light"
               readonly />
      </div>
    @endif

    {{-- 駐車場管理者名 --}}
    <div class="form-group col-3">
      <label class="required">{{ __('駐車場管理者名') }}</label>
    </div>
    <div class="form-group col-9">
      <input type="text"
             name="manager_name"
             value="{{ old('manager_name', $manager_name) }}"
             placeholder="{{ __('validation.attributes.manager_name') }}"
             class="form-control form-control-lg" />
    </div>

    {{-- 種別 --}}
    <div class="form-group col-3">
      <label class="required">{{ __('種別') }}</label>
    </div>
    <div class="form-group col-9">
      <input type="text"
             name="manager_type"
             value="{{ old('manager_type', $manager_type) }}"
             placeholder="{{ __('validation.attributes.manager_type') }}"
             class="form-control form-control-lg" />
    </div>

    {{-- 所属駐輪場 --}}
    <div class="form-group col-3">
      <label class="required">{{ __('所属駐輪場ID') }}</label>
    </div>
    <div class="form-group col-9">
      <select class="form-control form-control-lg mb10" name="manager_parkid">
        <option value="">{{ __('所属駐輪場ID') }}</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 class="required">{{ __('管理デバイス1') }}</label>
    </div>
    <div class="form-group col-9">
      <select class="form-control form-control-lg mb10" name="manager_device1">
        <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>{{ __('管理デバイス2') }}</label>
    </div>
    <div class="form-group col-9">
      <select class="form-control form-control-lg mb10" name="manager_device2">
        <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">
      <input type="text"
            name="manager_mail"
            value="{{ old('manager_mail', $record->manager_mail ?? '') }}"
            placeholder="{{ __('validation.attributes.manager_mail') }}"
            class="form-control form-control-lg" />
    </div>

    {{-- 電話番号 --}}
    <div class="form-group col-3">
      <label class="required">{{ __('電話番号') }}</label>
    </div>
    <div class="form-group col-9">
      <input type="text"
            name="manager_tel"
            value="{{ old('manager_tel', $record->manager_tel ?? '') }}"
            placeholder="{{ __('validation.attributes.manager_tel') }}"
            class="form-control form-control-lg" />
    </div>

    {{-- アラート1送信 --}}
    <div class="form-group col-3">
      <label>{{ __('アラート1送信') }}</label>
    </div>
    <div class="form-group col-9">
      <input type="text"
            name="manager_alert1"
            value="{{ old('manager_alert1', $record->manager_alert1 ?? '') }}"
            placeholder="{{ __('アラート1送信') }}"
            class="form-control form-control-lg" />
    </div>

    {{-- アラート2送信 --}}
    <div class="form-group col-3">
      <label>{{ __('アラート2送信') }}</label>
    </div>
    <div class="form-group col-9">
      <input type="text"
            name="manager_alert2"
            value="{{ old('manager_alert2', $record->manager_alert2 ?? '') }}"
            placeholder="{{ __('アラート2送信') }}"
            class="form-control form-control-lg" />
    </div>


    {{-- 退職フラグ --}}
    <div class="form-group col-3">
      <label class="required">{{ __('退職フラグ') }}</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' : '' }}>
          <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' : '' }}>
          <label class="form-check-label">{{ __('退職しない') }}</label>
        </div>
      </div>
    </div>

    {{-- 退職日 --}}
    <div class="form-group col-3">
      <label>{{ __('退職日') }}</label>
    </div>
    <div class="form-group col-9">
      <input type="date"
             name="manager_quitday"
             value="{{ old('manager_quitday', !empty($manager_quitday) ? \Carbon\Carbon::parse($manager_quitday)->format('Y-m-d') : '') }}"
             class="form-control form-control-lg"
             style="text-align: left;" />
    </div>

  </div>

  {{-- ▼ 下部ボタン --}}
    <div class="row mt-4">
      <!-- <div class="col-md-2"></div> -->
      <div class="form-group col-md-10 d-flex align-items-center gap-2 justify-content-start">
      {{-- 登録ボタン --}}
      @if(!empty($manager_id))
          <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(!empty($manager_id))
          <button type="button" id="delete_edit" class="btn btn-lg btn-danger">
              {{ __('削除') }}
          </button>
      @endif
  </div>
</div>
