-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminDashboard.php
More file actions
632 lines (551 loc) · 29.2 KB
/
adminDashboard.php
File metadata and controls
632 lines (551 loc) · 29.2 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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<?php
session_start();
if (!isset($_SESSION['name']))
header("Location: auth/login.php");
if ($_SESSION['role'] != 1)
header("Location: dashboard.php");
include('./conn.php');
// Fetch all tasks
$sql = "SELECT * FROM `tasks`";
$result = mysqli_query($conn, $sql) or die("Query failed");
$countTodo = 0;
$countProgress = 0;
$countReview = 0;
$countDone = 0;
// Loop through the results and count tasks for each category
while ($row = mysqli_fetch_assoc($result)) {
switch ($row['belong']) {
case "TODO":
$countTodo++;
break;
case "PROGRESS":
$countProgress++;
break;
case "REVIEW":
$countReview++;
break;
case "DONE":
$countDone++;
break;
default:
break;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>PMS-CCT</title>
<!-- Custom fonts for this template-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<!-- Custom styles for this template-->
<link href="css/dashboard1.css" rel="stylesheet">
</head>
<body id="page-top">
<!-- Page Wrapper -->
<div id="wrapper">
<!-- Sidebar -->
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
<!-- Sidebar - Brand -->
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
<div class="sidebar-brand-icon">
<img width="64" src="https://employee.crisscrosstamizh.in/logo.png" alt="cct">
</div>
<div class="sidebar-brand-text mx-3">PMS</div>
</a>
<!-- Divider -->
<hr class="sidebar-divider my-0">
<!-- Nav Item - Dashboard -->
<li class="nav-item active">
<a class="nav-link" href="index.html">
<i class="fas fa-fw fa-tachometer-alt"></i>
<span>Admin Panel</span></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider">
<!-- Heading -->
<div class="sidebar-heading">
Interface
</div>
<!-- Nav Item - Pages Collapse Menu -->
<li class="nav-item">
<a class="nav-link collapsed" href="#">
<i class="fas fa-fw fa-cog"></i>
<span>ISSUES</span>
</a>
</li>
<!-- Nav Item - Utilities Collapse Menu -->
<li class="nav-item">
<a class="nav-link collapsed" href="#">
<i class="fas fa-fw fa-wrench"></i>
<span>CODE</span>
</a>
</li>
<!-- Divider -->
<hr class="sidebar-divider">
<!-- Heading -->
<div class="sidebar-heading">
Addons
</div>
<!-- Nav Item - Pages Collapse Menu -->
<li class="nav-item">
<a class="nav-link collapsed" href="#">
<i class="fas fa-fw fa-folder"></i>
<span>Team</span>
</a>
</li>
<hr class="sidebar-divider d-none d-md-block">
<div class="text-center d-none d-md-inline">
<a href="#" onclick="logout()" class="d-none d-sm-inline-block btn btn-danger shadow-sm">Logout</a>
</div>
</ul>
<div id="content-wrapper" class="d-flex flex-column">
<div id="content">
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow" style=".topbar {
height: 3.375rem;
}">
<button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
<i class="fa fa-bars"></i>
</button>
<ul class="navbar-nav ml-auto">
<div class="topbar-divider d-none d-sm-block"></div>
<li class="nav-item dropdown no-arrow">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">@<?php echo $_SESSION['name']; ?></span>
<img class="img-profile rounded-circle" src="https://cdn-icons-png.flaticon.com/512/149/149071.png">
</a>
</li>
</ul>
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-gray-800">Hello <?php echo $_SESSION['name']; ?>!</h1>
</div>
<!-- Content Row -->
<div class="row">
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-primary shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">
Todo</div>
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $countTodo . " Task" ?></div>
</div>
<div class="col-auto">
<i class="fas fa-calendar fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<!-- Earnings (Monthly) Card Example -->
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-warning shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-warning text-uppercase mb-1">
In Progress</div>
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $countProgress . " Task" ?></div>
</div>
<div class="col-auto">
<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-info shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">In Review
</div>
<div class="row no-gutters align-items-center">
<div class="col-auto">
<div class="h5 mb-0 mr-3 font-weight-bold text-gray-800"><?php echo $countReview . " Task" ?></div>
</div>
</div>
</div>
<div class="col-auto">
<i class="fas fa-clipboard-list fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-success shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">
Done</div>
<div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $countDone . " Task" ?></div>
</div>
<div class="col-auto">
<i class="fas fa-comments fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-3 col-lg-5">
<div class="card shadow mb-4 " id="todo-section">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Todo's</h6>
<div class="dropdown no-arrow ">
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
</a>
</div>
</div>
<div class="flex flex-col" id="todo" ondragover="allowDrop(event)" ondrop="drop(event, 'TODO')">
<!-- dynamic content -->
<?php
mysqli_data_seek($result, 0);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
if ($row['belong'] == "TODO") {
echo '<div class="m-2 list" onclick=updatePopup(' . $row['id'] . ') draggable="true" ondragstart="drag(event)" id="' . $row['id'] . '">
<div class="card bg-primary text-white shadow">
<div class="card-body">' . $row['name'] . '
<div class="text-white-50 small text-sm">' . $row['title'] . '</div>
</div>
</div>
</div>';
}
}
}
?>
</div>
</div>
<div id="addbtn" style="border-radius: 4px;cursor: pointer;background-color: #ccede5ed; border: 1px dashed #13855c; text-align: center; padding: 7px; display: flex; justify-content: center; gap: 1rem;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="20">
<path d="M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32V224H48c-17.7 0-32 14.3-32 32s14.3 32 32 32H192V432c0 17.7 14.3 32 32 32s32-14.3 32-32V288H400c17.7 0 32-14.3 32-32s-14.3-32-32-32H256V80z" />
</svg>Add Task
</div>
</div>
<div class=" col-xl-3 col-lg-5">
<div class="card shadow mb-4 " id="in-progress-section">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">In Progress</h6>
</div>
<div class="flex flex-col" id="progress" ondragover="allowDrop(event)" ondrop="drop(event, 'PROGRESS')">
<!-- dynamic content -->
<?php
mysqli_data_seek($result, 0);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
if ($row['belong'] == "PROGRESS") {
echo '<div class="m-2 list" draggable="true" ondragstart="drag(event)" id="' . $row['id'] . '">
<div class="card bg-warning text-white shadow">
<div class="card-body">' . $row['name'] . '
<div class="text-white-50 small text-sm">' . $row['title'] . '</div>
</div>
</div>
</div>';
}
}
}
?>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-5">
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">In Review</h6>
</div>
<div class="flex flex-col" id="review" ondragover="allowDrop(event)" ondrop="drop(event, 'REVIEW')">
<!-- dynamic content -->
<?php
mysqli_data_seek($result, 0);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
if ($row['belong'] == "REVIEW") {
echo '<div class="m-2 list" onclick=updatePopup(' . $row['id'] . ') draggable="true" ondragstart="drag(event)" id="' . $row['id'] . '">
<div class="card bg-info text-white shadow">
<div class="card-body">' . $row['name'] . '
<div class="text-white-50 small text-sm">' . $row['title'] . '</div>
</div>
</div>
</div>';
}
}
}
?>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-5">
<div class="card shadow mb-4 dropzone">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Done</h6>
</div>
<div class="flex flex-col" id="done" ondragover="allowDrop(event)" ondrop="drop(event, 'DONE')">
<!-- dynamic content -->
<?php
mysqli_data_seek($result, 0);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
if ($row['belong'] == "DONE") {
echo '<div class="m-2 list" draggable="true" ondragstart="drag(event)" id="' . $row['id'] . '">
<div class="card bg-success text-white shadow">
<div class="card-body">' . $row['name'] . '
<div class="text-white-50 small text-sm">' . $row['title'] . '</div>
</div>
</div>
</div>';
}
}
}
?>
</div>
</div>
</div>
</div>
</div>
<!-- End of Main Content -->
<!-- Footer -->
<footer class="sticky-footer bg-white">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span>Copyright © PMS 2024</span>
</div>
</div>
</footer>
</div>
</div>
<!-- popup for create task -->
<div id="popup" class="popup">
<div class="popup-content">
<h2>Add Task</h2>
<form id="taskForm">
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">@</span>
<select class="form-select" id="name" aria-label="Default select example">
<!--<option>-select-</option>-->
<?php
include('./conn.php');
$sql = 'select id,name,role from users';
$queryRun = mysqli_query($conn, $sql);
if (mysqli_num_rows($queryRun) > 0) {
while ($row = mysqli_fetch_assoc($queryRun)) {
if ($row['role'] != 1) {
?>
<option value="<?php echo $row['id'] ?>"><?php echo $row['name'] ?></option><?php
}
}
}
?>
</select>
</div>
<div class="input-group mb-3">
<input type="text" id="task" name="task" required class="form-control" placeholder="Task" aria-label="Task" aria-describedby="basic-addon1">
</div>
<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Description</label>
<textarea class="form-control" id="description" rows="3"></textarea>
</div>
<input type="submit" class="btn btn-success" id="popupBtn" value="Create Task">
</form>
<button id="closePopup" class="btn btn-danger">Close</button>
</div>
</div>
<!-- popup for update task -->
<div id="popup2" class="popup">
<div class="popup-content">
<h2>Update Task</h2>
<section>
<div class="input-group mb-3">
<input type="hidden" id="<?php ?>" name="taskId" value="">
<h5 id="updateName">@</h5>
</div>
<div class="input-group mb-3">
<input type="text" id="updateTask" name="task" required class="form-control" placeholder="Task" aria-label="Task" aria-describedby="basic-addon1">
</div>
<div class="mb-3">
<label for="exampleFormControlTextarea1" class="form-label">Description</label>
<textarea class="form-control" id="updatedesc" rows="3"></textarea>
</div>
<input type="submit" class="btn btn-success" id="updateBtn" value="Update Task">
</section>
<button id="closePopup2" class="btn btn-danger">Close</button>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// 1.add task
document.getElementById('taskForm').addEventListener('submit', function(e) {
e.preventDefault();
var selectElement = document.getElementById('name');
var selectedIndex = selectElement.selectedIndex;
var selectedOption = selectElement.options[selectedIndex];
// Extract the selected ID and inner HTML of the selected option
var selectedId = selectedOption.value;
var selectedName = selectedOption.text;
// Get the task value
var task = document.getElementById('task').value;
var description = document.getElementById('description').value;
$.ajax({
url: 'tasks.php',
type: 'POST',
data: {
pid: selectedId,
title: task,
name: selectedName,
description: description,
belong: "TODO"
},
dataType: 'json',
success: function(response) {
if (response.success) {
window.location.href = "./adminDashboard.php";
} else {
alert(response.message);
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('AJAX Error:', textStatus, errorThrown);
}
});
var popup = document.getElementById('popup');
popup.style.display = "none";
});
// Get the modal
var popup = document.getElementById('popup');
var addBtn = document.getElementById('addbtn');
var closePopup = document.getElementById('closePopup');
// open the modal for add task
addBtn.onclick = function() {
popup.style.display = "block";
}
// close modal
closePopup.onclick = function() {
popup.style.display = "none";
}
// for update popup
document.getElementById('closePopup2').onclick = function() {
document.getElementById('popup2').style.display = "none";
}
window.onclick = function(event) {
if (event.target == popup) {
popup.style.display = "none";
}
}
});
function updatePopup(taskId) {
// Get the modal
var upopup = document.getElementById('popup2');
let updateBtn = document.getElementById('updateBtn');
upopup.style.display = "block";
$.ajax({
url: 'update.php',
type: 'GET',
data: {
id: taskId,
},
dataType: 'json',
success: function(response) {
if (response.success) {
var data = response.data;
document.getElementById('updateName').textContent = "@" + data.name;
document.getElementById('updateTask').value = data.title;
document.getElementById('updatedesc').value = data.description;
updateBtn.onclick = function() {
var updatedTask = document.getElementById('updateTask').value;
var updatedDesc = document.getElementById('updatedesc').value;
$.ajax({
url: 'update.php',
type: 'POST',
data: {
taskId: taskId,
title: updatedTask,
description: updatedDesc
},
dataType: 'json',
success: function(response) {
console.log(response);
if (response.success) {
//alert(response.success);
//window.location.href = "./adminDashboard.php";
window.location.href = "./adminDashboard.php";
//location.reload();
} else {
alert(response.message);
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('AJAX Error:', textStatus, errorThrown);
}
});
}
} else {
alert(response.message);
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('AJAX Error:', textStatus, errorThrown);
}
});
}
function logout() {
$.ajax({
url: './auth/logout.php',
type: 'GET',
success: function(response) {
window.location.href = "auth/login.php";
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('AJAX Error:', textStatus, errorThrown);
}
});
}
// Function to handle drag event
function drag(ev) {
ev.dataTransfer.setData("taskID", ev.target.id);
}
// Function to allow dropping elements
function allowDrop(ev) {
ev.preventDefault();
}
// Function to handle drop event
function drop(ev, category) {
ev.preventDefault();
var taskID = ev.dataTransfer.getData("taskID");
var taskElement = document.getElementById(taskID);
console.log('Task ID:', taskID, 'Category:', category, 'Task Element:', taskElement);
var taskId = taskElement.id;
$.ajax({
url: 'update.php',
type: 'POST',
data: {
taskId: taskId,
category: category
},
success: function(response) {
// refresh page
location.reload();
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('AJAX Error:', textStatus, errorThrown);
}
});
}
</script>
</body>
</html>