'error','message'=>'Sign in to view tracker location.']);exit; } try { $viewer=PART_CaseInformationAdmin($PAAPP_CONFIG_DB_LINK,(string)($MySession['SESSION']['PHPSESSID'] ?? '')); if ($viewer!==(int)$Response['SESSION']['AdminID']) throw new DomainException('Access denied'); } catch (Throwable $e) { http_response_code(403);echo json_encode(['status'=>'error','message'=>'Sign in to view tracker location.']);exit; } $dashID=filter_var($_GET['did'] ?? null,FILTER_VALIDATE_INT); if (!$dashID || $dashID<1) {http_response_code(400);echo json_encode(['status'=>'error','message'=>'A valid DashID is required.']);exit;} try { if (($_GET['view'] ?? '')==='map') { require_once __DIR__.'/PA_WEB_DASH_LOCATION_MAP_DATA.php'; $days=filter_var($_GET['days'] ?? 3,FILTER_VALIDATE_INT); if (!in_array($days,[1,3,7],true)) {http_response_code(400);echo json_encode(['status'=>'error','message'=>'Invalid history period.']);exit;} $data=PA_WEB_DASH_MAP_LOAD($PAAPP_CONFIG_DB_LINK,$dashID,$PASYSCONF,$days); } else $data=PA_WEB_DASH_LOCATION_LOAD($PAAPP_CONFIG_DB_LINK,$dashID,$PASYSCONF); echo json_encode(['status'=>'success','data'=>$data],JSON_THROW_ON_ERROR|JSON_INVALID_UTF8_SUBSTITUTE); } catch (DomainException $e) { http_response_code(404);echo json_encode(['status'=>'error','message'=>'Case not found.']); } catch (Throwable $e) { error_log('Tracker location unavailable for case '.$dashID); http_response_code(503);echo json_encode(['status'=>'error','message'=>'Tracker location is temporarily unavailable.']); }