@extends('layouts.app') @php $fmtDate = function ($value, string $format = 'M j, Y H:i') { if (empty($value)) return '—'; try { return \Illuminate\Support\Carbon::parse($value)->format($format); } catch (\Throwable $e) { return (string) $value; } }; @endphp @section('title', $template->template_code . ' — ' . $template->name) @section('content')
@foreach(['success' => 'check-circle', 'warning' => 'exclamation-triangle', 'error' => 'exclamation-circle'] as $key => $icon) @if(session($key))
{{ session($key) }}
@endif @endforeach

{{ $template->template_type->value }} {{ $template->template_code }} v{{ $template->version }}

{{ $template->name }}
@if($template->isEditable()) Edit
@csrf
@else
@csrf
@endif Back
Status: {{ $template->status->label() }}
Scope: {{ $template->scope->label() }}
Created By: {{ $template->creator?->name ?? '—' }}
Approved: {{ $fmtDate($template->approved_at, 'M j, Y') }}
FMEA Dimensions: @if($template->requires_severity) Severity @endif @if($template->requires_occurrence) Occurrence @endif @if($template->requires_detection) Detectability @endif
@if($template->description)
Description

{!! nl2br(e($template->description)) !!}

@endif

Created: {{ $fmtDate($template->created_at) }}

@foreach($template->thresholds() as $band) @endforeach
Min RPNMax RPNLevelAction
{{ $band['min'] }} {{ $band['max'] }} {{ $band['level'] }} {{ $band['action'] ?? '—' }}
@if($template->fields->isEmpty())
No custom fields defined.
@else @foreach($template->fields as $f) @endforeach
KeyLabelTypeRequiredOptions
{{ $f->field_key }} {{ $f->label }} {{ $f->field_type->label() }} {{ $f->is_required ? 'Yes' : 'No' }} {{ $f->options ? implode(', ', $f->options) : '—' }}
@endif
@if($template->assessments->isEmpty())
No assessments yet.
@else @foreach($template->assessments as $a) @endforeach
NumberTitleStatusOutcomeCreated
{{ $a->assessment_number }} {{ Str::limit($a->title, 50) }} {{ $a->status->label() }} @if($a->outcome) {{ $a->outcome->label() }} @endif {{ $fmtDate($a->created_at, 'M j, Y') }}
@endif
@endsection