-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccept_task.php
More file actions
80 lines (80 loc) · 2.62 KB
/
accept_task.php
File metadata and controls
80 lines (80 loc) · 2.62 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
80
<?php
session_start();
require 'db.php.inc';
if (!isset($_SESSION['user']) || $_SESSION['user']['role'] !== 'Team Member') {
header('Location: login.php');
exit();
}
if (!isset($_SESSION['task_confirmations'])) {
$_SESSION['task_confirmations'] = [];
}
try {
$stmt = $pdo->prepare("
SELECT t.task_id, t.task_name, t.description, t.priority, t.status, t.start_date, t.end_date
FROM tasks t
JOIN task_allocations ta ON t.task_id = ta.task_id
WHERE ta.user_id = :user_id AND t.status = 'Pending'
");
$stmt->execute([':user_id' => $_SESSION['user']['user_id']]);
$tasks = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
die("Database error: " . $e->getMessage());
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Accept Task</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php include 'header.php'; ?>
<?php if (isset($_SESSION['message'])): ?>
<div class="<?= strpos($_SESSION['message'], 'successfully') !== false ? 'success' : 'error' ?>">
<?= $_SESSION['message'] ?>
</div>
<?php unset($_SESSION['message']); ?>
<?php endif; ?>
<main>
<h2>Pending Tasks</h2>
<?php include 'sidebar.php'; ?>
<?php if (!empty($tasks)): ?>
<table>
<thead>
<tr>
<th>Task ID</th>
<th>Task Name</th>
<th>Description</th>
<th>Priority</th>
<th>Start Date</th>
<th>End Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($tasks as $task): ?>
<tr>
<td><?= $task['task_id'] ?></td>
<td><?= $task['task_name'] ?></td>
<td><?= $task['description'] ?></td>
<td><?= $task['priority'] ?></td>
<td><?= $task['start_date'] ?></td>
<td><?= $task['end_date'] ?></td>
<td>
<?php if (in_array($task['task_id'], $_SESSION['task_confirmations'])): ?>
<span>Accepted</span>
<?php else: ?>
<a href="task_confirmation.php?task_id=<?= $task['task_id'] ?>" class="btn-primary">Confirm</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<p>No tasks assigned to you yet.</p>
<?php endif; ?>
</main>
<?php include 'footer.php'; ?>
</body>
</html>