diff --git a/functions.php b/functions.php index 0157796..504ff0a 100644 --- a/functions.php +++ b/functions.php @@ -188,4 +188,24 @@ function generatePprEmail($entryId, $email, $ac_reg) { logJournal($conn, $entryId, "Confirm email FAILED"); } } + +function getAirport($conn, $code) { + $query = ""; + if (strlen($code) === 4) { + $query = "SELECT name FROM airports WHERE icao = ?"; + } elseif (strlen($code) === 3) { + $query = "SELECT name FROM airports WHERE iata = ?"; + } else { + return null; // Invalid code length + } + + $stmt = $conn->prepare($query); + $stmt->bind_param("s", $code); + $stmt->execute(); + $stmt->bind_result($name); + $stmt->fetch(); + $stmt->close(); + + return $name; +} ?> \ No newline at end of file diff --git a/tower.php b/tower.php index 9710c5b..a61350b 100644 --- a/tower.php +++ b/tower.php @@ -275,6 +275,14 @@ function renderTableCell($key, $value, $row) { $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 ?? '') . ""; } diff --git a/upcoming.php b/upcoming.php index 950aa0b..fc17fa6 100644 --- a/upcoming.php +++ b/upcoming.php @@ -230,6 +230,14 @@ function renderTableCell($key, $value, $row) { $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 ?? '') . ""; }