| Current Path : /var/www/magento.test.indacotrentino.com/www/scripts/tools/ |
| Current File : /var/www/magento.test.indacotrentino.com/www/scripts/tools/orders.php |
<?php
$servername = "localhost";
$username = "indaco";
$password = "indaco";
$dbname = "magento_indaco";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
<html>
<head>
<title>List orders test</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
</head>
<body>
<div class="container px-4 py-5">
<?php if ((int)$_GET['id']>0) :
$sql = "SELECT * FROM sales_order where entity_id=".(int)$_GET['id']." limit 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$message = '{ "action": "newOrder", "order": { "entity_id": "' . $row["entity_id"] . '", "increment_id": "' . $row["increment_id"] .'" }}';
$message = '{
"action": "newOrder",
"indaco": {
"instance_id": "' . $this->deploymentConfig->get('indaco/instance_id') . '"
},
"order": {
"entity_id": "' . $row["entity_id"] . '",
"increment_id": "' . $row["increment_id"] .'",
"datetime": "' . $row["created_at"] . '",
"store": {
"storeview_id": "' . $order->getStore()->getId() . '",
"storeview_code": "' . $order->getStore()->getCode() . '",
"store_id": "' . $order->getStore()->getGroup()->getId() . '",
"store_code": "' . $order->getStore()->getGroup()->getCode() . '",
"website_id": "' . $order->getStore()->getWebsite()->getId() . '",
"website_code": "' . $order->getStore()->getWebsite()->getCode() . '"
}
}
}';
$output = shell_exec("/var/www/indaco/www/bin/magento queue:message:publish '" . $message . "' 'order'");
if ($output !== null) {
?>
<h2 class="pb-2 border-bottom">Data sended for order <?php echo $_GET['id'] ?> to RabbitMQ</h2>
<div class="alert alert-success" role="alert">
<?php echo $output; ?>
</div>
<table class="table">
<tr>
<th>ID</th>
<th>Increment_id</th>
<th>Name</th>
<th>Created</th>
</tr>
<?php
echo "<tr>";
echo "<td>" . $row["entity_id"] . "</td>";
echo "<td>" . $row["increment_id"] . "</td>";
echo "<td>" . $row["customer_firstname"] . " " . substr($row["customer_lastname"], 0, 1) . ".</td>";
echo "<td>" . $row["created_at"] . "</td>";
echo "</tr>";
echo "</table><br/><a href='/tool/orders.php'>Back</a>";
} else {
?>
<div class="alert alert-danger" role="alert">
ERROR: <?php echo $output; ?>
</div>
<?php
}
} else {
echo "No order found.";
}
?>
<?php else : ?>
<h2 class="pb-2 border-bottom">Send data order to RabbitMQ</h2>
<?php
$sql = "SELECT * FROM sales_order order by entity_id desc";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo '
<table class="table">
<tr>
<th>ID</th>
<th>Increment_id</th>
<th>Name</th>
<th>Created</th>
<th>Send</th>
</tr>
';
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row["entity_id"] . "</td>";
echo "<td>" . $row["increment_id"] . "</td>";
echo "<td>" . $row["customer_firstname"] . " " . substr($row["customer_lastname"], 0, 1) . ".</td>";
echo "<td>" . $row["created_at"] . "</td>";
echo "<td><a href='/tool/orders.php?id=" . $row["entity_id"] . "'>Send to RabbitMQ</a></td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>
<?php endif; ?>
</div>
</body>
</html>