-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_details.php
More file actions
135 lines (129 loc) · 4.99 KB
/
task_details.php
File metadata and controls
135 lines (129 loc) · 4.99 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
session_start();
require 'db.php.inc';
if (!isset($_SESSION['user'])) {
header('Location: login.php');
exit();
}
if (!isset($_GET['task_id'])) {
die("Error: Task ID not provided.");
}
$taskId = $_GET['task_id'];
try {
$taskStmt = $pdo->prepare("
SELECT t.task_id, t.task_name, t.description, t.priority, t.status, t.progress, t.start_date, t.end_date, p.title AS project_name
FROM tasks t
JOIN projects p ON t.project_id = p.project_id
WHERE t.task_id = :task_id
");
$taskStmt->execute([':task_id' => $taskId]);
$task = $taskStmt->fetch(PDO::FETCH_ASSOC);
if (!$task) {
die("Error: Task not found.");
}
$teamStmt = $pdo->prepare("
SELECT u.user_id, u.full_name, u.photo_path, ta.role, ta.start_date,
ta.end_date,
ta.contribution_percentage
FROM task_allocations ta
JOIN users u ON ta.user_id = u.user_id
WHERE ta.task_id = :task_id");
$teamStmt->execute([':task_id' => $taskId]);
$teamMembers = $teamStmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
die("Database error: " . $e->getMessage());
}
function checkNum($id) {
$res = $id / 10 ;
$str = null ;
if($res >= 0 && $res < 1) {
$str = "00". $id;
return $str ;
}
else if($res >= 1 && $res <10) {
$str = "0" . $id;
return $str ;
} else{
$str = $id;
return $str ;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Task Details</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php include 'header.php'; ?>
<main class="task-details-container">
<h2>Task Details</h2>
<?php include 'sidebar.php';?>
<div class="task-details">
<div class="left-section">
<fieldset>
<legend>Task Information</legend>
<p><strong>Task ID:</strong> <?= $task['task_id'] ?></p>
<p><strong>Task Name:</strong> <?= $task['task_name'] ?></p>
<p><strong>Description:</strong> <?= $task['description'] ?></p>
<p><strong>Project:</strong> <?= $task['project_name'] ?></p>
<p><strong>Priority:</strong> <?= $task['priority'] ?></p>
<p><strong>Status:</strong>
<span class="<?= strtolower(str_replace(' ', '-', $task['status'])) ?>">
<?= $task['status'] ?>
</span>
</p>
<p><strong>Progress:</strong> <?= $task['progress'] ?>%</p>
<p><strong>Start Date:</strong> <?= $task['start_date'] ?></p>
<p><strong>End Date:</strong> <?= $task['end_date'] ?></p>
</fieldset>
</div>
<div class="right-section">
<fieldset>
<legend>Team Members</legend>
<?php if (!empty($teamMembers)): ?>
<table>
<thead>
<tr>
<th>Photo</th>
<th>Member ID</th>
<th>Name</th>
<th>Start Date</th>
<th>End Date</th>
<th>Effort (%)</th>
</tr>
</thead>
<tbody>
<?php foreach ($teamMembers as $member): ?>
<tr>
<td>
<img src = "images/<?= $member['photo_path'] ?>"
alt="<?= $member['full_name'] ?>"
class="member-photo">
</td>
<td><?= checkNum($member['user_id'])?></td>
<td><?= $member['full_name'] ?></td>
<td><?= $member['start_date'] ?></td>
<td>
<?= $member['contribution_percentage'] <= 50
? '<span class="in-progress">In Progress</span>'
: $member['end_date'] ?>
</td>
<td><?= $member['contribution_percentage'] ?>%</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<p>No team members allocated to this task.</p>
<?php endif; ?>
</fieldset>
</div>
</div>
</main>
<?php include 'footer.php';?>
</body>
</html>