TZ and editable fields
This commit is contained in:
65
tower.php
65
tower.php
@@ -245,6 +245,9 @@ function openDetail(id) {
|
||||
<?php
|
||||
|
||||
function renderTableCell($key, $value, $row) {
|
||||
if ($key == 'ETA' || $key == 'ETD') {
|
||||
return "<td>" . htmlspecialchars($value ?? '') . (!empty($value) ? " Z" : "") . "</td>"; // Add "Z" suffix only if not blank
|
||||
}
|
||||
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
|
||||
$notes = htmlspecialchars($row['notes'] ?? '');
|
||||
$acCall = htmlspecialchars($row['ac_call'] ?? '');
|
||||
@@ -262,6 +265,20 @@ function renderTableCell($key, $value, $row) {
|
||||
}
|
||||
}
|
||||
|
||||
function renderActionsCell($id, $status = null) {
|
||||
if ($status === 'LANDED') {
|
||||
return "<td>
|
||||
<img src='assets/cancel-icon.webp' title='Cancel PPR' style='width: 25px; height: auto;' onclick='markCancel($id)'>
|
||||
<img src='assets/depart.png' title='Depart' style='width: 30px; height: auto;' onclick='markDeparted($id)'>
|
||||
</td>";
|
||||
} else {
|
||||
return "<td>
|
||||
<img src='assets/cancel-icon.webp' title='Cancel PPR' style='width: 25px; height: auto;' onclick='markCancel($id)'>
|
||||
<img src='assets/arrive.png' title='Land' style='width: 30px; height: auto;' onclick='markLanded($id)'>
|
||||
</td>";
|
||||
}
|
||||
}
|
||||
|
||||
function renderTableRow($row) {
|
||||
$rowHtml = "<tr class='state-" . htmlspecialchars($row['status']) . "' data-id='" . htmlspecialchars($row['id']) . "'>";
|
||||
foreach ($row as $key => $value) {
|
||||
@@ -269,18 +286,11 @@ function renderTableRow($row) {
|
||||
$rowHtml .= renderTableCell($key, $value, $row);
|
||||
}
|
||||
}
|
||||
$rowHtml .= renderActionsCell($row['id']);
|
||||
$rowHtml .= renderActionsCell($row['id'], $row['status']);
|
||||
$rowHtml .= "</tr>";
|
||||
return $rowHtml;
|
||||
}
|
||||
|
||||
function renderActionsCell($id) {
|
||||
return "<td>
|
||||
<img src='assets/cancel-icon.webp' title='Cancel PPR' style='width: 25px; height: auto;' onclick='markCancel($id)'>
|
||||
<img src='assets/arrive.png' title='Land' style='width: 30px; height: auto;' onclick='markLanded($id)'>
|
||||
</td>";
|
||||
}
|
||||
|
||||
function renderTable($result) {
|
||||
$tableHtml = "<table border='1' id='arrivals'>
|
||||
<thead>
|
||||
@@ -327,44 +337,7 @@ $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 != 'notes' && $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 != 'notes' && $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 if ($key == 'ac_reg' && !empty($row['notes'])) {
|
||||
echo '<td class="red-triangle" data-notes="' . htmlspecialchars($row['notes'] ?? '') . '">' . htmlspecialchars($value ?? '') . '</td>';
|
||||
} else {
|
||||
echo '<td>' . htmlspecialchars($value ?? '') . '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '<td><img src="assets/cancel-icon.webp" title="Cancel PPR" style="width: 25px; height: auto;" onclick="markCancel(' . $row['id'] . ')"><img src="assets/depart.png" title="Depart" style="width: 30px; height: auto;" onclick="markDeparted(' . $row['id'] . ')"></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo ' </tbody></table>';
|
||||
echo renderTable($result); // Use the renderTable function
|
||||
} else {
|
||||
echo "No results found.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user