<?php
session_start();
$username = $_SESSION['staff'];

include ("connect.php");
	
if($_POST["Cancel"] == "Cancel")
{
	echo "<script language='javascript'>window.location='salarylist.php'</script>";
}
if($_SESSION['staff']!= null)
{
?>
	
<html>
<head>
<title>Daily Bookstore - Management System</title>
<link href="salaryprint.css" rel="stylesheet" type="text/css"/>
<link href="bookstaffprint.css" rel="stylesheet" type="text/css" media="print, projection" />
</head>

<body>

<table border='1' cellspacing='0' cellpadding='5' bordercolor='black' width='100%' align='center'>
<tr>
<td>
<center>
<form name="salarypay" method="post">

<?php

$slipID=$_GET['slipID'];
$result = mysql_query("SELECT * FROM salaryslip WHERE slipNo = '$slipID'");   

$row = mysql_fetch_array($result);

if($row['month'] == 1){
	$monthdata = "January";
	}else if($row['month'] == 2){
	$monthdata = "February";
	}else if($row['month'] == 3){
	$monthdata = "March";
	}else if($row['month'] == 4){
	$monthdata = "April";
	}else if($row['month'] == 5){
	$monthdata = "May";
	}else if($row['month'] == 6){
	$monthdata = "June";
	}else if($row['month'] == 7){
	$monthdata = "July";
	}else if($row['month'] == 8){
	$monthdata = "August";
	}else if($row['month'] == 9){
	$monthdata = "September";
	}else if($row['month'] == 10){
	$monthdata = "October";
	}else if($row['month'] == 11){
	$monthdata = "November";
	}else if($row['month'] == 12){
	$monthdata = "December";
	}else{
	}

echo "<tr>";
echo "<th colspan='4'>Daily Bookstore Salary Slip - $monthdata</th>";
echo "</tr>";

echo "<tr>";
echo "<td>Salary No: </td>";
echo "<td colspan='3'>".$row['slipNo']."</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Period: </td>";
echo "<td colspan='3'>".$row['startdate']." To ".$row['enddate']."</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Month Working Day: </td>";
echo "<td colspan='3'>".$row['workingday']."</td>";
echo "</tr>";

echo "<tr>";
echo "<td width='25%'>Employee Name: </td>";
echo "<td width='25%'>".$row['name']."</td>";

$names = $row['name'];

$result1 = mysql_query("SELECT staffIC FROM staff WHERE staffName = '$names'");   

$row1 = mysql_fetch_array($result1);

echo "<td width='25%'>IC No: </td>";
echo "<td width='25%'>".$row1['staffIC']."</td>";
echo "</tr>";

echo "<tr>";
echo "<td colspan='4'><br/></td>";
echo "</tr>";

echo "<tr>";
echo "<th colspan='2'>Earning</th>";
echo "<th colspan='2'>Deduction</th>";
echo "</tr>";

echo "<tr>";
echo "<td>Basic Salary: </td>";
echo "<td>RM ";
printf("%10.2f",$row["basicsalary"]);
echo "</td>";

echo "<td>No Pay Leave: </td>";
echo "<td>RM ";
printf("%10.2f",$row["leaveRM"]);
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Transport: </td>";
echo "<td>RM ";
printf("%10.2f",$row["allowance1"]);
echo "</td>";

echo "<td>EPF (Employee): </td>";
echo "<td>RM ";
printf("%10.2f",$row["epfrate1"]);
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Handphone: </td>";
echo "<td>RM ";
printf("%10.2f",$row["allowance2"]);
echo "</td>";

echo "<td>Socso (Employee): </td>";
echo "<td>RM ";
printf("%10.2f",$row["socso1"]);
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Meal: </td>";
echo "<td>RM ";
printf("%10.2f",$row["allowance3"]);
echo "</td>";

echo "<td>PCB: </td>";
echo "<td>RM ";
printf("%10.2f",$row["pcb"]);
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<th align='left'>Total Earning: </th>";
echo "<th align='left'>RM ";
printf("%10.2f",($row["basicsalary"] + $row["allowance1"] + $row["allowance2"] + $row["allowance3"]));
echo "</th>";

echo "<th align='left'>Total Deduction: </th>";
echo "<th align='left'>RM ";
printf("%10.2f",($row["leaveRM"] + $row["epfrate1"] + $row["socso1"] + $row["pcb"]));
echo "</th>";
echo "</tr>";

echo "<tr>";
echo "<th colspan='4'>Net Pay: RM ";
printf("%10.2f",$row["netpay"]);
echo "</th>";
echo "</tr>";

echo "<tr>";
echo "<th colspan='2' align='left'>Others</th>";
echo "<th>Company Stamp</th>";
echo "<th>Employee Signature</th>";
echo "</tr>";

echo "<tr>";
echo "<td>No Pay Leave: </td>";
echo "<td>".$row['staffNoPayHour']." Hour(s)</td>";

echo "<td rowspan='3'><br/></td>";
echo "<td rowspan='3'><br/></td>";
echo "</tr>";

echo "<tr>";
echo "<td>EPF (Company): </td>";
echo "<td>RM ";
printf("%10.2f",$row["epfrate2"]);
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Socso (Company): </td>";
echo "<td>RM ";
printf("%10.2f",$row["socso2"]);
echo "</td>";
echo "</tr>";
?>

<tr>
<td colspan="4" align="center">
<input type="button" value="Print" onClick="window.print()"/>
<input type="submit" name="Cancel" value="Cancel">
</td>
</tr>

</table>
</form>
</center>
</body>
</html>
<?php
}else{
	echo "<script language='javascript'>alert ('Please login.')</script>";
	echo "<script language='javascript'>window.location='index.php'</script>";
}
?>