Compare commits

...

2 Commits

Author SHA1 Message Date
15b2d36bf6 Notes on main screen 2025-03-17 20:37:43 +00:00
9e25f0023c Admin sort 2025-03-17 20:37:04 +00:00
2 changed files with 65 additions and 44 deletions

View File

@@ -20,6 +20,51 @@ require_db_auth();
row.classList.add("highlightJET"); // Add the class
}
});
// Sorting functionality
let table = document.querySelector("table");
let headers = table.querySelectorAll("th");
let sortDirection = {}; // Track sort direction for each column
headers.forEach((header, index) => {
header.addEventListener("click", function() {
let direction = sortDirection[index] === "asc" ? "desc" : "asc";
sortDirection[index] = direction;
sortTable(table, index, direction);
// Update visual indication
headers.forEach(h => h.classList.remove("sorted-asc", "sorted-desc"));
header.classList.add(direction === "asc" ? "sorted-asc" : "sorted-desc");
});
});
function sortTable(table, columnIndex, direction) {
let rows = Array.from(table.querySelectorAll("tbody tr"));
let isDate = !isNaN(Date.parse(rows[0].cells[columnIndex]?.textContent.trim() || ""));
let isNumeric = !isNaN(rows[0].cells[columnIndex]?.textContent.trim() || "");
let sortedRows = rows.sort((a, b) => {
let aText = a.cells[columnIndex]?.textContent.trim() || null;
let bText = b.cells[columnIndex]?.textContent.trim() || null;
if (aText === null || bText === null) {
return aText === null ? 1 : -1; // Place null/empty values at the bottom
}
if (isDate) {
let aDate = new Date(aText);
let bDate = new Date(bText);
return direction === "asc" ? aDate - bDate : bDate - aDate;
} else if (isNumeric) {
return direction === "asc" ? aText - bText : bText - aText;
} else {
return direction === "asc" ? aText.localeCompare(bText) : bText.localeCompare(aText);
}
});
let tbody = table.querySelector("tbody");
tbody.innerHTML = "";
sortedRows.forEach(row => tbody.appendChild(row));
}
});
</script>
<meta charset="UTF-8">
@@ -91,6 +136,16 @@ require_db_auth();
border-radius: 5px;
}
/* Add styles for sorted columns */
th.sorted-asc::after {
content: " ▲";
font-size: 0.8em;
}
th.sorted-desc::after {
content: " ▼";
font-size: 0.8em;
}
</style>
</head>
<body>
@@ -241,7 +296,6 @@ if ($result->num_rows > 0) {
echo '<td>' . htmlspecialchars($value ?? '') . '</td>';
}
}
echo '<td><img src="assets/cancel-icon.webp" title="Cancel PPR" style="width: 25px; height: auto;" onclick="markCancel(' . $row['id'] . ')"><img src="assets/cancel-icon.webp" title="DELETE PPR" style="width: 25px; height: auto;" onclick="deletePpr(' . $row['id'] . ')"><img src="assets/land.webp" title="Mark Landed" style="width: 30px; height: auto;" onclick="markLanded(' . $row['id'] . ')"></td>';
echo '</tr>';
}

View File

