@extends('layouts.app') @section('title', 'Dashboard – Gap Finder Analytics') @section('content')

Dashboard

Overview of territories, MRs, doctors, and imports.

Territories (Areas)
{{ $stats['areas'] }}
Medical Representatives
{{ $stats['mrs'] }}
Doctors
{{ $stats['doctors'] }}
MR–Area Assignments
{{ $stats['assignments'] }}
Visits
{{ $stats['visits'] }}
Import Batches
{{ $stats['import_batches'] }}

Recent Territories

@if ($recentAreas->count())
@foreach ($recentAreas as $a) @endforeach
Code / NameDoctors
{{ $a->code ?? $a->name }} {{ $a->doctors_count }}
@else

No territories yet. Import a location sheet.

@endif

Recent MRs

@if ($recentMrs->count())
@foreach ($recentMrs as $mr) @endforeach
NameAssignments
{{ $mr->name }} {{ $mr->area_assignments_count }}
@else

No MRs yet. Import a location sheet.

@endif

Recent Doctors

@if ($recentDoctors->count())
@foreach ($recentDoctors as $d) @endforeach
NameArea
{{ $d->name }} {{ $d->area->name ?? '–' }}
@else

No doctors yet. Import a location sheet.

@endif

Recent Import Batches

@if ($recentBatches->count())
@foreach ($recentBatches as $b) @endforeach
FileStatusRowsDate
{{ $b->file_name }} {{ $b->status }} {{ $b->staging_rows_count ?? 0 }} {{ $b->created_at->format('M j, Y H:i') }} View
@else

No import batches yet. Go to Imports to upload visit or location sheets.

@endif

All imports →

@if (!empty($deviationAlerts))

Deviation alerts (last 30 days)

MRs with compliance score below “high” ({{ $periodFrom }} – {{ $periodTo }}). Run php artisan visits:classify to refresh territory classification.

@foreach ($deviationAlerts as $mrId => $s) @php $mr = \App\Models\Mr::find($mrId); @endphp @endforeach
MRScoreBandVisitsOutsideReasons
{{ $mr?->name ?? 'MR #'.$mrId }} {{ $s['score'] }} {{ $s['band'] }} {{ $s['total_visits'] }} {{ $s['outside'] }} {{ collect($s['reasons'] ?? [])->pluck('code')->join(', ') ?: '–' }} Details

Compliance overview →

@endif @endsection