<?php
// Include your database connection code
include 'connect.php';

if (isset($_GET['date'])) {
    $date = $_GET['date'];
    $formattedDate = date('Y-m-d', strtotime($date)); // Format date as yyyy-mm-dd

    $sql = "SELECT * FROM a_orders WHERE OrderStatus='Completed' AND OrderDate = '$formattedDate'";
    $result = mysqli_query($con, $sql);

    $orders = array();
    while ($row = mysqli_fetch_assoc($result)) {
        $orders[] = $row;
    }
    
    // Return the orders as JSON
    echo json_encode($orders);
}
