@extends('layouts.app') @section('title', $deviation->deviation_number . ' — ' . $deviation->title) @section('content')

{{ $deviation->record_kind->label() }} {{ $deviation->deviation_number }} @if($deviation->is_emergency) EMERGENCY @endif

@include('deviations.partials.alerts') {{-- Header --}}
{{ $deviation->title }}
{{-- Status row --}}
Status: {{ $deviation->status->label() }}
Phase: {{ $currentPhase }} of 5
Department: {{ $deviation->department?->department_name }}
Discovered: {{ $deviation->discovered_date?->format('M j, Y H:i') }} by {{ $deviation->discoveredByUser?->name }}
{{-- Progress bar --}}
Overall Progress {{ round($progress) }}%
{{ round($progress) }}%
{{-- Phase Timeline --}} @php $phases = [ 1 => ['name' => 'Initiation & Containment', 'icon' => 'fa-flag'], 2 => ['name' => 'Risk Assessment', 'icon' => 'fa-clipboard-check'], 3 => ['name' => 'Investigation', 'icon' => 'fa-search'], 4 => ['name' => 'Impact & CAPA', 'icon' => 'fa-tasks'], 5 => ['name' => 'Effectiveness & Closure', 'icon' => 'fa-lock'], ]; @endphp
@foreach($phases as $num => $p) @php $phaseColor = $num < $currentPhase ? 'success' : ($num == $currentPhase ? 'primary' : 'secondary'); @endphp
@if($num < $currentPhase) @else @endif
Phase {{ $num }}
{{ $p['name'] }}
@endforeach
{{-- Gate Action --}} @if($currentPhase < 5)
Gate {{ $currentPhase }}: {{ $gateStatus['gate'] }}
@if($gateStatus['passed'])
All prerequisites met. You may advance to Phase {{ $currentPhase + 1 }}.
@csrf
@else
Prerequisites not met:
    @foreach($gateStatus['missing'] as $m)
  • {{ $m }}
  • @endforeach
@endif
@endif @include('record-links._tab', ['record' => $deviation]) {{-- Tab Navigation --}} {{-- Tab Content --}}
@include('deviations.partials.phase1', ['deviation' => $deviation])
@include('deviations.partials.phase2', ['deviation' => $deviation])
@include('deviations.partials.phase3', ['deviation' => $deviation])
@include('deviations.partials.phase4', ['deviation' => $deviation])
@include('deviations.partials.phase5', ['deviation' => $deviation])
{{-- Evidence --}}
Supporting Evidence
@include('deviations.partials.evidence-list', ['deviation' => $deviation])
{{-- Audit Trail --}}
Audit Trail
@include('deviations.partials.audit-trail', ['deviation' => $deviation])
{{-- Upload Evidence Modal --}} @endsection