false, "message" => ""]; try { if ($_SERVER["REQUEST_METHOD"] !== "POST") { throw new Exception("Invalid request."); } $id = intval($_POST['id']); $status = ($_POST['status'] === "active") ? "active" : "inactive"; $db = DBHandlerSelect::getInstance(); $pdo = $db->getConnection(); $stmt = $pdo->prepare("UPDATE excel_templates SET status = ?, updated_at = NOW() WHERE id = ?"); $stmt->execute([$status, $id]); if ($stmt->rowCount() > 0) { $response["success"] = true; } else { throw new Exception("Update failed."); } } catch (Exception $e) { $response["message"] = $e->getMessage(); } echo json_encode($response);