466 lines
23 KiB
HTML
466 lines
23 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
|
<!-- iOS / iPadOS web app meta tags -->
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
<meta name="mobile-web-app-capable" content="yes">
|
|
<title>{% block title %}Janitorial QC System{% endblock %}</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/theme.css') }}">
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/ipad_responsive.css') }}">
|
|
{# theme_modern.css loads LAST so it wins over theme.css tokens #}
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/theme_modern.css') }}">
|
|
{% block extra_css %}{% endblock %}
|
|
<style>
|
|
/* ── Notification bell styles (shared with the classic layout) ── */
|
|
.notif-bell-wrapper { position: relative; }
|
|
.notif-badge {
|
|
position: absolute;
|
|
top: 2px; right: 2px;
|
|
font-size: 0.6rem;
|
|
min-width: 16px; height: 16px; line-height: 16px;
|
|
padding: 0 4px; border-radius: 8px;
|
|
pointer-events: none;
|
|
}
|
|
.notif-dropdown {
|
|
width: 380px;
|
|
max-height: 520px;
|
|
overflow-y: auto;
|
|
padding: 0;
|
|
}
|
|
.notif-item {
|
|
border-left: 3px solid transparent;
|
|
transition: background 0.15s;
|
|
cursor: pointer;
|
|
}
|
|
.notif-item.unread {
|
|
border-left-color: var(--jqc-brand);
|
|
background-color: #f0f6fa;
|
|
}
|
|
.notif-item:hover { background-color: #e9f0f8; }
|
|
.notif-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; }
|
|
.notif-body { font-size: 0.78rem; color: #555; white-space: normal; }
|
|
.notif-time { font-size: 0.7rem; color: #999; }
|
|
.notif-empty { padding: 24px; text-align: center; color: #aaa; font-size: 0.85rem; }
|
|
|
|
/* ── Shared list-page filter panel (modern tint) ── */
|
|
.filter-panel {
|
|
background: #ffffff;
|
|
border: 1px solid var(--jqc-border);
|
|
border-left: 4px solid var(--jqc-brand);
|
|
border-radius: 14px;
|
|
}
|
|
.filter-panel .filter-title {
|
|
font-weight: 700;
|
|
font-size: .82rem;
|
|
letter-spacing: .03em;
|
|
text-transform: uppercase;
|
|
color: var(--jqc-brand);
|
|
}
|
|
.filter-panel .form-label {
|
|
font-weight: 600;
|
|
color: #3f4652;
|
|
}
|
|
.filter-panel .form-control,
|
|
.filter-panel .form-select {
|
|
border: 1.5px solid #cfd9e0;
|
|
background-color: #ffffff;
|
|
}
|
|
.filter-panel .form-control:focus,
|
|
.filter-panel .form-select:focus {
|
|
border-color: var(--jqc-brand);
|
|
box-shadow: 0 0 0 .18rem rgba(21, 95, 130, .20);
|
|
}
|
|
.filter-panel .form-control::placeholder { color: #9aa4b2; }
|
|
</style>
|
|
</head>
|
|
<body class="jqc-modern">
|
|
{% if current_user.is_authenticated %}
|
|
|
|
<!-- ══════════════════════════ TOP BAR ══════════════════════════ -->
|
|
<header class="jqc-topbar">
|
|
<button class="jqc-hamburger d-lg-none" type="button" id="jqcSidebarToggle" aria-label="Menu">
|
|
<i class="bi bi-list"></i>
|
|
</button>
|
|
|
|
<a class="jqc-brand" href="{{ url_for('dashboard.index') }}">
|
|
<span class="jqc-brand-mark">JQC</span>
|
|
<span class="jqc-brand-sub">By L.T. Services, Inc</span>
|
|
</a>
|
|
|
|
{# Scoped to inspection ID only — the placeholder says so explicitly so
|
|
nobody types a facility name and assumes the search is broken. #}
|
|
<form class="jqc-search" method="GET" action="{{ url_for('inspections.index') }}" role="search">
|
|
<i class="bi bi-search"></i>
|
|
<input type="search" name="inspection_id" class="form-control" inputmode="numeric"
|
|
placeholder="Inspection # (e.g. 1423)" aria-label="Search by inspection number"
|
|
title="Search by inspection number">
|
|
</form>
|
|
|
|
<div class="jqc-topbar-actions">
|
|
<!-- ── Notification Bell ── -->
|
|
<div class="dropdown">
|
|
<a class="jqc-icon-btn position-relative notif-bell-wrapper"
|
|
href="#"
|
|
id="notifDropdown"
|
|
role="button"
|
|
data-bs-toggle="dropdown"
|
|
aria-expanded="false"
|
|
title="Notifications">
|
|
<i class="bi bi-bell"></i>
|
|
{% if unread_notification_count > 0 %}
|
|
<span class="badge bg-danger notif-badge" id="notif-count-badge">
|
|
{{ unread_notification_count if unread_notification_count <= 99 else '99+' }}
|
|
</span>
|
|
{% else %}
|
|
<span class="badge bg-danger notif-badge d-none" id="notif-count-badge"></span>
|
|
{% endif %}
|
|
</a>
|
|
<div class="dropdown-menu dropdown-menu-end notif-dropdown shadow" id="notif-dropdown-menu">
|
|
<div class="d-flex justify-content-between align-items-center px-3 py-2 border-bottom">
|
|
<span class="fw-semibold" style="font-size:.9rem;">Notifications</span>
|
|
<button class="btn btn-link btn-sm p-0 text-muted text-decoration-none"
|
|
id="mark-all-read-btn" style="font-size:.75rem;">
|
|
Mark all as read
|
|
</button>
|
|
</div>
|
|
<div id="notif-list">
|
|
<div class="notif-empty">Loading…</div>
|
|
</div>
|
|
<div class="border-top d-flex justify-content-between px-3 py-2" style="font-size:.8rem;">
|
|
<a href="{{ url_for('notifications.index') }}" class="text-decoration-none">
|
|
<i class="bi bi-list-ul me-1"></i>View all
|
|
</a>
|
|
<a href="{{ url_for('notifications.preferences') }}" class="text-decoration-none text-muted">
|
|
<i class="bi bi-gear me-1"></i>Preferences
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ── User avatar menu ── -->
|
|
<div class="dropdown">
|
|
<a class="jqc-avatar" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown"
|
|
title="{{ current_user.display_name }}">
|
|
{{ (current_user.display_name.split() | map('first') | join)[:2] | upper }}
|
|
</a>
|
|
<ul class="dropdown-menu dropdown-menu-end">
|
|
<li class="px-3 py-2 border-bottom">
|
|
<div class="fw-semibold" style="font-size:.9rem;">{{ current_user.display_name }}</div>
|
|
<div class="text-muted" style="font-size:.75rem;">{{ current_user.role.replace('_',' ')|title }}</div>
|
|
</li>
|
|
<li>
|
|
<a class="dropdown-item" href="{{ url_for('auth.profile') }}">
|
|
<i class="bi bi-person-circle me-1"></i>My Profile
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a class="dropdown-item" href="{{ url_for('notifications.preferences') }}">
|
|
<i class="bi bi-bell-slash me-1"></i>Notification Preferences
|
|
</a>
|
|
</li>
|
|
{# The design A/B test is over — modern is THE design (Aug 2026).
|
|
The switcher and the vote tally are gone from this menu.
|
|
ui.switch_theme / ui.theme_votes still exist and still work
|
|
if visited directly, so nothing is stranded mid-request;
|
|
they are simply no longer offered. #}
|
|
<li><hr class="dropdown-divider"></li>
|
|
<li>
|
|
<a class="dropdown-item" href="{{ url_for('auth.logout') }}">
|
|
<i class="bi bi-box-arrow-right me-1"></i>Logout
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- ══════════════════════════ SIDEBAR ══════════════════════════ -->
|
|
<aside class="jqc-sidebar" id="jqcSidebar">
|
|
<nav class="jqc-nav">
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint and request.endpoint.startswith('dashboard.') }}"
|
|
href="{{ url_for('dashboard.index') }}">
|
|
<i class="bi bi-grid"></i><span>Dashboard</span>
|
|
</a>
|
|
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint and (request.endpoint.startswith('inspections.') or request.endpoint.startswith('scheduled_inspections.')) }}"
|
|
href="{{ url_for('inspections.index') }}">
|
|
<i class="bi bi-clipboard-check"></i><span>Inspections</span>
|
|
</a>
|
|
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint and (request.endpoint.startswith('reports.') or request.endpoint.startswith('scheduled_reports.')) }}"
|
|
href="{{ url_for('reports.index') }}">
|
|
<i class="bi bi-bar-chart-fill"></i><span>Reports & Analytics</span>
|
|
</a>
|
|
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint and request.endpoint.startswith('issues.') and request.endpoint != 'issues.verification_queue' }}"
|
|
href="{{ url_for('issues.index') }}">
|
|
<i class="bi bi-exclamation-triangle"></i><span>Issues</span>
|
|
</a>
|
|
|
|
{% if current_user.role in ['admin', 'director', 'auditor'] %}
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint == 'issues.verification_queue' }}"
|
|
href="{{ url_for('issues.verification_queue') }}">
|
|
<i class="bi bi-patch-check"></i><span>Verify</span>
|
|
{% if pending_verification_count and pending_verification_count > 0 %}
|
|
<span class="jqc-nav-badge">{{ pending_verification_count }}</span>
|
|
{% endif %}
|
|
</a>
|
|
{% endif %}
|
|
|
|
{% if current_user.role in ['admin', 'director', 'project_manager', 'auditor'] %}
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint and request.endpoint.startswith('projects.') }}"
|
|
href="{{ url_for('projects.index') }}">
|
|
<i class="bi bi-file-earmark-text"></i><span>Contract</span>
|
|
</a>
|
|
{% endif %}
|
|
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint and request.endpoint.startswith('facilities.') }}"
|
|
href="{{ url_for('facilities.list_facilities') }}">
|
|
<i class="bi bi-buildings"></i><span>Facility</span>
|
|
</a>
|
|
|
|
{% if current_user.role in ['admin', 'director'] %}
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint and request.endpoint.startswith('templates.') }}"
|
|
href="{{ url_for('templates.index') }}">
|
|
<i class="bi bi-list-check"></i><span>Templates</span>
|
|
</a>
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint and request.endpoint.startswith('customers.') }}"
|
|
href="{{ url_for('customers.index') }}">
|
|
<i class="bi bi-people"></i><span>Customer</span>
|
|
</a>
|
|
{% endif %}
|
|
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint and (request.endpoint.startswith('support.') or request.endpoint == 'ui.support_center') }}"
|
|
href="{{ url_for('ui.support_center') }}">
|
|
<i class="bi bi-life-preserver"></i><span>Supports</span>
|
|
{% if open_support_tickets_count > 0 %}
|
|
<span class="jqc-nav-badge">{{ open_support_tickets_count }}</span>
|
|
{% endif %}
|
|
</a>
|
|
|
|
{% if current_user.role == 'admin' %}
|
|
{% set admin_active = request.endpoint and (
|
|
request.endpoint.startswith('audit.')
|
|
or request.endpoint == 'auth.notification_matrix'
|
|
or request.endpoint.startswith('broadcast.')
|
|
or request.endpoint.startswith('devices.')
|
|
or request.endpoint.startswith('enrollment.')
|
|
or (request.endpoint.startswith('auth.') and 'user' in request.endpoint)
|
|
) %}
|
|
<a class="jqc-nav-link {{ 'active' if admin_active }}" data-bs-toggle="collapse"
|
|
href="#jqcAdminMenu" role="button" aria-expanded="{{ 'true' if admin_active else 'false' }}">
|
|
<i class="bi bi-shield-lock"></i><span>Admin</span>
|
|
<i class="bi bi-chevron-down jqc-nav-caret"></i>
|
|
</a>
|
|
<div class="collapse {{ 'show' if admin_active }}" id="jqcAdminMenu">
|
|
<a class="jqc-nav-sublink {{ 'active' if request.endpoint and request.endpoint.startswith('auth.') and 'user' in request.endpoint }}"
|
|
href="{{ url_for('auth.list_users') }}">Users</a>
|
|
<a class="jqc-nav-sublink {{ 'active' if request.endpoint and request.endpoint.startswith('audit.') }}"
|
|
href="{{ url_for('audit.index') }}">Audit Trail</a>
|
|
<a class="jqc-nav-sublink {{ 'active' if request.endpoint == 'auth.notification_matrix' }}"
|
|
href="{{ url_for('auth.notification_matrix') }}">Notification Matrix</a>
|
|
<a class="jqc-nav-sublink {{ 'active' if request.endpoint and request.endpoint.startswith('broadcast.') }}"
|
|
href="{{ url_for('broadcast.index') }}">Broadcast</a>
|
|
<a class="jqc-nav-sublink {{ 'active' if request.endpoint and request.endpoint.startswith('devices.') }}"
|
|
href="{{ url_for('devices.index') }}">Devices</a>
|
|
<a class="jqc-nav-sublink {{ 'active' if request.endpoint and request.endpoint.startswith('enrollment.') }}"
|
|
href="{{ url_for('enrollment.admin_list') }}">Enrollment Forms</a>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<a class="jqc-nav-link {{ 'active' if request.endpoint == 'ui.about' }}" href="{{ url_for('ui.about') }}">
|
|
<i class="bi bi-info-circle"></i><span>About Us</span>
|
|
</a>
|
|
</nav>
|
|
|
|
{# The design switcher was removed from the sidebar in phase50, when
|
|
modern became the default — it no longer belongs in the primary nav.
|
|
The same action still exists in the account menu (top right), so
|
|
anyone who needs the classic design can still get to it. #}
|
|
</aside>
|
|
<div class="jqc-sidebar-backdrop d-lg-none" id="jqcSidebarBackdrop"></div>
|
|
{% endif %}
|
|
|
|
<!-- ══════════════════════════ MAIN ══════════════════════════ -->
|
|
<main class="{{ 'jqc-main' if current_user.is_authenticated else '' }}">
|
|
<div class="container-fluid {{ '' if current_user.is_authenticated else 'mt-4' }}">
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
{% for category, message in messages %}
|
|
<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
|
|
{{ message }}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
{% block content %}{% endblock %}
|
|
</div>
|
|
</main>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
{% block extra_js %}{% endblock %}
|
|
|
|
{% if current_user.is_authenticated %}
|
|
<script>
|
|
// ── Sidebar off-canvas toggle (mobile / tablet portrait) ──────────────
|
|
(function () {
|
|
var btn = document.getElementById('jqcSidebarToggle');
|
|
var sidebar = document.getElementById('jqcSidebar');
|
|
var backdrop = document.getElementById('jqcSidebarBackdrop');
|
|
if (!btn || !sidebar) return;
|
|
function close() {
|
|
sidebar.classList.remove('open');
|
|
if (backdrop) backdrop.classList.remove('show');
|
|
}
|
|
btn.addEventListener('click', function () {
|
|
sidebar.classList.toggle('open');
|
|
if (backdrop) backdrop.classList.toggle('show');
|
|
});
|
|
if (backdrop) backdrop.addEventListener('click', close);
|
|
})();
|
|
</script>
|
|
<script>
|
|
(function () {
|
|
'use strict';
|
|
|
|
const FEED_URL = '{{ url_for("notifications.feed") }}';
|
|
const MARK_READ_BASE = '/notifications/';
|
|
const MARK_ALL_URL = '{{ url_for("notifications.mark_all_read") }}';
|
|
const CSRF_TOKEN = '{{ csrf_token() }}';
|
|
const POLL_INTERVAL = 60000; // 60 seconds
|
|
|
|
const badgeDesktop = document.getElementById('notif-count-badge');
|
|
const listDesktop = document.getElementById('notif-list');
|
|
|
|
function updateBadge(count) {
|
|
[badgeDesktop].forEach(function(badge) {
|
|
if (!badge) return;
|
|
if (count > 0) {
|
|
badge.textContent = count > 99 ? '99+' : count;
|
|
badge.classList.remove('d-none');
|
|
} else {
|
|
badge.textContent = '';
|
|
badge.classList.add('d-none');
|
|
}
|
|
});
|
|
}
|
|
|
|
function renderInto(container, notifications) {
|
|
if (!container) return;
|
|
if (!notifications.length) {
|
|
container.innerHTML = '<div class="notif-empty">'
|
|
+ '<i class="bi bi-check2-circle me-1"></i>You\'re all caught up!</div>';
|
|
return;
|
|
}
|
|
container.innerHTML = notifications.map(function(n) {
|
|
return '<div class="d-block text-decoration-none text-dark notif-item px-3 py-2 border-bottom '
|
|
+ (n.is_read ? '' : 'unread') + '"'
|
|
+ ' data-notif-id="' + n.id + '"'
|
|
+ ' data-link="' + escapeAttr(n.link || '') + '">'
|
|
+ '<div class="notif-title">' + escapeHtml(n.title) + '</div>'
|
|
+ '<div class="notif-body">' + escapeHtml(n.body) + '</div>'
|
|
+ '<div class="notif-time">' + escapeHtml(n.created_at) + '</div>'
|
|
+ '</div>';
|
|
}).join('');
|
|
container.querySelectorAll('.notif-item').forEach(function(el) {
|
|
el.addEventListener('click', function() {
|
|
var id = this.dataset.notifId;
|
|
var link = this.dataset.link;
|
|
markRead(id, function() {
|
|
el.classList.remove('unread');
|
|
if (link) window.location.href = link;
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
function renderNotifications(notifications) {
|
|
renderInto(listDesktop, notifications);
|
|
}
|
|
|
|
function escapeHtml(str) {
|
|
if (!str) return '';
|
|
return str.replace(/&/g,'&').replace(/</g,'<')
|
|
.replace(/>/g,'>').replace(/"/g,'"');
|
|
}
|
|
function escapeAttr(str) { return escapeHtml(str); }
|
|
|
|
window.fetchNotifications = function fetchNotifications() {
|
|
fetch(FEED_URL, { credentials: 'same-origin' })
|
|
.then(function(r) { return r.json(); })
|
|
.then(function(data) {
|
|
updateBadge(data.unread_count);
|
|
window._jqcNotifications = data.notifications;
|
|
var deskEl = document.getElementById('notifDropdown');
|
|
var deskOpen = deskEl && deskEl.getAttribute('aria-expanded') === 'true';
|
|
if (deskOpen) {
|
|
renderNotifications(data.notifications);
|
|
}
|
|
})
|
|
.catch(function() {});
|
|
};
|
|
|
|
function markRead(id, callback) {
|
|
fetch(MARK_READ_BASE + id + '/mark-read', {
|
|
method: 'POST',
|
|
headers: { 'X-CSRFToken': CSRF_TOKEN, 'Content-Type': 'application/json' },
|
|
credentials: 'same-origin',
|
|
})
|
|
.then(function(r) { return r.json(); })
|
|
.then(function() { if (callback) callback(); fetchNotifications(); })
|
|
.catch(function() { if (callback) callback(); });
|
|
}
|
|
|
|
['notifDropdown'].forEach(function(id) {
|
|
var el = document.getElementById(id);
|
|
if (!el) return;
|
|
el.addEventListener('show.bs.dropdown', function() {
|
|
if (window._jqcNotifications) {
|
|
renderNotifications(window._jqcNotifications);
|
|
} else {
|
|
fetchNotifications();
|
|
}
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('#mark-all-read-btn, .mark-all-read-btn').forEach(function(btn) {
|
|
btn.addEventListener('click', function(e) {
|
|
e.stopPropagation();
|
|
fetch(MARK_ALL_URL, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': CSRF_TOKEN,
|
|
'X-Requested-With': 'XMLHttpRequest',
|
|
},
|
|
credentials: 'same-origin',
|
|
})
|
|
.then(function(r) { return r.json(); })
|
|
.then(function() {
|
|
updateBadge(0);
|
|
document.querySelectorAll('.notif-item.unread').forEach(function(el) {
|
|
el.classList.remove('unread');
|
|
});
|
|
if (window._jqcNotifications) {
|
|
window._jqcNotifications.forEach(function(n) { n.is_read = true; });
|
|
}
|
|
})
|
|
.catch(function() {});
|
|
});
|
|
});
|
|
|
|
fetchNotifications();
|
|
setInterval(fetchNotifications, POLL_INTERVAL);
|
|
})();
|
|
</script>
|
|
{% endif %}
|
|
</body>
|
|
</html>
|