@extends('layouts.app') @section('title', 'Dashboard') @section('content')
{{-- ═══ GREETING HEADER (universal) ═══ --}}

{{ $greeting }}, {{ $userName }} 👋

{{ $todayDate }}

{{-- Quick actions + notification bell --}}
{{-- Notification Bell --}} @if($unreadNotificationsCount > 0) {{ $unreadNotificationsCount > 99 ? '99+' : $unreadNotificationsCount }} @endif @can('proposals.create') New Proposal @endcan @can('projects.manage') New Project @endcan @can('clients.manage') New Client @endcan
{{-- Flash messages --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- ═══════════════════════════════════════════════════ --}} {{-- ADMIN DASHBOARD --}} {{-- ═══════════════════════════════════════════════════ --}} @if($isAdmin) {{-- Row 1: 4 stat cards --}}
{{-- Revenue This Month --}}

Revenue This Month

{{ $defaultCurrency->symbol() }} {{ number_format((float) $revenueThisMonth, 2) }}

@if($revenueBreakdown->isNotEmpty())
@foreach($revenueBreakdown as $row)

{{ $row->currency }} {{ number_format((float) $row->total, 2) }}

@endforeach
@endif
{{-- Pipeline Value --}}

Pipeline Value

{{ $defaultCurrency->symbol() }} {{ number_format((float) $pipelineTotal, 2) }}

Active proposals value

{{-- Win Rate --}}

Win Rate

{{ $winRate }}%

{{ $approvedProposals }} / {{ $totalProposals }} proposals

{{-- Team Size --}}

Team Size

{{ $teamSize }}

{{ $teamSize }} active @if(isset($pendingInvitations) && $pendingInvitations > 0) · {{ $pendingInvitations }} pending @endif

{{-- Row 2: Project Health --}}

Project Health

{{ $projectsOnTrack }}

On Track

{{ $overdueCount }}

Overdue Invoices

{{ $projectsAtRisk }}

Projects Overdue

{{-- Row 3: Two columns --}}
{{-- Expiring proposals --}}

Proposals Expiring (7 days)

@forelse($expiringProposals as $p)

{{ $p->title }}

{{ $p->client?->name }}

{{ $p->valid_until?->format('d M') }}
@empty

No proposals expiring soon.

@endforelse
{{-- Invoices due soon --}}

Invoices Due (7 days)

@forelse($dueSoonInvoices as $inv)

{{ $inv->invoice_number }}

{{ $inv->client?->name }}

{{ $inv->due_date?->format('d M') }}
@empty

No invoices due soon.

@endforelse
@elseif($isCFO) {{-- ═══════════════════════════════════════════════════ --}} {{-- CFO / FINANCE MANAGER DASHBOARD --}} {{-- ═══════════════════════════════════════════════════ --}} {{-- Row 1: 4 stat cards --}}

Total Collected

{{ $defaultCurrency->symbol() }} {{ number_format((float) $allTimeRevenue, 2) }}

@if($revenueBreakdown->isNotEmpty())
@foreach($revenueBreakdown as $row)

{{ $row->currency }} {{ number_format((float) $row->total, 2) }}

@endforeach
@endif

Outstanding

{{ $unpaidCount }}

Unpaid / partial invoices

Overdue

{{ $overdueCount }}

Past due date

Forecast

@forelse($forecast ?? [] as $row)

{{ $row->currency }} {{ number_format((float) $row->total, 2) }}

@empty

@endforelse
{{-- Row 2: Aged Debtors --}}

Aged Debtors

0–30 Days

{{ $aged30 }}

invoices overdue

31–60 Days

{{ $aged60 }}

invoices overdue

60+ Days

{{ $aged90plus }}

invoices overdue

{{-- Row 3: Two columns --}}
{{-- Monthly revenue trend --}}

Monthly Revenue (Last 6 Months)

@forelse($monthlyRevenue as $row) @empty @endforelse
Month Currency Amount
{{ \Carbon\Carbon::create($row->year, $row->month)->format('M Y') }} {{ $row->currency }} {{ number_format((float) $row->total, 2) }}
No payment data.
{{-- Outstanding by client --}}

Outstanding by Client (Top 5)

@forelse($outstandingByClient as $client)

{{ $client->name }}

{{ number_format((float) $client->outstanding, 2) }}
@empty

No outstanding balances.

@endforelse
@elseif($isCRO) {{-- ═══════════════════════════════════════════════════ --}} {{-- CRO / BUSINESS MANAGER DASHBOARD --}} {{-- ═══════════════════════════════════════════════════ --}}

Total Proposals

{{ $totalProposals }}

Win Rate

{{ $winRate }}%

Pipeline Value

@forelse($pipelineValue ?? [] as $row)

{{ $row->currency }} {{ number_format((float) $row->total, 2) }}

@empty

@endforelse

New Clients (30d)

{{ $newClients }}

{{-- Proposal Funnel --}}

Proposal Funnel

@php $draftCount = $totalProposals - $sentProposals - $approvedProposals - $rejectedProposals; @endphp

{{ max(0, $draftCount) }}

Draft

{{ $sentProposals }}

Sent

{{ $approvedProposals }}

Approved

{{ $rejectedProposals }}

Rejected

{{-- Two columns --}}

Proposals Expiring (7 days)

@forelse($expiringProposals as $p)

{{ $p->title }}

{{ $p->client?->name }}

View
@empty

None expiring soon.

@endforelse

Recent Proposals

@forelse($recentProposals as $p)

{{ $p->title }}

{{ $p->client?->name }}

{{ ucfirst($p->status->value) }}
@empty

No proposals yet.

@endforelse
@elseif($isCOO) {{-- ═══════════════════════════════════════════════════ --}} {{-- COO / PROJECT MANAGER DASHBOARD --}} {{-- ═══════════════════════════════════════════════════ --}} {{-- RAG status --}}

