1859 lines
81 KiB
HTML
1859 lines
81 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Administration & Audit Portal | DMH Hospital</title>
|
|
<link rel="icon" href="{{ url_for('static', filename='logo.png') }}">
|
|
<style>
|
|
:root {
|
|
--primary: #0284c7;
|
|
--primary-hover: #0369a1;
|
|
--primary-light: #f0f9ff;
|
|
--primary-border: #bae6fd;
|
|
--primary-focus-ring: rgba(2, 132, 199, 0.2);
|
|
|
|
--surface: #ffffff;
|
|
--background: #f8fafc;
|
|
--border: #e2e8f0;
|
|
--border-hover: #cbd5e1;
|
|
|
|
--text-primary: #0f172a;
|
|
--text-secondary: #475569;
|
|
--text-muted: #64748b;
|
|
|
|
--success: #059669;
|
|
--success-light: #ecfdf5;
|
|
--success-border: #a7f3d0;
|
|
--success-text: #065f46;
|
|
|
|
--warning: #d97706;
|
|
--warning-light: #fffbeb;
|
|
--warning-border: #fde68a;
|
|
--warning-text: #92400e;
|
|
|
|
--danger: #dc2626;
|
|
--danger-light: #fef2f2;
|
|
--danger-border: #fecaca;
|
|
--danger-text: #991b1b;
|
|
|
|
--info: #0284c7;
|
|
--info-light: #f0f9ff;
|
|
--info-border: #bae6fd;
|
|
--info-text: #075985;
|
|
|
|
--radius-sm: 6px;
|
|
--radius: 8px;
|
|
--radius-lg: 12px;
|
|
--shadow-subtle: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
|
|
--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
|
|
--shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
background-color: var(--background);
|
|
color: var(--text-primary);
|
|
line-height: 1.5;
|
|
-webkit-font-smoothing: antialiased;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
/* ── Top Navigation Bar ────────────────────────────────────────── */
|
|
.navbar {
|
|
background-color: var(--surface);
|
|
border-bottom: 1px solid var(--border);
|
|
padding: 10px 32px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
|
|
}
|
|
|
|
.navbar-brand-area {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 14px;
|
|
}
|
|
|
|
.brand-logo-container {
|
|
width: 44px;
|
|
height: 44px;
|
|
border-radius: 10px;
|
|
background: #ffffff;
|
|
border: 1px solid #e2e8f0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 4px;
|
|
flex-shrink: 0;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
|
|
}
|
|
|
|
.brand-logo-img {
|
|
max-height: 36px;
|
|
max-width: 36px;
|
|
width: auto;
|
|
height: auto;
|
|
object-fit: contain;
|
|
display: block;
|
|
}
|
|
|
|
.brand-text h1 {
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
color: #0f172a;
|
|
margin: 0;
|
|
line-height: 1.2;
|
|
}
|
|
|
|
.brand-text span {
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
color: var(--primary);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.6px;
|
|
}
|
|
|
|
.navbar-right {
|
|
display: flex;
|
|
gap: 14px;
|
|
align-items: center;
|
|
}
|
|
|
|
.user-chip {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 9px;
|
|
padding: 5px 12px;
|
|
background: #f1f5f9;
|
|
border-radius: 20px;
|
|
border: 1px solid var(--border);
|
|
}
|
|
|
|
.user-avatar-small {
|
|
width: 26px;
|
|
height: 26px;
|
|
border-radius: 50%;
|
|
background: #0284c7;
|
|
color: #ffffff;
|
|
font-weight: 700;
|
|
font-size: 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.user-name-text {
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: #0f172a;
|
|
}
|
|
|
|
.user-role-badge {
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
background: #fee2e2;
|
|
color: #991b1b;
|
|
padding: 1px 6px;
|
|
border-radius: 8px;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.btn-hub {
|
|
padding: 7px 16px;
|
|
border: 1px solid var(--primary);
|
|
border-radius: var(--radius);
|
|
text-decoration: none;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: #ffffff;
|
|
background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 7px;
|
|
transition: all 0.15s ease;
|
|
box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
|
|
}
|
|
|
|
.btn-hub:hover {
|
|
background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.logout-link {
|
|
color: var(--text-muted);
|
|
text-decoration: none;
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 6px;
|
|
border-radius: var(--radius-sm);
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.logout-link:hover {
|
|
color: #dc2626;
|
|
background: #fee2e2;
|
|
}
|
|
|
|
/* ── Main Layout ─────────────────────────────────────────────── */
|
|
.container {
|
|
max-width: 1360px;
|
|
width: 100%;
|
|
margin: 0 auto;
|
|
padding: 24px 32px 64px;
|
|
flex: 1;
|
|
}
|
|
|
|
/* ── Page Header ─────────────────────────────────────────────── */
|
|
.page-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: flex-end;
|
|
margin-bottom: 22px;
|
|
padding-bottom: 16px;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
.header-title-box h2 {
|
|
font-size: 22px;
|
|
font-weight: 700;
|
|
color: #0f172a;
|
|
margin-bottom: 4px;
|
|
letter-spacing: -0.01em;
|
|
}
|
|
|
|
.header-title-box p {
|
|
color: var(--text-secondary);
|
|
font-size: 13.5px;
|
|
}
|
|
|
|
.header-meta-pill {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: #0369a1;
|
|
background: #e0f2fe;
|
|
padding: 5px 12px;
|
|
border-radius: 14px;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
/* ── Live Admin Statistics Cards (5-Card Grid) ───────────────── */
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
|
gap: 16px;
|
|
margin-bottom: 26px;
|
|
}
|
|
|
|
.stat-card {
|
|
background: #ffffff;
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-lg);
|
|
padding: 16px 18px;
|
|
box-shadow: var(--shadow-card);
|
|
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
|
}
|
|
|
|
.stat-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.06);
|
|
}
|
|
|
|
.stat-card-top {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.stat-icon-circle {
|
|
width: 36px;
|
|
height: 36px;
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.stat-badge {
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
padding: 3px 8px;
|
|
border-radius: 10px;
|
|
}
|
|
|
|
.stat-card-val {
|
|
font-size: 26px;
|
|
font-weight: 700;
|
|
color: #0f172a;
|
|
line-height: 1.2;
|
|
}
|
|
|
|
.stat-card-name {
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary);
|
|
margin-top: 3px;
|
|
}
|
|
|
|
.stat-card-desc {
|
|
font-size: 11.5px;
|
|
color: var(--text-muted);
|
|
margin-top: 2px;
|
|
}
|
|
|
|
/* ── Modern Tabs Navigation ──────────────────────────────────── */
|
|
.tabs-nav {
|
|
display: flex;
|
|
gap: 8px;
|
|
border-bottom: 1px solid var(--border);
|
|
margin-bottom: 24px;
|
|
overflow-x: auto;
|
|
padding-bottom: 2px;
|
|
}
|
|
|
|
.tab-btn {
|
|
padding: 10px 18px;
|
|
border: none;
|
|
background: transparent;
|
|
font-size: 13.5px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary);
|
|
cursor: pointer;
|
|
border-bottom: 2px solid transparent;
|
|
transition: all 0.15s ease;
|
|
white-space: nowrap;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
border-radius: var(--radius) var(--radius) 0 0;
|
|
}
|
|
|
|
.tab-btn:hover {
|
|
color: var(--primary);
|
|
background: #f1f5f9;
|
|
}
|
|
|
|
.tab-btn.active {
|
|
color: var(--primary);
|
|
border-bottom-color: var(--primary);
|
|
background: #e0f2fe;
|
|
color: #0369a1;
|
|
}
|
|
|
|
/* ── Tab Content Areas ───────────────────────────────────────── */
|
|
.tab-content {
|
|
display: none;
|
|
}
|
|
|
|
.tab-content.active {
|
|
display: block;
|
|
}
|
|
|
|
/* ── Summary Cards Grid inside Tabs ──────────────────────────── */
|
|
.summary-subgrid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
gap: 14px;
|
|
margin-bottom: 22px;
|
|
}
|
|
|
|
.summary-card {
|
|
background: #ffffff;
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
padding: 14px 16px;
|
|
box-shadow: var(--shadow-card);
|
|
}
|
|
|
|
.summary-card .summary-label {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: var(--text-muted);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.summary-card .summary-value {
|
|
font-size: 22px;
|
|
font-weight: 700;
|
|
color: #0f172a;
|
|
}
|
|
|
|
/* ── Card Blocks / Section Wrappers ──────────────────────────── */
|
|
.card-panel {
|
|
background: #ffffff;
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-lg);
|
|
padding: 22px 24px;
|
|
margin-bottom: 24px;
|
|
box-shadow: var(--shadow-card);
|
|
}
|
|
|
|
.panel-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 18px;
|
|
flex-wrap: wrap;
|
|
gap: 12px;
|
|
}
|
|
|
|
.panel-header-title h3 {
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
color: #0f172a;
|
|
}
|
|
|
|
.panel-header-title p {
|
|
font-size: 12.5px;
|
|
color: var(--text-muted);
|
|
margin-top: 2px;
|
|
}
|
|
|
|
/* ── Tables ─────────────────────────────────────────────────── */
|
|
.table-scroll {
|
|
overflow-x: auto;
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
}
|
|
|
|
table.data-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
font-size: 13px;
|
|
text-align: left;
|
|
background: #ffffff;
|
|
}
|
|
|
|
table.data-table th {
|
|
background-color: #f8fafc;
|
|
color: var(--text-secondary);
|
|
font-weight: 600;
|
|
font-size: 12px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.03em;
|
|
padding: 10px 14px;
|
|
border-bottom: 1px solid var(--border);
|
|
white-space: nowrap;
|
|
}
|
|
|
|
table.data-table td {
|
|
padding: 12px 14px;
|
|
border-bottom: 1px solid var(--border);
|
|
color: var(--text-primary);
|
|
vertical-align: middle;
|
|
}
|
|
|
|
table.data-table tr:last-child td {
|
|
border-bottom: none;
|
|
}
|
|
|
|
table.data-table tbody tr:hover {
|
|
background-color: #f8fafc;
|
|
}
|
|
|
|
table.data-table td.num,
|
|
table.data-table th.num {
|
|
text-align: right;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
/* ── Status Tags & Badges ───────────────────────────────────── */
|
|
.tag {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
padding: 3px 8px;
|
|
border-radius: 4px;
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
line-height: 1.2;
|
|
}
|
|
|
|
.tag.insheet, .tag.matched, .tag.active {
|
|
background-color: var(--success-light);
|
|
color: var(--success-text);
|
|
border: 1px solid var(--success-border);
|
|
}
|
|
|
|
.tag.pending, .tag.edited, .tag.warning {
|
|
background-color: var(--warning-light);
|
|
color: var(--warning-text);
|
|
border: 1px solid var(--warning-border);
|
|
}
|
|
|
|
.tag.missing, .tag.danger, .tag.inactive {
|
|
background-color: var(--danger-light);
|
|
color: var(--danger-text);
|
|
border: 1px solid var(--danger-border);
|
|
}
|
|
|
|
.tag.manual {
|
|
background-color: #f5f3ff;
|
|
color: #6d28d9;
|
|
border: 1px solid #ddd6fe;
|
|
}
|
|
|
|
.tag.admin {
|
|
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
|
|
color: #92400e;
|
|
border: 1px solid #fcd34d;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.tag.staff {
|
|
background-color: #f1f5f9;
|
|
color: #475569;
|
|
border: 1px solid #cbd5e1;
|
|
}
|
|
|
|
.tag.info {
|
|
background-color: #eff6ff;
|
|
color: #1d4ed8;
|
|
border: 1px solid #bfdbfe;
|
|
}
|
|
|
|
.mono {
|
|
font-family: var(--font-mono);
|
|
font-size: 12px;
|
|
}
|
|
|
|
.today-badge {
|
|
background: #0284c7;
|
|
color: #ffffff;
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
padding: 2px 6px;
|
|
border-radius: 4px;
|
|
margin-left: 8px;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
/* ── Buttons ─────────────────────────────────────────────────── */
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 6px;
|
|
padding: 8px 14px;
|
|
border-radius: var(--radius);
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
text-decoration: none;
|
|
border: 1px solid transparent;
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: var(--primary);
|
|
color: #ffffff;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background-color: var(--primary-hover);
|
|
}
|
|
|
|
.btn-secondary {
|
|
background-color: #ffffff;
|
|
border-color: var(--border);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background-color: #f8fafc;
|
|
color: var(--text-primary);
|
|
border-color: var(--border-hover);
|
|
}
|
|
|
|
.btn-danger {
|
|
background-color: #fee2e2;
|
|
color: #991b1b;
|
|
border-color: #fecaca;
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
background-color: #fecaca;
|
|
color: #7f1d1d;
|
|
}
|
|
|
|
.btn-warning {
|
|
background-color: #fef3c7;
|
|
color: #92400e;
|
|
border-color: #fde68a;
|
|
}
|
|
|
|
.btn-warning:hover {
|
|
background-color: #fde68a;
|
|
}
|
|
|
|
.btn-sm {
|
|
padding: 5px 10px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
/* ── Search & Filters ────────────────────────────────────────── */
|
|
.toolbar-row {
|
|
display: flex;
|
|
gap: 12px;
|
|
margin-bottom: 16px;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.search-input {
|
|
flex: 1;
|
|
min-width: 240px;
|
|
padding: 8px 14px;
|
|
border: 1px solid #cbd5e1;
|
|
border-radius: var(--radius);
|
|
font-size: 13px;
|
|
color: var(--text-primary);
|
|
background: #ffffff;
|
|
transition: border-color 0.15s ease;
|
|
}
|
|
|
|
.search-input:focus {
|
|
outline: none;
|
|
border-color: var(--primary);
|
|
box-shadow: 0 0 0 3px var(--primary-focus-ring);
|
|
}
|
|
|
|
.select-input {
|
|
padding: 8px 14px;
|
|
border: 1px solid #cbd5e1;
|
|
border-radius: var(--radius);
|
|
font-size: 13px;
|
|
color: var(--text-primary);
|
|
background: #ffffff;
|
|
cursor: pointer;
|
|
}
|
|
|
|
/* ── Empty State ─────────────────────────────────────────────── */
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 48px 24px;
|
|
color: var(--text-muted);
|
|
}
|
|
|
|
.empty-state-title {
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
color: #0f172a;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.empty-state-desc {
|
|
font-size: 13px;
|
|
}
|
|
|
|
/* ── Modals ──────────────────────────────────────────────────── */
|
|
.modal-overlay {
|
|
display: none;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
background: rgba(15, 23, 42, 0.45);
|
|
backdrop-filter: blur(3px);
|
|
z-index: 1000;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.modal-overlay.active {
|
|
display: flex;
|
|
}
|
|
|
|
.modal-box {
|
|
background: #ffffff;
|
|
border-radius: var(--radius-lg);
|
|
width: 100%;
|
|
max-width: 480px;
|
|
box-shadow: var(--shadow-modal);
|
|
overflow: hidden;
|
|
animation: modalFadeIn 0.15s ease-out;
|
|
}
|
|
|
|
@keyframes modalFadeIn {
|
|
from { opacity: 0; transform: scale(0.97); }
|
|
to { opacity: 1; transform: scale(1); }
|
|
}
|
|
|
|
.modal-header {
|
|
padding: 18px 24px;
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.modal-header h4 {
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
color: #0f172a;
|
|
}
|
|
|
|
.modal-close-btn {
|
|
background: transparent;
|
|
border: none;
|
|
font-size: 20px;
|
|
color: var(--text-muted);
|
|
cursor: pointer;
|
|
padding: 4px;
|
|
line-height: 1;
|
|
}
|
|
|
|
.modal-close-btn:hover {
|
|
color: #0f172a;
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 20px 24px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
font-size: 12.5px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 6px;
|
|
}
|
|
|
|
.form-control {
|
|
width: 100%;
|
|
padding: 8px 12px;
|
|
border: 1px solid #cbd5e1;
|
|
border-radius: var(--radius);
|
|
font-size: 13.5px;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.form-control:focus {
|
|
outline: none;
|
|
border-color: var(--primary);
|
|
box-shadow: 0 0 0 3px var(--primary-focus-ring);
|
|
}
|
|
|
|
.modal-footer {
|
|
padding: 14px 24px;
|
|
border-top: 1px solid var(--border);
|
|
background: #f8fafc;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: 10px;
|
|
}
|
|
|
|
/* ── Alert Messages ──────────────────────────────────────────── */
|
|
.alert-box {
|
|
padding: 10px 16px;
|
|
border-radius: var(--radius);
|
|
font-size: 13px;
|
|
margin-bottom: 16px;
|
|
display: none;
|
|
}
|
|
|
|
.alert-box.success {
|
|
display: block;
|
|
background: var(--success-light);
|
|
color: var(--success-text);
|
|
border: 1px solid var(--success-border);
|
|
}
|
|
|
|
.alert-box.error {
|
|
display: block;
|
|
background: var(--danger-light);
|
|
color: var(--danger-text);
|
|
border: 1px solid var(--danger-border);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- ── Top Navigation Bar ────────────────────────────────────────── -->
|
|
<nav class="navbar">
|
|
<div class="navbar-brand-area">
|
|
<div class="brand-logo-container">
|
|
<img src="{{ url_for('static', filename='logo.png') }}" alt="DMH Logo" class="brand-logo-img">
|
|
</div>
|
|
<div class="brand-text">
|
|
<h1>DMH Hospital</h1>
|
|
<span>Administration & Audit Portal</span>
|
|
</div>
|
|
</div>
|
|
<div class="navbar-right">
|
|
<!-- Back to Pharmacy Hub Button -->
|
|
<a href="{{ url_for('dashboard') }}" class="btn-hub" title="Switch to Staff Pharmacy Hub">
|
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M19 12H5M12 19l-7-7 7-7"/>
|
|
</svg>
|
|
Back to Pharmacy Hub
|
|
</a>
|
|
|
|
<!-- Admin User Pill -->
|
|
<div class="user-chip">
|
|
<div class="user-avatar-small">{{ current_user.username[:1].upper() if current_user else 'A' }}</div>
|
|
<span class="user-name-text">{{ current_user.username if current_user else 'Administrator' }}</span>
|
|
<span class="user-role-badge">ADMIN</span>
|
|
</div>
|
|
|
|
<!-- Sign Out -->
|
|
<a href="{{ url_for('logout') }}" class="logout-link" title="Sign Out">
|
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>
|
|
<polyline points="16 17 21 12 16 7"/>
|
|
<line x1="21" y1="12" x2="9" y2="12"/>
|
|
</svg>
|
|
</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- ── Main Layout Container ────────────────────────────────────── -->
|
|
<div class="container">
|
|
<!-- Page Header -->
|
|
<div class="page-header">
|
|
<div class="header-title-box">
|
|
<h2>System Administration Portal</h2>
|
|
<p>Manage hospital staff accounts, inspect real-time reconciliation queues, and update the master drug catalog.</p>
|
|
</div>
|
|
<div>
|
|
<span class="header-meta-pill">
|
|
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
|
|
<polyline points="22 4 12 14.01 9 11.01"/>
|
|
</svg>
|
|
Live DMH Database Connected
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ── Live Admin Statistics Cards (5 Cards Grid) ─────────────── -->
|
|
<div class="stats-grid">
|
|
<!-- Stat 1: Total Completed Invoices -->
|
|
<div class="stat-card">
|
|
<div class="stat-card-top">
|
|
<span class="stat-icon-circle" style="background:#ecfdf5;color:#059669;">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/>
|
|
</svg>
|
|
</span>
|
|
<span class="stat-badge" style="background:#d1fae5;color:#065f46;">Stored in DMH</span>
|
|
</div>
|
|
<div class="stat-card-val">{{ queue_stats.total_processed_count if queue_stats else summary.total_pdfs }}</div>
|
|
<div class="stat-card-name">Total Invoices Processed</div>
|
|
<div class="stat-card-desc">Completed GRNs stored in DMH</div>
|
|
</div>
|
|
|
|
<!-- Stat 2: Pending PO Approval Queue -->
|
|
<div class="stat-card">
|
|
<div class="stat-card-top">
|
|
<span class="stat-icon-circle" style="background:#fee2e2;color:#dc2626;">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><rect x="8" y="2" width="8" height="4" rx="1" ry="1"/><path d="m9 14 2 2 4-4"/>
|
|
</svg>
|
|
</span>
|
|
<span class="stat-badge" style="background:#fee2e2;color:#991b1b;">Queue 1</span>
|
|
</div>
|
|
<div class="stat-card-val">{{ queue_stats.pending_po_count if queue_stats else 0 }}</div>
|
|
<div class="stat-card-name">Pending PO Numbers</div>
|
|
<div class="stat-card-desc">Awaiting PO verification</div>
|
|
</div>
|
|
|
|
<!-- Stat 3: Pending Item Code Approval Queue -->
|
|
<div class="stat-card">
|
|
<div class="stat-card-top">
|
|
<span class="stat-icon-circle" style="background:#ffedd5;color:#ea580c;">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z"/><path d="m8.5 8.5 7 7"/>
|
|
</svg>
|
|
</span>
|
|
<span class="stat-badge" style="background:#ffedd5;color:#9a3412;">Queue 2</span>
|
|
</div>
|
|
<div class="stat-card-val">{{ queue_stats.pending_item_code_count if queue_stats else 0 }}</div>
|
|
<div class="stat-card-name">Pending Item Codes</div>
|
|
<div class="stat-card-desc">Awaiting standardized codes</div>
|
|
</div>
|
|
|
|
<!-- Stat 4: Drug Master Catalog -->
|
|
<div class="stat-card">
|
|
<div class="stat-card-top">
|
|
<span class="stat-icon-circle" style="background:#e0f2fe;color:#0284c7;">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M3 5V19A9 3 0 0 0 21 19V5"/><path d="M3 12A9 3 0 0 0 21 12"/>
|
|
</svg>
|
|
</span>
|
|
<span class="stat-badge" style="background:#e0f2fe;color:#0369a1;">Master DB</span>
|
|
</div>
|
|
<div class="stat-card-val">{{ queue_stats.catalog_count if queue_stats else 14324 }}</div>
|
|
<div class="stat-card-name">Drug Master Catalog</div>
|
|
<div class="stat-card-desc">Standardized items available</div>
|
|
</div>
|
|
|
|
<!-- Stat 5: Registered Accounts -->
|
|
<div class="stat-card">
|
|
<div class="stat-card-top">
|
|
<span class="stat-icon-circle" style="background:#f3e8ff;color:#7c3aed;">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>
|
|
</svg>
|
|
</span>
|
|
<span class="stat-badge" style="background:#f3e8ff;color:#6b21a8;">Staff & Admins</span>
|
|
</div>
|
|
<div class="stat-card-val">{{ all_users|length if all_users else 1 }}</div>
|
|
<div class="stat-card-name">Registered Accounts</div>
|
|
<div class="stat-card-desc">Active system operators</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ── Modern Navigation Tabs ─────────────────────────────────── -->
|
|
<div class="tabs-nav">
|
|
<button class="tab-btn active" onclick="switchTab('analytics')">
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/>
|
|
</svg>
|
|
Processing Analytics & Daily Audit
|
|
</button>
|
|
<button class="tab-btn" onclick="switchTab('users')">
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/>
|
|
</svg>
|
|
Staff & User Management
|
|
</button>
|
|
<button class="tab-btn" onclick="switchTab('catalog')">
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M3 5V19A9 3 0 0 0 21 19V5"/><path d="M3 12A9 3 0 0 0 21 12"/>
|
|
</svg>
|
|
Drug Master Catalog (14,324 items)
|
|
</button>
|
|
<button class="tab-btn" onclick="switchTab('quality')">
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
|
|
</svg>
|
|
Quality & Review
|
|
</button>
|
|
</div>
|
|
|
|
<!-- ═══════════════════════════════════════════════════════════════ -->
|
|
<!-- TAB 1: PROCESSING ANALYTICS & DAILY AUDIT -->
|
|
<!-- ═══════════════════════════════════════════════════════════════ -->
|
|
<div id="analytics" class="tab-content active">
|
|
<div class="summary-subgrid">
|
|
<div class="summary-card">
|
|
<div class="summary-label">Invoices Today</div>
|
|
<div class="summary-value">{{ summary.today_pdfs }}</div>
|
|
</div>
|
|
<div class="summary-card">
|
|
<div class="summary-label">Active Staff Today</div>
|
|
<div class="summary-value">{{ summary.today_active_users }}</div>
|
|
</div>
|
|
<div class="summary-card">
|
|
<div class="summary-label">Total Items Processed</div>
|
|
<div class="summary-value">{{ summary.total_items }}</div>
|
|
</div>
|
|
<div class="summary-card">
|
|
<div class="summary-label">Direct & Auto-Matched</div>
|
|
<div class="summary-value" style="color:var(--success);">{{ summary.total_items - summary.total_manual - summary.total_missing }}</div>
|
|
</div>
|
|
<div class="summary-card">
|
|
<div class="summary-label">Manual Mappings</div>
|
|
<div class="summary-value" style="color:#6d28d9;">{{ summary.total_manual }}</div>
|
|
</div>
|
|
<div class="summary-card">
|
|
<div class="summary-label">Pending / Missing Codes</div>
|
|
<div class="summary-value" style="color:var(--danger);">{{ summary.total_missing }}</div>
|
|
</div>
|
|
<div class="summary-card">
|
|
<div class="summary-label">PO Approvals Today</div>
|
|
<div class="summary-value" style="color:#2563eb;">{{ summary.today_po_approved }}</div>
|
|
</div>
|
|
<div class="summary-card">
|
|
<div class="summary-label">Total PO Approvals</div>
|
|
<div class="summary-value" style="color:#0284c7;">{{ summary.total_po_approved }}</div>
|
|
</div>
|
|
<div class="summary-card">
|
|
<div class="summary-label">Item Code Approvals</div>
|
|
<div class="summary-value" style="color:#7c3aed;">{{ summary.total_item_code_approved }}</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if stats %}
|
|
{% for day in stats %}
|
|
<div class="card-panel">
|
|
<div class="panel-header">
|
|
<div class="panel-header-title">
|
|
<h3>
|
|
Activity for {{ day.date }}
|
|
{% if day.date == today %}<span class="today-badge">TODAY</span>{% endif %}
|
|
</h3>
|
|
<p>Daily audit breakdown by pharmacy staff operator & PO approval actions</p>
|
|
</div>
|
|
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;">
|
|
<span class="tag staff" style="font-size:12px;padding:4px 9px;">{{ day.users|length }} Staff Active</span>
|
|
<span class="tag matched" style="font-size:12px;padding:4px 9px;">{{ day.day_po_approved }} POs Approved</span>
|
|
<span class="tag manual" style="font-size:12px;padding:4px 9px;">{{ day.day_item_approved }} Items Approved</span>
|
|
</div>
|
|
</div>
|
|
<div class="table-scroll">
|
|
<table class="data-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Staff Member</th>
|
|
<th class="num">Invoices</th>
|
|
<th class="num">Line Items</th>
|
|
<th class="num">With Code</th>
|
|
<th class="num">Auto-Matched</th>
|
|
<th class="num">Manual Mapped</th>
|
|
<th class="num">Missing Code</th>
|
|
<th class="num">PO Approvals</th>
|
|
<th class="num">Item Approvals</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for u in day.users %}
|
|
<tr>
|
|
<td><strong>{{ u.username }}</strong></td>
|
|
<td class="num">{{ u.pdfs_processed }}</td>
|
|
<td class="num">{{ u.total_items }}</td>
|
|
<td class="num">{{ u.items_with_code }}</td>
|
|
<td class="num"><span class="tag matched">{{ u.items_auto_matched }}</span></td>
|
|
<td class="num"><span class="tag manual">{{ u.items_manual }}</span></td>
|
|
<td class="num">
|
|
{% if u.items_missing > 0 %}<span class="tag missing">{{ u.items_missing }}</span>
|
|
{% else %}<span style="color:var(--text-muted);">0</span>{% endif %}
|
|
</td>
|
|
<td class="num">
|
|
{% if u.po_approved > 0 %}<span class="tag matched" style="font-weight:700;">{{ u.po_approved }}</span>
|
|
{% else %}<span style="color:var(--text-muted);">0</span>{% endif %}
|
|
</td>
|
|
<td class="num">
|
|
{% if u.item_code_approved > 0 %}<span class="tag manual" style="font-weight:700;">{{ u.item_code_approved }}</span>
|
|
{% else %}<span style="color:var(--text-muted);">0</span>{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- PO & ITEM CODE APPROVAL ACTIVITY HISTORY FOR THIS DAY -->
|
|
<div style="margin-top:22px;border-top:1px solid var(--border);padding-top:16px;">
|
|
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;">
|
|
<div style="font-weight:600;font-size:14px;color:var(--text-main);display:flex;align-items:center;gap:8px;">
|
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color:var(--primary);">
|
|
<circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/>
|
|
</svg>
|
|
PO & Item Code Activity History ({{ day.po_history|length }})
|
|
</div>
|
|
</div>
|
|
|
|
{% if day.po_history %}
|
|
<div class="table-scroll">
|
|
<table class="data-table" style="font-size:12.5px;">
|
|
<thead>
|
|
<tr>
|
|
<th style="width:85px;">Time</th>
|
|
<th>Staff Operator</th>
|
|
<th>Invoice #</th>
|
|
<th>Vendor</th>
|
|
<th>Approved PO #</th>
|
|
<th>Action Type</th>
|
|
<th>Resolution Status</th>
|
|
<th>Audit Log Notes</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for item in day.po_history %}
|
|
<tr>
|
|
<td style="color:var(--text-secondary);font-family:var(--font-mono);font-size:11.5px;">{{ item.time }}</td>
|
|
<td><strong>{{ item.approved_by }}</strong></td>
|
|
<td><span class="mono" style="font-weight:600;">{{ item.invoice_number }}</span></td>
|
|
<td style="max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="{{ item.vendor_name }}">{{ item.vendor_name }}</td>
|
|
<td>
|
|
{% if item.po_number_approved and item.po_number_approved != '--' %}
|
|
<span class="mono" style="font-weight:600;color:var(--primary);">{{ item.po_number_approved }}</span>
|
|
{% else %}
|
|
<span style="color:var(--text-muted);">None</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if item.approval_type == 'item_code_approval' %}
|
|
<span class="tag manual" style="font-size:11px;">Item Code Approved</span>
|
|
{% elif item.approval_status == 'rejected' %}
|
|
<span class="tag missing" style="font-size:11px;">Rejected</span>
|
|
{% else %}
|
|
<span class="tag matched" style="font-size:11px;">PO Approved</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if item.approval_status in ('approved', 'completed') %}
|
|
<span class="tag matched" style="font-size:11px;">{{ item.approval_status|capitalize }}</span>
|
|
{% elif item.approval_status == 'pending_item_code' %}
|
|
<span class="tag warning" style="font-size:11px;">Pending Item Codes</span>
|
|
{% elif item.approval_status == 'rejected' %}
|
|
<span class="tag missing" style="font-size:11px;">Rejected</span>
|
|
{% else %}
|
|
<span class="tag" style="font-size:11px;">{{ item.approval_status|capitalize }}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td style="color:var(--text-secondary);font-size:12px;">{{ item.notes }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% else %}
|
|
<div style="padding:14px 18px;background:#f8fafc;border-radius:var(--radius-sm);border:1px dashed var(--border);color:var(--text-muted);font-size:13px;display:flex;align-items:center;gap:8px;">
|
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/>
|
|
</svg>
|
|
No manual PO or Item Code approval actions recorded on this date (extractions processed directly or awaiting queue action).
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
{% else %}
|
|
<div class="card-panel">
|
|
<div class="empty-state">
|
|
<div class="empty-state-title">No Extractions Recorded</div>
|
|
<div class="empty-state-desc">Daily user extraction audit records will appear here as staff process invoices.</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- ═══════════════════════════════════════════════════════════════ -->
|
|
<!-- TAB 2: STAFF & USER MANAGEMENT -->
|
|
<!-- ═══════════════════════════════════════════════════════════════ -->
|
|
<div id="users" class="tab-content">
|
|
<div id="userAlertBox" class="alert-box"></div>
|
|
|
|
<div class="card-panel">
|
|
<div class="panel-header">
|
|
<div class="panel-header-title">
|
|
<h3>Registered Pharmacy Staff & Administrator Accounts</h3>
|
|
<p>Manage system access, create new staff operators, promote administrators, and reset passwords.</p>
|
|
</div>
|
|
<button class="btn btn-primary" onclick="openAddUserModal()">
|
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
|
|
</svg>
|
|
Add New User
|
|
</button>
|
|
</div>
|
|
|
|
<div class="toolbar-row">
|
|
<input type="text" id="userSearchInput" class="search-input" placeholder="Search staff by username or email..." onkeyup="filterUsersTable()">
|
|
</div>
|
|
|
|
<div class="table-scroll">
|
|
<table class="data-table" id="usersTable">
|
|
<thead>
|
|
<tr>
|
|
<th>Username</th>
|
|
<th>Email</th>
|
|
<th>Role</th>
|
|
<th>Registered Date</th>
|
|
<th>Last Login</th>
|
|
<th>Account Status</th>
|
|
<th style="text-align:right;">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="usersTableBody">
|
|
{% for user in all_users %}
|
|
<tr data-username="{{ user.username }}">
|
|
<td>
|
|
<strong>{{ user.username }}</strong>
|
|
</td>
|
|
<td style="color:var(--text-secondary);">{{ user.email }}</td>
|
|
<td>
|
|
{% if user.is_admin %}
|
|
<span class="tag admin">ADMIN</span>
|
|
{% else %}
|
|
<span class="tag staff">PHARMACY STAFF</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ user.created_at[:10] if user.created_at else 'N/A' }}</td>
|
|
<td>{{ user.last_login[:10] if user.last_login else 'Never' }}</td>
|
|
<td>
|
|
{% if user.is_active %}
|
|
<span class="tag active">Active</span>
|
|
{% else %}
|
|
<span class="tag inactive">Inactive</span>
|
|
{% endif %}
|
|
</td>
|
|
<td style="text-align:right; white-space:nowrap;">
|
|
<!-- Reset Password -->
|
|
<button class="btn btn-secondary btn-sm" onclick="openResetPasswordModal('{{ user.username }}')" title="Reset Password">
|
|
Reset Pass
|
|
</button>
|
|
|
|
<!-- Toggle Admin Role -->
|
|
{% if user.username != 'admin' and user.username != 'dmh' %}
|
|
<button class="btn btn-secondary btn-sm" onclick="toggleAdminRole('{{ user.username }}', {{ 0 if user.is_admin else 1 }})" title="Change Role">
|
|
{{ 'Make Staff' if user.is_admin else 'Make Admin' }}
|
|
</button>
|
|
<button class="btn btn-danger btn-sm" onclick="deleteUser('{{ user.username }}')">
|
|
Delete
|
|
</button>
|
|
{% else %}
|
|
<span style="color:var(--text-muted);font-size:12px;padding:0 8px;">Protected Admin</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══════════════════════════════════════════════════════════════ -->
|
|
<!-- TAB 3: DRUG MASTER CATALOG -->
|
|
<!-- ═══════════════════════════════════════════════════════════════ -->
|
|
<div id="catalog" class="tab-content">
|
|
<div id="catalogAlertBox" class="alert-box"></div>
|
|
|
|
<div class="card-panel">
|
|
<div class="panel-header">
|
|
<div class="panel-header-title">
|
|
<h3>Drug Master Catalog (14,324 items)</h3>
|
|
<p>Search, manage and update the hospital's standardized drug items, formulas, and hospital item codes.</p>
|
|
</div>
|
|
<button class="btn btn-primary" onclick="openAddCodeModal()">
|
|
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
|
|
</svg>
|
|
Add Item Code
|
|
</button>
|
|
</div>
|
|
|
|
<div class="toolbar-row">
|
|
<input type="text" id="catalogSearch" class="search-input" placeholder="Search by item code or drug description (e.g. Paracetamol, Pantocid)...">
|
|
<select id="catalogCategoryFilter" class="select-input">
|
|
<option value="">All Categories</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="table-scroll">
|
|
<table class="data-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Item Code</th>
|
|
<th>Medicine Name / Description</th>
|
|
<th>Category</th>
|
|
<th>Last Updated</th>
|
|
<th style="text-align:right;">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="catalogTableBody">
|
|
<tr><td colspan="5" style="text-align:center;padding:36px;color:var(--text-muted);">Loading catalog database...</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="empty-state" id="catalogEmptyState" style="display:none;">
|
|
<div class="empty-state-title">No Catalog Items Found</div>
|
|
<div class="empty-state-desc">Try adjusting your search terms or category filter.</div>
|
|
</div>
|
|
|
|
<div style="display:flex; justify-content:space-between; align-items:center; margin-top:16px;">
|
|
<span id="catalogCount" style="font-size:13px; font-weight:600; color:var(--text-muted);"></span>
|
|
<button class="btn btn-secondary btn-sm" id="catalogLoadMoreBtn" onclick="loadCatalog(true)" style="display:none;">Load More Entries</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ═══════════════════════════════════════════════════════════════ -->
|
|
<!-- TAB 4: QUALITY & MISSING CODE REVIEW -->
|
|
<!-- ═══════════════════════════════════════════════════════════════ -->
|
|
<div id="quality" class="tab-content">
|
|
<div class="summary-subgrid" id="qualitySummaryGrid"></div>
|
|
|
|
<div class="card-panel">
|
|
<div class="panel-header">
|
|
<div class="panel-header-title">
|
|
<h3>Catalog Distribution by Category</h3>
|
|
<p>Total standardized medicines registered under each pharmaceutical group.</p>
|
|
</div>
|
|
</div>
|
|
<div class="table-scroll">
|
|
<table class="data-table" id="categoryStatsTable">
|
|
<thead>
|
|
<tr>
|
|
<th>Drug Category</th>
|
|
<th class="num">Standardized Items</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="categoryStatsBody"></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-panel">
|
|
<div class="panel-header">
|
|
<div class="panel-header-title">
|
|
<h3>Unmapped Invoice Items Requiring Review</h3>
|
|
<p>Line items extracted from invoices where no matching hospital item code was found.</p>
|
|
</div>
|
|
</div>
|
|
<div class="table-scroll">
|
|
<table class="data-table" id="reviewTable">
|
|
<thead>
|
|
<tr>
|
|
<th>Item Description</th>
|
|
<th>Uploaded By</th>
|
|
<th>Source Filename</th>
|
|
<th>Extraction Date</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="reviewTableBody"></tbody>
|
|
</table>
|
|
</div>
|
|
<div class="empty-state" id="reviewEmptyState" style="display:none;">
|
|
<div class="empty-state-title">All Items Assigned</div>
|
|
<div class="empty-state-desc">Every extracted invoice line item currently has a mapped item code.</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ── MODAL 1: ADD USER ─────────────────────────────────────────── -->
|
|
<div id="addUserModal" class="modal-overlay">
|
|
<div class="modal-box">
|
|
<div class="modal-header">
|
|
<h4>Create Staff / Administrator Account</h4>
|
|
<button type="button" class="modal-close-btn" onclick="closeAddUserModal()">×</button>
|
|
</div>
|
|
<form id="addUserForm" onsubmit="submitAddUser(event)">
|
|
<div class="modal-body">
|
|
<div class="form-group">
|
|
<label for="newUsername">Username</label>
|
|
<input type="text" id="newUsername" class="form-control" required placeholder="e.g. john_pharmacy" autocomplete="off">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="newEmail">Email Address</label>
|
|
<input type="email" id="newEmail" class="form-control" required placeholder="john@dmhospital.org" autocomplete="off">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="newPassword">Initial Password</label>
|
|
<input type="password" id="newPassword" class="form-control" required placeholder="Minimum 6 characters" autocomplete="new-password">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="newPasswordConfirm">Confirm Password</label>
|
|
<input type="password" id="newPasswordConfirm" class="form-control" required placeholder="Confirm password" autocomplete="new-password">
|
|
</div>
|
|
<div class="form-group" style="display:flex;align-items:center;gap:8px;margin-top:8px;">
|
|
<input type="checkbox" id="newIsAdmin" style="width:16px;height:16px;">
|
|
<label for="newIsAdmin" style="margin-bottom:0;cursor:pointer;">Grant Full Administrator Privileges</label>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" onclick="closeAddUserModal()">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Create User</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ── MODAL 2: RESET PASSWORD ───────────────────────────────────── -->
|
|
<div id="resetPasswordModal" class="modal-overlay">
|
|
<div class="modal-box">
|
|
<div class="modal-header">
|
|
<h4>Reset Staff Password</h4>
|
|
<button type="button" class="modal-close-btn" onclick="closeResetPasswordModal()">×</button>
|
|
</div>
|
|
<form onsubmit="submitResetPassword(event)">
|
|
<input type="hidden" id="resetTargetUsername" value="">
|
|
<div class="modal-body">
|
|
<p style="font-size:13px;color:var(--text-muted);margin-bottom:14px;">
|
|
Resetting password for user: <strong id="resetTargetUsernameDisplay" style="color:#0f172a;"></strong>
|
|
</p>
|
|
<div class="form-group">
|
|
<label for="resetNewPassword">New Password</label>
|
|
<input type="password" id="resetNewPassword" class="form-control" required placeholder="Enter new password (min 6 characters)" autocomplete="new-password">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="resetNewPasswordConfirm">Confirm New Password</label>
|
|
<input type="password" id="resetNewPasswordConfirm" class="form-control" required placeholder="Confirm new password" autocomplete="new-password">
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" onclick="closeResetPasswordModal()">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Update Password</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ── MODAL 3: ADD / EDIT ITEM CODE ─────────────────────────────── -->
|
|
<div id="codeModal" class="modal-overlay">
|
|
<div class="modal-box">
|
|
<div class="modal-header">
|
|
<h4 id="codeModalHeader">Add Item Code</h4>
|
|
<button type="button" class="modal-close-btn" onclick="closeCodeModal()">×</button>
|
|
</div>
|
|
<form onsubmit="submitCodeForm(event)">
|
|
<input type="hidden" id="codeModalId" value="">
|
|
<div class="modal-body">
|
|
<div class="form-group">
|
|
<label for="codeItemCode">Item Code</label>
|
|
<input type="text" id="codeItemCode" class="form-control" required placeholder="e.g. DMH-MED-102" maxlength="50" style="font-family:monospace;font-weight:600;">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="codeName">Item Name / Formula</label>
|
|
<input type="text" id="codeName" class="form-control" required placeholder="e.g. Paracetamol 650mg Tablet">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="codeCategory">Category</label>
|
|
<input type="text" id="codeCategory" class="form-control" list="categoryOptions" placeholder="e.g. Pharmaceuticals, Antibiotics, IV Fluids">
|
|
<datalist id="categoryOptions"></datalist>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" onclick="closeCodeModal()">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Save Code</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- ── JavaScript ────────────────────────────────────────────────── -->
|
|
<script>
|
|
let catalogLoadedOnce = false;
|
|
let qualityLoadedOnce = false;
|
|
|
|
function switchTab(tabName) {
|
|
document.querySelectorAll('.tab-content').forEach(tab => tab.classList.remove('active'));
|
|
document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('active'));
|
|
|
|
const targetTab = document.getElementById(tabName);
|
|
if (targetTab) targetTab.classList.add('active');
|
|
|
|
// Find matching button
|
|
document.querySelectorAll('.tab-btn').forEach(btn => {
|
|
if (btn.getAttribute('onclick')?.includes(tabName)) {
|
|
btn.classList.add('active');
|
|
}
|
|
});
|
|
|
|
if (tabName === 'catalog' && !catalogLoadedOnce) {
|
|
catalogLoadedOnce = true;
|
|
loadCategoryOptions();
|
|
loadCatalog(false);
|
|
}
|
|
if (tabName === 'quality' && !qualityLoadedOnce) {
|
|
qualityLoadedOnce = true;
|
|
loadQualityStats();
|
|
loadItemsToReview();
|
|
}
|
|
}
|
|
|
|
// ============================================================
|
|
// USER MANAGEMENT
|
|
// ============================================================
|
|
|
|
function filterUsersTable() {
|
|
const query = (document.getElementById('userSearchInput')?.value || '').toLowerCase().trim();
|
|
const rows = document.querySelectorAll('#usersTableBody tr');
|
|
rows.forEach(r => {
|
|
const text = r.textContent.toLowerCase();
|
|
r.style.display = text.includes(query) ? '' : 'none';
|
|
});
|
|
}
|
|
|
|
function openAddUserModal() {
|
|
document.getElementById('addUserModal').classList.add('active');
|
|
}
|
|
|
|
function closeAddUserModal() {
|
|
document.getElementById('addUserModal').classList.remove('active');
|
|
document.getElementById('addUserForm')?.reset();
|
|
}
|
|
|
|
async function submitAddUser(event) {
|
|
event.preventDefault();
|
|
const username = document.getElementById('newUsername').value.trim();
|
|
const email = document.getElementById('newEmail').value.trim();
|
|
const password = document.getElementById('newPassword').value;
|
|
const passwordConfirm = document.getElementById('newPasswordConfirm').value;
|
|
const isAdmin = document.getElementById('newIsAdmin').checked;
|
|
|
|
if (password !== passwordConfirm) {
|
|
alert('Passwords do not match.');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const res = await fetch('/api/admin/add-user', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
username: username,
|
|
email: email,
|
|
password: password,
|
|
is_admin: isAdmin
|
|
})
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
showUserAlert('User account created successfully.', 'success');
|
|
closeAddUserModal();
|
|
setTimeout(() => location.reload(), 1200);
|
|
} else {
|
|
alert(data.message || 'Failed to create user');
|
|
}
|
|
} catch(e) {
|
|
alert('Error creating user: ' + e.message);
|
|
}
|
|
}
|
|
|
|
function openResetPasswordModal(username) {
|
|
document.getElementById('resetTargetUsername').value = username;
|
|
document.getElementById('resetTargetUsernameDisplay').textContent = username;
|
|
document.getElementById('resetNewPassword').value = '';
|
|
document.getElementById('resetNewPasswordConfirm').value = '';
|
|
document.getElementById('resetPasswordModal').classList.add('active');
|
|
}
|
|
|
|
function closeResetPasswordModal() {
|
|
document.getElementById('resetPasswordModal').classList.remove('active');
|
|
}
|
|
|
|
async function submitResetPassword(event) {
|
|
event.preventDefault();
|
|
const username = document.getElementById('resetTargetUsername').value;
|
|
const newPassword = document.getElementById('resetNewPassword').value;
|
|
const confirm = document.getElementById('resetNewPasswordConfirm').value;
|
|
|
|
if (newPassword !== confirm) {
|
|
alert('Passwords do not match.');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const res = await fetch('/api/admin/reset-password', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({username: username, new_password: newPassword})
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
showUserAlert(data.message, 'success');
|
|
closeResetPasswordModal();
|
|
} else {
|
|
alert(data.message || 'Failed to reset password');
|
|
}
|
|
} catch(e) {
|
|
alert('Error resetting password: ' + e.message);
|
|
}
|
|
}
|
|
|
|
async function toggleAdminRole(username, makeAdminFlag) {
|
|
const role = makeAdminFlag ? 'ADMIN' : 'PHARMACY STAFF';
|
|
if (!confirm(`Change role for "${username}" to ${role}?`)) return;
|
|
|
|
try {
|
|
const res = await fetch('/api/admin/toggle-admin', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({username: username, is_admin: makeAdminFlag})
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
showUserAlert(data.message, 'success');
|
|
setTimeout(() => location.reload(), 1000);
|
|
} else {
|
|
alert(data.message || 'Failed to change user role');
|
|
}
|
|
} catch(e) {
|
|
alert('Error: ' + e.message);
|
|
}
|
|
}
|
|
|
|
async function deleteUser(username) {
|
|
if (!confirm(`Delete user account "${username}"? This action cannot be undone.`)) return;
|
|
|
|
try {
|
|
const res = await fetch('/api/admin/delete-user', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({username: username})
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
showUserAlert(data.message, 'success');
|
|
const row = document.querySelector(`#usersTableBody tr[data-username="${username}"]`);
|
|
if (row) row.remove();
|
|
} else {
|
|
alert(data.message || 'Failed to delete user');
|
|
}
|
|
} catch(e) {
|
|
alert('Error: ' + e.message);
|
|
}
|
|
}
|
|
|
|
function showUserAlert(msg, type) {
|
|
const box = document.getElementById('userAlertBox');
|
|
box.className = `alert-box ${type}`;
|
|
box.textContent = msg;
|
|
setTimeout(() => { box.className = 'alert-box'; }, 4000);
|
|
}
|
|
|
|
// ============================================================
|
|
// CATALOG MANAGEMENT (14,324 ITEMS)
|
|
// ============================================================
|
|
|
|
let catalogPage = 1;
|
|
let catalogSearchTimer = null;
|
|
|
|
document.getElementById('catalogSearch')?.addEventListener('input', () => {
|
|
clearTimeout(catalogSearchTimer);
|
|
catalogSearchTimer = setTimeout(() => loadCatalog(false), 300);
|
|
});
|
|
|
|
document.getElementById('catalogCategoryFilter')?.addEventListener('change', () => loadCatalog(false));
|
|
|
|
async function loadCategoryOptions() {
|
|
try {
|
|
const res = await fetch('/api/catalog/categories');
|
|
const data = await res.json();
|
|
if (!data.success) return;
|
|
|
|
const filterSelect = document.getElementById('catalogCategoryFilter');
|
|
const datalist = document.getElementById('categoryOptions');
|
|
filterSelect.querySelectorAll('option:not(:first-child)').forEach(o => o.remove());
|
|
datalist.replaceChildren();
|
|
|
|
data.data.forEach(cat => {
|
|
const opt1 = document.createElement('option');
|
|
opt1.value = cat; opt1.textContent = cat;
|
|
filterSelect.appendChild(opt1);
|
|
|
|
const opt2 = document.createElement('option');
|
|
opt2.value = cat;
|
|
datalist.appendChild(opt2);
|
|
});
|
|
} catch (e) { /* silent */ }
|
|
}
|
|
|
|
async function loadCatalog(append) {
|
|
const q = document.getElementById('catalogSearch').value.trim();
|
|
const category = document.getElementById('catalogCategoryFilter').value;
|
|
catalogPage = append ? catalogPage + 1 : 1;
|
|
|
|
const params = new URLSearchParams({ page: catalogPage, per_page: 50 });
|
|
if (q) params.set('q', q);
|
|
if (category) params.set('category', category);
|
|
|
|
try {
|
|
const res = await fetch(`/api/catalog?${params}`);
|
|
const data = await res.json();
|
|
if (!data.success) return;
|
|
|
|
const tbody = document.getElementById('catalogTableBody');
|
|
if (!append) tbody.replaceChildren();
|
|
|
|
data.data.forEach(row => tbody.appendChild(buildCatalogRow(row)));
|
|
|
|
document.getElementById('catalogEmptyState').style.display = data.total === 0 ? 'block' : 'none';
|
|
document.getElementById('catalogCount').textContent = `Showing ${tbody.children.length} of ${data.total} standardized drug codes`;
|
|
document.getElementById('catalogLoadMoreBtn').style.display = data.has_more ? 'inline-block' : 'none';
|
|
} catch (e) {
|
|
showCatalogAlert('Failed to load catalog data.', 'error');
|
|
}
|
|
}
|
|
|
|
function buildCatalogRow(row) {
|
|
const tr = document.createElement('tr');
|
|
|
|
const codeTd = document.createElement('td');
|
|
codeTd.innerHTML = `<strong style="font-family:monospace;color:var(--primary);font-size:13.5px;">${row.item_code}</strong>`;
|
|
tr.appendChild(codeTd);
|
|
|
|
const nameTd = document.createElement('td');
|
|
nameTd.innerHTML = `<strong>${row.name}</strong>`;
|
|
tr.appendChild(nameTd);
|
|
|
|
const catTd = document.createElement('td');
|
|
catTd.innerHTML = `<span class="tag ${row.category ? 'insheet' : 'staff'}">${row.category || 'General Medicine'}</span>`;
|
|
tr.appendChild(catTd);
|
|
|
|
const upTd = document.createElement('td');
|
|
upTd.style.color = 'var(--text-muted)';
|
|
upTd.style.fontSize = '12px';
|
|
upTd.textContent = (row.updated_at || row.created_at || '').slice(0, 10) || 'Active';
|
|
tr.appendChild(upTd);
|
|
|
|
const actTd = document.createElement('td');
|
|
actTd.style.textAlign = 'right';
|
|
actTd.innerHTML = `
|
|
<button class="btn btn-secondary btn-sm" onclick='openEditCodeModal(${JSON.stringify(row)})'>Edit</button>
|
|
<button class="btn btn-danger btn-sm" onclick="deleteCatalogEntry(${row.id}, '${row.item_code}')">Delete</button>
|
|
`;
|
|
tr.appendChild(actTd);
|
|
|
|
return tr;
|
|
}
|
|
|
|
function openAddCodeModal() {
|
|
document.getElementById('codeModalId').value = '';
|
|
document.getElementById('codeModalHeader').textContent = 'Add Item Code';
|
|
document.getElementById('codeItemCode').value = '';
|
|
document.getElementById('codeName').value = '';
|
|
document.getElementById('codeCategory').value = '';
|
|
document.getElementById('codeModal').classList.add('active');
|
|
}
|
|
|
|
function openEditCodeModal(row) {
|
|
document.getElementById('codeModalId').value = row.id;
|
|
document.getElementById('codeModalHeader').textContent = 'Edit Item Code: ' + row.item_code;
|
|
document.getElementById('codeItemCode').value = row.item_code;
|
|
document.getElementById('codeName').value = row.name;
|
|
document.getElementById('codeCategory').value = row.category || '';
|
|
document.getElementById('codeModal').classList.add('active');
|
|
}
|
|
|
|
function closeCodeModal() {
|
|
document.getElementById('codeModal').classList.remove('active');
|
|
}
|
|
|
|
async function submitCodeForm(event) {
|
|
event.preventDefault();
|
|
const id = document.getElementById('codeModalId').value;
|
|
const payload = {
|
|
item_code: document.getElementById('codeItemCode').value.trim(),
|
|
name: document.getElementById('codeName').value.trim(),
|
|
category: document.getElementById('codeCategory').value.trim(),
|
|
};
|
|
|
|
try {
|
|
const res = await fetch(id ? `/api/catalog/${id}` : '/api/catalog', {
|
|
method: id ? 'PUT' : 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload)
|
|
});
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
showCatalogAlert(data.message, 'success');
|
|
closeCodeModal();
|
|
loadCategoryOptions();
|
|
loadCatalog(false);
|
|
} else {
|
|
alert(data.message || 'Failed to save item code');
|
|
}
|
|
} catch (e) {
|
|
alert('Network error saving item code');
|
|
}
|
|
}
|
|
|
|
async function deleteCatalogEntry(id, code) {
|
|
if (!confirm(`Delete item code "${code}" from Drug Master Catalog?`)) return;
|
|
try {
|
|
const res = await fetch(`/api/catalog/${id}`, { method: 'DELETE' });
|
|
const data = await res.json();
|
|
if (data.success) {
|
|
showCatalogAlert(data.message, 'success');
|
|
loadCatalog(false);
|
|
} else {
|
|
alert(data.message || 'Failed to delete item code');
|
|
}
|
|
} catch (e) {
|
|
alert('Network error deleting item code');
|
|
}
|
|
}
|
|
|
|
function showCatalogAlert(msg, type) {
|
|
const box = document.getElementById('catalogAlertBox');
|
|
box.className = `alert-box ${type}`;
|
|
box.textContent = msg;
|
|
setTimeout(() => { box.className = 'alert-box'; }, 4000);
|
|
}
|
|
|
|
// ============================================================
|
|
// QUALITY & REVIEW
|
|
// ============================================================
|
|
|
|
async function loadQualityStats() {
|
|
try {
|
|
const res = await fetch('/api/admin/quality-stats');
|
|
const result = await res.json();
|
|
if (!result.success) return;
|
|
const d = result.data;
|
|
|
|
const grid = document.getElementById('qualitySummaryGrid');
|
|
grid.replaceChildren();
|
|
[
|
|
['Total Master Codes', d.catalog_total_codes],
|
|
['Drug Categories', d.catalog_by_category.length],
|
|
['Total Items Processed', d.total_items],
|
|
['Reconciliation Rate', d.completion_pct + '%'],
|
|
['Direct Auto-Matched', d.items_auto_matched],
|
|
['Missing Item Code', d.items_missing],
|
|
].forEach(([label, value]) => {
|
|
const card = document.createElement('div');
|
|
card.className = 'summary-card';
|
|
card.innerHTML = `<div class="summary-label"></div><div class="summary-value"></div>`;
|
|
card.querySelector('.summary-label').textContent = label;
|
|
card.querySelector('.summary-value').textContent = value;
|
|
grid.appendChild(card);
|
|
});
|
|
|
|
const catBody = document.getElementById('categoryStatsBody');
|
|
catBody.replaceChildren();
|
|
d.catalog_by_category.forEach(c => {
|
|
const tr = document.createElement('tr');
|
|
const tdCat = document.createElement('td'); tdCat.textContent = c.category;
|
|
const tdCount = document.createElement('td'); tdCount.className = 'num'; tdCount.textContent = c.count;
|
|
tr.appendChild(tdCat); tr.appendChild(tdCount);
|
|
catBody.appendChild(tr);
|
|
});
|
|
} catch (e) { /* silent */ }
|
|
}
|
|
|
|
async function loadItemsToReview() {
|
|
try {
|
|
const res = await fetch('/api/admin/items-to-review?limit=100');
|
|
const result = await res.json();
|
|
if (!result.success) return;
|
|
|
|
const tbody = document.getElementById('reviewTableBody');
|
|
tbody.replaceChildren();
|
|
result.data.forEach(item => {
|
|
const tr = document.createElement('tr');
|
|
[item.description || '-', item.username, item.filename || '-', (item.created_at || '').slice(0, 10)]
|
|
.forEach(val => {
|
|
const td = document.createElement('td');
|
|
td.textContent = val;
|
|
tr.appendChild(td);
|
|
});
|
|
tbody.appendChild(tr);
|
|
});
|
|
document.getElementById('reviewEmptyState').style.display = result.data.length === 0 ? 'block' : 'none';
|
|
} catch (e) { /* silent */ }
|
|
}
|
|
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|