@extends('layouts.app')
@section('title', '定期予約登録')

@section('content')
<style>
  /* 画面全体のフォント／サイズを統一（やや小さめ） */
  .rv-add,
  .rv-add .card,
  .rv-add .form-control,
  .rv-add .btn,
  .rv-add .breadcrumb {
    font-family: "Noto Sans JP","Hiragino Kaku Gothic ProN","Meiryo",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
    font-size: 13px;
    line-height: 1.45;
  }
  /* 1行＝左ラベル／右入力 */
  .rv-add .field{display:flex;align-items:center;margin-bottom:.7rem;}
  .rv-add .label{flex:0 0 170px;margin:0;color:#333;font-weight:600;white-space:nowrap;}
  .rv-add .input{flex:1 1 auto;}
  .rv-add .form-control{height:calc(2.0rem + 2px);padding:.25rem .5rem;}
  .rv-add .help{color:#888;font-size:12px;}
</style>

<div class="rv-add">
  {{-- パンくず＆見出し --}}
  <div class="content-header">
    <div class="container-fluid">
      <div class="row mb-2">
        <div class="col-lg-6"><h1 class="m-0 text-dark">新規</h1></div>
        <div class="col-lg-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('reserves') }}">定期予約マスタ</a></li>
            <li class="breadcrumb-item active">新規</li>
          </ol>
        </div>
      </div>
      @if($errors->any())
        <div class="alert alert-danger py-2 px-3 my-2">
          <ul class="mb-0">
            @foreach($errors->all() as $e)<li>{{ $e }}</li>@endforeach
          </ul>
        </div>
      @endif
    </div>
  </div>

  <section class="content">
    <div class="container-fluid">
      <div class="card">
        <div class="card-header py-2">
          <button form="rvAddForm" type="submit" class="btn btn-success btn-sm">登録</button>
        </div>

        <form id="rvAddForm" method="post" action="{{ route('reserves_add') }}">
          @csrf
          <div class="card-body">

            {{-- 画面上部（ID系） --}}
            <div class="field">
              <label class="label">定期予約ID</label>
              <div class="input">
                <input type="text" class="form-control" value="（自動採番）" disabled>
              </div>
            </div>

            <div class="field">
              <label class="label">定期契約ID</label>
              <div class="input">
                <input type="number" class="form-control" name="contract_id" value="{{ old('contract_id') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">利用者分類ID</label>
              <div class="input">
                {{-- 任意：必要に応じて選択肢を与える（今は簡易にテキスト or 「全て」） --}}
                <select name="user_categoryid" class="form-control">
                  <option value="">全て</option>
                </select>
              </div>
            </div>

            <div class="field">
              <label class="label">利用者登録日時</label>
              <div class="input">
                <input type="datetime-local" class="form-control" name="user_created_at" value="{{ old('user_created_at') }}">
              </div>
            </div>

            {{-- 基本情報 --}}
            <div class="field">
              <label class="label">利用者ID <span class="text-danger">*</span></label>
              <div class="input">
                <input type="number" class="form-control" name="user_id" value="{{ old('user_id') }}" required>
              </div>
            </div>

            <div class="field">
              <label class="label">駐輪場ID <span class="text-danger">*</span></label>
              <div class="input">
                <input type="number" class="form-control" name="park_id" value="{{ old('park_id') }}" required>
              </div>
            </div>

            <div class="field">
              <label class="label">駐輪場所ID</label>
              <div class="input">
                <input type="number" class="form-control" name="price_parkplaceid" value="{{ old('price_parkplaceid') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">車種区分ID</label>
              <div class="input">
                <input type="number" class="form-control" name="psection_id" value="{{ old('psection_id') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">駐輪分類ID</label>
              <div class="input">
                <input type="number" class="form-control" name="ptype_id" value="{{ old('ptype_id') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">予約日時</label>
              <div class="input">
                <input type="datetime-local" class="form-control" name="reserve_date" value="{{ old('reserve_date') }}">
              </div>
            </div>

            {{-- ラジオ系 --}}
            <div class="field">
              <label class="label">減免措置</label>
              <div class="input">
                <div class="form-check form-check-inline">
                  <input class="form-check-input" type="radio" name="reduction_flag" id="reduction1" value="1" {{ old('reduction_flag','0')==='1'?'checked':'' }}>
                  <label class="form-check-label" for="reduction1">あり</label>
                </div>
                <div class="form-check form-check-inline ml-3">
                  <input class="form-check-input" type="radio" name="reduction_flag" id="reduction0" value="0" {{ old('reduction_flag','0')==='0'?'checked':'' }}>
                  <label class="form-check-label" for="reduction0">なし</label>
                </div>
              </div>
            </div>

            {{-- リマインド --}}
            <div class="field">
              <label class="label">自動リマインド日</label>
              <div class="input">
                <input type="date" class="form-control" name="auto_remind_day" value="{{ old('auto_remind_day') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">手動リマインド日</label>
              <div class="input">
                <input type="date" class="form-control" name="manual_remind_day" value="{{ old('manual_remind_day') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">８００Ｍ以内フラグ</label>
              <div class="input">
                <div class="form-check form-check-inline">
                  <input class="form-check-input" type="radio" name="within_800m_flag" id="m800_1" value="1" {{ old('within_800m_flag','0')==='1'?'checked':'' }}>
                  <label class="form-check-label" for="m800_1">８００M以内</label>
                </div>
                <div class="form-check form-check-inline ml-3">
                  <input class="form-check-input" type="radio" name="within_800m_flag" id="m800_0" value="0" {{ old('within_800m_flag','0')==='0'?'checked':'' }}>
                  <label class="form-check-label" for="m800_0">８００M内ではない</label>
                </div>
              </div>
            </div>

            {{-- 期間・状態 --}}
            <div class="field">
              <label class="label">解約日</label>
              <div class="input">
                <input type="date" class="form-control" name="reserve_cancelday" value="{{ old('reserve_cancelday') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">有効フラグ</label>
              <div class="input">
                <div class="form-check form-check-inline">
                  <input class="form-check-input" type="radio" name="valid_flag" id="valid1" value="1" {{ old('valid_flag','1')==='1'?'checked':'' }}>
                  <label class="form-check-label" for="valid1">有効</label>
                </div>
                <div class="form-check form-check-inline ml-3">
                  <input class="form-check-input" type="radio" name="valid_flag" id="valid0" value="0" {{ old('valid_flag')==='0'?'checked':'' }}>
                  <label class="form-check-label" for="valid0">無効</label>
                </div>
              </div>
            </div>

            {{-- 通知 --}}
            <div class="field">
              <label class="label">手動通知</label>
              <div class="input">
                <div class="form-check form-check-inline">
                  <input class="form-check-input" type="radio" name="manual_notice" id="mn1" value="1" {{ old('manual_notice','0')==='1'?'checked':'' }}>
                  <label class="form-check-label" for="mn1">手動通知</label>
                </div>
                <div class="form-check form-check-inline ml-3">
                  <input class="form-check-input" type="radio" name="manual_notice" id="mn2" value="2" {{ old('manual_notice')==='2'?'checked':'' }}>
                  <label class="form-check-label" for="mn2">メール通知</label>
                </div>
              </div>
            </div>

            <div class="field">
              <label class="label">手動通知方法</label>
              <div class="input">
                <div class="form-check form-check-inline">
                  <input class="form-check-input" type="radio" name="manual_notice_method" id="mm_tel" value="tel" {{ old('manual_notice_method','tel')==='tel'?'checked':'' }}>
                  <label class="form-check-label" for="mm_tel">電話</label>
                </div>
                <div class="form-check form-check-inline ml-3">
                  <input class="form-check-input" type="radio" name="manual_notice_method" id="mm_mail" value="post" {{ old('manual_notice_method')==='post'?'checked':'' }}>
                  <label class="form-check-label" for="mm_mail">郵送</label>
                </div>
              </div>
            </div>

            <div class="field">
              <label class="label">空き待ちメール送信日時</label>
              <div class="input">
                <input type="datetime-local" class="form-control" name="waiting_mail_sent_at" value="{{ old('waiting_mail_sent_at') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">空き待ち順</label>
              <div class="input">
                <input type="number" class="form-control" name="waiting_order" value="{{ old('waiting_order') }}">
                <div class="help">小さいほど優先度が高い想定</div>
              </div>
            </div>

            {{-- 任意：開始/終了（必要なら表示） --}}
            <div class="field">
              <label class="label">開始日</label>
              <div class="input">
                <input type="date" class="form-control" name="reserve_start" value="{{ old('reserve_start') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">終了日</label>
              <div class="input">
                <input type="date" class="form-control" name="reserve_end" value="{{ old('reserve_end') }}">
              </div>
            </div>

            <div class="field">
              <label class="label">オペレータID</label>
              <div class="input">
                <input type="number" class="form-control" name="ope_id" value="{{ old('ope_id') }}">
              </div>
            </div>

          </div>

          <div class="card-footer">
            <button type="submit" class="btn btn-success">登録</button>
            <a href="{{ route('reserves') }}" class="btn btn-default ml-2">戻る</a>
          </div>
        </form>
      </div>
    </div>
  </section>
</div>
@endsection
