prepare("SELECT id FROM process_instances WHERE process_definition_id = ? AND person_id IN ($placeholders)"); $params = array_merge([$process_id], $person_ids); $stmt->execute($params); $instance_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); if (empty($instance_ids)) { $_SESSION['flash_message'] = "No instances found for the selected people and process."; header('Location: ' . $_SERVER['HTTP_REFERER']); exit; } $notes = []; foreach ($instance_ids as $instance_id) { $notes[] = [ 'instance_id' => $instance_id, 'message' => $message, 'user_id' => $userId ]; } $workflowEngine = new WorkflowEngine(); $results = $workflowEngine->bulkAddNotes($notes); $_SESSION['flash_message'] = "Bulk note addition completed."; $_SESSION['bulk_results'] = $results; header('Location: ' . $_SERVER['HTTP_REFERER']); exit;