<?php
$staff_name = '';
$staff_photo = '';
$staff_role = '';

if (isset($_SESSION['staff_id'])) {
    $staff_id = $_SESSION['staff_id'];

    $stmt = $conn->prepare("
        SELECT s.name, s.passport, r.role_name AS rolename
        FROM staff s
        JOIN role r ON s.role = r.id
        WHERE s.id = ?
        LIMIT 1
    ");
    
    $stmt->bind_param("i", $staff_id);
    $stmt->execute();
    $result = $stmt->get_result();

    if ($result && $result->num_rows > 0) {
        $staff = $result->fetch_assoc();
        $staff_name = $staff['name'] ?? '';
        $staff_photo = $staff['passport'] ?? '';
        $staff_role = $staff['rolename'] ?? '';
    }
}
?>


<?php
$stmt = $conn->query("SELECT school_name, school_logo, school_favicon FROM administratives LIMIT 1");
if ($stmt && $stmt->num_rows > 0) {
    $adminData = $stmt->fetch_assoc();
    $school_name = $adminData['school_name'] ?? 'CBT Admin Panel';
    $school_logo = !empty($adminData['school_logo']) ? $adminData['school_logo'] : null;
    $school_short_name = !empty($adminData['$school_short_name']) ? $adminData['$school_short_name'] : null;
    $school_favicon = !empty($adminData['school_favicon']) ? $adminData['school_favicon'] : null;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><?= htmlspecialchars($school_name) ?> - CBT</title>

  <!-- Favicon -->
  <?php if (!empty($school_favicon)): ?>
    <link rel="icon" href="../../<?= htmlspecialchars($school_favicon) ?>" type="image/x-icon">
  <?php endif; ?>

  <!-- AdminLTE & Icons -->
  <!-- Bootstrap 4 CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/css/adminlte.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">
  <!-- ✅ DataTables CSS -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css">
 <!-- ✅ For showinfg MFormulas and Equations-->
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>





  
  <!-- FullCalendar CSS -->
  <link href="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.css" rel="stylesheet" />

  <style>
    .content-wrapper {
      overflow-y: auto;
      max-height: calc(100vh - 114px); /* Adjust for header + footer height */
    }
  </style>
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
