forked from Anthonyk3801/Elderly-Care-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployee.php
More file actions
133 lines (115 loc) · 3.95 KB
/
employee.php
File metadata and controls
133 lines (115 loc) · 3.95 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
<?php
session_start();
/*if(!isset($_SESSION['level'])) header('location:home.php');
if(isset($_SESSION['level'])){
if($_SESSION['level'] != 1) header('location:extras/transfer.php');
};
*/
include 'db_connection.php';
?>
<?php //TEMPLATES
include 'templates/header.html';
switch($_SESSION['level']) {
case '1':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/admin-side-bar.html';
break;
case '2':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/supervisor-side-bar.html';
break;
case '3':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/doctor-side-bar.html';
break;
case '4':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/caregiver-side-bar.html';
break;
case '5':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/patient-side-bar.html';
break;
case '6':
include 'templates/main-nav-bar.php';
include 'templates/main-grid-content-2columns.html';
include 'templates/familyMember-side-bar.html';
break;
default:
include 'templates/alert-message-before-login.html';
include 'templates/home-nav-bar.html';
include 'templates/main-grid-content-1column.html';
}
include 'templates/main-content.html';
?>
<h1 class="text-center">Employees</h1>
<hr>
<div class="mb-5 mt-5 text-center">
<form action="employee.php" method="POST" id="form2">
<label for="empID">Emp ID</label>
<input class="text-center me-5" type="number" name="empID" id="empID" min="1">
<label for="salary">New Salary</label>
<input class="text-center" type="number" name="salary" id="salary" min="1">
<button class="w-50 btn btn-sm btn-info text-light mt-5 mb-1" type="submit" value="submit" id="submit">Submit</button>
<button class="w-50 btn btn-sm btn-secondary text-light mt-1 mb-1" type="reset">Cancel</button>
</form>
</div>
<hr>
<div class="mb-5 mt-5 text-start">
<form action="employee.php" method="POST" id="form1">
<label for="search">Search: </label>
<input class="text-center" type="text" name="search"><br>
<label for="column">Column: </label>
<select class="text-center" name="column">
<option value="employeeID">Emp ID</option>
<option value="fName">Name</option>
<option value="role">Role</option>
<option value="salary">Salary</option>
</select><br>
<button class="w-25 btn btn-sm btn-info text-light mt-5 mb-1 ms-5" type="submit" value="search" id="search">Search</button>
</form>
</div>
<?php
if(isset($_POST['search'])){
$search = $_POST['search'];
$column = $_POST['column'];
$sql = "SELECT *
FROM Employee
WHERE $column = '$search' AND approval = 1";
$result = $conn->query($sql);
echo "<table width='30%' border=0>";
echo "<th>ID</th>";
echo "<th>Name </th>";
echo "<th>Role</th>";
echo "<th>Salary</th>";
echo "</tr>";
while($res = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$res['employeeID']."</td>";
echo "<td>".$res['fName']. " " .$res['lName']."</td>";
echo "<td>".$res['role']."</td>";
echo "<td>".$res['salary']."</td>";
}
echo "</table>";
}
if(isset($_POST['empID'])){
$empID = $_POST['empID'];
$salary = $_POST['salary'];
};
if (isset($_POST['empID'])){
$sql = "UPDATE Employee
SET salary=$_POST[salary]
WHERE employeeID = $_POST[empID]";
} else if($res['role'] === 'SuperVisor'){
echo "<p style='color:red;'>Supervisor can't update salary</p>";
}
?>
<?php // TEMPLATES
include 'templates/end-main-content.html';
include 'templates/footer.html';
?>