TZ changes
This commit is contained in:
97
tower.php
97
tower.php
@@ -244,64 +244,69 @@ function openDetail(id) {
|
||||
|
||||
<?php
|
||||
|
||||
// Create connection
|
||||
$conn = new mysqli($host, $username, $password, $database);
|
||||
|
||||
// Check connection
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
function renderTableCell($key, $value, $row) {
|
||||
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
|
||||
$notes = htmlspecialchars($row['notes'] ?? '');
|
||||
$acCall = htmlspecialchars($row['ac_call'] ?? '');
|
||||
$acReg = htmlspecialchars($value ?? '');
|
||||
if (!empty($row['notes'])) {
|
||||
return "<td class='red-triangle' data-notes='$notes'>$acCall<br><span class='acreg'>$acReg</span></td>";
|
||||
}
|
||||
return "<td>$acCall<br><span class='acreg'>$acReg</span></td>";
|
||||
} elseif ($key == 'ac_reg' && !empty($row['notes'])) {
|
||||
$notes = htmlspecialchars($row['notes'] ?? '');
|
||||
$acReg = htmlspecialchars($value ?? '');
|
||||
return "<td class='red-triangle' data-notes='$notes'>$acReg</td>";
|
||||
} else {
|
||||
return "<td>" . htmlspecialchars($value ?? '') . "</td>";
|
||||
}
|
||||
}
|
||||
|
||||
// Define your SQL query
|
||||
$sql = "SELECT id, status, ac_reg, ac_type, ac_call, TIME_FORMAT(eta,'%H:%i') AS ETA, fuel, in_from, pob_in, notes FROM submitted WHERE DATE(eta) = CURDATE() AND (status = 'NEW' OR status = 'CANCELED') ORDER BY eta ASC;"; // Replace with your table name
|
||||
function renderTableRow($row) {
|
||||
$rowHtml = "<tr class='state-" . htmlspecialchars($row['status']) . "' data-id='" . htmlspecialchars($row['id']) . "'>";
|
||||
foreach ($row as $key => $value) {
|
||||
if (!in_array($key, ['notes', 'status', 'id', 'ac_call'])) {
|
||||
$rowHtml .= renderTableCell($key, $value, $row);
|
||||
}
|
||||
}
|
||||
$rowHtml .= renderActionsCell($row['id']);
|
||||
$rowHtml .= "</tr>";
|
||||
return $rowHtml;
|
||||
}
|
||||
|
||||
// Execute the query
|
||||
$result = $conn->query($sql);
|
||||
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>";
|
||||
}
|
||||
|
||||
// Check if there are results
|
||||
if ($result->num_rows > 0) {
|
||||
// Start HTML table
|
||||
echo '<table border="1" id="arrivals">
|
||||
<thead>
|
||||
<tr>';
|
||||
|
||||
// Output table headers (assuming column names are known)
|
||||
function renderTable($result) {
|
||||
$tableHtml = "<table border='1' id='arrivals'>
|
||||
<thead>
|
||||
<tr>";
|
||||
$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>';
|
||||
if (!in_array($field->name, ['notes', 'status', 'id', 'ac_call'])) {
|
||||
$tableHtml .= "<th>" . htmlspecialchars($field->name ?? '') . "</th>";
|
||||
}
|
||||
|
||||
}
|
||||
echo '<th>actions</th>';
|
||||
$tableHtml .= "<th>actions</th></tr></thead><tbody>";
|
||||
|
||||
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) {
|
||||
if (!empty($row['notes'])) {
|
||||
echo '<td class="red-triangle" data-notes="' . htmlspecialchars($row['notes'] ?? '') . '">' . htmlspecialchars($row['ac_call'] ?? '') . "<br><span class=acreg>" . $value . '</span></td>';
|
||||
} else {
|
||||
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/arrive.png" title="Land" style="width: 30px; height: auto;" onclick="markLanded(' . $row['id'] . ')"></td>';
|
||||
echo '</tr>';
|
||||
$tableHtml .= renderTableRow($row);
|
||||
}
|
||||
|
||||
echo ' </tbody></table>';
|
||||
$tableHtml .= "</tbody></table>";
|
||||
return $tableHtml;
|
||||
}
|
||||
|
||||
$conn = connectDb();
|
||||
$sql = "SELECT id, status, ac_reg, ac_type, ac_call, TIME_FORMAT(eta,'%H:%i') AS ETA, fuel, in_from, pob_in, notes FROM submitted WHERE DATE(eta) = CURDATE() AND (status = 'NEW' OR status = 'CANCELED') ORDER BY eta ASC;"; // Replace with your table name
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
echo renderTable($result);
|
||||
} else {
|
||||
echo "No results found.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user