<?php
require 'functions.php';
?>
<!doctype html>
<html lang="en">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <!-- Bootstrap CSS -->
  <link rel="stylesheet" href="css/bootstrap.min.css">

  <!-- CSS yang saya tambahkan -->
  <link rel="stylesheet" href="css/style.css">

  <title>Proyek PSW2</title>
</head>
<style>
  .ssss {
    width: 30px;
    height: 30px;
    border-radius: 50%;
  }
</style>

<body>

  <!-- Navbar yang dibuat -->
  <nav class="navbar navbar-expand-lg navbar-light">
    <div class="container">
      <a class="navbar-brand" href="index.php">E-Complaint</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
        <div class="navbar-nav ml-auto">
          <a class="nav-item nav-link active" href="index.php">Home <span class="sr-only">(current)</span></a>
          <?php if (isset($_SESSION["level"])) : ?>
            <?php $level = $_SESSION["level"] == 'admin';
            if ($level) : ?>
              <a class="nav-item nav-link" href="Admin_KelolaAkun.php">Kelola Akun</a>
              <a class="nav-item nav-link" href="Admin_KeluhanMasuk.php">Keluhan Masuk</a>
              <a class="nav-item nav-link" href="Admin_PesanMasuk.php">Pesan Masuk</a>
            <?php endif; ?>
            <?php if (!$level) : ?>
              <a class="nav-item nav-link" href="User_DaftarKeluhan.php">Keluhan</a>
            <?php endif; ?>
          <?php endif; ?>
          <?php if (isset($_SESSION["login"])) : ?>
            <a class="nav-item nav-link" href="grafik.php">Grafik</a>
          <?php endif; ?>
          <a class="nav-item nav-link" href="about.php">About</a>
          <?php if (isset($_SESSION["level"])) : ?>
            <?php if (!$level) : ?>
              <?php if (isset($_SESSION["login"])) : ?>
                <?php if (isset($_SESSION["akun"])) : ?>
                  <?php
                  $id = $_SESSION["akun"];
                  $akun = query("SELECT * FROM user WHERE id= $id")[0];
                  ?>
                  <a class="nav-item nav-link" href="User_DataAkun.php?id=<?php echo $akun["id"] ?>"><img class="ssss" src="img/<?= $akun['gambar']; ?>"></a>
                <?php endif; ?>
              <?php endif; ?>
            <?php endif; ?>
          <?php endif; ?>
          <?php if (!isset($_SESSION["login"])) : ?>
            <a class="nav-item btn btn-primary tombol" href="login.php">Login</a>
          <?php endif; ?>
          <?php if (isset($_SESSION["login"])) : ?>
            <a class="nav-item btn btn-danger tombol" href="logout.php">Logout</a>
          <?php endif; ?>
        </div>
      </div>
    </div>
  </nav>
  <hr>