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

$supID = $_POST["supID"];
$supName = $_POST["supName"];
$supAddress = $_POST["supAddress"];
$supPhone = $_POST["supPhone"];
$supEmail = $_POST["supEmail"];
$scontact = $_POST["supcontact"];
$scontacttel = $_POST["scontacttel"];
$sfax = $_POST["sFax"];


if($_POST["Submit"] == "Submit")
	{
	if(($supID == "")||($supName == "")||($supAddress == "")||($supPhone == "")||($supEmail == "")||($scontact == "")||($scontacttel == "")||($sfax == ""))
	{
	echo "<script>alert('Please fill in all the information for Submit')</script>";
	echo "<script language='javascript'>window.location='supplier.php'</script>";
	}
	
else{
	include("connect.php");
	$result = mysql_query("INSERT INTO supplier(supID,supName,supAddress,supPhone,supEmail,scontact,scontacttel,sfax)
	VALUES
	('$supID', '$supName', '$supAddress', '$supPhone', '$supEmail', '$scontact', '$scontacttel', '$sfax')");
	
	$db = mysql_close();
	echo "<script language='javascript'>alert('Insert success.')</script>";
	echo "<script language='javascript'>window.location='supplierlist.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>Add Supplier</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/bill.gif" width="30" height="30">Supplier</legend>
<table>
<tr>
<td valign="top">
<a href="supplier.php"><img src="Picture/add.gif" width="30" height="30" alt="add suppplier"><a href="supplier.php">Add Supplier</a><br/>
<br/>
<a href="supplierinformation.php"><img src="Picture/list.gif" width="30" height="30" alt="supplier list"><a href="supplierlist.php">Supplier List</a><br/>
<br/>
</td>
</tr>
</table>
</fieldset>
</td>
<td width="75%">
<!--Table-->
<table cellpadding="3" cellspacing="1" width="100%" > 

<tr>
<td valign="top">
<!--Form-->

<form method="POST">
<fieldset> 
<legend><img src="Picture/add.gif" width="30" height="30" alt="manage event">New Supplier Registration Form</legend>

<table width="100%">

<tr>
<td valign="top" height="80">Supplier ID</td>
<td valign="top" ><input type="text" size="30" maxlength="40" name="supID"><br/>(Please Enter Supplier's ID)</td>
</tr>


<tr>
<td valign="top" height="80">Supplier Name</td>
<td valign="top" ><input type="text" size="30" maxlength="50" name="supName"><br/>(Chinese,Malay,English or other language are allow to insert)</td>
</tr>


<tr>
<td valign="top" height="150">Supplier Address</td>
<td valign="top" ><textarea name="supAddress" rows="7" cols="35" maxlength="100" style="font-family:times new roman"></textarea><br/>(Address length not more than 100 words)</td>
</tr>


<tr>
<td valign="top" height="80">Supplier Phone</td>
<td valign="top" ><input type="int" size="30" maxlength="20" style="number" name="supPhone"><br/>(Please Enter Supplier's Phone Number)</td>
</tr>


<tr>
<td valign="top" height="80">Supplier Email</td>
<td valign="top" ><input type="text" size="30" maxlength="80" name="supEmail"></td>
</tr>

<tr>
<td valign="top" height="80">Contactor</td>
<td valign="top" ><input type="text" size="30" maxlength="50" name="supcontact"></td>
</tr>

<tr>
<td valign="top" height="80">Contactor Tel</td>
<td valign="top" ><input type="text" size="30" maxlength="15" name="scontacttel"></td>
</tr>

<tr>
<td valign="top" height="80">Fax</td>
<td valign="top" ><input type="text" size="30" maxlength="50" name="sFax"></td>
</tr>

<tr>
<td></td>
<td><input type="Submit" name="Submit" value="Submit"/>
<input type="Reset" value="Reset"/></td>
</tr>
</table>
</fieldset>

</form>

</td>
</tr>
</table>
</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>