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 ''; - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; + echo ''; echo ''; echo ''; echo ''; - echo ''; + echo ''; echo ''; echo ''; echo ''; - echo ''; - echo ''; + echo ''; + echo ''; echo ''; echo ''; echo '
Aircraft Reg' . $row['ac_reg'] . '
Aircraft Type' . $row['ac_type'] . '
Callsign' . $row['ac_call'] . '
Captain' . $row['captain'] . '
Aircraft Reg
Aircraft Type
Callsign
Captain
Arriving From:' . $row['in_from'] . '
POB IN
ETA
Fuel' . $row['fuel'] . '
Fuel
POB OUT
Outbound To' . $row['out_to'] . '
ETD
Email Address' . $row['email'] . '
Phone' . $row['phone'] . '
Email Address
Phone
Notes' . $row['notes'] . '
PPR created' . $row['submitted_dt'] . ' by ' . $row['created_by'] . '
'; 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 ''; - } - - } - echo ''; - - 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 ''; - } else if ($key == 'ac_reg' && !empty($row['notes'])) { - echo ''; - } else { - echo ''; - } - } - } - echo ''; - echo ''; - } - - echo '
' . htmlspecialchars($field->name ?? '') . 'actions
' . htmlspecialchars($row['ac_call'] ?? '') . "
" . $value . '
' . htmlspecialchars($value ?? '') . '' . htmlspecialchars($value ?? '') . '
'; + 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']));