first commit
This commit is contained in:
148
action.php
Normal file
148
action.php
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Row 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>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
include("functions.php");
|
||||||
|
require_db_auth();
|
||||||
|
|
||||||
|
function opCancel() {
|
||||||
|
$conn = connectDb();
|
||||||
|
$sql = "UPDATE submitted SET status = 'CANCELED' where id = " . $_GET['id'];
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
function opLanded() {
|
||||||
|
$conn = connectDb();
|
||||||
|
$sql = "UPDATE submitted SET status = 'LANDED', landed_dt = NOW() where id = " . $_GET['id'];
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
function opDetail() {
|
||||||
|
$conn = connectDb();
|
||||||
|
$sql = "SELECT * FROM submitted WHERE id = " . $_GET['id'];
|
||||||
|
$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>";
|
||||||
|
echo "<p><i>PPR created at:</strong> " . $row['submitted_dt'] . " by " . $row['created_by'] . "</p></div>";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
echo "No details found for the given ID.";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($_GET['op']) {
|
||||||
|
case "cancel":
|
||||||
|
opCancel();
|
||||||
|
break;
|
||||||
|
case "landed":
|
||||||
|
opLanded();
|
||||||
|
break;
|
||||||
|
case "detail":
|
||||||
|
opDetail();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<p><center><button onclick="window.close()">Close Window</button></center>
|
||||||
|
|
||||||
18
adduser.php
Normal file
18
adduser.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
// Example to add a user with hashed password
|
||||||
|
include("functions.php");
|
||||||
|
$conn = connectDb();
|
||||||
|
|
||||||
|
$username = 'fire';
|
||||||
|
$password = 'egfh2204'; // Plain password, to be hashed
|
||||||
|
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
|
// Insert the user into the users table
|
||||||
|
$stmt = $conn->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
|
||||||
|
$stmt->bind_param("ss", $username, $hashedPassword);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
echo "User added successfully!";
|
||||||
|
$conn->close();
|
||||||
|
?>
|
||||||
146
arrivals.php
Normal file
146
arrivals.php
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
<?php
|
||||||
|
include("functions.php");
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="refresh" content="300">
|
||||||
|
<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>
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
.acreg {
|
||||||
|
padding: 4px;
|
||||||
|
text-align: center;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
font-size: 10pt;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<center><h2>Swansea Inbound PPR <?php echo date('l d M Y'); ?></h2></center>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
// Create connection
|
||||||
|
$conn = connectDb();
|
||||||
|
|
||||||
|
$custom_headings = [
|
||||||
|
'column1' => 'Custom Heading 1',
|
||||||
|
'column2' => 'Custom Heading 2',
|
||||||
|
'column3' => 'Custom Heading 3'
|
||||||
|
// Add more custom headings as needed
|
||||||
|
];
|
||||||
|
|
||||||
|
// Define your SQL query
|
||||||
|
$sql = "SELECT 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
|
||||||
|
$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 != 'ac_call') {
|
||||||
|
echo '<th>' . htmlspecialchars($field->name ?? '') . '</th>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ' </tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>';
|
||||||
|
|
||||||
|
// Output table rows
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
echo '<tr>';
|
||||||
|
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 '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ' </tbody>
|
||||||
|
</table>';
|
||||||
|
} else {
|
||||||
|
echo "No results found.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the database connection
|
||||||
|
$conn->close();
|
||||||
|
?>
|
||||||
BIN
cancel-icon.webp
Normal file
BIN
cancel-icon.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
74
functions.php
Normal file
74
functions.php
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Database connection details
|
||||||
|
$host = 'sasaprod.pattinson.org'; // Replace with your database host (usually 'localhost')
|
||||||
|
$username = 'ppruser'; // Replace with your database username
|
||||||
|
$password = 'iJ8kN*5[g6P3jaqN'; // Replace with your database password
|
||||||
|
$database = 'pprdevdb'; // Replace with your database name
|
||||||
|
|
||||||
|
function connectDb() {
|
||||||
|
|
||||||
|
// Create connection
|
||||||
|
$conn = new mysqli( $GLOBALS['host'], $GLOBALS['username'], $GLOBALS['password'], $GLOBALS['database']);
|
||||||
|
|
||||||
|
// Check connection
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $conn;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function require_db_auth() {
|
||||||
|
|
||||||
|
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
|
||||||
|
send_auth_headers();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $_SERVER['PHP_AUTH_USER'];
|
||||||
|
$pass = $_SERVER['PHP_AUTH_PW'];
|
||||||
|
|
||||||
|
$conn = connectDb();
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("SELECT password FROM users WHERE username = ?");
|
||||||
|
$stmt->bind_param("s", $user);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->store_result();
|
||||||
|
$stmt->bind_result($stored_hash);
|
||||||
|
$stmt->fetch();
|
||||||
|
|
||||||
|
// Verify the password
|
||||||
|
if ($stmt->num_rows == 0 || !password_verify($pass, $stored_hash)) {
|
||||||
|
send_auth_headers();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the connection
|
||||||
|
$stmt->close();
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_auth_headers() {
|
||||||
|
header('WWW-Authenticate: Basic realm="Restricted Area"');
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
die("Authentication required.");
|
||||||
|
}
|
||||||
|
|
||||||
|
function require_auth() {
|
||||||
|
$AUTH_USER = 'admin';
|
||||||
|
$AUTH_PASS = 'admin';
|
||||||
|
header('Cache-Control: no-cache, must-revalidate, max-age=0');
|
||||||
|
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
|
||||||
|
$is_not_authenticated = (
|
||||||
|
!$has_supplied_credentials ||
|
||||||
|
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
|
||||||
|
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
|
||||||
|
);
|
||||||
|
if ($is_not_authenticated) {
|
||||||
|
header('HTTP/1.1 401 Authorization Required');
|
||||||
|
header('WWW-Authenticate: Basic realm="PPR"');
|
||||||
|
echo 'Text to send if user hits Cancel button';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
188
input.html
Normal file
188
input.html
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
<script>
|
||||||
|
window.onload = function() {
|
||||||
|
document.getElementById('ac_reg').focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set default value to current date & time
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
let now = new Date();
|
||||||
|
let localDatetime = now.toISOString().slice(0, 16); // Format for datetime-local input
|
||||||
|
document.getElementById("eta").value = localDatetime;
|
||||||
|
});
|
||||||
|
|
||||||
|
function fetchResults() {
|
||||||
|
let input = document.getElementById("ac_reg").value.replace(/[^a-zA-Z0-9]/g, '');
|
||||||
|
|
||||||
|
// Trigger only if 4+ characters are entered
|
||||||
|
if (input.length >= 5) {
|
||||||
|
fetch(`lookup.php?reg=${encodeURIComponent(input)}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
let resultsDiv = document.getElementById("results");
|
||||||
|
let typeDiv = document.getElementById("ac_type");
|
||||||
|
let regDiv = document.getElementById("ac_reg");
|
||||||
|
|
||||||
|
resultsDiv.innerHTML = ""; // Clear previous results
|
||||||
|
console.log(data)
|
||||||
|
if (data.length == 1) {
|
||||||
|
resultsDiv.innerHTML = "<p>" + data[0].manufacturername + "<br>" + data[0].model + "</p>"
|
||||||
|
typeDiv.value = data[0].typecode;
|
||||||
|
regDiv.value = data[0].registration;
|
||||||
|
} else {
|
||||||
|
resultsDiv.innerHTML = "<p>No results found</p>";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => console.error("Error fetching data:", error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Manual PPR</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f4f4f9;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 20px;
|
||||||
|
width: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
text-align: center;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
font-weight: bold;
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, textarea {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 1rem;
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus, textarea:focus {
|
||||||
|
border-color: #007bff;
|
||||||
|
outline: none;
|
||||||
|
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
background: #007bff;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
font-size: 1rem;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 1rem;
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#results {
|
||||||
|
font-weight: bold;
|
||||||
|
font-family: 'Courier New', Courier, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
select:focus {
|
||||||
|
border-color: #007bff;
|
||||||
|
outline: none;
|
||||||
|
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="form-container">
|
||||||
|
<h2>Log new PPR</h2>
|
||||||
|
<form action="newppr.php" method="POST">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="ac_reg">Registration</label>
|
||||||
|
<input type="text" id="ac_reg" name="ac_reg" onkeyup="fetchResults()" required>
|
||||||
|
</div>
|
||||||
|
<div id="results"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="ac_type">Type</label>
|
||||||
|
<input type="text" id="ac_type" name="ac_type" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="ac_call">Callsign</label>
|
||||||
|
<input type="text" id="ac_call" name="ac_call">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="captain">Captain's Name</label>
|
||||||
|
<input type="text" id="captain" name="captain" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="in_from">Arriving From</label>
|
||||||
|
<input type="text" id="in_from" name="in_from" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="pob_in">POB</label>
|
||||||
|
<input type="number" id="pob_in" name="pob_in" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group"></div>
|
||||||
|
<label for="eta">ETA</label>
|
||||||
|
<input type="datetime-local" id="eta" name="eta">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="fuel">Fuel Needed</label>
|
||||||
|
<select id="fuel" name="fuel" single>
|
||||||
|
<option value="None">None</option>
|
||||||
|
<option value="JET A1">JET A1</option>
|
||||||
|
<option value="100LL">100LL</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="email">Email</label>
|
||||||
|
<input type="email" id="email" name="email" >
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="phone">Phone</label>
|
||||||
|
<input type="text" id="phone" name="phone" >
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="notes">Notes</label>
|
||||||
|
<textarea id="message" name="notes" rows="4" ></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
27
lookup.php
Normal file
27
lookup.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
include("functions.php");
|
||||||
|
require_db_auth();
|
||||||
|
|
||||||
|
$conn = connectDb();
|
||||||
|
|
||||||
|
// SQL Query
|
||||||
|
$sql = "SELECT * FROM aircraft WHERE clean_reg like '" . $_GET['reg'] . "'"; // Modify table/fields as needed
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
|
||||||
|
// Fetch data
|
||||||
|
$data = [];
|
||||||
|
if ($result->num_rows > 0) {
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$data[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close connection
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
// Return JSON output
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode($data, JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
36
newppr.php
Normal file
36
newppr.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
include("functions.php");
|
||||||
|
require_db_auth();
|
||||||
|
|
||||||
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
|
|
||||||
|
$conn = connectDb();
|
||||||
|
|
||||||
|
$columns = [];
|
||||||
|
$values = [];
|
||||||
|
|
||||||
|
echo "<h2>Received POST Data:</h2>";
|
||||||
|
echo "<ul>";
|
||||||
|
foreach ($_POST as $key => $value) {
|
||||||
|
$columns[] = "`" . $conn->real_escape_string($key) . "`";
|
||||||
|
$values[] = "'" . $conn->real_escape_string($value) . "'";
|
||||||
|
echo "<li><strong>" . htmlspecialchars($key) . ":</strong> " . htmlspecialchars($value) . "</li>";
|
||||||
|
}
|
||||||
|
if (!empty($columns)) {
|
||||||
|
$sql = "INSERT INTO submitted (created_by, " . implode(",", $columns) . ") VALUES ('" . $_SERVER['PHP_AUTH_USER'] . "'," . implode(",", $values) . ")";
|
||||||
|
echo $sql;
|
||||||
|
|
||||||
|
if ($conn->query($sql) === TRUE) {
|
||||||
|
echo "<p>Data successfully inserted into database.</p>";
|
||||||
|
echo '<script>window.close();</script>';
|
||||||
|
} else {
|
||||||
|
echo "<p>Error inserting data: " . $conn->error . "</p>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "</ul>";
|
||||||
|
} else {
|
||||||
|
echo "<h2>No POST data received.</h2>";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
79
testhook.json
Normal file
79
testhook.json
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"form_title": "PPR Request Form",
|
||||||
|
"form_slug": "ppr-request-form-joclld",
|
||||||
|
"submission": {
|
||||||
|
"Aircraft Registration": "G-BJAJ",
|
||||||
|
"Aircraft Type": "AA5",
|
||||||
|
"Callsign": "TEST1",
|
||||||
|
"Captain or PIC Name": "TESTY MCTESTFACE",
|
||||||
|
"Arriving From": "Wellesbourne",
|
||||||
|
"ETA": "11\/02\/2025 14:33",
|
||||||
|
"POB Inbound": "2",
|
||||||
|
"Fuel Required": "100LL",
|
||||||
|
"Departing To": "Pembrey",
|
||||||
|
"ETD": "12\/02\/2025 00:00",
|
||||||
|
"POB Outbound": "2",
|
||||||
|
"Email": "james@pattinson.org",
|
||||||
|
"Phone Number": "+441212121212",
|
||||||
|
"Additional Information": "Here are some notes man"
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"617dd0cd-2d17-4d7f-826b-5348afdb30b3": {
|
||||||
|
"value": "G-BJAJ",
|
||||||
|
"name": "Aircraft Registration"
|
||||||
|
},
|
||||||
|
"148a55d8-5357-49a3-b9aa-2a5d4dc64173": {
|
||||||
|
"value": "AA5",
|
||||||
|
"name": "Aircraft Type"
|
||||||
|
},
|
||||||
|
"52d7bc90-9d26-48a1-82db-b91b4ccd2f92": {
|
||||||
|
"value": "TEST1",
|
||||||
|
"name": "Callsign"
|
||||||
|
},
|
||||||
|
"49b2de0d-5bd6-4b0c-86dd-b18b85f8b8ff": {
|
||||||
|
"value": "TESTY MCTESTFACE",
|
||||||
|
"name": "Captain or PIC Name"
|
||||||
|
},
|
||||||
|
"4b4f7ecd-f80c-4e86-a7ab-6fadb3220df8": {
|
||||||
|
"value": "Wellesbourne",
|
||||||
|
"name": "Arriving From"
|
||||||
|
},
|
||||||
|
"ca4ac44f-0388-4a70-a072-38276ed2ac13": {
|
||||||
|
"value": "11\/02\/2025 14:33",
|
||||||
|
"name": "ETA"
|
||||||
|
},
|
||||||
|
"6fc47c54-7383-48fd-93fc-d8080f5ed8f5": {
|
||||||
|
"value": "2",
|
||||||
|
"name": "POB Inbound"
|
||||||
|
},
|
||||||
|
"d153c8a5-8345-4e6a-abfd-cf8adcc06f2d": {
|
||||||
|
"value": "100LL",
|
||||||
|
"name": "Fuel Required"
|
||||||
|
},
|
||||||
|
"ba95fd3f-1ec0-4553-95d3-a0b6a850738d": {
|
||||||
|
"value": "Pembrey",
|
||||||
|
"name": "Departing To"
|
||||||
|
},
|
||||||
|
"53d60abd-eb75-4b1f-92b6-5d47d26367ec": {
|
||||||
|
"value": "12\/02\/2025 00:00",
|
||||||
|
"name": "ETD"
|
||||||
|
},
|
||||||
|
"d1ac0860-31f4-4914-9d0b-cae42dfc7eda": {
|
||||||
|
"value": "2",
|
||||||
|
"name": "POB Outbound"
|
||||||
|
},
|
||||||
|
"0198c86c-edd1-4aaf-93a1-d68f8fc8c365": {
|
||||||
|
"value": "james@pattinson.org",
|
||||||
|
"name": "Email"
|
||||||
|
},
|
||||||
|
"e40ebc2d-887b-42b3-931d-c981c76b0c20": {
|
||||||
|
"value": "+441212121212",
|
||||||
|
"name": "Phone Number"
|
||||||
|
},
|
||||||
|
"73d26c2c-1d3d-44e2-82fc-3a1a2600c393": {
|
||||||
|
"value": "Here are some notes man",
|
||||||
|
"name": "Additional Information"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"message": "Please do not use the `submission` field. It is deprecated and will be removed in the future."
|
||||||
|
}
|
||||||
202
tower.php
Normal file
202
tower.php
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
<?php
|
||||||
|
include("functions.php");
|
||||||
|
require_db_auth();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="refresh" content="300">
|
||||||
|
<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>
|
||||||
|
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function markLanded(id) {
|
||||||
|
page="action.php?op=landed&id=" + id;
|
||||||
|
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>Swansea Inbound PPR <?php echo date('l d M Y'); ?></h2></center>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Create connection
|
||||||
|
$conn = new mysqli($host, $username, $password, $database);
|
||||||
|
|
||||||
|
// Check connection
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$custom_headings = [
|
||||||
|
'column1' => 'Custom Heading 1',
|
||||||
|
'column2' => 'Custom Heading 2',
|
||||||
|
'column3' => 'Custom Heading 3'
|
||||||
|
// Add more custom headings as needed
|
||||||
|
];
|
||||||
|
|
||||||
|
// Define your SQL query
|
||||||
|
$sql = "SELECT id, 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
|
||||||
|
$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' && $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 onclick="openDetail(' . $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 {
|
||||||
|
echo "No results found.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the database connection
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<center><button onclick="openPopup()">Log New PPR</button></center>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function openPopup() {
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
84
webhook.php
Normal file
84
webhook.php
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
print_r($data);
|
||||||
|
|
||||||
|
$fieldMap = array();
|
||||||
|
$fieldMap['ac_reg'] = '617dd0cd-2d17-4d7f-826b-5348afdb30b3';
|
||||||
|
$fieldMap['ac_type'] = '148a55d8-5357-49a3-b9aa-2a5d4dc64173';
|
||||||
|
$fieldMap['ac_call'] = '52d7bc90-9d26-48a1-82db-b91b4ccd2f92';
|
||||||
|
$fieldMap['captain'] = '49b2de0d-5bd6-4b0c-86dd-b18b85f8b8ff';
|
||||||
|
$fieldMap['fuel'] = 'd153c8a5-8345-4e6a-abfd-cf8adcc06f2d';
|
||||||
|
$fieldMap['in_from'] = '4b4f7ecd-f80c-4e86-a7ab-6fadb3220df8';
|
||||||
|
$fieldMap['eta'] = 'ca4ac44f-0388-4a70-a072-38276ed2ac13';
|
||||||
|
$fieldMap['pob_in'] = '6fc47c54-7383-48fd-93fc-d8080f5ed8f5';
|
||||||
|
$fieldMap['out_to'] = 'ba95fd3f-1ec0-4553-95d3-a0b6a850738d';
|
||||||
|
$fieldMap['etd'] = '53d60abd-eb75-4b1f-92b6-5d47d26367ec';
|
||||||
|
$fieldMap['pob_out'] = 'd1ac0860-31f4-4914-9d0b-cae42dfc7eda';
|
||||||
|
$fieldMap['email'] = '0198c86c-edd1-4aaf-93a1-d68f8fc8c365';
|
||||||
|
$fieldMap['phone'] = 'e40ebc2d-887b-42b3-931d-c981c76b0c20';
|
||||||
|
$fieldMap['notes'] = '73d26c2c-1d3d-44e2-82fc-3a1a2600c393';
|
||||||
|
|
||||||
|
#print_r($json['data'][$fieldMap['eta']]['value']);
|
||||||
|
|
||||||
|
$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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
|
// Check if the statement was prepared correctly
|
||||||
|
if ($stmt === false) {
|
||||||
|
die('MySQL prepare error: ' . mysqli_error($conn));
|
||||||
|
}
|
||||||
|
|
||||||
|
$ac_reg = $json['data'][$fieldMap['ac_reg']]['value'];
|
||||||
|
$ac_type = $json['data'][$fieldMap['ac_type']]['value'];
|
||||||
|
$captain = $json['data'][$fieldMap['captain']]['value'];
|
||||||
|
$in_from = $json['data'][$fieldMap['in_from']]['value'];
|
||||||
|
$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'];
|
||||||
|
|
||||||
|
if (array_key_exists($fieldMap['out_to'], $json['data'])) {
|
||||||
|
$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'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$email = $json['data'][$fieldMap['email']]['value'];
|
||||||
|
$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
|
||||||
|
if (mysqli_stmt_execute($stmt)) {
|
||||||
|
error_log("Record inserted for " . $ac_reg);
|
||||||
|
} else {
|
||||||
|
error_log("Error: " . mysqli_stmt_error($stmt));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the statement and connection
|
||||||
|
mysqli_stmt_close($stmt);
|
||||||
|
mysqli_close($mysqli);
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user