38960-vm/includes/layout/header.php
2026-03-17 08:22:39 +00:00

204 lines
15 KiB
PHP

<?php
require_once __DIR__ . '/../../db/config.php';
require_once __DIR__ . '/../../helpers.php';
$db = db();
$lang = $_SESSION['lang'];
$section = $section ?? 'dashboard';
$message = $message ?? '';
// Check for flash message in session
if (isset($_SESSION['flash_message'])) {
$message = $_SESSION['flash_message'];
unset($_SESSION['flash_message']);
}
// Fetch company settings for dynamic branding
$stmt = $db->query("SELECT setting_key, setting_value FROM settings WHERE setting_key IN ('company_name', 'company_logo', 'company_favicon')");
$site_settings = [];
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$site_settings[$row['setting_key']] = $row['setting_value'];
}
$site_name = !empty($site_settings['company_name']) ? $site_settings['company_name'] : __('hospital_management');
$site_logo = !empty($site_settings['company_logo']) ? $site_settings['company_logo'] : null;
$site_favicon = !empty($site_settings['company_favicon']) ? $site_settings['company_favicon'] : null;
?>
<!DOCTYPE html>
<html lang="<?php echo $_SESSION['lang']; ?>" dir="<?php echo get_dir(); ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo htmlspecialchars($site_name); ?></title>
<?php if ($site_favicon): ?>
<link rel="icon" type="image/x-icon" href="<?php echo htmlspecialchars($site_favicon); ?>">
<?php endif; ?>
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<?php if (is_rtl()): ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.rtl.min.css">
<?php endif; ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Tajawal:wght@400;500;700&display=swap" rel="stylesheet">
<!-- Select2 CSS -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" />
<!-- Summernote Lite CSS -->
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote-lite.min.css" rel="stylesheet">
<!-- Flatpickr CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<style>
body { font-family: 'Inter', 'Tajawal', sans-serif; background-color: #f4f7f6; }
.sidebar { min-height: 100vh; width: 250px; background-color: #002D62; color: white; transition: all 0.3s; flex-shrink: 0; }
.sidebar-link { color: #cfd8dc; text-decoration: none; padding: 12px 20px; display: block; border-left: 4px solid transparent; }
.sidebar-link:hover, .sidebar-link.active { background-color: #003a80; color: white; border-left-color: #4fc3f7; }
.sidebar-submenu { background-color: #001f44; padding-left: 20px; }
<?php if (is_rtl()): ?>
.sidebar-submenu { padding-left: 0; padding-right: 20px; }
<?php endif; ?>
.main-content { flex: 1; padding: 25px; min-width: 0; }
.card { border: none; border-radius: 8px; box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075); margin-bottom: 20px; }
.stat-card { padding: 20px; text-align: center; }
.stat-card i { font-size: 2.5rem; color: #0056b3; margin-bottom: 10px; }
.btn-primary { background-color: #0056b3; border-color: #0056b3; }
.table thead th { background-color: #f8f9fa; border-bottom: 2px solid #dee2e6; color: #495057; font-weight: 600; }
.navbar { background-color: white; border-bottom: 1px solid #e0e0e0; }
.card-header, .modal-header { background-color: #002D62 !important; color: white !important; border-bottom: none; }
.card-header .fw-bold, .modal-title { color: white !important; }
.modal-header .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
.card-header i { color: white !important; }
<?php if (is_rtl()): ?>
.sidebar-link { border-left: 0; border-right: 4px solid transparent; }
.sidebar-link:hover, .sidebar-link.active { border-right-color: #4fc3f7; }
<?php endif; ?>
/* Select2 custom styling to match Bootstrap 5 */
.select2-container--bootstrap-5 .select2-selection {
border: 1px solid #dee2e6;
border-radius: 0.375rem;
min-height: calc(1.5em + 0.75rem + 2px);
}
/* Summernote custom styling */
.note-editor.note-frame { border: 1px solid #dee2e6; border-radius: 0.375rem; }
.note-editor.note-airframe .note-editing-area .note-editable, .note-editor.note-frame .note-editing-area .note-editable { background-color: white; }
</style>
</head>
<body>
<div class="d-flex">
<!-- Sidebar -->
<div class="sidebar d-none d-md-block">
<div class="p-4 text-center">
<?php if ($site_logo): ?>
<img src="<?php echo htmlspecialchars($site_logo); ?>" alt="Logo" class="img-fluid mb-2" style="max-height: 50px;">
<?php else: ?>
<h5 class="fw-bold"><i class="bi bi-hospital"></i> <?php echo htmlspecialchars($site_name); ?></h5>
<?php endif; ?>
</div>
<nav class="mt-3">
<a href="dashboard.php" class="sidebar-link <?php echo $section === 'dashboard' ? 'active' : ''; ?>"><i class="bi bi-speedometer2 me-2"></i> <?php echo __('dashboard'); ?></a>
<a href="patients.php" class="sidebar-link <?php echo $section === 'patients' ? 'active' : ''; ?>"><i class="bi bi-people me-2"></i> <?php echo __('patients'); ?></a>
<a href="visits.php" class="sidebar-link <?php echo $section === 'visits' ? 'active' : ''; ?>"><i class="bi bi-clipboard2-pulse me-2"></i> <?php echo __('visits'); ?></a>
<a href="appointments.php" class="sidebar-link <?php echo $section === "appointments" ? "active" : ""; ?>"><i class="bi bi-calendar-event me-2"></i> <?php echo __("appointments"); ?></a>
<a href="home_visits.php" class="sidebar-link <?php echo $section === 'home_visits' ? 'active' : ''; ?>"><i class="bi bi-house-heart me-2"></i> <?php echo __('home_visits'); ?></a>
<a href="queue.php" class="sidebar-link <?php echo $section === 'queue' ? 'active' : ''; ?>"><i class="bi bi-list-ol me-2"></i> <?php echo __('queue_management'); ?></a>
<a href="#labSubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['laboratory_tests', 'test_groups', 'laboratory_inquiries']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
<span><i class="bi bi-prescription2 me-2"></i> <?php echo __('laboratory'); ?></span>
<i class="bi bi-chevron-down small"></i>
</a>
<div class="collapse <?php echo in_array($section, ['laboratory_tests', 'test_groups', 'laboratory_inquiries']) ? 'show' : ''; ?>" id="labSubmenu">
<div class="sidebar-submenu">
<a href="laboratory_tests.php" class="sidebar-link py-2 <?php echo $section === 'laboratory_tests' ? 'active' : ''; ?>"><i class="bi bi-list-check me-2"></i> <?php echo __('tests'); ?></a>
<a href="test_groups.php" class="sidebar-link py-2 <?php echo $section === 'test_groups' ? 'active' : ''; ?>"><i class="bi bi-collection me-2"></i> <?php echo __('test_groups'); ?></a>
<a href="laboratory_inquiries.php" class="sidebar-link py-2 <?php echo $section === 'laboratory_inquiries' ? 'active' : ''; ?>"><i class="bi bi-question-circle me-2"></i> <?php echo __('inquiries'); ?></a>
</div>
</div>
<!-- X-Ray Module -->
<a href="#xraySubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['xray_tests', 'xray_groups', 'xray_inquiries']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
<span><i class="bi bi-x-diamond me-2"></i> <?php echo __('xray'); ?></span>
<i class="bi bi-chevron-down small"></i>
</a>
<div class="collapse <?php echo in_array($section, ['xray_tests', 'xray_groups', 'xray_inquiries']) ? 'show' : ''; ?>" id="xraySubmenu">
<div class="sidebar-submenu">
<a href="xray_tests.php" class="sidebar-link py-2 <?php echo $section === 'xray_tests' ? 'active' : ''; ?>"><i class="bi bi-list-check me-2"></i> <?php echo __('tests'); ?></a>
<a href="xray_groups.php" class="sidebar-link py-2 <?php echo $section === 'xray_groups' ? 'active' : ''; ?>"><i class="bi bi-collection me-2"></i> <?php echo __('groups'); ?></a>
<a href="xray_inquiries.php" class="sidebar-link py-2 <?php echo $section === 'xray_inquiries' ? 'active' : ''; ?>"><i class="bi bi-question-circle me-2"></i> <?php echo __('inquiries'); ?></a>
</div>
</div>
<!-- Drugs Module -->
<a href="#drugsSubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['drugs', 'drugs_groups', 'suppliers']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
<span><i class="bi bi-capsule me-2"></i> <?php echo __('drugs'); ?></span>
<i class="bi bi-chevron-down small"></i>
</a>
<div class="collapse <?php echo in_array($section, ['drugs', 'drugs_groups', 'suppliers']) ? 'show' : ''; ?>" id="drugsSubmenu">
<div class="sidebar-submenu">
<a href="drugs.php" class="sidebar-link py-2 <?php echo $section === 'drugs' ? 'active' : ''; ?>"><i class="bi bi-list-check me-2"></i> <?php echo __('drugs'); ?></a>
<a href="drugs_groups.php" class="sidebar-link py-2 <?php echo $section === 'drugs_groups' ? 'active' : ''; ?>"><i class="bi bi-collection me-2"></i> <?php echo __('groups'); ?></a>
<a href="suppliers.php" class="sidebar-link py-2 <?php echo $section === 'suppliers' ? 'active' : ''; ?>"><i class="bi bi-truck me-2"></i> <?php echo __('suppliers'); ?></a>
</div>
</div>
<a href="billing.php" class="sidebar-link <?php echo $section === 'billing' ? 'active' : ''; ?>"><i class="bi bi-receipt me-2"></i> <?php echo __('billing'); ?></a>
<a href="insurance.php" class="sidebar-link <?php echo $section === 'insurance' ? 'active' : ''; ?>"><i class="bi bi-shield-check me-2"></i> <?php echo __('insurance'); ?></a>
<a href="doctors.php" class="sidebar-link <?php echo $section === 'doctors' ? 'active' : ''; ?>"><i class="bi bi-person-badge me-2"></i> <?php echo __('doctors'); ?></a>
<a href="doctor_holidays.php" class="sidebar-link <?php echo $section === 'doctor_holidays' ? 'active' : ''; ?>"><i class="bi bi-calendar-x me-2"></i> <?php echo __('doctor_holidays'); ?></a>
<a href="nurses.php" class="sidebar-link <?php echo $section === 'nurses' ? 'active' : ''; ?>"><i class="bi bi-person-heart me-2"></i> <?php echo __('nurses'); ?></a>
<a href="#settingsSubmenu" data-bs-toggle="collapse" class="sidebar-link <?php echo in_array($section, ['employees', 'positions', 'company_profile', 'cities', 'services', 'departments', 'queue_ads']) ? 'active' : ''; ?> d-flex justify-content-between align-items-center">
<span><i class="bi bi-gear me-2"></i> <?php echo __('settings'); ?></span>
<i class="bi bi-chevron-down small"></i>
</a>
<div class="collapse <?php echo in_array($section, ['employees', 'positions', 'company_profile', 'cities', 'services', 'departments', 'queue_ads']) ? 'show' : ''; ?>" id="settingsSubmenu">
<div class="sidebar-submenu">
<a href="settings.php" class="sidebar-link py-2 <?php echo $section === 'company_profile' ? 'active' : ''; ?>"><i class="bi bi-building me-2"></i> <?php echo __('company_profile'); ?></a>
<a href="employees.php" class="sidebar-link py-2 <?php echo $section === 'employees' ? 'active' : ''; ?>"><i class="bi bi-person-workspace me-2"></i> <?php echo __('employees'); ?></a>
<a href="positions.php" class="sidebar-link py-2 <?php echo $section === 'positions' ? 'active' : ''; ?>"><i class="bi bi-diagram-2 me-2"></i> <?php echo __('positions'); ?></a>
<a href="departments.php" class="sidebar-link py-2 <?php echo $section === 'departments' ? 'active' : ''; ?>"><i class="bi bi-diagram-3 me-2"></i> <?php echo __('departments'); ?></a>
<a href="hospital_services.php" class="sidebar-link py-2 <?php echo $section === 'services' ? 'active' : ''; ?>"><i class="bi bi-activity me-2"></i> <?php echo __('services'); ?></a>
<a href="cities.php" class="sidebar-link py-2 <?php echo $section === 'cities' ? 'active' : ''; ?>"><i class="bi bi-building me-2"></i> <?php echo __('cities'); ?></a>
<a href="queue_ads.php" class="sidebar-link py-2 <?php echo $section === 'queue_ads' ? 'active' : ''; ?>"><i class="bi bi-megaphone me-2"></i> <?php echo __('queue_ads'); ?></a>
</div>
</div>
</nav>
</div>
<!-- Main Content -->
<div class="main-content">
<!-- Top Navbar -->
<nav class="navbar navbar-expand-lg navbar-light mb-4 rounded shadow-sm px-3">
<div class="container-fluid p-0">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#topNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="topNav">
<div class="ms-auto d-flex align-items-center">
<a href="?lang=<?php echo get_lang_code(); ?>" class="btn btn-outline-secondary btn-sm me-3">
<i class="bi bi-translate"></i> <?php echo get_lang_name(); ?>
</a>
<div class="dropdown">
<a class="nav-link dropdown-toggle d-flex align-items-center" href="#" role="button" data-bs-dropdown="dropdown">
<img src="https://ui-avatars.com/api/?name=Admin&background=0056b3&color=fff" class="rounded-circle me-2" width="32" height="32">
<span>Admin</span>
</a>
<ul class="dropdown-menu dropdown-menu-end shadow border-0">
<li><a class="dropdown-item" href="#"><i class="bi bi-person me-2"></i> <?php echo __('profile'); ?></a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item text-danger" href="#"><i class="bi bi-box-arrow-right me-2"></i> <?php echo __('logout'); ?></a></li>
</ul>
</div>
</div>
</div>
</div>
</nav>
<?php if ($message): ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?php echo $message; ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php endif; ?>