@extends('layouts.app')
@section('title', '契約許容市区マスタ（新規）')

@section('content')
<div class="content-header">
  <div class="container-fluid">
    <div class="row mb-2">
      <div class="col-sm-6">
        <h1 class="m-0 text-dark">新規登録</h1>
      </div>
      <div class="col-sm-6">
        <ol class="breadcrumb float-sm-right text-sm">
          <li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
          <li class="breadcrumb-item"><a href="{{ route('contract_allowable_cities') }}">契約許容市区マスタ</a></li>
          <li class="breadcrumb-item active">新規登録</li>
        </ol>
      </div>
    </div>
  </div>
</div>

<section class="content">
  <div class="container-fluid">
    <form action="{{ route('contract_allowable_cities_add') }}" method="POST" id="form_main">
      @csrf
      <div class="card p-4">

        {{-- 契約許容市区マスタID --}}
        <div class="row mb-3">
          <label class="col-md-2 col-form-label">契約許容市区マスタID<span class="text-danger">*</span></label>
          <div class="col-md-10">
            <select name="contract_allowable_city_id" class="form-control" required>
              <option value="">選択してください</option>
              @foreach($contractAllowableCityList as $id => $name)
                <option value="{{ $id }}" {{ old('contract_allowable_city_id', $record->contract_allowable_city_id ?? '') == $id ? 'selected' : '' }}>{{ $name }}</option>
              @endforeach
            </select>
          </div>
        </div>

        {{-- 市区ID --}}
        <div class="row mb-3">
          <label class="col-md-2 col-form-label">市区ID<span class="text-danger">*</span></label>
          <div class="col-md-10">
            <select name="city_id" class="form-control" required>
              <option value="">選択してください</option>
              @foreach($cityList as $id => $name)
                <option value="{{ $id }}" {{ old('city_id') == $id ? 'selected' : '' }}>{{ $id }}</option>
              @endforeach
            </select>
          </div>
        </div>

        {{-- 許容市区名 --}}
        <div class="row mb-3">
          <label class="col-md-2 col-form-label">許容市区名<span class="text-danger">*</span></label>
          <div class="col-md-10">
            <input type="text" name="contract_allowable_city_name" class="form-control" value="{{ old('contract_allowable_city_name') }}" placeholder="許容市区名を入力">
          </div>
        </div>

        {{-- 駐輪場ID --}}
        <div class="row mb-3">
          <label class="col-md-2 col-form-label">駐輪場ID<span class="text-danger">*</span></label>
          <div class="col-md-10">
            <select name="park_id" class="form-control" required>
              <option value="">選択してください</option>
              @foreach($parkList as $id => $name)
                <option value="{{ $id }}" {{ old('park_id') == $id ? 'selected' : '' }}>{{ $name }}</option>
              @endforeach
            </select>
          </div>
        </div>

        {{-- 隣接区フラグ --}}
        <div class="row mb-3">
          <label class="col-md-2 col-form-label">隣接区フラグ<span class="text-danger">*</span></label>
          <div class="col-md-10">
            <select name="same_district_flag" class="form-control" required>
              <option value="">選択してください</option>
              <option value="0" {{ old('same_district_flag') == '0' ? 'selected' : '' }}>同一区</option>
              <option value="1" {{ old('same_district_flag') == '1' ? 'selected' : '' }}>隣接区</option>
            </select>
          </div>
        </div>

        {{-- 下部登録ボタン --}}
        <div class="mb-3">
          <button type="submit" class="btn btn-success btn-lg" onclick="return confirm('登録してよろしいですか？')">登録</button>
        </div>
        
      </div>
    </form>
  </div>
</section>
@endsection