Compare commits
4 Commits
main
...
e9042f8c21
| Author | SHA1 | Date | |
|---|---|---|---|
| e9042f8c21 | |||
| 6cd92f4314 | |||
| 46f44f54d3 | |||
| 393f155c37 |
16
action.php
16
action.php
@@ -83,12 +83,24 @@ function opCancel() {
|
||||
$conn = connectDb();
|
||||
$sql = "UPDATE submitted SET status = 'CANCELED' where id = " . $_GET['id'];
|
||||
$result = $conn->query($sql);
|
||||
logJournal($conn, $_GET['id'], "Marked Canceled");
|
||||
$conn->close();
|
||||
}
|
||||
|
||||
function opLanded() {
|
||||
$conn = connectDb();
|
||||
$sql = "UPDATE submitted SET status = 'LANDED', landed_dt = NOW() where id = " . $_GET['id'];
|
||||
$result = $conn->query($sql);
|
||||
logJournal($conn, $_GET['id'], "Marked Landed");
|
||||
$conn->close();
|
||||
}
|
||||
|
||||
function opDelete() {
|
||||
$conn = connectDb();
|
||||
$sql = "UPDATE submitted SET status = 'DELETED' where id = " . $_GET['id'];
|
||||
$result = $conn->query($sql);
|
||||
logJournal($conn, $_GET['id'], "Marked Deleted");
|
||||
$conn->close();
|
||||
}
|
||||
|
||||
function opDetail() {
|
||||
@@ -126,6 +138,7 @@ function opDetail() {
|
||||
echo "No details found for the given ID.";
|
||||
|
||||
}
|
||||
$conn->close();
|
||||
}
|
||||
|
||||
switch($_GET['op']) {
|
||||
@@ -135,6 +148,9 @@ switch($_GET['op']) {
|
||||
case "landed":
|
||||
opLanded();
|
||||
break;
|
||||
case "delete":
|
||||
opDelete();
|
||||
break;
|
||||
case "detail":
|
||||
opDetail();
|
||||
break;
|
||||
|
||||
258
admin.php
Normal file
258
admin.php
Normal file
@@ -0,0 +1,258 @@
|
||||
<?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: 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;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
select {
|
||||
padding: 10px;
|
||||
font-size: 16px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
</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 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");
|
||||
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">
|
||||
<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>
|
||||
<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();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
// 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');
|
||||
|
||||
$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 '<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') {
|
||||
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="cancel-icon.webp" title="DELETE PPR" style="width: 25px; height: auto;" onclick="deletePpr(' . $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>
|
||||
1
devtest.php
Normal file
1
devtest.php
Normal file
@@ -0,0 +1 @@
|
||||
New file
|
||||
@@ -6,6 +6,16 @@ $username = 'ppruser'; // Replace with your database username
|
||||
$password = 'iJ8kN*5[g6P3jaqN'; // Replace with your database password
|
||||
$database = 'pprdevdb'; // Replace with your database name
|
||||
|
||||
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() {
|
||||
|
||||
// Create connection
|
||||
@@ -20,6 +30,15 @@ function connectDb() {
|
||||
|
||||
}
|
||||
|
||||
function logJournal($conn, $id, $message) {
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO journal (ppr_id, entry, user, ip) VALUES (?, ?, ?, ?)");
|
||||
$stmt->bind_param("isss", $id, $message, $_SERVER['PHP_AUTH_USER'], getUserIP());
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
|
||||
}
|
||||
|
||||
function require_db_auth() {
|
||||
|
||||
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
|
||||
14
input.html
14
input.html
@@ -121,12 +121,6 @@
|
||||
outline: none;
|
||||
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
|
||||
}
|
||||
|
||||
.optional-label {
|
||||
color: gray;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -144,7 +138,7 @@
|
||||
<input type="text" id="ac_type" name="ac_type" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="optional-label" for="ac_call">Callsign (optional)</label>
|
||||
<label for="ac_call">Callsign</label>
|
||||
<input type="text" id="ac_call" name="ac_call">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -173,16 +167,16 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="optional-label" for="email">Email (optional)</label>
|
||||
<label for="email">Email</label>
|
||||
<input type="email" id="email" name="email" >
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="optional-label" for="phone">Phone (optional)</label>
|
||||
<label for="phone">Phone</label>
|
||||
<input type="text" id="phone" name="phone" >
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="optional-label" for="notes">Notes (optional)</label>
|
||||
<label for="notes">Notes</label>
|
||||
<textarea id="message" name="notes" rows="4" ></textarea>
|
||||
</div>
|
||||
|
||||
|
||||
29
tower.php
29
tower.php
@@ -120,7 +120,6 @@ require_db_auth();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<center><h2>Swansea Inbound PPR <?php echo date('l d M Y'); ?></h2></center>
|
||||
|
||||
@@ -150,7 +149,7 @@ $result = $conn->query($sql);
|
||||
// Check if there are results
|
||||
if ($result->num_rows > 0) {
|
||||
// Start HTML table
|
||||
echo '<table border="1" id="entries">
|
||||
echo '<table border="1">
|
||||
<thead>
|
||||
<tr>';
|
||||
|
||||
@@ -170,7 +169,7 @@ if ($result->num_rows > 0) {
|
||||
|
||||
// Output table rows
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo '<tr data-id=' . $row['id'] . '>';
|
||||
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) {
|
||||
@@ -198,26 +197,6 @@ $conn->close();
|
||||
|
||||
<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
|
||||
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>
|
||||
|
||||
<script>
|
||||
document.getElementById("entries").addEventListener("click", function (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>
|
||||
</script>
|
||||
Reference in New Issue
Block a user