Compare commits
2 Commits
ac5cd4f3a0
...
391f057824
| Author | SHA1 | Date | |
|---|---|---|---|
| 391f057824 | |||
| 41dcd937cd |
170
admin.php
170
admin.php
@@ -6,70 +6,9 @@ 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
|
||||
}
|
||||
});
|
||||
|
||||
// Sorting functionality
|
||||
let table = document.querySelector("table");
|
||||
let headers = table.querySelectorAll("th");
|
||||
let sortDirection = {}; // Track sort direction for each column
|
||||
|
||||
headers.forEach((header, index) => {
|
||||
header.addEventListener("click", function() {
|
||||
let direction = sortDirection[index] === "asc" ? "desc" : "asc";
|
||||
sortDirection[index] = direction;
|
||||
sortTable(table, index, direction);
|
||||
|
||||
// Update visual indication
|
||||
headers.forEach(h => h.classList.remove("sorted-asc", "sorted-desc"));
|
||||
header.classList.add(direction === "asc" ? "sorted-asc" : "sorted-desc");
|
||||
});
|
||||
});
|
||||
|
||||
function sortTable(table, columnIndex, direction) {
|
||||
let rows = Array.from(table.querySelectorAll("tbody tr"));
|
||||
let isDate = !isNaN(Date.parse(rows[0].cells[columnIndex]?.textContent.trim() || ""));
|
||||
let isNumeric = !isNaN(rows[0].cells[columnIndex]?.textContent.trim() || "");
|
||||
let sortedRows = rows.sort((a, b) => {
|
||||
let aText = a.cells[columnIndex]?.textContent.trim() || null;
|
||||
let bText = b.cells[columnIndex]?.textContent.trim() || null;
|
||||
|
||||
if (aText === null || bText === null) {
|
||||
return aText === null ? 1 : -1; // Place null/empty values at the bottom
|
||||
}
|
||||
|
||||
if (isDate) {
|
||||
let aDate = new Date(aText);
|
||||
let bDate = new Date(bText);
|
||||
return direction === "asc" ? aDate - bDate : bDate - aDate;
|
||||
} else if (isNumeric) {
|
||||
return direction === "asc" ? aText - bText : bText - aText;
|
||||
} else {
|
||||
return direction === "asc" ? aText.localeCompare(bText) : bText.localeCompare(aText);
|
||||
}
|
||||
});
|
||||
|
||||
let tbody = table.querySelector("tbody");
|
||||
tbody.innerHTML = "";
|
||||
sortedRows.forEach(row => tbody.appendChild(row));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Swansea Daily PPR</title>
|
||||
<title>PPR Monthly Reports</title>
|
||||
<style>
|
||||
|
||||
/* Styling for the table */
|
||||
@@ -104,16 +43,6 @@ require_db_auth();
|
||||
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;
|
||||
@@ -136,42 +65,18 @@ require_db_auth();
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
/* Add styles for sorted columns */
|
||||
th.sorted-asc::after {
|
||||
content: " ▲";
|
||||
font-size: 0.8em;
|
||||
}
|
||||
th.sorted-desc::after {
|
||||
content: " ▼";
|
||||
font-size: 0.8em;
|
||||
.container {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php include("menu.php"); ?>
|
||||
|
||||
<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 deletePpr(id) {
|
||||
page="action.php?op=delete&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");
|
||||
@@ -183,29 +88,31 @@ require_db_auth();
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<center><h2>Swansea Inbound PPR ADMIN</h2></center>
|
||||
|
||||
<div class="container">
|
||||
<h2>Select a Month</h2>
|
||||
<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>
|
||||
<p id="output"></p>
|
||||
</div>
|
||||
<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() {
|
||||
@@ -251,15 +158,7 @@ require_db_auth();
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
// Create connection
|
||||
$conn = new mysqli($host, $username, $password, $database);
|
||||
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
$conn = connectDb();
|
||||
|
||||
$year = $_GET['year'] ?? date('Y');
|
||||
$month = $_GET['month'] ?? date('n');
|
||||
@@ -282,7 +181,6 @@ if ($result->num_rows > 0) {
|
||||
}
|
||||
|
||||
}
|
||||
// echo '<th>actions</th>';
|
||||
|
||||
echo ' </tr>
|
||||
</thead>
|
||||
@@ -304,15 +202,7 @@ if ($result->num_rows > 0) {
|
||||
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>
|
||||
<?php include("footer.php"); ?>
|
||||
36
footer.php
Normal file
36
footer.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<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>
|
||||
@@ -1,10 +1,11 @@
|
||||
<?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
|
||||
$host = 'sasaprod.pattinson.org';
|
||||
$username = 'ppruser';
|
||||
$password = 'iJ8kN*5[g6P3jaqN';
|
||||
$database = 'pprdevdb';
|
||||
$created_by = "Website (DEV)";
|
||||
|
||||
$mailHost = 'send.one.com'; // Your SMTP server
|
||||
$mailSMTPAuth = true;
|
||||
|
||||
33
menu.php
Normal file
33
menu.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<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>
|
||||
35
tower.php
35
tower.php
@@ -169,42 +169,11 @@ require_db_auth();
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* Menu bar styling */
|
||||
.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>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="menu-bar">
|
||||
<a href="tower.php" class="active">HOME</a>
|
||||
<a href="upcoming.php">Future PPRs</a>
|
||||
<a href="admin.php">Reports</a>
|
||||
</div>
|
||||
<?php include("menu.php"); ?>
|
||||
|
||||
<script>
|
||||
function markAction(id, action, title, buttonText) {
|
||||
@@ -440,5 +409,5 @@ $conn->close();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<?php include("footer.php"); ?>
|
||||
|
||||
|
||||
35
upcoming.php
35
upcoming.php
@@ -13,33 +13,6 @@ require_db_auth();
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Upcoming Movements</title>
|
||||
<style>
|
||||
/* ...existing styles from tower.php... */
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
/* Table styling */
|
||||
table {
|
||||
@@ -172,11 +145,7 @@ require_db_auth();
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="menu-bar">
|
||||
<a href="tower.php">HOME</a>
|
||||
<a href="upcoming.php" class="active">Future PPRs</a>
|
||||
<a href="admin.php">Reports</a>
|
||||
</div>
|
||||
<?php include("menu.php"); ?>
|
||||
|
||||
<script>
|
||||
function markAction(id, action, title, buttonText) {
|
||||
@@ -309,6 +278,7 @@ $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);
|
||||
|
||||
@@ -323,3 +293,4 @@ $conn->close();
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<?php include("footer.php"); ?>
|
||||
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
include("functions.php");
|
||||
|
||||
$created_by = "Website (DEV)";
|
||||
|
||||
$conn = connectDb();
|
||||
|
||||
// Check if the URL has a 'test' parameter set
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
<?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