Filtering of status

This commit is contained in:
2025-03-01 21:05:36 +00:00
parent 9d40de216f
commit 5077445d5d

View File

@@ -27,6 +27,28 @@ require_db_auth();
<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;
}
label {
display: flex;
align-items: center;
gap: 5px;
font-size: 16px;
cursor: pointer;
}
.hidden {
display: none;
}
/* Styling for the table */
table {
width: 80%;
@@ -91,6 +113,22 @@ require_db_auth();
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>
@@ -124,6 +162,15 @@ require_db_auth();
</script>
<center><h2>Swansea Inbound PPR <?php echo date('l d M Y'); ?></h2></center>
<div class="checkbox-container">
<label>
<input type="checkbox" id="toggle-landed" onchange="toggleRows('state-LANDED', this.checked)"> Show LANDED
</label>
<label>
<input type="checkbox" id="toggle-canceled" onchange="toggleRows('state-CANCELED', this.checked)"> Show CANCELED
</label>
</div>
<?php
// Create connection
@@ -142,7 +189,7 @@ $custom_headings = [
];
// 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
$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 != 'DELETED' ORDER BY eta ASC;"; // Replace with your table name
// Execute the query
$result = $conn->query($sql);
@@ -157,7 +204,7 @@ if ($result->num_rows > 0) {
// Output table headers (assuming column names are known)
$fields = $result->fetch_fields();
foreach ($fields as $field) {
if ($field->name != 'id' && $field->name != 'ac_call') {
if ($field->name != 'status' && $field->name != 'id' && $field->name != 'ac_call') {
echo '<th>' . htmlspecialchars($field->name ?? '') . '</th>';
}
@@ -170,9 +217,9 @@ if ($result->num_rows > 0) {
// Output table rows
while ($row = $result->fetch_assoc()) {
echo '<tr data-id=' . $row['id'] . '>';
echo '<tr class="state-' . $row['status'] . '" data-id=' . $row['id'] . '>';
foreach ($row as $key => $value) {
if ($key != 'id' && $key != 'ac_call') {
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 {
@@ -180,7 +227,7 @@ if ($result->num_rows > 0) {
}
}
}
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 '<td><span class=acreg>' . $row['status'] .'</span><br><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>';
}
@@ -209,6 +256,20 @@ $conn->close();
</script>
<script>
function toggleRows(className) {
document.querySelectorAll('.' + className).forEach(row => {
row.classList.toggle('hidden');
});
}
document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll('.state-LANDED, .state-CANCELED').forEach(row => {
row.classList.add('hidden');
});
});
document.getElementById("entries").addEventListener("click", function (event) {
let td = event.target.closest("td");
if (!td) return; // Clicked outside <td>