37338-vm/_add_process_event.php
2026-01-10 07:48:27 +00:00

32 lines
908 B
PHP

<?php
require_once 'db/config.php';
session_start();
if (!isset($_SESSION['user_id'])) {
http_response_code(401);
die('Unauthorized');
}
$pdo = db();
$instanceId = $_POST['instanceId'] ?? null;
$eventType = $_POST['eventType'] ?? null;
$description = $_POST['description'] ?? null;
$userId = $_SESSION['user_id'];
if (!$instanceId || !$eventType) {
http_response_code(400);
die('Missing parameters');
}
// Create the event
$stmt = $pdo->prepare("INSERT INTO process_events (processInstanceId, eventType, description, createdBy) VALUES (?, ?, ?, ?)");
$stmt->execute([$instanceId, $eventType, $description, $userId]);
// Update the last activity time for the instance
$stmt_update = $pdo->prepare("UPDATE process_instances SET lastActivityAt = NOW() WHERE id = ?");
$stmt_update->execute([$instanceId]);
// Redirect back to the dashboard
header("Location: process_dashboard.php");
exit;