@extends('admin.layouts.app')
@section('panel')
    <div class="row">

        <div class="col-lg-12">
            <div class="show-filter mb-3 text-end">
                <button type="button" class="btn btn-outline--primary showFilterBtn btn-sm"><i class="las la-filter"></i>
                    @lang('Filter')</button>
            </div>

            @if ($pageTitle != 'Dummy Person')
                <div class="card responsive-filter-card mb-4">
                    <div class="card-body">
                        <form action="">
                            <div class="d-flex flex-wrap gap-4">
                                <div class="flex-grow-1">
                                    <label>@lang('Email/Username/UserID')</label>
                                    <input type="text" name="search" value="{{ request()->search }}"
                                        class="form-control">
                                </div>
                                {{-- <div class="flex-grow-1">
                                    <label>@lang('Network Status')</label>
                                    <select name="network_status" class="form-control">
                                        <option value="" @selected(empty(request()->network_status))>@lang('All')</option>
                                        <option value="{{ Status::NetworkPending }}" @selected(request()->network_status == Status::NetworkPending)>
                                            @lang('Pending')</option>
                                        <option value="{{ Status::NetworkPlanPurchased }}" @selected(request()->network_status == Status::NetworkPlanPurchased)>
                                            @lang('Plan Purchased')</option>
                                        <option value="{{ Status::NetworkFullActivated }}" @selected(request()->network_status == Status::NetworkFullActivated)>
                                            @lang('Full Activated')</option>
                                    </select>
                                </div> --}}

                                <div class="flex-grow-1">
                                    <label>@lang('Date')</label>
                                    <input name="date" type="text" data-range="true"
                                        data-multiple-dates-separator=" - " data-language="en"
                                        class="datepicker-here form-control" data-position='bottom right'
                                        placeholder="@lang('Start date - End date')" autocomplete="off" value="{{ request()->date }}">
                                </div>

                                <div class="flex-grow-1 align-self-end">
                                    <button class="btn btn--primary w-100 h-45"><i class="fas fa-filter"></i>
                                        @lang('Filter')</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            @endif


            @if (!request()->routeIs('admin.users.dummy'))
                <div class="d-flex justify-content-end">
                    <div class="btn-group mb-3" role="group" aria-label="Basic example">
                        <a href="{{ route('admin.users.export', ['search' => request()->search, 'network_status' => request()->network_status, 'date' => request()->date, 'scope' => @$scope]) }}"
                            class="btn btn--success"><i class="las la-file-excel"></i> @lang('Export Excel')</a>
                        <a href="{{ route('admin.users.generate.pdf', ['search' => request()->search, 'network_status' => request()->network_status, 'date' => request()->date, 'scope' => @$scope]) }}"
                            class="btn btn--danger"><i class="las la-file-pdf"></i> @lang('Export PDF')</a>
                    </div>
                </div>
            @endif

            <div class="card b-radius--10 ">
                <div class="card-body p-0">
                    <div class="table-responsive--md  table-responsive">
                        <table class="table table--light style--two">
                            <thead>
                                <tr>
                                    <th>@lang('User')</th>
                                    <th>@lang('Email-Phone')</th>
                                    <th>@lang('Country')</th>
                                    <th>@lang('Joined At')</th>
                                    <th>@lang('Balance')</th>
                                    <th>@lang('Action')</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse($users as $user)
                                    <tr>
                                        <td>
                                            <span class="fw-bold">{{ $user->fullname }}</span>
                                            <br>
                                            UserId: {{ $user->system_id }}
                                            <br>
                                            <span class="small">
                                                <a
                                                    href="{{ route('admin.users.detail', $user->id) }}"><span>@</span>{{ $user->username }}</a>
                                            </span>
                                        </td>


                                        <td>
                                            {{ $user->email }}<br>{{ $user->mobile }}
                                        </td>
                                        <td>
                                            <span class="fw-bold"
                                                title="{{ @$user->address->country }}">{{ $user->country_code }}</span>
                                        </td>



                                        <td>
                                            {{ showDateTime($user->created_at) }} <br>
                                            {{ diffForHumans($user->created_at) }}
                                        </td>


                                        <td>
                                            <span class="fw-bold">

                                                {{ $general->cur_sym }}{{ showAmount($user->balance) }}
                                            </span>
                                        </td>

                                        <td>
                                            @if ($user->dummy_person == 0)
                                                @haspermission('manage_user:user_edit', 'admin')
                                                    <a href="{{ route('admin.users.detail', $user->id) }}"
                                                        class="btn btn-sm btn-outline--primary">
                                                        <i class="las la-desktop text--shadow"></i> @lang('Details')
                                                    </a>
                                                @endhaspermission
                                            @else
                                                @haspermission('manage_user:dummy_users_edit', 'admin')
                                                    <a href="{{ route('admin.users.dummyUserdetail', $user->id) }}"
                                                        class="btn btn-sm btn-outline--primary">
                                                        <i class="las la-desktop text--shadow"></i> @lang('Details')
                                                    </a>
                                                @endhaspermission
                                            @endif
                                        </td>

                                    </tr>
                                @empty
                                    <tr>
                                        <td class="text-muted text-center" colspan="100%">{{ __($emptyMessage) }}</td>
                                    </tr>
                                @endforelse

                            </tbody>
                        </table><!-- table end -->
                    </div>
                </div>
                @if ($users->hasPages())
                    <div class="card-footer py-4">
                        {{ paginateLinks($users) }}
                    </div>
                @endif
            </div>
        </div>


    </div>
@endsection



@push('breadcrumb-plugins')
    @haspermission('manage_user:user_create', 'admin')
        <a href="{{ route('admin.users.add.user') }}" class="btn btn-sm btn-outline--primary"><i class="fas fa-plus"></i> Add
            User's</a>
    @endhaspermission
@endpush

@push('style-lib')
    <link rel="stylesheet" href="{{ asset('assets/admin/css/vendor/datepicker.min.css') }}">
@endpush


@push('script-lib')
    <script src="{{ asset('assets/admin/js/vendor/datepicker.min.js') }}"></script>
    <script src="{{ asset('assets/admin/js/vendor/datepicker.en.js') }}"></script>
@endpush
