<?php 
include('include/session.php');
// session_start();
include 'include/navigation.php';
include 'connection.php';
// Establish a database connection
$dbConnection = new DbConnection();
$connection = $dbConnection->connection;
?>

<html lang="en">
<head>
    <link rel="stylesheet" href="assets/css/style.css">
    <?php include 'include/header_links.php'; ?>
</head>
<body>
    <div class="container_main">
          <div id="warantee_button">
                    <div> <button class="reset-button"><a href="_new_order_list.php"><i class="fa-solid fa-backward"></i></a></button></div>
                   
                </div>

        <h1>Order Cancel List</h1>
      
        <table class="table table-striped">
            <thead>
                <tr>
                    <th scope="col">S.no</th>
                    <th scope="col">Order_id</th>
                    <th scope="col">Cuid</th>
                    <th scope="col">Category</th>
                    <th scope="col">Product</th>
                    <th scope="col">Variation</th>
                    <th scope="col">Price</th>
                    <th scope="col">Total Amount</th>
                    <th scope="col">Payment Reference</th>
                   
                    <th scope="col">Delete</th>
                </tr>
            </thead>
            <tbody>
                <?php
                $query = "SELECT * FROM order_cancel";
                $result = mysqli_query($connection, $query);
                $id = 1;

                if ($result && mysqli_num_rows($result) > 0) {
                    while ($row = mysqli_fetch_assoc($result)) {
                        echo "<tr>";
                        echo "<td>{$id}</td>";
                        echo "<td>{$row['order_id']}</td>";
                        echo "<td>{$row['cuid']}</td>";
                        echo '<td>' . implode("<br>", explode(",", $row['category'])) . '</td>';
                        echo '<td>' . implode("<br>", explode(",", $row['product'])) . '</td>';
                        echo '<td>' . implode("<br>", explode(",", $row['variation'])) . '</td>';
                        echo '<td>' . implode("<br>", explode(",", $row['price'])) . '</td>';
                        echo "<td>{$row['total_price']}</td>";
                        echo "<td>{$row['payment_reference']}</td>";

                        
                        
                        echo "<td><button type='button' class='btn btn-danger'><a href='order_delete.php?order_id={$row['order_id']}'><i class='bi bi-trash'></i></a></button></td>";
                        $id++;
                        echo "</tr>";
                    }
                }
                ?>
            </tbody>
        </table>
  </div>
        <section class="footer">
            <?php include_once("include/footer_two.php"); ?>
        </section>
    
  
    <?php include "include/footer_link.php"; ?>
  
   
</body>
</html>


