Dashboard

@php $showInv = $show['invoices'] ?? false; $showProp = $show['proposals'] ?? false; $showEst = $show['estimations'] ?? false; $showPay = $show['payments'] ?? false; $showCust = $show['customers'] ?? false; $showLeads = $show['leads'] ?? false; $hasAny = $showInv || $showProp || $showEst || $showPay || $showCust || $showLeads; $ownOnly = fn(string $key) => ($access[$key]['visible'] ?? false) && !($access[$key]['all'] ?? false); $canRemind = $showCust || $showLeads; $ajaxUrl = url('admin/dashboard/ajax'); $companyName = \App\Models\Option::get('company_name', config('app.name', 'Dashboard')); $cur = $currency ?? '₹'; $urls = [ 'invoices' => Route::has('admin.salesmanagement.invoices.index') ? route('admin.salesmanagement.invoices.index') : '', 'proposals' => Route::has('admin.salesmanagement.proposals.index') ? route('admin.salesmanagement.proposals.index') : '', 'estimations' => Route::has('admin.salesmanagement.estimations.index') ? route('admin.salesmanagement.estimations.index') : '', 'customers' => Route::has('admin.customermanagement.index') ? route('admin.customermanagement.index') : '', 'leads' => Route::has('admin.leadmanagement.index') ? route('admin.leadmanagement.index') : '', ]; @endphp {{-- ═══ HEADER ═══ --}}
{{ $companyName }}
{{ auth('admin')->user()->name ?? '' }} · {{ now()->format('l, d M Y') }}
@if($canRemind) @endif
@if($hasAny) {{-- ═══════════════════════════════════════════════════ ROW 1: STAT CARDS — bold grid across top ═══════════════════════════════════════════════════ --}}
@if($showPay && isset($stats['revenue']))
Revenue @if($ownOnly('payments'))own@endif
{{ $cur }}{{ number_format($stats['revenue']['value'],2) }}
@if($stats['revenue']['change']!=0){{ $stats['revenue']['change']>=0?'+':'' }}{{ $stats['revenue']['change'] }}% vs last mo @else—@endif
@endif @if($showInv && isset($stats['invoices']))
Invoices @if($ownOnly('invoices'))own@endif
{{ $stats['invoices']['total'] }}
@endif @if($showProp && isset($stats['proposals']))
Proposals @if($ownOnly('proposals'))own@endif
{{ $stats['proposals']['total'] }}
{{ $stats['proposals']['open'] }} open · {{ $stats['proposals']['accepted'] }} accepted
@endif @if($showEst && isset($stats['estimations']))
Estimations @if($ownOnly('estimations'))own@endif
{{ $stats['estimations']['total'] }}
{{ $stats['estimations']['open'] }} open · {{ $stats['estimations']['accepted'] }} accepted
@endif @if($showCust && isset($stats['customers']))
Customers @if($ownOnly('customers'))own@endif
{{ number_format($stats['customers']['value']) }}
+{{ $stats['customers']['new'] }} this mo @if($stats['customers']['change']!=0)· {{ $stats['customers']['change']>=0?'+':'' }}{{ $stats['customers']['change'] }}%@endif
@endif @if($showLeads && isset($stats['leads']))
Active Leads @if($ownOnly('leads'))own@endif
{{ number_format($stats['leads']['value']) }}
+{{ $stats['leads']['new'] }} new · {{ $stats['leads']['converted'] }} converted
@endif
{{-- ═══════════════════════════════════════════════════ ROW 2: Revenue Chart (left) + Calendar (right) ═══════════════════════════════════════════════════ --}}
@if($showPay && !empty($revenueChart))

Revenue & Invoiced

6 months
@endif {{-- Calendar — big and proper --}}

Calendar

@if($canRemind)@endif
{{-- Events --}}
Upcoming
No events
{{-- Legend --}}
@foreach(['#2563eb'=>'Customer','#7c3aed'=>'Lead','#d97706'=>'Invoice','#0891b2'=>'Estimation','#4f46e5'=>'Proposal'] as $col=>$lbl) {{ $lbl }} @endforeach
{{-- ═══════════════════════════════════════════════════ ROW 3: Sub-charts — Invoice Donut, Lead Dist, Cust Growth ═══════════════════════════════════════════════════ --}} @php $subCount = ($showInv && !empty($invoiceDonut)?1:0) + ($showLeads && !empty($leadPipeline) && collect($leadPipeline)->sum('count')>0?1:0) + ($showCust && !empty($customerGrowth)?1:0); @endphp @if($subCount > 0)
@if($showInv && !empty($invoiceDonut))

Invoice Status

@if($urls['invoices'])View all →@endif
@endif @if($showLeads && !empty($leadPipeline) && collect($leadPipeline)->sum('count')>0)

Lead Distribution

@if($urls['leads'])View all →@endif
@endif @if($showCust && !empty($customerGrowth))

Customer Growth

6 months
@endif
@endif {{-- ═══════════════════════════════════════════════════ ROW 4: Lead Pipeline ═══════════════════════════════════════════════════ --}} @if($showLeads && !empty($leadPipeline)) @php $pt=collect($leadPipeline)->sum('count'); @endphp @if($pt>0)

Lead Pipeline @if($ownOnly('leads'))own@endif

