@extends('layouts.app') @section('title', 'Dashboard') @section('breadcrumb')Dashboard@endsection @section('content') @php $userRole = $userRole ?? auth()->user()->role?->name ?? 'staff'; @endphp {{-- ═══════════════════ TRADES DASHBOARD ═══════════════════ --}} @if($userRole === 'trades')

Dashboard

Welcome back, {{ auth()->user()->name }}. Here's your work summary.

My Timesheet
@if(isset($runningEntry) && $runningEntry)
Timer Running
{{ $runningEntry->taskType?->name ?? 'General' }} — {{ $runningEntry->job?->contact?->full_name ?? $runningEntry->job?->job_number ?? 'No job' }}
Stop Timer
@endif
Active Jobs
{{ $myJobs->count() }}
Assigned to you
Hours This Week
{{ $hoursThisWeek }}
{{ now()->startOfWeek()->format('d M') }} – {{ now()->endOfWeek()->format('d M') }}
Completed Jobs
{{ $completedJobsCount }}
All time

My Active Jobs

View all
@forelse($myJobs as $job)
{{ $job->contact?->initials ?? '??' }}
{{ $job->contact?->full_name ?? 'Unknown' }}
{{ $job->job_number }} · {{ $job->site_address ?? $job->site_suburb }}
{{ $job->stageLabel() }}
@empty

No active jobs assigned to you.

@endforelse
@if(isset($recentTimeEntries) && $recentTimeEntries->count())

Recent Time Log

Timesheet
@foreach($recentTimeEntries as $entry)
{{ $entry->taskType?->name ?? 'General' }}
{{ $entry->job?->contact?->full_name ?? $entry->job?->job_number ?? '—' }} · {{ $entry->started_at?->format('d M') }}
{{ round($entry->duration_minutes / 60, 1) }}h
@endforeach
@endif
{{-- ═══════════════════ FULL DASHBOARD (ALL OTHER ROLES) ═══════════════════ --}} @else @php $isAdmin = $isAdmin ?? in_array($userRole, ['office_admin','project_manager']); $isFinance = $isFinance ?? in_array($userRole, ['office_admin','project_manager','accounts']); // Use navPerms from view composer if available $canCreateLead = ($userRole === 'office_admin') || (!empty($navPerms['leads.create'] ?? false)); $canCreateJob = ($userRole === 'office_admin') || (!empty($navPerms['jobs.create'] ?? false)); @endphp

Dashboard

Welcome back, {{ auth()->user()->name }}. Here's what's happening today.

@if($canCreateLead) New Lead @endif @if($canCreateJob) New Job @endif
Total Jobs
{{ $totalJobs }}
All time
Active Jobs
{{ $activeJobs }}
Currently in progress
Jobs This Month
{{ $jobsThisMonth }}
{{ now()->format('F Y') }}
Overdue Items
{{ $overdueItems }}
Needs attention

Job Pipeline

View all
@foreach([ ['label'=>'Lead','key'=>'lead','color'=>'#94a3b8','icon'=>'user-plus'], ['label'=>'Consult','key'=>'consult','color'=>'#60a5fa','icon'=>'comments'], ['label'=>'Sold','key'=>'sold','color'=>'#4ade80','icon'=>'handshake'], ['label'=>'Contracts','key'=>'contracts','color'=>'#c084fc','icon'=>'file-contract'], ['label'=>'Chk Meas.','key'=>'cm','color'=>'#818cf8','icon'=>'ruler'], ['label'=>'Processing','key'=>'processing','color'=>'#2dd4bf','icon'=>'industry'], ['label'=>'Delivery','key'=>'delivery','color'=>'#fb923c','icon'=>'truck'], ['label'=>'Install.','key'=>'installation','color'=>'#fbbf24','icon'=>'tools'], ['label'=>'Complete','key'=>'completion','color'=>'#34d399','icon'=>'check-circle'], ] as $stage)
{{ $pipeline[$stage['key']] ?? 0 }}
{{ $stage['label'] }}
@endforeach

Recent Jobs

View all
@forelse($recentJobs as $job) @empty @endforelse
Job Client Stage Value
{{ $job->job_number }}
{{ $job->project_type ? ucfirst($job->project_type) : 'Kitchen' }}
{{ $job->contact?->full_name ?? '—' }}
{{ $job->site_suburb }}
{{ $job->stageLabel() }}
${{ number_format($job->job_value ?? 0) }}
No jobs yet

Upcoming Events

