@extends('base.base')
@section('base')
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">绑定关系查询</h3>
                </div>
                <div class="card-body">
                    <form class="form-inline mb-4" method="get" action="{{ route('admin.extension_new.bind_list') }}">
                        <div class="form-group mx-sm-3 mb-2">
                            <label for="start_time" class="mr-2">选择注册时间：</label>
                            <input type="datetime-local" name="start_time" id="start_time" class="form-control" value="{{ $start_time }}">
                        </div>
                        <div class="form-group mx-sm-3 mb-2">
                            <input type="datetime-local" name="end_time" id="end_time" class="form-control" value="{{ $end_time }}">
                        </div>
                        <div class="form-group mx-sm-3 mb-2">
                            <label for="UserID" class="mr-2">会员ID：</label>
                            <input type="text" class="form-control" name="UserID" id="UserID" value="{{ $UserID }}">
                        </div>
                        <div class="form-group mx-sm-3 mb-2">
                            <label for="SpreaderID" class="mr-2">上级ID：</label>
                            <input type="text" class="form-control" name="SpreaderID" id="SpreaderID" value="{{ $SpreaderID }}">
                        </div>
                        <div class="form-group mx-sm-3 mb-2">
                            <label for="sort" class="mr-2">排序：</label>
                            <select name="sort" id="sort" class="form-control">
                                <option value="">请选择</option>
                                <option value="downCount1 + downCount2" @if($request->input('sort') == 'downCount1 + downCount2') selected @endif>按最多排序</option>
                            </select>
                        </div>
                        <button type="submit" class="btn btn-primary mb-2 mr-2">搜索</button>
                        <a href="{{ route('admin.extension_new.bind_list') }}" class="btn btn-warning mb-2">清空</a>
                    </form>

                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>会员ID</th>
                                    <th>TA的上级ID</th>
                                    <th>已发放额度</th>
                                    <th>账号创建时间</th>
                                    <th>最后登录时间</th>
{{--                                    <th>所有下级人数</th>--}}
                                    <th>直属下级</th>
{{--                                    <th>下下级</th>--}}
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($list as $v)
                                <tr>
                                    <td>
                                        <a href="/admin/global/id_find?UserID={{$v->UserID}}">
                                            {{$v->GameID}}
                                        </a>
                                    </td>
                                    <td>
                                        <a href="/admin/global/id_find?UserID={{$v->SpreaderID}}">
                                            {{ $v->SpreaderGameID }}
                                        </a>
                                    </td>
                                    <td>{{ $v->Rewards }}</td>
                                    <td>{{$v->RegisterDate??""}}</td>
                                    <td>{{ $v->LastLogonDate??"" }}</td>
{{--                                    <td>{{$v->downCount1 + $v->downCount2}}</td>--}}
                                    <td>
                                        @if($v->downCount1 > 0)
                                            {{$v->downCount1}}
                                        @else
                                            {{$v->downCount1}}
                                        @endif
                                    </td>
{{--                                    <td>--}}
{{--                                        @if($v->downCount2 > 0)--}}
{{--                                            {{$v->downCount2}}--}}
{{--                                        @else--}}
{{--                                            {{$v->downCount2}}--}}
{{--                                        @endif--}}
{{--                                    </td>--}}
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                    <div class="card-footer clearfix">
                        总共 <b>{{ $list->appends($request->all())->total() }}</b> 条,分为<b>{{ $list->lastPage() }}</b>页
                        {{ $list->links() }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@section('scripts')
<script>
    $(function() {
        $('#start_time, #end_time').datetimepicker({
            format: 'YYYY-MM-DD HH:mm:ss'
        });
    });
</script>
@endsection