{{ $onTrack }}

On Track

{{ $atRisk }}

At Risk (<7 days)

{{ $overdueProjects }}

Overdue

{{-- 4 stat cards --}}

Active Projects

{{ $activeProjects }}

On Hold

{{ $onHoldProjects }}

Pending Proposals

{{ $pendingProposals }}

Overdue Invoices

{{ $overdueInvoices }}

{{-- Upcoming deadlines (14 days) --}}

Upcoming Deadlines (14 days)

@forelse($upcomingDeadlines as $proj) @php $days = now()->diffInDays($proj->end_date, false); @endphp @empty @endforelse
Project Client Due Date Days Left
{{ $proj->title }} {{ $proj->client?->name }} {{ $proj->end_date?->format('d M Y') }} {{ $days < 0 ? abs((int)$days).' overdue' : (int)$days.'d' }}
No upcoming deadlines.
@elseif($isTechLead) {{-- ═══════════════════════════════════════════════════ --}} {{-- TECH LEAD DASHBOARD --}} {{-- ═══════════════════════════════════════════════════ --}}

Active Projects

{{ $activeProjects }}

On Track

{{ $onTrack }}

At Risk

{{ $atRisk }}

Unassigned

{{ $unassigned }}

{{-- Upcoming deadlines --}}

Upcoming Deadlines (14 days)

@forelse($upcomingDeadlines as $proj) @php $days = now()->diffInDays($proj->end_date, false); @endphp

{{ $proj->title }}

{{ $proj->client?->name }} · {{ $proj->assignedUsers->count() }} member(s)

{{ $proj->end_date?->format('d M') }}
@empty

No upcoming deadlines.

@endforelse
{{-- Team Workload --}}

Team Workload

@forelse($teamWorkload as $member) @php $pct = min(100, $member['projects'] * 33); $label = match(true) { $member['projects'] === 0 => ['text' => 'Available', 'color' => 'bg-emerald-500', 'badge' => 'bg-emerald-100 text-emerald-700'], $member['projects'] <= 2 => ['text' => 'Assigned', 'color' => 'bg-sky-500', 'badge' => 'bg-sky-100 text-sky-700'], default => ['text' => 'Heavy', 'color' => 'bg-amber-500', 'badge' => 'bg-amber-100 text-amber-700'], }; @endphp
{{ $member['name'] }} {{ $label['text'] }} ({{ $member['projects'] }})
@empty

No staff members found.

@endforelse
{{-- Active Projects list --}}

Active Projects

@forelse($activeProjectsList as $proj) @empty @endforelse
Project Client Team Deadline
{{ $proj->title }} {{ $proj->client?->name }} {{ $proj->assigned_users_count }} member(s) {{ $proj->end_date?->format('d M Y') ?? '—' }}
No active projects.
@elseif($isClientMgr) {{-- ═══════════════════════════════════════════════════ --}} {{-- CLIENT MANAGER DASHBOARD --}} {{-- ═══════════════════════════════════════════════════ --}}

Total Clients

{{ $totalClients }}

Active Proposals

{{ $activeProposalCount }}

Approved This Month

{{ $approvedThisMonth }}

Expiring Soon

{{ $expiringSoonCount }}

{{-- Client Health Table --}}

Client Health

@forelse($clientHealth as $client) @empty @endforelse
Client Active Proposals Overdue Invoices Status
{{ $client->name }} {{ $client->active_proposals }} {{ $client->overdue_invoices }} @if($client->overdue_invoices > 0) At Risk @elseif($client->active_proposals > 0) Active @else Healthy @endif
No clients found.
{{-- Expiring proposals --}} @if($expiringProposals->isNotEmpty())

Proposals Needing Attention

@foreach($expiringProposals as $p)

{{ $p->title }}

{{ $p->client?->name }} · expires {{ $p->valid_until?->format('d M Y') }}

View
@endforeach
@endif @elseif($isHR) {{-- ═══════════════════════════════════════════════════ --}} {{-- HR MANAGER DASHBOARD --}} {{-- ═══════════════════════════════════════════════════ --}}

Total Team

{{ $totalTeam }}

Pending Invites

{{ $pendingInvitations }}

Expired Invites

{{ $expiredInvitations }}

New Joins (30d)

{{ $recentJoins }}

{{-- Role Distribution --}}

Team by Role

@php $maxCount = $roleDistribution->max('users_count') ?: 1; @endphp @foreach($roleDistribution as $role) @if($role->users_count > 0)
{{ $role->name }}
{{ $role->users_count }}
@endif @endforeach
{{-- Recent team members --}}

Recent Team Members

@forelse($recentTeam as $member) @empty @endforelse
Name Role Joined
{{ $member->name }} {{ $member->roles->first()?->name ?? '—' }} {{ $member->created_at->format('d M Y') }}
No team members.
@elseif($isStaff) {{-- ═══════════════════════════════════════════════════ --}} {{-- STAFF DASHBOARD --}} {{-- ═══════════════════════════════════════════════════ --}}

My Active Projects

{{ $myProjectsCount }}

My Proposals

{{ $myProposalsCount }}

{{-- My Projects (cards) --}}

My Projects

@if($myProjects->isEmpty())

You haven't been assigned to any projects yet.

@else @endif
{{-- My recent proposals --}} @if($myProposals->isNotEmpty())

My Recent Proposals

@foreach($myProposals as $p)

{{ $p->title }}

{{ ucfirst($p->status->value) }}
@endforeach
@endif @else {{-- Fallback: authenticated but no recognised role --}}

No dashboard is configured for your account role.

Please contact your administrator to have a role assigned.

@endif
@endsection