@extends('layouts.dashboard') @section('title', 'Admin Dashboard') @section('header-title', 'Executive Overview') @section('content')

Proposal Pipeline Dashboard

Track, manage, and close your active client proposals.

Pipeline Healthy
@php $userRole = auth()->user()->role->slug ?? ''; $formatIndianCurrency = static function ($amount, $decimals = 2) { [$whole, $decimal] = array_pad( explode('.', number_format((float) $amount, $decimals, '.', '')), 2, null, ); $sign = str_starts_with($whole, '-') ? '-' : ''; $whole = ltrim($whole, '-'); if (strlen($whole) > 3) { $lastThreeDigits = substr($whole, -3); $remainingDigits = substr($whole, 0, -3); $remainingDigits = preg_replace('/\B(?=(\d{2})+(?!\d))/', ',', $remainingDigits); $whole = $remainingDigits . ',' . $lastThreeDigits; } return $sign . $whole . ($decimal !== null ? '.' . $decimal : ''); }; @endphp
{{-- CARD: TOTAL --}}

Total

{{ $totalProposals }}

{{ strtoupper($userRole) }} scope
{{-- CARD: PENDING APPROVAL --}}

Pending

{{ $pendingCount }}

Awaiting approval
{{-- CARD: APPROVED --}}

Approved

{{ $approvedCount }}

{{ $totalProposals > 0 ? round(($approvedCount / $totalProposals) * 100, 1) : 0 }}% win rate
{{-- CARD: REJECTED --}}

Rejected

{{ $rejectedCount }}

{{ $draftCount }} drafts pending
@php $draftRate = $totalProposals > 0 ? round(($draftCount / $totalProposals) * 100) : 0; $pendingRate = $totalProposals > 0 ? round(($pendingCount / $totalProposals) * 100) : 0; $wonRate = $totalProposals > 0 ? round(($approvedCount / $totalProposals) * 100) : 0; $rejectedRate = $totalProposals > 0 ? round(($rejectedCount / $totalProposals) * 100) : 0; @endphp

Active Client Proposals

Detailed client, product, value, handler, and stage visibility for the current pipeline.

