@extends('layouts.dashboard') @section('title', 'Tracking Alerts') @section('content')

Tracking Alerts & Notifications

Critical Alerts

{{ $alerts->where('scheduled_end', '<', now())->count() }}

Overdue Visits

{{ $alerts->where('scheduled_end', '<', now())->count() }}

No Location Updates

{{ $alerts->where('last_location_update', '<', now()->subMinutes(30))->count() }}

Resolved Today

0

Active Alerts

@php $alertTypes = [ 'overdue' => ['icon' => 'fa-clock', 'color' => 'text-red-600', 'bg' => 'bg-red-100'], 'no_location' => ['icon' => 'fa-map-marker-slash', 'color' => 'text-yellow-600', 'bg' => 'bg-yellow-100'], 'off_route' => ['icon' => 'fa-route', 'color' => 'text-orange-600', 'bg' => 'bg-orange-100'], ]; @endphp @forelse($alerts as $visit) @php $isOverdue = $visit->scheduled_end && $visit->scheduled_end < now(); $noLocation = $visit->last_location_update && $visit->last_location_update < now()->subMinutes(30); if ($isOverdue) { $type = 'overdue'; $severity = 'critical'; $message = 'Visit overdue by ' . $visit->scheduled_end->diffForHumans(null, true); } elseif ($noLocation) { $type = 'no_location'; $severity = 'warning'; $message = 'No location update for ' . $visit->last_location_update->diffForHumans(null, true); } else { $type = 'off_route'; $severity = 'info'; $message = 'Potential route deviation'; } @endphp @empty @endforelse
Alert Employee & Client Details Severity Time Actions
@if($type == 'overdue') Overdue Visit @elseif($type == 'no_location') No Location Update @else Route Deviation @endif
{{ $message }}
{{ $visit->employee->name }}
{{ $visit->client->name }}
@if($visit->current_address) {{ Str::limit($visit->current_address, 25) }} @else Location unknown @endif
Scheduled: {{ $visit->scheduled_date->format('H:i') }} @if($visit->scheduled_end) - {{ $visit->scheduled_end->format('H:i') }} @endif
@if($severity == 'critical') Critical @elseif($severity == 'warning') Warning @else Info @endif @if($type == 'overdue') {{ $visit->scheduled_end->diffForHumans() }} @elseif($type == 'no_location') {{ $visit->last_location_update->diffForHumans() }} @else {{ $visit->updated_at->diffForHumans() }} @endif

No active alerts at the moment

Great! Everything is running smoothly.

Recent Resolved Alerts

No resolved alerts in the past 24 hours

Resolved alerts will appear here for 24 hours

@endsection