-
Notifications
You must be signed in to change notification settings - Fork 1
/
project.php
122 lines (113 loc) · 5.36 KB
/
project.php
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
<?php
require_once 'src/Services/DatabaseService.php';
require_once 'src/Entities/ProjectEntity.php';
require_once 'src/Services/ProjectDisplayServices.php';
require_once 'src/Models/ProjectsModel.php';
require_once 'src/Services/ClientDisplayService.php';
require_once 'src/Models/ClientsModel.php';
require_once 'src/Services/DateService.php';
require_once 'src/Models/TasksModel.php';
require_once 'src/Models/UsersModel.php';
require_once 'src/Services/EstimateService.php';
$db = DatabaseService::connect();
$pageLocale = $_GET['location'] ?? 'uk';
$projectsModel = new ProjectsModel($db);
$tasksModel = new TasksModel($db);
$clientsModel = new ClientsModel($db);
$usersModel = new UsersModel($db);
$idLink = $_GET['project'] ?? 1;
$project = $projectsModel->getProjectById($idLink);
$projectTitle = ProjectDisplayService::displayProject($project);
$projectDeadline = DateService::reformatDateUK($project->deadline);
if ($pageLocale === 'us') {
$projectDeadline = DateService::reformatDateUS($project->deadline);
}
$client = $clientsModel->getClientById($project->client_id);
$clientTitle = ClientDisplayService::displayClient($client);
$displayUserNameByProjectId = $usersModel->getUsersByProjectId($idLink);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Project Manager - Project Name</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="h-full">
<header class="p-3 bg-teal-50 flex justify-between">
<h1 class="sm:text-5xl text-4xl"><a href="index.php">Project Manager</a></h1>
<div class="pr-3 flex">
<?= "<a href='project.php?project=$idLink&location=uk' class='p-3 " .
($pageLocale == 'uk' ? "bg-slate-300" : "") .
" rounded-l-lg border-y border-l'>🇬🇧</a>";
echo "<a href='project.php?project=$idLink&location=us' class='p-3 " .
($pageLocale == 'uk' ? "" : "bg-slate-300") .
" rounded-r-lg border-y border-r'>🇺🇸</a>";
?>
</div>
</header>
<main class="p-3">
<div class="flex justify-between mb-3">
<h2 class="text-4xl font-bold mb-2"><?= $projectTitle.$projectDeadline ?>
<a href="index.php" class="text-base text-blue-600 hover:underline ms-3">Return to all projects</a>
</h2>
<div class="flex items-center gap-3">
<h3 class="text-3xl font-bold"><?= $clientTitle ?></h3>
<img class="w-[50px]" src=<?= $client->logo ?> alt="client logo" />
</div>
</div>
<section class="flex gap-5 flex-nowrap h-[70vh] pb-5 overflow-x-auto">
<?php
foreach($displayUserNameByProjectId as $taskAndUser){
$displayUserName = $taskAndUser['username'];
$displayUserAvatar = $taskAndUser['avatar'];
$userID = $taskAndUser['userID'];
echo "<div class=\"shrink-0 w-full sm:w-1/2 lg:w-1/4 h-100\">
<div class=\"overflow-y-auto border rounded p-3 pb-0 h-full\">
<h4 class=\"border-b pb-2 mb-3 text-2xl font-bold\">
<a href=\"\">$displayUserName</a>
<img
src=$displayUserAvatar alt=\"Project Avatar\"
class=\"float-right\">
</h4>
";
$displayTasksByUser = $tasksModel->getTasksByUserAndProject($idLink, $userID);
foreach ($displayTasksByUser as $task) {
$deadlineDate = $task['task_deadline'];
$overDeadline = DateService::checkDeadlineOverdue($deadlineDate);
$displayTaskName = $task['task_name'];
$displayTaskEstimate = $task['estimate'];
$displayTaskEstimate = ($pageLocale === 'us') ? EstimateService::convertEstimate($displayTaskEstimate) : $displayTaskEstimate;
$taskID = $task['taskID'];
$linkTask = "task.php?task={$taskID}&location={$pageLocale}";
if($overDeadline) {
echo "<div class=\"w-full\">
<a class=\"block border rounded border-red-600 hover:underline mb-3 p-3 bg-red-200 border-red-600 text-2xl\" href=\"$linkTask\">
<h3 class=\"mb-0 text-red-800 font-bold\">$displayTaskName
<span class=\"bg-teal-400 px-2 rounded text-white font-bold float-right\">$displayTaskEstimate</span>
</h3>
</a>
</div>";
} else {
echo "<div class=\"w-full\">
<a class=\"block border rounded border-slate-600 hover:underline mb-3 p-3 bg-slate-300 text-2xl\" href=\"$linkTask\">
<h3 class=\"mb-0 font-bold\">$displayTaskName
<span class=\"bg-teal-400 px-2 rounded text-white font-bold float-right\">$displayTaskEstimate</span>
</h3>
</a>
</div>";
}
}
echo "
</div>
</div>
";
}
?>
</section>
</main>
<footer class="border-t border-slate-300 mt-3 mx-3 p-3 pt-5">
<p>© Copyright iO Academy 2024</p>
</footer>
</body>
</html>