<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
require './lang/translate.php';
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>AlarmDrift</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap 5 CDN -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery (must come before DataTables) -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

    <!-- DataTables -->
    <script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>

</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
  <div class="container-fluid">
    <a class="navbar-brand" href="index.php"><?= t('brand') ?></a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav me-auto">
        <li class="nav-item"><a class="nav-link" href="index.php"><?= t('home') ?></a></li>
        <li class="nav-item"><a class="nav-link" href="clients.php"><?= t('clients') ?></a></li>
        <li class="nav-item"><a class="nav-link" href="signal_log.php"><?= t('signal_log') ?></a></li>
      </ul>
      <ul class="navbar-nav ms-auto">
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="maintenanceDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            <?= t('maintenance') ?>
          </a>
          <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="maintenanceDropdown">
            <?php if (!empty($_SESSION['user_role']) && $_SESSION['user_role'] === 'Admin'): ?>
              <li><h6 class="dropdown-header"><?= t('clients_header') ?></h6></li>
              <li><a class="dropdown-item" href="edit_user.php"><?= t('dealers') ?></a></li>
              <li><a class="dropdown-item" href="edit_user.php"><?= t('client_templates') ?></a></li>
              <li><h6 class="dropdown-header"><?= t('event_handling_header') ?></h6></li>
              <li><a class="dropdown-item" href="edit_user.php"><?= t('event_templates') ?></a></li>
              <li><a class="dropdown-item" href="edit_user.php"><?= t('response_plans') ?></a></li>
            <?php endif; ?>
          </ul>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="systemDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            <?= t('system') ?>
          </a>
          <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="systemDropdown">
            <?php if (!empty($_SESSION['user_role']) && $_SESSION['user_role'] === 'Admin'): ?>
              <li><h6 class="dropdown-header"><?= t('users_header') ?></h6></li>
              <li><a class="dropdown-item" href="edit_user.php"><?= t('users') ?></a></li>
              <li><a class="dropdown-item" href="edit_user.php"><?= t('access_groups') ?></a></li>
              <li><h6 class="dropdown-header"><?= t('system_header') ?></h6></li>
              <li><a class="dropdown-item" href="edit_user.php"><?= t('sms_email') ?></a></li>
              <li><a class="dropdown-item" href="receivers.php"><?= t('receivers') ?></a></li>
              <li><a class="dropdown-item" href="edit_user.php"><?= t('system_settings') ?></a></li>
              <li><a class="dropdown-item" href="edit_user.php"><?= t('backup') ?></a></li>
            <?php endif; ?>
          </ul>
        </li>
        <li class="nav-item dropdown ms-3">
          <a class="nav-link dropdown-toggle" href="#" id="logoutDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            <?= t('logout') ?>
          </a>
          <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="logoutDropdown">
            <li><a class="dropdown-item" href="logout.php"><?= t('logout') ?></a></li>
          </ul>
        </li>
      </ul>
    </div>
  </div>
</nav>

<div class="container">
