{% extends "base.html" %} {% block title %}Dashboard{% endblock %} {% block content %}

Welcome, {{ current_user.username }}!

{{ current_user.role|title }}
{# ── Top stat cards ─────────────────────────────────────────────────────── #}
Today's Inspections
{{ today_inspections }}
Completed Today
{{ completed_today }}
Open Issues
{{ open_issues }}
Avg Score (30d)
{{ avg_score if avg_score else '--' }}{% if avg_score %}%{% endif %}
{# ── SLA Summary ─────────────────────────────────────────────────────────── #} {% if sla_breached > 0 or sla_at_risk > 0 %}
{% if sla_breached > 0 %}
SLA Breached
{{ sla_breached }}
{% endif %} {% if sla_at_risk > 0 %}
SLA At Risk
{{ sla_at_risk }}
{% endif %}
{% endif %} {# ── System quick stats (admin/supervisor) ──────────────────────────────── #} {% if current_user.role in ['admin', 'supervisor'] %}
{{ total_facilities }}
Active Facilities
{{ total_templates }}
Templates
{% if current_user.role == 'admin' %}
{{ total_users }}
Users
{% endif %}
{% endif %} {# ── Score trend chart + Facility performance ───────────────────────────── #}
Inspection Score Trend (Last 30 Days)
{% if trend_labels %} {% else %}
No completed inspections with scores in the last 30 days.
{% endif %}
{% if current_user.role in ['admin', 'supervisor'] and facility_perf %}
Facility Performance (30d)
{% for f in facility_perf %} {% endfor %}
Facility Inspections Avg Score
{{ f.name }} {{ f.count }} {{ f.avg }}%
{% endif %}
{# ── Recent activity ─────────────────────────────────────────────────────── #}
Recent Activity
{% if recent_inspections %}
{% if current_user.role != 'inspector' %}{% endif %} {% for insp in recent_inspections %} {% if current_user.role != 'inspector' %}{% endif %} {% endfor %}
Date Facility AreaInspectorScore Status
{{ insp.inspection_date.strftime('%Y-%m-%d %H:%M') }} {{ insp.facility.name }} {{ insp.area.name if insp.area else '—' }}{{ insp.inspector.username }} {% if insp.overall_score %} {{ insp.overall_score }}% {% else %} {% endif %} {{ insp.status|title }}
{% else %}
No recent inspections.
{% endif %}
{% if trend_labels %} {% endif %} {% endblock %}