{{ $pt }} total
@foreach($leadPipeline as $sg)@if($sg['count']>0)@php $pipeUrl=$urls['leads'];if(!in_array($sg['name'],['Lost','Junk'])&&$pipeUrl){$sid=\Illuminate\Support\Facades\DB::table('leads_status')->where('name',$sg['name'])->value('id');$pipeUrl.=$sid?'?status='.$sid:'';}elseif($sg['name']==='Lost'&&$pipeUrl){$pipeUrl.='?lost=1';}elseif($sg['name']==='Junk'&&$pipeUrl){$pipeUrl.='?junk=1';} @endphp@if(($sg['count']/$pt)>.08){{ $sg['count'] }}@endif@endif @endforeach
@foreach($leadPipeline as $sg){{ $sg['name'] }} {{ $sg['count'] }}@endforeach
@endif @endif {{-- ═══════════════════════════════════════════════════ ROW 5: Recent tables (2-col on desktop) ═══════════════════════════════════════════════════ --}}
Recent Activity
@foreach([ ['key'=>'invoices','show'=>$showInv,'data'=>$recentInvoices,'title'=>'Recent Invoices','route'=>'admin.salesmanagement.invoices','nf'=>'invoice_number','sr'=>'admin.salesmanagement.invoices.show'], ['key'=>'proposals','show'=>$showProp,'data'=>$recentProposals,'title'=>'Recent Proposals','route'=>'admin.salesmanagement.proposals','nf'=>'proposal_number','sr'=>'admin.salesmanagement.proposals.show'], ['key'=>'estimations','show'=>$showEst,'data'=>$recentEstimations,'title'=>'Recent Estimations','route'=>'admin.salesmanagement.estimations','nf'=>'estimation_number','sr'=>'admin.salesmanagement.estimations.show'], ] as $sec) @if($sec['show'])

{{ $sec['title'] }}

@if(Route::has($sec['route'].'.index'))View all →@endif
@if($sec['data']->isEmpty())
No records yet
@else
@foreach($sec['data'] as $row)@php $st=$row->status??'draft';$c=match($st){'paid','accepted'=>'#059669','unpaid','pending'=>'#d97706','overdue'=>'#dc2626','partially_paid'=>'#2563eb','sent'=>'#7c3aed','declined'=>'#dc2626',default=>'#6b7280'}; @endphp @endforeach
#AmountStatus
@if(Route::has($sec['sr'])){{ $row->{$sec['nf']}??'#'.$row->id }}@else{{ $row->{$sec['nf']}??'#'.$row->id }}@endif{{ $cur }}{{ number_format($row->total??0,2) }}{{ ucfirst(str_replace('_',' ',$st)) }}
@foreach($sec['data'] as $row)@php $st=$row->status??'draft';$c=match($st){'paid','accepted'=>'#059669','unpaid','pending'=>'#d97706','overdue'=>'#dc2626','partially_paid'=>'#2563eb','sent'=>'#7c3aed','declined'=>'#dc2626',default=>'#6b7280'}; @endphp
@if(Route::has($sec['sr'])){{ $row->{$sec['nf']}??'#'.$row->id }}@else{{ $row->{$sec['nf']}??'#'.$row->id }}@endif
{{ $cur }}{{ number_format($row->total??0,2) }}
{{ ucfirst(str_replace('_',' ',$st)) }}{{ \Carbon\Carbon::parse($row->created_at)->format('d M') }}
@endforeach
@endif
@endif @endforeach @if($showLeads)

Recent Leads

@if($urls['leads'])View all →@endif
@if($recentLeads->isEmpty())
No leads yet
@else
@foreach($recentLeads as $l)@endforeach
LeadStatusValue
@if(Route::has('admin.leadmanagement.show')){{ $l->name }}@else{{ $l->name }}@endif @if($l->company)
{{ $l->company }}
@endif
@if($l->status_name){{ $l->status_name }}@else—@endif{{ ($l->lead_value??0)>0?$cur.number_format($l->lead_value,2):'—' }}
@foreach($recentLeads as $l)
@if(Route::has('admin.leadmanagement.show')){{ $l->name }}@else{{ $l->name }}@endif
@if($l->company)
{{ $l->company }}
@endif
{{ ($l->lead_value??0)>0?$cur.number_format($l->lead_value,0):'—' }}
@if($l->status_name)
{{ $l->status_name }}
@endif
@endforeach
@endif
@endif @if($showCust)

Recent Customers

@if($urls['customers'])View all →@endif
@if($recentCustomers->isEmpty())
No customers yet
@else
@foreach($recentCustomers as $c)@endforeach
CustomerTypeActive
@if(Route::has('admin.customermanagement.show')){{ $c->name }}@else{{ $c->name }}@endif @if($c->email)
{{ $c->email }}
@endif
{{ ucfirst($c->customer_type??'person') }}{{ $c->active?'Yes':'No' }}
@endif
@endif @if($showPay && $showCust && $topCustomers->isNotEmpty())

Top Customers by Revenue

@foreach($topCustomers as $i=>$tc)@endforeach
#CustomerRevenueTxns
{{ $i+1 }}{{ $tc->name }}@if($tc->company) · {{ $tc->company }}@endif{{ $cur }}{{ number_format($tc->total_paid,2) }}{{ $tc->payment_count }}
@endif
{{-- Quick Actions --}}

Quick Actions

@if($showCust && Route::has('admin.customermanagement.create'))
New Customer
@endif @if($showLeads && Route::has('admin.leadmanagement.create'))
New Lead
@endif @if($showInv && Route::has('admin.salesmanagement.invoices.create'))
New Invoice
@endif @if($showProp && Route::has('admin.salesmanagement.proposals.create'))
New Proposal
@endif @if($showEst && Route::has('admin.salesmanagement.estimations.create'))
New Estimation
@endif
@else
No Data Available
Install modules or check permissions.
@if(Route::has('admin.modules.index'))Browse Modules@endif
@endif {{-- ═══ REMINDER MODAL ═══ --}} @if($canRemind)

New Reminder

@endif {{-- ═══ SCRIPTS ═══ --}}