<?php
session_start();
if (!isset($_SESSION['AccAdminID'])) {
    header('Location: login.html');
    exit();
}

include("connection.php");
$AccID = $_SESSION['AccAdminID'];

// Fetching the user's name
$sql = "SELECT Admin_Name FROM admin WHERE Admin_ID = '$AccID'";
$result = mysqli_query($conn, $sql);
$user = mysqli_fetch_assoc($result);
$userName = $user['Admin_Name'];
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin | UITM BAZAAR</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="style2.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
</head>
<body>
    <aside class="sidebar">
      <div class="logo">
        <img src="pic/profiles.png" alt="logo">
        <h2><?php echo $userName; ?>'s</h2>
      </div>
      <ul class="links">
        <h4>Main Menu</h4>
        <li>
          <span class="material-symbols-outlined"><img src="pic/home.png"></span>
          <a href="adminmenu.php">Main Menu</a>
        </li>
        <hr>
        <h4>Advanced</h4>
        <li>
          <span class="material-symbols-outlined"><img src="pic/admin.png"></span>
          <a href="newAdmin.php">New Admin Acc</a>
        </li>
        <hr>
        <h4>Account</h4>
        <li>
          <span class="material-symbols-outlined"><img src="pic/profile2.png"></span>
          <a href="adminProfile.php">Profile</a>
        </li>
        <hr>
        <h4>Sign Out</h4>
        <li class="logout-link">
          <span class="material-symbols-outlined"><i class="fa-solid fa-right-from-bracket"></i></span>
          <a href="logoutAdmin.php">Logout</a>
        </li>
      </ul>
    </aside>
    <header class="header">
        <a href="adminmenu.php" class="logo"><span><?php echo $userName; ?>'s</span></a>
        <i class="fa-solid fa-bars" id="menu-icon"></i>
        <nav class="navbar">
            <a href="report.php">Report</a>
            <a href="renterList.php">Renter List</a>
            <a href="viewFeedback.php">Feedback</a>
            <a href="approval.php">Order</a>
            <a href="postEvents.php">Events</a>
        </nav>
    </header>
    <div class="slider-wrapper">
        <div class="slider">
            <div class="nav-arrow left" onclick="scrollToSection(-1)"><i class="fa fa-arrow-left" aria-hidden="true"></i></div>
            <div class="nav-arrow right" onclick="scrollToSection(1)"><i class="fa fa-arrow-right" aria-hidden="true"></i></div>
            <section class="home" id="home">
                <div class="home-content">
                    <h1>Homepage <span>Management</span></h1>
                    <p>Hi, Admin please kindly proceed or approve order that in your queue. You can upload some events for promote it to other users</p>
                    <br><br>
                    <button class="btn" onclick="scrollToSection(1)">MORE <i class="fa-solid fa-briefcase"></i></button>
                </div>
                <div class="home-img">
                    <img src="pic/admin.jpg" alt="Admin">
                </div>
            </section>
            <section class="services" id="services">
                <div class="service-container">
                    <div class="boxes">
                        <div class="card">
                            <a href="report.php"><img src="pic/report.jpg" alt="Report"></a>
                            <h2>Report</h2>
                        </div>
                        <div class="card">
                            <a href="renterList.php"><img src="pic/list.jpg" alt="List"></a>
                            <h2>List</h2>
                        </div>
                        <div class="card">
                            <a href="viewFeedback.php"><img src="pic/feedback.jpg" alt="Feedback"></a>
                            <h2>Feedback</h2>
                        </div>
                        <div class="card">
                            <a href="approval.php"><img src="pic/approv.jpeg" alt="Order"></a>
                            <h2>Order</h2>
                        </div>
                        <div class="card">
                            <a href="postEvents.php"><img src="pic/event.png" alt="Event"></a>
                            <h2>Event</h2>
                        </div>
                        <div class="card">
                            <a href="newAdmin.php"><img src="pic/profile.jpg" alt="Profile"></a>
                            <h2>+ Acc</h2>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
    <footer class="footer" id="footer">
        <p class="copyright">
            NextGen Techne © | All Rights Reserved
        </p>
    </footer>
    <script>
        let currentSection = 0;

        function scrollToSection(direction) {
            const sections = document.querySelectorAll('.slider section');
            currentSection = (currentSection + direction + sections.length) % sections.length;
            sections[currentSection].scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'start' });
        }
    </script>
</body>
</html>
