31 lines
900 B
PHP
31 lines
900 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;
|
|
$status = $_POST['status'] ?? null;
|
|
$userId = $_SESSION['user_id'];
|
|
|
|
if (!$instanceId || !$status) {
|
|
http_response_code(400);
|
|
die('Missing parameters');
|
|
}
|
|
|
|
// Update instance status and last activity time
|
|
$stmt = $pdo->prepare("UPDATE process_instances SET status = ?, lastActivityAt = NOW() WHERE id = ?");
|
|
$stmt->execute([$status, $instanceId]);
|
|
|
|
// Create a status change event
|
|
$stmt_event = $pdo->prepare("INSERT INTO process_events (processInstanceId, eventType, description, createdBy) VALUES (?, 'status_change', ?, ?)");
|
|
$stmt_event->execute([$instanceId, "Status changed to $status", $userId]);
|
|
|
|
// Redirect back to the dashboard
|
|
header("Location: process_dashboard.php");
|
|
exit;
|