@extends('backend.layouts.app')
@section('title')
    {{ __('Transactions') }}
@endsection
@section('content')
    <div class="main-content">
        <div class="page-title">
            <div class="container-fluid">
                <div class="row">
                    <div class="col">
                        <h2 class="title">{{$title}}</h2>
                    </div>
                </div>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row">
                <div class="col-xl-12">
                    <div class="site-table table-responsive">
                        <form action="{{ request()->url() }}" method="get">
                            <div class="table-filter d-flex justify-content-between">
                                <div class="filter d-flex">
                                    <div class="search">
                                        <input type="text" id="search" name="query" value="{{ request('query') }}" placeholder="Search" />
                                    </div>
                                    <button type="submit" class="apply-btn ms-2"><i data-lucide="search"></i>{{ __('Search') }}</button>
                                </div>
                                <div class="filter d-flex">
                                    <select class="form-select form-select-sm me-2" name="filter_by_transaction_type" aria-label=".form-select-sm example">
                                        <option value="" selected>{{ __('Filter By Transaction Type') }}</option>
                                        <option value="investment" {{ request('investment') == 'investment' ? 'selected' : '' }}>{{ __('Investment') }}</option>
                                        <option value="withdraw" {{ request('withdraw') == 'withdraw' ? 'selected' : '' }}>{{ __('Withdraw') }}</option>
                                        <option value="deposit" {{ request('deposit') == 'deposit' ? 'selected' : '' }}>{{ __('Deposit') }}</option>
                                        <option value="signup_bonus" {{ request('signup_bonus') == 'signup_bonus' ? 'selected' : '' }}>{{ __('Signup Bonus') }}</option>
                                    </select>
                                    <select class="form-select form-select-sm" name="status" aria-label=".form-select-sm example">
                                        <option value="" selected>{{ __('Filter By Status') }}</option>
                                        <option value="success" {{ request('success') == 'success' ? 'selected' : '' }}>{{ __('Success') }}</option>
                                        <option value="pending" {{ request('pending') == 'pending' ? 'selected' : '' }}>{{ __('Pending') }}</option>
                                        <option value="failed" {{ request('failed') == 'failed' ? 'selected' : '' }}>{{ __('Failed') }}</option>
                                    </select>
                                </div>
                            </div>
                        </form>
                        <table class="table">
                            <thead>
                            <tr>
                                <th>{{ __('Date') }}</th>
                                <th>{{ __('User') }}</th>
                                <th>{{ __('Transaction ID') }}</th>
                                <th>{{ __('Type') }}</th>
                                <th>{{ __('Amount') }}</th>
                                <th>{{ __('Gateway') }}</th>
                                <th>{{ __('Status') }}</th>
                            </tr>
                            </thead>
                            <tbody>
                            @forelse($data as $item)
                                <tr>
                                    <td>{{ $item->created_at }}</td>
                                    <td>@include('backend.transaction.include.__user', ['user' => $item->user])</td>
                                    <td>{{ $item->tnx }}</td>
                                    <td>@include('backend.transaction.include.__txn_type', ['type' => $item->type])</td>
                                    <td>@include('backend.transaction.include.__txn_amount', ['amount' => $item->final_amount])</td>
                                    <td>{{ $item->method }}</td>
                                    <td>@include('backend.transaction.include.__txn_status', ['status' => $item->status])</td>
                                </tr>
                            @empty
                                <td colspan="8" class="text-center">{{ __('No Data Found!') }}</td>
                            @endforelse
                            </tbody>
                            <!-- Modal for Send Email -->
                        @can('customer-mail-send')
                            @include('backend.user.include.__mail_send')
                        @endcan
                        <!-- Modal for Send Email-->
                        </table>
                        {{ $data->links('backend.include.__pagination') }}
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection