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

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");
?>
</div>
</fieldset>
</td>
</tr>
</table>

</center>
<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">Manage Bill</legend>
<table>
<tr>
<td valign="top">
<a href="onlineorderlist.php"><img src="Picture/onlineorder.gif" width="30" height="30" alt="manage online order"><a href="onlineorderlist.php">Online Order</a><br/>
<br/>
<a href="salesorder.php"><img src="Picture/salesorder.gif" width="30" height="30" alt="manage sales order"><a href="salesorder.php">Sales Order</a><br/>
<br/>
<a href="invlist.php"><img src="Picture/invoice.gif" width="30" height="30" alt="manage invoice"><a href="invlist.php">Invoice</a>
</td>
</tr>
</table>
</fieldset>
</td>
<td width="75%">

<?php
include("connect.php");
$invNo=$_GET['invNo'];

$result = mysql_query("SELECT * FROM invoice WHERE invNo = '$invNo'");

$row = mysql_fetch_array($result);

$result2 = mysql_query("SELECT * FROM invstatus WHERE invNo = '$invNo'");

$num_results = mysql_num_rows($result2);

echo "<fieldset>";
echo "<legend>Invoice - $invNo Delivery Status</legend>";
echo "<br/>";
echo "<table width='70%' border='0'>";
echo "<tr>";
echo "<td width='15%'>Invoice No: </td>";
echo "<td>".$row["invNo"]."</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Buyer Name: </td>";
echo "<td>".$row["custName"]."</td>";
echo "</tr>";
echo "</table>";

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

echo "<tr>";
echo "<td colspan='4' bgcolor='gray'>Invoice Item List</td>";
echo "</tr>";

echo "<tr bgcolor='gray' style='color:black'>";
echo "<td>No</td>";
echo "<td>Date</td>";
echo "<td>Status</td>";
echo "<td>Note</td>";
echo "</tr>";

if($num_results!=0){
for($i=0; $i <$num_results; $i++)
{
	$row2 = mysql_fetch_array($result2);	
	echo "<tr>";
	echo "<td>".($i + 1)."</td>";
	echo "<td>".$row2["invSDate"]."</td>";
	echo "<td>".$row2["invStatus"]."</td>";
	echo "<td>".$row2["invNote"]."</td>";
	echo "</tr>";
}
}else{
echo "<tr>";
echo "<td align='center' colspan='4'>Currently No Update For This Invoice.</td>";
echo "</tr>";
}
echo "</table>";
echo "</fieldset>";
?>
<br/><br/>
<table width="70%">
<form name="invstatusform" method="post" action="updatestatus.php">
<tr>
<th colspan="4">Add Invoice Status</th>
</tr>
<tr>
<td>Status: </td>
<td><select name="invStatus"><option value="0">Choose One</option>
	<option value="Prepare To Delivery.">Prepare To Delivery</option>
	<option value="Delivering. Tracking No: ">Delivering</option>
	<option value="Item Delivered.">Item Delivered</option>
	</select>
</td>
<td>Note: </td>
<td>
<input type="text" name="invNote" size="50" maxlength="50">
</td>
</tr>
</table>

<table width="70%" align="left">
<?php
echo "<tr>";
echo "<input type='hidden' name='invNo' value='$invNo'>";
	echo "<td colspan='6' align='center'>	
	<input type='submit' name='Submit' value='Submit'>
	<input type='submit' name='Back' value='Back'>";
	echo "</tr>";
?>
</table>

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