32 lines
836 B
PHP
32 lines
836 B
PHP
<?php
|
|
session_start();
|
|
require_once 'WorkflowEngine.php';
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
$_SESSION['error_message'] = "Authentication required.";
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
$userId = $_SESSION['user_id'];
|
|
|
|
$personId = $_GET['personId'] ?? null;
|
|
$processDefinitionId = $_GET['processId'] ?? null;
|
|
|
|
if (!$personId || !$processDefinitionId) {
|
|
$_SESSION['error_message'] = "Missing parameters for process initialization.";
|
|
header('Location: index.php');
|
|
exit();
|
|
}
|
|
|
|
$engine = new WorkflowEngine();
|
|
$instance = $engine->getOrCreateInstanceByDefId($personId, $processDefinitionId, $userId);
|
|
|
|
if ($instance) {
|
|
$_SESSION['success_message'] = "Process initialized successfully.";
|
|
} else {
|
|
$_SESSION['error_message'] = "Failed to initialize process.";
|
|
}
|
|
|
|
header('Location: index.php');
|
|
exit();
|