@extends('layouts.app')
@section('title', '[東京都|〇〇駐輪場] 定期契約マスタ')
@section('content')
    <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><!-- /.col -->
                <div class="col-lg-6">
                    <ol class="breadcrumb float-sm-right text-sm">
                        <li class="breadcrumb-item"><a href="{{route('home')}}">XX様info(ホーム)</a></li>
                        <li class="breadcrumb-item"><a href="javascript: void(0);">[東京都|〇〇駐輪場]</a></li>
                        <li class="breadcrumb-item active">{{__('定期契約マスタ')}}</li>
                    </ol>
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <!-- SELECT2 EXAMPLE -->
            <form action="{{route('regular_contracts')}}" method="post" id="list-form">
                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                <input type="hidden" value="{{$sort}}" name="sort" id="sort">
                <input type="hidden" value="{{$sort_type}}" name="sort_type" id="sort_type">
            </form>
            <div class="row">


                <div class="container-fluid mb20">
                    <button type="submit" class="btn btn-sm btn-default mr10" name="delete"
                            id="delete">{{__('削除')}}</button>
                    <button type="submit" class="btn btn-sm btn-default mr10" name="import_csv" id="import_csv" action="{{route('regular_contracts_import')}}">{{__('インポート')}}</button>
                    <button type="submit" class="btn btn-sm btn-default mr10" name="export_csv" id="export_csv" action="{{route('regular_contracts_export')}}">{{__('CSV出力')}}</button>
                    {{ $list->appends(['sort' => $sort,'sort_type'=>$sort_type])->links('pagination') }}
                </div>
                <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>
                <div class="col-lg-12 row sample03-wrapper no_padding_right mb20">
                    <div class="col-xl-2 col-lg-2 col-md-2 col-sm-3 col-xs-3 table_left">
                        <form action="{{route('regular_contracts_delete')}}" method="post" id="form_delete">
                            <input type="hidden" name="_token" value="{{ csrf_token() }}">
                            <table class="table dataTable">
                                <thead>
                                <tr>
                                    <th>
                                        <input type="checkbox" class="minimal m-0" id="checkbox_all">
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $item)
                                    <tr role="row">
                                        <td>
                                            <input type="checkbox" class="minimal m-0 checkbox"
                                                   value="{{$item->contract_id}}" name="pk[]">
                                            <div class="btn_action">
                                                {{--<a href="{{route('regular_contract_add')}}" class="btn btn-sm btn-default">詳細</a>--}}
                                                <a href="{{route('regular_contract_info',['pk'=>$item->contract_id])}}"
                                                   class="btn btn-sm btn-default ml10">{{__('編集')}}</a>
                                            </div>
                                        </td>

                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </form>
                    </div>
                    <div class="col-lg-10 col-xl-10 col-md-10 col-sm-9 col-xs-9 table_right no_padding_right">
                        <div class="scroll">
                            <table class="table dataTable">
                                <thead>
                                <tr>

                                    <!--  定期契約ID -->
                                    <th class="sorting @if($sort=="contract_id"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contract_id"><span>{{__('validation.attributes.contract_id')}}</span>
                                    </th>
                                    <!-- 定期契約QRID -->
                                    <th class="sorting @if($sort=="contract_qr_id"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contract_qr_id">
                                        <span>{{__('validation.attributes.contract_qr_id')}}</span>
                                    </th>
                                    <!-- 利用者 -->
                                    <th class="sorting @if($sort=="user_id"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="user_id"><span>{{__('validation.attributes.user_name')}}</span>
                                    </th>
                                    <!-- 利用者分類 -->
                                    <th class="sorting @if($sort=="user_categoryid"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="user_categoryid">
                                        <span>{{__('validation.attributes.user_category_name')}}</span>
                                    </th>
                                    <!-- 定期予約-->
                                    <th class="sorting @if($sort=="reserve_id"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="reserve_id"><span>{{__('validation.attributes.reserve_name')}}</span>
                                    </th>
                                    <!-- 駐輪場 -->
                                    <th class="sorting @if($sort=="park_id"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="park_id"><span>{{__('validation.attributes.park_name')}}</span>
                                    </th>
                                    <!-- 駐輪場所 -->
                                    <th class="sorting @if($sort=="price_parkplaceid"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="price_parkplaceid">
                                        <span>{{__('validation.attributes.price_parkplace_name')}}</span>
                                    </th>
                                    <!-- 防犯登録番号 -->
                                    <th><span>{{__('validation.attributes.user_securitynum')}}</span></th>
                                    <!-- 予約日時 -->
                                    <th class="sorting @if($sort=="reserve_date"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="reserve_date"><span>{{__('validation.attributes.reserve_date')}}</span>
                                    </th>
                                    <!-- 予約移行フラグ -->
                                    <th class="sorting @if($sort=="contract_reserve"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contract_reserve">
                                        <span>{{__('validation.attributes.contract_reserve')}}</span>
                                    </th>
                                    <!-- 契約日時 -->
                                    <th class="sorting @if($sort=="contract_created_at"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contract_created_at">
                                        <span>{{__('validation.attributes.contract_created_at')}}</span>
                                    </th>
                                    <!-- 更新可能日 -->
                                    <th class="sorting @if($sort=="contract_updated_at"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contract_updated_at">
                                        <span>{{__('validation.attributes.contract_updated_at')}}</span>
                                    </th>
                                    <!-- 解約日時 -->
                                    <th class="sorting @if($sort=="contract_cancelday"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contract_cancelday">
                                        <span>{{__('validation.attributes.contract_cancelday')}}</span>
                                    </th>
                                    <!-- 減免措置 -->
                                    <th class="sorting @if($sort=="contract_reduction"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contract_reduction">
                                        <span>{{__('validation.attributes.contract_reduction')}}</span>
                                    </th>
                                    <!-- 有効期間S -->
                                    <th class="sorting @if($sort=="contract_periods"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contract_periods">
                                        <span>{{__('validation.attributes.contract_periods')}}</span>
                                    </th>
                                    <!-- 有効期間E -->
                                    <th class="sorting @if($sort=="contract_periode"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        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 @if($sort=="repayment_at"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="repayment_at"><span>{{__('validation.attributes.repayment_at')}}</span>
                                    </th>
                                    <!-- 決済コード -->
                                    <th class="sorting @if($sort=="contact_guid"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contact_guid"><span>{{__('validation.attributes.contact_guid')}}</span>
                                    </th>
                                    <!-- 店舗コード -->
                                    <th class="sorting @if($sort=="contact_shop_code"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        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 @if($sort=="contract_cancel_flag"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        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 @if($sort=="park_position"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        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 @if($sort=="contract_payment_number"){{$sort_type == 'asc'?'sorting_asc':'sorting_desc'}}@endif"
                                        sort="contract_payment_number">
                                        <span>{{__('validation.attributes.contract_payment_number')}}</span>
                                    </th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $item)
                                    <tr>
                                        <!-- 定期契約ID -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->contract_id, 0, 10)}}</span></td>
                                        <!-- 定期契約QRID -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->contract_qr_id, 0, 10)}}</span></td>
                                        <!-- 利用者ID -->
                                        <td class='sm-item text-left'>
                                            {{--<span>{{mb_substr(!empty($item->userName())?$item->userName()->user_name:'', 0, 10)}}</span>--}}
                                            <span>{{mb_substr($item->user_id, 0, 10)}}</span>
                                        </td>
                                        <!-- 利用者分類ID -->
                                        <td class='sm-item text-left'>
                                            {{--<span>{{mb_substr(!empty($item->getUserType())?$item->getUserType()->print_name:'', 0, 10)}}</span>--}}
                                            <span>{{mb_substr($item->user_categoryid, 0, 10)}}</span>
                                        </td>
                                        <!-- 定期予約ID -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->reserve_id, 0, 10)}}</span></td>
                                        <!-- 駐輪場ID -->
                                        <td class='sm-item text-left'>
                                            {{--<span>{{mb_substr(!empty($item->getPark())?$item->getPark()->park_name:'', 0, 10)}}</span>--}}
                                            <span>{{mb_substr($item->park_id, 0, 10)}}</span>
                                        </td>
                                        <!-- 駐輪場所ID -->
                                        <td class='sm-item text-left'>
                                            {{--<span>{{mb_substr(!empty($item->getPrice())?$item->getPrice()->prine_name:'', 0, 10)}}</span>--}}
                                            <span>{{mb_substr($item->price_parkplaceid, 0, 10)}}</span>
                                        </td>
                                        <!-- 防犯登録番号 -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->user_securitynum, 0, 10)}}</span></td>
                                        <!-- 予約日時 -->
                                        <td class='sm-item text-right'>
                                            @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'>
                                            <span>{{mb_substr($item->contract_reserve, 0, 10)}}</span></td>
                                        <!-- 契約日時 -->
                                        <td class='sm-item text-right'>
                                            @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'>
                                            @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'>
                                            @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'>
                                            <span>{{mb_substr($item->contract_reduction, 0, 10)}}</span></td>
                                        <!-- 有効期間S -->
                                        <td class='sm-item text-right'>
                                            @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>
                                        <!-- 有効期間E -->
                                        <td class='sm-item text-right'>
                                            @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>
                                        <!-- 消費税ID -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->contract_taxid, 0, 10)}}</span></td>
                                        <!-- 請求金額 -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->billing_amount, 0, 10)}}</span></td>
                                        <!-- 授受日時 -->
                                        <td class='sm-item text-right'>
                                            @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'>
                                            <span>{{mb_substr($item->contract_money, 0, 10)}}</span></td>
                                        <!-- 解約時返戻金 -->
                                        <td class='sm-item text-left'><span>{{mb_substr($item->refunds, 0, 10)}}</span>
                                        </td>
                                        <!-- 返戻金付随情報 -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->refunds_comment, 0, 10)}}</span></td>
                                        <!-- 返金日 -->
                                        <td class='sm-item text-right'>
                                            @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'>
                                            <span>{{mb_substr($item->contact_guid, 0, 10)}}</span></td>
                                        <!-- 店舗コード -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->contact_shop_code, 0, 10)}}</span></td>
                                        <!-- 授受種別 -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->contract_cvs_class, 0, 10)}}</span></td>
                                        <!-- 授受フラグ -->
                                        <td class='sm-item text-right'>
                                            <span>{{$item->contract_flag? __("はい") : __("いいえ") }}</span>
                                        </td>
                                        <!-- 決済トランザクションID -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->settlement_transaction_id, 0, 10)}}</span></td>
                                        <!-- シール発行数 -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->contract_seal_issue, 0, 10)}}</span></td>
                                        <!-- シール再発行リクエスト -->
                                        <td class='sm-item text-right'>
                                            <span>{{$item->seal_reissue_request?__("はい"):__("いいえ")}}</span></td>
                                        <!-- シール発行許可 -->
                                        <td class='sm-item text-left'>
                                            <span>{{$item->contract_permission?__("発行許可"):__("発行許可しない")}}</span></td>
                                        <!-- 解約フラグ -->
                                        <td class='sm-item text-right'>
                                            <span>{{$item->contract_cancel_flag? __("解約") : __("解約しない")}}</span></td>
                                        <!-- タグ／ＱＲフラグ -->
                                        <td class='sm-item text-right'>
                                            <span>{{$item->tag_qr_flag?__("ＱＲ") :__("タグ")}}</span>
                                        </td>
                                        <!-- オペレータータグ変更フラグ -->
                                        <td class='sm-item text-right'>
                                            <span>{{$item->tag_change_flag? __("タグに変更する"): __("タグに変更しない")}}</span></td>
                                        <!-- 駐輪位置番号 -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->park_position, 0, 10)}}</span></td>
                                        <!-- オペレータID -->
                                        <td class='sm-item text-left'>
                                            {{--<span>{{mb_substr(!empty($item->getOpe())? $item->getOpe()->ope_name:'', 0, 10)}}</span>--}}
                                            <span>{{mb_substr($item->ope_id, 0, 10)}}</span></td>
                                        </td>
                                        <!-- 手動通知 -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->contract_manual, 0, 10)}}</span></td>
                                        <!-- 通知方法 -->
                                        <td class='sm-item text-left'>
                                            <span>{{mb_substr($item->contract_notice, 0, 10)}}</span></td>
                                        <!-- 受付番号 -->
                                        <td class='sm-item text-right'>
                                            <span>{{mb_substr($item->contract_payment_number, 0, 10)}}</span></td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>

            </div>
            <!-- /.row -->
        </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->

@endsection