{% extends "base.html" %} {% block title %}Dashboard{% endblock %} {# MODERN dashboard (design A/B test — slide 1 of JQC_design). Uses exactly the same context variables as templates/dashboard.html — the dashboard.index route is untouched. Every tile links to the same filtered list view the classic dashboard links to, so no navigation path is lost. #} {% block content %} {# ── Header ───────────────────────────────────────────────────────────── #}
Welcome, {{ current_user.display_name }}
{{ current_user.role.replace('_',' ')|title }}
{{ now_display }}
{# ── Scheduled inspections ────────────────────────────────────────────── #} {% if current_user.role != 'customer' %}
Scheduled Inspection In Progress
View all
{% if sched_overdue_count %}
{{ sched_overdue_count }} scheduled inspection{{ 's' if sched_overdue_count != 1 }} {{ 'are' if sched_overdue_count != 1 else 'is' }} overdue.
{% endif %} {% if sched_upcoming %}
{% for s in sched_upcoming %} {# MT's column is next_run_at (ST calls it next_due_date) — via the due_date property, guarded: an active schedule can carry a NULL next_run_at, and .strftime() on Undefined/None is a 500. #} {% endfor %}
FacilityInspection TemplateInspector How OftenNext Due Date
{{ s.facility.name if s.facility else '—' }} {{ s.template.name if s.template else '—' }} {{ s.inspector.display_name if s.inspector else '—' }} {{ s.recurrence_label }}{{ s.due_date.strftime('%b %d, %Y') if s.due_date else '—' }} {% if s.inspector_id and s.inspector_id == current_user.id %} {% if s.is_acknowledged %} Confirmed {% else %}
{% endif %} {% set open_id = sched_open_inspections.get(s.id) %} {% if open_id %} Continue {% else %} Start {% endif %} {% endif %}
{% else %}
No inspections due in the next 7 days.
{% endif %}
{% endif %} {# ── KPI row ──────────────────────────────────────────────────────────── #}
{{ completed_today }}
Submitted Today
{{ submitted_this_week }}
Submitted This Week
{{ open_issues }}
Open Issues
{% if current_user.role != 'customer' %}
{{ sched_total }}
On Schedules
{% else %}
{{ customer_facilities|length if customer_facilities else 0 }}
Your Facilities
{% endif %}
{# ── Three summary cards ──────────────────────────────────────────────── #}
{# ── Recent activity ──────────────────────────────────────────────────── #}
Recent Activities
View all
{% if recent_inspections %}
{% if not current_user.is_inspector %}{% endif %} {% for insp in recent_inspections %} {# The row stays click-anywhere for the mouse, but the date is a real link so the row is keyboard-reachable and openable in a new tab. The guard stops the row handler from double-firing on that link. #} {% if not current_user.is_inspector %}{% endif %} {% endfor %}
Date Facility Name AreaInspectorScore Status
{{ insp.inspection_date.strftime('%b %d, %Y') }} {{ insp.facility.name }} {{ insp.area.name if insp.area else '—' }}{{ insp.inspector.display_name }} {% if insp.overall_score %} {{ insp.overall_score }}% {% else %} {% endif %} {{ 'Submitted' if insp.status == 'completed' else insp.status|title }}
{% else %}
No recent inspections.
{% endif %}
{# ── My open issues (inspector widget) ────────────────────────────────── #} {% if my_issues %}
My Open Issues
View all
{% for issue in my_issues %} {% set sla = sla_status(issue) %} {% endfor %}
ID Severity Facility / Description Status SLA
#{{ issue.id }} {{ issue.severity|title }}
{{ issue.resolved_facility.name if issue.resolved_facility else '—' }}
{{ issue.description[:60] }}{% if issue.description|length > 60 %}…{% endif %}
{{ issue.status|replace('_',' ')|title }} {% if sla == 'breached' %} Breached {% elif sla == 'at_risk' %} {{ sla_hours_remaining(issue)|abs|round(1) }}h left {% else %} OK {% endif %}
{% endif %} {# ── Customer portal: scoped facilities panel ─────────────────────────── #} {% if current_user.role == 'customer' and customer_facilities %}
Your Facilities {{ customer_facilities|length }}
{% if customer_facilities|length > 6 %}
{% endif %}
{% for f in customer_facilities %}
{{ f.name }}
{{ f.address or '—' }}
{{ f.project.name if f.project else '—' }}
{% endfor %}
{% if customer_facilities|length > 9 %}
{% endif %}
{# Same VISIBLE = 9 / search > 6 thresholds as the classic dashboard (rule 65). #} {% endif %} {% endblock %}