setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $fetchAll = function ($sql, $params = array()) use ($db) { $q = $db->prepare($sql); $q->execute($params); return $q->fetchAll(PDO::FETCH_ASSOC); }; $fetchOne = function ($sql, $params = array()) use ($db) { $q = $db->prepare($sql); $q->execute($params); return $q->fetch(PDO::FETCH_ASSOC) ?: null; }; try { $db->beginTransaction(); $databaseNowUTC = $db->query('SELECT UTC_TIMESTAMP()')->fetchColumn(); if ($isJsonDownload && $requestedAtUTC > $databaseNowUTC) { $db->rollBack(); http_response_code(400); exit('The report snapshot time is in the future'); } $snapshotAtUTC = $isJsonDownload ? $requestedAtUTC : $databaseNowUTC; $case = $fetchOne('SELECT d.*,cd.DeviceID,cl.FirstName AS ClientFirstName,cl.LastName AS ClientLastName FROM PART_Dash d ' . 'LEFT JOIN ClientDevices cd ON cd.ClientDevicesID=d.ClientDevicesID AND cd.ClientID=d.ClientID ' . 'LEFT JOIN ClientAccounts cl ON cl.ClientID=d.ClientID ' . 'WHERE d.DashID=?', array($dashID)); if (!$case) { $db->rollBack(); http_response_code(404); exit('Case not found'); } $events = $fetchAll('SELECT * FROM PART_Dash_Audit WHERE DashID=? AND Insert_DateTime<=? ' . 'ORDER BY Insert_DateTime ASC,DashAuditID ASC', array($dashID, $snapshotAtUTC)); $steps = $fetchAll('SELECT s.*,COALESCE(NULLIF(c.Title,\'\'),t.Title) AS CurrentTitle ' . 'FROM PART_DashSteps s ' . 'LEFT JOIN PART_DashStepTemplates t ON t.DashStepTemplateID=s.DashStepTemplateID ' . 'LEFT JOIN PART_DashStepTagCache c ON c.DashStepID=s.DashStepID AND c.RecordStatus=0 ' . 'WHERE s.DashID=? ORDER BY s.DashStepID', array($dashID)); $responses = $fetchAll('SELECT r.*,q.QuestionKey,q.QuestionText,a.AnswerKey,a.AnswerText ' . 'FROM PART_DashStepResponses r ' . 'JOIN PART_DashSteps s ON s.DashStepID=r.DashStepID AND s.DashID=? ' . 'LEFT JOIN PART_DashStepQuestions q ON q.DashStepQuestionID=r.DashStepQuestionID ' . 'LEFT JOIN PART_DashStepAnswers a ON a.DashStepAnswerID=r.DashStepAnswerID ' . 'ORDER BY r.Insert_DateTime,r.DashStepResponseID', array($dashID)); $emailAttempts = $fetchAll('SELECT * FROM PART_DashEmailSent WHERE DashID=? ORDER BY AttemptDateTime,DashEmailSentID', array($dashID)); $smsAttempts = $fetchAll('SELECT * FROM PART_DashSMSSent WHERE DashID=? ORDER BY AttemptDateTime,DashSMSSentID', array($dashID)); $deviceEvent = null; if ((int)$case['ClientDevicesEventID'] > 0) { $deviceEvent = $fetchOne('SELECT * FROM ClientDeviceEvent WHERE ClientDevicesEventID=? AND ClientID=? AND DeviceID=?', array($case['ClientDevicesEventID'], $case['ClientID'], $case['DeviceID'])); } require_once '/opt/SA/DEV/SERVICE/LIB/PACOMMONLIBRARY/php/functions/PACommonPosHistory.php'; $posSource=$case['DeviceID'] ? PACommonPosHistorySource($case['DeviceID'],['receiptFrom'=>$case['Insert_DateTime'],'receiptTo'=>$snapshotAtUTC]) : '`Pos`'; $positions = $case['DeviceID'] ? $fetchAll('SELECT * FROM '.$posSource.' WHERE DeviceID=? ' . 'AND InsertDateTime>=? AND InsertDateTime<=? ORDER BY InsertDateTime,PosID', array($case['DeviceID'], $case['Insert_DateTime'], $snapshotAtUTC)) : array(); $db->commit(); } catch (Throwable $e) { if ($db->inTransaction()) $db->rollBack(); http_response_code(500); exit('The audit export could not be prepared. Please try again.'); } $snapshot = array( 'schemaVersion' => 1, 'reportType' => 'PART case operational audit snapshot', 'exportedAtUTC' => $snapshotAtUTC, 'exportingAdminID' => (int)$Response['SESSION']['AdminID'], 'timestampBasis' => 'Database/server timezone UTC. Pos.TS is raw device epoch milliseconds; its UTC display is derived.', 'case' => $case, 'linkedClientDeviceEvent' => $deviceEvent, 'auditEvents' => $events, 'dashSteps' => $steps, 'stepResponses' => $responses, 'emailAttempts' => $emailAttempts, 'smsAttempts' => $smsAttempts, 'trackerPositions' => $positions, ); $json = json_encode($snapshot, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT); if ($json === false) { http_response_code(500); exit('The audit export could not be encoded.'); } $digest = hash('sha256', $json); if ($isJsonDownload) { if (!hash_equals($expectedDigest, $digest)) { http_response_code(409); exit('The case records changed. Reload the report and download its new snapshot.'); } if (ob_get_level()) ob_clean(); header('Content-Type: application/json; charset=UTF-8'); header('Content-Disposition: attachment; filename="' . preg_replace('/[^A-Za-z0-9._-]/', '_', $case['CaseName']) . '-audit-source.json"'); header('Cache-Control: private, no-store, max-age=0'); header('Pragma: no-cache'); header('X-Content-Type-Options: nosniff'); echo $json; exit; } $escape = function ($value) { return htmlspecialchars((string)$value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); }; $stepByID = array(); foreach ($steps as $step) $stepByID[(int)$step['DashStepID']] = $step; $triggersByKey = array(); foreach ($events as $event) { $value = json_decode((string)$event['NewValue'], true); $key = is_array($value) ? trim((string)($value['event_key'] ?? '')) : ''; if ($key !== '' && !isset($triggersByKey[$key]) && in_array($event['Action'], array('TIMER_ACTION_CREATED', 'TIMER_INFO_CREATED', 'TIMER_REMINDER_RECORDED', 'NO_PI_RESPONSE_INFO_CREATED', 'PI_INVITE_RESEND_CLAIMED'), true) && trim((string)$event['Details']) !== '') $triggersByKey[$key] = $event; } $triggerFor = function ($event) use ($triggersByKey) { $value = json_decode((string)$event['NewValue'], true); if (!is_array($value)) return null; $context = $value['context'] ?? null; $key = trim((string)(is_array($context) ? ($context['timer_event'] ?? '') : ($value['timer_event'] ?? ''))); $trigger = $key !== '' ? ($triggersByKey[$key] ?? null) : null; return $trigger && (int)$trigger['DashAuditID'] < (int)$event['DashAuditID'] ? $trigger : null; }; $stepTitle = function ($id) use ($stepByID) { return trim((string)($stepByID[(int)$id]['CurrentTitle'] ?? '')); }; $actionLabel = function ($action) { return ucwords(strtolower(str_replace('_', ' ', (string)$action))); }; $recordedAnswer = function ($response) { foreach (array('AnswerText', 'ResponseText', 'AnswerKey') as $field) { if (isset($response[$field]) && (string)$response[$field] !== '') return $response[$field]; } return '(empty)'; }; $readableQuestion = function ($question) use ($case) { return strtr((string)$question, array( '{{TRACKERUSERFIRST}}' => trim((string)$case['ClientFirstName']) ?: '[client first name]', '{{TRACKERUSERLAST}}' => trim((string)$case['ClientLastName']) ?: '[client last name]', )); }; $sentTime = function ($value) { return !$value || $value === '0000-00-00 00:00:00' ? 'Not recorded' : $value; }; $policeResponses = array_filter($responses, function ($response) { return stripos((string)($response['QuestionText'] ?? ''), 'police') !== false; }); $attempts = array(); foreach ($emailAttempts as $row) $attempts[] = array('channel' => 'Email', 'row' => $row); foreach ($smsAttempts as $row) $attempts[] = array('channel' => 'SMS', 'row' => $row); usort($attempts, function ($a, $b) { $timeOrder = strcmp((string)$a['row']['AttemptDateTime'], (string)$b['row']['AttemptDateTime']); if ($timeOrder !== 0) return $timeOrder; return strcmp($a['channel'], $b['channel']); }); $firstEvent = $events ? $events[0]['Insert_DateTime'] : ''; $lastEvent = $events ? $events[count($events)-1]['Insert_DateTime'] : ''; $nonce = base64_encode(random_bytes(16)); if (ob_get_level()) ob_clean(); header('Content-Type: text/html; charset=UTF-8'); header('Cache-Control: private, no-store, max-age=0'); header('Pragma: no-cache'); header('X-Content-Type-Options: nosniff'); header("Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; script-src 'nonce-" . $nonce . "'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'"); ?> <?php echo $escape($case['CaseName']); ?> - Complete case audit
Download source JSON
Pink Angels Rescue Team / Operational case record

