-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsalary1.php
99 lines (89 loc) · 2.14 KB
/
salary1.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
<?php
session_start();
if (!isset($_SESSION["manager"])) {
header('Location: index.php');
exit;
}
require_once('mysql_conn.php');
$dept = $_REQUEST['dtype'];
$sql ="SELECT * FROM employee where dept='$dept'";
$result = mysql_query($sql);
$month = $_REQUEST['month'];
$monthNO;
switch ($month)
{
case 'January': $monthNO = '01';
break;
case 'February': $monthNO = '02';
break;
case 'March': $monthNO = '03';
break;
case 'April': $monthNO = '04';
break;
case 'May': $monthNO = '05';
break;
case 'June': $monthNO = '06';
break;
case 'July': $monthNO = '07';
break;
case 'August': $monthNO = '08';
break;
case 'September': $monthNO = '09';
break;
case 'October': $monthNO = '10';
break;
case 'November': $monthNO = '11';
break;
case 'December': $monthNO = '12';
break;
}
?>
<html>
<head><title>Salary Calculation</title></head>
<center>
<h1>Salary Information</h1>
<hr>
<table border="1" style="width:50%">
<tr>
<td>User ID</td>
<td>Name</td>
<td>Department</td>
<td>Salary</td>
<td>Absent Days</td>
<td>Payable salary</td>
</tr>
<?php
while($row = mysql_fetch_array($result))
{
echo "<tr>";
$var = $row['e_id'];
echo "<td>".$var."</td>";
echo "<td>".$row['name']."</td>";
echo "<td>".$row['dept']."</td>";
$sql2 ="SELECT * FROM `attendance` WHERE e_id='$var' AND attend_date LIKE '%$monthNO%'";
$result2 = mysql_query($sql2);
$attend = mysql_num_rows($result2);
$sql3 ="SELECT salary FROM `employee` WHERE e_id='$var'";
$result3 = mysql_query($sql3);
$salary= mysql_fetch_array($result3);
$sal = $salary['salary'];
$pSalary = ($sal/30)*$attend;
$abs = 30-$attend;
echo "<td>".$sal."</td>";
echo "<td>".$abs."</td>";
echo "<td>".$pSalary."</td>";
echo "</tr>";
$sqlinsert = "INSERT INTO `salary`(`e_id`, `month`, `salary`, `p_salary`, `absentDays`) VALUES ('$var','$monthNO','$sal','$pSalary','$abs')";
if(!mysql_query($sqlinsert))
{
echo "Error: " . $sqlinsert . "<br>" . mysql_error($conn);
}
}
echo "</table> \n";
?>
</table>
<br>
<a href="manager.php">Back to admin page</a>
<a href="logout.php"><h3>Logout</h3></a>
</center>
</html>