<?php
	$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');
	
	mysql_selectDB("wauhaha_karaoke",$login);
	

$StaffID = $_GET["StaffID"];
$month = $_POST["month"];
$year = $_POST["year"];
$hours = $_POST["hours"];
$t = $_POST['t'];
 $l=$_POST['l'];
$result1 = mysql_query("select * from salary where StaffID='$StaffID' ");
$row1 = mysql_fetch_array($result1);
$position = $row1["position"];	
$result2= mysql_query("select * from salaryrate where position='$position' ");
$result3= mysql_query("select * from staff where StaffID='$StaffID' ");

$row2 = mysql_fetch_array($result2);
$row3 = mysql_fetch_array($result3);
$overtime = $row2['overtime'];
$overtime1 = $hours * $overtime; 
$tsalary = $row1['TSalary'];
$total = $tsalary + $overtime1;
$username = $row3['Username'];
$name = $row3['Name'];
$epf = $row1['Epf'];
$sal = $row1['Salary'];
if($l<0){
$l2 = $l * $overtime;
}else{
$l2 = $l * 0;
}
$total2 =$total + $l2; 
if(!is_numeric($hours)){
			echo "<script language='javascript'>alert('Overtime number must be numeric.')</script>";
			echo "<script language='javascript'>window.location='adminviewsalary.php?StaffID=$StaffID'</script>";

}else



echo "<body style='background-color: #ffffff;background-image:url(rail.jpg);background-repeat: repeat-y'>";
echo "<center><a href='http://www.wauhaha.com/karaoke/adminviewsalary.php?StaffID=$StaffID'>Back</a></center>";
echo "<center><table style='font-size:20pt'><form method=post action='http://www.wauhaha.com/karaoke/printsalaryaction.php?StaffID=$StaffID'>";
echo "<tr>";
echo "<td>Salary ID:</td>";
echo "<td>";
 include("salaryid.php");
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Staff ID:</td>";
echo "<td>$StaffID <input type=hidden name=staffid value='$StaffID'  ></td>";

echo "</tr>";
echo "<tr>";
echo "<td>Username:</td>";
echo "<td>".$row3['Username']." <input type=hidden name=username value=".$row3['Username']."  ></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Name :</td>";
echo "<td>".$row3['Name']." <input type=hidden name=name value=".$row3['Name']."  ></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Position  :</td>";
echo "<td>$position	<input type=hidden name=position value='$position'  ></td>";
echo "</tr>";

echo "<tr>";
echo "<td>Date  :</td>";
echo "<td>$t <input type=hidden name=t value='$t'  ></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Salary:</td>";
echo "<td>RM ".$row1['Salary']." <input type=hidden name=salary value=".$row1['Salary']."  ></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Overtime:</td>";
echo "<td>RM $overtime1 (RM".$row2['overtime']." * $hours hours ) <input type=hidden name=overtime1 value='$overtime1' </td>";
echo "</tr>";
echo "<tr>";
echo "<td>Unpaid Leave:</td>";
echo "<td>RM$l2 (RM".$row2['overtime']." * $l hours ) <input type=hidden name=l2 value='$l2' </td>";
echo "</tr>";
echo "<tr>";
echo "<td>Epf  :</td>";
echo "<td>RM ".$row1['Epf']." <input type=hidden name=epf value=".$row1['Epf']." </td>";
echo "</tr>";
echo "<tr>";
echo "<td>Company Epf  :</td>";
echo "<td>RM ".$row1['epf1']." <input type=hidden name=e2 value=".$row1['epf1']." </td>";
echo "</tr>";
echo "<tr>";
echo "<td>Socso  :</td>";
echo "<td>RM ".$row2['socso']." <input type=hidden name=s value=".$row2['socso']." </td>";
echo "</tr>";
echo "<tr>";
echo "<td>Total Salary  :</td>";
echo "<td>RM $total2</td> <input type=hidden name=total2 value='$total2' " ;
echo "</tr>";
echo "<tr><td colspan=2><center><input type=submit name=submit value='submit' style='width:100;height:50'></center></td></tr>";
echo "</form></table></center>";




?>	
<center><button onclick='window.print()' style="width:100;height:50">Print </button></center>
</body>