@extends('layouts.portal') @section('title', 'Hierarchy Report') @section('page_title', 'Hierarchy Report') @section('page_subtitle', 'Your referral network — upline, downline, and commission at every level') @section('sidebar') @include('agent.partials.sidebar', ['active' => 'reports-hierarchy']) @endsection @section('content')

Hierarchy Report

You and your downline, up to {{ config('mlm.max_levels', 3) }} levels deep

@php $totalClients = collect($nodes)->sum('total_referred_clients'); $totalCommission = collect($nodes)->sum('commission_total'); @endphp

Agents in Your Tree

{{ count($nodes) }}

Total Referred Clients

{{ $totalClients }}

Total Commission

RM {{ number_format($totalCommission, 2) }}

@forelse($nodes as $i => $node) @empty @endforelse
Agent Code Level Upline Downline Referred Clients Commission Status Clients
{{ $node['agent_name'] }} @if($node['level'] === 0)(You)@endif {{ $node['agent_code'] ?? '—' }} {{ $node['level'] === 0 ? 'Self' : 'L' . $node['level'] }} {{ $node['upline_name'] ?? '—' }} {{ $node['downline_count'] }} {{ $node['total_referred_clients'] }} RM {{ number_format($node['commission_total'], 2) }}
Paid: {{ number_format($node['commission_paid'], 2) }} / Pending: {{ number_format($node['commission_pending'], 2) }}
{{ ucfirst($node['status'] ?? '-') }}
No downline agents yet
@endsection