Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1bd87c9d1b | |||
| faec70c562 | |||
| cd1afc491c |
337
action.php
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
@@ -33,10 +34,6 @@
|
|||||||
background-color: #f9f9f9;
|
background-color: #f9f9f9;
|
||||||
}
|
}
|
||||||
|
|
||||||
.details th {
|
|
||||||
text-align: right; /* Justify table headings to the right */
|
|
||||||
}
|
|
||||||
|
|
||||||
.details p {
|
.details p {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
@@ -74,150 +71,9 @@
|
|||||||
button:hover {
|
button:hover {
|
||||||
background-color: #0056b3;
|
background-color: #0056b3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editable {
|
|
||||||
padding: 5px;
|
|
||||||
font-size: 16px;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 5px;
|
|
||||||
width: 90%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
input:focus {
|
|
||||||
border-color: #007bff;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edit-button {
|
|
||||||
margin-left: 10px;
|
|
||||||
padding: 5px 10px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
background-color: transparent;
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edit-button img {
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edit-button:hover img {
|
|
||||||
filter: brightness(0.8);
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
element.addEventListener("focus", function () {
|
|
||||||
oldValue = this.value || this.textContent.trim(); // Store old value when focused
|
|
||||||
});
|
|
||||||
|
|
||||||
element.addEventListener("blur", function () {
|
|
||||||
let newValue = this.value || this.textContent.trim();
|
|
||||||
let column = this.getAttribute("data-column");
|
|
||||||
|
|
||||||
if (newValue !== oldValue) {
|
|
||||||
sendUpdate(id, column, oldValue, newValue, element);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
element.addEventListener("keydown", function (event) {
|
|
||||||
if (event.key === "Enter") {
|
|
||||||
event.preventDefault(); // Prevent new line
|
|
||||||
this.blur(); // Trigger blur event to save changes
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Select all edit buttons
|
|
||||||
document.querySelectorAll(".edit-button").forEach((button) => {
|
|
||||||
button.addEventListener("click", function () {
|
|
||||||
editField(button);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables editing for the field
|
|
||||||
*/
|
|
||||||
function editField(button) {
|
|
||||||
let element = button.parentElement.nextElementSibling.firstElementChild;
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}, { once: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the updated data to the server
|
|
||||||
*/
|
|
||||||
function sendUpdate(flightId, column, oldValue, newValue, element) {
|
|
||||||
fetch("update_data.php", {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
||||||
body: `id=${flightId}&column=${encodeURIComponent(column)}&old_value=${encodeURIComponent(oldValue)}&new_value=${encodeURIComponent(newValue)}`
|
|
||||||
})
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
if (data.success) {
|
|
||||||
console.log(`Updated: ${data.column} changed from '${data.old_value}' to '${data.new_value}'`);
|
|
||||||
oldValue = newValue; // ✅ Update oldValue to prevent reverting
|
|
||||||
} else {
|
|
||||||
alert("Error updating data");
|
|
||||||
if (element.tagName === "INPUT") {
|
|
||||||
element.value = oldValue; // ❌ Revert ONLY if update fails
|
|
||||||
} else {
|
|
||||||
element.textContent = oldValue; // ❌ Revert ONLY if update fails
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error("Fetch error:", error);
|
|
||||||
if (element.tagName === "INPUT") {
|
|
||||||
element.value = oldValue; // ❌ Revert only on network failure
|
|
||||||
} else {
|
|
||||||
element.textContent = oldValue; // ❌ Revert only on network failure
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
include("functions.php");
|
include("functions.php");
|
||||||
@@ -227,58 +83,12 @@ function opCancel() {
|
|||||||
$conn = connectDb();
|
$conn = connectDb();
|
||||||
$sql = "UPDATE submitted SET status = 'CANCELED' where id = " . $_GET['id'];
|
$sql = "UPDATE submitted SET status = 'CANCELED' where id = " . $_GET['id'];
|
||||||
$result = $conn->query($sql);
|
$result = $conn->query($sql);
|
||||||
logJournal($conn, $_GET['id'], "Marked Canceled");
|
|
||||||
$conn->close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = ? WHERE id = ?";
|
$sql = "UPDATE submitted SET status = 'LANDED', landed_dt = NOW() where id = " . $_GET['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() {
|
|
||||||
$conn = connectDb();
|
|
||||||
$sql = "UPDATE submitted SET status = 'DELETED' where id = " . $_GET['id'];
|
|
||||||
$result = $conn->query($sql);
|
$result = $conn->query($sql);
|
||||||
logJournal($conn, $_GET['id'], "Marked Deleted");
|
|
||||||
$conn->close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function opDetail() {
|
function opDetail() {
|
||||||
@@ -290,60 +100,32 @@ function opDetail() {
|
|||||||
// Output data of the row
|
// Output data of the row
|
||||||
$row = $result->fetch_assoc();
|
$row = $result->fetch_assoc();
|
||||||
echo '<div class="container">';
|
echo '<div class="container">';
|
||||||
echo '<table class="details">';
|
echo '<div class="details"><p><strong>Aircraft Reg: </strong>' . $row['ac_reg'] . "</p>";
|
||||||
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 "<p><strong>Aircraft Type:</strong> " . $row['ac_type'] . "</p>";
|
||||||
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 "<p><strong>Callsign:</strong> " . $row['ac_call'] . "</p>";
|
||||||
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 "<p><strong>Captain's Name:</strong> " . $row['captain'] . "</p>";
|
||||||
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 "<p><strong>Arriving From:</strong> " . $row['in_from'] . "</p>";
|
||||||
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 "<p><strong>POB IN:</strong> " . $row['pob_in'] . "</p>";
|
||||||
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 "<p><strong>ETA:</strong> " . $row['eta'] . "</p>";
|
||||||
echo '<tr><th>ETA Z</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><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 Z</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><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>';
|
|
||||||
|
|
||||||
// Fetch journal entries
|
echo "<p><strong>Fuel Required:</strong> " . $row['fuel'] . "</p>";
|
||||||
$journalSql = "SELECT * FROM journal WHERE ppr_id = " . $_GET['id'] . " ORDER BY id DESC";
|
|
||||||
$journalResult = $conn->query($journalSql);
|
|
||||||
$journalCount = $journalResult->num_rows;
|
|
||||||
|
|
||||||
// Add button to toggle journal entries
|
echo "<p><strong>POB OUT:</strong> " . $row['pob_out'] . "</p>";
|
||||||
echo '<br><button onclick="window.close()">Close Window</button>';
|
echo "<p><strong>Outbound To:</strong> " . $row['out_to'] . "</p>";
|
||||||
echo ' <button onclick="toggleJournal()">Show Journal Entries (' . $journalCount . ')</button>';
|
echo "<p><strong>ETD:</strong> " . $row['etd'] . "</p>";
|
||||||
echo '<div id="journal-entries" style="display:none;">';
|
|
||||||
echo '<h3>Journal Entries</h3>';
|
|
||||||
echo '<table class="journal-table">';
|
|
||||||
echo '<tr><th>Timestamp</th><th>User</th><th>Entry</th></tr>';
|
|
||||||
|
|
||||||
if ($journalCount > 0) {
|
|
||||||
while ($journalRow = $journalResult->fetch_assoc()) {
|
|
||||||
echo '<tr>';
|
|
||||||
echo '<td>' . $journalRow['entry_dt'] . '</td>';
|
|
||||||
echo '<td>' . $journalRow['user'] . '</td>';
|
|
||||||
echo '<td>' . $journalRow['entry'] . '</td>';
|
|
||||||
echo '</tr>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
echo '<tr><td colspan="3">No journal entries found.</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '</table>';
|
echo "<p><strong>Email Address:</strong> " . $row['email'] . "</p>";
|
||||||
echo '</div>';
|
echo "<p><strong>Phone:</strong> " . $row['phone'] . "</p>";
|
||||||
echo '</div>';
|
|
||||||
|
|
||||||
|
echo "<p><strong>Notes:</strong> " . $row['notes'] . "</p>";
|
||||||
|
echo "<p><i>PPR created at:</strong> " . $row['submitted_dt'] . " by " . $row['created_by'] . "</p></div>";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
echo "No details found for the given ID.";
|
echo "No details found for the given ID.";
|
||||||
|
|
||||||
}
|
}
|
||||||
$conn->close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($_GET['op']) {
|
switch($_GET['op']) {
|
||||||
@@ -353,12 +135,6 @@ switch($_GET['op']) {
|
|||||||
case "landed":
|
case "landed":
|
||||||
opLanded();
|
opLanded();
|
||||||
break;
|
break;
|
||||||
case "departed":
|
|
||||||
opDeparted();
|
|
||||||
break;
|
|
||||||
case "delete":
|
|
||||||
opDelete();
|
|
||||||
break;
|
|
||||||
case "detail":
|
case "detail":
|
||||||
opDetail();
|
opDetail();
|
||||||
break;
|
break;
|
||||||
@@ -366,74 +142,7 @@ switch($_GET['op']) {
|
|||||||
default:
|
default:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
<p><center><button onclick="window.close()">Close Window</button></center>
|
||||||
<script>
|
|
||||||
function toggleJournal() {
|
|
||||||
var journalEntries = document.getElementById("journal-entries");
|
|
||||||
var toggleButton = document.querySelector("button[onclick='toggleJournal()']");
|
|
||||||
if (journalEntries.style.display === "none") {
|
|
||||||
journalEntries.style.display = "block";
|
|
||||||
toggleButton.textContent = "Hide Journal Entries";
|
|
||||||
} else {
|
|
||||||
journalEntries.style.display = "none";
|
|
||||||
toggleButton.textContent = "Show Journal Entries";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.journal-table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.journal-table th, .journal-table td {
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
padding: 8px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.journal-table th {
|
|
||||||
background-color: #f2f2f2;
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.journal-table tr:nth-child(even) {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.journal-table tr:hover {
|
|
||||||
background-color: #f1f1f1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edit-button {
|
|
||||||
margin-left: 10px;
|
|
||||||
padding: 5px 10px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
background-color: transparent;
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edit-button img {
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edit-button:hover img {
|
|
||||||
filter: brightness(0.8);
|
|
||||||
}
|
|
||||||
|
|
||||||
.editable {
|
|
||||||
background-color: transparent;
|
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editable:focus {
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|||||||
208
admin.php
@@ -1,208 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("functions.php");
|
|
||||||
require_db_auth();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>PPR Monthly Reports</title>
|
|
||||||
<style>
|
|
||||||
|
|
||||||
/* Styling for the table */
|
|
||||||
table {
|
|
||||||
width: 90%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin: 20px 0;
|
|
||||||
margin-left: auto; /* Automatically adjusts left margin */
|
|
||||||
margin-right: auto; /* Automatically adjusts right margin */
|
|
||||||
|
|
||||||
}
|
|
||||||
table, th, td {
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
padding: 2px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 2px;
|
|
||||||
text-align: center;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
font-size: 8pt;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
background-color: #f2f2f2;
|
|
||||||
}
|
|
||||||
tr:nth-child(even) {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
|
||||||
tr:hover {
|
|
||||||
background-color: #f1f1f1;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
padding: 10px 20px;
|
|
||||||
font-size: 1rem;
|
|
||||||
background-color: #007bff;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
button:hover {
|
|
||||||
background-color: #0056b3;
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
|
||||||
padding: 10px;
|
|
||||||
font-size: 16px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<?php include("menu.php"); ?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function openDetail(id) {
|
|
||||||
page="action.php?op=detail&id=" + id;
|
|
||||||
var popupWindow = window.open(page, "PopupWindow", "toolbar=no, location=no, directories=no,status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=600, height=1100");
|
|
||||||
popupWindow.onload = function () {
|
|
||||||
var contentHeight = popupWindow.document.body.scrollHeight;
|
|
||||||
var contentWidth = popupWindow.document.body.scrollWidth;
|
|
||||||
popupWindow.resizeTo(contentWidth + 20, contentHeight + 180); // Adding padding to prevent clipping
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<center><h2>Swansea Inbound PPR ADMIN</h2></center>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div style="display: inline-block; text-align: left;">
|
|
||||||
<select id="monthSelect">
|
|
||||||
<option value="1">January</option>
|
|
||||||
<option value="2">February</option>
|
|
||||||
<option value="3">March</option>
|
|
||||||
<option value="4">April</option>
|
|
||||||
<option value="5">May</option>
|
|
||||||
<option value="6">June</option>
|
|
||||||
<option value="7">July</option>
|
|
||||||
<option value="8">August</option>
|
|
||||||
<option value="9">September</option>
|
|
||||||
<option value="10">October</option>
|
|
||||||
<option value="11">November</option>
|
|
||||||
<option value="12">December</option>
|
|
||||||
</select>
|
|
||||||
<select id="yearSelect"></select>
|
|
||||||
<button onclick="selectMonthYear()">Submit</button>
|
|
||||||
<button onclick="downloadCSV()">Download CSV</button>
|
|
||||||
</div>
|
|
||||||
<p id="output"></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function populateYearDropdown() {
|
|
||||||
let yearSelect = document.getElementById("yearSelect");
|
|
||||||
let currentYear = new Date().getFullYear();
|
|
||||||
let startYear = currentYear;
|
|
||||||
let endYear = currentYear - 10; // Last 10 years
|
|
||||||
|
|
||||||
for (let year = startYear; year >= endYear; year--) { // Descending order
|
|
||||||
let option = document.createElement("option");
|
|
||||||
option.value = year;
|
|
||||||
option.textContent = year;
|
|
||||||
if (year === currentYear) {
|
|
||||||
option.selected = true; // Set default to current year
|
|
||||||
}
|
|
||||||
yearSelect.appendChild(option);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectMonthYear() {
|
|
||||||
let month = document.getElementById("monthSelect").value;
|
|
||||||
let year = document.getElementById("yearSelect").value;
|
|
||||||
window.location.href = `admin.php?year=${year}&month=${month}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectMonth() {
|
|
||||||
let month = new URLSearchParams(window.location.search).get('month') ?? new Date().getMonth() + 1;
|
|
||||||
document.getElementById("monthSelect").value = month;
|
|
||||||
}
|
|
||||||
|
|
||||||
const year = new URLSearchParams(window.location.search).get('year') ?? new Date().getFullYear();
|
|
||||||
const month = new URLSearchParams(window.location.search).get('month') ?? new Date().getMonth() + 1;
|
|
||||||
|
|
||||||
selectMonth();
|
|
||||||
populateYearDropdown();
|
|
||||||
|
|
||||||
function downloadCSV() {
|
|
||||||
let year = document.getElementById("yearSelect").value;
|
|
||||||
let month = document.getElementById("monthSelect").value;
|
|
||||||
window.location.href = `download.php?year=${year}&month=${month}`;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$conn = connectDb();
|
|
||||||
|
|
||||||
$year = $_GET['year'] ?? date('Y');
|
|
||||||
$month = $_GET['month'] ?? date('n');
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM submitted WHERE status != 'DELETED' and MONTH(eta) = $month and YEAR(eta) = $year ORDER BY eta ASC;"; // Replace with your table name
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
// Check if there are results
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
// Start HTML table
|
|
||||||
echo '<table border="1">
|
|
||||||
<thead>
|
|
||||||
<tr>';
|
|
||||||
|
|
||||||
// Output table headers (assuming column names are known)
|
|
||||||
$fields = $result->fetch_fields();
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
if ($field->name != 'id') {
|
|
||||||
echo '<th>' . htmlspecialchars($field->name ?? '') . '</th>';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
echo ' </tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>';
|
|
||||||
|
|
||||||
// Output table rows
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
echo '<tr onclick="openDetail(' . $row['id'] . ')">';
|
|
||||||
foreach ($row as $key => $value) {
|
|
||||||
if ($key != 'id') {
|
|
||||||
echo '<td>' . htmlspecialchars($value ?? '') . '</td>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo ' </tbody></table>';
|
|
||||||
} else {
|
|
||||||
echo "No results found.";
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn->close();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php include("footer.php"); ?>
|
|
||||||
59
arrivals.php
@@ -25,53 +25,56 @@ include("functions.php");
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Swansea Daily PPR</title>
|
<title>Swansea Daily PPR</title>
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
/* Styling for the table */
|
/* Styling for the table */
|
||||||
table {
|
table {
|
||||||
width: 90%;
|
width: 80%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
margin: 20px auto;
|
margin: 20px 0;
|
||||||
background-color: #000; /* Black background for digital display effect */
|
margin-left: auto; /* Automatically adjusts left margin */
|
||||||
color: #0f0; /* Bright green text for digital display effect */
|
margin-right: auto; /* Automatically adjusts right margin */
|
||||||
font-family: 'Courier New', Courier, monospace; /* Monospace font for digital look */
|
|
||||||
font-size: 18px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
table, th, td {
|
table, th, td {
|
||||||
border: 1px solid #444; /* Subtle border for table cells */
|
border: 1px solid #ddd;
|
||||||
}
|
}
|
||||||
th {
|
th {
|
||||||
padding: 10px;
|
padding: 8px;
|
||||||
background-color: #222; /* Darker background for headers */
|
text-align: center;
|
||||||
color: #fff; /* White text for headers */
|
|
||||||
font-weight: bold;
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
}
|
||||||
td {
|
td {
|
||||||
padding: 10px;
|
padding: 8px;
|
||||||
|
text-align: center;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
font-size: 16pt;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color: #f2f2f2;
|
||||||
}
|
}
|
||||||
tr:nth-child(even) {
|
tr:nth-child(even) {
|
||||||
background-color: #111; /* Slightly lighter background for even rows */
|
background-color: #f9f9f9;
|
||||||
}
|
}
|
||||||
tr:hover {
|
tr:hover {
|
||||||
background-color: #333; /* Highlight row on hover */
|
background-color: #f1f1f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Highlight styles for fuel types */
|
|
||||||
.highlight100LL {
|
.highlight100LL {
|
||||||
background-color: #0044cc !important; /* Blue for 100LL */
|
background-color: #ADD8E6 !important;
|
||||||
color: #fff !important; /* White text */
|
#font-weight: bold;
|
||||||
}
|
|
||||||
.highlightJET {
|
|
||||||
background-color: #ffcc00 !important; /* Yellow for JET A1 */
|
|
||||||
color: #000 !important; /* Black text */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Styling for aircraft registration */
|
.highlightJET {
|
||||||
.acreg {
|
background-color: yellow !important; /* Allow it to override the odd/even shading */
|
||||||
font-size: 14px;
|
#font-weight: bold;
|
||||||
font-style: italic;
|
|
||||||
color: #ccc; /* Light gray for subtle emphasis */
|
|
||||||
}
|
}
|
||||||
|
.acreg {
|
||||||
|
padding: 4px;
|
||||||
|
text-align: center;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
font-size: 10pt;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
BIN
assets/edit.png
|
Before Width: | Height: | Size: 13 KiB |
BIN
assets/egfh.webp
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 56 KiB |
BIN
assets/logo.png
|
Before Width: | Height: | Size: 22 KiB |
259
bookout.html
@@ -1,259 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Book Out</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
background-color: #f4f4f4;
|
|
||||||
}
|
|
||||||
.form-container {
|
|
||||||
max-width: 500px;
|
|
||||||
margin: 20px auto;
|
|
||||||
padding: 20px;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 8px;
|
|
||||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
.form-container h2 {
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: 15px;
|
|
||||||
}
|
|
||||||
.form-group label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
.form-group input, .form-group select {
|
|
||||||
width: 100%;
|
|
||||||
padding: 10px;
|
|
||||||
font-size: 1rem;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
.form-group input:focus, .form-group select:focus {
|
|
||||||
border-color: #007bff;
|
|
||||||
outline: none;
|
|
||||||
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
|
|
||||||
}
|
|
||||||
.hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
button {
|
|
||||||
width: 100%;
|
|
||||||
padding: 10px;
|
|
||||||
font-size: 1rem;
|
|
||||||
color: #fff;
|
|
||||||
background-color: #007bff;
|
|
||||||
border: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
button:hover {
|
|
||||||
background-color: #0056b3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.form-container {
|
|
||||||
width: 100%; /* Ensure it fits the screen */
|
|
||||||
margin: 20px auto;
|
|
||||||
padding: 15px;
|
|
||||||
box-sizing: border-box; /* Include padding in width calculation */
|
|
||||||
}
|
|
||||||
.form-group input, .form-group select, button {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
h2 {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
|
||||||
.form-container {
|
|
||||||
width: 100%; /* Ensure it fits the screen */
|
|
||||||
margin: 10px auto;
|
|
||||||
padding: 10px;
|
|
||||||
box-sizing: border-box; /* Include padding in width calculation */
|
|
||||||
}
|
|
||||||
.form-group input, .form-group select, button {
|
|
||||||
font-size: 0.8rem;
|
|
||||||
padding: 6px;
|
|
||||||
}
|
|
||||||
h2 {
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.nature-button {
|
|
||||||
flex: 1;
|
|
||||||
padding: 10px;
|
|
||||||
font-size: 1rem;
|
|
||||||
color: #fff;
|
|
||||||
background-color: #007bff;
|
|
||||||
border: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.3s;
|
|
||||||
}
|
|
||||||
.nature-button:hover {
|
|
||||||
background-color: #0056b3;
|
|
||||||
}
|
|
||||||
.nature-button.selected {
|
|
||||||
background-color: #28a745; /* Green for selected */
|
|
||||||
}
|
|
||||||
|
|
||||||
.pob-button {
|
|
||||||
flex: 1;
|
|
||||||
padding: 10px;
|
|
||||||
font-size: 1rem;
|
|
||||||
color: #fff;
|
|
||||||
background-color: #007bff;
|
|
||||||
border: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.3s;
|
|
||||||
}
|
|
||||||
.pob-button:hover {
|
|
||||||
background-color: #0056b3;
|
|
||||||
}
|
|
||||||
.pob-button.selected {
|
|
||||||
background-color: #28a745; /* Green for selected */
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
function toggleLandawayFields(natureOfFlight) {
|
|
||||||
const landawayFields = document.getElementById("landaway-fields");
|
|
||||||
document.getElementById("nature_of_flight").value = natureOfFlight;
|
|
||||||
|
|
||||||
// Update button styles
|
|
||||||
document.querySelectorAll(".nature-button").forEach(button => {
|
|
||||||
button.classList.remove("selected");
|
|
||||||
});
|
|
||||||
document.getElementById(`nature_${natureOfFlight}`).classList.add("selected");
|
|
||||||
|
|
||||||
if (natureOfFlight === "Landaway") {
|
|
||||||
landawayFields.classList.remove("hidden");
|
|
||||||
} else {
|
|
||||||
landawayFields.classList.add("hidden");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectPOB(pob) {
|
|
||||||
document.getElementById("pob").value = pob;
|
|
||||||
|
|
||||||
// Update button styles
|
|
||||||
document.querySelectorAll(".pob-button").forEach(button => {
|
|
||||||
button.classList.remove("selected");
|
|
||||||
});
|
|
||||||
document.getElementById(`pob_${pob}`).classList.add("selected");
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCookie(name, value, days) {
|
|
||||||
const date = new Date();
|
|
||||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
||||||
document.cookie = `${name}=${value};expires=${date.toUTCString()};path=/`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCookie(name) {
|
|
||||||
const cookies = document.cookie.split(';');
|
|
||||||
for (let i = 0; i < cookies.length; i++) {
|
|
||||||
const cookie = cookies[i].trim();
|
|
||||||
if (cookie.startsWith(name + '=')) {
|
|
||||||
return cookie.substring(name.length + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleAircraftRegInput() {
|
|
||||||
const acRegInput = document.getElementById("ac_reg");
|
|
||||||
const acTypeInput = document.getElementById("ac_type");
|
|
||||||
const captainNameInput = document.getElementById("captain_name");
|
|
||||||
acRegInput.value = acRegInput.value.toUpperCase();
|
|
||||||
setCookie("ac_reg", acRegInput.value, 30);
|
|
||||||
setCookie("ac_type", acTypeInput.value, 30);
|
|
||||||
setCookie("captain_name", captainNameInput.value, 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
function populateAircraftFields() {
|
|
||||||
const savedReg = getCookie("ac_reg");
|
|
||||||
const savedType = getCookie("ac_type");
|
|
||||||
const savedCaptainName = getCookie("captain_name");
|
|
||||||
if (savedReg) {
|
|
||||||
document.getElementById("ac_reg").value = savedReg;
|
|
||||||
}
|
|
||||||
if (savedType) {
|
|
||||||
document.getElementById("ac_type").value = savedType;
|
|
||||||
}
|
|
||||||
if (savedCaptainName) {
|
|
||||||
document.getElementById("captain_name").value = savedCaptainName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", populateAircraftFields);
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="form-container">
|
|
||||||
<h2>Log Outgoing Flight</h2>
|
|
||||||
<form action="submit_outgoing.php" method="POST">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ac_reg">Aircraft Registration</label>
|
|
||||||
<input type="text" id="ac_reg" name="ac_reg" required maxlength="16" oninput="handleAircraftRegInput()">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="ac_type">Aircraft Type</label>
|
|
||||||
<input type="text" id="ac_type" name="ac_type" required maxlength="32" oninput="handleAircraftRegInput()">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="captain_name">Captain's Name</label>
|
|
||||||
<input type="text" id="captain_name" name="captain_name" required maxlength="64" oninput="handleAircraftRegInput()">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>POB (Persons on Board)</label>
|
|
||||||
<input type="hidden" id="pob" name="pob" required>
|
|
||||||
<div style="display: flex; gap: 10px;">
|
|
||||||
<button type="button" id="pob_1" class="pob-button" onclick="selectPOB(1)">1</button>
|
|
||||||
<button type="button" id="pob_2" class="pob-button" onclick="selectPOB(2)">2</button>
|
|
||||||
<button type="button" id="pob_3" class="pob-button" onclick="selectPOB(3)">3</button>
|
|
||||||
<button type="button" id="pob_4" class="pob-button" onclick="selectPOB(4)">4</button>
|
|
||||||
<button type="button" id="pob_5" class="pob-button" onclick="selectPOB(5)">5</button>
|
|
||||||
<button type="button" id="pob_6" class="pob-button" onclick="selectPOB(6)">6</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Nature of Flight</label>
|
|
||||||
<input type="hidden" id="nature_of_flight" name="nature_of_flight" required>
|
|
||||||
<div style="display: flex; gap: 10px;">
|
|
||||||
<button type="button" id="nature_Local" class="nature-button" onclick="toggleLandawayFields('Local')">Local</button>
|
|
||||||
<button type="button" id="nature_Circuits" class="nature-button" onclick="toggleLandawayFields('Circuits')">Circuits</button>
|
|
||||||
<button type="button" id="nature_Landaway" class="nature-button" onclick="toggleLandawayFields('Landaway')">Landaway</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="departure_time">Time of Departure</label>
|
|
||||||
<input type="datetime-local" id="etd" name="etd" required>
|
|
||||||
</div>
|
|
||||||
<div id="landaway-fields" class="hidden">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="destination">Destination</label>
|
|
||||||
<input type="text" id="destination" name="destination" maxlength="64">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="return_time">Estimated Time of Return</label>
|
|
||||||
<input type="datetime-local" id="eta" name="eta">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<button type="submit">Submit</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
47
download.php
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("functions.php");
|
|
||||||
require_db_auth();
|
|
||||||
|
|
||||||
// Create connection
|
|
||||||
$conn = new mysqli($host, $username, $password, $database);
|
|
||||||
|
|
||||||
// Check connection
|
|
||||||
if ($conn->connect_error) {
|
|
||||||
die("Connection failed: " . $conn->connect_error);
|
|
||||||
}
|
|
||||||
|
|
||||||
$year = $_GET['year'] ?? date('Y');
|
|
||||||
$month = $_GET['month'] ?? date('n');
|
|
||||||
|
|
||||||
$datetime = DateTime::createFromFormat('!m', $month);
|
|
||||||
$monthName = $datetime->format('F');
|
|
||||||
$filename = $monthName . $year . '.csv';
|
|
||||||
|
|
||||||
header('Content-Type: text/csv');
|
|
||||||
header('Content-Disposition: attachment;filename=' . $filename);
|
|
||||||
|
|
||||||
$output = fopen('php://output', 'w');
|
|
||||||
|
|
||||||
$escape = '\\'; // Define the escape character
|
|
||||||
|
|
||||||
// Fetch data
|
|
||||||
$sql = "SELECT * FROM submitted WHERE status != 'DELETED' and MONTH(eta) = $month and YEAR(eta) = $year ORDER BY eta ASC;";
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
// Output column headers
|
|
||||||
$fields = $result->fetch_fields();
|
|
||||||
$headers = [];
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
$headers[] = $field->name;
|
|
||||||
}
|
|
||||||
fputcsv($output, $headers, ',', '"', $escape);
|
|
||||||
|
|
||||||
// Output rows
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
fputcsv($output, $row, ',', '"', $escape);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the database connection
|
|
||||||
$conn->close();
|
|
||||||
fclose($output);
|
|
||||||
?>
|
|
||||||
36
footer.php
@@ -1,36 +0,0 @@
|
|||||||
<style>
|
|
||||||
.footer-bar {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
background-color: #333;
|
|
||||||
color: white;
|
|
||||||
padding: 10px 0;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
font-size: 14px;
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 50px; /* Define the height explicitly */
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-bar a {
|
|
||||||
color: #007bff;
|
|
||||||
text-decoration: none;
|
|
||||||
margin-left: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-bar a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
padding-bottom: 50px; /* Add padding equal to the footer height */
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="footer-bar">
|
|
||||||
<span>Swansea Airport PPR system Version 1.0</span>
|
|
||||||
</div>
|
|
||||||
225
functions.php
@@ -1,92 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Database connection details
|
// Database connection details
|
||||||
$host = 'sasaprod.pattinson.org';
|
$host = 'sasaprod.pattinson.org'; // Replace with your database host (usually 'localhost')
|
||||||
$username = 'ppruser';
|
$username = 'ppruser'; // Replace with your database username
|
||||||
$password = 'iJ8kN*5[g6P3jaqN';
|
$password = 'iJ8kN*5[g6P3jaqN'; // Replace with your database password
|
||||||
$database = 'pprdevdb';
|
$database = 'pprdevdb'; // Replace with your database name
|
||||||
$created_by = "Website (DEV)";
|
|
||||||
|
|
||||||
$mailHost = 'send.one.com'; // Your SMTP server
|
|
||||||
$mailSMTPAuth = true;
|
|
||||||
$mailUsername = 'noreply@swansea-airport.wales';
|
|
||||||
$mailPassword = 'SASAGoForward2155';
|
|
||||||
//$mailSMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
|
||||||
$mailPort = 465;
|
|
||||||
$mailFromAddress = 'noreply@swansea-airport.wales';
|
|
||||||
$mailFromName = 'Swansea Airport';
|
|
||||||
|
|
||||||
$baseUrl = "https://pprdev.swansea-airport.wales";
|
|
||||||
|
|
||||||
use PHPMailer\PHPMailer\PHPMailer;
|
|
||||||
use PHPMailer\PHPMailer\Exception;
|
|
||||||
|
|
||||||
function getUserIP() {
|
|
||||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
|
||||||
return $_SERVER['HTTP_CLIENT_IP'];
|
|
||||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
|
||||||
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
|
||||||
} else {
|
|
||||||
return $_SERVER['REMOTE_ADDR'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function connectDb() {
|
function connectDb() {
|
||||||
|
|
||||||
// Create connection
|
// Create connection
|
||||||
$conn = new mysqli( $GLOBALS['host'], $GLOBALS['username'], $GLOBALS['password'], $GLOBALS['database']);
|
$conn = new mysqli( $GLOBALS['host'], $GLOBALS['username'], $GLOBALS['password'], $GLOBALS['database']);
|
||||||
|
|
||||||
// Check connection
|
// Check connection
|
||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
||||||
die("Connection failed: " . $conn->connect_error);
|
die("Connection failed: " . $conn->connect_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $conn;
|
return $conn;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function logJournal($conn, $id, $message) {
|
|
||||||
|
|
||||||
if (isset($_SERVER['PHP_AUTH_USER'])) {
|
|
||||||
$user = $_SERVER['PHP_AUTH_USER'];
|
|
||||||
} else {
|
|
||||||
$user = "None";
|
|
||||||
}
|
|
||||||
|
|
||||||
$stmt = $conn->prepare("INSERT INTO journal (ppr_id, entry, user, ip) VALUES (?, ?, ?, ?)");
|
|
||||||
$ip = getUserIP();
|
|
||||||
$stmt->bind_param("isss", $id, $message, $user, $ip);
|
|
||||||
$stmt->execute();
|
|
||||||
$stmt->close();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function require_db_auth() {
|
function require_db_auth() {
|
||||||
|
|
||||||
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
|
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
|
||||||
send_auth_headers();
|
send_auth_headers();
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $_SERVER['PHP_AUTH_USER'];
|
$user = $_SERVER['PHP_AUTH_USER'];
|
||||||
$pass = $_SERVER['PHP_AUTH_PW'];
|
$pass = $_SERVER['PHP_AUTH_PW'];
|
||||||
|
|
||||||
$conn = connectDb();
|
$conn = connectDb();
|
||||||
|
|
||||||
$stmt = $conn->prepare("SELECT password FROM users WHERE username = ?");
|
$stmt = $conn->prepare("SELECT password FROM users WHERE username = ?");
|
||||||
$stmt->bind_param("s", $user);
|
$stmt->bind_param("s", $user);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->store_result();
|
$stmt->store_result();
|
||||||
$stmt->bind_result($stored_hash);
|
$stmt->bind_result($stored_hash);
|
||||||
$stmt->fetch();
|
$stmt->fetch();
|
||||||
|
|
||||||
// Verify the password
|
// Verify the password
|
||||||
if ($stmt->num_rows == 0 || !password_verify($pass, $stored_hash)) {
|
if ($stmt->num_rows == 0 || !password_verify($pass, $stored_hash)) {
|
||||||
send_auth_headers();
|
send_auth_headers();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the connection
|
// Close the connection
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
$conn->close();
|
$conn->close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,115 +56,19 @@ function send_auth_headers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function require_auth() {
|
function require_auth() {
|
||||||
$AUTH_USER = 'admin';
|
$AUTH_USER = 'admin';
|
||||||
$AUTH_PASS = 'admin';
|
$AUTH_PASS = 'admin';
|
||||||
header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
||||||
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
|
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
|
||||||
$is_not_authenticated = (
|
$is_not_authenticated = (
|
||||||
!$has_supplied_credentials ||
|
!$has_supplied_credentials ||
|
||||||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
|
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
|
||||||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
|
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
|
||||||
);
|
);
|
||||||
if ($is_not_authenticated) {
|
if ($is_not_authenticated) {
|
||||||
header('HTTP/1.1 401 Authorization Required');
|
header('HTTP/1.1 401 Authorization Required');
|
||||||
header('WWW-Authenticate: Basic realm="PPR"');
|
header('WWW-Authenticate: Basic realm="PPR"');
|
||||||
echo 'Text to send if user hits Cancel button';
|
echo 'Text to send if user hits Cancel button';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateSecureToken($email, $entryId) {
|
|
||||||
$secretKey = "your-very-secret-key"; // Use an environment variable for this
|
|
||||||
$timestamp = time();
|
|
||||||
$data = "$email|$entryId|$timestamp";
|
|
||||||
$hash = hash_hmac('sha256', $data, $secretKey);
|
|
||||||
return base64_encode("$data|$hash");
|
|
||||||
}
|
|
||||||
|
|
||||||
function validateSecureToken($token) {
|
|
||||||
$secretKey = "your-very-secret-key";
|
|
||||||
$decoded = base64_decode($token);
|
|
||||||
|
|
||||||
if (!$decoded) return false;
|
|
||||||
|
|
||||||
list($email, $entryId, $timestamp, $hash) = explode('|', $decoded);
|
|
||||||
|
|
||||||
// Check expiration (e.g., valid for 1 hour)
|
|
||||||
//if (time() - $timestamp > 3600) {
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Verify hash
|
|
||||||
$data = "$email|$entryId|$timestamp";
|
|
||||||
$validHash = hash_hmac('sha256', $data, $secretKey);
|
|
||||||
|
|
||||||
if (!hash_equals($validHash, $hash)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['email' => $email, 'entryId' => $entryId];
|
|
||||||
}
|
|
||||||
|
|
||||||
function generatePprEmail($entryId, $email, $ac_reg) {
|
|
||||||
global $conn, $mailHost, $mailSMTPAuth, $mailUsername, $mailPassword, $mailPort, $baseUrl, $mailFromAddress, $mailFromName;
|
|
||||||
|
|
||||||
if (!class_exists('PHPMailer\PHPMailer\PHPMailer')) {
|
|
||||||
require '../vendor/autoload.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
$token = generateSecureToken($email, $entryId);
|
|
||||||
$secureLink = $baseUrl . "/pilotppr.php?op=view&token=" . urlencode($token);
|
|
||||||
|
|
||||||
$mail = new PHPMailer(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$mail->isSMTP();
|
|
||||||
$mail->Host = $mailHost;
|
|
||||||
$mail->SMTPAuth = $mailSMTPAuth;
|
|
||||||
$mail->Username = $mailUsername;
|
|
||||||
$mail->Password = $mailPassword;
|
|
||||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
|
||||||
$mail->Port = $mailPort;
|
|
||||||
|
|
||||||
$mail->setFrom($mailFromAddress, $mailFromName);
|
|
||||||
$mail->addAddress($email);
|
|
||||||
|
|
||||||
$mail->isHTML(true);
|
|
||||||
$mail->Subject = "PPR Confirmation for " . $ac_reg;
|
|
||||||
$mail->Body = "
|
|
||||||
|
|
||||||
<p>Dear Pilot,<p>This is to confirm we have received your PPR information, and we look forward to welcoming you at Swansea Airport.<p>Please review our <a href=https://swansea-airport.wales/pilot-information/arrival-procedures.html>arrival procedures</a> prior to your arrival.<p>To view or cancel your PPR please click the button:</p>
|
|
||||||
<a href='$secureLink' style='display: inline-block; padding: 10px 20px; color: white; background-color: #007bff; text-decoration: none; border-radius: 5px;'>View PPR</a>
|
|
||||||
<p><img src='https://ppr.swansea-airport.wales/dev/assets/egfh.webp' alt='Swansea Airport' style='width: 200px;'>
|
|
||||||
";
|
|
||||||
|
|
||||||
$mail->send();
|
|
||||||
echo "Email sent successfully!";
|
|
||||||
logJournal($conn, $entryId, "Confirm email sent");
|
|
||||||
|
|
||||||
} catch (Exception $e) {
|
|
||||||
echo "Email sending failed: {$mail->ErrorInfo}";
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
36
input.html
@@ -5,10 +5,9 @@
|
|||||||
|
|
||||||
// Set default value to current date & time
|
// Set default value to current date & time
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
const currentIsoDateString = new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString()
|
let now = new Date();
|
||||||
let localDatetime = currentIsoDateString.slice(0, 16); // Format for datetime-local input
|
let localDatetime = now.toISOString().slice(0, 16); // Format for datetime-local input
|
||||||
document.getElementById("eta").value = localDatetime;
|
document.getElementById("eta").value = localDatetime;
|
||||||
// document.getElementById("etd").value = localDatetime;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function fetchResults() {
|
function fetchResults() {
|
||||||
@@ -137,46 +136,33 @@
|
|||||||
<form action="newppr.php" method="POST">
|
<form action="newppr.php" method="POST">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="ac_reg">Registration</label>
|
<label for="ac_reg">Registration</label>
|
||||||
<input type="text" id="ac_reg" name="ac_reg" onkeyup="fetchResults()" required maxlength="16">
|
<input type="text" id="ac_reg" name="ac_reg" onkeyup="fetchResults()" required>
|
||||||
</div>
|
</div>
|
||||||
<div id="results"></div>
|
<div id="results"></div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="ac_type">Type</label>
|
<label for="ac_type">Type</label>
|
||||||
<input type="text" id="ac_type" name="ac_type" required maxlength="16">
|
<input type="text" id="ac_type" name="ac_type" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="optional-label" for="ac_call">Callsign (optional)</label>
|
<label class="optional-label" for="ac_call">Callsign (optional)</label>
|
||||||
<input type="text" id="ac_call" name="ac_call" maxlength="16">
|
<input type="text" id="ac_call" name="ac_call">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="captain">Captain's Name</label>
|
<label for="captain">Captain's Name</label>
|
||||||
<input type="text" id="captain" name="captain" required maxlength="64">
|
<input type="text" id="captain" name="captain" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="in_from">Arriving From</label>
|
<label for="in_from">Arriving From</label>
|
||||||
<input type="text" id="in_from" name="in_from" required maxlength="64">
|
<input type="text" id="in_from" name="in_from" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="pob_in">POB Inbound</label>
|
<label for="pob_in">POB</label>
|
||||||
<input type="number" id="pob_in" name="pob_in" required>
|
<input type="number" id="pob_in" name="pob_in" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group"></div>
|
<div class="form-group"></div>
|
||||||
<label for="eta">ETA (Local)</label>
|
<label for="eta">ETA</label>
|
||||||
<input type="datetime-local" id="eta" name="eta">
|
<input type="datetime-local" id="eta" name="eta">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label for="out_to">Out to</label>
|
|
||||||
<input type="text" id="out_to" name="out_to" maxlength="64">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="pob_out">POB Outbound</label>
|
|
||||||
<input type="number" id="pob_out" name="pob_out" >
|
|
||||||
</div>
|
|
||||||
<div class="form-group"></div>
|
|
||||||
<label for="eta">Departing At (Local)</label>
|
|
||||||
<input type="datetime-local" id="etd" name="etd">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="fuel">Fuel Needed</label>
|
<label for="fuel">Fuel Needed</label>
|
||||||
<select id="fuel" name="fuel" single>
|
<select id="fuel" name="fuel" single>
|
||||||
@@ -188,11 +174,11 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="optional-label" for="email">Email (optional)</label>
|
<label class="optional-label" for="email">Email (optional)</label>
|
||||||
<input type="email" id="email" name="email" maxlength="128">
|
<input type="email" id="email" name="email" >
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="optional-label" for="phone">Phone (optional)</label>
|
<label class="optional-label" for="phone">Phone (optional)</label>
|
||||||
<input type="text" id="phone" name="phone" maxlength="16">
|
<input type="text" id="phone" name="phone" >
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
33
menu.php
@@ -1,33 +0,0 @@
|
|||||||
<style>
|
|
||||||
.menu-bar {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
background-color: #333;
|
|
||||||
padding: 10px 0;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-bar a {
|
|
||||||
color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
padding: 10px 20px;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
font-size: 16px;
|
|
||||||
transition: background-color 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-bar a:hover {
|
|
||||||
background-color: #575757;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-bar a.active {
|
|
||||||
background-color: #007bff;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="menu-bar">
|
|
||||||
<a href="tower.php" class="<?= basename($_SERVER['PHP_SELF']) === 'tower.php' ? 'active' : '' ?>">HOME</a>
|
|
||||||
<a href="upcoming.php" class="<?= basename($_SERVER['PHP_SELF']) === 'upcoming.php' ? 'active' : '' ?>">Future PPRs</a>
|
|
||||||
<a href="admin.php" class="<?= basename($_SERVER['PHP_SELF']) === 'admin.php' ? 'active' : '' ?>">Reports</a>
|
|
||||||
</div>
|
|
||||||
31
newppr.php
@@ -1,48 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
include("functions.php");
|
include("functions.php");
|
||||||
require_db_auth();
|
require_db_auth();
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
|
||||||
$conn = connectDb();
|
$conn = connectDb();
|
||||||
|
|
||||||
$columns = [];
|
$columns = [];
|
||||||
$values = [];
|
$values = [];
|
||||||
|
|
||||||
echo "<h2>Received POST Data:</h2><ul>";
|
echo "<h2>Received POST Data:</h2>";
|
||||||
|
echo "<ul>";
|
||||||
foreach ($_POST as $key => $value) {
|
foreach ($_POST as $key => $value) {
|
||||||
$escaped_key = "`" . $conn->real_escape_string($key) . "`";
|
$columns[] = "`" . $conn->real_escape_string($key) . "`";
|
||||||
if ($key === 'eta' || $key === 'etd') {
|
$values[] = "'" . $conn->real_escape_string($value) . "'";
|
||||||
// Convert London time to UTC
|
|
||||||
$datetime = new DateTime($value, new DateTimeZone('Europe/London'));
|
|
||||||
$datetime->setTimezone(new DateTimeZone('UTC'));
|
|
||||||
$escaped_value = "'" . $datetime->format('Y-m-d H:i:s') . "'";
|
|
||||||
} else {
|
|
||||||
$escaped_value = ($value === '' || $value === null) ? "NULL" : (is_numeric($value) ? $value : "'" . $conn->real_escape_string($value) . "'");
|
|
||||||
}
|
|
||||||
$columns[] = $escaped_key;
|
|
||||||
$values[] = $escaped_value;
|
|
||||||
echo "<li><strong>" . htmlspecialchars($key) . ":</strong> " . htmlspecialchars($value) . "</li>";
|
echo "<li><strong>" . htmlspecialchars($key) . ":</strong> " . htmlspecialchars($value) . "</li>";
|
||||||
}
|
}
|
||||||
echo "</ul>";
|
|
||||||
|
|
||||||
if (!empty($columns)) {
|
if (!empty($columns)) {
|
||||||
$sql = "INSERT INTO submitted (created_by, " . implode(",", $columns) . ") VALUES ('" . $_SERVER['PHP_AUTH_USER'] . "'," . implode(",", $values) . ")";
|
$sql = "INSERT INTO submitted (created_by, " . implode(",", $columns) . ") VALUES ('" . $_SERVER['PHP_AUTH_USER'] . "'," . implode(",", $values) . ")";
|
||||||
echo $sql;
|
echo $sql;
|
||||||
|
|
||||||
if ($conn->query($sql) === TRUE) {
|
if ($conn->query($sql) === TRUE) {
|
||||||
$lastId = $conn->insert_id;
|
echo "<p>Data successfully inserted into database.</p>";
|
||||||
echo "<p>Data successfully inserted into database with id = " . $lastId . "</p>";
|
|
||||||
if (!empty($_POST['email'])) {
|
|
||||||
echo "Email is set to " . $_POST['email'];
|
|
||||||
generatePprEmail($lastId, $_POST['email'], $_POST['ac_reg']);
|
|
||||||
} else {
|
|
||||||
echo "Email 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>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
echo "</ul>";
|
||||||
} else {
|
} else {
|
||||||
echo "<h2>No POST data received.</h2>";
|
echo "<h2>No POST data received.</h2>";
|
||||||
}
|
}
|
||||||
|
|||||||
181
pilotppr.php
@@ -1,181 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("functions.php");
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Swansea PPR Details</title>
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
background-color: #f4f4f4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
width: 80%;
|
|
||||||
margin: 20px auto;
|
|
||||||
background-color: #fff;
|
|
||||||
padding: 20px;
|
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
color: #333;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.details {
|
|
||||||
padding: 15px;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 5px;
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.details p {
|
|
||||||
margin: 10px 0;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.details p strong {
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
|
|
||||||
.back-link {
|
|
||||||
display: inline-block;
|
|
||||||
margin-top: 20px;
|
|
||||||
text-decoration: none;
|
|
||||||
color: #fff;
|
|
||||||
background-color: #007BFF;
|
|
||||||
padding: 10px 15px;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.back-link:hover {
|
|
||||||
background-color: #0056b3;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
padding: 10px 20px;
|
|
||||||
font-size: 1rem;
|
|
||||||
background-color: #007bff;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: 0.3s;
|
|
||||||
}
|
|
||||||
|
|
||||||
button:hover {
|
|
||||||
background-color: #0056b3;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="container" id="message">
|
|
||||||
These details have been submitted as your PPR. We look forward to seeing you at Swansea Airport!<p>To cancel your PPR, use the button below. It is currently not possible to make any changes here, but please feel free to cancel if you need to and create a new PPR.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
if (isset($_GET['token'])) {
|
|
||||||
$result = validateSecureToken($_GET['token']);
|
|
||||||
|
|
||||||
if ($result) {
|
|
||||||
// Token is valid, allow changes to database entry
|
|
||||||
$email = $result['email'];
|
|
||||||
$entryId = $result['entryId'];
|
|
||||||
} else {
|
|
||||||
die("Invalid or expired token.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch($_GET['op']) {
|
|
||||||
case "cancel":
|
|
||||||
opCancel($entryId);
|
|
||||||
break;
|
|
||||||
case "view":
|
|
||||||
opView($entryId);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function opCancel($entryId) {
|
|
||||||
|
|
||||||
$conn = connectDb();
|
|
||||||
$sql = "UPDATE submitted SET status = 'CANCELED' where id = " . $entryId;
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
logJournal($conn, $entryId, "Marked Canceled by Pilot");
|
|
||||||
$conn->close();
|
|
||||||
echo'<script>document.getElementById("message").innerHTML = "Your PPR has been canceled. Thank you for letting us know!";</script>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function opView($entryId) {
|
|
||||||
|
|
||||||
$conn = connectDb();
|
|
||||||
$sql = "SELECT * FROM submitted WHERE status = 'NEW' AND id = " . $entryId;
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
// Output data of the row
|
|
||||||
$row = $result->fetch_assoc();
|
|
||||||
echo '<div class="container">';
|
|
||||||
echo '<div class="details"><p><strong>Aircraft Reg: </strong>' . $row['ac_reg'] . "</p>";
|
|
||||||
echo "<p><strong>Aircraft Type:</strong> " . $row['ac_type'] . "</p>";
|
|
||||||
echo "<p><strong>Callsign:</strong> " . $row['ac_call'] . "</p>";
|
|
||||||
echo "<p><strong>Captain's Name:</strong> " . $row['captain'] . "</p>";
|
|
||||||
echo "<p><strong>Arriving From:</strong> " . $row['in_from'] . "</p>";
|
|
||||||
echo "<p><strong>POB IN:</strong> " . $row['pob_in'] . "</p>";
|
|
||||||
echo "<p><strong>ETA:</strong> " . $row['eta'] . "</p>";
|
|
||||||
|
|
||||||
echo "<p><strong>Fuel Required:</strong> " . $row['fuel'] . "</p>";
|
|
||||||
|
|
||||||
echo "<p><strong>POB OUT:</strong> " . $row['pob_out'] . "</p>";
|
|
||||||
echo "<p><strong>Outbound To:</strong> " . $row['out_to'] . "</p>";
|
|
||||||
echo "<p><strong>ETD:</strong> " . $row['etd'] . "</p>";
|
|
||||||
|
|
||||||
echo "<p><strong>Email Address:</strong> " . $row['email'] . "</p>";
|
|
||||||
echo "<p><strong>Phone:</strong> " . $row['phone'] . "</p>";
|
|
||||||
|
|
||||||
echo "<p><strong>Notes:</strong> " . $row['notes'] . "</p></div>";
|
|
||||||
echo '<button onclick="confirmWithSweetAlert(\'pilotppr.php?op=cancel&token=' . urlencode($_GET['token']) . '\')">Cancel PPR</button>';
|
|
||||||
|
|
||||||
} else {
|
|
||||||
echo "";
|
|
||||||
echo'<script>document.getElementById("message").innerHTML = "No details found for the given ID. This could mean the PPR has been canceled already.";</script>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn->close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!-- Include SweetAlert -->
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function confirmWithSweetAlert(url) {
|
|
||||||
Swal.fire({
|
|
||||||
title: "Cancel PPR?",
|
|
||||||
text: "We hope to see you soon!",
|
|
||||||
icon: "warning",
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: "#3085d6",
|
|
||||||
cancelButtonColor: "#d33",
|
|
||||||
confirmButtonText: "Cancel PPR",
|
|
||||||
cancelButtonText: "Keep PPR"
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.isConfirmed) {
|
|
||||||
window.location.href = url;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
106
public.css
@@ -1,106 +0,0 @@
|
|||||||
/* Overall page styling */
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
display: grid;
|
|
||||||
grid-template-rows: auto 1fr auto;
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
height: 100vh;
|
|
||||||
font-size: 30px; /* Increased font size */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Header styles */
|
|
||||||
header {
|
|
||||||
background-color: #333;
|
|
||||||
color: white;
|
|
||||||
padding: 20px;
|
|
||||||
text-align: center;
|
|
||||||
img.left-image {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
img.right-image {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
width: 9%;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Main section styles */
|
|
||||||
main {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr; /* Two equal-width columns */
|
|
||||||
gap: 20px;
|
|
||||||
padding: 20px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Table styles */
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin: 0;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
th, td {
|
|
||||||
padding: 12px;
|
|
||||||
text-align: left;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
background-color: #f4f4f4;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr:nth-child(even) {
|
|
||||||
background-color: #d3d3d3;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Footer styles */
|
|
||||||
footer {
|
|
||||||
background-color: #333;
|
|
||||||
color: white;
|
|
||||||
text-align: center;
|
|
||||||
padding: 10px 0;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Marquee container */
|
|
||||||
.marquee {
|
|
||||||
display: inline-block;
|
|
||||||
white-space: nowrap;
|
|
||||||
padding-right: 100%; /* This makes the text start out of view */
|
|
||||||
animation: scroll-left 20s linear infinte;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Keyframes for scrolling animation */
|
|
||||||
@keyframes scroll-left {
|
|
||||||
from {
|
|
||||||
transform: translateX(100%);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
transform: translateX(-100%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Marquee text styling */
|
|
||||||
.marquee-text {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: #f4f4f4;
|
|
||||||
padding-left: 50px;
|
|
||||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Responsive adjustments */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
main {
|
|
||||||
grid-template-columns: 1fr; /* Stack columns on smaller screens */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
116
public.php
@@ -1,116 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("functions.php");
|
|
||||||
|
|
||||||
// Create connection
|
|
||||||
$conn = connectDb();
|
|
||||||
|
|
||||||
// Fetch arrivals for today's date with status 'NEW'
|
|
||||||
$arrivalsSql = "SELECT ac_reg, ac_type, in_from, TIME_FORMAT(eta, '%H:%i') AS due
|
|
||||||
FROM submitted
|
|
||||||
WHERE DATE(eta) = CURDATE() AND status = 'NEW'
|
|
||||||
ORDER BY eta ASC";
|
|
||||||
$arrivalsResult = $conn->query($arrivalsSql);
|
|
||||||
|
|
||||||
// Fetch departures for today's date with status 'LANDED'
|
|
||||||
$departuresSql = "SELECT ac_reg, ac_type, out_to, TIME_FORMAT(etd, '%H:%i') AS due
|
|
||||||
FROM submitted
|
|
||||||
WHERE DATE(etd) = CURDATE() AND status = 'LANDED'
|
|
||||||
ORDER BY etd ASC";
|
|
||||||
$departuresResult = $conn->query($departuresSql);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="refresh" content="300">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Swansea Airport - Arrivals & Departures</title>
|
|
||||||
<link rel="stylesheet" href="public.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
<img src="assets/logo.png" alt="EGFH Logo" class="left-image">
|
|
||||||
<h1>Arrivals/Departures Information</h1>
|
|
||||||
<img src="assets/flightImg.png" alt="EGFH Logo" class="right-image">
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main>
|
|
||||||
<!-- Left column with arrivals table -->
|
|
||||||
<div>
|
|
||||||
<h2><center>Arrivals</center></h2>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Registration</th>
|
|
||||||
<th>Aircraft Type</th>
|
|
||||||
<th>From</th>
|
|
||||||
<th>Due</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php if ($arrivalsResult->num_rows > 0): ?>
|
|
||||||
<?php while ($row = $arrivalsResult->fetch_assoc()): ?>
|
|
||||||
<tr>
|
|
||||||
<td><?= htmlspecialchars($row['ac_reg']) ?></td>
|
|
||||||
<td><?= htmlspecialchars($row['ac_type']) ?></td>
|
|
||||||
<td><?= htmlspecialchars($row['in_from']) ?></td>
|
|
||||||
<td><?= htmlspecialchars($row['due']) ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php endwhile; ?>
|
|
||||||
<?php else: ?>
|
|
||||||
<tr>
|
|
||||||
<td colspan="4">No arrivals found.</td>
|
|
||||||
</tr>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Right column with departures table -->
|
|
||||||
<div>
|
|
||||||
<h2><center>Departures</center></h2>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Registration</th>
|
|
||||||
<th>Aircraft Type</th>
|
|
||||||
<th>To</th>
|
|
||||||
<th>Due</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php if ($departuresResult->num_rows > 0): ?>
|
|
||||||
<?php while ($row = $departuresResult->fetch_assoc()): ?>
|
|
||||||
<tr>
|
|
||||||
<td><?= htmlspecialchars($row['ac_reg']) ?></td>
|
|
||||||
<td><?= htmlspecialchars($row['ac_type']) ?></td>
|
|
||||||
<td><?= htmlspecialchars($row['out_to']) ?></td>
|
|
||||||
<td><?= htmlspecialchars($row['due']) ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php endwhile; ?>
|
|
||||||
<?php else: ?>
|
|
||||||
<tr>
|
|
||||||
<td colspan="4">No departures found.</td>
|
|
||||||
</tr>
|
|
||||||
<?php endif; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<footer>
|
|
||||||
<!-- Footer content -->
|
|
||||||
<div class="iso-marquee-linkwrap">
|
|
||||||
<div class="iso-marquee--long iso-marquee">
|
|
||||||
<!-- Add marquee content here -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
// Close the database connection
|
|
||||||
$conn->close();
|
|
||||||
?>
|
|
||||||
@@ -1,60 +1,65 @@
|
|||||||
{
|
{
|
||||||
"form_title": "DEV DEV DEV PPR Request Form",
|
"form_title": "PPR Request Form",
|
||||||
"form_slug": "ppr-request-form-joclld-1",
|
"form_slug": "ppr-request-form-joclld",
|
||||||
"submission": {
|
"submission": {
|
||||||
"Aircraft Registration": "G-LORD",
|
"Aircraft Registration": "G-BJAJ",
|
||||||
"Aircraft Type": "RV-8",
|
"Aircraft Type": "AA5",
|
||||||
"Captain or PIC Name": "The Lord Rotherwick",
|
"Callsign": "TEST1",
|
||||||
"Arriving From": "at Lodge",
|
"Captain or PIC Name": "TESTY MCTESTFACE",
|
||||||
"ETA": "17\/03\/2025 17:22",
|
"Arriving From": "Wellesbourne",
|
||||||
"POB Inbound": "1",
|
"ETA": "11\/02\/2025 14:33",
|
||||||
"Fuel Required": "None",
|
"POB Inbound": "2",
|
||||||
"Departing To": "Ranger\u2019s Lodge",
|
"Fuel Required": "100LL",
|
||||||
"ETD": "20\/03\/2025 00:00",
|
"Departing To": "Pembrey",
|
||||||
"POB Outbound": "1",
|
"ETD": "12\/02\/2025 00:00",
|
||||||
|
"POB Outbound": "2",
|
||||||
"Email": "james@pattinson.org",
|
"Email": "james@pattinson.org",
|
||||||
"Phone Number": "+44123123123",
|
"Phone Number": "+441212121212",
|
||||||
"Additional Information": "I am resending my PPR as I didn\u2019t receive a confirmation from my PPR yesterday."
|
"Additional Information": "Here are some notes man"
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"617dd0cd-2d17-4d7f-826b-5348afdb30b3": {
|
"617dd0cd-2d17-4d7f-826b-5348afdb30b3": {
|
||||||
"value": "G-YSIR",
|
"value": "G-BJAJ",
|
||||||
"name": "Aircraft Registration"
|
"name": "Aircraft Registration"
|
||||||
},
|
},
|
||||||
"148a55d8-5357-49a3-b9aa-2a5d4dc64173": {
|
"148a55d8-5357-49a3-b9aa-2a5d4dc64173": {
|
||||||
"value": "RV-8",
|
"value": "AA5",
|
||||||
"name": "Aircraft Type"
|
"name": "Aircraft Type"
|
||||||
},
|
},
|
||||||
|
"52d7bc90-9d26-48a1-82db-b91b4ccd2f92": {
|
||||||
|
"value": "TEST1",
|
||||||
|
"name": "Callsign"
|
||||||
|
},
|
||||||
"49b2de0d-5bd6-4b0c-86dd-b18b85f8b8ff": {
|
"49b2de0d-5bd6-4b0c-86dd-b18b85f8b8ff": {
|
||||||
"value": "The Lord Rotherwick",
|
"value": "TESTY MCTESTFACE",
|
||||||
"name": "Captain or PIC Name"
|
"name": "Captain or PIC Name"
|
||||||
},
|
},
|
||||||
"4b4f7ecd-f80c-4e86-a7ab-6fadb3220df8": {
|
"4b4f7ecd-f80c-4e86-a7ab-6fadb3220df8": {
|
||||||
"value": "Private strip at Ranger\u2019s",
|
"value": "Wellesbourne",
|
||||||
"name": "Arriving From"
|
"name": "Arriving From"
|
||||||
},
|
},
|
||||||
"ca4ac44f-0388-4a70-a072-38276ed2ac13": {
|
"ca4ac44f-0388-4a70-a072-38276ed2ac13": {
|
||||||
"value": "31\/03\/2025 13:00",
|
"value": "11\/02\/2025 14:33",
|
||||||
"name": "ETA"
|
"name": "ETA"
|
||||||
},
|
},
|
||||||
"6fc47c54-7383-48fd-93fc-d8080f5ed8f5": {
|
"6fc47c54-7383-48fd-93fc-d8080f5ed8f5": {
|
||||||
"value": "1",
|
"value": "2",
|
||||||
"name": "POB Inbound"
|
"name": "POB Inbound"
|
||||||
},
|
},
|
||||||
"d153c8a5-8345-4e6a-abfd-cf8adcc06f2d": {
|
"d153c8a5-8345-4e6a-abfd-cf8adcc06f2d": {
|
||||||
"value": "None",
|
"value": "100LL",
|
||||||
"name": "Fuel Required"
|
"name": "Fuel Required"
|
||||||
},
|
},
|
||||||
"ba95fd3f-1ec0-4553-95d3-a0b6a850738d": {
|
"ba95fd3f-1ec0-4553-95d3-a0b6a850738d": {
|
||||||
"value": "Ranger\u2019s Lodge",
|
"value": "Pembrey",
|
||||||
"name": "Departing To"
|
"name": "Departing To"
|
||||||
},
|
},
|
||||||
"53d60abd-eb75-4b1f-92b6-5d47d26367ec": {
|
"53d60abd-eb75-4b1f-92b6-5d47d26367ec": {
|
||||||
"value": "31\/03\/2025 00:00",
|
"value": "12\/02\/2025 00:00",
|
||||||
"name": "ETD"
|
"name": "ETD"
|
||||||
},
|
},
|
||||||
"d1ac0860-31f4-4914-9d0b-cae42dfc7eda": {
|
"d1ac0860-31f4-4914-9d0b-cae42dfc7eda": {
|
||||||
"value": "1",
|
"value": "2",
|
||||||
"name": "POB Outbound"
|
"name": "POB Outbound"
|
||||||
},
|
},
|
||||||
"0198c86c-edd1-4aaf-93a1-d68f8fc8c365": {
|
"0198c86c-edd1-4aaf-93a1-d68f8fc8c365": {
|
||||||
@@ -62,11 +67,11 @@
|
|||||||
"name": "Email"
|
"name": "Email"
|
||||||
},
|
},
|
||||||
"e40ebc2d-887b-42b3-931d-c981c76b0c20": {
|
"e40ebc2d-887b-42b3-931d-c981c76b0c20": {
|
||||||
"value": "+44123123123",
|
"value": "+441212121212",
|
||||||
"name": "Phone Number"
|
"name": "Phone Number"
|
||||||
},
|
},
|
||||||
"73d26c2c-1d3d-44e2-82fc-3a1a2600c393": {
|
"73d26c2c-1d3d-44e2-82fc-3a1a2600c393": {
|
||||||
"value": "I am resending my PPR as I didn\u2019t receive a confirmation from my PPR yesterday.",
|
"value": "Here are some notes man",
|
||||||
"name": "Additional Information"
|
"name": "Additional Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
346
tower.php
@@ -7,8 +7,6 @@ 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");
|
||||||
@@ -29,37 +27,6 @@ require_db_auth();
|
|||||||
<title>Swansea Daily PPR</title>
|
<title>Swansea Daily PPR</title>
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
.checkbox-container {
|
|
||||||
display: flex;
|
|
||||||
gap: 15px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
padding: 10px;
|
|
||||||
background: #f9f9f9;
|
|
||||||
border-radius: 8px;
|
|
||||||
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;
|
|
||||||
gap: 5px;
|
|
||||||
font-size: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Styling for the table */
|
/* Styling for the table */
|
||||||
table {
|
table {
|
||||||
width: 80%;
|
width: 80%;
|
||||||
@@ -124,243 +91,100 @@ require_db_auth();
|
|||||||
background-color: #0056b3;
|
background-color: #0056b3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.state-CANCELED {
|
|
||||||
text-decoration: line-through;
|
|
||||||
color: gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-LANDED {
|
|
||||||
font-style: italic;
|
|
||||||
color: gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="checkbox"] {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
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>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<?php include("menu.php"); ?>
|
<script>
|
||||||
|
function markLanded(id) {
|
||||||
<script>
|
page="action.php?op=landed&id=" + id;
|
||||||
function markAction(id, action, title, buttonText) {
|
|
||||||
const now = new Date();
|
|
||||||
const currentTime = now.toISOString().slice(11, 16); // Extract HH:MM
|
|
||||||
|
|
||||||
Swal.fire({
|
|
||||||
title: title,
|
|
||||||
html: `<input type="time" id="timepicker" class="swal2-input" value="${currentTime}">`,
|
|
||||||
icon: "info",
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: "#3085d6",
|
|
||||||
cancelButtonColor: "#d33",
|
|
||||||
confirmButtonText: buttonText,
|
|
||||||
preConfirm: () => {
|
|
||||||
const time = document.getElementById("timepicker").value;
|
|
||||||
if (!time) {
|
|
||||||
Swal.showValidationMessage("Please select a time");
|
|
||||||
}
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.isConfirmed) {
|
|
||||||
const page = `action.php?op=${action}&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 markCancel(id) {
|
||||||
}
|
page="action.php?op=cancel&id=" + id;
|
||||||
|
|
||||||
function markDeparted(id) {
|
|
||||||
markAction(id, "departed", "Depart Aircraft at time (UTC)", "Departed");
|
|
||||||
}
|
|
||||||
|
|
||||||
function markLanded(id) {
|
|
||||||
markAction(id, "landed", "Land Aircraft at time (UTC)", "Landed");
|
|
||||||
}
|
|
||||||
|
|
||||||
function markCancel(id) {
|
|
||||||
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();
|
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 openDetail(id) {
|
||||||
}
|
page="action.php?op=detail&id=" + id;
|
||||||
|
var popupWindow = window.open(page, "PopupWindow", "toolbar=no, location=no, directories=no,status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=600, height=1100");
|
||||||
|
popupWindow.onload = function () {
|
||||||
|
var contentHeight = popupWindow.document.body.scrollHeight;
|
||||||
|
var contentWidth = popupWindow.document.body.scrollWidth;
|
||||||
|
popupWindow.resizeTo(contentWidth + 20, contentHeight + 180); // Adding padding to prevent clipping
|
||||||
|
};
|
||||||
|
|
||||||
function openDetail(id) {
|
}
|
||||||
const page = `action.php?op=detail&id=${id}`;
|
|
||||||
var popupWindow = window.open(page, "PopupWindow", "toolbar=no, location=no, directories=no,status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=600, height=1100");
|
|
||||||
popupWindow.onload = function () {
|
|
||||||
var contentHeight = popupWindow.document.body.scrollHeight;
|
|
||||||
var contentWidth = popupWindow.document.body.scrollWidth;
|
|
||||||
popupWindow.resizeTo(contentWidth + 20, contentHeight + 180); // Adding padding to prevent clipping
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<center><h2>Tower Ops <?php echo date('l d M Y'); ?></h2></center>
|
|
||||||
|
|
||||||
<!--
|
</script>
|
||||||
<div class="checkbox-container">
|
<center><h2>Swansea Inbound PPR <?php echo date('l d M Y'); ?></h2></center>
|
||||||
<label>
|
|
||||||
<input type="checkbox" id="toggle-canceled" onchange="toggleRows('state-CANCELED', this.checked)"> Show CANCELED
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<div class="heading">Inbound Aircraft</div>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function renderTableCell($key, $value, $row) {
|
// Create connection
|
||||||
if ($key == 'ETA' || $key == 'ETD') {
|
$conn = new mysqli($host, $username, $password, $database);
|
||||||
return "<td>" . htmlspecialchars($value ?? '') . (!empty($value) ? " Z" : "") . "</td>"; // Add "Z" suffix only if not blank
|
|
||||||
}
|
// Check connection
|
||||||
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
|
if ($conn->connect_error) {
|
||||||
$notes = htmlspecialchars($row['notes'] ?? '');
|
die("Connection failed: " . $conn->connect_error);
|
||||||
$acCall = htmlspecialchars($row['ac_call'] ?? '');
|
|
||||||
$acReg = htmlspecialchars($value ?? '');
|
|
||||||
if (!empty($row['notes'])) {
|
|
||||||
return "<td class='red-triangle' data-notes='$notes'>$acCall<br><span class='acreg'>$acReg</span></td>";
|
|
||||||
}
|
|
||||||
return "<td>$acCall<br><span class='acreg'>$acReg</span></td>";
|
|
||||||
} elseif ($key == 'ac_reg' && !empty($row['notes'])) {
|
|
||||||
$notes = htmlspecialchars($row['notes'] ?? '');
|
|
||||||
$acReg = htmlspecialchars($value ?? '');
|
|
||||||
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 {
|
|
||||||
return "<td>" . htmlspecialchars($value ?? '') . "</td>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderActionsCell($id, $status = null) {
|
$custom_headings = [
|
||||||
if ($status === 'LANDED') {
|
'column1' => 'Custom Heading 1',
|
||||||
return "<td>
|
'column2' => 'Custom Heading 2',
|
||||||
<img src='assets/cancel-icon.webp' title='Cancel PPR' style='width: 25px; height: auto;' onclick='markCancel($id)'>
|
'column3' => 'Custom Heading 3'
|
||||||
<img src='assets/depart.png' title='Depart' style='width: 30px; height: auto;' onclick='markDeparted($id)'>
|
// Add more custom headings as needed
|
||||||
</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) {
|
|
||||||
if (!in_array($key, ['notes', 'status', 'id', 'ac_call'])) {
|
|
||||||
$rowHtml .= renderTableCell($key, $value, $row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$rowHtml .= renderActionsCell($row['id'], $row['status']);
|
|
||||||
$rowHtml .= "</tr>";
|
|
||||||
return $rowHtml;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderTable($result) {
|
|
||||||
$tableHtml = "<table border='1' id='arrivals'>
|
|
||||||
<thead>
|
|
||||||
<tr>";
|
|
||||||
$fields = $result->fetch_fields();
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
if (!in_array($field->name, ['notes', 'status', 'id', 'ac_call'])) {
|
|
||||||
$tableHtml .= "<th>" . htmlspecialchars($field->name ?? '') . "</th>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$tableHtml .= "<th>actions</th></tr></thead><tbody>";
|
|
||||||
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$tableHtml .= renderTableRow($row);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tableHtml .= "</tbody></table>";
|
|
||||||
return $tableHtml;
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn = connectDb();
|
|
||||||
$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
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
echo renderTable($result);
|
|
||||||
} else {
|
|
||||||
echo "No results found.";
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="heading">Visiting Aircraft</div>
|
|
||||||
|
|
||||||
<div id="landed">
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
// Define your SQL query
|
// 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, 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' ORDER BY eta ASC;"; // Replace with your table name
|
||||||
|
|
||||||
// Execute the query
|
// Execute the query
|
||||||
$result = $conn->query($sql);
|
$result = $conn->query($sql);
|
||||||
|
|
||||||
// Check if there are results
|
// Check if there are results
|
||||||
if ($result->num_rows > 0) {
|
if ($result->num_rows > 0) {
|
||||||
echo renderTable($result); // Use the renderTable function
|
// Start HTML table
|
||||||
|
echo '<table border="1" id="entries">
|
||||||
|
<thead>
|
||||||
|
<tr>';
|
||||||
|
|
||||||
|
// Output table headers (assuming column names are known)
|
||||||
|
$fields = $result->fetch_fields();
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
if ($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 data-id=' . $row['id'] . '>';
|
||||||
|
foreach ($row as $key => $value) {
|
||||||
|
if ($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="land.webp" title="Mark Landed" style="width: 30px; height: auto;" onclick="markLanded(' . $row['id'] . ')"></td>';
|
||||||
|
echo '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ' </tbody></table>';
|
||||||
} else {
|
} else {
|
||||||
echo "No results found.";
|
echo "No results found.";
|
||||||
}
|
}
|
||||||
@@ -370,8 +194,6 @@ $conn->close();
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<center><button onclick="openPopup()">Log New PPR</button></center>
|
<center><button onclick="openPopup()">Log New PPR</button></center>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -387,35 +209,15 @@ $conn->close();
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
document.getElementById("entries").addEventListener("click", function (event) {
|
||||||
|
let td = event.target.closest("td");
|
||||||
|
if (!td) return; // Clicked outside <td>
|
||||||
|
|
||||||
function toggleRows(className) {
|
let tr = td.parentElement; // Get the row
|
||||||
document.querySelectorAll('.' + className).forEach(row => {
|
|
||||||
row.classList.toggle('hidden');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
|
||||||
document.querySelectorAll('.state-CANCELED').forEach(row => {
|
|
||||||
row.classList.add('hidden');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById("arrivals")?.addEventListener("click", clickRow);
|
|
||||||
document.getElementById("landed")?.addEventListener("click", clickRow);
|
|
||||||
|
|
||||||
function clickRow (event) {
|
|
||||||
let td = event.target.closest("td");
|
|
||||||
if (!td) return; // Clicked outside <td>
|
|
||||||
|
|
||||||
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>
|
||||||
|
|
||||||
<?php include("footer.php"); ?>
|
|
||||||
|
|
||||||
|
|||||||
304
upcoming.php
@@ -1,304 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("functions.php");
|
|
||||||
require_db_auth();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="refresh" content="300">
|
|
||||||
<!-- Include SweetAlert -->
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Upcoming Movements</title>
|
|
||||||
<style>
|
|
||||||
|
|
||||||
/* Table styling */
|
|
||||||
table {
|
|
||||||
width: 80%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
margin: 20px auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
table, th, td {
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
}
|
|
||||||
|
|
||||||
th, td {
|
|
||||||
padding: 8px;
|
|
||||||
text-align: center;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
padding: 8px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 8px;
|
|
||||||
text-align: center;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
font-size: 16pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr:nth-child(even) {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr:hover {
|
|
||||||
background-color: #f1f1f1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight100LL {
|
|
||||||
background-color: #ADD8E6 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlightJET {
|
|
||||||
background-color: yellow !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-container {
|
|
||||||
display: flex;
|
|
||||||
gap: 15px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
padding: 10px;
|
|
||||||
background: #f9f9f9;
|
|
||||||
border-radius: 8px;
|
|
||||||
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;
|
|
||||||
gap: 5px;
|
|
||||||
font-size: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-CANCELED {
|
|
||||||
text-decoration: line-through;
|
|
||||||
color: gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-LANDED {
|
|
||||||
font-style: italic;
|
|
||||||
color: gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="checkbox"] {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.acreg {
|
|
||||||
padding: 4px;
|
|
||||||
text-align: center;
|
|
||||||
font-family: Arial, sans-serif;
|
|
||||||
font-size: 10pt;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<?php include("menu.php"); ?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function markAction(id, action, title, buttonText) {
|
|
||||||
const now = new Date();
|
|
||||||
const currentTime = now.toISOString().slice(11, 16); // Extract HH:MM
|
|
||||||
|
|
||||||
Swal.fire({
|
|
||||||
title: title,
|
|
||||||
html: `<input type="time" id="timepicker" class="swal2-input" value="${currentTime}">`,
|
|
||||||
icon: "info",
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: "#3085d6",
|
|
||||||
cancelButtonColor: "#d33",
|
|
||||||
confirmButtonText: buttonText,
|
|
||||||
preConfirm: () => {
|
|
||||||
const time = document.getElementById("timepicker").value;
|
|
||||||
if (!time) {
|
|
||||||
Swal.showValidationMessage("Please select a time");
|
|
||||||
}
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.isConfirmed) {
|
|
||||||
const page = `action.php?op=${action}&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) {
|
|
||||||
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) {
|
|
||||||
const page = `action.php?op=detail&id=${id}`;
|
|
||||||
var popupWindow = window.open(page, "PopupWindow", "toolbar=no, location=no, directories=no,status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=600, height=1100");
|
|
||||||
popupWindow.onload = function () {
|
|
||||||
var contentHeight = popupWindow.document.body.scrollHeight;
|
|
||||||
var contentWidth = popupWindow.document.body.scrollWidth;
|
|
||||||
popupWindow.resizeTo(contentWidth + 20, contentHeight + 180); // Adding padding to prevent clipping
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<center><h2>Upcoming Movements</h2></center>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
function renderTableCell($key, $value, $row) {
|
|
||||||
if ($key == 'ETA') {
|
|
||||||
return "<td>" . htmlspecialchars($value ?? '') . (!empty($value) ? " Z" : "") . "</td>";
|
|
||||||
}
|
|
||||||
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
|
|
||||||
$notes = htmlspecialchars($row['notes'] ?? '');
|
|
||||||
$acCall = htmlspecialchars($row['ac_call'] ?? '');
|
|
||||||
$acReg = htmlspecialchars($value ?? '');
|
|
||||||
if (!empty($row['notes'])) {
|
|
||||||
return "<td class='red-triangle' data-notes='$notes'>$acCall<br><span class='acreg'>$acReg</span></td>";
|
|
||||||
}
|
|
||||||
return "<td>$acCall<br><span class='acreg'>$acReg</span></td>";
|
|
||||||
} elseif ($key == 'ac_reg' && !empty($row['notes'])) {
|
|
||||||
$notes = htmlspecialchars($row['notes'] ?? '');
|
|
||||||
$acReg = htmlspecialchars($value ?? '');
|
|
||||||
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 {
|
|
||||||
return "<td>" . htmlspecialchars($value ?? '') . "</td>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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/edit.png' title='Edit Details' style='width: 25px; height: auto;' onclick='openDetail($id)'>
|
|
||||||
</td>";
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderTableRow($row) {
|
|
||||||
$rowHtml = "<tr>";
|
|
||||||
foreach ($row as $key => $value) {
|
|
||||||
if (!in_array($key, ['id', 'ac_call', 'notes'])) { // Exclude 'notes'
|
|
||||||
$rowHtml .= renderTableCell($key, $value, $row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$rowHtml .= renderActionsCell($row['id']);
|
|
||||||
$rowHtml .= "</tr>";
|
|
||||||
return $rowHtml;
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderTable($result) {
|
|
||||||
$tableHtml = "<table border='1'>
|
|
||||||
<thead>
|
|
||||||
<tr>";
|
|
||||||
$fields = $result->fetch_fields();
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
if (!in_array($field->name, ['id', 'ac_call', 'notes'])) { // Exclude 'notes'
|
|
||||||
$tableHtml .= "<th>" . htmlspecialchars($field->name ?? '') . "</th>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$tableHtml .= "<th>Actions</th></tr></thead><tbody>";
|
|
||||||
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
$tableHtml .= renderTableRow($row);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tableHtml .= "</tbody></table>";
|
|
||||||
return $tableHtml;
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn = connectDb();
|
|
||||||
$sql = "SELECT id, ac_reg, ac_type, ac_call, eta AS ETA, fuel, in_from, pob_in, notes
|
|
||||||
FROM submitted
|
|
||||||
WHERE DATE(eta) > CURDATE()
|
|
||||||
AND status != 'CANCELED'
|
|
||||||
ORDER BY eta ASC;";
|
|
||||||
$result = $conn->query($sql);
|
|
||||||
|
|
||||||
if ($result->num_rows > 0) {
|
|
||||||
echo renderTable($result);
|
|
||||||
} else {
|
|
||||||
echo "<center>No upcoming movements found.</center>";
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn->close();
|
|
||||||
?>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
<?php include("footer.php"); ?>
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("functions.php");
|
|
||||||
require_db_auth();
|
|
||||||
|
|
||||||
$conn = connectDb();
|
|
||||||
|
|
||||||
// Ensure required parameters are received
|
|
||||||
if (!isset($_POST['id'], $_POST['column'], $_POST['new_value'], $_POST['old_value'])) {
|
|
||||||
die(json_encode(['error' => 'Invalid request']));
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = intval($_POST['id']); // Sanitize ID
|
|
||||||
$column = $_POST['column'];
|
|
||||||
$old_value = $_POST['old_value'];
|
|
||||||
$new_value = $_POST['new_value'];
|
|
||||||
|
|
||||||
// Allowed columns for security (prevent SQL injection)
|
|
||||||
$allowed_columns = [
|
|
||||||
'ac_reg', 'ac_type', 'ac_call', 'captain',
|
|
||||||
'in_from', 'pob_in', 'eta', 'fuel',
|
|
||||||
'pob_out', 'out_to', 'etd', 'email', 'phone', 'notes'
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!in_array($column, $allowed_columns)) {
|
|
||||||
die(json_encode(['error' => 'Invalid column']));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert eta or etd to UTC if supplied
|
|
||||||
// 1st June 2025 JP - NO - when editing just use Zulu time
|
|
||||||
//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']));
|
|
||||||
}
|
|
||||||
|
|
||||||
$stmt->bind_param("si", $new_value, $id);
|
|
||||||
$success = $stmt->execute();
|
|
||||||
$stmt->close();
|
|
||||||
|
|
||||||
// If update successful, log the change
|
|
||||||
if ($success) {
|
|
||||||
$message = $column . " changed from " . $old_value . " to " . $new_value;
|
|
||||||
logJournal($conn, $id, $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
$conn->close();
|
|
||||||
|
|
||||||
// Return JSON response
|
|
||||||
echo json_encode([
|
|
||||||
'success' => $success,
|
|
||||||
'column' => $column,
|
|
||||||
'old_value' => $old_value,
|
|
||||||
'new_value' => $new_value
|
|
||||||
]);
|
|
||||||
?>
|
|
||||||
149
webhook.php
@@ -1,103 +1,84 @@
|
|||||||
<?php
|
<?php
|
||||||
include("functions.php");
|
|
||||||
|
|
||||||
$conn = connectDb();
|
// Basic connection settings
|
||||||
|
$databaseHost = 'sasaprod.pattinson.org';
|
||||||
|
$databaseUsername = 'root';
|
||||||
|
$databasePassword = 'PugPictureMousePen';
|
||||||
|
$databaseName = 'pprdevdb';
|
||||||
|
$created_by = "webhook-dev";
|
||||||
|
|
||||||
|
//ini_set("error_log", "ppr.log");
|
||||||
|
error_log("Webhook handler called");
|
||||||
|
|
||||||
|
// Connect to the database
|
||||||
|
$mysqli = mysqli_connect($databaseHost, $databaseUsername, $databasePassword, $databaseName);
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
#if($json = json_decode(file_get_contents("php://input"), true)) {
|
||||||
|
if($json = json_decode(file_get_contents("testhook.json"), true)) {
|
||||||
|
|
||||||
|
$data = $json;
|
||||||
|
|
||||||
// Check if the URL has a 'test' parameter set
|
|
||||||
if (isset($_GET['test'])) {
|
|
||||||
$payload = json_decode(file_get_contents('testhook.json'), true);
|
|
||||||
} else {
|
|
||||||
$payload = json_decode(file_get_contents('php://input'), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log the received payload for debugging
|
print_r($data);
|
||||||
error_log("Received payload: " . print_r($payload, true));
|
|
||||||
|
|
||||||
// Mapping of JSON 'name' keys to database column names
|
$fieldMap = array();
|
||||||
$columnMapping = [
|
$fieldMap['ac_reg'] = '617dd0cd-2d17-4d7f-826b-5348afdb30b3';
|
||||||
"Aircraft Registration" => "ac_reg",
|
$fieldMap['ac_type'] = '148a55d8-5357-49a3-b9aa-2a5d4dc64173';
|
||||||
"Aircraft Type" => "ac_type",
|
$fieldMap['ac_call'] = '52d7bc90-9d26-48a1-82db-b91b4ccd2f92';
|
||||||
"Callsign" => "ac_call",
|
$fieldMap['captain'] = '49b2de0d-5bd6-4b0c-86dd-b18b85f8b8ff';
|
||||||
"Captain or PIC Name" => "captain",
|
$fieldMap['fuel'] = 'd153c8a5-8345-4e6a-abfd-cf8adcc06f2d';
|
||||||
"Arriving From" => "in_from",
|
$fieldMap['in_from'] = '4b4f7ecd-f80c-4e86-a7ab-6fadb3220df8';
|
||||||
"ETA" => "eta",
|
$fieldMap['eta'] = 'ca4ac44f-0388-4a70-a072-38276ed2ac13';
|
||||||
"POB Inbound" => "pob_in",
|
$fieldMap['pob_in'] = '6fc47c54-7383-48fd-93fc-d8080f5ed8f5';
|
||||||
"Fuel Required" => "fuel",
|
$fieldMap['out_to'] = 'ba95fd3f-1ec0-4553-95d3-a0b6a850738d';
|
||||||
"Departing To" => "out_to",
|
$fieldMap['etd'] = '53d60abd-eb75-4b1f-92b6-5d47d26367ec';
|
||||||
"ETD" => "etd",
|
$fieldMap['pob_out'] = 'd1ac0860-31f4-4914-9d0b-cae42dfc7eda';
|
||||||
"POB Outbound" => "pob_out",
|
$fieldMap['email'] = '0198c86c-edd1-4aaf-93a1-d68f8fc8c365';
|
||||||
"Email" => "email",
|
$fieldMap['phone'] = 'e40ebc2d-887b-42b3-931d-c981c76b0c20';
|
||||||
"Phone Number" => "phone",
|
$fieldMap['notes'] = '73d26c2c-1d3d-44e2-82fc-3a1a2600c393';
|
||||||
"Additional Information" => "notes"
|
|
||||||
];
|
|
||||||
|
|
||||||
// Prepare the SQL statement dynamically
|
#print_r($json['data'][$fieldMap['eta']]['value']);
|
||||||
$columns = [];
|
|
||||||
$values = [];
|
|
||||||
$placeholders = [];
|
|
||||||
$types = '';
|
|
||||||
$email = '';
|
|
||||||
$ac_reg = '';
|
|
||||||
|
|
||||||
foreach ($payload['data'] as $key => $field) {
|
$stmt = mysqli_prepare($mysqli, "INSERT INTO submitted (ac_reg, ac_type, captain, fuel, in_from, eta, pob_in, etd, pob_out, email, phone, notes, created_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
$name = $field['name'];
|
|
||||||
if (isset($columnMapping[$name])) {
|
|
||||||
$columns[] = $columnMapping[$name];
|
|
||||||
$value = $field['value'];
|
|
||||||
|
|
||||||
// Transform ETA and ETD to MySQL datetime format in UTC
|
// Check if the statement was prepared correctly
|
||||||
if ($name == "ETA" || $name == "ETD") {
|
if ($stmt === false) {
|
||||||
$date = DateTime::createFromFormat('d/m/Y H:i', $value, new DateTimeZone('Europe/London'));
|
die('MySQL prepare error: ' . mysqli_error($conn));
|
||||||
$date->setTimezone(new DateTimeZone('UTC')); // Convert to UTC
|
|
||||||
$value = $date->format('Y-m-d H:i:s');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle POB Inbound and POB Outbound as integers
|
|
||||||
if ($name == "POB Inbound" || $name == "POB Outbound") {
|
|
||||||
$types .= 'i';
|
|
||||||
} else {
|
|
||||||
$types .= 's'; // Assuming all other values are strings
|
|
||||||
}
|
|
||||||
|
|
||||||
$values[] = $value;
|
|
||||||
$placeholders[] = '?';
|
|
||||||
|
|
||||||
// Capture email and aircraft registration for email sending
|
|
||||||
if ($name == "Email") {
|
|
||||||
$email = $value;
|
|
||||||
}
|
|
||||||
if ($name == "Aircraft Registration") {
|
|
||||||
$ac_reg = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add created_by to the columns, values, and placeholders
|
$ac_reg = $json['data'][$fieldMap['ac_reg']]['value'];
|
||||||
$columns[] = 'created_by';
|
$ac_type = $json['data'][$fieldMap['ac_type']]['value'];
|
||||||
$values[] = $created_by;
|
$captain = $json['data'][$fieldMap['captain']]['value'];
|
||||||
$placeholders[] = '?';
|
$in_from = $json['data'][$fieldMap['in_from']]['value'];
|
||||||
$types .= 's';
|
$fuel = $json['data'][$fieldMap['fuel']]['value'];
|
||||||
|
$date = DateTime::createFromFormat('d/m/Y H:i', $json['data'][$fieldMap['eta']]['value']);
|
||||||
|
$eta = $date->format('Y-m-d H:i:s');
|
||||||
|
$pob_in = $json['data'][$fieldMap['pob_in']]['value'];
|
||||||
|
|
||||||
$sql = "INSERT INTO submitted (" . implode(', ', $columns) . ") VALUES (" . implode(', ', $placeholders) . ")";
|
if (array_key_exists($fieldMap['out_to'], $json['data'])) {
|
||||||
$stmt = $conn->prepare($sql);
|
$date = DateTime::createFromFormat('d/m/Y H:i', $json['data'][$fieldMap['etd']]['value']);
|
||||||
|
$etd = $date->format('Y-m-d H:i:s');
|
||||||
|
$pob_out = $json['data'][$fieldMap['pob_out']]['value'];
|
||||||
|
$out_to = $json['data'][$fieldMap['out_to']]['value'];
|
||||||
|
}
|
||||||
|
|
||||||
// Bind parameters dynamically
|
$email = $json['data'][$fieldMap['email']]['value'];
|
||||||
$stmt->bind_param($types, ...$values);
|
$phone = $json['data'][$fieldMap['phone']]['value'];
|
||||||
|
$notes = $json['data'][$fieldMap['notes']]['value'];
|
||||||
|
|
||||||
|
mysqli_stmt_bind_param($stmt, "ssssssisissss", $ac_reg, $ac_type, $captain, $fuel, $in_from, $eta, $pob_in, $etd, $pob_out, $email, $phone, $notes, $created_by);
|
||||||
|
|
||||||
// Execute the statement
|
// Execute the statement
|
||||||
if ($stmt->execute()) {
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
error_log("New record created successfully");
|
error_log("Record inserted for " . $ac_reg);
|
||||||
$lastId = $stmt->insert_id;
|
|
||||||
if (!empty($email)) {
|
|
||||||
generatePprEmail($lastId, $email, $ac_reg);
|
|
||||||
} else {
|
|
||||||
error_log("Email is not set.");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
error_log("Error: " . $stmt->error);
|
error_log("Error: " . mysqli_stmt_error($stmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the connection
|
// Close the statement and connection
|
||||||
$stmt->close();
|
mysqli_stmt_close($stmt);
|
||||||
$conn->close();
|
mysqli_close($mysqli);
|
||||||
?>
|
?>
|
||||||