'Unauthorized']); exit; } $person_id = $_GET['person_id'] ?? null; $process_definition_id = $_GET['process_id'] ?? null; $process_code = $_GET['process_code'] ?? null; $pdo = db(); if (!$process_definition_id && $process_code) { $stmt = $pdo->prepare("SELECT id FROM process_definitions WHERE code = ? AND is_latest = 1 LIMIT 1"); $stmt->execute([$process_code]); $process_definition_id = $stmt->fetchColumn(); } if (!$subject_id || !$process_definition_id) { http_response_code(400); echo json_encode(['error' => 'Missing subject_id or process_id']); exit; } $userId = $_SESSION['user_id']; $engine = new WorkflowEngine(); // Fetch Subject and Process Definition details first $subjectName = 'Unknown'; if ($subject_type === 'person') { $stmt_person = $pdo->prepare("SELECT first_name, last_name FROM people WHERE id = ?"); $stmt_person->execute([$subject_id]); $person = $stmt_person->fetch(); if ($person) { $subjectName = $person['first_name'] . ' ' . $person['last_name']; } } elseif ($subject_type === 'meeting') { $stmt_meeting = $pdo->prepare("SELECT m.meeting_datetime, bg.name as group_name FROM meetings m JOIN bni_groups bg ON m.bni_group_id = bg.id WHERE m.id = ?"); $stmt_meeting->execute([$subject_id]); $meeting = $stmt_meeting->fetch(); if ($meeting) { $subjectName = $meeting['group_name'] . ' - ' . date('d.m.Y', strtotime($meeting['meeting_datetime'])); } } $stmt_process = $pdo->prepare("SELECT * FROM process_definitions WHERE id = ?"); $stmt_process->execute([$process_definition_id]); $process = $stmt_process->fetch(); if (!$process) { http_response_code(404); echo "
Could not find process.
"; exit; } // Try to find an existing instance $instance = $engine->getActiveInstanceForSubject($process['code'], $subject_type, $subject_id); ?>No actions available.
Brak zdarzeń.
Outcome: = htmlspecialchars($outcomeLabel) ?>
"= nl2br(htmlspecialchars($data['note'])) ?>"
Next follow-up: = date('d.m.Y, H:i', strtotime($data['next_contact_date'])) ?>
= htmlspecialchars(ucfirst(str_replace('_', ' ', $event['event_type']))) ?> ' . htmlspecialchars($message) . ''; } ?> By = htmlspecialchars($event['first_name'] . ' ' . $event['last_name']) ?> on = date('d.m.Y, H:i', strtotime($event['created_at'])) ?>This process has not been started for this person.
This person is not eligible to start this process.