Upcoming Movements
" . htmlspecialchars($value ?? '') . (!empty($value) ? " Z" : "") . "";
}
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
$notes = htmlspecialchars($row['notes'] ?? '');
$acCall = htmlspecialchars($row['ac_call'] ?? '');
$acReg = htmlspecialchars($value ?? '');
if (!empty($row['notes'])) {
return "$acCall $acReg | ";
}
return "$acCall $acReg | ";
} elseif ($key == 'ac_reg' && !empty($row['notes'])) {
$notes = htmlspecialchars($row['notes'] ?? '');
$acReg = htmlspecialchars($value ?? '');
return "$acReg | ";
} elseif ($key == 'in_from' || $key == 'out_to') {
if (!empty($value) && (strlen($value) === 3 || strlen($value) === 4)) {
$airportName = getAirport(connectDb(), $value);
if ($airportName) {
return "" . htmlspecialchars($value) . " " . htmlspecialchars($airportName) . " | ";
}
}
return "" . htmlspecialchars($value ?? '') . " | ";
} else {
return "" . htmlspecialchars($value ?? '') . " | ";
}
}
function renderActionsCell($id) {
return "
| ";
}
function renderTableRow($row) {
$rowHtml = "";
foreach ($row as $key => $value) {
if (!in_array($key, ['id', 'ac_call', 'notes'])) { // Exclude 'notes'
$rowHtml .= renderTableCell($key, $value, $row);
}
}
$rowHtml .= renderActionsCell($row['id']);
$rowHtml .= "
";
return $rowHtml;
}
function renderTable($result) {
$tableHtml = "
";
$fields = $result->fetch_fields();
foreach ($fields as $field) {
if (!in_array($field->name, ['id', 'ac_call', 'notes'])) { // Exclude 'notes'
$tableHtml .= "| " . htmlspecialchars($field->name ?? '') . " | ";
}
}
$tableHtml .= "Actions |
";
while ($row = $result->fetch_assoc()) {
$tableHtml .= renderTableRow($row);
}
$tableHtml .= "
";
return $tableHtml;
}
$conn = connectDb();
$sql = "SELECT id, ac_reg, ac_type, ac_call, eta AS ETA, fuel, in_from, pob_in, notes
FROM submitted
WHERE DATE(eta) > CURDATE()
AND status != 'CANCELED'
ORDER BY eta ASC;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo renderTable($result);
} else {
echo "No upcoming movements found.";
}
$conn->close();
?>