based on this info (-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Nov 08, 2024 at 03:05 PM
-- Server version: 10.11.9-MariaDB
-- PHP Version: 7.2.34

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `u406552082_kaakalia`
--

-- --------------------------------------------------------

--
-- Table structure for table `customers`
--

CREATE TABLE `customers` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `contact` varchar(50) DEFAULT NULL,
  `delivery_address` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `orders`
--

CREATE TABLE `orders` (
  `id` int(11) NOT NULL,
  `customer_id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `status` enum('Pending','In Progress','Completed','Delivered') DEFAULT 'Pending',
  `order_date` datetime DEFAULT current_timestamp(),
  `delivery_datetime` datetime DEFAULT NULL,
  `delivery_date` date DEFAULT NULL,
  `quantity` int(11) NOT NULL DEFAULT 1,
  `packaging_preferences` varchar(255) DEFAULT NULL,
  `discount_amount` decimal(10,2) DEFAULT 0.00,
  `discount_reason` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `order_items`
--

CREATE TABLE `order_items` (
  `id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `packaging_preferences` varchar(255) DEFAULT NULL,
  `discount_amount` decimal(10,2) DEFAULT 0.00,
  `discount_reason` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `size` varchar(50) DEFAULT NULL,
  `price` decimal(10,2) NOT NULL,
  `category` varchar(50) DEFAULT NULL,
  `thumbnail` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `role` enum('admin','staff') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `customers`
--
ALTER TABLE `customers`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
  ADD PRIMARY KEY (`id`),
  ADD KEY `customer_id` (`customer_id`);

--
-- Indexes for table `order_items`
--
ALTER TABLE `order_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_id` (`order_id`),
  ADD KEY `product_id` (`product_id`);

--
-- Indexes for table `products`
--
ALTER TABLE `products`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `order_items`
--
ALTER TABLE `order_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
  ADD CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`),
  ADD CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`);

--
-- Constraints for table `order_items`
--
ALTER TABLE `order_items`
  ADD CONSTRAINT `order_items_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `order_items_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;) i want to update this codes (<?php
// public/orders/view_order_customer.php

// Enable error reporting for debugging (disable in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Include authentication and database connection **before** including the header
require_once __DIR__ . '/../../includes/auth.php';
require_once __DIR__ . '/../../includes/db_connect.php';

// Now include the header
require_once '../../includes/header.php';

// Check if order_id is given
$order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0;

if ($order_id <= 0) {
    header("Location: view_orders.php?error=6"); // Invalid order ID
    exit();
}

// Fetch order details along with customer and product information
$order_sql = "
    SELECT 
        orders.id AS order_id,
        orders.status,
        orders.order_date,
        orders.delivery_datetime,
        customers.name AS customer_name,
        customers.contact,
        customers.delivery_address,
        orders.product_id AS primary_product_id,
        orders.quantity AS primary_quantity,
        orders.packaging_preferences AS primary_packaging_preferences,
        products.name AS primary_product_name,
        products.size AS primary_product_size
    FROM 
        orders
    JOIN 
        customers ON orders.customer_id = customers.id
    JOIN 
        products ON orders.product_id = products.id
    WHERE 
        orders.id = ?
";
$order_stmt = $conn->prepare($order_sql);
$order_stmt->bind_param("i", $order_id);
$order_stmt->execute();
$order_result = $order_stmt->get_result();
$order = $order_result->fetch_assoc();
$order_stmt->close();

if (!$order) {
    header("Location: view_orders.php?error=7"); // Order not found
    exit();
}

// Fetch additional order items
$order_items_sql = "
    SELECT 
        order_items.product_id,
        order_items.quantity,
        order_items.packaging_preferences,
        products.name AS product_name,
        products.size AS product_size
    FROM 
        order_items
    JOIN 
        products ON order_items.product_id = products.id
    WHERE 
        order_items.order_id = ?
";
$item_stmt = $conn->prepare($order_items_sql);
$item_stmt->bind_param("i", $order_id);
$item_stmt->execute();
$order_items_result = $item_stmt->get_result();
$order_items = [];
while ($item = $order_items_result->fetch_assoc()) {
    $order_items[] = $item;
}
$item_stmt->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Order #<?= htmlspecialchars($order['order_id']) ?> Details - Kaak Alia Management System</title>
    <link rel="stylesheet" href="/kaak_alia_management_system/assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
    <style>
        body {
            font-family: 'Cairo', sans-serif;
            background: linear-gradient(to bottom, #f5f7fa, #c3cfe2);
            margin: 0;
            padding: 20px;
            box-sizing: border-box;
        }
        .header {
            background-color: #333;
            color: #fff;
            padding: 20px 30px;
            text-align: center;
            border-radius: 8px;
            font-size: 24px;
            margin-bottom: 30px;
        }
        .order-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 20px;
        }
        .order-details {
            background-color: #ffffff;
            border-radius: 8px;
            padding: 20px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.15);
            width: 100%;
            max-width: 600px;
        }
        .order-details h4 {
            font-size: 20px;
            font-weight: bold;
            color: #4F3F02;
            margin-bottom: 15px;
            border-bottom: 2px solid #D1C287;
            padding-bottom: 10px;
        }
        .info-section {
            display: flex;
            justify-content: space-between;
            padding: 10px 0;
            border-bottom: 1px solid #eaeaea;
        }
        .info-label {
            font-weight: bold;
            color: #333;
        }
        .info-value {
            color: #555;
        }
        .btn-back {
            background-color: #4F3F02;
            color: white;
            text-align: center;
            padding: 10px 20px;
            border-radius: 5px;
            text-decoration: none;
            font-weight: bold;
            transition: background-color 0.3s;
        }
        .btn-back:hover {
            background-color: #D1C287;
            color: #333;
        }
    </style>
</head>
<body>
    <div class="header">
        Order #<?= htmlspecialchars($order['order_id']) ?> Details
    </div>
    
    <div class="order-container">
        <div class="order-details">
            <h4>Order Information</h4>
            <div class="info-section">
                <span class="info-label">Status:</span>
                <span class="info-value"><?= htmlspecialchars($order['status']) ?></span>
            </div>
            <div class="info-section">
                <span class="info-label">Order Date:</span>
                <span class="info-value"><?= date("d M Y, h:i A", strtotime($order['order_date'])) ?></span>
            </div>
            <div class="info-section">
                <span class="info-label">Delivery DateTime:</span>
                <span class="info-value"><?= $order['delivery_datetime'] ? date("d M Y, h:i A", strtotime($order['delivery_datetime'])) : 'N/A' ?></span>
            </div>
        </div>

        <div class="order-details">
            <h4>Customer Information</h4>
            <div class="info-section">
                <span class="info-label">Name:</span>
                <span class="info-value"><?= htmlspecialchars($order['customer_name']) ?></span>
            </div>
            <div class="info-section">
                <span class="info-label">Contact:</span>
                <span class="info-value"><?= htmlspecialchars($order['contact']) ?></span>
            </div>
            <div class="info-section">
                <span class="info-label">Delivery Address:</span>
                <span class="info-value"><?= nl2br(htmlspecialchars($order['delivery_address'])) ?></span>
            </div>
        </div>

        <div class="order-details">
            <h4>Primary Product Information</h4>
            <div class="info-section">
                <span class="info-label">Product:</span>
                <span class="info-value"><?= htmlspecialchars($order['primary_product_name'] . " - " . $order['primary_product_size']) ?></span>
            </div>
            <div class="info-section">
                <span class="info-label">Quantity:</span>
                <span class="info-value"><?= htmlspecialchars($order['primary_quantity']) ?></span>
            </div>
            <div class="info-section">
                <span class="info-label">Packaging:</span>
                <span class="info-value"><?= htmlspecialchars($order['primary_packaging_preferences']) ?></span>
            </div>
        </div>

        <div class="order-details">
            <h4>Additional Products</h4>
            <?php if (!empty($order_items)): ?>
                <?php foreach ($order_items as $item): ?>
                    <div class="info-section">
                        <span class="info-label">Product:</span>
                        <span class="info-value"><?= htmlspecialchars($item['product_name'] . " - " . $item['product_size']) ?></span>
                    </div>
                    <div class="info-section">
                        <span class="info-label">Quantity:</span>
                        <span class="info-value"><?= htmlspecialchars($item['quantity']) ?></span>
                    </div>
                    <div class="info-section">
                        <span class="info-label">Packaging:</span>
                        <span class="info-value"><?= htmlspecialchars($item['packaging_preferences']) ?></span>
                    </div>
                <?php endforeach; ?>
            <?php else: ?>
                <p class="info-value">No additional products.</p>
            <?php endif; ?>
        </div>

        <a href="view_orders.php" class="btn-back">Back to Orders</a>
    </div>
</body>
</html>
) and make it clear and so amaming and make usre the discount is exist and reason and make different colors and amke the prefeerences packages too different colors and type full codes