mvp.3
This commit is contained in:
parent
4df1537bcb
commit
44f71c32c4
90
edit_process.php
Normal file
90
edit_process.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?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>© <?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>
|
||||
@ -87,6 +87,13 @@ $project_image_url = htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '');
|
||||
<h5 class="mb-1 fw-bold"><?php echo htmlspecialchars($process['name']); ?></h5>
|
||||
<small class="text-muted"><?php echo date("M d, Y", strtotime($process['created_at'])); ?></small>
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<form action="edit_process.php" method="GET" class="me-2">
|
||||
<input type="hidden" name="id" value="<?php echo $process['id']; ?>">
|
||||
<button type="submit" class="btn btn-sm btn-outline-primary" title="Edit Process">
|
||||
<i data-feather="edit" style="width: 16px; height: 16px;"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form action="delete_process.php" method="POST" onsubmit="return confirm('Are you sure you want to delete this process?');">
|
||||
<input type="hidden" name="id" value="<?php echo $process['id']; ?>">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" title="Delete Process">
|
||||
@ -94,6 +101,7 @@ $project_image_url = htmlspecialchars($_SERVER['PROJECT_IMAGE_URL'] ?? '');
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mb-1 text-muted"><?php echo htmlspecialchars($process['description']); ?></p>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
33
update_process.php
Normal file
33
update_process.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$id = $_POST['id'] ?? null;
|
||||
$name = $_POST['name'] ?? null;
|
||||
$description = $_POST['description'] ?? null;
|
||||
|
||||
if ($id && $name && $description) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("UPDATE processes SET name = :name, description = :description WHERE id = :id");
|
||||
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
|
||||
$stmt->bindParam(':description', $description, PDO::PARAM_STR);
|
||||
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
header('Location: index.php?status=success&message=Process updated successfully!');
|
||||
exit();
|
||||
} else {
|
||||
header('Location: edit_process.php?id=' . $id . '&status=error&message=Failed to update process.');
|
||||
exit();
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
error_log("DB Error: " . $e->getMessage());
|
||||
header('Location: edit_process.php?id=' . $id . '&status=error&message=Database error: ' . urlencode($e->getMessage()));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
header('Location: index.php?status=error&message=Invalid request method.');
|
||||
exit();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user