@@ -140,35 +140,6 @@ require_db_auth();
cursor: pointer;
}
/* Add this CSS for the red triangle */
.red-triangle {
position: relative;
}
.red-triangle::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
border-left: 10px solid red;
border-bottom: 10px solid transparent;
}
.red-triangle:hover::after {
content: attr(data-notes);
position: absolute;
top: 20px;
left: 0;
background: #fff;
border: 1px solid #ddd;
padding: 5px;
border-radius: 5px;
white-space: nowrap;
z-index: 10;
}
</style>
</head>
<body>
@@ -240,7 +211,7 @@ function openDetail(id) {
</div>
-->
<div class="heading">Inbound Aircraft</div>
<div class="heading">Inbound PPR</div>
<?php
@@ -253,7 +224,7 @@ if ($conn->connect_error) {
}
// Define your SQL query
$sql = "SELECT id, status, ac_reg, ac_type, ac_call, TIME_FORMAT(eta,'%H:%i') AS ETA, fuel, in_from, pob_in, notes FROM submitted WHERE DATE(eta) = CURDATE() AND (status = 'NEW' OR status = 'CANCELED') ORDER BY eta ASC;"; // Replace with your table name
$sql = "SELECT id, status, ac_reg, ac_type, ac_call, TIME_FORMAT(eta,'%H:%i') AS ETA, fuel, in_from, pob_in FROM submitted WHERE DATE(eta) = CURDATE() AND (status = 'NEW' OR status = 'CANCELED') ORDER BY eta ASC;"; // Replace with your table name
// Execute the query
$result = $conn->query($sql);
@@ -268,7 +239,7 @@ if ($result->num_rows > 0) {
// Output table headers (assuming column names are known)
$fields = $result->fetch_fields();
foreach ($fields as $field) {
if ($field->name != 'notes' && $field->name != 'status' && $field->name != 'id' && $field->name != 'ac_call') {
if ($field->name != 'status' && $field->name != 'id' && $field->name != 'ac_call') {
echo '<th>' . htmlspecialchars($field->name ?? '') . '</th>';
}
@@ -283,14 +254,12 @@ if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo '<tr class="state-' . $row['status'] . '" data-id=' . $row['id'] . '>';
foreach ($row as $key => $value) {
if ($key != 'notes' && $key != 'status' && $key != 'id' && $key != 'ac_call') {
if ($key != 'status' && $key != 'id' && $key != 'ac_call') {
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
echo '<td>' . htmlspecialchars($row['ac_call'] ?? '') . "<br><span class=acreg>" . $value . '</span></td>';
} else if ($key == 'ac_reg' && !empty($row['notes'])) {
echo '<td class="red-triangle" data-notes="' . htmlspecialchars($row['notes'] ?? '') . '">' . htmlspecialchars($value ?? '') . '</td>';
} else {
echo '<td>' . htmlspecialchars($value ?? '') . '</td>';
}
}
}
}
echo '<td><img src="assets/cancel-icon.webp" title="Cancel PPR" style="width: 25px; height: auto;" onclick="markCancel(' . $row['id'] . ')"><img src="assets/arrive.png" title="Land" style="width: 30px; height: auto;" onclick="markLanded(' . $row['id'] . ')"></td>';
@@ -304,14 +273,14 @@ if ($result->num_rows > 0) {
?>
<div class="heading">Visiting Aircraft</div>
<div class="heading">Booking Out</div>
<div id="landed">
<?php
// Define your SQL query
$sql = "SELECT id, status, ac_reg, ac_type, ac_call, TIME_FORMAT(etd,'%H:%i') AS ETD, fuel, out_to, pob_out, notes FROM submitted WHERE DATE(eta) = CURDATE() AND status = 'LANDED' ORDER BY eta ASC;"; // Replace with your table name
$sql = "SELECT id, status, ac_reg, ac_type, ac_call, TIME_FORMAT(etd,'%H:%i') AS ETD, fuel, out_to, pob_out FROM submitted WHERE DATE(eta) = CURDATE() AND status = 'LANDED' ORDER BY eta ASC;"; // Replace with your table name
// Execute the query
$result = $conn->query($sql);
@@ -326,7 +295,7 @@ if ($result->num_rows > 0) {
// Output table headers (assuming column names are known)
$fields = $result->fetch_fields();
foreach ($fields as $field) {
if ($field->name != 'notes' && $field->name != 'status' && $field->name != 'id' && $field->name != 'ac_call') {
if ($field->name != 'status' && $field->name != 'id' && $field->name != 'ac_call') {
echo '<th>' . htmlspecialchars($field->name ?? '') . '</th>';
}
@@ -341,14 +310,12 @@ if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo '<tr class="state-' . $row['status'] . '" data-id=' . $row['id'] . '>';
foreach ($row as $key => $value) {
if ($key != 'notes' && $key != 'status' && $key != 'id' && $key != 'ac_call') {
if ($key != 'status' && $key != 'id' && $key != 'ac_call') {
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
echo '<td>' . htmlspecialchars($row['ac_call'] ?? '') . "<br><span class=acreg>" . $value . '</span></td>';
} else if ($key == 'ac_reg' && !empty($row['notes'])) {
echo '<td class="red-triangle" data-notes="' . htmlspecialchars($row['notes'] ?? '') . '">' . htmlspecialchars($value ?? '') . '</td>';
} else {
echo '<td>' . htmlspecialchars($value ?? '') . '</td>';
}
}
}
}
echo '<td><img src="assets/cancel-icon.webp" title="Cancel PPR" style="width: 25px; height: auto;" onclick="markCancel(' . $row['id'] . ')"><img src="assets/depart.png" title="Depart" style="width: 30px; height: auto;" onclick="markDeparted(' . $row['id'] . ')"></td>';