06/12 Redesign Reports page
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<ul class="nav nav-pills mb-4 flex-wrap gap-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {{ 'active' if request.endpoint == 'reports.index' else '' }}"
|
||||
href="{{ url_for('reports.index') }}">
|
||||
<i class="bi bi-bar-chart me-1"></i>Overview & Trends
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {{ 'active' if request.endpoint == 'reports.issues_aging' else '' }}"
|
||||
href="{{ url_for('reports.issues_aging') }}">
|
||||
<i class="bi bi-clock-history me-1"></i>Issues Aging
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {{ 'active' if request.endpoint == 'reports.sla_compliance' else '' }}"
|
||||
href="{{ url_for('reports.sla_compliance') }}">
|
||||
<i class="bi bi-shield-check me-1"></i>SLA Compliance
|
||||
</a>
|
||||
</li>
|
||||
{% if current_user.role in ['admin', 'director', 'project_manager'] %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {{ 'active' if request.endpoint == 'reports.followup_closure' else '' }}"
|
||||
href="{{ url_for('reports.followup_closure') }}">
|
||||
<i class="bi bi-arrow-repeat me-1"></i>Follow-up Closure
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if current_user.role in ['admin', 'director'] %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {{ 'active' if request.endpoint == 'reports.inspector_performance' else '' }}"
|
||||
href="{{ url_for('reports.inspector_performance') }}">
|
||||
<i class="bi bi-person-lines-fill me-1"></i>Inspector Performance
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
@@ -0,0 +1,186 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Follow-up Closure Rate{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{# ── Sub-nav ── #}
|
||||
{% include 'reports/_subnav.html' %}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-start mb-4">
|
||||
<div>
|
||||
<h2><i class="bi bi-arrow-repeat text-purple me-2" style="color:#7c3aed;"></i>Follow-up Closure Rate</h2>
|
||||
<p class="text-muted mb-0">
|
||||
{{ start.strftime('%b %d, %Y') }} — {{ end.strftime('%b %d, %Y') }}
|
||||
· Inspections flagged for follow-up and whether a re-inspection was completed.
|
||||
</p>
|
||||
</div>
|
||||
<a href="{{ url_for('reports.export_followup_closure', start=start.strftime('%Y-%m-%d'), end=end.strftime('%Y-%m-%d')) }}"
|
||||
class="btn btn-sm btn-outline-success">
|
||||
<i class="bi bi-file-earmark-excel me-1"></i>Export Excel
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{# ── Date filter ── #}
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-body py-2">
|
||||
<form method="get" class="row g-2 align-items-end">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small mb-1">From</label>
|
||||
<input type="date" name="start" class="form-control form-control-sm" value="{{ start.strftime('%Y-%m-%d') }}">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small mb-1">To</label>
|
||||
<input type="date" name="end" class="form-control form-control-sm" value="{{ end.strftime('%Y-%m-%d') }}">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button class="btn btn-sm btn-primary">Apply</button>
|
||||
<a href="{{ url_for('reports.followup_closure') }}" class="btn btn-sm btn-outline-secondary">Reset</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ── KPI row ── #}
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-6 col-md-4">
|
||||
<div class="card shadow-sm h-100" style="border-left:5px solid #7c3aed;">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small fw-semibold mb-1">Flagged for Follow-up</div>
|
||||
<div class="fs-1 fw-bold" style="color:#7c3aed;">{{ total }}</div>
|
||||
<div class="text-muted small">inspections in period</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-4">
|
||||
<div class="card shadow-sm h-100" style="border-left:5px solid #16a34a;">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small fw-semibold mb-1">Re-inspected</div>
|
||||
<div class="fs-1 fw-bold text-success">{{ closed }}</div>
|
||||
<div class="text-muted small">follow-up completed</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-4">
|
||||
<div class="card shadow-sm h-100"
|
||||
style="border-left:5px solid {{ '#16a34a' if rate and rate >= 80 else '#d97706' if rate and rate >= 50 else '#dc2626' }};">
|
||||
<div class="card-body">
|
||||
<div class="text-muted small fw-semibold mb-1">Closure Rate</div>
|
||||
<div class="fs-1 fw-bold
|
||||
{{ 'text-success' if rate and rate >= 80 else 'text-warning' if rate and rate >= 50 else 'text-danger' if rate is not none else 'text-muted' }}">
|
||||
{{ rate|round(1) if rate is not none else '—' }}{% if rate is not none %}%{% endif %}
|
||||
</div>
|
||||
<div class="text-muted small">of flagged inspections re-done</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if total == 0 %}
|
||||
<div class="alert alert-info">
|
||||
<i class="bi bi-info-circle me-2"></i>No inspections were flagged for follow-up in this period.
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
{# ── By facility ── #}
|
||||
{% if by_facility %}
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header bg-light fw-semibold">
|
||||
<i class="bi bi-building me-1"></i>Closure Rate by Facility
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Facility</th>
|
||||
<th class="text-center">Flagged</th>
|
||||
<th class="text-center">Re-inspected</th>
|
||||
<th class="text-center">Closure Rate</th>
|
||||
<th>Progress</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in by_facility %}
|
||||
<tr>
|
||||
<td class="fw-semibold">{{ row.name }}</td>
|
||||
<td class="text-center">{{ row.total }}</td>
|
||||
<td class="text-center">{{ row.closed }}</td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-{{ 'success' if row.rate >= 80 else 'warning text-dark' if row.rate >= 50 else 'danger' }} px-3">
|
||||
{{ row.rate }}%
|
||||
</span>
|
||||
</td>
|
||||
<td style="min-width:120px;">
|
||||
<div class="progress" style="height:8px;">
|
||||
<div class="progress-bar bg-{{ 'success' if row.rate >= 80 else 'warning' if row.rate >= 50 else 'danger' }}"
|
||||
style="width:{{ row.rate }}%;"></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# ── Detail table ── #}
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-light d-flex justify-content-between">
|
||||
<span class="fw-semibold"><i class="bi bi-list-ul me-1"></i>Inspection Detail</span>
|
||||
<span class="text-muted small">{{ total }} flagged</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-sm mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Date</th>
|
||||
<th>Facility</th>
|
||||
<th>Template</th>
|
||||
<th>Inspector</th>
|
||||
<th class="text-center">Score</th>
|
||||
<th>Note</th>
|
||||
<th class="text-center">Re-inspected?</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for insp in flagged %}
|
||||
<tr class="{{ '' if insp._has_followup else 'table-warning' }}">
|
||||
<td class="text-muted small">#{{ insp.id }}</td>
|
||||
<td class="small">{{ insp.inspection_date.strftime('%Y-%m-%d') if insp.inspection_date else '—' }}</td>
|
||||
<td class="small">{{ insp.facility.name if insp.facility else '—' }}</td>
|
||||
<td class="small">{{ insp.template.name if insp.template else '—' }}</td>
|
||||
<td class="small">{{ insp.inspector.display_name if insp.inspector else '—' }}</td>
|
||||
<td class="text-center">
|
||||
{% if insp.overall_score %}
|
||||
<span class="badge bg-{{ 'success' if insp.overall_score >= 80 else 'warning text-dark' if insp.overall_score >= 60 else 'danger' }}">
|
||||
{{ insp.overall_score|round(1) }}%
|
||||
</span>
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
<td class="small text-muted">
|
||||
{{ insp.follow_up_note[:60] if insp.follow_up_note else '—' }}
|
||||
{% if insp.follow_up_note and insp.follow_up_note|length > 60 %}…{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{% if insp._has_followup %}
|
||||
<span class="badge bg-success"><i class="bi bi-check-circle me-1"></i>Yes</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger"><i class="bi bi-x-circle me-1"></i>No</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ url_for('inspections.view', inspection_id=insp.id) }}"
|
||||
class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-eye"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endif %}{# end total == 0 #}
|
||||
{% endblock %}
|
||||
@@ -13,20 +13,7 @@
|
||||
{% block content %}
|
||||
|
||||
{# ── Sub-nav ── #}
|
||||
<ul class="nav nav-pills mb-4">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="{{ url_for('reports.index') }}">
|
||||
<i class="bi bi-bar-chart me-1"></i>Overview
|
||||
</a>
|
||||
</li>
|
||||
{% if current_user.role in ['admin', 'director'] %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('reports.inspector_performance') }}">
|
||||
<i class="bi bi-person-lines-fill me-1"></i>Inspector Performance
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% include 'reports/_subnav.html' %}
|
||||
|
||||
{# ── Header + date filter ── #}
|
||||
<div class="d-flex justify-content-between align-items-start mb-4">
|
||||
|
||||
@@ -16,18 +16,7 @@
|
||||
{% block content %}
|
||||
|
||||
{# ── Sub-nav ── #}
|
||||
<ul class="nav nav-pills mb-4">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ url_for('reports.index', start=start.strftime('%Y-%m-%d'), end=end.strftime('%Y-%m-%d')) }}">
|
||||
<i class="bi bi-bar-chart me-1"></i>Overview
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="{{ url_for('reports.inspector_performance', start=start.strftime('%Y-%m-%d'), end=end.strftime('%Y-%m-%d')) }}">
|
||||
<i class="bi bi-person-lines-fill me-1"></i>Inspector Performance
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% include 'reports/_subnav.html' %}
|
||||
|
||||
{# ── Header ── #}
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Issues Aging{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{# ── Sub-nav ── #}
|
||||
{% include 'reports/_subnav.html' %}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-start mb-4">
|
||||
<div>
|
||||
<h2><i class="bi bi-clock-history text-danger me-2"></i>Issues Aging</h2>
|
||||
<p class="text-muted mb-0">All currently open issues grouped by how long they have been waiting.</p>
|
||||
</div>
|
||||
<a href="{{ url_for('reports.export_issues_aging', severity=severity_filter, facility_id=facility_id_filter or '') }}"
|
||||
class="btn btn-sm btn-outline-success">
|
||||
<i class="bi bi-file-earmark-excel me-1"></i>Export Excel
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{# ── Filters ── #}
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-body py-2">
|
||||
<form method="get" class="row g-2 align-items-end">
|
||||
<div class="col-md-2">
|
||||
<label class="form-label small mb-1">Severity</label>
|
||||
<select name="severity" class="form-select form-select-sm">
|
||||
<option value="">All</option>
|
||||
{% for s in ['critical','high','medium','low'] %}
|
||||
<option value="{{ s }}" {{ 'selected' if severity_filter == s }}>{{ s|title }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small mb-1">Facility</label>
|
||||
<select name="facility_id" class="form-select form-select-sm">
|
||||
<option value="">All Facilities</option>
|
||||
{% for f in facilities %}
|
||||
<option value="{{ f.id }}" {{ 'selected' if facility_id_filter == f.id }}>{{ f.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button class="btn btn-sm btn-primary">Apply</button>
|
||||
<a href="{{ url_for('reports.issues_aging') }}" class="btn btn-sm btn-outline-secondary">Clear</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ── KPI row ── #}
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-6 col-md-4">
|
||||
<div class="card shadow-sm border-0 h-100" style="background:#fff7ed;">
|
||||
<div class="card-body">
|
||||
<div class="small fw-semibold text-muted mb-1">Total Open</div>
|
||||
<div class="fs-1 fw-bold" style="color:#ea580c;">{{ total }}</div>
|
||||
<div class="small text-muted">unresolved issues</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-4">
|
||||
<div class="card shadow-sm border-0 h-100" style="background:#fef2f2;">
|
||||
<div class="card-body">
|
||||
<div class="small fw-semibold text-muted mb-1">SLA Breached</div>
|
||||
<div class="fs-1 fw-bold text-danger">{{ sla_breached }}</div>
|
||||
<div class="small text-muted">past resolution deadline</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-4">
|
||||
<div class="card shadow-sm border-0 h-100" style="background:#fefce8;">
|
||||
<div class="card-body">
|
||||
<div class="small fw-semibold text-muted mb-1">SLA At Risk</div>
|
||||
<div class="fs-1 fw-bold text-warning">{{ sla_at_risk }}</div>
|
||||
<div class="small text-muted">approaching deadline</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ── Bucket accordions ── #}
|
||||
<div class="accordion" id="agingAccordion">
|
||||
{% for label in bucket_labels %}
|
||||
{% set bucket = buckets[label] %}
|
||||
{% set bucket_id = 'bucket-' ~ loop.index %}
|
||||
{% set is_danger = label in ['>4 weeks', '1–4 weeks'] %}
|
||||
{% set is_warning = label == '3–7 days' %}
|
||||
<div class="accordion-item mb-2 shadow-sm border-0">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button {{ 'collapsed' if loop.index > 1 else '' }} fw-semibold"
|
||||
type="button" data-bs-toggle="collapse"
|
||||
data-bs-target="#{{ bucket_id }}">
|
||||
<span class="badge rounded-pill me-2
|
||||
{{ 'bg-danger' if is_danger else 'bg-warning text-dark' if is_warning else 'bg-secondary' }}">
|
||||
{{ bucket|length }}
|
||||
</span>
|
||||
{{ label }}
|
||||
{% if is_danger and bucket|length > 0 %}
|
||||
<span class="ms-2 badge bg-danger bg-opacity-25 text-danger" style="font-size:.7rem;">Needs attention</span>
|
||||
{% endif %}
|
||||
</button>
|
||||
</h2>
|
||||
<div id="{{ bucket_id }}" class="accordion-collapse collapse {{ 'show' if loop.index == 1 else '' }}"
|
||||
data-bs-parent="#agingAccordion">
|
||||
<div class="accordion-body p-0">
|
||||
{% if bucket %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-sm mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Age</th>
|
||||
<th>Severity</th>
|
||||
<th>Facility / Area</th>
|
||||
<th>Description</th>
|
||||
<th>Status</th>
|
||||
<th>SLA</th>
|
||||
<th>Assigned</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in bucket %}
|
||||
{% set issue = item.issue %}
|
||||
{% set sla = item.sla %}
|
||||
<tr class="{{ 'table-danger' if sla == 'breached' else 'table-warning' if sla == 'at_risk' else '' }}">
|
||||
<td class="text-muted small">#{{ issue.id }}</td>
|
||||
<td class="text-nowrap small">{{ item.age_h }}h</td>
|
||||
<td>
|
||||
<span class="badge bg-{{ 'danger' if issue.severity in ['critical','high'] else 'warning text-dark' if issue.severity == 'medium' else 'secondary' }}">
|
||||
{{ issue.severity|title }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="small">
|
||||
{{ issue.resolved_facility.name if issue.resolved_facility else '—' }}<br>
|
||||
<span class="text-muted">{{ issue.area.name if issue.area else '—' }}</span>
|
||||
</td>
|
||||
<td class="small">{{ issue.description[:70] }}{% if issue.description|length > 70 %}…{% endif %}</td>
|
||||
<td>
|
||||
<span class="badge bg-{{ 'info text-dark' if issue.status == 'pending_verification' else 'warning text-dark' if issue.status == 'in_progress' else 'secondary' }}">
|
||||
{{ issue.status|replace('_',' ')|title }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if sla == 'breached' %}<span class="badge bg-danger"><i class="bi bi-alarm me-1"></i>Breached</span>
|
||||
{% elif sla == 'at_risk' %}<span class="badge bg-warning text-dark">At Risk</span>
|
||||
{% elif sla == 'ok' %}<span class="badge bg-secondary">OK</span>
|
||||
{% else %}<span class="text-muted small">—</span>{% endif %}
|
||||
</td>
|
||||
<td class="small">{{ issue.assigned_user.display_name if issue.assigned_user else '—' }}</td>
|
||||
<td>
|
||||
<a href="{{ url_for('issues.view', issue_id=issue.id) }}" class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-eye"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="p-3 text-muted small">No issues in this age range.</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if total == 0 %}
|
||||
<div class="alert alert-success mt-3">
|
||||
<i class="bi bi-check-circle me-2"></i>No open issues match the selected filters.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -29,6 +29,10 @@
|
||||
class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-file-text"></i> Full Report
|
||||
</a>
|
||||
<a href="{{ url_for('reports.facility_summary_pdf', facility_id=facility.id, days=days) }}"
|
||||
class="btn btn-sm btn-outline-danger" title="Download customer-facing PDF summary">
|
||||
<i class="bi bi-file-earmark-pdf"></i> PDF Summary
|
||||
</a>
|
||||
<a href="{{ url_for('reports.index') }}" class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left"></i> Reports
|
||||
</a>
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}SLA Compliance{% endblock %}
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
.compliance-ring { position:relative; display:inline-flex; align-items:center; justify-content:center; width:120px; height:120px; }
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
{# ── Sub-nav ── #}
|
||||
{% include 'reports/_subnav.html' %}
|
||||
|
||||
<div class="d-flex justify-content-between align-items-start mb-4">
|
||||
<div>
|
||||
<h2><i class="bi bi-shield-check text-success me-2"></i>SLA Compliance</h2>
|
||||
<p class="text-muted mb-0">{{ start.strftime('%b %d, %Y') }} — {{ end.strftime('%b %d, %Y') }}</p>
|
||||
</div>
|
||||
<a href="{{ url_for('reports.export_sla_compliance', start=start.strftime('%Y-%m-%d'), end=end.strftime('%Y-%m-%d'), facility_id=facility_id_filter or '') }}"
|
||||
class="btn btn-sm btn-outline-success">
|
||||
<i class="bi bi-file-earmark-excel me-1"></i>Export Excel
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{# ── Filters ── #}
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-body py-2">
|
||||
<form method="get" class="row g-2 align-items-end">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small mb-1">From</label>
|
||||
<input type="date" name="start" class="form-control form-control-sm" value="{{ start.strftime('%Y-%m-%d') }}">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small mb-1">To</label>
|
||||
<input type="date" name="end" class="form-control form-control-sm" value="{{ end.strftime('%Y-%m-%d') }}">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small mb-1">Facility</label>
|
||||
<select name="facility_id" class="form-select form-select-sm">
|
||||
<option value="">All Facilities</option>
|
||||
{% for f in facilities %}
|
||||
<option value="{{ f.id }}" {{ 'selected' if facility_id_filter == f.id }}>{{ f.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<button class="btn btn-sm btn-primary">Apply</button>
|
||||
<a href="{{ url_for('reports.sla_compliance') }}" class="btn btn-sm btn-outline-secondary">Reset</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if total == 0 %}
|
||||
<div class="alert alert-info">
|
||||
<i class="bi bi-info-circle me-2"></i>No resolved issues found for this period and filter.
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
{# ── Overall KPI ── #}
|
||||
<div class="row g-3 mb-4 align-items-stretch">
|
||||
<div class="col-md-3">
|
||||
<div class="card shadow-sm h-100 text-center"
|
||||
style="border-left:6px solid {{ '#16a34a' if overall_pct and overall_pct >= 90 else '#d97706' if overall_pct and overall_pct >= 70 else '#dc2626' }};">
|
||||
<div class="card-body d-flex flex-column align-items-center justify-content-center py-4">
|
||||
<div class="text-muted small fw-semibold mb-1">Overall Compliance</div>
|
||||
<div class="display-4 fw-bold
|
||||
{{ 'text-success' if overall_pct and overall_pct >= 90 else 'text-warning' if overall_pct and overall_pct >= 70 else 'text-danger' }}">
|
||||
{{ overall_pct|round(1) if overall_pct is not none else '—' }}{% if overall_pct is not none %}%{% endif %}
|
||||
</div>
|
||||
<div class="text-muted small mt-1">{{ met }}/{{ total }} resolved on time</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ── Per-severity compliance cards ── #}
|
||||
{% for sev, color_cls in [('critical','danger'),('high','danger'),('medium','warning'),('low','secondary')] %}
|
||||
{% set d = by_severity[sev] %}
|
||||
<div class="col-6 col-md">
|
||||
<div class="card shadow-sm h-100">
|
||||
<div class="card-body text-center">
|
||||
<div class="mb-1"><span class="badge bg-{{ color_cls }} {{ 'text-dark' if color_cls == 'warning' else '' }} px-2">
|
||||
{{ sev|title }}
|
||||
</span></div>
|
||||
<div class="small text-muted mb-1">SLA: {{ d.sla_hours }}h window</div>
|
||||
<div class="fs-3 fw-bold
|
||||
{{ 'text-success' if d.pct and d.pct >= 90 else 'text-warning' if d.pct and d.pct >= 70 else 'text-danger' if d.pct is not none else 'text-muted' }}">
|
||||
{{ d.pct|round(1) if d.pct is not none else '—' }}{% if d.pct is not none %}%{% endif %}
|
||||
</div>
|
||||
<div class="small text-muted">{{ d.met }}/{{ d.total }}</div>
|
||||
{% if d.total > 0 %}
|
||||
<div class="progress mt-2" style="height:4px;">
|
||||
<div class="progress-bar bg-{{ 'success' if d.pct and d.pct >= 90 else 'warning' if d.pct and d.pct >= 70 else 'danger' }}"
|
||||
style="width:{{ d.pct or 0 }}%;"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{# ── Facility breakdown ── #}
|
||||
{% if by_facility %}
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-light fw-semibold">
|
||||
<i class="bi bi-building me-1"></i>Compliance by Facility
|
||||
<span class="badge bg-secondary ms-1">{{ by_facility|length }}</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>Facility</th>
|
||||
<th class="text-center">Resolved Issues</th>
|
||||
<th class="text-center">Met SLA</th>
|
||||
<th class="text-center">Compliance %</th>
|
||||
<th>Progress</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in by_facility %}
|
||||
{% set pct_val = row.pct or 0 %}
|
||||
{% set bar_class = 'bg-success' if pct_val >= 90 else 'bg-warning' if pct_val >= 70 else 'bg-danger' %}
|
||||
<tr>
|
||||
<td class="fw-semibold">{{ row.name }}</td>
|
||||
<td class="text-center">{{ row.total }}</td>
|
||||
<td class="text-center">{{ row.met }}</td>
|
||||
<td class="text-center">
|
||||
{% if row.pct is not none %}
|
||||
<span class="badge bg-{{ 'success' if row.pct >= 90 else 'warning text-dark' if row.pct >= 70 else 'danger' }} px-3">
|
||||
{{ row.pct }}%
|
||||
</span>
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
<td style="min-width:120px;">
|
||||
<div class="progress" style="height:8px;">
|
||||
<div class="progress-bar {{ bar_class }}" style="width:{{ row.pct or 0 }}%;"></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}{# end total == 0 #}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user