Total {{ $totalProposals }} {{-- Draft {{ $draftCount }} --}} Pending / Review {{ $pendingCount }} Approved {{ $approvedCount }} Rejected {{ $rejectedCount }} View All
{{--
Draft {{ $draftRate }}%
Pending / In Review {{ $pendingRate }}%
Approved {{ $wonRate }}%
Rejected {{ $rejectedRate }}%
--}}
{{-- --}} @forelse($proposals as $proposal) @php $statusClasses = [ 'draft' => 'bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-300', 'pending' => 'bg-amber-100 dark:bg-amber-900/20 text-amber-800 dark:text-amber-400', 'pending_approval' => 'bg-blue-100 dark:bg-blue-900/20 text-blue-800 dark:text-blue-400', 'revision_requested' => 'bg-orange-100 dark:bg-orange-900/20 text-orange-800 dark:text-orange-400', 'revised' => 'bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-300', 'approved' => 'bg-green-100 dark:bg-green-900/20 text-green-800 dark:text-green-400', 'converted' => 'bg-blue-100 dark:bg-blue-900/20 text-blue-800 dark:text-blue-400', 'rejected' => 'bg-red-100 dark:bg-red-900/20 text-red-800 dark:text-red-400', ]; $statusDots = [ 'draft' => 'bg-gray-400', 'pending' => 'bg-amber-400', 'pending_approval' => 'bg-blue-500', 'revision_requested' => 'bg-orange-500', 'revised' => 'bg-slate-500', 'approved' => 'bg-green-500', 'converted' => 'bg-blue-500', 'rejected' => 'bg-red-500', ]; $statusLabels = [ 'draft' => 'Draft', 'pending' => 'Submitted', 'pending_approval' => 'In Review', 'revision_requested' => 'Revision Requested', 'revised' => 'Revised', 'approved' => 'Approved', 'converted' => 'Converted', 'rejected' => 'Rejected', ]; $statusClass = $statusClasses[$proposal->status] ?? $statusClasses['draft']; $statusDot = $statusDots[$proposal->status] ?? $statusDots['draft']; $statusLabel = $statusLabels[$proposal->status] ?? ucfirst(str_replace('_', ' ', $proposal->status)); $clientName = $proposal->client?->company_name ?? ($proposal->client?->contact_person ?? ($proposal->createdBy?->name ?? 'Client')); $contactLine = collect([ $proposal->client?->contact_person, $proposal->client?->phone, $proposal->client?->email, ]) ->filter() ->join(' | '); $productName = $proposal->product?->name ?? ($proposal->product?->model_name ?? 'Proposal Item'); $variantName = $proposal->selectedVariant?->variant_name ?? 'Variant not selected'; $luxePackageSelection = match ($proposal->lux_package) { // 'yes' => 'Yes' . (($proposal->luxe_package_price ?? 0) > 0 ? ' - ₹ ' . number_format($proposal->luxe_package_price, 2) : ''), 'yes' => 'Yes', 'no' => 'No', default => 'Not selected', }; $createdDate = $proposal->created_at?->format('d M Y') ?? 'N/A'; $validUntil = $proposal->valid_until?->format('d M Y') ?? 'Not set'; $ageInDays = $proposal->created_at ? $proposal->created_at->diffInDays(now()) : null; $approvalRecord = $proposal->approvals ->where('status', 'approved') ->sortByDesc('updated_at') ->first(); $approvalHistory = $proposal->histories ->whereIn('action_type', ['approved', 'revision_created']) ->sortByDesc('created_at') ->first(); $approvedBy = $approvalRecord?->approver?->name; if (!$approvedBy && $proposal->status === 'approved') { $approvedBy = $approvalHistory?->actionBy?->name ?? ($proposal->createdBy?->name ?? 'Approval recorded'); } @endphp {{-- --}} @empty @endforelse
S.No Client Details Proposal Product / Scope Value Stage handled ByCreated AtAction
{{ $proposals->firstItem() + $loop->index }} {{ $clientName }} {{ $contactLine ?: 'Contact details not available' }} @if ($proposal->client?->gst_number) GST: {{ $proposal->client->gst_number }} @endif {{ $proposal->proposal_number }} Created: {{ $createdDate }} @if (($proposal->revision_number ?? 0) > 0) Rev {{ $proposal->revision_number }} @endif {{ $productName }} Variant: {{ $variantName }} Luxe Package: {{ $luxePackageSelection }} ₹ {{ $formatIndianCurrency($proposal->final_amount ?? 0, 0) }} Base: ₹ {{ $formatIndianCurrency($proposal->requested_price ?? ($proposal->original_price ?? 0)) }} Upgradations: ₹ {{ $formatIndianCurrency($proposal->upgradation_total ?? 0) }} @if (($proposal->discount_amount ?? 0) > 0) Discount: ₹ {{ $formatIndianCurrency($proposal->discount_amount) }} @endif {{ $statusLabel }} {{-- Level {{ $proposal->approval_level ?? 0 }} --}} {{ $proposal->createdBy->name ?? 'N/A' }} Assigned: {{ $proposal->currentHandler->name ?? 'Not assigned' }} Approved by: {{ $approvedBy ?? 'Pending approval' }} {{ $createdDate }} Valid until {{ $validUntil }} {{ is_null($ageInDays) ? 'Age unavailable' : $ageInDays . ' days in pipeline' }} View
No active proposals available.
@if ($proposals->hasPages())
Showing {{ $proposals->firstItem() }} to {{ $proposals->lastItem() }} of {{ $proposals->total() }} proposals
{{ $proposals->links() }}
@endif
@endsection @push('scripts') @endpush