Complete case audit

· Chronological, oldest to newest

Case ID
Case status
Alert source
Alert recorded (UTC)
Linked tracker event ID
Tracker device ID
Snapshot created (UTC)
Exporting Admin ID
Audit events ( to UTC)
Tracker reports in window
How to read this report. Each timeline entry is one stored PART_Dash_Audit row with its event ID and raw action. Step headings are current labels and may differ from the wording at the event time. "Provider accepted" does not establish delivery or receipt. Police-related answers are system entries, not an independent police report. Tracker coordinates are device reports, not proof of a person's location. This export is not a certification of authenticity or a chain-of-custody record.

Timestamps from the database are shown as UTC (database and server timezone checked at implementation). Tracker TS values are retained as raw epoch milliseconds; the displayed UTC conversion is derived. Question name tags use the current client name for readability; original templates remain in the JSON. Preserve the downloaded JSON and its SHA-256 digest with the report, and document each subsequent transfer under your evidence-handling procedure.

Case timeline

No PART_Dash_Audit rows were found for this case at snapshot time.

    0) $actor .= ' #' . (int)$event['PerformedBy']; ?>
  1. UTC

    []
    · Audit Event # · DashStep # · RecordStatus
    Recorded on info step #:
    Originating step #:
    Reason:
    Recipient:
    Intended destination:
    Notice result:
    :

    Recorded detail:

    Before (raw)
    After (raw)

