@extends($activeTemplate.'layouts.users')

@push('style')
	<link rel="stylesheet" href="{{ asset($activeTemplateTrue.'css/history.css') }}{{$catch}}">
	<style>
		.earnitem {float: left;width:calc(100% / 2 );height: auto;overflow: hidden;margin-left: 0px;}
		.typeitem {float: left;width:calc(98% / 3 );height: auto;overflow: hidden;margin-left: 0px;}
		table {
    border-collapse: collapse;
}
table thead tr th {
  border-bottom: 2px solid #FFF;
}
	</style>

@endpush

@section('content')
@php $link = route('invite', ['code' => auth()->user()->ref_code]); @endphp

<uni-app class="uni-app--maxwidth">
	<uni-page data-page="pages/record/balance">
		<uni-page-wrapper class="rTitst">
			<uni-page-body>
				<uni-view data-v-58cb4ed7="" data-v-5c2fef75="" class="back-title" style="background:#1c72dc;">
					<span data-href="{{ route('user.profile') }}" class="returnBank"><img src="{{ asset($activeTemplateTrue.'img/back.png') }}" style="margin-left:12px;width:28px;" /></span>
					<span data-v-58cb4ed7="" class="title-txt">Team Rebate</span>
				</uni-view>
				<uni-view data-v-c23c4702="" class="content">

					<uni-view data-v-d40c0b3e="" class="content color-bg" style="height: auto;">

					<div style=" width: 94%; margin: 30px auto; margin-top: 1px; text-align: center; color: #FFF; position: relative; height: auto; overflow: hidden;" class="tabs">
						<div class="earnitem" >
							<div style="font-weight:700;padding: 5px; height: auto; line-height:30px; overflow: hidden;">
							Invite<br/><span style="color:#f29d27;font-size:26px;">({{ $totalTeamMember }})</span>
							</div>
						</div>
						<div class="earnitem" value="2" >
							<div style="font-weight:700;padding: 5px; height: auto; line-height:30px; overflow: hidden;">
							Valid members<br/><span style="color:#f29d27;font-size:26px;">({{ $ActiveMemberstotal }})</span>
							</div>
						</div>
					</div>

					<div style=" width: 94%; margin: 0 auto; margin-top: 1px; text-align: center; color: #FFF; position: relative; height: auto; overflow: hidden;" class="tabs">
						<div class="typeitem @if($lev_id==1) active over @endif linkBTN" value="1" data-href="{{ route('user.agents', ['id' => 1]) }}">
							<div style="font-weight:700;padding: 5px; height: 30px; line-height:30px; overflow: hidden;">A {{ $levels[0]->percent }}% - {{ ($lev_id == 1 ) ? $totalCommission:0 }}</div>
						</div>
						<div class="typeitem @if($lev_id==2) active over @endif linkBTN" value="2" data-href="{{ route('user.agents', ['id' => 2]) }}">
							<div style="font-weight:700;padding: 5px; height: 30px; line-height: 30px; overflow: hidden; ">B {{ $levels[1]->percent }}% - {{ ($lev_id == 2 ) ? $totalCommission:0; }}</div>
						</div>
						<div class="typeitem @if($lev_id==3) active over @endif linkBTN" value="3" data-href="{{ route('user.agents', ['id' => 3]) }}">
							<div style="font-weight:700;padding: 5px; height: 30px; line-height: 30px; overflow: hidden; ">C {{ $levels[2]->percent }}% - {{ ($lev_id == 3 ) ? $totalCommission:0; }}</div>
						</div>
					</div>

					<uni-view data-v-d40c0b3e="" class="content-inset">
						<uni-view data-v-d40c0b3e="" id="list" class="list">

						<table class="table team-members" style="width:100%;margin-top: 40px;color:#FFF;text-align:center;">
							<thead><tr><th scope="col">Account</th> <th scope="col">Referrer</th> <th scope="col">Assets</th></tr></thead>
							<tbody>
								@php
									$lastUsers = collect($levelUsers)->reverse()->take(30)->reverse();
								@endphp

								@foreach($lastUsers as $user)
									@php
										$total_assets = DB::table('investments')->where('user_id', $user->id)->sum('amount');
									@endphp    
									<tr><td>{{ substr_replace($user->mobile, str_repeat("*", 3), 3, 3) }}</td> <td>{{ $user->ref_code }}</td> <td>{{ config('settings')->cur_sym }}{{ showAmount($total_assets) }}</td></tr>
								@endforeach
							</tbody>
						</table>
					</uni-view>
				</uni-view>


				</uni-view>
			</uni-page-body>
		</uni-page-wrapper>
	</uni-page>
</uni-app>

@endsection

@push('script')
<script>
    function copyText(textToCopy) {
		var $temp = $("<input>");
		$("body").append($temp);
		$temp.val(textToCopy).select();
		document.execCommand("copy");
		$temp.remove();
		modalMessage("Copied!");
    }
</script>
@endpush