@extends('backend.layouts.app')

@section('title')
    {{ __('Customer Details') }}
@endsection

@section('style')
    <script src="{{ asset('global/js/jquery.min.js') }}"></script>
@endsection

@section('content')
    <div class="main-content">
        <div class="page-title">
            <div class="container-fluid">
                <div class="row">
                    <div class="col">
                        <div class="title-content">
                            <h2 class="title">{{ __('Details of') . ' ' . $user->first_name . ' ' . $user->last_name }}</h2>
                            <a href="{{ url()->previous() }}" class="title-btn">
                                <i icon-name="corner-down-left"></i>{{ __('Back') }}
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row justify-content-center">
                <div class="col-xxl-3 col-xl-6 col-lg-8 col-md-6 col-sm-12">
                    <div class="profile-card">
                        <div class="top">
                            <div class="avatar">
                                @if($user->avatar)
                                    <img class="avatar-image" src="{{ asset($user->avatar) }}" alt="{{ $user->first_name }}" />
                                @else
                                    <span class="avatar-text">{{ $user->first_name[0] . $user->last_name[0] }}</span>
                                @endif
                            </div>
                            <div class="title-des">
                                <h4>{{ $user->first_name . ' ' . $user->last_name }}</h4>
                                <p>{{ ucwords($user->city) }}@if($user->city) , @endif {{ $user->country }}</p>
                            </div>
                            <div>
                                <p>{{__('Last Login:') . ' ' . $login_activities->created_at}}</p>
                                <p>{{__('Browser:') . ' ' . $login_activities->browser}}</p>
                            </div>
                            <div class="btns">
                                @can('customer-mail-send')
                                    <span type="button" data-bs-toggle="modal" data-bs-target="#sendEmail">
                                        <a href="javascript:void(0);" class="site-btn-round blue-btn" data-bs-toggle="tooltip" title="{{ __('Send Email') }}">
                                            <i icon-name="mail"></i>
                                        </a>
                                    </span>
                                @endcan
                                @can('customer-login')
                                    <a href="{{ route('admin.user.login',$user->id) }}" target="_blank" class="site-btn-round red-btn" data-bs-toggle="tooltip" title="{{ __('Login As User') }}">
                                        <i icon-name="user-plus"></i>
                                    </a>
                                @endcan
                                @can('customer-balance-add-or-subtract')
                                    <span data-bs-toggle="modal" data-bs-target="#addSubBal">
                                        <a href="javascript:void(0);" class="site-btn-round primary-btn" data-bs-toggle="tooltip" title="{{ __('Fund Add or Subtract') }}">
                                            <i icon-name="wallet"></i>
                                        </a>
                                    </span>
                                @endcan
                                @can('customer-balance-add-or-subtract')
                                    <span data-bs-toggle="modal" data-bs-target="#sendNotification">
                                    <a href="javascript:void(0);" class="site-btn-round primary-btn" data-bs-toggle="tooltip" title="{{ __('Send Notification') }}">
                                         <i icon-name="bell-ring"></i>
                                    </a>
                                    </span>
                                @endcan
                            </div>
                        </div>
                        <div class="site-card">
                            <div class="site-card-body">
                                <div class="row">
                                    <div class="col-xl-12">
                                        <div class="admin-user-balance-card">
                                            <div class="wallet-name">
                                                <div class="name">{{ __('Main Wallet') }}</div>
                                                <div class="chip-icon">
                                                    <img class="chip" src="{{ asset('backend/materials/chip.png') }}" alt="" />
                                                </div>
                                            </div>
                                            <div class="wallet-info">
                                                <div class="wallet-id">{{ setting('site_currency', 'global') }}</div>
                                                <div class="balance">{{ setting('currency_symbol', 'global') . $user->balance }}</div>
                                            </div>
                                        </div>
                                        <div class="admin-user-balance-card">
                                            <div class="wallet-name">
                                                <div class="name">{{ __('Profit Wallet') }}</div>
                                                <div class="chip-icon">
                                                    <img class="chip" src="{{ asset('backend/materials/chip.png') }}" alt="" />
                                                </div>
                                            </div>
                                            <div class="wallet-info">
                                                <div class="wallet-id">{{ setting('site_currency', 'global') }}</div>
                                                <div class="balance">{{ setting('currency_symbol', 'global') . $user->profit_balance }}</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- User Status Update -->
                    @can('all-type-status')
                        @include('backend.user.include.__status_update')
                    @endcan
                    <!-- User Status Update End-->
                    </div>
                </div>

                <div class="col-xxl-9 col-xl-12 col-lg-12 col-md-12 col-sm-12">
                    <div class="site-tab-bars">
                        <ul class="nav nav-pills" id="pills-tab" role="tablist">
                            <!-- Informations Tab -->
                            @canany(['customer-basic-manage', 'customer-change-password'])
                                <li class="nav-item" role="presentation">
                                    <a href="{{ route('admin.user.edit', ['user' => $user->id, 'tab' => 'informations']) }}"
                                       class="nav-link {{ request()->get('tab') === 'informations' || is_null(request()->get('tab')) ? 'active' : '' }}"
                                       id="pills-informations-tab"
                                       type="button"
                                       role="tab"
                                       aria-controls="pills-informations"
                                       aria-selected="{{ request()->get('tab') === 'informations' || is_null(request()->get('tab')) ? 'true' : 'false' }}">
                                        <i icon-name="user"></i>{{ __('Informations') }}
                                    </a>
                                </li>
                            @endcanany

                        <!-- Investment Tab -->
                            @can('investment-list')
                                <li class="nav-item" role="presentation">
                                    <a href="{{ route('admin.user.edit',['user'=>$user->id,'tab'=>'investments']) }}"
                                       class="nav-link {{ request()->get('tab') === 'investments' ? 'active' : '' }}"
                                       id="pills-transfer-tab"
                                       type="button"
                                       role="tab"
                                       aria-controls="pills-transfer"
                                       aria-selected="{{ request()->get('tab') === 'investments' ? 'true' : 'false' }}">
                                        <i icon-name="anchor"></i>{{ __('Investments') }}
                                    </a>
                                </li>
                            @endcan

                        <!-- Earning Tab -->
                            @can('profit-list')
                                <li class="nav-item" role="presentation">
                                    <a href="{{ route('admin.user.edit',['user'=>$user->id,'tab'=>'earnings']) }}"
                                       class="nav-link {{ request()->get('tab') === 'earnings' ? 'active' : '' }}"
                                       id="pills-deposit-tab"
                                       type="button"
                                       role="tab"
                                       aria-controls="pills-deposit"
                                       aria-selected="{{ request()->get('tab') === 'earnings' ? 'true' : 'false' }}">
                                        <i icon-name="credit-card"></i>{{ __('Earnings') }}
                                    </a>
                                </li>
                            @endcan

                        <!-- Transaction Tab -->
                            @can('transaction-list')
                                <li class="nav-item" role="presentation">
                                    <a href="{{ route('admin.user.edit',['user'=>$user->id,'tab'=>'transactions']) }}"
                                       class="nav-link {{ request()->get('tab') === 'transactions' ? 'active' : '' }}"
                                       id="pills-transactions-tab"
                                       type="button"
                                       role="tab"
                                       aria-controls="pills-transactions"
                                       aria-selected="{{ request()->get('tab') === 'transactions' ? 'true' : 'false' }}">
                                        <i icon-name="cast"></i>{{ __('Transactions') }}
                                    </a>
                                </li>
                            @endcan

                        <!-- Referral Tree Tab -->
                            @if(setting('site_referral', 'global') == 'level')
                                <li class="nav-item" role="presentation">
                                    <a href="{{ route('admin.user.edit',['user'=>$user->id,'tab'=>'referral_tree']) }}"
                                       class="nav-link {{ request()->get('tab') === 'referral_tree' ? 'active' : '' }}"
                                       id="pills-tree-tab"
                                       type="button"
                                       role="tab"
                                       aria-controls="pills-tree"
                                       aria-selected="{{ request()->get('tab') === 'referral_tree' ? 'true' : 'false' }}">
                                        <i icon-name="network"></i>{{ __('Referral Tree') }}
                                    </a>
                                </li>
                            @endif

                        <!-- Ticket Tab -->
                            @canany(['support-ticket-list', 'support-ticket-action'])
                                <li class="nav-item" role="presentation">
                                    <a href="{{ route('admin.user.edit',['user'=>$user->id,'tab'=>'tickets']) }}"
                                       class="nav-link {{ request()->get('tab') === 'tickets' ? 'active' : '' }}"
                                       id="pills-ticket-tab"
                                       type="button"
                                       role="tab"
                                       aria-controls="pills-ticket"
                                       aria-selected="{{ request()->get('tab') === 'tickets' ? 'true' : 'false' }}">
                                        <i icon-name="wrench"></i>{{ __('Ticket') }}
                                    </a>
                                </li>
                            @endcanany
                        </ul>
                    </div>

                    <div class="site-tab-content">
                        <div class="tab-content" id="pills-tabContent">
                            <!-- Informations Tab Content -->
                            @canany(['customer-basic-manage', 'customer-change-password'])
                                <div class="tab-pane fade {{ request()->get('tab') === 'informations' || is_null(request()->get('tab')) ? 'show active' : '' }}" id="pills-informations" role="tabpanel">
                                    @include('backend.user.include.__basic_info')
                                </div>
                            @endcanany

                        <!-- Investments Tab -->
                            @can('investment-list')
                                <div class="tab-pane fade {{ request()->get('tab') === 'investments' ? 'show active' : '' }}" id="pills-investments" role="tabpanel">
                                    @include('backend.user.include.__investments', ['data' => $investmentData])
                                </div>
                            @endcan

                        <!-- Earnings Tab -->
                            @can('profit-list')
                                <div class="tab-pane fade {{ request()->get('tab') === 'earnings' ? 'show active' : '' }}" id="pills-earnings" role="tabpanel">
                                    @include('backend.user.include.__earnings', ['data' => $earningData])
                                </div>
                            @endcan

                        <!-- Transactions Tab -->
                            @can('transaction-list')
                                <div class="tab-pane fade {{ request()->get('tab') === 'transactions' ? 'show active' : '' }}" id="pills-transactions" role="tabpanel">
                                    @include('backend.user.include.__transactions', ['data' => $transactionData])
                                </div>
                            @endcan

                        <!-- Referral Tree Tab -->
                            @if(setting('site_referral', 'global') == 'level')
                                <div class="tab-pane fade {{ request()->get('tab') === 'referral_tree' ? 'show active' : '' }}" id="pills-referral_tree" role="tabpanel">
                                    @include('backend.user.include.__referral_tree')
                                </div>
                            @endif

                        <!-- Ticket Tab -->
                            @canany(['support-ticket-list', 'support-ticket-action'])
                                <div class="tab-pane fade {{ request()->get('tab') === 'tickets' ? 'show active' : '' }}" id="pills-tickets" role="tabpanel">
                                    @include('backend.user.include.__ticket',['tickets', $tickets])
                                </div>
                            @endcanany
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Modal for Send Email -->
    @can('customer-mail-send')
        @include('backend.user.include.__mail_send',['name' => $user->first_name.' '.$user->last_name, 'id' => $user->id])
    @endcan

    <!-- Modal for Add or Subtract Balance -->
    @can('customer-balance-add-or-subtract')
        @include('backend.user.include.__balance')
    @endcan
    @include('backend.user.include.__notification_send',['name' => $user->first_name.' '.$user->last_name, 'id' => $user->id])
@endsection