-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
142 lines (116 loc) · 5.58 KB
/
admin.php
File metadata and controls
142 lines (116 loc) · 5.58 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
<?php
require_once("DBConnection.php");
session_start();
if(!isset($_SESSION["sess_user"])){
header("Location: index.php");
}
else{
?>
<!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.0">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"></script>
<link rel="stylesheet" href="css/style.css">
<title>Admin Panel</title>
<style>
h1 {
text-align: center;
font-size: 2.5em;
font-weight: bold;
padding-top: 1em;
}
.mycontainer {
width: 90%;
margin: 1.5rem auto;
min-height: 60vh;
}
.mycontainer table {
margin: 1.5rem auto;
}
</style>
</head>
<body>
<nav class="navbar header-nav navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Online Leave Application</a>
<!-- <button class="btn-default" onclick="window.location.href='leavehist.php';">Leave History</button> </div> -->
<!-- <nav class="nav navbar-right">
<a class="nav-link active" href="#">Active</a>
</nav>
<button id="logout" onclick="window.location.href='logout.php';">Logout</button> </div> -->
<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link" href="list_emp.php" style="color:white;">View Employees <span class="badge badge-pill" style="background-color:#2196f3;"><?php include('count_emp.php');?></span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="leave_history.php" style="color:white;">View Leave History</a>
</li>
<li class="nav-item">
<button id="logout" onclick="window.location.href='logout.php';">Logout</button> </div>
</li>
</ul>
</nav>
<h1>Admin Panel</h1>
<div class="mycontainer">
<table class="table table-bordered table-hover table-striped">
<thead>
<th>#</th>
<th>Employee</th>
<th>Leave Application</th>
<th>Dates</th>
<th>Leave</th>
<th>Actions</th>
<!-- <th>Action</th> -->
</thead>
<tbody>
<!-- loading all leave applications from database -->
<?php
global $row;
$query = mysqli_query($conn,"SELECT * FROM leaves WHERE status='Pending'");
$numrow = mysqli_num_rows($query);
if($query){
if($numrow!=0){
$cnt=1;
while($row = mysqli_fetch_assoc($query)){
$datetime1 = new DateTime($row['fromdate']);
$datetime2 = new DateTime($row['todate']);
$interval = $datetime1->diff($datetime2);
echo "<tr>
<td>$cnt</td>
<td>{$row['ename']}</td>
<td>{$row['descr']}</td>
<td>{$datetime1->format('Y/m/d')} <b>--</b> {$datetime2->format('Y/m/d')}</td>
<td>{$interval->format('%a Day/s')}</td>
<td><a href=\"updateStatusAccept.php?eid={$row['eid']}&descr={$row['descr']}\"><button class='btn-success btn-sm' >Accept</button></a>
<a href=\"updateStatusReject.php?eid={$row['eid']}&descr={$row['descr']}\"><button class='btn-danger btn-sm' >Reject</button></a></td>
</tr>";
$cnt++; }
}
}
else{
echo "Query Error : " . "SELECT * FROM leaves WHERE status='Pending'" . "<br>" . mysqli_error($conn);
}
?>
</tbody>
</table>
</div>
<footer class="footer navbar navbar-expand-lg navbar-light bg-light" style="color:white;">
<div>
<p class="text-center">© <?php echo date("Y"); ?> - Online Leave Application</p>
<p class="text-center">Developed By Issa Oderinde</p>
</div>
</footer>
</body>
</html>
<?php
}
ini_set('display_errors', true);
error_reporting(E_ALL);
?>