-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathname.php
More file actions
179 lines (166 loc) · 7.35 KB
/
name.php
File metadata and controls
179 lines (166 loc) · 7.35 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
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
<?php include('head.php'); ?>
<?php include('ai.php'); ?>
<div class="box1">
<!-- Button trigger modal for Add -->
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addModal">Add</button>
<!-- Button trigger modal for Update -->
<button class="btn btn-primary ms-2" data-bs-toggle="modal" data-bs-target="#updateModal">Update</button>
<!-- Button trigger modal for Delete -->
<button class="btn btn-primary ms-2" data-bs-toggle="modal" data-bs-target="#deleteModal">Delete</button>
</div>
<!-- Department Selection Form -->
<form action="dropdown.php" method="post">
<label for="department">Select Department:</label>
<select name="department" id="department">
<option value="">All Departments</option>
<option value="Purchasing">Purchasing</option>
<option value="Sales">Sales</option>
<option value="Finance">Finance</option>
<option value="HR">HR</option>
<option value="Accounting">Accounting</option>
<option value="Marketing">Marketing</option>
<option value="IT">IT</option>
</select>
<input type="submit" class="btn btn-primary" value="Filter">
</form>
<!-- Delete Button Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel">Delete Employee</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="delete.php" method="post">
<div class="mb-3">
<label for="delete_id" class="form-label">Enter ID to Delete:</label>
<input type="text" class="form-control" id="delete_id" name="delete_id">
</div>
<button type="submit" class="btn btn-danger" name="deleteemployee">Delete</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<table class="table table-hover table-bordered table-striped">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Department</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<?php
include('ai.php');
// Query modification based on selected department
$condition = "";
if (isset($_POST['department']) && !empty($_POST['department'])) {
$department = mysqli_real_escape_string($connection, $_POST['department']);
$condition = " WHERE Department = '$department'";
}
$query = "SELECT * FROM `employee`" . $condition;
$result = mysqli_query($connection, $query);
if (!$result) {
die("QUERY FAILED... " . mysqli_error($connection));
} else {
while ($row = mysqli_fetch_assoc($result)) {
?>
<tr>
<td><?php echo htmlspecialchars($row['Id']); ?></td>
<td><?php echo htmlspecialchars($row['Name']); ?></td>
<td><?php echo htmlspecialchars($row['Department']); ?></td>
<td><?php echo htmlspecialchars($row['Salary']); ?></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<?php
if(isset($_GET['message'])){
echo "<h6>".$_GET['message']."</h6>";
}
?>
<?php
if(isset($_GET['insert_msg'])){
echo "<h6>".$_GET['insert_msg']."</h6>";
}
?>
<!-- Add Employee Modal -->
<form action="insert.php" method="post">
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addModalLabel">Addition of Employee</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="id">Id</label>
<input type="text" name="id" class="form-control">
</div>
<div class="form-group">
<label for="name">Name</label>
<input type="text" name="names" class="form-control">
</div>
<div class="form-group">
<label for="dept">Department</label>
<input type="text" name="dept" class="form-control">
</div>
<div class="form-group">
<label for="sal">Salary</label>
<input type="text" name="sal" class="form-control">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<input type="submit" class="btn btn-success" name="addemployee" value="ADD">
</div>
</div>
</div>
</div>
</div>
</form>
<!-- Update Employee Modal -->
<form action="update.php" method="post">
<div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="updateModalLabel">Update Employee</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="update_id">Id</label>
<input type="text" name="update_id" class="form-control">
</div>
<div class="form-group">
<label for="update_name">Name</label>
<input type="text" name="update_name" class="form-control">
</div>
<div class="form-group">
<label for="update_dept">Department</label>
<input type="text" name="update_dept" class="form-control">
</div>
<div class="form-group">
<label for="update_sal">Salary</label>
<input type="text" name="update_sal" class="form-control">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<input type="submit" class="btn btn-primary" name="updateemployee" value="UPDATE">
</div>
</div>
</div>
</div>
</div>
</form>
<?php include('foot.php'); ?>