<?php
header('Access-Control-Allow-Origin: *');
header(
    'Access-Control-Allow-Methods: HEAD, GET, POST, PUT, PATCH, DELETE, OPTIONS'
);
header(
    'Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method,Access-Control-Request-Headers, Authorization'
);
header('Content-Type: application/json');
include '../../../../config/db.php';

// Sanitize input
$id = $_GET['id'];
// Get all users with a specific status
$query = "SELECT * FROM BrandingOrders a INNER JOIN Orders o ON o.orderId = a.orderId WHERE a.orderId = $id";
$result = mysqli_query( $con, $query );
if ( $result ) {
  $users = array();
  while ( $row = mysqli_fetch_assoc( $result ) ) {
    $users[] = $row;
  }
  $response = array(
    'status' => 'success',
    'data' => $users
  );
} else {
  $response = array(
    'status' => 'error',
    'message' => mysqli_error( $con )
  );
}

// Return response as JSON
header( 'Content-Type: application/json' );
echo json_encode( $response );

?>