0 && trim((string)($row['NearbyStepEventDetails'] ?? '')) !== '') { $reason = 'Nearby same-step event #' . (int)$row['NearbyStepEventID'] . ' (within 10 seconds; context only): ' . trim((string)$row['NearbyStepEventDetails']); } $recipient = ''; $intended = ''; $noticeResult = ''; if ($isNotice) { if ($notification !== null) { $role = trim((string)($notification['recipient_role'] ?? '')); $name = trim((string)($notification['recipient_name'] ?? '')); $destination = trim((string)($notification['actual_destination'] ?? '')); $intended = trim((string)($notification['intended_destination'] ?? '')); if ($destination !== '' && empty($notification['redirected'])) $intended = ''; $recipient = trim(($role !== '' ? $role : 'Recipient') . ($name !== '' ? ' - ' . $name : '') . ($destination !== '' ? ' | ' . $destination : ' | destination not recorded')); $labels = array( 'provider_accepted' => 'Provider accepted; delivery not confirmed', 'submitted_to_sender' => 'Submitted to sender; delivery not confirmed', 'failed' => 'Failed', 'blocked' => 'Blocked', 'not_sent' => 'Not sent', 'unknown' => 'Outcome unknown', 'delivered' => 'Delivered to mail server; not proof of reading', 'soft_bounced' => 'Delivery failed: soft bounce', 'hard_bounced' => 'Delivery failed: hard bounce', 'open_detected' => 'Email open detected; not proof of reading or acknowledgement', 'rejected' => 'Delivery failed: rejected' ); $stage = (string)($notification['stage'] ?? 'unknown'); $noticeResult = $labels[$stage] ?? 'Outcome unknown'; } else { $recipient = $isNoticeSummary ? 'See the separate Email and SMS events' : 'Not recorded in this event'; $noticeResult = $isNoticeSummary && trim((string)($row['Details'] ?? '')) !== '' ? trim((string)$row['Details']) : 'Not recorded in this event'; } } $locations = array(); foreach (array('detectiveGPS' => 'Detective GPS', 'trackerLocation' => 'Tracker location') as $key => $label) { if (!isset($payload[$key]) || !is_array($payload[$key])) continue; $point = $payload[$key]; $source = trim((string)($point['source'] ?? '')); $status = trim((string)($point['status'] ?? 'unavailable')); $parts = array($status); if (isset($point['latitude'], $point['longitude']) && is_numeric($point['latitude']) && is_numeric($point['longitude'])) { $parts[] = $point['latitude'] . ', ' . $point['longitude']; } $parts[] = 'source: ' . ($source !== '' ? $source : 'not recorded'); if (!empty($point['capturedAtUTC'])) $parts[] = 'captured ' . $point['capturedAtUTC'] . ' UTC'; if (isset($point['sourceRecordID']) && $point['sourceRecordID'] !== null) { $parts[] = 'record #' . $point['sourceRecordID']; } if (!empty($point['reason'])) $parts[] = $point['reason']; $locations[] = array('label' => $label, 'value' => implode('; ', $parts)); } return array( 'reason' => $reason, 'details' => trim((string)($row['Details'] ?? '')), 'isNotice' => $isNotice, 'recipient' => $recipient, 'intended' => $intended, 'noticeResult' => $noticeResult, 'locations' => $locations ); } function PA_WEB_DASH_AUDIT_RENDER_FACTS(array $row) { $facts = PA_WEB_DASH_AUDIT_FACTS($row); $escape = static function ($value) { return htmlspecialchars((string)$value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); }; echo '