false, 'ERROR' => 'no_business_selected']); } $data = readJsonBody(); $servicePointID = (int) ($data['ServicePointID'] ?? 0); if ($servicePointID <= 0) { apiAbort(['OK' => false, 'ERROR' => 'missing_ServicePointID']); } $qFind = queryOne(" SELECT ID, BeaconID FROM ServicePoints WHERE ID = ? AND BusinessID = ? AND BeaconID IS NOT NULL LIMIT 1 ", [$servicePointID, $businessId]); if (!$qFind) { apiAbort([ 'OK' => false, 'ERROR' => 'not_found', 'ServicePointID' => $servicePointID, 'BusinessID' => (string) $businessId, ]); } $removedBeaconID = (int) $qFind['BeaconID']; queryTimed("UPDATE ServicePoints SET BeaconID = NULL, AssignedByUserID = NULL WHERE ID = ? AND BusinessID = ?", [$servicePointID, $businessId]); jsonResponse([ 'OK' => true, 'ERROR' => '', 'ACTION' => 'unassigned', 'ServicePointID' => $servicePointID, 'BeaconID' => $removedBeaconID, 'BusinessID' => (string) $businessId, ]);