@extends('admin.layouts.main-layout')
@section('content')
<div class="card">
    <div class="card-header">
        <h3 class="card-title">Roulette Details</h3>
        <div class="row">
            <div class="col-md-12">
                <form role="form" method="get" action="">
                    <div class="box-body">
                        <div class="row">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <select class="form-control select2" name="period_id" style="width: 100%;">
                                        <option value="">--Select Period --</option>
                                        @foreach($periods as $key => $value)
                                        <option value="{{$value->id}}" {{Request::get('period_id') == $value->id ? 'selected' : ''}}>{{$value->period}}</option>
                                        @endforeach
                                    </select>

                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <input type="text" name="search_name" class="form-control  " value="{{Request::get('search_name')}}" placeholder="user name">

                                </div>
                            </div>

                            <div class="col-md-3">
                                <div class="form-group">
                                    <select class="form-control select2" name="search_status" style="width: 100%;">
                                        <option value="">--Page Show --</option>
                                        <option value="10" {{Request::get('search_status') == '10' ? 'selected' : ''}}>10</option>
                                        <option value="50" {{Request::get('search_status') == '50' ? 'selected' : ''}}>50</option>
                                        <option value="100" {{Request::get('search_status') == '100' ? 'selected' : ''}}>100</option>
                                        <option value="500" {{Request::get('search_status') == '500' ? 'selected' : ''}}>500</option>
                                        <option value="1000" {{Request::get('search_status') == '1000' ? 'selected' : ''}}>1000</option>
                                        <option value="5000" {{Request::get('search_status') == '5000' ? 'selected' : ''}}>5000</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <button type="submit" class="btn btn-success mr-2">Search</button>
                                <a href="{{url('admin/roulette-result')}}" class="btn btn-danger mr-2">Reset</a>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="row mt-4">
            <div class="col-md-6">
                <h6>Bet Details</h6>
                <h5><b>Period</b>: {{$period->period}}</h5>
                <h5><b>Total Bets</b>: {{$count}}</h5>
                <h5><b>Total Amount</b>: {{$total}}</h5>
            </div>
            <div class="col-md-6">
                <h6>Result Details</h6>
                @if($result)
                <h6><b>Jodi</b>: {{$result->number}}</h6>
                <h6><b>Colour</b>: {{$result->color}}</h6>
                <h6><b>Even/Odd</b>: {{$result->even_odd}}</h6>
                <h6><b>Small/Big</b>: {{$result->small_big}}</h6>
                <h6><b>Admin Amount</b>: {{$result->admin_amount}}</h6>
                <h6><b>Distributed Amount</b>: {{$result->distributed_amount}}</h6>
                @endif
            </div>
        </div>


    </div>
    <div align="left">



    </div>
    <!-- /.card-header -->
    <div class="card-body">
        @if(session()->has('message'))
        <div class="alert alert-success">
            {{ session()->get('message') }}
        </div>
        @endif
        <div id="example1_wrapper" class=" dt-bootstrap4">
            <div class="row">
                <div class="col-sm-12">
                    <div class='tablescroll'>
                        <div class="table-responsive">
                            <table id="example1" class="table table-bordered table-striped dataTable" role="grid"
                                aria-describedby="example1_info">
                                <thead>
                                    <tr role="row">
                                        <th class="sorting_asc" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                            aria-sort="ascending"
                                            aria-label="Rendering engine: activate to sort column descending"
                                            style="width: 60px;">#
                                        </th>
                                        <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                            aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                            User Name
                                        </th>
                                        <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                            aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                            User Mobile
                                        </th>
                                        <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                            aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                            Number / Color / Even Odd / Small Big
                                        </th>
                                        <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                            aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                            Amount
                                        </th>
                                        <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                            aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                            Date
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @php
                                    $page=1;
                                    if(Request::input('page'))
                                    $page=Request::input('page');
                                    $sort = $lists->perPage();
                                    @endphp
                                    @forelse($lists as $key => $list)
                                    <tr>
                                        <td>{{ $sort*($page-1)+($key+1) }}</td>
                                        <td>
                                            {{isset($list->user) ?$list->user->name : ''}}

                                        </td>
                                        <td>
                                            {{isset($list->user) ?$list->user->mobile_number : ''}}

                                        </td>
                                        <td>
                                            {{isset($list->roulette_betting_option) ?$list->roulette_betting_option->betting_options : ''}}
                                        </td>
                                        <td>
                                            {{$list->amount}}
                                        </td>
                                        <td>
                                            {{dateShow($list->created_at)}}
                                        </td>
                                    </tr>
                                    @empty
                                    <tr>
                                        <td colspan="7">Record not found </td>
                                    </tr>
                                    @endforelse
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-6 text-left" style="margin: 20px 0px;">
                            Showing {{$lists->firstItem()}} to {{$lists->lastItem()}} of {{$lists->total()}}
                        </div>
                        <div class="col-md-6 text-right">
                            {!! $lists->appends(request()->input())->links() !!}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
    <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
            <!--  <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div> -->
            <div class="modal-body">
                <div class="container">
                    <div class="justify-content-center">
                        <div class="">
                            <div class="card">
                                <div class="card-header">Fund Request <button type="button" class="close" data-dismiss="modal">&times;</button></div>
                                <div class="card-body">
                                    @if ($errors->any())
                                    <div class="alert alert-danger">
                                        <ul>
                                            @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                            @endforeach
                                        </ul>
                                    </div>
                                    @endif
                                    <form method="post" action="{{ url('/admin/fund') }}" autocomplete="off" enctype="multipart/form-data">
                                        @csrf

                                        <div class="form-group">
                                            <label for="title">Are you sure you want to accept the fund?</label>
                                        </div>


                                        <br>
                                        <input type="hidden" name="fund_id" value="">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary" name="type" value="accept">Accept</button>
                                            <button type="submit" class="btn btn-danger" name="type" value="reject">Reject</button>
                                        </div>

                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>

    </div>
</div>
@endsection
@section('js-content')
<script>
    function openModal(id) {
        $('input[name="fund_id"]').val(id);
        $('#myModal').modal();
    }
</script>
@endsection