Recorded police-related answers

No response to a question containing "police" was found in this case's step-response records. This does not establish whether police were contacted outside the system.

Step #, response #:
Recorded answer: ( UTC)

All recorded step answers

Response / stepQuestionRecorded answerStored time (UTC)
# / #

Notification attempt records

These are stored attempt/status rows. Audit entries may contain additional destination and provider details. A sent/accepted status is not independent delivery confirmation.

Source ID / channelStepRecipientStatusAttempted (UTC)Sent field (UTC)
#

Linked tracker alert record

ClientDeviceEvent # was recorded at UTC. Method ; event type ; EventCompleted ; coordinates , . Its complete source row is in the JSON snapshot.

No matching linked ClientDeviceEvent row was found. No event was inferred by time or location.

Tracker position history

Pos rows for the linked device received from the case's Insert_DateTime through this snapshot. This is a device-report history, not a police tracking record or independent validation of a person's location. TS is the raw device epoch-millisecond value; received time is Pos.InsertDateTime.

Pos IDDevice TS / derived UTCReceived (UTC)MethodLAT / LONACC

/

Source and integrity notes

Sources: PART_Dash, PART_Dash_Audit, PART_DashSteps, PART_DashStepTagCache, PART_DashStepResponses, PART_DashStepQuestions, PART_DashStepAnswers, PART_DashEmailSent, PART_DashSMSSent, ClientDeviceEvent, and Pos. Only the linked device event was included; position rows were selected by linked DeviceID and the stated receipt-time window. No external police database or official report was queried.

The download button saves the exact JSON snapshot embedded in this report. SHA-256 of those UTF-8 JSON bytes:

This digest detects later changes to that JSON file; it does not authenticate the source database, prove delivery, or establish custody. Preserve who exported, received, stored, or transferred the files and when, according to the receiving agency's procedure. A legal or forensic reviewer should validate the records and time interpretation before relying on them.

Evidence-handling references (guidance, not case evidence): NIST IR 8387, Digital Evidence Preservation and NIJ, Digital Evidence in the Courtroom. Any police dispatch history, incident report, call recording, or provider delivery record must be obtained independently and linked by its own source ID and custodian; none is included here.