-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhome.php
More file actions
263 lines (244 loc) · 10.6 KB
/
home.php
File metadata and controls
263 lines (244 loc) · 10.6 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<?php
// Check if a session is already started
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
$twhere = "";
if($_SESSION['login_type'] != 1)
$twhere = " ";
?>
<!-- Info boxes -->
<div class="col-12">
<div class="card">
<div class="card-body">
Welcome <?php echo $_SESSION['login_name']; ?>!
</div>
</div>
</div>
<hr>
<?php
$where = "";
if($_SESSION['login_type'] == 2){
$where = " where manager_id = '{$_SESSION['login_id']}' ";
}elseif($_SESSION['login_type'] == 3){
$where = " where concat('[',REPLACE(user_ids,',','],['),']') LIKE '%[{$_SESSION['login_id']}]%' ";
}
$where2 = "";
if($_SESSION['login_type'] == 2){
$where2 = " where p.manager_id = '{$_SESSION['login_id']}' ";
}elseif($_SESSION['login_type'] == 3){
$where2 = " where concat('[',REPLACE(p.user_ids,',','],['),']') LIKE '%[{$_SESSION['login_id']}]%' ";
}
?>
<!-- User Cards Section (Before Project Progress) -->
<div class="container-fluid">
<div class="row">
<?php
$user_query = $conn->query("SELECT * FROM users");
if ($user_query) {
while($user = $user_query->fetch_assoc()):
$full_name = htmlspecialchars($user['firstname'] . ' ' . $user['lastname']);
$avatar = htmlspecialchars($user['avatar']);
// Replaced assigned_to with project_id
$tasks_assigned_query = $conn->query("SELECT * FROM task_list WHERE project_id = {$user['id']}");
$tasks_assigned = $tasks_assigned_query ? $tasks_assigned_query->num_rows : 0;
?>
<!-- Card with Matte Glass Effect and Clickable -->
<div class="col-sm-12 col-md-6 col-lg-4 mb-3"> <!-- Adjusted for responsive grid -->
<a href="index.php?page=view_project&id=<?php echo $user['id']; ?>" class="card-link">
<div class="card user-card">
<div class="avatar">
<img src="<?php echo $avatar ? 'assets/uploads/' . $avatar : 'assets/uploads/default.png'; ?>" alt="<?php echo $full_name; ?>">
</div>
<div class="details">
<h3><?php echo $full_name; ?></h3>
<p><strong>Tasks Assigned:</strong> <?php echo $tasks_assigned; ?></p>
</div>
</div>
</a>
</div>
<?php endwhile; ?>
<?php
} else {
echo "<p>No users found.</p>";
}
?>
</div>
</div>
<!-- Project Progress Section -->
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card card-outline card-success">
<div class="card-header">
<b>Project Progress</b>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table m-0 table-hover">
<colgroup>
<col width="5%">
<col width="30%">
<col width="35%">
<col width="15%">
<col width="15%">
</colgroup>
<thead>
<tr>
<th>#</th>
<th>Project</th>
<th>Progress</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$stat = array("Pending","Started","On-Progress","On-Hold","Over Due","Done");
$qry = $conn->query("SELECT * FROM project_list $where order by name asc");
if ($qry) {
while($row = $qry->fetch_assoc()):
$prog = 0;
$tprog_query = $conn->query("SELECT * FROM task_list where project_id = {$row['id']}");
$tprog = $tprog_query ? $tprog_query->num_rows : 0;
$cprog_query = $conn->query("SELECT * FROM task_list where project_id = {$row['id']} and status = 3");
$cprog = $cprog_query ? $cprog_query->num_rows : 0;
$prog = $tprog > 0 ? ($cprog / $tprog) * 100 : 0;
$prog = $prog > 0 ? number_format($prog, 2) : $prog;
?>
<tr>
<td><?php echo $i++; ?></td>
<td>
<a><?php echo ucwords($row['name']); ?></a>
<br>
<small>Due: <?php echo date("Y-m-d", strtotime($row['end_date'])); ?></small>
</td>
<td class="project_progress">
<div class="progress progress-sm">
<div class="progress-bar bg-green" role="progressbar" aria-valuenow="<?php echo $prog; ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $prog; ?>%">
</div>
</div>
<small><?php echo $prog; ?>% Complete</small>
</td>
<td class="project-state">
<?php
if($stat[$row['status']] == 'Pending'){
echo "<span class='badge badge-secondary'>{$stat[$row['status']]}</span>";
}elseif($stat[$row['status']] == 'Started'){
echo "<span class='badge badge-primary'>{$stat[$row['status']]}</span>";
}elseif($stat[$row['status']] == 'On-Progress'){
echo "<span class='badge badge-info'>{$stat[$row['status']]}</span>";
}elseif($stat[$row['status']] == 'On-Hold'){
echo "<span class='badge badge-warning'>{$stat[$row['status']]}</span>";
}elseif($stat[$row['status']] == 'Over Due'){
echo "<span class='badge badge-danger'>{$stat[$row['status']]}</span>";
}elseif($stat[$row['status']] == 'Done'){
echo "<span class='badge badge-success'>{$stat[$row['status']]}</span>";
}
?>
</td>
<td>
<a class="btn btn-primary btn-sm" href="./index.php?page=view_project&id=<?php echo $row['id']; ?>">
<i class="fas fa-folder"></i> View
</a>
</td>
</tr>
<?php endwhile; ?>
<?php
} else {
echo "<tr><td colspan='5'>No projects found.</td></tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Small Boxes -->
<div class="col-12 col-sm-6 col-md-4">
<div class="small-box bg-light shadow-sm border">
<div class="inner">
<h3><?php echo $conn->query("SELECT * FROM project_list $where")->num_rows; ?></h3>
<p>Total Projects</p>
</div>
<div class="icon">
<i class="fa fa-layer-group"></i>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-md-4">
<div class="small-box bg-light shadow-sm border">
<div class="inner">
<h3><?php echo $conn->query("SELECT t.*, p.name as pname, p.start_date, p.status as pstatus, p.end_date, p.id as pid FROM task_list t INNER JOIN project_list p ON p.id = t.project_id $where2")->num_rows; ?></h3>
<p>Total Tasks</p>
</div>
<div class="icon">
<i class="fa fa-tasks"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Light Theme with White Background -->
<style>
body {
background-color: #f4f4f9; /* Light background */
font-family: Arial, sans-serif;
}
.card {
background: rgba(255, 255, 255, 0.7); /* Matte glass effect */
backdrop-filter: blur(10px);
border: 1px solid rgba(0, 0, 0, 0.1);
color: #333;
}
.card.user-card {
width: 100%; /* Full width for responsiveness */
margin: 10px;
text-align: center;
padding: 20px;
}
.card-link {
text-decoration: none;
color: inherit;
}
.avatar img {
width: 100px;
height: 100px;
border-radius: 50%;
object-fit: cover;
}
h3, p {
margin: 0;
}
.progress-bar {
background-color: #28a745;
}
.btn-primary {
background-color: #007bff;
border-color: #007bff;
}
/* Sidebar Customization */
.sidebar {
background: rgba(255, 255, 255, 0.1); /* Matte glass effect */
backdrop-filter: blur(10px);
color: #fff; /* Text color */
border-right: 1px solid rgba(255, 255, 255, 0.2); /* Optional: border to enhance glass effect */
}
.sidebar a {
color: #fff; /* Link color */
}
.sidebar .nav-item .nav-link {
color: #fff; /* Link color */
}
.sidebar .nav-item .nav-link:hover {
background-color: rgba(255, 255, 255, 0.2); /* Lighten on hover */
}
.sidebar .nav-item .nav-link.active {
background-color: rgba(255, 255, 255, 0.3); /* Light background for active link */
}
.sidebar .nav-icon {
color: #fff; /* Icon color */
}
</style>