Spaces:
Sleeping
Sleeping
Download templates/base.html from alisaleem97/NexLab_System: direct link, hf CLI and curl.
- Browser
- Download file 63.1 kB
-
https://huggingface.co/spaces/alisaleem97/NexLab_System/resolve/main/templates/base.html
- Command line
-
hf download hf://spaces/alisaleem97/NexLab_System/templates/base.html
-
curl -L -o base.html https://huggingface.co/spaces/alisaleem97/NexLab_System/resolve/main/templates/base.html
63.1 kB
<!-- templates/base.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Lab System{% endblock %}</title>
<!-- Tailwind CSS -->
<script src="/static/vendor/tailwind/tailwindcss.js"></script>
<!-- Google Fonts -->
<link href="/static/vendor/fonts/fonts.css" rel="stylesheet">
<style>
body { font-family: 'Inter', sans-serif; }
.sidebar-link:hover { background-color: rgba(255,255,255,0.1); }
.sidebar-link.active { background-color: #4f46e5; }
/* Submenu Styles */
.sidebar-submenu {
max-height: 0;
overflow: hidden;
transition: all 0.3s cubic-bezier(0, 1, 0, 1);
}
.sidebar-submenu.open {
max-height: 1000px;
transition: all 0.3s cubic-bezier(1, 0, 1, 0);
}
.chevron {
transition: transform 0.3s ease;
}
.chevron.rotate {
transform: rotate(180deg);
}
.submenu-item {
position: relative;
padding-left: 3rem !important;
}
.submenu-item::before {
content: '';
position: absolute;
left: 1.75rem;
top: 50%;
width: 4px;
height: 4px;
background: rgba(255,255,255,0.3);
border-radius: 50%;
transform: translateY(-50%);
}
.submenu-item.active::before {
background: #818cf8;
box-shadow: 0 0 8px #818cf8;
}
/* Custom Scrollbar for Sidebar */
.custom-scrollbar::-webkit-scrollbar {
width: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: rgba(255,255,255,0.05);
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.1);
border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
background: rgba(255,255,255,0.2);
}
/* Modal Styles */
.modal-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 1000;
justify-content: center;
align-items: center;
backdrop-filter: blur(4px);
}
.modal-overlay.active {
display: flex;
}
.modal-content {
background: white;
border-radius: 16px;
padding: 2rem;
max-width: 400px;
width: 90%;
text-align: center;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
animation: modalSlideIn 0.3s ease-out;
}
@keyframes modalSlideIn {
from {
opacity: 0;
transform: translateY(-50px) scale(0.9);
}
to {
opacity: 1;
transform: translateY(0) scale(1);
}
}
.modal-icon {
width: 80px;
height: 80px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 1.5rem;
}
.modal-icon.success {
background: #10b981;
color: white;
}
.modal-icon.error {
background: #ef4444;
color: white;
}
.modal-icon.warning {
background: #f59e0b;
color: white;
}
.modal-icon svg {
width: 40px;
height: 40px;
}
/* ─── Global Fixed-Size Table Styles ─────────────────────────────── */
/* Wrapper: horizontal scroll if content still overflows, but table
itself won't grow beyond the viewport/container width. */
.overflow-x-auto {
overflow-x: auto;
}
/* Make every data table fixed-layout so columns don't stretch to
fit content. Combined with overflow-x-auto on the wrapper this
keeps the table at a stable width while allowing a horizontal
scrollbar only when necessary. */
table {
table-layout: fixed;
width: 100%;
min-width: 600px; /* stay readable on narrow containers */
border-collapse: collapse;
}
/* All header cells: wrap text, consistent padding. */
table thead th {
white-space: normal !important;
word-break: break-word;
overflow-wrap: break-word;
vertical-align: bottom;
}
/* All body cells: allow text to wrap so rows expand vertically
instead of pushing the table wider. */
table tbody td {
white-space: normal !important;
word-break: break-word;
overflow-wrap: break-word;
vertical-align: top;
}
/* Default column width distribution – each column gets an equal
share. Individual pages can override with inline width/style on
<th> elements when they need custom proportions. */
table th,
table td {
max-width: 0; /* forces fixed-layout to honour table-layout:fixed */
}
/* ──────────────────────────────────────────────────────────────── */
/* ─── Range Hover Tooltip ─────────────────────────────────────── */
.range-hover-wrapper {
position: relative;
display: inline-block;
}
.range-hover-btn {
background: #64748b;
color: #fff;
border: none;
padding: 2px 10px;
border-radius: 6px;
font-size: 11px;
font-weight: 700;
cursor: default;
letter-spacing: 0.3px;
transition: background 0.2s;
}
.range-hover-wrapper:hover .range-hover-btn {
background: #3b82f6;
}
.range-hover-bubble {
display: none;
position: fixed;
background: #fef3c7;
color: #92400e;
border: 1px solid #fcd34d;
border-radius: 10px;
padding: 10px 16px;
font-size: 12px;
font-weight: 600;
white-space: normal;
word-break: break-word;
width: max-content;
max-width: 320px;
min-width: 120px;
text-align: center;
line-height: 1.5;
z-index: 9999;
box-shadow: 0 4px 16px rgba(0,0,0,0.15);
pointer-events: none;
}
.range-hover-bubble::after {
content: '';
position: absolute;
top: 100%;
left: 50%;
transform: translateX(-50%);
border: 6px solid transparent;
border-top-color: #fcd34d;
}
/* ──────────────────────────────────────────────────────────────── */
</style>
<script>
/* Range hover tooltip positioning — uses position:fixed so the
bubble escapes any overflow:hidden / overflow:auto ancestor. */
document.addEventListener('mouseenter', function(e) {
const wrapper = e.target.closest('.range-hover-wrapper');
if (!wrapper) return;
const bubble = wrapper.querySelector('.range-hover-bubble');
if (!bubble) return;
const rect = wrapper.getBoundingClientRect();
bubble.style.display = 'block';
/* Position above the button, centered */
const bubbleRect = bubble.getBoundingClientRect();
let left = rect.left + rect.width / 2 - bubbleRect.width / 2;
let top = rect.top - bubbleRect.height - 8;
/* Keep within viewport */
if (left < 4) left = 4;
if (left + bubbleRect.width > window.innerWidth - 4) left = window.innerWidth - bubbleRect.width - 4;
if (top < 4) top = rect.bottom + 8; /* flip below if no room above */
bubble.style.left = left + 'px';
bubble.style.top = top + 'px';
}, true);
document.addEventListener('mouseleave', function(e) {
const wrapper = e.target.closest('.range-hover-wrapper');
if (!wrapper) return;
const bubble = wrapper.querySelector('.range-hover-bubble');
if (bubble) bubble.style.display = 'none';
}, true);
</script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#4f46e5',
secondary: '#1e293b',
accent: '#818cf8',
background: '#f3f4f6'
}
}
}
}
</script>
</head>
<body class="bg-background text-slate-800">
<div class="flex h-screen overflow-hidden">
<!-- Sidebar Overlay (Mobile) -->
<div id="sidebarOverlay" class="fixed inset-0 bg-black bg-opacity-50 z-40 hidden lg:hidden transition-opacity duration-300" onclick="toggleSidebar()"></div>
<!-- Sidebar -->
<aside id="sidebar" class="fixed inset-y-0 left-0 z-50 w-64 bg-secondary text-white flex flex-col shadow-xl transform -translate-x-full lg:static lg:translate-x-0 transition-transform duration-300 ease-in-out">
<div class="h-16 flex items-center justify-between border-b border-slate-700 px-4">
<h1 class="text-xl font-bold tracking-wider">🔬 <span class="text-accent">NEX</span>LAB</h1>
<button onclick="toggleSidebar()" class="lg:hidden text-slate-400 hover:text-white focus:outline-none">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>
</button>
</div>
<nav class="flex-1 overflow-y-auto py-4 custom-scrollbar">
<!-- Main -->
<ul class="space-y-1">
{% if has_page('dashboard') %}
<li>
<a href="/" class="sidebar-link flex items-center px-6 py-3 transition-colors {% if request.url.path == '/' %}active{% endif %}">
<svg class="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"></path></svg>
Dashboard
</a>
</li>
{% endif %}
</ul>
<!-- Patient Management -->
{% if has_page('patient_registration') or has_page('patients') or has_page('deleted_patients') or has_page('deleted_tests') or has_page('patient_history') or has_page('patient_status') %}
<div class="mt-4">
<button onclick="toggleSubMenu('patientMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"></path></svg>
<span class="text-sm font-medium">Patient Management</span>
</div>
<svg id="patientMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="patientMenu" class="sidebar-submenu space-y-1">
{% if has_page('patient_registration') %}<li>
<a href="/patient-registration" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/patient-registration' %}active{% endif %}">
Patient Registration
</a>
</li>{% endif %}
{% if has_page('patients') %}<li>
<a href="/patients" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/patients' or request.url.path.startswith('/patients/edit') %}active{% endif %}">
Patients
</a>
</li>{% endif %}
{% if has_page('deleted_patients') %}<li>
<a href="/patients/deleted" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path.startswith('/patients/deleted') or request.url.path.startswith('/patients/view-deleted') %}active{% endif %}">
Deleted Patients
</a>
</li>{% endif %}
{% if has_page('deleted_tests') %}<li>
<a href="/deleted_tests_page" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path.startswith('/deleted_tests') %}active{% endif %}">
Deleted Tests
</a>
</li>{% endif %}
{% if has_page('patient_history') %}<li>
<a href="/patient-history" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path.startswith('/patient-history') %}active{% endif %}">
Patient History
</a>
</li>{% endif %}
{% if has_page('patient_status') %}<li>
<a href="/patient-status" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path.startswith('/patient-status') %}active{% endif %}">
Patient Status
</a>
</li>{% endif %}
</ul>
</div>
{% endif %}
<!-- Results -->
{% if has_page('result_entry') or has_page('double_auth') or has_page('no_sample') %}
<div class="mt-2">
<button onclick="toggleSubMenu('resultsMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path></svg>
<span class="text-sm font-medium">Results</span>
</div>
<svg id="resultsMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="resultsMenu" class="sidebar-submenu space-y-1">
{% if has_page('result_entry') %}<li>
<a href="/result-entry" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path.startswith('/result-entry') %}active{% endif %}">
Result Entry
</a>
</li>{% endif %}
{% if has_page('double_auth') %}<li>
<a href="/double-auth" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path.startswith('/double-auth') %}active{% endif %}">
Double Authorisation
</a>
</li>{% endif %}
{% if has_page('no_sample') %}<li>
<a href="/no-sample" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path.startswith('/no-sample') %}active{% endif %}">
No Sample
</a>
</li>{% endif %}
</ul>
</div>
{% endif %}
<!-- Printing & Design -->
{% if has_page('print_barcode') or has_page('barcode_designer') or has_page('print_receipt') or has_page('receipt_designer') or has_page('print_results') or has_page('call_centre') or has_page('result_designer') %}
<div class="mt-2">
<button onclick="toggleSubMenu('printMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 17h2.457a2 2 0 001.414-.586l.007-.007a2 2 0 000-2.828L12 4.685 3.121 13.565a2 2 0 000 2.828l.007.007a2 2 0 001.414.586H7m10 0a2 2 0 012 2v2a2 2 0 01-2 2H7a2 2 0 01-2-2v-2a2 2 0 012-2m10 0V7a3 3 0 00-3-3h-4a3 3 0 00-3 3v10"></path></svg>
<span class="text-sm font-medium">Printing & Design</span>
</div>
<svg id="printMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="printMenu" class="sidebar-submenu space-y-1">
{% if has_page('print_barcode') %}<li>
<a href="/print-barcode" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/print-barcode' %}active{% endif %}">
Print Barcode
</a>
</li>{% endif %}
{% if has_page('barcode_designer') %}<li>
<a href="/print-barcode-designer" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/print-barcode-designer' %}active{% endif %}">
Barcode Designer
</a>
</li>{% endif %}
{% if has_page('print_receipt') %}<li>
<a href="/print-receipt" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/print-receipt' %}active{% endif %}">
Print Receipt
</a>
</li>{% endif %}
{% if has_page('receipt_designer') %}<li>
<a href="/print-receipt-designer" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/print-receipt-designer' %}active{% endif %}">
Receipt Designer
</a>
</li>{% endif %}
{% if has_page('print_results') %}<li>
<a href="/print-results" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/print-results' %}active{% endif %}">
Print Results
</a>
</li>{% endif %}
{% if has_page('call_centre') %}<li>
<a href="/call-centre" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/call-centre' %}active{% endif %}">
Call Centre
</a>
</li>{% endif %}
{% if has_page('result_designer') %}<li>
<a href="/print-result-designer" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/print-result-designer' %}active{% endif %}">
Result Designer
</a>
</li>{% endif %}
</ul>
</div>
{% endif %}
<!-- Lab Setup -->
{% if has_page('departments') or has_page('sample_types') or has_page('devices') or has_page('parameters') or has_page('report_notes') %}
<div class="mt-2">
<button onclick="toggleSubMenu('setupMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>
<span class="text-sm font-medium">Lab Setup</span>
</div>
<svg id="setupMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="setupMenu" class="sidebar-submenu space-y-1">
{% if has_page('departments') %}<li>
<a href="/departments" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/departments' %}active{% endif %}">
Departments
</a>
</li>{% endif %}
{% if has_page('sample_types') %}<li>
<a href="/sample-types" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/sample-types' %}active{% endif %}">
Sample Types
</a>
</li>{% endif %}
{% if has_page('devices') %}<li>
<a href="/devices" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/devices' %}active{% endif %}">
Devices
</a>
</li>{% endif %}
{% if has_page('parameters') %}<li>
<a href="/parameters" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/parameters' %}active{% endif %}">
Parameters
</a>
</li>{% endif %}
{% if has_page('report_notes') %}<li>
<a href="/report-notes" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/report-notes' %}active{% endif %}">
Report Notes
</a>
</li>{% endif %}
{% if has_page('supplies') %}<li>
<a href="/supplies" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/supplies' %}active{% endif %}">
Supplies
</a>
</li>{% endif %}
{% if has_page('inventory') %}<li>
<a href="/inventory" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/inventory' %}active{% endif %}">
Inventory
</a>
</li>{% endif %}
{% if has_page('inventory') or has_page('tests') %}<li>
<a href="/cal-control" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/cal-control' %}active{% endif %}">
Cal & Control
</a>
</li>{% endif %}
</ul>
</div>
{% endif %}
<!-- Tests & Packages -->
{% if has_page('tests') or has_page('formulas') or has_page('test_ranges') or has_page('test_result_types') or has_page('packages') %}
<div class="mt-2">
<button onclick="toggleSubMenu('testsMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path></svg>
<span class="text-sm font-medium">Tests & Packages</span>
</div>
<svg id="testsMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="testsMenu" class="sidebar-submenu space-y-1">
{% if has_page('tests') %}<li>
<a href="/tests" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/tests' %}active{% endif %}">
Tests
</a>
</li>{% endif %}
{% if has_page('formulas') %}<li>
<a href="/formulas" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/formulas' %}active{% endif %}">
Formulas
</a>
</li>{% endif %}
{% if has_page('test_ranges') %}<li>
<a href="/test-ranges" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/test-ranges' %}active{% endif %}">
Test Ranges
</a>
</li>{% endif %}
{% if has_page('test_result_types') %}<li>
<a href="/test-result-types" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/test-result-types' %}active{% endif %}">
Result Types
</a>
</li>{% endif %}
{% if has_page('packages') %}<li>
<a href="/packages" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/packages' %}active{% endif %}">
Packages
</a>
</li>{% endif %}
</ul>
</div>
{% endif %}
<!-- Financials -->
{% if has_page('expenses_types') or has_page('expenses_entry') %}
<div class="mt-2">
<button onclick="toggleSubMenu('financialsMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<span class="text-sm font-medium">Financials</span>
</div>
<svg id="financialsMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="financialsMenu" class="sidebar-submenu space-y-1">
{% if has_page('expenses_types') %}<li>
<a href="/expenses-types" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/expenses-types' %}active{% endif %}">
Expenses Types
</a>
</li>{% endif %}
{% if has_page('expenses_entry') %}<li>
<a href="/expenses-entry" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/expenses-entry' %}active{% endif %}">
Expenses Entry
</a>
</li>{% endif %}
</ul>
</div>
{% endif %}
<!-- Reports -->
{% if has_page('detailed_income') or has_page('net_amounts') or has_page('payment_records') or has_page('patients_number') or has_page('patient_region') or has_page('tests_number') or has_page('discount_report') or has_page('expenses_report') or has_page('remain_report') %}
<div class="mt-2">
<button onclick="toggleSubMenu('reportsMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
<span class="text-sm font-medium">Reports</span>
</div>
<svg id="reportsMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="reportsMenu" class="sidebar-submenu space-y-1">
{% if has_page('discount_report') %}<li>
<a href="/reports/discount" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/reports/discount' %}active{% endif %}">
Discount Report
</a>
</li>{% endif %}
{% if has_page('detailed_income') %}<li>
<a href="/reports/detailed-income" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/reports/detailed-income' %}active{% endif %}">
Detailed Income
</a>
</li>{% endif %}
{% if has_page('net_amounts') %}<li>
<a href="/reports/net-amounts" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/reports/net-amounts' %}active{% endif %}">
Net Amounts
</a>
</li>{% endif %}
{% if has_page('payment_records') %}<li>
<a href="/reports/payment-records" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/reports/payment-records' %}active{% endif %}">
Payment Records
</a>
</li>{% endif %}
{% if has_page('patients_number') %}<li>
<a href="/reports/patients-number" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/reports/patients-number' %}active{% endif %}">
Patients Number
</a>
</li>{% endif %}
{% if has_page('patient_region') %}<li>
<a href="/reports/patient-region" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/reports/patient-region' %}active{% endif %}">
Patient Region
</a>
</li>{% endif %}
{% if has_page('tests_number') %}<li>
<a href="/reports/tests-number" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/reports/tests-number' %}active{% endif %}">
Test Number
</a>
</li>{% endif %}
{% if has_page('expenses_report') %}<li>
<a href="/reports/expenses" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/reports/expenses' %}active{% endif %}">
Expenses Report
</a>
</li>{% endif %}
{% if has_page('remain_report') %}<li>
<a href="/reports/remain" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/reports/remain' %}active{% endif %}">
Remain
</a>
</li>{% endif %}
</ul>
</div>
{% endif %}
<!-- Geography & Partners -->
{% if has_page('partners') or has_page('provinces') or has_page('regions') %}
<div class="mt-2">
<button onclick="toggleSubMenu('geoMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>
<span class="text-sm font-medium">Geography & Partners</span>
</div>
<svg id="geoMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="geoMenu" class="sidebar-submenu space-y-1">
{% if has_page('partners') %}<li>
<a href="/partners" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/partners' %}active{% endif %}">
Partners
</a>
</li>{% endif %}
{% if has_page('provinces') %}<li>
<a href="/provinces" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/provinces' %}active{% endif %}">
Provinces
</a>
</li>{% endif %}
{% if has_page('regions') %}<li>
<a href="/regions" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/regions' %}active{% endif %}">
Regions
</a>
</li>{% endif %}
</ul>
</div>
{% endif %}
<!-- HR & Staff -->
<div class="mt-2">
<button onclick="toggleSubMenu('hrMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z"></path></svg>
<span class="text-sm font-medium">HR & Staff</span>
</div>
<svg id="hrMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="hrMenu" class="sidebar-submenu space-y-1">
<li>
<a href="/hr" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path.startswith('/hr') %}active{% endif %}">
Employees
</a>
</li>
</ul>
</div>
<!-- Settings -->
{% if has_page('lab_info') or has_page('user_management') or has_page('activity_logs') %}
<div class="mt-2">
<button onclick="toggleSubMenu('settingsMenu')" class="w-full flex items-center justify-between px-6 py-3 text-slate-300 hover:text-white hover:bg-slate-800 transition-all group">
<div class="flex items-center">
<svg class="w-5 h-5 mr-3 text-slate-400 group-hover:text-accent transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>
<span class="text-sm font-medium">Settings</span>
</div>
<svg id="settingsMenu-chevron" class="w-4 h-4 chevron" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<ul id="settingsMenu" class="sidebar-submenu space-y-1">
{% if has_page('lab_info') %}<li>
<a href="/lab-info" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/lab-info' %}active{% endif %}">
Lab Info
</a>
</li>{% endif %}
{% if has_page('user_management') %}<li>
<a href="/users" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/users' %}active{% endif %}">
User Management
</a>
</li>{% endif %}
{% if has_page('activity_logs') %}<li>
<a href="/activity-logs" class="sidebar-link flex items-center px-6 py-3 submenu-item transition-colors {% if request.url.path == '/activity-logs' %}active{% endif %}">
Activity Logs
</a>
</li>{% endif %}
</ul>
</div>
{% endif %}
</nav>
<div class="p-4 border-t border-slate-700">
<a href="/logout" class="flex items-center px-4 py-2 text-red-400 hover:text-red-300 transition-colors">
<svg class="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"></path></svg>
Logout
</a>
</div>
</aside>
<!-- Main Content -->
<div class="flex-1 flex flex-col overflow-hidden">
<!-- Topbar -->
<header class="h-16 bg-white shadow-sm flex items-center justify-between px-4 lg:px-6 z-10 relative">
<div class="flex items-center">
<button id="sidebarToggle" onclick="toggleSidebar()" class="text-slate-500 hover:text-slate-700 focus:outline-none lg:hidden mr-3">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path></svg>
</button>
<h2 class="text-base lg:text-lg font-semibold text-slate-700 truncate max-w-[120px] sm:max-w-[200px] md:max-w-none">{% block page_title %}Dashboard{% endblock %}</h2>
</div>
<!-- Center: Lab Name -->
<div class="absolute left-1/2 -translate-x-1/2 hidden md:block">
{% if global_lab_name %}
<div class="bg-indigo-600 text-white px-5 py-1.5 rounded-lg text-sm font-bold tracking-wide shadow-sm border border-indigo-700 whitespace-nowrap">
🔬 {{ global_lab_name }}
</div>
{% endif %}
</div>
<div class="flex items-center space-x-4">
<!-- Chat Widget Toggle -->
{% if current_user %}
<button onclick="toggleChatWidget()" class="relative p-2 text-slate-500 hover:text-primary transition-colors focus:outline-none" title="Messages">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"></path></svg>
<span id="globalUnreadBadge" class="absolute top-0 right-0 inline-flex items-center justify-center px-1.5 py-0.5 text-[10px] font-bold leading-none text-white bg-red-500 rounded-full hidden border-2 border-white shadow-sm transform translate-x-1 -translate-y-1">0</span>
</button>
{% endif %}
<div class="flex items-center space-x-2 border-l border-slate-200 pl-4">
<div class="w-8 h-8 rounded-full bg-primary text-white flex items-center justify-center font-bold">{{ current_user.full_name[0]|upper if current_user else 'A' }}</div>
<span class="text-sm font-medium text-slate-600">{{ current_user.full_name if current_user else 'Admin' }}</span>
</div>
</div>
</header>
<!-- Page Content -->
<main class="flex-1 overflow-x-hidden overflow-y-auto bg-background p-4 lg:p-6">
{% block content %}{% endblock %}
</main>
</div>
</div>
<!-- Modal Popup -->
<div id="modalOverlay" class="modal-overlay">
<div class="modal-content">
<div id="modalIcon" class="modal-icon success">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
</svg>
</div>
<h3 id="modalTitle" class="text-2xl font-bold mb-2">Success!</h3>
<p id="modalMessage" class="text-slate-600 mb-6">Operation completed successfully.</p>
<button id="modalButton" onclick="closeModal()" class="w-full py-3 px-4 rounded-lg font-medium transition duration-200">
Continue
</button>
</div>
</div>
<!-- Confirmation Modal -->
<div id="confirmModalOverlay" class="modal-overlay">
<div class="modal-content">
<div class="modal-icon warning">
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
</svg>
</div>
<h3 class="text-2xl font-bold mb-2 text-slate-800">Confirm Delete</h3>
<p id="confirmMessage" class="text-slate-600 mb-6">Are you sure you want to delete this item? This action cannot be undone.</p>
<div class="flex gap-3">
<button id="confirmCancel" onclick="closeConfirmModal()" class="flex-1 py-3 px-4 rounded-lg font-medium transition duration-200 bg-slate-200 text-slate-700 hover:bg-slate-300">
Cancel
</button>
<button id="confirmConfirm" class="flex-1 py-3 px-4 rounded-lg font-medium transition duration-200 bg-red-600 text-white hover:bg-red-700">
Delete
</button>
</div>
</div>
</div>
<script>
// Sidebar Toggle
function toggleSidebar() {
const sidebar = document.getElementById('sidebar');
const overlay = document.getElementById('sidebarOverlay');
const isClosed = sidebar.classList.contains('-translate-x-full');
if (isClosed) {
sidebar.classList.remove('-translate-x-full');
overlay.classList.remove('hidden');
document.body.style.overflow = 'hidden'; // Prevent background scroll
} else {
sidebar.classList.add('-translate-x-full');
overlay.classList.add('hidden');
document.body.style.overflow = '';
}
}
// Close sidebar on escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && !document.getElementById('sidebar').classList.contains('-translate-x-full')) {
toggleSidebar();
}
});
// Modal Functions
function showModal(type, title, message, callback = null) {
const overlay = document.getElementById('modalOverlay');
const icon = document.getElementById('modalIcon');
const titleEl = document.getElementById('modalTitle');
const messageEl = document.getElementById('modalMessage');
const button = document.getElementById('modalButton');
icon.className = 'modal-icon ' + type;
if (type === 'success') {
button.className = 'w-full py-3 px-4 rounded-lg font-medium transition duration-200 bg-green-600 text-white hover:bg-green-700';
icon.innerHTML = '<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>';
} else if (type === 'error') {
button.className = 'w-full py-3 px-4 rounded-lg font-medium transition duration-200 bg-red-600 text-white hover:bg-red-700';
icon.innerHTML = '<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>';
}
titleEl.textContent = title;
messageEl.textContent = message;
overlay.classList.add('active');
if (callback) {
button.onclick = function() {
closeModal();
callback();
};
} else {
button.onclick = closeModal;
}
}
function closeModal() {
document.getElementById('modalOverlay').classList.remove('active');
}
function showConfirmModal(message, onConfirm) {
const overlay = document.getElementById('confirmModalOverlay');
const messageEl = document.getElementById('confirmMessage');
const confirmBtn = document.getElementById('confirmConfirm');
const cancelBtn = document.getElementById('confirmCancel');
messageEl.textContent = message;
overlay.classList.add('active');
confirmBtn.onclick = function() {
closeConfirmModal();
if (onConfirm) onConfirm();
};
cancelBtn.onclick = closeConfirmModal;
}
function closeConfirmModal() {
document.getElementById('confirmModalOverlay').classList.remove('active');
}
// Check for URL parameters on page load
window.addEventListener('DOMContentLoaded', function() {
const urlParams = new URLSearchParams(window.location.search);
const success = urlParams.get('success');
const error = urlParams.get('error');
if (success) {
showModal('success', 'Success!', decodeURIComponent(success));
window.history.replaceState({}, document.title, window.location.pathname);
} else if (error) {
showModal('error', 'Error!', decodeURIComponent(error));
window.history.replaceState({}, document.title, window.location.pathname);
}
});
// Replace confirm() with modal
function confirmDelete(url) {
showConfirmModal('Are you sure you want to delete this item? This action cannot be undone.', function() {
var form = document.createElement('form');
form.method = 'POST';
form.action = url;
form.style.display = 'none';
document.body.appendChild(form);
form.submit();
});
}
</script>
<!-- Sidebar Scripts -->
<script>
function toggleSidebar() {
const sidebar = document.getElementById('sidebar');
const overlay = document.getElementById('sidebarOverlay');
sidebar.classList.toggle('-translate-x-full');
overlay.classList.toggle('hidden');
}
function toggleSubMenu(id) {
const menu = document.getElementById(id);
const chevron = document.getElementById(id + '-chevron');
if (menu) menu.classList.toggle('open');
if (chevron) chevron.classList.toggle('rotate');
}
document.addEventListener('DOMContentLoaded', () => {
// Auto-expand active menu
const activeLink = document.querySelector('.sidebar-link.active');
if (activeLink) {
const subMenu = activeLink.closest('.sidebar-submenu');
if (subMenu) {
subMenu.classList.add('open');
const chevron = document.getElementById(subMenu.id + '-chevron');
if (chevron) chevron.classList.add('rotate');
}
}
// Escape to close sidebar
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
const sidebar = document.getElementById('sidebar');
if (sidebar && !sidebar.classList.contains('-translate-x-full')) {
toggleSidebar();
}
}
});
});
</script>
<!-- Excel Export Utils -->
<script>
function exportTableToExcel(btnElement) {
let table = btnElement.closest('table');
if (!table) return;
// Get a filename context from the h2 or default
let titleEl = document.querySelector('h2');
let baseName = titleEl ? titleEl.innerText.trim().replace(/[^a-zA-Z0-9\u0600-\u06FF\s_]/g, '') : 'Export';
let filename = baseName.replace(/\s+/g, '_') + '.xls';
let clonedTable = table.cloneNode(true);
// Remove elements not needed in Excel (e.g. actions dropdowns, icons, no-excel)
clonedTable.querySelectorAll('.no-excel, button, input:not([type="text"]), i, a, svg').forEach(el => el.remove());
// Handle text inputs appropriately
clonedTable.querySelectorAll('input[type="text"]').forEach(el => {
let parent = el.parentNode;
parent.innerText = el.value || '';
});
// Convert to Excel HTML
let html = clonedTable.outerHTML;
let dataType = 'application/vnd.ms-excel';
// HTML wrapper with meta charset for correct Arabic UTF-8 Encoding
let tableHtml = `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
<head><meta charset="utf-8"/></head><body>${html}</body></html>`;
let downloadLink = document.createElement("a");
document.body.appendChild(downloadLink);
if (navigator.msSaveOrOpenBlob) {
let blob = new Blob(['\ufeff', tableHtml], { type: dataType });
navigator.msSaveOrOpenBlob(blob, filename);
} else {
// btoa + unescape + encodeURIComponent trick for full UTF-8 base64 encoding support
downloadLink.href = 'data:' + dataType + ';base64,' + btoa(unescape(encodeURIComponent(tableHtml)));
downloadLink.download = filename;
downloadLink.click();
}
document.body.removeChild(downloadLink);
}
document.addEventListener('DOMContentLoaded', function() {
const currentPath = window.location.pathname;
// Exclude logic
let isExcluded = false;
const startsWithExcludes = [
'/patient-registration',
'/result-entry',
'/double-auth',
'/call-centre',
'/patient-history',
'/users',
'/activity-logs',
'/no-sample',
'/print',
'/view-results',
'/patient-status',
'/view-call-centre'
];
if (startsWithExcludes.some(p => currentPath.startsWith(p))) {
isExcluded = true;
}
if (currentPath === '/patients' || currentPath.startsWith('/patients/edit')) {
isExcluded = true;
}
if (!isExcluded) {
document.querySelectorAll('table').forEach((table) => {
let theadTr = table.querySelector('thead tr');
if (!theadTr) return;
let lastTh = theadTr.lastElementChild;
if (lastTh && lastTh.tagName === 'TH') {
let btn = document.createElement('button');
btn.className = 'absolute right-2 top-1/2 -translate-y-1/2 bg-blue-500 hover:bg-blue-600 text-white shadow-sm flex items-center justify-center w-7 h-7 rounded no-excel transition-transform hover:scale-105 active:scale-95 z-10';
btn.innerHTML = `<svg class="w-4 h-4 text-white pointer-events-none" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path></svg>`;
btn.title = 'Download Table to Excel';
btn.type = 'button';
btn.onclick = function(e) {
e.stopPropagation();
e.preventDefault();
exportTableToExcel(this);
};
lastTh.style.position = 'relative'; // Ensure button correctly pins to TH bounds
// Prevent overlap with actual column text padding
const paddingRight = parseFloat(window.getComputedStyle(lastTh).paddingRight);
if (paddingRight < 36) {
lastTh.style.paddingRight = '36px';
}
lastTh.appendChild(btn);
}
});
}
});
</script>
{% block scripts %}{% endblock %}
{% if current_user %}
{% include 'chat_widget.html' %}
{% endif %}
</body>
</html>
<!-- templates/base.html -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}Lab System{% endblock %}</title>
<!-- Tailwind CSS -->
<script src="/static/vendor/tailwind/tailwindcss.js"></script>
<!-- Google Fonts -->
<link href="/static/vendor/fonts/fonts.css" rel="stylesheet">
<style>
body { font-family: 'Inter', sans-serif; }
.sidebar-link:hover { background-color: rgba(255,255,255,0.1); }
.sidebar-link.active { background-color: #4f46e5; }
/* Submenu Styles */
.sidebar-submenu {
max-height: 0;
overflow: hidden;
transition: all 0.3s cubic-bezier(0, 1, 0, 1);
}
.sidebar-submenu.open {
max-height: 1000px;
transition: all 0.3s cubic-bezier(1, 0, 1, 0);
}
.chevron {
transition: transform 0.3s ease;
}
.chevron.rotate {
transform: rotate(180deg);
}
.submenu-item {
position: relative;
padding-left: 3rem ;
}
.submenu-item::before {
content: '';
position: absolute;
left: 1.75rem;
top: 50%;
width: 4px;
height: 4px;
background: rgba(255,255,255,0.3);
border-radius: 50%;
transform: translateY(-50%);
}
.submenu-item.active::before {
background: #818cf8;
box-shadow: 0 0 8px #818cf8;
}
/* Custom Scrollbar for Sidebar */
.custom-scrollbar::-webkit-scrollbar {
width: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: rgba(255,255,255,0.05);
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.1);
border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
background: rgba(255,255,255,0.2);
}
/* Modal Styles */
.modal-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 1000;
justify-content: center;
align-items: center;
backdrop-filter: blur(4px);
}
.modal-overlay.active {
display: flex;
}
.modal-content {
background: white;
border-radius: 16px;
padding: 2rem;
max-width: 400px;
width: 90%;
text-align: center;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
animation: modalSlideIn 0.3s ease-out;
}
@keyframes modalSlideIn {
from {
opacity: 0;
transform: translateY(-50px) scale(0.9);
}
to {