'danger', 'message' => 'Błąd: Brak wymaganych parametrów.']; header('Location: process_dashboard.php'); exit; } $instanceId = (int)$_POST['instanceId']; $transitionId = $_POST['transitionId']; $userId = $_SESSION['user_id'] ?? null; $payload = $_POST['payload'] ?? null; if (!$userId) { $_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Błąd: Sesja wygasła.']; header('Location: login.php'); exit; } try { $engine = new WorkflowEngine(); $success = $engine->applyTransition($instanceId, $transitionId, $payload, $userId); if ($success) { $_SESSION['flash_message'] = ['type' => 'success', 'message' => 'Akcja została wykonana pomyślnie.']; } else { $_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Błąd: Nie udało się wykonać akcji.']; } } catch (Exception $e) { error_log("Error applying transition: " . $e->getMessage()); $_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Wystąpił krytyczny błąd: ' . $e->getMessage()]; } header('Location: process_dashboard.php'); exit;