{% extends "base.html" %} {% block title %}{{ inspection.template.name }} — Inspection{% endblock %} {% block extra_css %} {% endblock %} {% block content %}
{# ── Header ── #}

{{ inspection.template.name }}

{{ inspection.facility.name }} {% if inspection.area %} · {{ inspection.area.name }}{% endif %}  ·  Inspector: {{ inspection.inspector.display_name }}
{{ inspection.template.frequency|title }}
{# ── Instructions from the schedule (phase36) ── Only rendered when this inspection was started from a ScheduledInspection that carries instructions. `scheduled_inspection` is NULL for ad-hoc work and for schedules deleted after the inspection was started, so both the relationship and the text are guarded. #} {% if inspection.scheduled_inspection and inspection.scheduled_inspection.notes %}
Instructions for this inspection
{{ inspection.scheduled_inspection.notes }}
{% endif %} {# ── Form body ── #}
{% if form_fields %}
{% for field in form_fields %} {% set fid = field.id %} {% set saved = saved_responses.get(fid, '') %}
{# ── Section label (display only) ── #} {% if field.type == 'section' %}
{{ field.label }}
{# ── Static 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 '' }}
{# ── Submit / Print / Email buttons (display in preview; no action needed here) ── #} {% elif field.type in ('button_submit','button_print','button_email') %} {# rendered by the sticky footer instead #} {# ── Text ── #} {% elif field.type == 'text' %} {% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Textarea ── #} {% elif field.type == 'textarea' %} {% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Number ── #} {% elif field.type == 'number' %} {% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Date ── #} {% elif field.type == 'date' %} {% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Email ── #} {% elif field.type == 'email' %} {% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Checkbox ── #} {% elif field.type == 'checkbox' %}
{% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Checkbox group ── #} {% elif field.type == 'checkbox_group' %} {% for opt in field.options %}
{% endfor %} {% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Radio ── #} {% elif field.type == 'radio' %} {% for opt in field.options %}
{% endfor %} {% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Pass / Fail ── #} {% elif field.type == 'pass_fail' %} {% set pf_options = field.options if field.options else ['Pass', 'Fail'] %}
{% for opt in pf_options %} {% set is_pass = opt.lower() in ('pass','yes','ok','good','acceptable','compliant') %} {% endfor %}
{% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Select / Dropdown ── #} {% elif field.type == 'select' %} {% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Rating (stars) ── #} {% elif field.type == 'rating' %}
{% for i in range(1, 6) %} {% endfor %}
{% if field.help_text %}
{{ field.help_text }}
{% endif %} {# ── Image / Photo upload ── #} {% elif field.type == 'image' %} {# Single
{% endfor %}
{% else %}

This template has no form fields. Please add fields in the template editor.

{% endif %}
{# ── Sticky footer ── #}
{# ── Flag Issue offcanvas panel ───────────────────────────────────────────── Replaces the old full-page navigation. The form posts to the existing flag_issue endpoint via fetch — no page reload, no photo data loss. #}
Flag Issue

Facility: {{ inspection.facility.name }}

{% endblock %} {% block extra_js %} {% endblock %}