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

include ("connect.php");

$username = $_SESSION['staff'];
if($_GET["sort"]!=""){
$sort = $_GET["sort"];
}else{
$sort = num;
}
if($_SESSION['staff']!= null)
{
?>
	
<html>
<head>
<title>Daily Bookstore - Management System</title>
<!--include css file-->
<link href="bookstaff.css" rel="stylesheet" type="text/css"/>
</head>

<body>

<?php
include ("stafffunctionbar.php");
?>

<center>
<h2>Daily Bookstore Management - Salary Slip List</h2>
</center>

<div id="mainpage">
<table width="90%">
<tr>
<td width="15%" valign="top">
<fieldset style="margin:0 5 0 0">
<legend><img src="Picture/salary.gif" width="30" height="30">Salary</legend>
<table>
<td valign="top">
<a href="salarylist.php"><img src="Picture/salary.gif" width="30" height="30" alt="EPF"><a href="salarylist.php">Salary List</a><br/>
<br/>
<a href="addsalary.php"><img src="Picture/addsalary.jpg" width="30" height="30" alt="EPF"><a href="addsalary.php">Add Salary</a><br/>
<br/>
<a href="editepf.php"><img src="Picture/epf.gif" width="30" height="30" alt="EPF"><a href="editepf.php">EPF</a><br/>
<br/>
<a href="socsolist.php"><img src="Picture/socso.gif" width="30" height="30" alt="Socso"><a href="socsolist.php">Socso</a><br/>
</td>
</tr>
</table>
</fieldset>
</td>

<td width="75%">
<?php
include ("connect.php");
$result = mysql_query("SELECT * FROM salaryslip");   


echo "<div id='mainpage'>";
echo "<table width='70%'>";
echo "<caption><img src='Picture/salary.gif' width='30' height='30' />Daily Bookstore Management System - Salary</caption>";

echo "<div>";

echo "<table border='1' cellspacing='0' cellpadding='5' bordercolor='white' align='center' width='90%'>";

echo "<tr bgcolor='gray' style='color:lightblue'>";
echo "<td width='3'>No.</td>";
echo "<td width='50'>Slip ID</td>";
echo "<td width='200'>Staff Name</td>";
echo "<td width='10'>Month</td>";
echo "<td width='10'>Start Date</td>";
echo "<td width='3'>End Date</td>";
echo "<td>View</td>";
echo "<td>Delete</td>";
echo "</tr>";

$num_results = mysql_num_rows($result);
if($num_results!=0){
for($i=0;$i<$num_results;$i++){
	$row = mysql_fetch_array($result);
	echo "<tr>";
	echo "<td>".($i + 1)."</td>";
	echo "<td>".$row["slipNo"]."</td>";
	echo "<td>".$row["name"]."</td>";
	
	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 "<td>$monthdata</td>";
	echo "<td>".$row["startdate"]."</td>";
	echo "<td>".$row["enddate"]."</td>";
	echo "<td><a href='viewsalaryslip.php?slipID=".$row["slipNo"]."'>View</a></td>";
	echo "<td><a href='deletesalaryslip.php?slipID=".$row["slipNo"]."'>Delete</a></td>";
	echo "</tr>";
}
}else{
echo "<td colspan='8' align='center'>No Salary Slip Here.</td>";
}

echo "</table>";
echo "</div>";

echo "<hr/>";
$db = mysql_close();
?>

</td>
</tr>
</table>
<center>
<div id="bottom">
<br/>
Copyright &#169; with Tian Tian Bookstore 2011. All Rights Reserved.
<br/>
Website:<a href="../bookstore" target="_blank">www.dailybook.com.my
</div>
</center>
</body>
</html>
<?php
}else{
	echo "<script language='javascript'>alert ('Please login.')</script>";
	echo "<script language='javascript'>window.location='index.php'</script>";
}
?>