Compare commits
2 Commits
ca28f490eb
...
f6368f12f1
| Author | SHA1 | Date | |
|---|---|---|---|
| f6368f12f1 | |||
| f6ba990e1c |
28
action.php
28
action.php
@@ -116,6 +116,11 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
let id = "<?php echo $_GET['id'];?>";
|
||||
|
||||
// Disable all dropdowns by default
|
||||
document.querySelectorAll("select.editable").forEach((element) => {
|
||||
element.disabled = true;
|
||||
});
|
||||
|
||||
// Select all editable elements
|
||||
document.querySelectorAll(".editable").forEach((element) => {
|
||||
let oldValue = element.value || element.textContent.trim(); // Store initial value
|
||||
@@ -157,6 +162,9 @@ function editField(button) {
|
||||
if (element.tagName === "INPUT") {
|
||||
element.readOnly = false;
|
||||
element.focus();
|
||||
} else if (element.tagName === "SELECT") {
|
||||
element.disabled = false; // Enable dropdown
|
||||
element.focus();
|
||||
} else {
|
||||
element.contentEditable = true;
|
||||
element.focus();
|
||||
@@ -165,6 +173,8 @@ function editField(button) {
|
||||
element.addEventListener("blur", function () {
|
||||
if (element.tagName === "INPUT") {
|
||||
element.readOnly = true;
|
||||
} else if (element.tagName === "SELECT") {
|
||||
element.disabled = true; // Disable dropdown
|
||||
} else {
|
||||
element.contentEditable = false;
|
||||
}
|
||||
@@ -281,19 +291,23 @@ function opDetail() {
|
||||
$row = $result->fetch_assoc();
|
||||
echo '<div class="container">';
|
||||
echo '<table class="details">';
|
||||
echo '<tr><th>Aircraft Reg</th><td></td><td>' . $row['ac_reg'] . '</td></tr>';
|
||||
echo '<tr><th>Aircraft Type</th><td></td><td>' . $row['ac_type'] . '</td></tr>';
|
||||
echo '<tr><th>Callsign</th><td></td><td>' . $row['ac_call'] . '</td></tr>';
|
||||
echo '<tr><th>Captain</th><td></td><td>' . $row['captain'] . '</td></tr>';
|
||||
echo '<tr><th>Aircraft Reg</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="text" class="editable" data-column="ac_reg" value="' . $row['ac_reg'] . '" readonly></td></tr>';
|
||||
echo '<tr><th>Aircraft Type</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="text" class="editable" data-column="ac_type" value="' . $row['ac_type'] . '" readonly></td></tr>';
|
||||
echo '<tr><th>Callsign</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="text" class="editable" data-column="ac_call" value="' . $row['ac_call'] . '" readonly></td></tr>';
|
||||
echo '<tr><th>Captain</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="text" class="editable" data-column="captain" value="' . $row['captain'] . '" readonly></td></tr>';
|
||||
echo '<tr><th>Arriving From:</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><span class="editable" data-column="in_from">' . $row['in_from'] . '</span></td></tr>';
|
||||
echo '<tr><th>POB IN</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="number" class="editable" data-column="pob_in" value="' . $row['pob_in'] . '" readonly></td></tr>';
|
||||
echo '<tr><th>ETA</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="datetime-local" class="editable" data-column="eta" value="' . ($row['eta'] ? date('Y-m-d\TH:i', strtotime($row['eta'])) : '') . '" readonly></td></tr>';
|
||||
echo '<tr><th>Fuel</th><td></td><td>' . $row['fuel'] . '</td></tr>';
|
||||
echo '<tr><th>Fuel</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><select class="editable" data-column="fuel" onchange="this.blur()" disabled>';
|
||||
echo '<option value="None"' . ($row['fuel'] === 'None' ? ' selected' : '') . '>None</option>';
|
||||
echo '<option value="100LL"' . ($row['fuel'] === '100LL' ? ' selected' : '') . '>100LL</option>';
|
||||
echo '<option value="JET A1"' . ($row['fuel'] === 'JET A1' ? ' selected' : '') . '>JET A1</option>';
|
||||
echo '</select></td></tr>';
|
||||
echo '<tr><th>POB OUT</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="number" class="editable" data-column="pob_out" value="' . $row['pob_out'] . '" readonly></td></tr>';
|
||||
echo '<tr><th>Outbound To</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><span class="editable" data-column="out_to">' . $row['out_to'] . '</span></td></tr>';
|
||||
echo '<tr><th>ETD</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="datetime-local" class="editable" data-column="etd" value="' . ($row['etd'] ? date('Y-m-d\TH:i', strtotime($row['etd'])) : '') . '" readonly></td></tr>';
|
||||
echo '<tr><th>Email Address</th><td></td><td>' . $row['email'] . '</td></tr>';
|
||||
echo '<tr><th>Phone</th><td></td><td>' . $row['phone'] . '</td></tr>';
|
||||
echo '<tr><th>Email Address</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="email" class="editable" data-column="email" value="' . $row['email'] . '" readonly></td></tr>';
|
||||
echo '<tr><th>Phone</th><td><button class="edit-button" onclick="editField(this)"><img src="assets/edit.png" alt="Edit"></button></td><td><input type="tel" class="editable" data-column="phone" value="' . $row['phone'] . '" readonly></td></tr>';
|
||||
echo '<tr><th>Notes</th><td></td><td>' . $row['notes'] . '</td></tr>';
|
||||
echo '<tr><th>PPR created</th><td></td><td>' . $row['submitted_dt'] . ' by ' . $row['created_by'] . '</td></tr>';
|
||||
echo '</table>';
|
||||
|
||||
88
tower.php
88
tower.php
@@ -213,11 +213,24 @@ function markLanded(id) {
|
||||
}
|
||||
|
||||
function markCancel(id) {
|
||||
const page = `action.php?op=cancel&id=${id}`;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", page, false); // 'false' makes the request synchronous
|
||||
xhr.send();
|
||||
window.location.reload(true);
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "This action will cancel the PPR.",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Yes, cancel it!",
|
||||
cancelButtonText: "No, keep it"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const page = `action.php?op=cancel&id=${id}`;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", page, false); // 'false' makes the request synchronous
|
||||
xhr.send();
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function openDetail(id) {
|
||||
@@ -245,6 +258,9 @@ function openDetail(id) {
|
||||
<?php
|
||||
|
||||
function renderTableCell($key, $value, $row) {
|
||||
if ($key == 'ETA' || $key == 'ETD') {
|
||||
return "<td>" . htmlspecialchars($value ?? '') . (!empty($value) ? " Z" : "") . "</td>"; // Add "Z" suffix only if not blank
|
||||
}
|
||||
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
|
||||
$notes = htmlspecialchars($row['notes'] ?? '');
|
||||
$acCall = htmlspecialchars($row['ac_call'] ?? '');
|
||||
@@ -262,6 +278,20 @@ function renderTableCell($key, $value, $row) {
|
||||
}
|
||||
}
|
||||
|
||||
function renderActionsCell($id, $status = null) {
|
||||
if ($status === 'LANDED') {
|
||||
return "<td>
|
||||
<img src='assets/cancel-icon.webp' title='Cancel PPR' style='width: 25px; height: auto;' onclick='markCancel($id)'>
|
||||
<img src='assets/depart.png' title='Depart' style='width: 30px; height: auto;' onclick='markDeparted($id)'>
|
||||
</td>";
|
||||
} else {
|
||||
return "<td>
|
||||
<img src='assets/cancel-icon.webp' title='Cancel PPR' style='width: 25px; height: auto;' onclick='markCancel($id)'>
|
||||
<img src='assets/arrive.png' title='Land' style='width: 30px; height: auto;' onclick='markLanded($id)'>
|
||||
</td>";
|
||||
}
|
||||
}
|
||||
|
||||
function renderTableRow($row) {
|
||||
$rowHtml = "<tr class='state-" . htmlspecialchars($row['status']) . "' data-id='" . htmlspecialchars($row['id']) . "'>";
|
||||
foreach ($row as $key => $value) {
|
||||
@@ -269,18 +299,11 @@ function renderTableRow($row) {
|
||||
$rowHtml .= renderTableCell($key, $value, $row);
|
||||
}
|
||||
}
|
||||
$rowHtml .= renderActionsCell($row['id']);
|
||||
$rowHtml .= renderActionsCell($row['id'], $row['status']);
|
||||
$rowHtml .= "</tr>";
|
||||
return $rowHtml;
|
||||
}
|
||||
|
||||
function renderActionsCell($id) {
|
||||
return "<td>
|
||||
<img src='assets/cancel-icon.webp' title='Cancel PPR' style='width: 25px; height: auto;' onclick='markCancel($id)'>
|
||||
<img src='assets/arrive.png' title='Land' style='width: 30px; height: auto;' onclick='markLanded($id)'>
|
||||
</td>";
|
||||
}
|
||||
|
||||
function renderTable($result) {
|
||||
$tableHtml = "<table border='1' id='arrivals'>
|
||||
<thead>
|
||||
@@ -327,44 +350,7 @@ $result = $conn->query($sql);
|
||||
|
||||
// Check if there are results
|
||||
if ($result->num_rows > 0) {
|
||||
// Start HTML table
|
||||
echo '<table border="1" id="landed">
|
||||
<thead>
|
||||
<tr>';
|
||||
|
||||
// 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') {
|
||||
echo '<th>' . htmlspecialchars($field->name ?? '') . '</th>';
|
||||
}
|
||||
|
||||
}
|
||||
echo '<th>actions</th>';
|
||||
|
||||
echo ' </tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
|
||||
// Output table rows
|
||||
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 == '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>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo ' </tbody></table>';
|
||||
echo renderTable($result); // Use the renderTable function
|
||||
} else {
|
||||
echo "No results found.";
|
||||
}
|
||||
|
||||
@@ -25,6 +25,13 @@ if (!in_array($column, $allowed_columns)) {
|
||||
die(json_encode(['error' => 'Invalid column']));
|
||||
}
|
||||
|
||||
// Convert eta or etd to UTC if supplied
|
||||
if (in_array($column, ['eta', 'etd'])) {
|
||||
$date = new DateTime($new_value, new DateTimeZone('Europe/London'));
|
||||
$date->setTimezone(new DateTimeZone('UTC'));
|
||||
$new_value = $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE submitted SET `$column` = ? WHERE id = ?");
|
||||
if (!$stmt) {
|
||||
die(json_encode(['error' => 'Prepare statement failed']));
|
||||
|
||||
Reference in New Issue
Block a user