@extends('layouts.sneat') @section('title', 'Dashboard - Analytics') @section('vendor-style') @endsection @section('vendor-script') @endsection @section('content') @php $authUser = Auth::user(); @endphp @if($authUser && !in_array($authUser->user_type, [3, 345, 346]))
{{-- Top KPI Cards --}}
Projects

{{ $myProjectCount }}

Enquiries

{{ $enquiriesCount }}

Appoinments

{{ $appoinments }}

Assigned Activities

{{ $allActivities->count() }}

{{-- =================== LEFT: Company Targets =================== --}}
{{-- TAB CONTENT --}}
@foreach ($plannersByUser as $userId => $data)
@foreach ($data['planners'] as $planner) @php // 🔑 UNIQUE KEY PER USER + PLANNER $uid = $userId . '_' . $planner->id; @endphp
{{-- HEADER --}}

{{-- COLLAPSE --}}
{{-- STATUS BARS --}} @php $statusCounts = $planner->contactStatusCountsForUser($userId); $targetCounts = $planner->targetCounts(); $fixedStatuses = [ 1 => 'Initial Contact', 3 => 'Proposals & Quotes', 5 => 'Contract Signed', ]; @endphp
@foreach ($fixedStatuses as $statusId => $statusName) @php $achieved = $statusCounts[$statusName] ?? 0; $target = $targetCounts[$statusId] ?? 0; $percent = $target > 0 ? round(($achieved / $target) * 100) : 0; @endphp
{{ $statusName }}
{{ $achieved }} / {{ $target }}
@endforeach
{{-- CHART --}} @php $monthlyData = $planner->monthlyPerformanceForUser($userId); $months = collect($monthlyData)->keys(); $statuses = [ 'Initial Contact', 'Proposals & Quotes', 'Contract Signed' ]; @endphp
@endforeach
@endforeach
{{-- =================== RIGHT: Latest Enquiries =================== --}}
Latest Enquiries
View All
    @foreach ($enquiries as $enquiry)
  • @if ($enquiry->avatar) avatar @else
    {{ strtoupper(substr($enquiry->name, 0, 1)) }}
    @endif
    {{ $enquiry->name }}
    {{ \Carbon\Carbon::parse($enquiry->created_at)->timezone('Asia/Kolkata')->format('d M | h:i A') }}
    {{ $enquiry->phone_number }}
  • @endforeach
Next Follow-Ups
View All
    @forelse($nextFollowUps as $followUp)
  • {{ $followUp->contact->name ?? 'N/A' }}
    {{ $followUp->title ?? '-' }} • {{ \Carbon\Carbon::parse($followUp->next_follow_up_date)->format('d M Y') }}
    {{ $followUp->contact->phone_number ?? '-' }}
  • @empty
  • No upcoming follow-ups
  • @endforelse
{{-- Charts --}}
Contact Status
@forelse($upcomingMeetings as $meeting) @php $meetingDate = \Carbon\Carbon::parse($meeting->meeting_datetime)->startOfDay(); $now = \Carbon\Carbon::now()->startOfDay(); if ($meetingDate->isToday()) { $timeLabel = 'Today'; $timeClass = 'bg-success'; $icon = 'mdi-calendar-today'; } elseif ($meetingDate->isTomorrow()) { $timeLabel = 'Tomorrow'; $timeClass = 'bg-warning'; $icon = 'mdi-calendar-arrow-right'; } else { $diffDays = $now->diffInDays($meetingDate); $timeLabel = $diffDays . ' days remaining'; $timeClass = 'bg-danger'; $icon = 'mdi-calendar-clock'; } $participants = $meeting->participants ?? []; @endphp
Upcoming Meetings
{{ $meeting->title }}
{{ $timeLabel }}

Organizer: {{ $meeting->organizer ?? 'N/A' }}

When: {{ $meeting->meeting_datetime->format('d M Y, h:i A') }}

Venue: {{ $meeting->venue ?? 'N/A' }}

Agenda: {{ $meeting->agenda ?? 'No agenda' }}

