<?php
//include "config.php"; // DB connection

$machinesQuery = mysqli_query($conn, "
    SELECT id, machine_tab_code, station 
    FROM station_master_table 
    WHERE machine_type IN (1, 3, 2, 4)
");


if (mysqli_num_rows($machinesQuery) > 0) {
    while ($machine = mysqli_fetch_assoc($machinesQuery)) {
       // $machineIdEnc = urlencode(utility::app_crypt($machine['id'], 'e'));
		$machine_tab_code = $machine['machine_tab_code'];
        ?>
        
        <div class="col-md-4 mb-3">
            <a href="<?= $config->frontEndURL . '/admin/machine_tab/index?page=enginer_login&code=' . $machine_tab_code; ?>" 
               target="_blank" 
               style="text-decoration:none;">
                <div class="card machine-card text-center p-3 shadow-sm">
                    <h5 class="card-title"><?= htmlspecialchars($machine['station']); ?></h5>
                    <p class="card-text text-muted">ID: <?= $machine['id']; ?></p>
                </div>
            </a>
        </div>

        <?php
    }
} else {
    echo '<div class="col-12 text-center">No machines found with type = 1</div>';
}
?>

<style>
.machine-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    border-radius: 10px;
}
.machine-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}
</style>
