-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_task.php
More file actions
79 lines (73 loc) · 2.95 KB
/
update_task.php
File metadata and controls
79 lines (73 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
session_start();
if (!isset($_SESSION['user']) || $_SESSION['user']['role'] !== 'Team Member') {
header('Location: login.php');
exit();
}
require 'db.php.inc';
if (!isset($_GET['task_id'])) {
die("Error: Task ID not provided.");
}
$taskId = $_GET['task_id'];
try {
$stmt = $pdo->prepare("
SELECT t.task_id, t.task_name, p.title AS project_name, t.progress, t.status, t.start_date, t.end_date
FROM tasks t
JOIN projects p ON t.project_id = p.project_id
WHERE t.task_id = :task_id
");
$stmt->execute([':task_id' => $taskId]);
$task = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$task) {
die("Error: Task not found.");
}
} catch (PDOException $e) {
die("Database error: " . $e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Update Task</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php include 'header.php'; ?>
<main>
<h2>Update Task Progress</h2>
<?php if (isset($_GET['error'])): ?>
<div class="error"><?= $_GET['error'] ?></div>
<?php endif; ?>
<?php if (isset($_GET['message'])): ?>
<div class="success"><?= $_GET['message'] ?></div>
<?php endif; ?>
<?php include 'sidebar.php'?>
<form method="POST" action="update_task_process.php">
<fieldset>
<legend>Task Details</legend>
<p><strong>Task ID:</strong> <?= $task['task_id'] ?></p>
<p><strong>Task Name:</strong> <?= $task['task_name'] ?></p>
<p><strong>Project:</strong> <?= $task['project_name'] ?></p>
<p><strong>Start Date:</strong> <?= $task['start_date'] ?></p>
<p><strong>End Date:</strong> <?= $task['end_date'] ?></p>
</fieldset>
<fieldset>
<legend>Update Progress and Status</legend>
<label for="progress">Progress (%)</label>
<input type="range" id="progress" name="progress" min="0" max="100" step="1" value="<?= $task['progress'] ?>"
oninput="document.getElementById('progressValue').innerText = this.value + '%'">
<span id="progressValue"><?= $task['progress'] ?>%</span>
<label for="status">Status</label>
<select id="status" name="status">
<option value="Pending" <?= $task['status'] === 'Pending' ? 'selected' : '' ?>>Pending</option>
<option value="In Progress" <?= $task['status'] === 'In Progress' ? 'selected' : '' ?>>In Progress</option>
<option value="Completed" <?= $task['status'] === 'Completed' ? 'selected' : '' ?>>Completed</option>
</select>
<button type="submit">Save Changes</button>
</fieldset>
<input type="hidden" name="task_id" value="<?= $task['task_id'] ?>">
</form>
</main>
<?php include 'footer.php'; ?>
</body>
</html>