WIP booking out
This commit is contained in:
43
action.php
43
action.php
@@ -88,11 +88,45 @@ function opCancel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function opLanded() {
|
function opLanded() {
|
||||||
|
|
||||||
|
$date = date('Y-m-d');
|
||||||
|
$time = urldecode($_GET['time']);
|
||||||
|
$landed_dt = $date . ' ' . $time;
|
||||||
|
|
||||||
$conn = connectDb();
|
$conn = connectDb();
|
||||||
$sql = "UPDATE submitted SET status = 'LANDED', landed_dt = NOW() where id = " . $_GET['id'];
|
$sql = "UPDATE submitted SET status = 'LANDED', landed_dt = ? WHERE id = ?";
|
||||||
$result = $conn->query($sql);
|
|
||||||
logJournal($conn, $_GET['id'], "Marked Landed");
|
$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();
|
$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() {
|
function opDelete() {
|
||||||
@@ -148,6 +182,9 @@ switch($_GET['op']) {
|
|||||||
case "landed":
|
case "landed":
|
||||||
opLanded();
|
opLanded();
|
||||||
break;
|
break;
|
||||||
|
case "departed":
|
||||||
|
opDeparted();
|
||||||
|
break;
|
||||||
case "delete":
|
case "delete":
|
||||||
opDelete();
|
opDelete();
|
||||||
break;
|
break;
|
||||||
|
|||||||
BIN
arrive.png
Normal file
BIN
arrive.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
depart.png
Normal file
BIN
depart.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
@@ -128,9 +128,9 @@ function validateSecureToken($token) {
|
|||||||
list($email, $entryId, $timestamp, $hash) = explode('|', $decoded);
|
list($email, $entryId, $timestamp, $hash) = explode('|', $decoded);
|
||||||
|
|
||||||
// Check expiration (e.g., valid for 1 hour)
|
// Check expiration (e.g., valid for 1 hour)
|
||||||
if (time() - $timestamp > 3600) {
|
//if (time() - $timestamp > 3600) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Verify hash
|
// Verify hash
|
||||||
$data = "$email|$entryId|$timestamp";
|
$data = "$email|$entryId|$timestamp";
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
echo "Username is not set.";
|
echo "Username is not set.";
|
||||||
}
|
}
|
||||||
|
|
||||||
//echo '<script>window.close();</script>';
|
echo '<script>window.close();</script>';
|
||||||
} else {
|
} else {
|
||||||
echo "<p>Error inserting data: " . $conn->error . "</p>";
|
echo "<p>Error inserting data: " . $conn->error . "</p>";
|
||||||
}
|
}
|
||||||
|
|||||||
208
tower.php
208
tower.php
@@ -7,6 +7,8 @@ require_db_auth();
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="refresh" content="300">
|
<meta http-equiv="refresh" content="300">
|
||||||
|
<!-- Include SweetAlert -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
let rows = document.querySelectorAll("table tbody tr");
|
let rows = document.querySelectorAll("table tbody tr");
|
||||||
@@ -37,6 +39,15 @@ require_db_auth();
|
|||||||
width: fit-content;
|
width: fit-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.heading {
|
||||||
|
width: 80%;
|
||||||
|
margin: 20px auto;
|
||||||
|
background-color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
font-size: 20pt;
|
||||||
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -133,14 +144,101 @@ require_db_auth();
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function markLanded(id) {
|
function markDeparted(id) {
|
||||||
page="action.php?op=landed&id=" + 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();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", page, false); // 'false' makes the request synchronous
|
xhr.open("GET", page, false); // 'false' makes the request synchronous
|
||||||
xhr.send();
|
xhr.send();
|
||||||
window.location.reload(true);
|
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) {
|
function markCancel(id) {
|
||||||
page="action.php?op=cancel&id=" + id;
|
page="action.php?op=cancel&id=" + id;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
@@ -160,17 +258,16 @@ require_db_auth();
|
|||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</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">
|
<div class="checkbox-container">
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="toggle-landed" onchange="toggleRows('state-LANDED', this.checked)"> Show LANDED
|
|
||||||
</label>
|
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" id="toggle-canceled" onchange="toggleRows('state-CANCELED', this.checked)"> Show CANCELED
|
<input type="checkbox" id="toggle-canceled" onchange="toggleRows('state-CANCELED', this.checked)"> Show CANCELED
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="heading">Inbound PPR</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Create connection
|
// Create connection
|
||||||
@@ -181,15 +278,8 @@ if ($conn->connect_error) {
|
|||||||
die("Connection failed: " . $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
|
// 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
|
// Execute the query
|
||||||
$result = $conn->query($sql);
|
$result = $conn->query($sql);
|
||||||
@@ -197,7 +287,7 @@ $result = $conn->query($sql);
|
|||||||
// Check if there are results
|
// Check if there are results
|
||||||
if ($result->num_rows > 0) {
|
if ($result->num_rows > 0) {
|
||||||
// Start HTML table
|
// Start HTML table
|
||||||
echo '<table border="1" id="entries">
|
echo '<table border="1" id="arrivals">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>';
|
<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>';
|
echo '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,6 +387,8 @@ $conn->close();
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<center><button onclick="openPopup()">Log New PPR</button></center>
|
<center><button onclick="openPopup()">Log New PPR</button></center>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -264,21 +412,27 @@ $conn->close();
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
document.querySelectorAll('.state-LANDED, .state-CANCELED').forEach(row => {
|
document.querySelectorAll('.state-CANCELED').forEach(row => {
|
||||||
row.classList.add('hidden');
|
row.classList.add('hidden');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById("arrivals").addEventListener("click", clickRow);
|
||||||
|
document.getElementById("landed").addEventListener("click", clickRow);
|
||||||
|
|
||||||
document.getElementById("entries").addEventListener("click", function (event) {
|
function clickRow (event) {
|
||||||
let td = event.target.closest("td");
|
let td = event.target.closest("td");
|
||||||
if (!td) return; // Clicked outside <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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (td !== tr.lastElementChild) {
|
|
||||||
let rowId = tr.dataset.id; // Get the unique row ID
|
|
||||||
openDetail(rowId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user