-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaff_master.php
More file actions
94 lines (88 loc) · 4.59 KB
/
staff_master.php
File metadata and controls
94 lines (88 loc) · 4.59 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
<?php
// staff_master.php
include 'header.php';
include 'sidebar.php';
// --- Search Logic ---
$search_term = isset($_GET['search']) ? trim($_GET['search']) : '';
$sql = "SELECT * FROM staff";
if (!empty($search_term)) {
$search_like = "%" . $search_term . "%";
// Search by name or user ID
$sql .= " WHERE name LIKE ? OR user_id LIKE ? OR client_name LIKE ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sss", $search_like, $search_like, $search_like);
$stmt->execute();
$result = $stmt->get_result();
} else {
$sql .= " ORDER BY id DESC";
$result = $conn->query($sql);
}
?>
<!-- Main Content -->
<div class="bg-white p-8 rounded-lg shadow-md w-full">
<div class="flex justify-between items-center mb-6">
<h4 class="text-2xl font-bold text-gray-700">Staff Master</h4>
<a href="staff_add.php"
class="bg-pink-600 hover:bg-pink-700 text-white font-bold py-2 px-4 rounded flex items-center">
<i class="fas fa-plus mr-2"></i> Add Staff
</a>
</div>
<!-- Search Form -->
<div class="mb-6 flex justify-end">
<form action="staff_master.php" method="GET" class="flex items-center">
<label for="search" class="mr-2 text-gray-600">Search:</label>
<input type="text" name="search" id="search" value="<?php echo htmlspecialchars($search_term); ?>"
class="shadow-sm border rounded py-2 px-3 text-gray-700 focus:outline-none focus:ring-2 focus:ring-pink-500"
placeholder="Search...">
<button type="submit" class="ml-2 bg-pink-600 hover:bg-pink-700 text-white font-bold py-2 px-4 rounded">
<i class="fas fa-search"></i>
</button>
</form>
</div>
<!-- Data Table -->
<div class="overflow-x-auto">
<table class="min-w-full bg-white">
<thead class="bg-gray-200 text-gray-600 uppercase text-sm leading-normal">
<tr>
<th class="py-3 px-6 text-left">SRNO</th>
<th class="py-3 px-6 text-left">Client Name</th>
<th class="py-3 px-6 text-left">Name</th>
<th class="py-3 px-6 text-left">User ID</th>
<th class="py-3 px-6 text-center">Status</th>
<th class="py-3 px-6 text-center">Reset Password</th>
<th class="py-3 px-6 text-center">Actions</th>
</tr>
</thead>
<tbody class="text-gray-600 text-sm font-light">
<?php
if ($result && $result->num_rows > 0) {
$sr_no = 1;
while ($row = $result->fetch_assoc()) {
$status_color = $row['status'] == 'Enable' ? 'bg-green-200 text-green-800' : 'bg-red-200 text-red-800';
echo "<tr class='border-b border-gray-200 hover:bg-gray-100'>";
echo "<td class='py-3 px-6 text-left'>" . $sr_no++ . "</td>";
echo "<td class='py-3 px-6 text-left'>" . htmlspecialchars($row["client_name"]) . "</td>";
echo "<td class='py-3 px-6 text-left'>" . htmlspecialchars($row["name"]) . "</td>";
echo "<td class='py-3 px-6 text-left'>" . htmlspecialchars($row["user_id"]) . "</td>";
echo "<td class='py-3 px-6 text-center'><span class='py-1 px-3 rounded-full text-xs " . $status_color . "'>" . htmlspecialchars($row["status"]) . "</span></td>";
echo "<td class='py-3 px-6 text-center'><a href='staff_reset_password.php?id=" . $row['id'] . "' class='text-blue-600 hover:underline'>Reset</a></td>";
echo "<td class='py-3 px-6 text-center'>";
echo "<div class='flex item-center justify-center'>";
echo "<a href='staff_edit.php?id=" . $row['id'] . "' class='w-4 mr-2 transform hover:text-purple-500 hover:scale-110' title='Edit'><i class='fas fa-pencil-alt'></i></a>";
echo "<a href='staff_delete.php?id=" . $row['id'] . "' onclick='return confirm(\"Are you sure?\");' class='w-4 mr-2 transform hover:text-red-500 hover:scale-110' title='Delete'><i class='fas fa-trash-alt'></i></a>";
echo "</div>";
echo "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='7' class='text-center py-4'>No staff found.</td></tr>";
}
$conn->close();
?>
</tbody>
</table>
</div>
</div>
<?php
include 'footer.php';
?>