diff --git a/action.php b/action.php
index a9cba90..47be466 100644
--- a/action.php
+++ b/action.php
@@ -281,19 +281,23 @@ function opDetail() {
$row = $result->fetch_assoc();
echo '
';
echo '
';
diff --git a/tower.php b/tower.php
index d1a5c19..e461c2b 100644
--- a/tower.php
+++ b/tower.php
@@ -245,6 +245,9 @@ function openDetail(id) {
" . htmlspecialchars($value ?? '') . (!empty($value) ? " Z" : "") . ""; // 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 "
+
+
+ | ";
+ } else {
+ return "
+
+
+ | ";
+ }
+}
+
function renderTableRow($row) {
$rowHtml = "
";
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 .= "
";
return $rowHtml;
}
-function renderActionsCell($id) {
- return "
-
-
- | ";
-}
-
function renderTable($result) {
$tableHtml = "
@@ -327,44 +337,7 @@ $result = $conn->query($sql);
// Check if there are results
if ($result->num_rows > 0) {
- // Start HTML table
- echo '
-
- ';
-
- // 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 '| ' . htmlspecialchars($field->name ?? '') . ' | ';
- }
-
- }
- echo 'actions | ';
-
- echo '
-
- ';
-
- // Output table rows
- while ($row = $result->fetch_assoc()) {
- echo '';
- foreach ($row as $key => $value) {
- if ($key != 'notes' && $key != 'status' && $key != 'id' && $key != 'ac_call') {
- if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
- echo '' . htmlspecialchars($row['ac_call'] ?? '') . " " . $value . ' | ';
- } else if ($key == 'ac_reg' && !empty($row['notes'])) {
- echo '' . htmlspecialchars($value ?? '') . ' | ';
- } else {
- echo '' . htmlspecialchars($value ?? '') . ' | ';
- }
- }
- }
- echo '  | ';
- echo '
';
- }
-
- echo '
';
+ echo renderTable($result); // Use the renderTable function
} else {
echo "No results found.";
}
diff --git a/update_data.php b/update_data.php
index 75a2f42..3c5422d 100644
--- a/update_data.php
+++ b/update_data.php
@@ -25,6 +25,13 @@ if (!in_array($column, $allowed_columns)) {
die(json_encode(['error' => 'Invalid column']));
}
+// Convert eta or etd to UTC if supplied
+if (in_array($column, ['eta', 'etd'])) {
+ $date = new DateTime($new_value, new DateTimeZone('Europe/London'));
+ $date->setTimezone(new DateTimeZone('UTC'));
+ $new_value = $date->format('Y-m-d H:i:s');
+}
+
$stmt = $conn->prepare("UPDATE submitted SET `$column` = ? WHERE id = ?");
if (!$stmt) {
die(json_encode(['error' => 'Prepare statement failed']));