false, 'error' => 'Unauthorized']); exit; } $orderId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT); if (!is_int($orderId) || $orderId <= 0) { http_response_code(400); echo json_encode(['ok' => false, 'error' => 'Invalid order id']); exit; } $detail = get_sales_order_detail($pdo, $orderId); if ($detail === null) { http_response_code(404); echo json_encode(['ok' => false, 'error' => 'Order not found']); exit; } echo json_encode(['ok' => true, 'order' => $detail], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);