forked from iamkcube/CUG-Internship-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcug-details.php
129 lines (119 loc) · 4.89 KB
/
cug-details.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
<?php
include 'authenticate.php';
checkUser("admin");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CUG Details</title>
<link rel="icon" type="image/webp" href="logo.webp" />
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="cug-details.css">
</head>
<body>
<header>
<div class="header-top">
<a href="">
<h1>East Coast Railway</h1>
<h1>Closed User Group</h1>
</a>
</div>
</header>
<main>
<section id="cug-details">
<div class="heading-container">
<button class="back-btn" onclick="window.location.href = 'admin-page.php'"><img
src="icon/back-button.webp" alt="back button"></button>
<h2 class="heading">CUG Details</h2>
<div class="search-bar-container">
<input type="text" id="search-bar" placeholder="Search here" onkeyup="filterTable()">
</div>
</div>
<div class="table-container">
<table>
<thead>
<tr>
<th>CUG Number</th>
<th>Employee Number</th>
<th>Employee Name</th>
<th>Designation</th>
<th>Unit</th>
<th>Department</th>
<th>Bill Unit No</th>
<th>Allocation</th>
<th>Operator</th>
<th>Plan</th>
<th>Status</th>
<th>Created At</th>
<th>Updated At</th>
</tr>
</thead>
<tbody>
<?php
// Include database connection script
include 'db_connect.php';
$sql = "SELECT * FROM cugdetails";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row["cug_number"] . "</td>";
echo "<td>" . $row["emp_number"] . "</td>";
echo "<td>" . $row["empname"] . "</td>";
echo "<td>" . $row["designation"] . "</td>";
echo "<td>" . $row["unit"] . "</td>";
echo "<td>" . $row["department"] . "</td>";
echo "<td>" . $row["bill_unit_no"] . "</td>";
echo "<td>" . $row["allocation"] . "</td>";
echo "<td>" . $row["operator"] . "</td>";
echo "<td>" . $row["plan"] . "</td>";
echo "<td>" . $row["status"] . "</td>";
$created_at = new DateTime($row["created_at"]);
$updated_at = new DateTime($row["updated_at"]);
echo "<td>" . $created_at->format('g:i A \o\n jS M, y') . "</td>";
echo "<td>" . $updated_at->format('g:i A \o\n jS M, y') . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='12'>No records found</td></tr>";
}
$conn->close();
?>
</tbody>
</table>
</div>
</section>
</main>
<footer>
<p>© 2024 East Coast Railway. All rights reserved.</p>
<div class="footer-links">
<a href="#">Privacy Policy</a>
<a href="#">Terms of Service</a>
</div>
</footer>
<script>
function filterTable() {
const input = document.getElementById('search-bar');
const filter = input.value.toUpperCase();
const table = document.querySelector('#cug-details table');
const tr = table.getElementsByTagName('tr');
for (let i = 1; i < tr.length; i++) {
let tdArray = tr[i].getElementsByTagName('td');
let match = false;
for (let j = 0; j < tdArray.length; j++) {
let td = tdArray[j];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
match = true;
break;
}
}
}
tr[i].style.display = match ? "" : "none";
}
}
</script>
</body>
</html>