ICAO and IATA code lookup

This commit is contained in:
2025-04-15 17:13:47 +00:00
parent 31c1172e08
commit c4cfb43edc
3 changed files with 36 additions and 0 deletions

View File

@@ -188,4 +188,24 @@ function generatePprEmail($entryId, $email, $ac_reg) {
logJournal($conn, $entryId, "Confirm email FAILED"); 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;
}
?> ?>

View File

@@ -275,6 +275,14 @@ function renderTableCell($key, $value, $row) {
$notes = htmlspecialchars($row['notes'] ?? ''); $notes = htmlspecialchars($row['notes'] ?? '');
$acReg = htmlspecialchars($value ?? ''); $acReg = htmlspecialchars($value ?? '');
return "<td class='red-triangle' data-notes='$notes'>$acReg</td>"; return "<td class='red-triangle' data-notes='$notes'>$acReg</td>";
} elseif ($key == 'in_from' || $key == 'out_to') {
if (!empty($value) && (strlen($value) === 3 || strlen($value) === 4)) {
$airportName = getAirport(connectDb(), $value);
if ($airportName) {
return "<td>" . htmlspecialchars($value) . "<br><span style='font-size: smaller; font-style: italic;'>" . htmlspecialchars($airportName) . "</span></td>";
}
}
return "<td>" . htmlspecialchars($value ?? '') . "</td>";
} else { } else {
return "<td>" . htmlspecialchars($value ?? '') . "</td>"; return "<td>" . htmlspecialchars($value ?? '') . "</td>";
} }

View File

@@ -230,6 +230,14 @@ function renderTableCell($key, $value, $row) {
$notes = htmlspecialchars($row['notes'] ?? ''); $notes = htmlspecialchars($row['notes'] ?? '');
$acReg = htmlspecialchars($value ?? ''); $acReg = htmlspecialchars($value ?? '');
return "<td class='red-triangle' data-notes='$notes'>$acReg</td>"; return "<td class='red-triangle' data-notes='$notes'>$acReg</td>";
} elseif ($key == 'in_from' || $key == 'out_to') {
if (!empty($value) && (strlen($value) === 3 || strlen($value) === 4)) {
$airportName = getAirport(connectDb(), $value);
if ($airportName) {
return "<td>" . htmlspecialchars($value) . "<br><span style='font-size: smaller; font-style: italic;'>" . htmlspecialchars($airportName) . "</span></td>";
}
}
return "<td>" . htmlspecialchars($value ?? '') . "</td>";
} else { } else {
return "<td>" . htmlspecialchars($value ?? '') . "</td>"; return "<td>" . htmlspecialchars($value ?? '') . "</td>";
} }