<?php

/**
 * @var string $content
 * @var string $title
 */

header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: 0');

$userRole = $_SESSION['user']['role'];
if ($userRole !== 'ADMIN' && $userRole !== 'TEKNISI') {
  redirect('HOME');
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title><?= !empty($title) ? $title . ' - ' : 'Admin - ' ?>ITSM App</title>

  <link rel="stylesheet" href="<?= asset('css/bootstrap-custom.css') ?>">

  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
    integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
    crossorigin="anonymous"></script>

  <link rel="stylesheet"
    href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">

  <link rel="stylesheet" href="<?= asset('css/app.css') ?>">
  <script>
    const BASE_URL = "<?= BASE_URL ?>";
  </script>
  <script src="<?= asset('js/app.js') ?>" defer></script>
</head>

<body>

  <?php $this->partial('layouts/admin/navbar'); ?>
  <div class="d-flex">

    <aside class="sidebar">
      <div class="p-3 fw-bold border-bottom">
        Cabang Mampang
      </div>

      <?php $this->partial('layouts/admin/sidebar'); ?>
    </aside>



    <main class="flex-grow-1">
      <div class="container-fluid p-4">

        <?php if (isset($_SESSION['success'])): ?>
          <div class="alert alert-success alert-dismissible fade show" role="alert">
            <?= $_SESSION['success'] ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
          </div>
          <?php unset($_SESSION['success']); ?>
        <?php endif; ?>

        <?php if (isset($_SESSION['error'])): ?>
          <div class="alert alert-danger alert-dismissible fade show" role="alert">
            <?= $_SESSION['error'] ?>
            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
          </div>
          <?php unset($_SESSION['error']); ?>
        <?php endif; ?>

        <?= $content ?>

      </div>
    </main>

  </div>

</body>

</html>