@extends('layouts.app')
@section('title', '定期契約マスタ')

@section('content')

<!-- Content Header -->
<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 active">定期契約マスタ</li>
                </ol>
            </div>
        </div>
    </div>
</div>

<!-- Main Content -->
<section class="content">
    <div class="container-fluid">
        <div class="mb-2">
            <span>
                ※この画面のデータは通常変更する必要はありません。
            </span>
        </div>

        <!-- ▼ 絞り込みフィルター -->
        <div class="col-lg-12 px-0">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">絞り込みフィルター</h3>
                </div>

                <div class="card-body">
                    <form action="{{ route('regularcontracts') }}" method="POST" id="list-form">
                        @csrf
                        <input type="hidden" name="sort" id="sort" value="{{ $sort ?? '' }}">
                        <input type="hidden" name="sort_type" id="sort_type" value="{{ $sort_type ?? '' }}">

                        {{-- 1行目：利用者ID / 駐輪場 --}}
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">利用者ID</div>
                                    <div class="col-9">
                                        <input type="text" name="user_id" id="user_id" class="form-control"
                                               value="{{ $inputs['user_id'] ?? '' }}" placeholder="123456">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">駐輪場</div>
                                    <div class="col-9">
                                        <select name="park_id" class="form-control">
                                            <option value="">全て</option>
                                            @foreach(($parkOptions ?? $parkList ?? []) as $id => $name)
                                                <option value="{{ $id }}" @if(($inputs['park_id'] ?? '') == (string)$id) selected @endif>
                                                    {{ $name }}
                                                </option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- 2行目：利用者分類 / 予約日時（～） --}}
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">利用者分類</div>
                                    <div class="col-9">
                                        <select name="user_categoryid" class="form-control">
                                            <option value="">全て</option>
                                            @foreach(($userTypeOptions ?? $userCategoryList ?? []) as $id => $name)
                                                <option value="{{ $id }}" @if(($inputs['user_categoryid'] ?? '') == (string)$id) selected @endif>
                                                    {{ $name }}
                                                </option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">予約日時</div>
                                    <div class="col-9 d-flex align-items-center">
                                        <input type="datetime-local" name="reserve_date_from" class="form-control"
                                               value="{{ $inputs['reserve_date_from'] ?? '' }}">
                                        <span class="mx-3">～</span>
                                        <input type="datetime-local" name="reserve_date_to" class="form-control"
                                               value="{{ $inputs['reserve_date_to'] ?? '' }}">
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- 3行目：タグシリアル / 契約日時（～） --}}
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">タグシリアル</div>
                                    <div class="col-9">
                                        <input type="text" name="user_tag_serial" class="form-control"
                                               value="{{ $inputs['user_tag_serial'] ?? '' }}" placeholder="キーワード...">
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">契約日時</div>
                                    <div class="col-9 d-flex align-items-center">
                                        <input type="datetime-local" name="contract_created_from" class="form-control"
                                               value="{{ $inputs['contract_created_from'] ?? '' }}">
                                        <span class="mx-3">～</span>
                                        <input type="datetime-local" name="contract_created_to" class="form-control"
                                               value="{{ $inputs['contract_created_to'] ?? '' }}">
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- 4行目：フリガナ / 解約日時（～） --}}
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">フリガナ</div>
                                    <div class="col-9">
                                        {{-- 利用者フリガナ（u.user_phonetic） --}}
                                        <input type="text" name="user_phonetic" class="form-control"
                                               value="{{ $inputs['user_phonetic'] ?? '' }}" placeholder="キーワード...">
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">解約日時</div>
                                    <div class="col-9 d-flex align-items-center">
                                        <input type="datetime-local" name="contract_canceled_from" class="form-control"
                                               value="{{ $inputs['contract_canceled_from'] ?? '' }}">
                                        <span class="mx-3">～</span>
                                        <input type="datetime-local" name="contract_canceled_to" class="form-control"
                                               value="{{ $inputs['contract_canceled_to'] ?? '' }}">
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- 5行目：電話番号 / 授受日時（～） --}}
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">電話番号</div>
                                    <div class="col-9">
                                        <input type="text" name="phone" class="form-control"
                                               value="{{ $inputs['phone'] ?? '' }}" placeholder="キーワード...">
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">授受日時</div>
                                    <div class="col-9 d-flex align-items-center">
                                        <input type="datetime-local" name="receipt_delivery_from" class="form-control"
                                               value="{{ $inputs['receipt_delivery_from'] ?? '' }}">
                                        <span class="mx-3">～</span>
                                        <input type="datetime-local" name="receipt_delivery_to" class="form-control"
                                               value="{{ $inputs['receipt_delivery_to'] ?? '' }}">
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- 6行目：メールアドレス / 定期有効月数（全て） --}}
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">メールアドレス</div>
                                    <div class="col-9">
                                        <input type="text" name="email" class="form-control"
                                               value="{{ $inputs['email'] ?? '' }}" placeholder="キーワード...">
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">定期有効月数</div>
                                    <div class="col-9">
                                        {{-- controllerは contract_valid_months を見ています --}}
                                        <select name="enable_months" class="form-control">
                                            <option value="">全て</option>
                                            @foreach(($enableMonthsList ?? []) as $id => $name)
                                                <option value="{{ $id }}" @if(($inputs['enable_months'] ?? '') == (string)$id) selected @endif>
                                                    {{ $name }}
                                                </option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- 7行目：ワークコード / 定期契約継続 --}}
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">ワークコード</div>
                                    <div class="col-9">
                                        <select name="work_record" class="form-control">
                                            <option value="0" @if(($inputs['work_record'] ?? '0') === '0') selected @endif>
                                                全レコード表示
                                            </option>
                                            <option value="1" @if(($inputs['work_record'] ?? '') === '1') selected @endif>
                                                ワークレコード非表示
                                            </option>
                                            <option value="2" @if(($inputs['work_record'] ?? '') === '2') selected @endif>
                                                ワークレコード表示
                                            </option>
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">定期契約継続</div>
                                    <div class="col-9">
                                        <select name="contract_permission" class="form-control">
                                            <option value="">全て</option>
                                            <option value="1" @if(($inputs['contract_permission'] ?? '') === '1') selected @endif>継続</option>
                                            <option value="0" @if(($inputs['contract_permission'] ?? '') === '0') selected @endif>継続しない</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- 8行目：定期契約ID / 名寄フリガナ --}}
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">定期契約ID</div>
                                    <div class="col-9">
                                        <input type="text" name="contract_id" class="form-control"
                                               value="{{ $inputs['contract_id'] ?? '' }}" placeholder="定期契約ID">
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">名寄フリガナ</div>
                                    <div class="col-9">
                                        {{-- controllerは merge_phonetic を見て rc.chk_user_phonetic を検索 --}}
                                        <input type="text" name="merge_phonetic" class="form-control"
                                               value="{{ $inputs['merge_phonetic'] ?? '' }}">
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- 9行目：検索 / ゾーン名検索 --}}
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">検索</div>
                                    <div class="col-9">
                                        <input type="text" name="zone_keyword" class="form-control"
                                               value="{{ $inputs['zone_keyword'] ?? '' }}" placeholder="ゾーンID,車室番号,旧会員番号">
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">ゾーン名検索</div>
                                    <div class="col-9">
                                        <input type="text" name="zone_name" class="form-control"
                                               value="{{ $inputs['zone_name'] ?? '' }}">
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- 10行目：関連住所入力あり / タグ・QR --}}
                        <div class="row mb-4">
                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">関連住所入力あり</div>
                                    <div class="col-9">
                                        <div class="d-flex align-items-center" style="height: 38px;">
                                            <input type="checkbox" name="has_address" value="1"
                                                   @if(($inputs['has_address'] ?? '') == '1') checked @endif>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-6">
                                <div class="row align-items-center">
                                    <div class="col-3 font-weight-bold">タグ・QR</div>
                                    <div class="col-9">
                                        <select name="tag_qr_flag" class="form-control">
                                            <option value="">全て</option>
                                            <option value="1" @if(($inputs['tag_qr_flag'] ?? '') === '1') selected @endif>QR</option>
                                            <option value="0" @if(($inputs['tag_qr_flag'] ?? '') === '0') selected @endif>タグ</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        {{-- ボタン（図２の左下） --}}
                        <div class="mt-2">
                            <button type="submit" name="action" value="filter" class="btn btn-default mr-2">絞り込み</button>
                            <button type="submit" name="action" value="unlink" class="btn btn-default">解除</button>
                        </div>

                    </form>
                </div>
            </div>
        </div>
        <!-- ▲ 絞り込みフィルターここまで -->

        <!-- ▼ 操作ボタン -->
        <div class="col-lg-12 mb-3">
            <button type="button" class="btn btn-sm btn-default mr10"
                    onclick="location.href='{{ route('regularcontracts_add') }}'">新規</button>
            <button type="button" class="btn btn-sm btn-default mr10" id="delete">削除</button>
            <button type="button" class="btn btn-sm btn-default mr10"
                    onclick="location.href='{{ route('regularcontracts_import') }}'">インポート
            </button>
           <button type="button"
                    class="btn btn-sm btn-default mr10"
                    name="export_csv"
                    id="export_csv"
                    action="{{ route('regularcontracts_export') }}">
                {{ __('CSV出力') }}
            </button>
            
             <a class="btn btn-sm btn-default mr10"
            href="{{ route('regularcontracts_export', request()->query() + ['type' => 'city']) }}">
                役所提出用CSV出力
            </a>       
        </div>

        <!-- ▼ ページネーション -->
        <div class="col-lg-12 mb-3">
            <div class="d-flex justify-content-end">
                {{ $list->links('pagination') }}
            </div>
        </div>

        {{-- ▼ フラッシュメッセージ（stations と同じ） --}}
        <div class="form col-lg-12">
            @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>

        <!-- ▼ ここから単一テーブル構成（stations と同じ） -->
        <div class="col-lg-12 mb20">
            <div class="table-responsive">
                <form action="{{ route('regularcontracts_delete') }}" method="POST" id="form_delete">
                    @csrf
                    <table class="table table-bordered dataTable text-nowrap">
                        <thead class="thead-light">
                        <tr>
                            {{-- ★ チェック + 編集 用の1列 --}}
                            <th style="width:140px;" class="text-left">
                                <input type="checkbox" onclick="$('input[name*=\'ids\']').prop('checked', this.checked);">
                            </th>

                            <!--  定期契約ID -->
                            <th class="sorting {{ ($sort=='contract_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_id">
                                <span>{{__('validation.attributes.contract_id')}}</span>
                            </th>

                            <!-- 定期契約QRID -->
                            <th class="sorting {{ ($sort=='contract_qr_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_qr_id">
                                <span>{{__('validation.attributes.contract_qr_id')}}</span>
                            </th>

                            <!-- 利用者 -->
                            <th class="sorting {{ ($sort=='user_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="user_id">
                                <span>{{__('validation.attributes.user_name')}}</span>
                            </th>

                            <!-- 利用者分類 -->
                            <th class="sorting {{ ($sort=='user_categoryid') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="user_categoryid">
                                <span>{{__('validation.attributes.user_category_name')}}</span>
                            </th>

                            <!-- 定期予約 -->
                            <th class="sorting {{ ($sort=='reserve_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="reserve_id">
                                <span>{{__('validation.attributes.reserve_name')}}</span>
                            </th>

                            <!-- 駐輪場 -->
                            <th class="sorting {{ ($sort=='park_id') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="park_id">
                                <span>{{__('validation.attributes.park_name')}}</span>
                            </th>

                            <!-- 駐輪場所 -->
                            <th class="sorting {{ ($sort=='price_parkplaceid') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="price_parkplaceid">
                                <span>{{__('validation.attributes.price_parkplace_name')}}</span>
                            </th>

                            <!-- 防犯登録番号 -->
                            <th><span>{{__('validation.attributes.user_securitynum')}}</span></th>

                            <!-- 予約日時 -->
                            <th class="sorting {{ ($sort=='reserve_date') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="reserve_date">
                                <span>{{__('validation.attributes.reserve_date')}}</span>
                            </th>

                            <!-- 予約移行フラグ -->
                            <th class="sorting {{ ($sort=='contract_reserve') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_reserve">
                                <span>{{__('validation.attributes.contract_reserve')}}</span>
                            </th>

                            <!-- 契約日時 -->
                            <th class="sorting {{ ($sort=='contract_created_at') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_created_at">
                                <span>{{__('validation.attributes.contract_created_at')}}</span>
                            </th>

                            <!-- 更新可能日 -->
                            <th class="sorting {{ ($sort=='contract_updated_at') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_updated_at">
                                <span>{{__('validation.attributes.contract_updated_at')}}</span>
                            </th>

                            <!-- 解約日時 -->
                            <th class="sorting {{ ($sort=='contract_cancelday') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_cancelday">
                                <span>{{__('validation.attributes.contract_cancelday')}}</span>
                            </th>

                            <!-- 減免措置 -->
                            <th class="sorting {{ ($sort=='contract_reduction') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_reduction">
                                <span>{{__('validation.attributes.contract_reduction')}}</span>
                            </th>

                            <!-- 有効期間S -->
                            <th class="sorting {{ ($sort=='contract_periods') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_periods">
                                <span>{{__('validation.attributes.contract_periods')}}</span>
                            </th>

                            <!-- 有効期間E -->
                            <th class="sorting {{ ($sort=='contract_periode') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_periode">
                                <span>{{__('validation.attributes.contract_periode')}}</span>
                            </th>

                            <!-- 消費税ID -->
                            <th><span>{{__('validation.attributes.contract_taxid')}}</span></th>

                            <!-- 請求金額 -->
                            <th><span>{{__('validation.attributes.billing_amount')}}</span></th>

                            <!-- 授受日時 -->
                            <th><span>{{__('validation.attributes.contract_payment_day')}}</span></th>

                            <!-- 授受金額 -->
                            <th><span>{{__('validation.attributes.contract_money')}}</span></th>

                            <!-- 解約時返戻金 -->
                            <th><span>{{__('validation.attributes.refunds')}}</span></th>

                            <!-- 返戻金付随情報 -->
                            <th><span>{{__('validation.attributes.refunds_comment')}}</span></th>

                            <!-- 返金日 -->
                            <th class="sorting {{ ($sort=='repayment_at') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="repayment_at">
                                <span>{{__('validation.attributes.repayment_at')}}</span>
                            </th>

                            <!-- 決済コード -->
                            <th class="sorting {{ ($sort=='contact_guid') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contact_guid">
                                <span>{{__('validation.attributes.contact_guid')}}</span>
                            </th>

                            <!-- 店舗コード -->
                            <th class="sorting {{ ($sort=='contact_shop_code') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contact_shop_code">
                                <span>{{__('validation.attributes.contact_shop_code')}}</span>
                            </th>

                            <!-- 授受種別 -->
                            <th><span>{{__('validation.attributes.contract_cvs_class')}}</span></th>

                            <!-- 授受フラグ -->
                            <th><span>{{__('validation.attributes.contract_flag')}}</span></th>

                            <!-- 決済トランザクションID -->
                            <th><span>{{__('validation.attributes.settlement_transaction_id')}}</span></th>

                            <!-- シール発行数 -->
                            <th><span>{{__('validation.attributes.contract_seal_issue')}}</span></th>

                            <!-- シール再発行リクエスト -->
                            <th><span>{{__('validation.attributes.seal_reissue_request')}}</span></th>

                            <!-- シール発行許可 -->
                            <th><span>{{__('validation.attributes.contract_permission')}}</span></th>

                            <!-- 解約フラグ -->
                            <th class="sorting {{ ($sort=='contract_cancel_flag') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_cancel_flag">
                                <span>{{__('validation.attributes.contract_cancel_flag')}}</span>
                            </th>

                            <!-- タグ／ＱＲフラグ -->
                            <th><span>{{__('validation.attributes.tag_qr_flag')}}</span></th>

                            <!-- オペレータータグ変更フラグ -->
                            <th><span>{{__('validation.attributes.tag_change_flag')}}</span></th>

                            <!-- 駐輪位置番号 -->
                            <th class="sorting {{ ($sort=='park_position') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="park_position">
                                <span>{{__('validation.attributes.park_position')}}</span>
                            </th>

                            <!-- オペレータID -->
                            <th><span>{{__('validation.attributes.ope_id')}}</span></th>

                            <!-- 手動通知 -->
                            <th><span>{{__('validation.attributes.contract_manual')}}</span></th>

                            <!-- 通知方法 -->
                            <th><span>{{__('validation.attributes.contract_notice')}}</span></th>

                            <!-- 受付番号 -->
                            <th class="sorting {{ ($sort=='contract_payment_number') ? ($sort_type=='asc'?'sorting_asc':'sorting_desc') : '' }}" sort="contract_payment_number">
                                <span>{{__('validation.attributes.contract_payment_number')}}</span>
                            </th>
                        </tr>
                        </thead>

                        <tbody class="bg-white">
                        @foreach($list as $item)
                            <tr>
                                {{-- ★ 同じセル内に チェック + 編集ボタン（stations と同じ） --}}
                                <td class="align-middle" style="background-color:#faebd7;">
                                    <div class="d-flex align-items-center">
                                        <input type="checkbox" class="m-0 checkbox" name="ids[]" value="{{ $item->contract_id }}">
                                        <a href="{{ route('regularcontracts_info', ['contract_id' => $item->contract_id]) }}" class="btn btn-sm btn-default ml10">編集</a>
                                    </div>
                                </td>

                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->contract_id, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->contract_qr_id, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->user_id, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->user_categoryid, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->reserve_id, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->park_id, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->price_parkplaceid, 0, 10) }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ mb_substr($item->user_securitynum, 0, 10) }}</span></td>

                                <td class="sm-item text-right align-middle">
                                    @if($item->reserve_date)
                                        <span class="text-muted"><i class="fa fa-clock-o mr-1"></i>{{ mb_substr($item->reserve_date, 0, 10) }}</span>
                                    @endif
                                </td>

                                <td class="sm-item text-right align-middle"><span>{{ mb_substr($item->contract_reserve, 0, 10) }}</span></td>

                                <td class="sm-item text-right align-middle">
                                    @if($item->created_at)
                                        <span class="text-muted"><i class="fa fa-clock-o mr-1"></i>{{ mb_substr($item->created_at, 0, 10) }}</span>
                                    @endif
                                </td>

                                <td class="sm-item text-right align-middle">
                                    @if($item->updated_at)
                                        <span class="text-muted"><i class="fa fa-clock-o mr-1"></i>{{ mb_substr($item->updated_at, 0, 10) }}</span>
                                    @endif
                                </td>

                                <td class="sm-item text-right align-middle">
                                    @if($item->contract_cancelday)
                                        <span class="text-muted"><i class="fa fa-clock-o mr-1"></i>{{ mb_substr($item->contract_cancelday, 0, 10) }}</span>
                                    @endif
                                </td>

                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->contract_reduction, 0, 10) }}</span></td>

                                <td class="sm-item text-right align-middle">
                                    @if($item->contract_periods)
                                        <span class="text-muted"><i class="fa fa-clock-o mr-1"></i>{{ mb_substr($item->contract_periods, 0, 10) }}</span>
                                    @endif
                                </td>

                                <td class="sm-item text-right align-middle">
                                    @if($item->contract_periode)
                                        <span class="text-muted"><i class="fa fa-clock-o mr-1"></i>{{ mb_substr($item->contract_periode, 0, 10) }}</span>
                                    @endif
                                </td>

                                <td class="sm-item text-right align-middle"><span>{{ mb_substr($item->contract_taxid, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->billing_amount, 0, 10) }}</span></td>

                                <td class="sm-item text-right align-middle">
                                    @if($item->contract_payment_day)
                                        <span class="text-muted"><i class="fa fa-clock-o mr-1"></i>{{ mb_substr($item->contract_payment_day, 0, 10) }}</span>
                                    @endif
                                </td>

                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->contract_money, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->refunds, 0, 10) }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ mb_substr($item->refunds_comment, 0, 10) }}</span></td>

                                <td class="sm-item text-right align-middle">
                                    @if($item->repayment_at)
                                        <span class="text-muted"><i class="fa fa-clock-o mr-1"></i>{{ mb_substr($item->repayment_at, 0, 10) }}</span>
                                    @endif
                                </td>

                                <td class="sm-item text-right align-middle"><span>{{ mb_substr($item->contact_guid, 0, 10) }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ mb_substr($item->contact_shop_code, 0, 10) }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ mb_substr($item->contract_cvs_class, 0, 10) }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ $item->contract_flag ? __("はい") : __("いいえ") }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->settlement_transaction_id, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->contract_seal_issue, 0, 10) }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ $item->seal_reissue_request ? __("はい") : __("いいえ") }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ $item->contract_permission ? __("発行許可") : __("発行許可しない") }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ $item->contract_cancel_flag ? __("解約") : __("解約しない") }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ $item->tag_qr_flag ? __("ＱＲ") : __("タグ") }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ $item->tag_change_flag ? __("タグに変更する") : __("タグに変更しない") }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ mb_substr($item->park_position, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->ope_id, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->contract_manual, 0, 10) }}</span></td>
                                <td class="sm-item text-left align-middle"><span>{{ mb_substr($item->contract_notice, 0, 10) }}</span></td>
                                <td class="sm-item text-right align-middle"><span>{{ mb_substr($item->contract_payment_number, 0, 10) }}</span></td>
                            </tr>
                        @endforeach
                        </tbody>

                    </table>
                </form>
            </div>
        </div>
        <!-- ▲ 単一テーブル構成ここまで -->
    </section>

@endsection
