<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Viewing Customer Order</TITLE>
</HEAD>
<BODY>

<?php
/***************************************************************************
 *			view_cust.php                                      *
 *                     	          				           *
 *   File Info:		  View Customers                                   *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include ("./header.inc");
?>
<center><img src=images/searching.gif border=0><font face=verdana size=2 color=darkred>  Viewing Records from your CUSTOMER ORDER</font></center>
<?php
include("./config.php");

$orderid =  getenv("QUERY_STRING"); 
$table = "custdet";
$conn = @mysql_connect($server,$user,$password)
	or die("Unable to connect to SQL database...");
$rs = @mysql_select_db($database,$conn) 
	or die("Unable to select the database...Please press 'Create Database' to create new database.");
$sql = " SELECT * from $table where orderid = '$orderid'";

$rs = mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");
echo"<br><center><img src=images/docs.gif border=0><font face=verdana size=2> <strong>YOUR ORDER DETAILS</strong></font><img src=images/line.gif border=0 width=100% height=1><br>";
echo"<br><table width=35% border=0 align=center cellspacing=0 cellpadding=0>
  <tr bgcolor=#FFFFFF>
<td align=center><a href = ./store.php><img src=images/homes.gif border=0></a> Back to Store Main Page</b></center></td>
  </tr></table><br>";
?>
<br>
<p align = "center"><font face = "Verdana" size = 3">Below are the details for your order <?php echo("'$orderid'");?></p>
<?php 
$list = "<center><table border =\"1\" cellpadding =\"2\" bgcolor = $backcolor>";
$list.="<tr><th>Order ID</th>";
$list.="<th>PRODUCT</th>";
$list.="<th>QUANTITY</th>";
$list.="<th>PRICE</th>";
$list.="<th>TOTAL PRICE</th>";
$list.="</tr>";

while($row = mysql_fetch_array($rs))
{
	$order = $row["orderid"];
	$qty = $row["qty"];
	$product = $row["product"];
	$price = $row["price"];
	$price = number_format($price,2);
	$totalprice = $row["totalprice"];
	$totalprice = number_format($totalprice,2);
	$pcurrency = $row["currency"];
	$list.= "<tr bgcolor = #FFFFFF>";
	$list.="<td><font face=verdana size=2>$order</font></td>";
	$list.="<td><font face=verdana size=2>$product</font></td>";
	$list.="<td><font face=verdana size=2>$qty</font></td>";
	######## display information for non-world currency ########
	if ($wcurrency == "NO" && $pcurrency == "NO")
	{
		$list.="<td><font face=verdana size=2>$currency$price</font></td>";
		$list.="<td><font face=verdana size=2>$currency$totalprice</font></td>";
	}
	else if ($wcurrency != "NO" && $pcurrency == "YES")
	{	######### world currency ##########
		$list.="<td><font face=verdana size=2>($wcurrency)$price</font></td>";
		$list.="<td><font face=verdana size=2>($wcurrency)$totalprice</font></td>";
	}
	if ($wcurrency != "NO" && $pcurrency == "NO")
	{
		$list.="<td><font face=verdana size=2>($currency)$price</font></td>";
		$list.="<td><font face=verdana size=2>($currency)$totalprice</font></td>";
	}
	if ($wcurrency == "NO" && $pcurrency == "YES")
	{
		$list.="<td><font face=verdana size=2>($currency)$price</font></td>";
		$list.="<td><font face=verdana size=2>($currency)$totalprice</font></td>";
	}
	$list.="</tr>";
}
$list.= "</table></center>";
echo($list);
$get_itemtot = "SELECT SUM(totalprice) FROM $table
		WHERE orderid = '$orderid'";

$itemtot_result = mysql_query($get_itemtot) 
	or die("SQL command failed - Couldn't get total");

$itemtot = mysql_result($itemtot_result,0,"SUM(totalprice)");

$fmt_itemtot = sprintf("%0.2f",$itemtot);

############# display total for non world currency #####################

if ($wcurrency == "NO" && $pcurrency == "NO")
{
	echo "<br><center><strong><font face=verdana size=2>TOTAL ORDER $currency$fmt_itemtot</strong></font></center>";
}
else	############ world currency total ##################
{

if ($pcurrency == "YES")
{
if ($wcurrency != "NO")
echo "<br><center><font face=verdana size=2>The shopping cart is using world currency   </font>";
if ($wcurrency == "ARS")
	echo "<img src = ./images/argntina.gif></td>";
if ($wcurrency == "BRL")
	echo "<img src = ./images/brazil.gif></td>";
if ($wcurrency == "BND")
	echo "<img src = ./images/brunei.gif></td>";
if ($wcurrency == "CNY")
	echo "<img src = ./images/china.gif></td>";
if ($wcurrency == "EGY")
	echo "<img src = ./images/egypt.gif></td>";
if ($wcurrency == "HKD")
	echo "<img src = ./images/hngkng97.gif></td>";
if ($wcurrency == "INR")
	echo "<img src = ./images/india.gif></td>";
if ($wcurrency == "IDR")
	echo "<img src = ./images/indonsia.gif></td>";
if ($wcurrency == "KWD")
	echo "<img src = ./images/kuwait.gif></td>";
if ($wcurrency == "MYR")
	echo "<img src = ./images/malaysia.gif></td>";
if ($wcurrency == "NZD")
	echo "<img src = ./images/newzeal.gif></td>";
if ($wcurrency == "NOR")
	echo "<img src = ./images/norway.gif></td>";
if ($wcurrency == "PKR")
	echo "<img src = ./images/pakistan.gif></td>";
if ($wcurrency == "PHP")
	echo "<img src = ./images/phillipn.gif><td>";
if ($wcurrency == "PLN")
	echo "<img src = ./images/poland.gif></td>";
if ($wcurrency == "ROL")
	echo "<img src = ./images/romania.gif></td>";
if ($wcurrency == "RUR")
	echo "<img src = ./images/russia.gif></td>";
if ($wcurrency == "SAR")
	echo "<img src = ./images/saudiar.gif></td>";
if ($wcurrency == "SGD")
	echo " <img src = ./images/singapor.gif></td>";
if ($wcurrency == "ZAR")
	echo "<img src = ./images/safrica.gif></td>";
if ($wcurrency == "KRW")
	echo "<img src = ./images/skorea.gif></td>";
if ($wcurrency == "SEK")
	echo "<img src = ./images/sweden.gif></td>";
if ($wcurrency == "CHF")
	echo "<img src = ./images/switzrld.gif></td>";
if ($wcurrency == "TWD")
echo "<img src = ./images/taiwan.gif></td>";
if ($wcurrency == "THB")
	echo "<img src = ./images/thailand.gif></td>";
if ($wcurrency == "VND")
	echo "<img src = ./images/vietnam.gif></td>";	
echo "</center>";
}
if ($pcurrency == "YES")
{
if ($wcurrency != "NO")
	echo "<br><br><center><strong><font face=verdana size=2>TOTAL ORDER ($wcurrency)$fmt_itemtot</font></strong></center>";
if ($scurrency == "gbp") 
	$newtotal = $fmt_itemtot * $conv1;
if ($scurrency == "usd")
	$newtotal = $fmt_itemtot * $conv2;
if ($scurrency == "eur") 
	$newtotal = $fmt_itemtot * $conv3;
if ($scurrency == "jpy")
	$newtotal = $fmt_itemtot * $conv4;
if ($scurrency == "cad")
	$newtotal = $fmt_itemtot * $conv5;
if ($wcurrency != "NO")
	$newtotal =  sprintf("%0.2f",$newtotal);
if ($wcurrency != "NO")
	echo "<center><strong><font face=verdana size=2>TOTAL ORDER ($currency)$newtotal</font></strong></center>";
else
	echo "<center><strong><font face=verdana size=2>TOTAL ORDER ($currency)$fmt_itemtot</font></strong></center>";
}else
	echo "<center><strong><font face=verdana size=2>TOTAL ORDER $currency$fmt_itemtot</font></strong></center>";
}

$table = "history";
$nsql = "SELECT fullname, address1, address2, city, postcode from $table where orderid = '$orderid'";
$rees = mysql_query($nsql,$conn)
	or die("Could not execute SQL query!!! Unable to extrace delivery information.");

$lists="<br><center><img src=images/line.gif border=0 width=400 height=2><table width=50% cellpadding=2 cellspacing=0 border=0 bgcolor=#FFFFFF align = center>";
$lists.="<tr>";
$lists.="<td align=center><strong>ORDER DELIVERY DETAILS:</strong></td>";
$lists.="</tr>";
$lists.="</table><br>";
echo($lists);
while($rowa = mysql_fetch_array($rees))
{
	$fullname = $rowa["fullname"];
	$address1 = $rowa["address1"];
	$address2 = $rowa["address2"];
	$city = $rowa["city"];
	$postcode = $rowa["postcode"];
	if ($fullname == NULL)
		$fullname = "Delivery Person's Name: N/A";
}

echo("<font face=verdana size=2>$fullname</font><br>");
echo("<font face=verdana size=2>$address1</font><br>");
echo("<font face=verdana size=2>$address2</font><br>");
echo("<font face=verdana size=2>$city</font><br>");
echo("<font face=verdana size=2>$postcode</font><br><img src=images/line.gif border=0 width=400 height=2></center>");

# check see if shipping order status available

$table = "shipping";
$xsql = "SELECT * from $table where orderid = '$orderid'";
$yres = @mysql_query($xsql,$conn);
$nims = @mysql_num_rows($yres);

if ($nims > 0)
{
echo"<br><center><img src=images/online-order.gif border=0><font face=verdana size=2 color=navy> Shipping Status for Order '$orderid'</font></center><br>";
$list = "<center><table border =\"1\" cellpadding =\"2\" bgcolor = $backcolor>";
$list.="<tr><th><font face=verdana size=2>Order ID</font></th>";
$list.="<th><font face=verdana size=2>Status</font></th>";
$list.="<th><font face=verdana size=2>Ship.Info</font></th>";
$list.="<th><font face=verdana size=2>Ship.Type</font></th>";
$list.="<th><font face=verdana size=2>Order Status</font></th>";
$list.="</tr>";	
while($row = mysql_fetch_array($yres))
{
	$orderid = $row["orderid"];
	$status = $row["status"];
	$shipinfo = $row["shipinfo"];
	$shiptype = $row["shiptype"];
	$orderstat = $row["orderstat"];
	$list.= "<tr bgcolor = #FFFFFF>";
	$list.="<td><font face=verdana size=2>$orderid</font></td>";
	$list.="<td><font face=verdana size=2>$status</font></td>";
	$list.="<td><font face=verdana size=2>$shipinfo</font></td>";
	$list.="<td><font face=verdana size=2>$shiptype</font></td>";
	$list.="<td><font face=verdana size=2>$orderstat</font></td>";
	$list.="</tr>";
}
$list.= "</table></center><br><br>";
echo($list);

}
else
{
echo "<br><br><p align=center><b><font face=verdan size=2 color=navy>ORDER STATUS:</b></font> <font face=verdana size=2 color=green>Opps...There seems to be no shipping status for Order No: '<b>$orderid'</b><br>NOTE: Shipping status will be created by the company and it will appear here once available.</font></p><br><br>";
}
echo "<center><font face=verdana size=2><a href=javascript:history.back()><img src=images/back-to.gif border = 0></a> Click to go back previous page...</font></center>";
echo "<br><br><img src=images/line.gif border=0 width=100% height=1><br>";
include("./your-footer.inc");?>
</BODY>
</HTML>