439 lines
14 KiB
PHP
439 lines
14 KiB
PHP
<?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>
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
let rows = document.querySelectorAll("table tbody tr");
|
|
|
|
rows.forEach(row => {
|
|
let fuelCell = row.cells[3]; // Get the "Fuel" cell (index 3)
|
|
|
|
if (fuelCell.textContent == "100LL") {
|
|
row.classList.add("highlight100LL"); // Add the class
|
|
} else if (fuelCell.textContent == "JET A1") {
|
|
row.classList.add("highlightJET"); // Add the class
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Swansea Daily PPR</title>
|
|
<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 */
|
|
table {
|
|
width: 80%;
|
|
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: 8px;
|
|
text-align: center;
|
|
}
|
|
td {
|
|
padding: 8px;
|
|
text-align: center;
|
|
font-family: Arial, sans-serif;
|
|
font-size: 16pt;
|
|
}
|
|
.acreg {
|
|
padding: 4px;
|
|
text-align: center;
|
|
font-family: Arial, sans-serif;
|
|
font-size: 10pt;
|
|
font-style: italic;
|
|
}
|
|
th {
|
|
background-color: #f2f2f2;
|
|
}
|
|
tr:nth-child(even) {
|
|
background-color: #f9f9f9;
|
|
}
|
|
tr:hover {
|
|
background-color: #f1f1f1;
|
|
}
|
|
|
|
.highlight100LL {
|
|
background-color: #ADD8E6 !important;
|
|
#font-weight: bold;
|
|
}
|
|
|
|
.highlightJET {
|
|
background-color: yellow !important; /* Allow it to override the odd/even shading */
|
|
#font-weight: bold;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
.state-CANCELED {
|
|
text-decoration: line-through;
|
|
color: gray;
|
|
}
|
|
|
|
.state-LANDED {
|
|
font-style: italic;
|
|
color: gray;
|
|
}
|
|
|
|
input[type="checkbox"] {
|
|
width: 18px;
|
|
height: 18px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<script>
|
|
function markDeparted(id) {
|
|
|
|
const now = new Date();
|
|
const currentTime = now.toISOString().slice(11, 16); // Extract HH:MM
|
|
|
|
Swal.fire({
|
|
title: "Depart Aircraft at time",
|
|
html: `<input type="time" id="timepicker" class="swal2-input" value="${currentTime}">`,
|
|
icon: "info",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#3085d6",
|
|
cancelButtonColor: "#d33",
|
|
confirmButtonText: "Departed",
|
|
preConfirm: () => {
|
|
const time = document.getElementById("timepicker").value;
|
|
if (!time) {
|
|
Swal.showValidationMessage("Please select a time");
|
|
}
|
|
return time;
|
|
}
|
|
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
page="action.php?op=departed&id=" + id + "&time=" + encodeURIComponent(result.value);
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("GET", page, false); // 'false' makes the request synchronous
|
|
xhr.send();
|
|
window.location.reload(true);
|
|
}
|
|
});
|
|
}
|
|
|
|
function markLanded(id) {
|
|
|
|
const now = new Date();
|
|
const currentTime = now.toISOString().slice(11, 16); // Extract HH:MM
|
|
|
|
Swal.fire({
|
|
title: "Land Aircraft at time",
|
|
html: `<input type="time" id="timepicker" class="swal2-input" value="${currentTime}">`,
|
|
icon: "info",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#3085d6",
|
|
cancelButtonColor: "#d33",
|
|
confirmButtonText: "Landed",
|
|
preConfirm: () => {
|
|
const time = document.getElementById("timepicker").value;
|
|
if (!time) {
|
|
Swal.showValidationMessage("Please select a time");
|
|
}
|
|
return time;
|
|
}
|
|
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
page="action.php?op=landed&id=" + id + "&time=" + encodeURIComponent(result.value);
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("GET", page, false); // 'false' makes the request synchronous
|
|
xhr.send();
|
|
window.location.reload(true);
|
|
}
|
|
});
|
|
}
|
|
function markLanded(id) {
|
|
|
|
const now = new Date();
|
|
const currentTime = now.toISOString().slice(11, 16); // Extract HH:MM
|
|
|
|
Swal.fire({
|
|
title: "Land Aircraft at time",
|
|
html: `<input type="time" id="timepicker" class="swal2-input" value="${currentTime}">`,
|
|
icon: "info",
|
|
showCancelButton: true,
|
|
confirmButtonColor: "#3085d6",
|
|
cancelButtonColor: "#d33",
|
|
confirmButtonText: "Landed",
|
|
preConfirm: () => {
|
|
const time = document.getElementById("timepicker").value;
|
|
if (!time) {
|
|
Swal.showValidationMessage("Please select a time");
|
|
}
|
|
return time;
|
|
}
|
|
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
page="action.php?op=landed&id=" + id + "&time=" + encodeURIComponent(result.value);
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("GET", page, false); // 'false' makes the request synchronous
|
|
xhr.send();
|
|
window.location.reload(true);
|
|
}
|
|
});
|
|
}
|
|
function markCancel(id) {
|
|
page="action.php?op=cancel&id=" + id;
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("GET", page, false); // 'false' makes the request synchronous
|
|
xhr.send();
|
|
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
|
|
};
|
|
|
|
}
|
|
|
|
</script>
|
|
<center><h2>Tower Ops <?php echo date('l d M Y'); ?></h2></center>
|
|
|
|
<div class="checkbox-container">
|
|
<label>
|
|
<input type="checkbox" id="toggle-canceled" onchange="toggleRows('state-CANCELED', this.checked)"> Show CANCELED
|
|
</label>
|
|
</div>
|
|
|
|
<div class="heading">Inbound PPR</div>
|
|
|
|
<?php
|
|
|
|
// Create connection
|
|
$conn = new mysqli($host, $username, $password, $database);
|
|
|
|
// Check connection
|
|
if ($conn->connect_error) {
|
|
die("Connection failed: " . $conn->connect_error);
|
|
}
|
|
|
|
// Define your SQL query
|
|
$sql = "SELECT id, status, ac_reg, ac_type, ac_call, TIME_FORMAT(eta,'%H:%i') AS ETA, fuel, in_from, pob_in FROM submitted WHERE DATE(eta) = CURDATE() AND (status = 'NEW' OR status = 'CANCELED') ORDER BY eta ASC;"; // Replace with your table name
|
|
|
|
// Execute the query
|
|
$result = $conn->query($sql);
|
|
|
|
// Check if there are results
|
|
if ($result->num_rows > 0) {
|
|
// Start HTML table
|
|
echo '<table border="1" id="arrivals">
|
|
<thead>
|
|
<tr>';
|
|
|
|
// Output table headers (assuming column names are known)
|
|
$fields = $result->fetch_fields();
|
|
foreach ($fields as $field) {
|
|
if ($field->name != 'status' && $field->name != 'id' && $field->name != 'ac_call') {
|
|
echo '<th>' . htmlspecialchars($field->name ?? '') . '</th>';
|
|
}
|
|
|
|
}
|
|
echo '<th>actions</th>';
|
|
|
|
echo ' </tr>
|
|
</thead>
|
|
<tbody>';
|
|
|
|
// Output table rows
|
|
while ($row = $result->fetch_assoc()) {
|
|
echo '<tr class="state-' . $row['status'] . '" data-id=' . $row['id'] . '>';
|
|
foreach ($row as $key => $value) {
|
|
if ($key != 'status' && $key != 'id' && $key != 'ac_call') {
|
|
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
|
|
echo '<td>' . htmlspecialchars($row['ac_call'] ?? '') . "<br><span class=acreg>" . $value . '</span></td>';
|
|
} else {
|
|
echo '<td>' . htmlspecialchars($value ?? '') . '</td>';
|
|
}
|
|
}
|
|
}
|
|
echo '<td><img src="cancel-icon.webp" title="Cancel PPR" style="width: 25px; height: auto;" onclick="markCancel(' . $row['id'] . ')"><img src="arrive.png" title="Land" style="width: 30px; height: auto;" onclick="markLanded(' . $row['id'] . ')"></td>';
|
|
echo '</tr>';
|
|
}
|
|
|
|
echo ' </tbody></table>';
|
|
} else {
|
|
echo "No results found.";
|
|
}
|
|
|
|
?>
|
|
|
|
<div class="heading">Booking Out</div>
|
|
|
|
<div id="landed">
|
|
|
|
<?php
|
|
|
|
// Define your SQL query
|
|
$sql = "SELECT id, status, ac_reg, ac_type, ac_call, TIME_FORMAT(etd,'%H:%i') AS ETD, fuel, out_to, pob_out FROM submitted WHERE DATE(eta) = CURDATE() AND status = 'LANDED' ORDER BY eta ASC;"; // Replace with your table name
|
|
|
|
// Execute the query
|
|
$result = $conn->query($sql);
|
|
|
|
// Check if there are results
|
|
if ($result->num_rows > 0) {
|
|
// Start HTML table
|
|
echo '<table border="1" id="landed">
|
|
<thead>
|
|
<tr>';
|
|
|
|
// Output table headers (assuming column names are known)
|
|
$fields = $result->fetch_fields();
|
|
foreach ($fields as $field) {
|
|
if ($field->name != 'status' && $field->name != 'id' && $field->name != 'ac_call') {
|
|
echo '<th>' . htmlspecialchars($field->name ?? '') . '</th>';
|
|
}
|
|
|
|
}
|
|
echo '<th>actions</th>';
|
|
|
|
echo ' </tr>
|
|
</thead>
|
|
<tbody>';
|
|
|
|
// Output table rows
|
|
while ($row = $result->fetch_assoc()) {
|
|
echo '<tr class="state-' . $row['status'] . '" data-id=' . $row['id'] . '>';
|
|
foreach ($row as $key => $value) {
|
|
if ($key != 'status' && $key != 'id' && $key != 'ac_call') {
|
|
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
|
|
echo '<td>' . htmlspecialchars($row['ac_call'] ?? '') . "<br><span class=acreg>" . $value . '</span></td>';
|
|
} else {
|
|
echo '<td>' . htmlspecialchars($value ?? '') . '</td>';
|
|
}
|
|
}
|
|
}
|
|
echo '<td><img src="cancel-icon.webp" title="Cancel PPR" style="width: 25px; height: auto;" onclick="markCancel(' . $row['id'] . ')"><img src="depart.png" title="Depart" style="width: 30px; height: auto;" onclick="markDeparted(' . $row['id'] . ')"></td>';
|
|
echo '</tr>';
|
|
}
|
|
|
|
echo ' </tbody></table>';
|
|
} else {
|
|
echo "No results found.";
|
|
}
|
|
|
|
// Close the database connection
|
|
$conn->close();
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<center><button onclick="openPopup()">Log New PPR</button></center>
|
|
|
|
<script>
|
|
function openPopup() {
|
|
popup = window.open("input.html", "PopupWindow", "toolbar=no, location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=600, height=1100");
|
|
const checkPopup = setInterval(() => {
|
|
if (popup && popup.closed) {
|
|
clearInterval(checkPopup);
|
|
window.location.reload(); // Reload parent window
|
|
}
|
|
}, 500); // Check every 500ms
|
|
}
|
|
</script>
|
|
|
|
<script>
|
|
|
|
function toggleRows(className) {
|
|
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);
|
|
}
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|