@if (!empty($participants))
Participants: @foreach ($participants as $userId) @php $user = \App\Models\User::find($userId); @endphp @if ($user)
  • {{ $user->name }}
  • @endif @endforeach
    @endif

    @if ($meeting->latestMom) View MOM @if ($meeting->latestMom->decisions)

    Decisions: {{ \Illuminate\Support\Str::limit($meeting->latestMom->decisions, 60) }}
    @endif @else Status: {{ ucfirst($meeting->status) }} @endif

    @empty

    No upcoming meetings

    @endforelse
    {{-- TAB SECTION --}}
    {{-- TAB 1: Activities & Enquiries --}}
    {{-- Recent Assigned Activities --}}
    Recent Assigned Activities
    @forelse($recentActivities as $activity) @php $logs = $activity->employeeActivityLogs ?? collect(); $totalHours = $logs->sum('hours'); $actualHours = $logs->sum(function ($log) { if (!$log->actual_time) { return 0; } [$h, $m, $s] = explode(':', $log->actual_time); return (int) $h + (int) $m / 60 + (int) $s / 3600; }); $progress = $totalHours > 0 ? round(($actualHours / $totalHours) * 100) : 0; if ($logs->count() === 0) { $overallStatus = 'Pending'; } elseif ( $logs->every(fn($log) => strtolower($log->status) === 'completed') ) { $overallStatus = 'Completed'; } elseif ( $logs->contains(fn($log) => strtolower($log->status) === 'in progress') ) { $overallStatus = 'In Progress'; } else { $overallStatus = 'Pending'; } @endphp {{-- Avatar --}} {{-- Activity title --}} {{-- Status --}} {{-- Progress --}} @empty @endforelse
    Team Member Activity Status Progress
    @if ($activity->user->profile_image) {{ $activity->user->name }} @else {{ strtoupper(substr($activity->user->name, 0, 2)) }} @endif
    {{ $activity->user->name }} all log
    {{ $activity->user->email ?? 'N/A' }}
    {{ $activity->activity->title ?? 'N/A' }} @if (strtolower($overallStatus) === 'completed') Completed @elseif(strtolower($overallStatus) === 'in progress') In Progress @else {{ ucfirst($overallStatus) }} @endif
    {{ $progress }}%
    No recent assigned activities
    {{-- Latest Enquiries --}}
    {{-- TAB 2: Finance & Renewals --}}
    {{-- Recent Invoices --}}
    Recent Invoices
      @forelse ($recentInvoices as $invoice)
    • {{ $invoice->ref }}
      {{ $invoice->type }} • {{ $invoice->client_name }} • {{ \Carbon\Carbon::parse($invoice->created_at)->diffForHumans() }}
      ₹{{ number_format($invoice->amount, 2) }}
    • @empty
    • No recent invoices
    • @endforelse
    {{-- Upcoming Renewals --}}
    Upcoming Renewals
    Next 15 Days
    @forelse ($upcomingRenewals as $renewal) @php $expiry = \Carbon\Carbon::parse($renewal->expiry_date)->startOfDay(); $today = now()->startOfDay(); $daysLeft = $today->diffInDays($expiry, false); if (isset($renewal->status) && strtolower($renewal->status) === 'paid') { $badgeText = 'Paid'; $color = 'success'; $progressPercent = 100; } else { if ($daysLeft <= 0) { $badgeText = 'Expired'; $color = 'danger'; } elseif ($daysLeft == 1) { $badgeText = 'Tomorrow'; $color = 'warning'; } else { $badgeText = $daysLeft . ' days'; $color = 'primary'; } $progressPercent = min(100, max(0, round(((15 - $daysLeft) / 15) * 100))); } @endphp @empty
    No upcoming renewals 🎉
    @endforelse
    {{-- Invoice Distribution --}}
    Invoice Distribution
    @foreach (['proposal' => 'primary', 'proforma' => 'info', 'service' => 'success', 'quick' => 'warning', 'renewal' => 'secondary'] as $type => $color) @php $percentage = $totalInvoices > 0 ? round(($counts[$type] / $totalInvoices) * 100) : 0; @endphp
    {{ $type }} {{ $counts[$type] ?? 0 }} ({{ $percentage }}%)
    @endforeach
    {{-- TAB 3: Remuneration --}}
    Employee Salaries
      @foreach ($salaries as $salary)
    • @if (!empty($salary->profile_image)) {{ $salary->name }} @else {{ strtoupper(substr($salary->name, 0, 2)) }} @endif
      {{ $salary->name }}
      {{ $salary->status }}
      To Pay: ₹{{ number_format($salary->basic_salary, 2) }}, Paid: ₹{{ number_format($salary->total_paid, 2) }}, Pending: ₹{{ number_format($salary->pending_amount, 2) }}
      Last Paid: {{ $salary->last_paid_date ? \Carbon\Carbon::parse($salary->last_paid_date)->format('d-M-Y') : 'N/A' }}
    • @endforeach
    {{-- /END TAB --}}
    Activity Logs
    Loading...
    Follow-Up Details

    Loading follow-up details...

    Contact Information
    Name
    Phone
    Email
    Organization
    Follow-Up Details

    Title

    Notes

    Next Date
    Assigned To
    Responsible Person
    @else {{-- For user_type = 345, show welcome message only --}}

    Welcome, {{ $authUser->name }}!

    You currently have limited access.

    @endif @endsection