WIP booking out

This commit is contained in:
2025-03-11 18:19:51 +00:00
parent ce9de8d7ff
commit 8ce6b3d0fd
6 changed files with 226 additions and 35 deletions

View File

@@ -88,11 +88,45 @@ function opCancel() {
}
function opLanded() {
$date = date('Y-m-d');
$time = urldecode($_GET['time']);
$landed_dt = $date . ' ' . $time;
$conn = connectDb();
$sql = "UPDATE submitted SET status = 'LANDED', landed_dt = NOW() where id = " . $_GET['id'];
$result = $conn->query($sql);
logJournal($conn, $_GET['id'], "Marked Landed");
$sql = "UPDATE submitted SET status = 'LANDED', landed_dt = ? WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("si", $landed_dt, $_GET['id']);
$stmt->execute();
$stmt->close();
logJournal($conn, $_GET['id'], "Marked Landed at time " . $time);
$conn->close();
}
function opDeparted() {
$date = date('Y-m-d');
$time = urldecode($_GET['time']);
$departed_dt = $date . ' ' . $time;
$conn = connectDb();
$sql = "UPDATE submitted SET status = 'DEPARTED', departed_dt = ? WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("si", $departed_dt, $_GET['id']);
$stmt->execute();
$stmt->close();
logJournal($conn, $_GET['id'], "Marked Departed at time " . $time);
$conn->close();
}
function opDelete() {
@@ -148,6 +182,9 @@ switch($_GET['op']) {
case "landed":
opLanded();
break;
case "departed":
opDeparted();
break;
case "delete":
opDelete();
break;

BIN
arrive.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
depart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -128,9 +128,9 @@ function validateSecureToken($token) {
list($email, $entryId, $timestamp, $hash) = explode('|', $decoded);
// Check expiration (e.g., valid for 1 hour)
if (time() - $timestamp > 3600) {
return false;
}
//if (time() - $timestamp > 3600) {
// return false;
//}
// Verify hash
$data = "$email|$entryId|$timestamp";

View File

@@ -36,7 +36,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo "Username is not set.";
}
//echo '<script>window.close();</script>';
echo '<script>window.close();</script>';
} else {
echo "<p>Error inserting data: " . $conn->error . "</p>";
}

210
tower.php
View File

@@ -7,6 +7,8 @@ require_db_auth();
<html lang="en">
<head>
<meta http-equiv="refresh" content="300">
<!-- Include SweetAlert -->
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
let rows = document.querySelectorAll("table tbody tr");
@@ -37,6 +39,15 @@ require_db_auth();
width: fit-content;
}
.heading {
width: 80%;
margin: 20px auto;
background-color: #fff;
text-align: center;
font-family: Arial, sans-serif;
font-size: 20pt;
}
label {
display: flex;
align-items: center;
@@ -133,14 +144,101 @@ require_db_auth();
</head>
<body>
<script>
function markLanded(id) {
page="action.php?op=landed&id=" + id;
<script>
function markDeparted(id) {
const now = new Date();
const currentTime = now.toISOString().slice(11, 16); // Extract HH:MM
Swal.fire({
title: "Depart Aircraft at time",
html: `<input type="time" id="timepicker" class="swal2-input" value="${currentTime}">`,
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Departed",
preConfirm: () => {
const time = document.getElementById("timepicker").value;
if (!time) {
Swal.showValidationMessage("Please select a time");
}
return time;
}
}).then((result) => {
if (result.isConfirmed) {
page="action.php?op=departed&id=" + id + "&time=" + encodeURIComponent(result.value);
var xhr = new XMLHttpRequest();
xhr.open("GET", page, false); // 'false' makes the request synchronous
xhr.send();
window.location.reload(true);
}
});
}
function markLanded(id) {
const now = new Date();
const currentTime = now.toISOString().slice(11, 16); // Extract HH:MM
Swal.fire({
title: "Land Aircraft at time",
html: `<input type="time" id="timepicker" class="swal2-input" value="${currentTime}">`,
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Landed",
preConfirm: () => {
const time = document.getElementById("timepicker").value;
if (!time) {
Swal.showValidationMessage("Please select a time");
}
return time;
}
}).then((result) => {
if (result.isConfirmed) {
page="action.php?op=landed&id=" + id + "&time=" + encodeURIComponent(result.value);
var xhr = new XMLHttpRequest();
xhr.open("GET", page, false); // 'false' makes the request synchronous
xhr.send();
window.location.reload(true);
}
});
}
function markLanded(id) {
const now = new Date();
const currentTime = now.toISOString().slice(11, 16); // Extract HH:MM
Swal.fire({
title: "Land Aircraft at time",
html: `<input type="time" id="timepicker" class="swal2-input" value="${currentTime}">`,
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Landed",
preConfirm: () => {
const time = document.getElementById("timepicker").value;
if (!time) {
Swal.showValidationMessage("Please select a time");
}
return time;
}
}).then((result) => {
if (result.isConfirmed) {
page="action.php?op=landed&id=" + id + "&time=" + encodeURIComponent(result.value);
var xhr = new XMLHttpRequest();
xhr.open("GET", page, false); // 'false' makes the request synchronous
xhr.send();
window.location.reload(true);
}
});
}
function markCancel(id) {
page="action.php?op=cancel&id=" + id;
var xhr = new XMLHttpRequest();
@@ -160,17 +258,16 @@ require_db_auth();
}
</script>
<center><h2>Swansea Inbound PPR <?php echo date('l d M Y'); ?></h2></center>
<center><h2>Tower Ops <?php echo date('l d M Y'); ?></h2></center>
<div class="checkbox-container">
<label>
<input type="checkbox" id="toggle-landed" onchange="toggleRows('state-LANDED', this.checked)"> Show LANDED
</label>
<label>
<input type="checkbox" id="toggle-canceled" onchange="toggleRows('state-CANCELED', this.checked)"> Show CANCELED
</label>
</div>
<div class="heading">Inbound PPR</div>
<?php
// Create connection
@@ -181,15 +278,8 @@ if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$custom_headings = [
'column1' => 'Custom Heading 1',
'column2' => 'Custom Heading 2',
'column3' => 'Custom Heading 3'
// Add more custom headings as needed
];
// 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 FROM submitted WHERE DATE(eta) = CURDATE() AND status != 'DELETED' 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);
@@ -197,7 +287,7 @@ $result = $conn->query($sql);
// Check if there are results
if ($result->num_rows > 0) {
// Start HTML table
echo '<table border="1" id="entries">
echo '<table border="1" id="arrivals">
<thead>
<tr>';
@@ -227,7 +317,63 @@ if ($result->num_rows > 0) {
}
}
}
echo '<td><span class=acreg>' . $row['status'] .'</span><br><img src="cancel-icon.webp" title="Cancel PPR" style="width: 25px; height: auto;" onclick="markCancel(' . $row['id'] . ')"><img src="land.webp" title="Mark Landed" style="width: 30px; height: auto;" onclick="markLanded(' . $row['id'] . ')"></td>';
echo '<td><img src="cancel-icon.webp" title="Cancel PPR" style="width: 25px; height: auto;" onclick="markCancel(' . $row['id'] . ')"><img src="arrive.png" title="Land" style="width: 30px; height: auto;" onclick="markLanded(' . $row['id'] . ')"></td>';
echo '</tr>';
}
echo ' </tbody></table>';
} else {
echo "No results found.";
}
?>
<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 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);
// 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 != '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 != '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 {
echo '<td>' . htmlspecialchars($value ?? '') . '</td>';
}
}
}
echo '<td><img src="cancel-icon.webp" title="Cancel PPR" style="width: 25px; height: auto;" onclick="markCancel(' . $row['id'] . ')"><img src="depart.png" title="Depart" style="width: 30px; height: auto;" onclick="markDeparted(' . $row['id'] . ')"></td>';
echo '</tr>';
}
@@ -241,6 +387,8 @@ $conn->close();
?>
</div>
<center><button onclick="openPopup()">Log New PPR</button></center>
<script>
@@ -264,21 +412,27 @@ $conn->close();
}
document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll('.state-LANDED, .state-CANCELED').forEach(row => {
document.querySelectorAll('.state-CANCELED').forEach(row => {
row.classList.add('hidden');
});
});
document.getElementById("arrivals").addEventListener("click", clickRow);
document.getElementById("landed").addEventListener("click", clickRow);
document.getElementById("entries").addEventListener("click", function (event) {
let td = event.target.closest("td");
if (!td) return; // Clicked outside <td>
function clickRow (event) {
let td = event.target.closest("td");
if (!td) return; // Clicked outside <td>
let tr = td.parentElement; // Get the row
let tr = td.parentElement; // Get the row
if (td !== tr.lastElementChild) {
let rowId = tr.dataset.id; // Get the unique row ID
openDetail(rowId);
}
});
</script>
if (td !== tr.lastElementChild) {
let rowId = tr.dataset.id; // Get the unique row ID
openDetail(rowId);
}
}
</script>