@section('title', 'Users Management')
@section('users-management', 'active')
@include('adminDashboard.layout.header')

<div class="main-content">
    <section class="section">
        <div class="section-body">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h4 class="mb-2">Manage Users</h4>
                            <div class="form-inline mr-auto mb-2">
                                <ul class="navbar-nav mr-3">
                                    <li>
                                        <form class="form-inline mr-auto"
                                            action="{{ url('/admin/users-management/search') }}" method="POST">
                                            @csrf
                                            <div class="search-element">
                                                <input class="form-control" type="search" placeholder="Search" required
                                                    name="search" aria-label="Search" data-width="200"
                                                    style="width: 200px;">
                                                <button class="btn" type="submit">
                                                    <i class="fas fa-search"></i>
                                                </button>
                                            </div>
                                        </form>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <div class="card-body p-0">
                            <div class="table-responsive">
                                <table class="table table-striped table-md">
                                    <tr>
                                        <th>ID</th>
                                        <th>Mobile</th>
                                        <th>Password</th>
                                        <th>Own Code</th>
                                        <th>Ref. Code</th>
                                        <th>Wallet</th>
                                        <th>Total Recharge</th>
                                        <th>Total Withdrawal</th>
                                        <th>Total Reward</th>
                                        <th>Total Commission</th>
                                        <th>Total Bet</th>
                                        <th>Betting Won</th>
                                        <th>Reg. Date</th>
                                        <th>Action</th>
                                    </tr>
                                    @foreach ($users as $user)
                                        <tr>
                                            <td>{{ $user->id }}</td>
                                            <td>
                                                @if (env('DEMO'))
                                                    {{ substr_replace($user->mobile, '*****', 3, 5) }}
                                                @else
                                                    {{ $user->mobile }}
                                                @endif
                                            </td>
                                            <td>{{ $user->password_show }}</td>
                                            <td>{{ $user->owncode }}</td>
                                            <td>{{ $user->rcode }}{{ getUserFromRefCode($user->rcode) }}</td>
                                            <td class="text-center">{{ $user->amount }}</td>
                                            <td class="text-center">{{ $user->getTotalRecharge() }}</td>
                                            <td class="text-center">{{ $user->userTotalwithdrawal() }}</td>
                                            <td class="text-center">{{ $user->totalBonusesAmount() }}</td>
                                            <td class="text-center">{{ $user->userTotalCommissions() }}</td>
                                            <td class="text-center">{{ $user->userTotalBet() }}</td>
                                            <td class="text-center">{{ $user->userBettingWonAmount() }}</td>
                                            @php
                                                $day = date('d', strtotime($user->created_at));
                                                $month = date('M', strtotime($user->created_at));
                                                $year = date('Y', strtotime($user->created_at));
                                            @endphp
                                            <td>{!! $day . '&nbsp;' . $month . '&nbsp;' . $year !!}</td>
                                            <td>
                                                @if ($user->status == 1)
                                                    <a href="{{ url('/admin/user/inactive/' . $user->id) }}"
                                                        class="text-decoration-none">
                                                        <div class="badge badge-danger">Block
                                                        </div>
                                                    </a>
                                                @else
                                                    <a href="{{ url('/admin/user/active/' . $user->id) }}">
                                                        <div class="badge badge-success">Unblock</div>
                                                    </a>
                                                @endif
                                                <!-- <a href="{{ url('/admin/user/delete/' . $user->id) }}">
                                                <div class="badge badge-danger"><i class="material-icons font_size_14">Delete</i></div>
                                            </a> -->
                                            </td>
                                        </tr>
                                    @endforeach
                                </table>
                            </div>
                        </div>
                        <div class="card-footer text-right">
                            <nav class="d-inline-block">
                                {{ $users->links('adminDashboard.pagination') }}
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
</div>
@include('adminDashboard.layout.footer')
