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

$supID = $_POST["supID"];
$supName = $_POST["supName"];
$supAddress = $_POST["supAddress"];
$supPhone = $_POST["supPhone"];
$supEmail = $_POST["supEmail"];

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>Supplier Control</h2>

<center>
<div id="mainpage">
<div id="bill">
<table width="90%">
<tr>
<td width="15%" valign="top">
<fieldset style="margin:0 5 0 0">
<legend><img src="Picture/bill.gif" width="30" height="30">Supplier</legend>
<table>
<tr>
<td valign="top">
<a href="customer.php"><img src="Picture/add.gif" width="30" height="30" alt="add customer"><a href="supplier.php">Add Supplier</a><br/>
<br/>
<a href="customerinformation.php"><img src="Picture/list.gif" width="30" height="30" alt="customer list"><a href="supplierlist.php">Supplier List</a><br/>
<br/>
</td>
</tr>
</table>
</fieldset>
</td>
<td width="100%">	
<table width="100%">
<tr>
<td valign="top">

<form method='POST'>
<fieldset> 
<legend><img src="Picture/list.gif" width="30" height="30" alt="customer list">Supplier List</legend>

	
	<table border='1' width='100%'>
	<tr>
	<th>Supplier ID</th>
	<th>Supplier Name</th>
	<th>Supplier Address</th>
	<th>Supplier Phone</th>
	<th>Supplier Email</th>
	<th>Contactor</th>
	<th>Contactor Tel</th>
	<th>Fax</th>
	<th>Delete</th>
	<th>Edit</th>
	</tr>
	
<?php
include("connect.php");

$result = mysql_query("SELECT * FROM supplier ORDER BY supID,supName,supAddress,supPhone,supEmail");


$num_results = mysql_num_rows($result);

	for ($i=0; $i <$num_results; $i++)
{
	$row = mysql_fetch_array($result);	
	echo "<tr>";
	echo "<td align='center'><font style='color:blue'>".$row['supID']."</font></td>";
	echo "<td align='center'><font style='color:blue'>".$row['supName']."</font></td>";
	echo "<td align='center'><font style='color:blue'>".$row['supAddress']."</font></td>";
	echo "<td align='center'><font style='color:blue'>".$row['supPhone']."</font></td>";
	echo "<td align='center'><font style='color:blue'><A href = 'mailto:".$row['supEmail']."'>".$row['supEmail']."</a></font></td>";
	echo "<td align='center'><font style='color:blue'>".$row['scontact']."</font></td>";
	echo "<td align='center'><font style='color:blue'>".$row['scontacttel']."</font></td>";
	echo "<td align='center'><font style='color:blue'>".$row['sfax']."</font></td>";
	echo "<td align='center'><a href='deleteSupplierInformation.php?supID=".$row['supID']."'>";
	echo "Delete";
	echo "</td>";
	echo "<td>";
	echo "<a href='supplierUpdate.php?supID=".$row['supID']."'>";
	echo "Edit";
	echo "</td>";
}

//$result->free();
$db = mysql_close();
?>	
	
	</tr>
	</table>
	

</td>
</fieldset>
</form>

</td>
</tr>
</table>
</div>
</div>
</center>
</td>
</tr>
</table>
<?php
}else{
	echo "<script language='javascript'>alert ('Please login.')</script>";
	echo "<script language='javascript'>window.location='index.php'</script>";
}
?>
<hr/>

<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>