<?php

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

$current =
basename($_SERVER['PHP_SELF']);

$role =
$_SESSION['role'] ?? '';

?>

<!-- Font Awesome -->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">

<!-- Main Layout CSS -->
<link rel="stylesheet"
href="/SEAT/assets/css/templates/layout.css">

<?php

/* DEFAULT NOTIFICATIONS */
$unread_count  = 0;
$notifications = [];

/* COUNT UNREAD */
if(!empty($notifications)){
    foreach($notifications as $n){
        if(isset($n['is_read']) && $n['is_read'] == 0){
            $unread_count++;
        }
    }
}

?>

<!-- ======================================================
   TOPBAR
====================================================== -->

<div class="topbar">

    <!-- LEFT SIDE -->
    <div class="leftArea">

        <button
        class="toggleBtn"
        onclick="toggleSidebar()"
        >

            <i class="fa fa-bars"></i>

        </button>

        <div class="logo">
            Smart Event Automated Ticketing System (SEAT)
        </div>

    </div>

    <!-- RIGHT SIDE -->
    <div class="topRight">

        <!-- ======================================================
           NOTIFICATION (HIDE FOR ADMIN)
        ======================================================= -->

        <?php if($role !== "admin"){ ?>

            <?php
            $notificationFile =
            $_SERVER['DOCUMENT_ROOT'] .
            "/SEAT/modules/Notification/notification.php";

            if(file_exists($notificationFile)){
                include($notificationFile);
            }
            ?>

        <?php } ?>

        <!-- ======================================================
           LOGOUT
        ======================================================= -->

        <form
        action="/SEAT/logout.php"
        method="post"
        >

            <button
            type="submit"
            class="logoutBtn"
            >

                <i class="fa fa-right-from-bracket"></i>

                Logout

            </button>

        </form>

    </div>

</div>