@extends('layouts.app') @section('title', $project->name . ' | DYSON LATAM') @section('content') @php $stageLabels = [ 'sample_arrival' => 'Sample Arrival', 'lab_testing' => 'Lab Testing', 'cert_release' => 'Certificate Release', 'country_homologation' => 'Country Homologation', ]; $statusLabels = [ 'completed' => 'Completed', 'in_progress' => 'In Progress', 'pending' => 'Pending', 'blocked' => 'Blocked', 'overdue' => 'Overdue', 'na' => 'N/A', ]; $statusClasses = [ 'completed' => 'status-green', 'in_progress' => 'status-blue', 'pending' => 'status-slate', 'blocked' => 'status-red', 'overdue' => 'status-red', 'na' => 'status-slate', ]; $totalStages = $project->stages->count(); $completedStages = $project->stages->where('status', 'completed')->count(); $progress = $totalStages > 0 ? round(($completedStages / $totalStages) * 100) : 0; $hasBlocked = $project->stages->contains(fn($stage) => $stage->status === 'blocked'); $hasOverdue = $project->stages->contains(fn($stage) => $stage->status === 'overdue'); if ($hasBlocked) { $projectStatus = 'blocked'; } elseif ($hasOverdue) { $projectStatus = 'overdue'; } elseif ($progress === 100) { $projectStatus = 'completed'; } elseif ($project->stages->contains(fn($stage) => $stage->status === 'in_progress')) { $projectStatus = 'in_progress'; } else { $projectStatus = 'pending'; } $projectStatusLabel = $statusLabels[$projectStatus] ?? 'Pending'; $projectStatusClass = $statusClasses[$projectStatus] ?? 'status-slate'; @endphp
{{-- HEADER --}}

{{ $project->name }}

MODEL · {{ $project->model }}
← BACK @if (\Illuminate\Support\Facades\Auth::user()?->role !== 'viewer') EDIT PROJECT @endif
{{-- SUMMARY --}}
Project
{{ $project->name }}
Country
{{ $project->country->name ?? '—' }}
Category
{{ $project->category->name ?? '—' }}
Launch
{{ $project->launch_date ? $project->launch_date->format('d M Y') : '—' }}
Status
{{ $projectStatusLabel }}
{{-- PROGRESS --}}
{{ $progress }}%
{{-- MAIN CONTENT --}}
{{-- LEFT COLUMN --}}
{{-- STAGES --}}
Project Stages
{{ $project->stages->count() }} STAGES
@if ($project->stages->isEmpty())
No stages configured.
@else
@foreach ($project->stages as $stage) @php $stageClass = $statusClasses[$stage->status] ?? 'status-slate'; $stageLabel = $statusLabels[$stage->status] ?? ucfirst(str_replace('_', ' ', $stage->status)); @endphp
{{ $stageLabels[$stage->stage] ?? $stage->stage }}
@if ($stage->completed_at) Completed: {{ $stage->completed_at->format('d M Y') }} @else Not completed @endif
{{ $stageLabel }}
@if ($stage->notes)
{{ $stage->notes }}
@endif
@csrf @method('PATCH')
@endforeach
@endif {{-- CERTIFICATIONS --}}
Certifications
{{ $project->certifications->count() }} RECORDS
@php $availableOptionalCertifications = $project->country ->certifications() ->where('required', false) ->whereNotIn('certification', $project->certifications->pluck('certification')) ->orderBy('id') ->get(); @endphp @foreach ($availableOptionalCertifications as $optionalCertification)
@csrf
@endforeach
@if ($project->certifications->isEmpty())
No certifications configured.
@else
@foreach ($project->certifications as $certification) @php $certClass = $certification->status === 'completed' ? 'status-green' : ($certification->status === 'blocked' || $certification->status === 'overdue' ? 'status-red' : 'status-slate'); @endphp
{{ $certification->certification }}
{{ $certification->required ? 'Required' : 'Optional' }}
{{ ucfirst(str_replace('_', ' ', $certification->status)) }}
@csrf @method('PATCH') @if (!$certification->required) @csrf @method('DELETE')
@endif
@if ($certification->completed_at)
Completed: {{ $certification->completed_at->format('d M Y') }}
@endif @if ($certification->notes)
{{ $certification->notes }}
@endif
@endforeach
@endif
{{-- RIGHT COLUMN --}}
{{-- PROJECT INFORMATION --}}
Project Information
{{ $project->model }}
{{ $project->country->name ?? '—' }}
{{ $project->category->name ?? '—' }}
{{ $project->launch_date ? $project->launch_date->format('d M Y') : '—' }}
{{-- COMMENTS --}}
Comments
{{ $project->comments->count() }}
@csrf
@if ($project->comments->isEmpty())
No comments have been registered.
@else
@foreach ($project->comments as $comment)
{{ $comment->user->name ?? 'System' }}
{{ $comment->created_at->format('d M Y H:i') }}
{{ $comment->text }}
@endforeach
@endif
@endsection