-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.php
More file actions
112 lines (102 loc) · 3.23 KB
/
tasks.php
File metadata and controls
112 lines (102 loc) · 3.23 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
<?php
session_start();
if (isset($_SESSION['role']) && isset($_SESSION['id']) && $_SESSION['role'] == "admin") {
include "DB_connection.php";
include "app/Model/Task.php";
include "app/Model/User.php";
$text = "All Task";
if (isset($_GET['due_date']) && $_GET['due_date'] == "Due Today") {
$text = "Due Today";
$tasks = get_all_tasks_due_today($conn);
$num_task = count_tasks_due_today($conn);
}else if (isset($_GET['due_date']) && $_GET['due_date'] == "Overdue") {
$text = "Overdue";
$tasks = get_all_tasks_overdue($conn);
$num_task = count_tasks_overdue($conn);
}else if (isset($_GET['due_date']) && $_GET['due_date'] == "No Deadline") {
$text = "No Deadline";
$tasks = get_all_tasks_NoDeadline($conn);
$num_task = count_tasks_NoDeadline($conn);
}else{
$tasks = get_all_tasks($conn);
$num_task = count_tasks($conn);
}
$users = get_all_users($conn);
?>
<!DOCTYPE html>
<html>
<head>
<title>All Tasks</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<input type="checkbox" id="checkbox">
<?php include "inc/header.php" ?>
<div class="body">
<?php include "inc/nav.php" ?>
<section class="section-1">
<h4 class="title-2">
<a href="create_task.php" class="btn">Create Task</a>
<a href="tasks.php?due_date=Due Today">Due Today</a>
<a href="tasks.php?due_date=Overdue">Overdue</a>
<a href="tasks.php?due_date=No Deadline">No Deadline</a>
<a href="tasks.php">All Tasks</a>
</h4>
<h4 class="title-2"><?=$text?> (<?=$num_task?>)</h4>
<?php if (isset($_GET['success'])) {?>
<div class="success" role="alert">
<?php echo stripcslashes($_GET['success']); ?>
</div>
<?php } ?>
<?php if ($tasks != 0) { ?>
<table class="main-table">
<tr>
<th>#</th>
<th>Title</th>
<th>Description</th>
<th>Assigned To</th>
<th>Due Date</th>
<th>Status</th>
<th>Action</th>
</tr>
<?php $i=0; foreach ($tasks as $task) { ?>
<tr>
<td><?=++$i?></td>
<td><?=$task['title']?></td>
<td><?=$task['description']?></td>
<td>
<?php
foreach ($users as $user) {
if($user['id'] == $task['assigned_to']){
echo $user['full_name'];
}}?>
</td>
<td><?php if($task['due_date'] == "") echo "No Deadline";
else echo $task['due_date'];
?></td>
<td><?=$task['status']?></td>
<td>
<a href="edit-task.php?id=<?=$task['id']?>" class="edit-btn">Edit</a>
<a href="delete-task.php?id=<?=$task['id']?>" class="delete-btn">Delete</a>
</td>
</tr>
<?php } ?>
</table>
<?php }else { ?>
<h3>Empty</h3>
<?php }?>
</section>
</div>
<script type="text/javascript">
var active = document.querySelector("#navList li:nth-child(4)");
active.classList.add("active");
</script>
</body>
</html>
<?php }else{
$em = "First login";
header("Location: login.php?error=$em");
exit();
}
?>