-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleaves.php
157 lines (157 loc) · 5.8 KB
/
leaves.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
<?php
include 'dbconnection.php';
include('session.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Leaves</title>
<meta http-equiv="refresh">
<link rel="stylesheet" href="styling.css?v=<?php echo time(); ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<!--navigation bar -->
<?php include 'navigation.php'?>
<div class="heading"><h4>LEAVE REQUESTS</h4></div>
<div class="workspace">
<h3>Pending Leave Requests list</h3>
<hr>
<div class="tables">
<?php
include 'dbconnection.php';
//Query information
$query = "select leave_request_id, concat(first_name,' ',last_name) as names, leave_name, date_requested, concat(start_date,' to ',end_date) as dates
from employees, leave_types, leave_requests
where leave_requests.user_id = employees.employee_ID and leave_requests.leave_request = leave_types.leave_id
and leave_requests.status = '1'";
if($result = $mysqli->query($query)) {
//Do nothing if successful
}
else {
echo "Error getting information from the database."."<br>";
}
//Create table headers
echo "<table class='leave_tables'> <tr>";
echo "<th>Employee Name</th>";
echo "<th>Leave Type</th>";
echo "<th>Date Requested</th>";
echo "<th>Leave Date</th>";
echo "<th>Action</th>";
echo "</tr\n>";
//loop through all the rows and create a row for each
while($result_ar = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$result_ar['names']."</td>";
echo "<td>".$result_ar['leave_name']."</td>";
echo "<td>".$result_ar['date_requested']."</td>";
echo "<td>".$result_ar['dates']."</td>";
echo "<td>
<details>
<summary>Select</summary>
<div><a href='request_approval.php? leave_id=".$result_ar['leave_request_id']."'>Approve Request</a></div>
<div><a href='request_denied.php? leave_id=".$result_ar['leave_request_id']."'>Deny Request</a></div>
</details>
</td>";
echo "</td></tr>\n";
}
echo "</table>";
//Close database connection
$mysqli->close();
?>
</div>
<h3>Approved Leave Requests list</h3>
<hr>
<div class="tables">
<?php
include 'dbconnection.php';
//Query information
$query = "select leave_request_id, concat(first_name,' ',last_name) as names, leave_name, date_requested, concat(start_date,' to ',end_date) as dates
from employees, leave_types, leave_requests
where leave_requests.user_id = employees.employee_ID and leave_requests.leave_request = leave_types.leave_id
and leave_requests.status = '2'";
if($result = $mysqli->query($query)) {
//Do nothing if successful
}
else {
echo "Error getting information from the database."."<br>";
}
//Create table headers
echo "<table class='leave_tables'> <tr>";
echo "<th>Employee Name</th>";
echo "<th>Leave Type</th>";
echo "<th>Date Requested</th>";
echo "<th>Leave Date</th>";
echo "<th>Action</th>";
echo "</tr\n>";
//loop through all the rows and create a row for each
while($result_ar = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$result_ar['names']."</td>";
echo "<td>".$result_ar['leave_name']."</td>";
echo "<td>".$result_ar['date_requested']."</td>";
echo "<td>".$result_ar['dates']."</td>";
echo "<td>
<details>
<summary>Select</summary>
<div><a href='request_denied.php? leave_id=".$result_ar['leave_request_id']."'>Deny Request</a></div>
</details>
</td>";
echo "</td></tr>\n";
}
echo "</table>";
//Close database connection
$mysqli->close();
?>
</div>
<h3>Denied Leave Requests list</h3>
<hr>
<div class="tables">
<?php
include 'dbconnection.php';
//Query information
$query = "select leave_request_id, concat(first_name,' ',last_name) as names, leave_name, date_requested, concat(start_date,' to ',end_date) as dates
from employees, leave_types, leave_requests
where leave_requests.user_id = employees.employee_ID and leave_requests.leave_request = leave_types.leave_id
and leave_requests.status = '3'";
if($result = $mysqli->query($query)) {
//Do nothing if successful
}
else {
echo "Error getting information from the database."."<br>";
}
//Create table headers
echo "<table class='leave_tables'> <tr>";
echo "<th>Employee Name</th>";
echo "<th>Leave Type</th>";
echo "<th>Date Requested</th>";
echo "<th>Leave Date</th>";
echo "<th>Action</th>";
echo "</tr\n>";
//loop through all the rows and create a row for each
while($result_ar = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>".$result_ar['names']."</td>";
echo "<td>".$result_ar['leave_name']."</td>";
echo "<td>".$result_ar['date_requested']."</td>";
echo "<td>".$result_ar['dates']."</td>";
echo "<td>
<details>
<summary>Select</summary>
<div><a href='request_approval.php? leave_id=".$result_ar['leave_request_id']."'>Approve Request</a></div>
</details>
</td>";
echo "</td></tr>\n";
}
echo "</table>";
//Close database connection
$mysqli->close();
?>
</div>
</div>
<div class="empty"></div>
<div id="second">
<?php include 'footer.php' ?>
</div>
</body>
</html>