<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Page - Cart2 Data</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-LyTNSpABvuykJbpT5TB3xQSGJxiePfT8T0lS+s76nz5bWU/bMivs5I29LwJl/Dv8Tciz/9hD/B3TfiHQbJ/39Q==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-xw9nHT6m5aiKUW8qgX6O8jKgACvG4hR/lnR5STpSmFfb/QUn9Pl0j+J6B1/9TkBvqKlyYzdD5ot05yQlHMW5dg==" crossorigin="anonymous" referrerpolicy="no-referrer" />

    <style>
        
    
    .switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

        /* CSS for styling the table and navigation */
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #ffcda7;

        }

        h1 {
            text-align: center;
            margin-top: 20px;
        }

        nav ul {
            list-style-type: none;
            padding: 0;
            margin: 0;
            text-align: center;
        }

        nav ul li {
            display: inline;
            margin-right: 20px;
        }

        nav ul li a {
            text-decoration: none;
            color: #333;
            font-weight: bold;
        }

        nav ul li a:hover {
            color: #009688;
        }

        .content-section {
            display: none;
            padding: 20px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        th, td {
            padding: 8px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }

        th {
            background-color: #C67336;
        }

        img {
            max-width: 100px;
        }
    </style>
</head>
<body>

<h1>Admin Page</h1>



    <style>
body {margin:0;font-family:Arial}

.topnav {
  overflow: hidden;
  background-color: #333;
}

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

.active {
  background-color: #04AA6D;
  color: white;
}

.topnav .icon {
  display: none;
}

.dropdown {
  float: left;
  overflow: hidden;
}

.dropdown .dropbtn {
  font-size: 17px;    
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

.topnav a:hover, .dropdown:hover .dropbtn {
  background-color: #555;
  color: white;
}

.dropdown-content a:hover {
  background-color: #ddd;
  color: black;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.topnav {
  overflow: hidden;
  background-color: #333; /* Adjust background color as needed */
}

.topnav a {
  float: left;
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

.topnav a.icon {
  display: none;
}

@media screen and (max-width: 600px) {
  .topnav a:not(:first-child) {
    display: none;
  }
  
  .topnav a.icon {
    float: right;
    display: block;
  }
}

@media screen and (max-width: 600px) {
  .topnav.responsive {position: relative;}
  
  .topnav.responsive .icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
}


</style>


<div class="topnav" id="myTopnav">

<a href="admin1.php">
<i class="fas fa-arrow-left"></i> Back
</a>

</div>


<?php
// Include the database configuration file
include 'config.php';

// Check if the name parameter is set in the URL
if(isset($_GET['name'])) {
    // Get the name from the URL parameter
    $name = $_GET['name'];

    // Prepare and execute SQL query to fetch orders associated with the specified name
    $stmt = $conn->prepare("SELECT * FROM cart2 WHERE user_id IN (SELECT user_id FROM user_info WHERE name = ?)");
    $stmt->bind_param("s", $name);
    $stmt->execute();
    $result = $stmt->get_result();

    // Check if there are any orders associated with the name
    if ($result->num_rows > 0) {
        // Display the orders
        echo "<h2>Orders for $name</h2>";
        echo "<table class='order-table'>";
        echo "<tr><th>Item Name</th><th>Item Price</th><th>Quantity</th><th>Item Image</th><th>Subtotal</th></tr>";

        // Loop through each order and display order details
        while ($row = $result->fetch_assoc()) {
            echo "<tr>";
            echo "<td>" . $row['item_name'] . "</td>";
            echo "<td>RM " . $row['item_price'] . "</td>";
            echo "<td>" . $row['quantity'] . "</td>";
            echo "<td><img src='" . $row['item_image'] . "' alt='Item Image'></td>";
            echo "<td>RM " . $row['subtotal'] . "</td>";
            echo "</tr>";
        }

        // Close the table
        echo "</table>";
    } else {
        // If no orders found for the name, display a message
        echo "<p>No orders found for $name.</p>";
    }

    // Close the statement
    $stmt->close();
} else {
    // If name parameter is not set, display an error message
    echo "<p>Error: Name parameter is missing.</p>";
}

// Close the database connection
$conn->close();
?>


<script>
function myFunction() {
  var x = document.getElementById("myTopnav");
  if (x.className === "topnav") {
    x.className += " responsive";
  } else {
    x.className = "topnav";
  }
}
</script>

<!-- Content sections -->
<div id="home" class="content-section">
    <!-- Content for the Home section goes here -->
</div>












<script>
    // Provided JavaScript code
    function showContent(sectionId) {
        var contentSections = document.getElementsByClassName('content-section');

        for (var i = 0; i < contentSections.length; i++) {
            contentSections[i].style.display = 'none';
        }

        var selectedSection = document.getElementById(sectionId);

        if (selectedSection) {
            selectedSection.style.display = 'block';
            // Store the current section in local storage
            storeCurrentSection(sectionId);
        }
    }

    function showHomeSection() {
        showContent('home');
    }

    function storeCurrentSection(sectionId) {
        localStorage.setItem('currentSection', sectionId);
    }

    window.onload = function() {
        // Retrieve the current section from local storage
        var currentSection = localStorage.getItem('currentSection');
        
        // If there is a current section stored, show it
        if (currentSection) {
            showContent(currentSection);
        } else {
            // Otherwise, show the default section (e.g., "Home")
            showHomeSection();
        }

        // After successful login, call the login function to redirect to the "Cart Data" section
        login();
    };

    // Function to simulate login and redirect to "Cart Data" section
    function login() {
        // Perform login actions here (e.g., authenticate user)

        // Redirect to the "Cart Data" section
        showContent('cartData');
    }
</script>
</body>
</html>


<style>
    /* CSS for styling the form for uploading menu items */
    #foodUploadForm,
#drinkUploadForm {
    max-width: 400px;
    margin: auto;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f9f9f9;
}

#foodUploadForm label,
#drinkUploadForm label {
    display: block;
    margin-bottom: 10px;
}

#foodUploadForm input[type="file"],
#foodUploadForm input[type="text"],
#drinkUploadForm input[type="file"],
#drinkUploadForm input[type="text"] {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Ensures padding and border are included in the width */
}

#foodUploadForm button[type="submit"],
#drinkUploadForm button[type="submit"] {
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#foodUploadForm button[type="submit"]:hover,
#drinkUploadForm button[type="submit"]:hover {
    background-color: #45a049;
}



</style>


