37237-vm/edit_process.php
Flatlogic Bot 44f71c32c4 mvp.3
2026-01-02 11:10:39 +00:00

90 lines
3.8 KiB
PHP

<?php
require_once 'db/config.php';
$process = null;
$error = '';
if (isset($_GET['id'])) {
$id = $_GET['id'];
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT id, name, description FROM processes WHERE id = :id");
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
$process = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$process) {
$error = "Process not found.";
}
} catch (PDOException $e) {
error_log("DB Error: " . $e->getMessage());
$error = "Could not retrieve process details.";
}
} else {
$error = "No process ID provided.";
}
$project_name = htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'ProcessFlow Optimizer');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Process - <?php echo $project_name; ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<script src="https://unpkg.com/feather-icons"></script>
</head>
<body class="bg-light">
<header class="header">
<div class="container">
<h1 class="h3 mb-0"><?php echo $project_name; ?></h1>
<p class="text-muted mb-0">A business process analyzer and automated optimizer</p>
</div>
</header>
<main class="container py-5">
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="card shadow-sm">
<div class="card-body p-4">
<?php if ($error): ?>
<div class="alert alert-danger" role="alert">
<?php echo $error; ?>
</div>
<a href="index.php" class="btn btn-primary">Go Back</a>
<?php elseif ($process): ?>
<h2 class="h4 card-title fw-bold">Edit Process: <?php echo htmlspecialchars($process['name']); ?></h2>
<p class="card-subtitle mb-4 text-muted">Modify the details of your process.</p>
<form action="update_process.php" method="POST">
<input type="hidden" name="id" value="<?php echo $process['id']; ?>">
<div class="mb-3">
<label for="name" class="form-label">Process Name</label>
<input type="text" class="form-control" id="name" name="name" value="<?php echo htmlspecialchars($process['name']); ?>" required>
</div>
<div class="mb-3">
<label for="description" class="form-label">Description</label>
<textarea class="form-control" id="description" name="description" rows="4" required><?php echo htmlspecialchars($process['description']); ?></textarea>
</div>
<button type="submit" class="btn btn-primary">Update Process</button>
<a href="index.php" class="btn btn-link">Cancel</a>
</form>
<?php endif; ?>
</div>
</div>
</div>
</div>
</main>
<footer class="text-center py-4 text-muted">
<p>&copy; <?php echo date("Y"); ?> <?php echo $project_name; ?>. All rights reserved.</p>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
feather.replace()
</script>
</body>
</html>