@extends('layouts.app') @section('content')
Verification Details

Verification Information
Checklist: {{ $verification->checklist->mosque->name }} - {{ \Carbon\Carbon::parse($verification->checklist->date)->format('d M Y') }}
Moulvi: @if($verification->moulvi)
{{ substr($verification->moulvi->name, 0, 1) }}
{{ $verification->moulvi->name }} @if($verification->moulvi->email)
{{ $verification->moulvi->email }} @endif
@else Not Assigned @endif
Status: @php $statusColors = [ 'PENDING' => 'warning', 'APPROVED' => 'success', 'REJECTED' => 'danger' ]; @endphp {{ $verification->approve_status }}
Created At: {{ $verification->created_at->format('d M Y, h:i A') }}
Last Updated: {{ \Carbon\Carbon::parse($verification->updated_at)->format('d M Y, h:i A') }}
@if($verification->comments)
Comments

{{ $verification->comments }}

@endif @canany(['update verifications', 'delete verifications'])
Actions
@can('update verifications') Edit Verification @endcan @can('delete verifications')
@csrf @method('DELETE')
@endcan
@endcanany
KPI Scores
@if($verification->kpi_score_json && isset($verification->kpi_score_json['average_score'])) Average: {{ $verification->kpi_score_json['average_score'] }}/10 @endif
@php // ✅ Ensure array (in case stored as JSON string) $kpi = $verification->kpi_score_json; if (is_string($kpi)) { $kpi = json_decode($kpi, true) ?: []; } elseif (is_object($kpi)) { $kpi = (array) $kpi; } elseif (!is_array($kpi)) { $kpi = []; } $kpiCategories = [ 'cleanliness' => 'Cleanliness', 'prayer_mat_arrangement' => 'Prayer Mat Arrangement', 'ablution_area' => 'Ablution Area', 'restrooms' => 'Restrooms', 'carpet_condition' => 'Carpet Condition', 'window_cleaning' => 'Window Cleaning', 'lighting' => 'Lighting', 'overall_hygiene' => 'Overall Hygiene', ]; @endphp @if(!empty($kpi))
@foreach($kpiCategories as $key => $label) @php $score = isset($kpi[$key]) ? (int) $kpi[$key] : null; // ✅ clamp 0..10 if ($score !== null) { $score = max(0, min(10, $score)); } $bar = 'danger'; if ($score !== null) { $bar = $score >= 7 ? 'success' : ($score >= 5 ? 'warning' : 'danger'); } @endphp @if($score !== null)
{{ $label }} {{ $score }}/10
@endif @endforeach
{{-- ✅ Summary (optional keys) --}} @php $total = $kpi['total_score'] ?? null; $avg = $kpi['average_score'] ?? null; // If avg not stored, calculate it from category scores if ($avg === null) { $vals = []; foreach ($kpiCategories as $k => $lbl) { if (isset($kpi[$k])) $vals[] = (float) $kpi[$k]; } $avg = count($vals) ? array_sum($vals) / count($vals) : null; } @endphp @if($total !== null || $avg !== null)

{{ $total !== null ? $total : '-' }}

Total Score

{{ $avg !== null ? number_format((float)$avg, 2) : '-' }}

Average Score
@endif @else

No KPI scores recorded.

@endif
Checklist Details
@if($verification->checklist->shift_started_at && $verification->checklist->shift_ended_at) @endif
Mosque: {{ $verification->checklist->mosque->name }}
Cleaner: @if($verification->checklist->cleaner) {{ $verification->checklist->cleaner->name }} @else Not Assigned @endif
Checklist Status: @php $checklistStatusColors = [ 'NOT_STARTED' => 'secondary', 'IN_PROGRESS' => 'warning', 'SUBMITTED' => 'info', 'PENDING_VERIFICATION' => 'primary', 'VERIFIED' => 'success', 'REWORK_REQUIRED' => 'danger' ]; @endphp {{ ucfirst(strtolower(str_replace('_', ' ', $verification->checklist->status))) }}
Shift Time: {{ \Carbon\Carbon::parse($verification->checklist->shift_started_at)->format('h:i A') }} - {{ \Carbon\Carbon::parse($verification->checklist->shift_ended_at)->format('h:i A') }}
@endsection