{{-- resources/views/admin/regularcontracts/add.blade.php --}}
@extends('layouts.app')
@section('title', '新規｜定期契約マスタ')

@section('content')
<style>
  .rc-page, .rc-page .card, .rc-page .form-control, .rc-page .custom-select, .rc-page .btn {
    font-size: 13px;
    line-height: 1.45;
  }
  .rc-form .row-line{display:flex;align-items:center;margin-bottom:.6rem}
  .rc-form .row-line .label{flex:0 0 240px;font-weight:600;white-space:nowrap;margin:0;color:#333}
  .rc-form .row-line .input{flex:1 1 auto;min-width:260px}
  .rc-form .form-control,.rc-form .custom-select{height:calc(2.0rem + 2px);padding:.25rem .5rem}
  .rc-form .inline-range{display:flex;gap:.5rem;align-items:center}
  .rc-form .inline-range .tilde{color:#666}
  .rc-toolbar{display:flex;justify-content:flex-start;gap:.5rem;margin-bottom:.75rem}
</style>

<div class="rc-page">
  <div class="content-header">
    <div class="container-fluid">
      <div class="d-flex align-items-center justify-content-between mb-2">
        <h1 class="m-0 text-dark">新規</h1>
        <ol class="breadcrumb float-sm-right text-sm mb-0">
          <li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
          <li class="breadcrumb-item"><a href="{{ route('regularcontracts') }}">定期契約マスタ</a></li>
          <li class="breadcrumb-item active">新規</li>
        </ol>
      </div>
    </div>
  </div>

  <section class="content">
    <div class="container-fluid">

      <div class="card rc-form">
        <div class="card-header d-flex justify-content-start gap-2">
          <button form="rc-add-form" type="submit" class="btn btn-sm btn-default register js-confirm-submit">登録</button>
        </div>
         <div class="card-body">
           <form id="rc-add-form" method="post" action="{{ route('regularcontracts_add') }}">
            @csrf

            {{-- ====== 1段目 ====== --}}
            <div class="row">
              <div class="col-lg-6">
                <div class="row-line">
                  <p class="label">旧定期契約番号</p>
                  <div class="input"><input name="old_contract_number" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">定期契約QRID</p>
                  <div class="input"><input name="contract_qr_id" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">利用者ID</p>
                  <div class="input"><input name="user_id" class="form-control" type="number" min="0"></div>
                </div>
                <div class="row-line">
                  <p class="label">利用者分類ID</p>
                  <div class="input"><input name="user_categoryid" class="form-control" type="number" min="0"></div>
                </div>
                <div class="row-line">
                  <p class="label">定期予約ID</p>
                  <div class="input"><input name="reserve_id" class="form-control" type="number" min="0"></div>
                </div>
                <div class="row-line">
                  <p class="label">駐輪場ID</p>
                  <div class="input"><input name="park_id" class="form-control" type="number" min="0"></div>
                </div>
                <div class="row-line">
                  <p class="label">駐輪場所ID</p>
                  <div class="input"><input name="price_parkplaceid" class="form-control" type="number" min="0"></div>
                </div>
                <div class="row-line">
                  <p class="label">防犯登録番号</p>
                  <div class="input"><input name="crime_prevention_registration_number" class="form-control" type="text"></div>
                </div>

                <div class="row-line">
                  <p class="label">予約日時</p>
                  <div class="input inline-range">
                    <input name="reserve_date" type="datetime-local" class="form-control">
                  </div>
                </div>
                <div class="row-line">
                  <p class="label">契約日時</p>
                  <div class="input inline-range">
                    <input name="contract_created_at" type="datetime-local" class="form-control">
                  </div>
                </div>
                <div class="row-line">
                  <p class="label">更新可能日</p>
                  <div class="input"><input name="renewable_date" type="date" class="form-control"></div>
                </div>
                <div class="row-line">
                  <p class="label">解約日時</p>
                  <div class="input inline-range">
                    <input name="contract_cancelday" type="datetime-local" class="form-control">
                  </div>
                </div>

                <div class="row-line">
                  <p class="label">有効期間S</p>
                  <div class="input"><input name="valid_from" type="date" class="form-control"></div>
                </div>
                <div class="row-line">
                  <p class="label">有効期間E</p>
                  <div class="input"><input name="valid_to" type="date" class="form-control"></div>
                </div>
                <div class="row-line">
                  <p class="label">定期有効月数</p>
                  <div class="input"><input name="enable_months" type="number" min="0" class="form-control"></div>
                </div>
                <div class="row-line">
                  <p class="label">シール印刷可能日</p>
                  <div class="input"><input name="printable_date" type="date" class="form-control"></div>
                </div>
                <div class="row-line">
                  <p class="label">請求金額</p>
                  <div class="input"><input name="billing_amount" type="number" step="1" min="0" class="form-control"></div>
                </div>
                <div class="row-line">
                  <p class="label">車室割り当てフラグ</p>
                  <div class="input">
                    <select name="assign_flag" class="custom-select">
                      <option value="">—</option>
                      <option value="1">割当済</option>
                      <option value="0">未割当</option>
                    </select>
                  </div>
                </div>
                <div class="row-line">
                  <p class="label">授受日時</p>
                  <div class="input"><input name="receipt_delivery_date" type="datetime-local" class="form-control"></div>
                </div>
                <div class="row-line">
                  <p class="label">授受金額</p>
                  <div class="input"><input name="receipt_delivery_amount" type="number" step="1" min="0" class="form-control"></div>
                </div>
                <div class="row-line">
                  <p class="label">授受フラグ</p>
                  <div class="input">
                    <select name="receipt_delivery_flag" class="custom-select">
                      <option value="">—</option>
                      <option value="1">済</option>
                      <option value="0">未</option>
                    </select>
                  </div>
                </div>
              </div>

              {{-- 右列 --}}
              <div class="col-lg-6">
                <div class="row-line">
                  <p class="label">決済トランザクションID</p>
                  <div class="input"><input name="payment_transaction_id" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">シール発行数</p>
                  <div class="input"><input name="contract_seal_count" type="number" min="0" class="form-control"></div>
                </div>
                <div class="row-line">
                  <p class="label">シール発行リクエスト</p>
                  <div class="input">
                    <div class="form-check form-check-inline">
                      <input class="form-check-input" type="radio" name="contract_seal_request" value="1" id="seal_req1">
                      <label class="form-check-label" for="seal_req1">はい</label>
                    </div>
                    <div class="form-check form-check-inline">
                      <input class="form-check-input" type="radio" name="contract_seal_request" value="0" id="seal_req0" checked>
                      <label class="form-check-label" for="seal_req0">いいえ</label>
                    </div>
                  </div>
                </div>

                <div class="row-line">
                  <p class="label">定期継続フラグ</p>
                  <div class="input">
                    <select name="contract_continuing" class="custom-select">
                      <option value="">—</option>
                      <option value="1">継続</option>
                      <option value="0">それ以外（新規）</option>
                    </select>
                  </div>
                </div>
                <div class="row-line">
                  <p class="label">シール発行可</p>
                  <div class="input">
                    <select name="contract_delivery" class="custom-select">
                      <option value="">—</option>
                      <option value="1">発行可</option>
                      <option value="0">発行しない</option>
                    </select>
                  </div>
                </div>
                <div class="row-line">
                  <p class="label">減免フラグ</p>
                  <div class="input">
                    <select name="contract_reduction" class="custom-select">
                      <option value="">—</option>
                      <option value="1">減免</option>
                      <option value="0">減免しない</option>
                    </select>
                  </div>
                </div>
                <div class="row-line">
                  <p class="label">８０ＭＯＭ以内</p>
                  <div class="input">
                    <select name="contract_60flag" class="custom-select">
                      <option value="">—</option>
                      <option value="1">ＯＫ</option>
                      <option value="0">他</option>
                    </select>
                  </div>
                </div>

                <div class="row-line">
                  <p class="label">タグ／QRフラグ</p>
                  <div class="input">
                    <div class="form-check form-check-inline">
                      <input class="form-check-input" type="radio" name="tag_qr_flag" value="1" id="qr1">
                      <label class="form-check-label" for="qr1">ＱＲ</label>
                    </div>
                    <div class="form-check form-check-inline">
                      <input class="form-check-input" type="radio" name="tag_qr_flag" value="0" id="qr0" checked>
                      <label class="form-check-label" for="qr0">タグ</label>
                    </div>
                  </div>
                </div>
                <div class="row-line">
                  <p class="label">オペレータ名変更フラグ</p>
                  <div class="input">
                    <select name="tag_change_flag" class="custom-select">
                      <option value="">—</option>
                      <option value="1">タグに変更してる</option>
                      <option value="0">タグに変更していない</option>
                    </select>
                  </div>
                </div>

                <div class="row-line">
                  <p class="label">駐輪位置番号</p>
                  <div class="input"><input name="park_position" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">手動通知</p>
                  <div class="input"><input name="contract_manual" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">通知方法</p>
                  <div class="input"><input name="contract_notice" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">受付番号</p>
                  <div class="input"><input name="accept_number" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">オペレータID</p>
                  <div class="input"><input name="ope_id" class="form-control" type="number" min="0"></div>
                </div>

                <div class="row-line">
                  <p class="label">シール発行許可</p>
                  <div class="input">
                    <select name="contract_permission" class="custom-select">
                      <option value="">—</option>
                      <option value="1">許可</option>
                      <option value="0">未許可</option>
                    </select>
                  </div>
                </div>
                <div class="row-line">
                  <p class="label">解約フラグ</p>
                  <div class="input">
                    <select name="contract_cancel_flag" class="custom-select">
                      <option value="">—</option>
                      <option value="1">キャンセル</option>
                      <option value="0">－</option>
                    </select>
                  </div>
                </div>

                <div class="row-line">
                  <p class="label">収納企業コード</p>
                  <div class="input"><input name="company_code" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">共有先収納企業コード</p>
                  <div class="input"><input name="shared_company_code" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">（更新元）契約更新済フラグ</p>
                  <div class="input">
                    <select name="update_flag" class="custom-select">
                      <option value="">—</option>
                      <option value="1">更新済</option>
                      <option value="0">未更新</option>
                    </select>
                  </div>
                </div>
                <div class="row-line">
                  <p class="label">車種区分ID</p>
                  <div class="input"><input name="vehicle_type_id" class="form-control" type="number" min="0"></div>
                </div>

                {{-- チェック用（検索補助の控え） --}}
                <div class="row-line">
                  <p class="label">チェック用_フリガナ</p>
                  <div class="input"><input name="user_phonetic" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">チェック用_居住所郵便番号</p>
                  <div class="input"><input name="user_resident_zip" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">チェック用_携帯電話番号</p>
                  <div class="input"><input name="user_mobile" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">チェック用_自宅電話番号</p>
                  <div class="input"><input name="user_homephone" class="form-control" type="text"></div>
                </div>
                <div class="row-line">
                  <p class="label">チェック用_旧会員番号</p>
                  <div class="input"><input name="old_member_number" class="form-control" type="text"></div>
                </div>

              </div>
            </div>

            {{-- 下部：登録ボタン --}}
            <div class="mt-3">
              <button type="submit" class="btn btn-sm btn-default register js-confirm-submit">登録</button>
              <a href="{{ route('regularcontracts') }}" class="btn btn-sm btn-default">戻る</a>
            </div>
          </form>
        </div>
      </div>

    </div>
  </section>
</div>
@push('scripts')
<script>
  (function ($) {
    'use strict';

    $(function () {
      $(document).off('click.rcConfirm', '.js-confirm-submit').on('click.rcConfirm', '.js-confirm-submit', function (e) {
        e.preventDefault();
        var $button = $(this);

        $.confirm({
          title: '確認ダイアログ。',
          content: '登録してよろしいですか？　はい/いいえ',
          buttons: {
            ok: {
              text: 'はい',
              btnClass: 'btn-primary',
              keys: ['enter'],
              action: function () {
                var formId = $button.attr('form');
                if (formId) {
                  $('#' + formId).trigger('submit');
                  return;
                }
                var $form = $button.closest('form');
                if ($form.length) {
                  $form.trigger('submit');
                } else {
                  $('form').first().trigger('submit');
                }
              }
            },
            いいえ: function () {}
          }
        });
      });
    });
  })(jQuery);
</script>
@endpush
@endsection
