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

include ("connect.php");
	if($_POST["Save"] == "Save")
	{
	for ($k=0; $k <2; $k++)
	{
	$typeepf = $_POST['typeepf'.$k];
	$epfvalue = $_POST['epfvalue'.$k];
	

	$result = mysql_query("UPDATE epf SET epfvalue='$epfvalue' WHERE typeepf = '$typeepf'");
	
	
}
$db = mysql_close();
	echo "<script language='javascript'>alert('Edit Success.')</script>";
	echo "<script language='javascript'>window.location='salarymain.php'</script>";
}
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 - Manage EPF</h2>
</center>

<div id="mainpage">
<table width="90%">
<tr>
<td width="15%" valign="top">
<fieldset>
<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%">
<center>
<form name="editepf" method="post">
<fieldset style="width:80%">
<legend><img src="Picture/epf.gif" width="30" height="30">Edit EPF</legend>

<table align="center">

<?php
include("connect.php");
$result = mysql_query("SELECT * FROM epf ORDER BY typeepf");

$num_results = mysql_num_rows($result);
for($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);

echo "<tr>";
echo "<td><input type='hidden' name='typeepf{$i}' value='$row[typeepf]'> $row[typeepf]</td>";
echo "<td><input type='text' name='epfvalue{$i}' size='10' maxlength='10' value='$row[epfvalue]'></td>";
echo "</tr>";

}
echo "<tr>";
echo "<td colspan='4' align='center'><input type='submit' name='Save' value='Save'></td>";
echo "</tr>";
echo "</table>";
?>
</fieldset>
</form>
</center>
</body>
</html>
<?php
}else{
	echo "<script language='javascript'>alert ('Please login.')</script>";
	echo "<script language='javascript'>window.location='index.php'</script>";
}
?>