-
Notifications
You must be signed in to change notification settings - Fork 1
/
manager_dashboard.php
253 lines (224 loc) · 8.56 KB
/
manager_dashboard.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
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
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="manager_dashboard.css">
<title>Manager Dashboard</title>
</head>
<body>
<div class="navbar">
<h2>Welcome <?php echo $_SESSION["emp_name"]; ?> <br>Employee ID : <?php echo $_SESSION["emp_id"]; ?> </h2>
<a href="logout.php" style="float: right;"><h3>Logout</h3></a>
</div>
<div class="tab">
<button class="tablinks" onclick="openTab(event, 'addTask')"><span></span>Add Task to Employee</button>
<button class="tablinks" onclick="openTab(event, 'projectStatistics')"><span></span>View Project Statistics</button>
<button class="tablinks" onclick="openTab(event, 'viewAttendance')"><span></span>View Attendance</button>
<button class="tablinks" onclick="openTab(event, 'payrollSlip')"><span></span>Payroll Slip</button>
<button class="tablinks" onclick="openTab(event, 'notice')"><span></span>Notice</button>
</div>
<!-- Tabs Content -->
<div id="addTask" class="tabcontent">
<h1>Add Tasks</h1>
<?php require_once("fetchtask.php");?>
<form method="post" action="addtask.php">
<label for="project_id">Select Project:</label>
<select id="project_id" name="project_id" required>
<?php
// Output project options
while ($row = $resultProjects->fetch_assoc()) {
echo "<option value=".$row["project_id"].">".$row["project_name"]."</option>";
}
?>
</select><br><br>
<label for="emp_id">Select Employee:</label>
<select id="emp_id" name="emp_id" required>
<?php
// Output employee options
while ($row = $resultEmployees->fetch_assoc()) {
echo "<option value=".$row["emp_id"].">".$row["emp_id"]."</option>";
}
?>
</select><br><br>
<label for="role">Role:</label>
<input type="text" id="role" name="role" required><br><br>
<input type="submit" value="Assign Task">
</form>
</div>
<div id="projectStatistics" class="tabcontent">
<h1>Project Statistics</h1>
<?php
// Database connection parameters
$servername = "localhost"; // Change this to your database server name
$username = "root"; // Change this to your database username
$password = ""; // Change this to your database password
$database = "project_database"; // Change this to your database name
// Create connection
$conn = new mysqli($servername, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// SQL query to fetch all data from the 'project' table
$sql = "SELECT * FROM project";
$result = $conn->query($sql);
?>
<table>
<tr>
<th>Project ID</th>
<th>Project Name</th>
<th>Description</th>
<th>Status</th>
<th>Progression</th>
<th>Starting Date</th>
<th>Ending Date</th>
</tr><?php
if ($result->num_rows > 0) {
// Output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>
<td>".$row["project_id"]."</td>
<td>".$row["project_name"]."</td>
<td>".$row["description"]."</td>
<td>".$row["status"]."</td>
<td>".$row["progression"]."</td>
<td>".$row["starting_date"]."</td>
<td>".$row["ending_date"]."</td>
</tr>";
}
} else {
echo "<tr><td colspan='7'>No projects found</td></tr>";
}
?>
</table>
</div>
<div id="viewAttendance" class="tabcontent">
<?php
$db = mysqli_connect("localhost", "root", "", "project_database") or die("Connectivity Failed");
$firstDayOfMonth = date("1-m-Y");
$totalDaysInMonth = date("t", strtotime($firstDayOfMonth));
// Fetching Students
$fetchingEmp = mysqli_query($db, "SELECT * FROM employee") OR die(mysqli_error($db));
$totalNumberOfEmp= mysqli_num_rows($fetchingEmp);
$EmpNamesArray = array();
$EmpIDsArray = array();
$counter = 0;
while($Emp= mysqli_fetch_assoc($fetchingEmp))
{
$EmpNamesArray[] = $Emp['emp_name'];
$EmpIDsArray[] = $Emp['emp_id'];
}
?>
<div class="container-fluid">
<header class="bg-primary text-white text-center mb-3 py-3">
<div class="row">
<div class="col-12">
<h2>Attendance<br>
Month: <u><?php echo strtoupper(date("F")); ?></u></h2>
</div>
</div>
</header>
<table border="1" cellspacing="0">
<?php
for($i = 1; $i<=$totalNumberOfEmp+ 2; $i++)
{
if($i == 1)
{
echo "<tr>";
echo "<td rowspan='2'>Names</td>";
for($j = 1; $j<=$totalDaysInMonth; $j++)
{
echo "<td>$j</td>";
}
echo "</tr>";
}else if($i == 2)
{
echo "<tr>";
for($j = 0; $j<$totalDaysInMonth; $j++)
{
echo "<td>" . date("D", strtotime("+$j days", strtotime($firstDayOfMonth))) . "</td>";
}
echo "</tr>";
}else
{
echo "<tr>";
echo "<td>" . $EmpNamesArray[$counter] . "</td>";
for($j = 1; $j<=$totalDaysInMonth; $j++)
{
$dateOfAttendance = date("Y-m-$j");
$fetchingEmpAttendance = mysqli_query($db, "SELECT status FROM attendance WHERE emp_id = '". $EmpIDsArray[$counter] ."' AND curr_date = '". $dateOfAttendance ."'") OR die(mysqli_error($db));
$isAttendanceAdded = mysqli_num_rows($fetchingEmpAttendance);
if($isAttendanceAdded > 0)
{
$EmpAttendance = mysqli_fetch_assoc($fetchingEmpAttendance);
if($EmpAttendance['status'] == "P")
{
$color = "green";
}else if($EmpAttendance['status'] == "A")
{
$color = "red";
}else if($EmpAttendance['status'] == "H")
{
$color = "blue";
}else if($EmpAttendance['status'] == "L")
{
$color = "brown";
}
echo "<td style='background-color: $color; color:white'>" . $EmpAttendance['status'] . "</td>";
}else {
echo "<td></td>";
}
}
echo "</tr>";
$counter++;
}
}
?>
</table>
</div>
</div>
</div>
<div id="payrollSlip" class="tabcontent">
<h3>Payroll Slip</h3>
<?php require_once("emp_payroll.php");?>
</div>
<div id="notice" class="tabcontent">
<h1>Notice</h1>
<?php require_once("viewNotice.php"); ?>
<h3>Existing Notices:</h3>
<ul>
<?php
foreach ($notices as $notice) {
echo "<li> {$notice['time']} - {$notice['notice']}</li>";
}
?>
</ul>
<h3>Write New Notice:</h3>
<form method="post" action="editNoticemg.php">
<label for="notice">Notice:</label><br>
<textarea id="notice" name="notice" rows="4" cols="50" required></textarea><br><br>
<input type="submit" value="Submit Notice">
</form>
</div>
<script>
function openTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
</script>
</body>
</html>