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


$staffID=$_GET['staffID'];

include ("connect.php");

	$soNo = $_POST["soNo"];
	$custName = $_POST["custName"];
	$soDate = $_POST["soDate"];
	$soAddress = $_POST["soAddress"];
	$soTel = $_POST["soTel"];
	
if($_POST["Submit"] == "Submit")
	{
	$result = mysql_query("INSERT INTO salesorder(soNo, custName, soDate, soAddress, soTel)
	VALUES
	('$soNo', '$custName', '$soDate', '$soAddress', '$soTel')";
	
	$db = mysql_close();
	echo "<script language='javascript'>alert('New.')</script>";
	echo "<script language='javascript'>window.location='addso2.php?soNo=$soNo'</script>"; 
}
if($_POST["Back"] == "Back")
	{
	echo "<script language='javascript'>window.location='salesorder.php'</script>"; 
	}
if($_SESSION['staff']!= null)
{
?>
	
<html>
<head>
<title>Bookstore - Sales Order Management</title>
</head>
<body style="background:lightyellow">

<table width="100%">
<tr>
<td rowspan="2" align="center" valign="center" alt="天天书局" title="天天书局" ><img src="Logo.gif" width="110" height="110"></td>

<td width="25%"></td>
<td width="25%"></td>

<td>
<form method=GET action="http://www.google.com/search">
<input type=hidden name=ie value=UTF-8 >
<input type=hidden name=oe value=UTF-8 target="_blank">
<table bgcolor="#FFFFFF" target="_blank">
<tr>
<td>
<a href="http://www.google.com">
<img src="GoogleLogo.jpg" border="0" alt="Google" align="absmiddle" title="Google" >
</a>
<input type=text name=q size=25 maxlength=255 value="">
<input type=submit name=btnG value="Google Search">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

<?php
session_start();
$username = $_SESSION['staff'];
if($_SESSION['staff']!= null)
{
echo "<span style='color:black;font-weight:bold'>".$username."</span>";
echo "<a href='logout.php'>(Logout)</a>";
}else{
echo "<span style='color:black;font-weight:bold'>You haven't login.</span>";
echo "<a href='index.php'>(Login)</a>";
}
?>

<hr/>

<table align="right">
<tr>
<td><center>
<a href="index.php"><h4>Home Page</h4></a>
<a href="addbook.php"><h4>Add Book</h4></a>
<a href="addstaff.php"><h4>Add Staff</h4></a>
<a href="stafflist.php"><h4>Staff List</h4></a>
<a href="onlineorderlist.php"><h4>Online Order List</h4></a>
<a href="salesorder.php"><h4>Sales Order List</h4></a>
<a href="addso1.php"><h4>Add Sales Order</h4></a>
</center></td>
</tr>
</table>

<form name="addso1" method="post">
<fieldset style="width:70%">
<legend>New Sales Order</legend>

<table align="left">
<tr>
<td colspan="2">Step 1 - Insert customer basic information.</td>
</tr>

<tr>
<td>Order ID: </td>
<td>
<?php
include("connect.php");
include("salesorderID.php");
echo "$index<input type='hidden' name='soNo' value='$index'/>";
?>
</td>
</tr>

<tr>
<td>Buyer Name: </td>
<td><input type="text" name="custName" size="30" maxlength="50"></td>
</tr>

<tr>
<td>Date: </td>
<td>
<?php
$soDate = date("Y-m-d");
echo "<input type='text' name='soDate' value='$soDate'/>";
?>
</td>
</tr>

<tr>
<td>Address: </td>
<td><input type="text" name="soAddress" size="100" maxlength="100"></td>
</tr>

<tr>
<td>Phone No: </td>
<td><input type="text" name="soTel" size="30" maxlength="15"></td>
</tr>

<tr>
<td colspan="2"><input type="submit" name="Submit" value="Submit">
<input type="submit" name="Back" value="Back"></td>
</tr>
</table>

</fieldset>
</form>

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