@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 p-4">

  <div class="row mb-3">
    @if($isInfo || $isEdit)
      <label class="col-md-2 col-form-label">{{ __('validation.attributes.print_area_id') }}</label>
      <div class="col-md-10">
        <input type="text" class="form-control" value="{{ $record->print_area_id ?? '' }}" readonly>
      </div>
    @endif
  </div>

  <div class="row mb-3">
    <label class="col-md-2 col-form-label">
      {{ __('validation.attributes.print_area_name') }}
      @if(!$isInfo)<span class="text-danger">*</span>@endif
    </label>
    <div class="col-md-10">
      <input type="text" name="print_area_name" class="form-control"
             value="{{ old('print_area_name', $record->print_area_name ?? '') }}"
             placeholder="{{ __('validation.attributes.print_area_name') }}"
             @if($isInfo) readonly @endif>
    </div>
  </div>

  <div class="row mb-3">
    <label class="col-md-2 col-form-label">
      {{ __('validation.attributes.park_name') }}
      @if(!$isInfo)<span class="text-danger">*</span>@endif
    </label>
    <div class="col-md-10">
      <select name="park_id" class="form-control" @if($isInfo) disabled @endif>
        <option value="">{{ __('validation.attributes.park_name') }}</option>
        @foreach($parks as $key => $val)
          <option value="{{ $key }}" @if(($record->park_id ?? '') == $key) selected @endif>{{ $val }}</option>
        @endforeach
      </select>
    </div>
  </div>

  {{-- 下部登録ボタン --}}
  <div class="text-left mt-4">
    @if($isInfo)
      {{-- 詳細モード（info）では、編集ボタンを表示 --}}
      <a href="{{ route('print_areas_add') }}" class="btn btn-lg btn-success">{{ __('登録') }}</a>
      <a href="{{ route('print_areas_edit', ['id' => $record->print_area_id]) }}" class="btn btn-danger px-5">{{ __('編集') }}</a>
    @else
      {{-- 登録 or 更新 --}}
      <button type="submit" class="btn btn-lg btn-success">
        {{ $isEdit ? '登録' : '登録' }}
      </button>

      {{-- 削除ボタン --}}
      @if($isEdit)
        <a href="{{ route('print_areas_delete', ['id' => $record->print_area_id]) }}"
          class="btn btn-lg btn-danger ml-3"
          onclick="return confirm('削除してよろしいですか？')">
          削除
        </a>
      @endif
    @endif
  </div>

</div>
