@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>
            <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 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>


            @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.download.excel.debt.notcleard', ['search' => request()->search, '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.download.pdf.debt.notcleard', ['search' => request()->search, '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="row mb-3 g-3">
                <div class="col-xxl-3 col-sm-6">
                    <div class="widget-two box--shadow2 b-radius--5 bg--white">
                        <i class="fa fa-user overlay-icon text--danger"></i>
                        <div class="widget-two__icon b-radius--5 bg--warning">
                            <i class="fa fa-user"></i>
                        </div>
                        <div class="widget-two__content">
                            <h3>{{ $deposit['total_person_with_debt_value'] }}</h3>
                            <p>@lang('Total Users with Debt')</p>
                        </div>
                        <a href="{{ route('admin.users.debtNotFree') }}"
                            class="widget-two__btn border border--primary btn-outline--primary">@lang('View All')</a>
                    </div>
                </div>
                <div class="col-xxl-3 col-sm-6">
                    <div class="widget-two box--shadow2 b-radius--5 bg--white">
                        <i class="fas fa-rupee-sign overlay-icon text--danger"></i>
                        <div class="widget-two__icon b-radius--5 bg--secondary">
                            <i class="fas fa-rupee-sign"></i>
                        </div>
                        <div class="widget-two__content">
                            <h3>{{ $general->cur_sym }}{{ showAmount($deposit['total_debt_value'], 2) }}</h3>
                            <p>@lang('Total Debt Value')</p>
                        </div>
                    </div>
                </div>
                <div class="col-xxl-3 col-sm-6">
                    <div class="widget-two box--shadow2 b-radius--5 bg--white">
                        <i class="fas fa-plus overlay-icon text--danger"></i>
                        <div class="widget-two__icon b-radius--5 bg--dark">
                            <i class="fas fa-dove"></i>
                        </div>
                        <div class="widget-two__content">
                            <h3>{{ $general->cur_sym }}{{ $deposit['total_person_with_debt_cleared_at'] }}</h3>
                            <p>@lang('Total Users Who Cleared Their Debt')</p>
                        </div>
                        <a href="{{ route('admin.users.debtFree') }}"
                            class="widget-two__btn border border--secondary btn-outline--dark">@lang('View All')</a>
                    </div>
                </div>
            </div>

            <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('Total Debt')</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>
                                            <ul>

                                                <li>{{ $general->cur_sym }} {{ $user->current_debt_value }}</li>
                                            </ul>
                                        </td>


                                        <td>
                                            @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

                                        </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>

    <x-confirmation-modal />
@endsection



@push('breadcrumb-plugins')
    <a href="{{ route('admin.users.add.user') }}" class="btn btn-sm btn-outline--primary"><i class="fas fa-plus"></i> Add
        User's</a>
@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