Calendar
@forelse($upcomingEvents as $event)
{{ $event->title }}
{{ $event->start_at->format('D d M, g:ia') }}
@empty

No upcoming events

@endforelse

Pending Tasks

@forelse($pendingTasks as $task)
{{ $task->title }}
Due {{ $task->due_date?->format('d M') ?? 'No date' }}
{{ ucwords(str_replace('_',' ',$task->status)) }}
@empty

No pending tasks

@endforelse
@if($isAdmin || $isFinance)
@if($isAdmin && $recentLeads->count() >= 0)

Recent Leads

View all
@forelse($recentLeads as $lead)
{{ $lead->contact?->initials ?? '??' }}
{{ $lead->contact?->full_name ?? 'Unknown' }}
{{ $lead->source }} · {{ $lead->enquiry_date?->diffForHumans() }}
{{ $lead->statusLabel() }}
@empty

No leads yet

@endforelse
@endif @if($isFinance && $recentQuotes->count() >= 0)

Recent Quotes

View all
@forelse($recentQuotes as $quote)
{{ $quote->quote_number }}
{{ $quote->contact?->full_name ?? '—' }}
${{ number_format($quote->total ?? 0) }}
{{ $quote->statusLabel() }}
@empty

No quotes yet

@endforelse
@endif
@endif @if($isFinance)
Operational Status

Contracts Administration

{{ $pipeline['contracts'] }} job(s) at contracts stage

View all
@if($unsignedContracts > 0) {{ $unsignedContracts }} unsigned @endif @if($pendingDepositContracts > 0) {{ $pendingDepositContracts }} deposit(s) outstanding @endif @if($unsignedContracts === 0 && $pendingDepositContracts === 0) All contracts up to date @endif
@forelse($contractsJobs as $job)
{{ $job->contact?->initials ?? '??' }}
{{ $job->contact?->full_name ?? 'Unknown' }}
{{ $job->job_number }} · {{ $job->site_suburb }}
${{ number_format($job->job_value ?? 0) }}
@php $latestContract = $job->contracts->first(); @endphp @if($latestContract?->signed_date) Signed @elseif($latestContract)Unsigned @elseNo contract@endif
@empty

No jobs at contracts stage

@endforelse

Processing / Manufacturing

{{ $pipeline['processing'] }} job(s) in production

View all
@forelse($processingStats as $row) @php $job = $row['job']; $pct = $row['total'] > 0 ? ($row['completed'] / $row['total']) * 100 : 0; @endphp
{{ $job->contact?->initials ?? '??' }}
{{ $job->contact?->full_name ?? 'Unknown' }}
{{ $job->job_number }}
{{ $row['completed'] }}/{{ $row['total'] }} orders
@if($row['pending'] > 0)
{{ $row['pending'] }} pending
@else
All done
@endif
@if($row['total'] > 0)
@else
No production orders yet
@endif
@empty

No jobs in processing

@endforelse

Pre-Delivery

{{ $pipeline['delivery'] }} job(s) awaiting delivery

View all
@if($scheduledDeliveries->count())
Upcoming Scheduled Deliveries
@foreach($scheduledDeliveries as $del)
{{ $del->job?->contact?->full_name ?? $del->job?->job_number ?? '—' }}
{{ \Carbon\Carbon::parse($del->scheduled_date)->format('D d M') }}
@endforeach
@endif
@forelse($deliveryJobs as $job)
{{ $job->contact?->initials ?? '??' }}
{{ $job->contact?->full_name ?? 'Unknown' }}
{{ $job->job_number }} · {{ $job->site_suburb }}
${{ number_format($job->job_value ?? 0) }}
@empty

No jobs awaiting delivery

@endforelse

Installation / Completion

{{ $pipeline['installation'] }} installing · {{ $pipeline['completion'] }} completing

View all
@if($upcomingInstalls->count())
Upcoming Installations
@foreach($upcomingInstalls as $inst)
{{ $inst->title }}
{{ $inst->start_at->format('D d M') }}
@if($inst->assignedTo)
{{ $inst->assignedTo->name }}
@endif
@endforeach
@endif
@forelse($installationJobs as $job)
{{ $job->contact?->initials ?? '??' }}
{{ $job->contact?->full_name ?? 'Unknown' }}
{{ $job->job_number }} · {{ $job->site_suburb }}
{{ $job->stageLabel() }}
@empty

No jobs in installation or completion

@endforelse
@endif {{-- end operational panels --}}
@endif {{-- end non-trades --}} @endsection