{% extends "base.html" %} {% block title %}Inspection #{{ inspection.id }} — Results{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{# ── Action bar ── #}
Back to Inspections
{% if current_user.role in ['admin','supervisor'] %}
{% endif %}
{# ── Header ── #}

{{ inspection.template.name }}

{{ inspection.facility.name }}{% if inspection.area %} · {{ inspection.area.name }}{% endif %}  ·  Inspector: {{ inspection.inspector.username }}
{{ inspection.status|replace('_',' ')|title }} {% if inspection.overall_score is not none %}
{{ inspection.overall_score }}%
{% endif %}
{# ── Meta row ── #}
Date {{ inspection.inspection_date.strftime('%B %d, %Y %H:%M') }}
{% if inspection.completed_at %}
Completed {{ inspection.completed_at.strftime('%B %d, %Y %H:%M') }}
{% endif %}
Template {{ inspection.template.name }}
Frequency {{ inspection.template.frequency|title }}
{# ── Form field responses ── #} {% if form_fields %}
{% for field in form_fields %} {% set fid = field.id %} {% set val = form_data.get(fid) %}
{% if field.type == 'section' %}
{{ field.label }}
{% elif field.type == 'label' %} {% set fs_map = {'small':'0.78rem','normal':'0.9rem','large':'1.05rem','x-large':'1.25rem'} %}
{{ field.text_content or '' }}
{% elif field.type in ('button_submit','button_print','button_email') %} {# not shown in read-only view #} {% elif field.type == 'image' %} {{ field.label }} {% if val %} Photo {% else %}
No photo uploaded
{% endif %} {% elif field.type == 'signature' %} {{ field.label }} {% if val and val.startswith('data:') %} Signature {% else %}
No signature
{% endif %} {% elif field.type == 'rating' %} {{ field.label }}
{% if val %} {% for i in range(1, 6) %}{{ '★' if i <= (val|int) else '☆' }}{% endfor %} ({{ val }}/5) {% else %} Not rated {% endif %}
{% elif field.type == 'checkbox' %} {{ field.label }}
{% if val == 'true' %} Checked {% else %} Unchecked {% endif %}
{% elif field.type == 'checkbox_group' %} {{ field.label }}
{% if val %} {% for item in (val if val is iterable and val is not string else []) %} {{ item }} {% else %} None selected {% endfor %} {% else %} None selected {% endif %}
{% elif field.type == 'table' %} {{ field.label }} {% if val and val is iterable and val is not string %}
{% for hdr in (field.col_headers or ['Column 1']) %}{% endfor %} {% for row in val %} {% for hdr in (field.col_headers or ['Column 1']) %} {% endfor %} {% endfor %}
{{ hdr }}
{{ row.get(hdr, '') }}
{% else %}
No data
{% endif %} {% else %} {# text, textarea, number, date, email, radio, select ── #} {{ field.label }}
{{ val or 'Not answered' }}
{% endif %}
{% endfor %}
{% else %}

No form fields found for this template.

{% endif %} {# ── Issues ── #} {% if issues %}
Issues Logged ({{ issues|length }})
{% for issue in issues %} {% endfor %}
SeverityAreaDescriptionStatus
{{ issue.severity|title }} {{ issue.area.name }} {{ issue.description[:80] }}{% if issue.description|length > 80 %}…{% endif %} {{ issue.status|replace('_',' ')|title }} View
{% endif %}
{% endblock %}