37497-vm/update_status.php
Flatlogic Bot 65bff23a0b 1
2026-01-16 09:31:10 +00:00

34 lines
990 B
PHP

<?php
require_once 'db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$requestId = $_POST['request_id'] ?? null;
$action = $_POST['action'] ?? null;
if ($requestId && $action) {
$newStatus = null;
if ($action === 'approve') {
$newStatus = 'System_Reception';
} elseif ($action === 'reject') {
$newStatus = 'Rejected';
}
if ($newStatus) {
try {
$pdo = db();
$stmt = $pdo->prepare('UPDATE ChangeRequests SET status = :status WHERE id = :id AND status = :current_status');
$stmt->execute([
':status' => $newStatus,
':id' => $requestId,
':current_status' => 'Dept_Approval_Pending'
]);
} catch (PDOException $e) {
die("Database error: " . $e->getMessage());
}
}
}
}
header('Location: request_dashboard.php');
exit;