@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">
                                <label>@lang('Status')</label>
                                <select name="status" class="form-control">
                                    <option value="">@lang('All')</option>
                                    <option value="{{ Status::Pending }}" @selected(request()->status == Status::Pending)>@lang('Pending')
                                    </option>
                                    <option value="{{ Status::Approved }}" @selected(request()->status == Status::Approved)>@lang('Approved')
                                    </option>
                                    <option value="{{ Status::Rejected }}" @selected(request()->status == Status::Rejected)>@lang('Rejected')
                                    </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>

            <div class="d-flex justify-content-end">
                <div class="btn-group mb-3" role="group" aria-label="Basic example">
                    <a href="{{ route('admin.donation.exportExcelDonationList', ['search' => request()->search, 'date' => request()->date]) }}"
                        class="btn btn--success"><i class="las la-file-excel"></i> @lang('Export Excel')</a>
                    <a href="{{ route('admin.donation.exportPdfDonationList', ['search' => request()->search, 'date' => request()->date]) }}"
                        class="btn btn--danger"><i class="las la-file-pdf"></i> @lang('Export PDF')</a>
                </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('Payer')</th>
                                    <th>@lang('Amount')</th>
                                    <th>@lang('Receiver')</th>
                                    <th>@lang('Status')</th>
                                    <th class="text-center">@lang('Payment Details')</th>
                                    <th>@lang('Created At')</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse($donationList as $user)
                                    <tr>
                                        <td>
                                            <span class="fw-bold">{{ $user->payerUser->fullname }}</span>
                                            <br>
                                            UserId: {{ $user->payerUser->system_id }}
                                            <br>

                                            <span class="small">
                                                <span>@</span>{{ $user->payerUser->username }}
                                            </span>

                                            <br>
                                            @haspermission('manage_user:login_as_user', 'admin')
                                                <div class="flex-fill">
                                                    <a href="{{ route('admin.users.login', $user->payerUser->id) }}"
                                                        target="_blank" class="btn btn--primary btn--gradi btn--shadow ">
                                                        <i class="las la-sign-in-alt"></i>
                                                    </a>
                                                </div>
                                            @endhaspermission
                                        </td>

                                        <td>
                                            {{ $general->cur_sym }} {{ $user->amount }}
                                        </td>

                                        <td>
                                            <span class="fw-bold">{{ $user->receiverUser->fullname }}</span>
                                            <br>
                                            UserId: {{ $user->receiverUser->system_id }}
                                            <br>
                                            <span class="small">
                                                <span>@</span>{{ $user->receiverUser->username }}
                                            </span>
                                            <br>
                                            @haspermission('manage_user:login_as_user', 'admin')
                                                <div class="flex-fill">
                                                    <a href="{{ route('admin.users.login', $user->receiverUser->id) }}"
                                                        target="_blank" class="btn btn--primary btn--shadow ">
                                                        <i class="las la-sign-in-alt"></i>
                                                    </a>
                                                </div>
                                            @endhaspermission
                                        </td>
                                        <td>@php echo $user->statusBadge @endphp</td>
                                        <td class="text-center">
                                            <br>
                                            <span style="font-weight: bold"> Payment Mode:</span> {{ $user->payment_mode }}
                                            <br>
                                            <span style="font-weight: bold"> UTR No:</span> {{ $user->utr_no }}
                                            <br>
                                            <span style="font-weight: bold"> TRX:</span> {{ $user->trx }}
                                            <div class="my-1">
                                                <a href="/{{ getFilePath('withdrawMethod') . '/' . $user->screen_short }}"
                                                    target="_blank"><i class="fa fa-file"></i> @lang('Screenshot') </a>
                                            </div>
                                        </td>
                                        <td>
                                            <span class="fw-bold">{{ $user->created_at->format('d M Y h:i A') }}</span>
                                        </td>
                                    </tr>
                                @empty
                                    <tr>
                                        <td class="text-muted text-center" colspan="100%">{{ __($emptyMessage) }}</td>
                                    </tr>
                                @endforelse

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


    </div>

    <x-confirmation-modal />
@endsection
@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
