<html>
<head><title>EZ Shopper - Checkout Order</title></head>
<body>
<?

/***************************************************************************
 *			shop_checkouts.php                                 *
 *                     	          				           *
 *   File Info:		  Checkout basket                                  *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include ("./config.php");
include ("./tests.php");

######################### if first time...url will contain PHPSESSID=xxxx  #############################
######################### code below will refresh page to remove PHPSESSID #############################
$strvar = getenv("QUERY_STRING");
$pos = strpos($strvar,'=');
$strs = substr($strvar,0,$pos);
session_start();
$PHPSESSID = session_id();
#### if unregistered permit  to continue to checkout ####

$checkout = "false";
if ($strvar == "unregistered")
	$checkout = "true";

if ((!session_is_registered("admin")) && ($checkout == "false"))
{
include ("./logredirect.php");	
exit();
} 	
if ($pos > 0 && $empty == NULL)
{
	echo "<table width=450 border=1 cellspacing=0 cellpadding=0 height=150>
<tr><td width=450 bgcolor=#CCCCCC height=10>$header</td></tr>
<tr><td width=450 bgcolor=#FFFFFF height=140>";
	echo "<b><br><center>Please be patient as we now re-directing you to main store page...<br>You will only see this message once i.e every time you start a new browser window.</center></b><br></td></tr></table>";
	include_once("./redirect-me.php");
} else {
if ($phpcart == "NO")
{

}
$logstate = getenv("QUERY_STRING");

if ($phpcart == "NO" or $phpcart == "YES"){
if ((!session_is_registered("admin")) && ($checkout == "false"))
{
include ("./logredirect.php");	
} 
else
{
$table= "myorders";
$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 'mydata'...Please press 'Create Database' to create new database.");
$get_itemtot = "SELECT SUM(SEL_ITEM_TOTALPRICE) FROM $table
		WHERE USER_ID =  '$PHPSESSID'";

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

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

$fmt_itemtot = sprintf("%0.2f",$itemtot);
	
if ($wcurrency == "NO")
{
	if ($itemtot < $min_cost or $itemtot < $mincost) 
	{
		$shipping = $shipcost;
	} else
	 {
		$shipping = 0;
	}
}
else
	$shipping = 0;

$fmt_shipping = sprintf("%0.2f",$shipping);

$subtotal = $itemtot + $shipping;

$fmt_subtotal = sprintf("%0.2f",$subtotal);

$get_cart = "SELECT SEL_ITEM, SEL_ITEM_TITLE, SEL_ITEM_QTY, SEL_ITEM_PRICE, 
		SEL_ITEM_TOTALPRICE FROM $table 
		WHERE USER_ID =  '$PHPSESSID'";

$cart_result = mysql_query($get_cart)
	or die("SQL command failed - Couldn't get cart.");

$num_rows = mysql_numrows($cart_result);

##### if registered get the first name + last name + email ######

if ($admin != NULL)
{
	$table = "users";
	$user = $_SESSION['admin'];
	$sql1 = "SELECT * from $table where username = '$user'";
	$gresult = mysql_query($sql1,$conn);
	$row = @mysql_fetch_array($gresult);

	$first = $row["firstname"];
	$last = $row["lastname"];
	$uemail = $row["email"];
	$full_name = $first;
	$full_name.= ",";
	$full_name.= $last;
	$email = $uemail;
}

if ($num_rows == "0") {
	if ($logstate == NULL or $checkout == "true")
	{
	echo "<table width=450 border=1 cellspacing=0 cellpadding=0 height=150>
<tr><td width=450 bgcolor=#CCCCCC height=10>$header</td></tr>
<tr><td width=450 bgcolor=#FFFFFF height=140>";
	echo "<P><center><font color = navy face=verdana size=2><img src=images/online-order.gif border=0>There are no items in your shopping cart</font><br><font face=verdana color=navy size=2><img src=images/bullets.gif border=0>You can only checkout when there are items in shopping cart!</center></font></p><p align=justify>We accept online payments from PayPal, Nochex, 2CheckOut and we accept cheques, money orders and cash (if you send recorded delivery).</p></td></tr></table>";
	
	}
	if ($logstate == "login")
	{

	$table = "stocks";
	$sql = " SELECT pid,sitem,scat,spic,stock,color,size from $table where pid=$pid";
	$rs = @mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");

	$row=mysql_fetch_array($rs);
	$pics = $row["spic"];
	$scat=$row["scat"];
	$stocknum = $row["stock"];
	if (strlen($pics) < 1)
	{	
		$pics="./images/nopic.jpg";
	}
	if (fopen($pics,"r") == NULL)
		$pics = "./images/nopic.jpg";
	if (strlen($scat) < 1)
	{
		$scat = "N/A";
	}
	echo "<center><TABLE cellSpacing=0 cellPadding=0 border=0><TR>
      <TD background=./images/border_cnr_tl.gif><IMG height=8 alt= src=./images/px.gif width=8 border=0></TD>
      <TD background=./images/border_top.gif><IMG height=8 alt= src=./images/px.gif width=120 border=0></TD>
      <TD background=./images/border_cnr_tr.gif><IMG height=8 alt= src=./images/px.gif width=8          border=0></TD></TR><TR><TD background=./images/border_left.gif>
       <IMG height=60 alt= src=./images/px.gif width=8 border=0></TD>
       <TD width=120>
       <TABLE cellSpacing=0 cellPadding=4 width=480 border=0>
       <TBODY><tr><td align=center><center><img src=images/mouses.gif border=0><font face = Verdana size =4 color=navy> Authorisation Accepted</font></center></td></tr><TR><tr><td align=center>........................................................................................</td></tr>
       <TD align=center><font color = #0000CC size = 2>You have now logged in !<br><br>Click any navigation buttons to start shopping! </center></font></td></tr><tr><td align=center>........................................................................................</td></tr><tr><td align=center><font face=verdana size=1 color=navy>We recommend the following product item</font></td></tr>";
echo "<tr><td align=center><img src=$pics border=0 alt=Picture></td></tr>";
echo "<tr><td><font face=verdana size=1><b>Product Item ID:</b>	$pid <a href = ./shop_showitem.php?pid=$pid></font><font color = $highlight><u>Show Item</u></font></a>";
echo "</td></tr><tr><td><font face=verdana size=1><b>Product Item   :</b>    $pitem</font>";
echo "</td></tr><tr><td><font face=verdana size=1><b>Product Description:</b> $pdes</font></td></tr>";
echo "<tr><td><font face=verdana size=1><b>Product Category:</b> $scat</font></td></tr>";
if ($stocknum >=1)
echo "<tr><td><font face=verdana size=1><b>Stock: </b> $stocknum</td></tr>";
if ($stocknum < 1)
echo "<tr><td><font face=verdana size=1><b>Stock: </b> <font face=verdana size=1 color=red>Out of Stock!</font></td></tr>";
echo "</TBODY></TABLE></TD><TD background=./images/border_right.gif>
      <IMG height=60 alt= src=./images/px.gif width=8 border=0></TD></TR>
      <TR><TD background=./images/border_cnr_bl.gif>
      <IMG height=8 alt= src=./images/px.gif width=8 border=0></TD>
      <TD background=./images/border_bottom.gif>
      <IMG height=8 alt= src=./images/px.gif width=121 border=0></TD>
      <TD background=./images/border_cnr_br.gif>
      <IMG height=8 alt= src=./images/px.gif 
      width=8 border=0></TD></TR></TABLE></center><br><br>";
	}
} else {

if ($wcurrency == "NO")
{
echo "

<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
<HTML>
<HEAD>
<TITLE>Shopping Cart: Checkout</TITLE>
</HEAD>
<BODY>

<center><img src=images/cart-checkout.gif border=0 height=36></center>

<FORM ACTION=\"shop_sendorder.php\" METHOD=\"post\">
<center><img src=images/bill-info.gif border=0></center>
<table border=0 cellspacing=0 cellpadding=5 align = center>

<tr>
<td><strong><font face=verdana size=2>Full Name:</font></strong></td>
<td><INPUT TYPE=text NAME=full_name SIZE=20 value = $full_name></td>
</tr>

<tr>
<td><strong><font face=verdana size=2>E-Mail Address:</font></strong></td>
<td><INPUT TYPE=text NAME=email SIZE=20 value = $email></td>
</tr>

<tr>
<td><strong><font face=verdana size=2>Address Line 1:</font></strong></td>
<td><INPUT TYPE=text NAME=address1 SIZE=40></td>
</tr>


<tr>
<td><strong><font face=verdana size=2>Address Line 2:</font></strong></td>
<td><INPUT TYPE=text NAME=address2 SIZE=40></td>
</tr>

<tr>
<td><strong><font face=verdana size=2>City/State/Country:</font></strong></td>
<td><INPUT TYPE=text NAME=city SIZE=40></td>
</tr>

<tr>
<td><strong><font face=verdana size=2>Post/Zip Code:</font></strong></td>
<td><INPUT TYPE=text NAME=postcode SIZE=20></td>
</tr>

<tr>
<td><strong><font face=verdana size=2>Payment Type:</font></strong></td>
<td>
<SELECT NAME=pay_type>
<OPTION VALUE=\"PayPal\">PayPal</OPTION>
<OPTION VALUE=\"Nochex\">Nochex</OPTION>
<OPTION VALUE=\"2Checkout\">2Checkout</OPTION>
<OPTION VALUE=\"Cheque\">Cheque</OPTION>
<OPTION VALUE=\"Postal order\">Postal order</OPTION>
</SELECT> 
</td>
</tr>

<tr>
<td><strong><font face=verdana size=2>Telephone Number:</font></strong></td>
<td><INPUT TYPE=text NAME=phone SIZE=20></td>
</tr>


</table>

<img src=images/line.gif border=0 width=500 height=1>
<center><img src=./images/cart-contents.gif border=0><img src = ./images/shoppingcart.gif width=30 height = 30></center>

<table border=0 cellpadding=10 cellspacing=0 bgcolor=$backcolor align = center>

<tr>
<td align=center><strong><font face=verdana size=2 color=darkred>ITEM</font></strong></td>
<td align=center><strong><font face=verdana size=2 color=darkred>TITLE DESCRIPTION</font></strong></td>
<td align=center><strong><font face=verdana size=2 color=darkred>QTY</font></strong></td>
<td align=center><strong><font face=verdana size=2 color=darkred>UNIT PRICE</font></strong></td>
<td align=center width=100><strong><font face=verdana size=2 color=darkred>TOTAL COSTS</font></strong></td>
</tr>
";
}
else
{
echo "

<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
<HTML>
<HEAD>
<TITLE>Shopping Cart: Checkout</TITLE>
</HEAD>
<BODY>
<center><img src=images/cart-checkout.gif border=0 height=36></center>
<FORM ACTION=\"shop_sendorder.php\" METHOD=\"post\">
<center><img src=images/bill-info.gif border=0></center>

<table border=0 cellspacing=0 cellpadding=5 align = center>

<tr>
<td><strong><font face=verdana size=2>Full Name:</font></strong></td>
<td><INPUT TYPE=text NAME=full_name SIZE=20 value = $full_name></td>
</tr>

<tr>
<td><strong><font face=verdana size=2>E-Mail Address:</font></strong></td>
<td><INPUT TYPE=text NAME=email SIZE=20 value = $email></td>
</tr>

<tr>
<td><strong><font face=verdana size=2>Address Line 1:</font></strong></td>
<td><INPUT TYPE=text NAME=address1 SIZE=40></td>
</tr>


<tr>
<td><strong><font face=verdana size=2>Address Line 2:</font></strong></td>
<td><INPUT TYPE=text NAME=address2 SIZE=40></td>
</tr>

<tr>
<td><strong><font face=verdana size=2>City/State:</font></strong></td>
<td><INPUT TYPE=text NAME=city SIZE=30></td>
</tr>

<tr>
<td><strong><font face=verdana size=2>Post/Zip Code:</font></strong></td>
<td><INPUT TYPE=text NAME=postcode SIZE=20></td>
</tr>
<tr>
<td><strong><font face=verdana size=2>Country:</font></strong></td>
<td><INPUT TYPE=text NAME=country SIZE=50></td>
</tr>
<tr>
<td><strong><font face=verdana size=2>Payment Type:</font></strong></td>
<td>
<SELECT NAME=pay_type>
<OPTION VALUE=\"PayPal\">PayPal</OPTION>
<OPTION VALUE=\"Nochex\">Nochex</OPTION>
<OPTION VALUE=\"2Checkout\">2Checkout</OPTION>
<OPTION VALUE=\"Cheque\">Cheque</OPTION>
<OPTION VALUE=\"Postal order\">Postal order</OPTION>
</SELECT> 
</td>
</tr>

<tr>
<td><strong><font face=verdana size=2>Contact Number:</font></strong></td>
<td><INPUT TYPE=text NAME=phone SIZE=20></td>
</tr>


</table>

<img src=images/line.gif border=0 width=500 height=1>
<center><img src=./images/cart-contents.gif border=0><img src = ./images/shoppingcart.gif width=30 height = 30></center><br>

<table border=0 width=100% cellpadding=10 cellspacing=0 bgcolor=#FFFFFF align = center>

<tr>
<td align=center><strong><font face=verdana size=2 color=darkred>ITEM</font></strong></td>
<td align=center><strong><font face=verdana size=2 color=darkred>TITLE DESCRIPTION</font></strong></td>
<td align=center><strong><font face=verdana size=2 color=darkred>QTY</font></strong></td>
<td align=center><strong><font face=verdana size=2 color=darkred>PRICE</font></strong></td>
<td align=center><strong><font face=verdana size=2 color=darkred>TOTAL & SHIPPING</font></strong></td>
</tr>
";
}


while ($row = mysql_fetch_array($cart_result)) {

	$sel_item = $row["SEL_ITEM"];
	$sel_item_title = $row["SEL_ITEM_TITLE"];	
	$sel_item_qty = $row["SEL_ITEM_QTY"];
	$sel_item_price = $row["SEL_ITEM_PRICE"];
	$sel_item_price = number_format($sel_item_price,2);
	$sel_item_totalprice = $row["SEL_ITEM_TOTALPRICE"];

	$fmt_item_totalprice = sprintf("%0.2f",$sel_item_totalprice);
	$tables = "stocks";
	$get_carts = "SELECT size,color from $tables where (sitem like '$sel_item' or sitem like '$sel_item_title')";
	$carts = @mysql_query($get_carts,$conn)
		or die("Unable to get product and stock information for shopping cart....");
	
	$prow = mysql_fetch_array($carts);
	$color = $prow["color"];
	$size = $prow["size"];
	if ($wcurrency == "NO")
	{
	echo "
	<tr><font face=verdana size=2>
	<td>$sel_item color:$color size:$size</td>
	<td>$sel_item_title</td>
	<td align=right>$sel_item_qty</td>
	<td align=right>$currency $sel_item_price</td>
	<td align=right>$currency $fmt_item_totalprice</td>	
	</font></tr>
	";
	}
	else	# world currency
	{
		echo "
		<tr><font face=verdana size=2>
		<td>$sel_item color:$color size:$size</td>
		<td>$sel_item_title</td>
		<td align=right>$sel_item_qty</td>
		<td align=right>($wcurrency) $sel_item_price</td>
		<td align=right>($wcurrency) $fmt_item_totalprice</td>	
		</font></tr>
		";
	}
}
	if ($wcurrency == "NO")
	{
	echo "
	<tr>
	<td colspan=4 align=right><strong><font face=verdana size=2 color=red>Item Total:</font></strong></td>
	<td align=right><strong><font face=verdana size=2>$currency $fmt_itemtot</font></strong></td></tr>

	<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=red>Shipping:</font></strong></td>
	<td align=right>";
	
		#### non-world-currency and no shipping option ####

		if ($shipopt == "NO")
		{
			if ($shipping != "0")
		 	{
				echo "<strong><font face=verdana size=2>$currency $fmt_shipping</font></strong>";
			} 
			else 
			{
				echo "<strong><font face=verdana size=2 color=red>FREE!</font></strong>";
			}
		}
		#### world-currency and shipping option ####

		if ($shipopt != "NO")
		{
			if ($shipping != "0")
		 	{
				echo "<img src=images/ship-calc.gif border=0 alt=Shipping height=24>";
			} 
			else 
			{
				echo "<img src=images/ship-calc.gif border=0 alt=Shipping height=24>";
			}
		}
	}
	else
	{	#world currency
		echo "
		<tr>
		<td colspan=4 align=right><strong><font face=verdana size=2 color=red>Item Total:</font></strong></td>
		<td align=right><strong><font face=verdana size=2 >($wcurrency) $fmt_itemtot</font></strong></td></tr>

		<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=red>Shipping:</font></strong></td>
		<td align=right>";
	
		#### non-world currency and no shipping option ###

		if ($shipopt == "NO") 
		{
			if ($shipping != "0")
		 	{
				if ($wcurrency == "NO")
					echo "<strong><font face=verdana size=2 >$currency $fmt_shipping</font></strong>";
				else
					echo "<img src=images/ship-calc.gif border=0 alt=Shipping height=24>";
			} 
			else 
			{
				if ($wcurrency == "NO")
					echo "<strong><font face=verdana size=2 color=red>FREE!</font></strong>";
				else
					echo "<img src=images/ship-calc.gif border=0 alt=Shipping height=24>";
			}
		}

		#### world currency and shipping option ###

		if ($shipopt != "NO") 
		{
			if ($shipping != "0")
		 	{
			echo "<img src=images/ship-calc.gif border=0 alt=Shipping height=24>";
			} 
			else 
			{
			echo "<img src=images/ship-calc.gif border=0 alt=Shipping height=24>";
			}
		}
	}
	# non world currency
	if ($wcurrency == "NO")
	{
	if ($shipopt == "NO")
	echo "
	</td></tr>
	<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=navy>Subtotal:</font></strong></td>
	<td align=right><strong><font face=verdana size=2>$currency $fmt_subtotal</font></strong></td></tr>
	<tr><td colspan=5 align=center>
	<input type=\"submit\" name=\"submit\" value=\"Send This Order!\">
	</td></tr>
	</table>
	</form>
	</BODY>
	</HTML>
	";
		if ($shipopt == "YES")
	echo "
	</td></tr>
	<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=navy>Subtotal:</font></strong></td>
	<td align=right><strong><img src=images/ship-calc.gif border=0 alt=Shipping height=24></td></tr>
	<tr><td colspan=5 align=center>
	<input type=\"submit\" name=\"submit\" value=\"Send This Order!\">
	</td></tr>
	</table>
	</form>
	</BODY>
	</HTML>
	";

	}
	else # world currency
	{
	echo "
	</td></tr>

	<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=red>Subtotal:</font></strong></td>
	<td align=right><strong><font face=verdana size=2>($wcurrency) $fmt_subtotal</font></strong></td></tr>

	<tr><td colspan=5 align=center>";
	if ($scurrency == "gbp")
	{	
		$convert = $fmt_itemtot * $conv1;	
		if ($convert < 999)
		$convert = number_format($convert,2);
		if ($convert > 999)
		$converts = number_format($convert,2);
		echo "<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=navy>Basket Total:</font></strong></td>
		<td align=right>";
		if ($convert < 999)
		echo "<font face=verdana size=2>$currency$convert</font></td></tr>";
		if ($convert > 999)
		echo "<font face=verdana size=2>$currency$converts</font></td></tr>";
	}	
	if ($scurrency == "usd")
	{
		$convert = $fmt_itemtot * $conv2;
		if ($convert < 999)
		$convert = number_format($convert,2);
		if ($convert > 999)
		$converts = number_format($convert,2);
		echo "<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=navy>Basket Total:</font></strong></td>
		<td align=right>";
		if ($convert < 999)
		echo "<center><font face=verdana size=2>$currency$convert</center></font></td></tr>";
		if ($convert > 999)
		echo "<font face=verdana size=2>$currency$converts</font></td></tr>";
	}
	if ($scurrency == "eur")
	{
		$convert = $fmt_itemtot * $conv3;
		if ($convert < 999)
		$convert = number_format($convert,2);
		if ($convert > 999)
		$converts = number_format($convert,2);
		echo "<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=navy>Basket Total:</font></strong></td>
		<td align=right>";
		if ($convert < 999)
		echo "<font face=verdana size=2>$currency$convert</font></td></tr>";
		if ($convert > 999)
		echo "<font face=verdana size=2>$currency$converts</font></td></tr>";
	}
	if ($scurrency == "jpy")
	{
		$convert = $fmt_itemtot * $conv4;
		if ($convert < 999)
		$convert = number_format($convert,2);
		if ($convert > 999)
		$converts = number_format($convert,2);
		echo "<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=navy>Basket Total:</font></strong></td>
		<td align=right>";
		if ($convert < 999)
		echo "<font face=verdana size=2>$currency$convert</font></td></tr>";
		if ($convert > 999)
		echo "<font face=verdana size=2>$currency$converts</font></td></tr>";
	}
	if ($scurrency == "cad")
	{
		$convert = $fmt_itemtot * $conv5;
		if ($convert < 999)
		$convert = number_format($convert,2);
		if ($convert > 999)
		$converts = number_format($convert,2);
		echo "<tr><td colspan=4 align=right><strong><font face=verdana size=2 color=navy>Basket Total:</font></strong></td>
		<td align=right>";
		if ($convert < 999)
		echo "<font face=verdana size=2>$currency$convert</font></td></tr>";
		if ($convert > 999)
		echo "<font face=verdana size=2>$currency$converts</font></td></tr>";
	}
	echo "
	Select shipping zone: <select name = shipzone><option value = 'zone1'>-- Zone 1 --</option><option value = 'zone2'>-- Zone 2 --</option><option value = 'zone3'>-- Zone 3 --</option></select>
	<input type=\"submit\" name=\"submit\" value=\"Send This Order!\">
	</td></tr>

	</table>

	</form>
	
	</BODY>
	</HTML>
	";
	}
    if ($wcurrency == "ARS")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/argntina.gif></font></center><br>";
     if ($wcurrency == "BRL")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/brazil.gif></font></center><br>";
     if ($wcurrency == "BND")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/brunei.gif></font></center><br>";
     if ($wcurrency == "CNY")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/china.gif></font></center><br>";
     if ($wcurrency == "EGY")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/egypt.gif></font></center><br>";
     if ($wcurrency == "HKD")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/hngkng97.gif></font></center><br>";
     if ($wcurrency == "INR")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/india.gif></font></center><br>";
     if ($wcurrency == "IDR")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/indonsia.gif></font></center><br>";
     if ($wcurrency == "KWD")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <p align = center>Our Price <img src = ./images/kuwait.gif></font></center><br>";
     if ($wcurrency == "MYR")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/malaysia.gif></font></center><br>";
     if ($wcurrency == "NZD")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/newzeal.gif></font></center><br>";
     if ($wcurrency == "NOR")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/norway.gif></font></center><br>";
     if ($wcurrency == "PKR")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/pakistan.gif></font></center><br>";
     if ($wcurrency == "PHP")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/phillipn.gif></font></center><br>";
     if ($wcurrency == "PLN")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/poland.gif></center></center><br>";
     if ($wcurrency == "ROL")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/romania.gif></font></center><br>";
     if ($wcurrency == "RUR")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/russia.gif></font></center><br>";
     if ($wcurrency == "SAR")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/saudiar.gif></font></center><br>";
     if ($wcurrency == "ZAR")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency  <img src = ./images/safrica.gif></font></center><br>";
     if ($wcurrency == "KRW")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency <img src = ./images/skorea.gif></font></center><br>";
    if ($wcurrency == "SEK")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency <img src = ./images/sweden.gif></font></center><br>";
   if ($wcurrency == "CHF")
	echo "<center>NOTE: This Shopping Cart is using world currency <img src = ./images/switzrld.gif></center><br>";
   if ($wcurrency == "TWD")
	echo "<center>NOTE: This Shopping Cart is using world currency <img src = ./images/taiwan.gif></center><br>";
  if ($wcurrency == "THB")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency <img src = ./images/thailand.gif></font></center><br>";
  if ($wcurrency == "VND")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency <img src = ./images/vietnam.gif></font></center><br>";
 if ($wcurrency == "SGD")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency <img src = ./images/singapor.gif></font></center><br>";
if ($wcurrency == "USD")
	echo "<center><font face=verdana size=2>NOTE: This Shopping Cart is using world currency <img src = ./images/usa.gif></font></center><br>";

############# display shipping information ###############

echo "<img src=images/line.gif width=500 height=1 border=0>";

if ($shipopt == "NO")
{
	############# non-sql ##################
	if ($itemtot < $min_cost && $usedata == "NO") 
	{
		$shipping = $shipcost;
	} else 
	{
		$shipping = 0;
	}

	if ($itemtot < $mincost && $usedata == "YES") 
	{
		$shipping = $shipcost;
	} else 
	{
		$shipping = 0;	
	}
	if ($wcurrency == "NO")
	{
		echo "<br><center><font face=verdana size=2 colour = navy> <b>Shipping Information</b></font></center>";
		echo "<br><p align = justify><font face = Verdana size =2>Please note that our shipping costs are calculated using the following method. If a customer orders less than $currency$mincost in the chosen currency, shipping cost will be added to the shopping cart  (Shipping Costs will be $currency$shipcost). Shipping is free if the customers orders more than $currency$mincost!!! </font></p>";
	}
	if ($wcurrency != "NO")
	{
		echo "<br><center><font face=verdana size=2 colour = navy> <b>Shipping Information</b></font></center>";
	echo "<br><p align = center><font face = Verdana size =2><b>Zone 1 shipping costs will be $zone1.<br>Zone 2 shipping costs will be $zone2.<br>Zone 3 shipping costs will be $zone3.</b></p><br><p align=justify>The above costs will be in the chosen's country's currency. The conversion from the chosen country's currency to UK Sterling, US Dollars, Euros, JapaneseYen and Canadian Dollars will take place.</p><center>"; 
		$tshipping1 = 0;
		$tshipping2 = 0;
		$tshipping3 = 0;
		$tship1 = 0;
		$tship2 = 0;
		$tship3 = 0;
		if ($scurrency == "gbp") # Convert to Sterling
		{
			$tship1 = $zone1 * $conv1;
			$tship1 = number_format($tship1,2);
			$tship2 = $zone2 * $conv1;
			$tship2 = number_format($tship2,2);
			$tship3 = $zone3 * $conv1;
			$tship3 = number_format($tship3,2);
		}
		if ($scurrency == "usd") # Convert to US Dollars
		{
			$tship1 = $zone1 * $conv2;
			$tship1 = number_format($tship1,2);
			$tship2 = $zone2 * $conv2;
			$tship2 = number_format($tship2,2);
			$tship3 = $zone3 * $conv2;
			$tship3 = number_format($tship3,2);	
		}
		if ($scurrency == "eur") # Convert to Euros
		{
			$tship1 = $zone1 * $conv3;
			$tship1 = number_format($tship1,2);
			$tship2 = $zone2 * $conv3;
			$tship2 = number_format($tship2,2);
			$tship3 = $zone3 * $conv3;
			$tship3 = number_format($tship3,2);	
		}
		if ($scurrency == "jpy") # Convert to Yen
		{
			$tship1 = $zone1 * $conv4;
			$tship1 = number_format($tship1,2);
			$tship2 = $zone2 * $conv4;
			$tship2 = number_format($tship2,2);
			$tship3 = $zone3 * $conv4;
			$tship3 = number_format($tship3,2);	
		}
		if ($scurrency == "cad") # convert to Can. Dollars
		{
			$tship1 = $zone1 * $conv5;
			$tship1 = number_format($tship1,2);
			$tship2 = $zone2 * $conv5;
			$tship2 = number_format($tship2,2);
			$tship3 = $zone3 * $conv5;
			$tship3 = number_format($tship3,2);	
		}
		$tshipping1 = $convert + $tship1;
		$tshipping1 = number_format($tshipping1,2);
		$tshipping2 = $convert + $tship2;
		$tshipping2 = number_format($tshipping2,2);
		$tshipping3 = $convert + $tship3;
		$tshipping3 = number_format($tshipping3,2);
		
		echo "If shipping to Zone 1 = $currency$tship1 <font color=navy>Basket Total</font> = <b>$currency$tshipping1</b><br>";
		echo "If shipping to Zone 2 = $currency$tship2 <font color=navy>Basket Total</font> = <b>$currency$tshipping2</b><br>";
		echo "If shipping to Zone 3 = $currency$tship3 <font color=navy>Basket Total</font> = <b>$currency$tshipping3</b><br>";
	}
}

if ($shipopt != "NO")
{
	$table = "myorders";
	$get_carts = "SELECT SEL_ITEM, SEL_ITEM_TITLE, SEL_ITEM_QTY, SEL_ITEM_PRICE, SEL_ITEM_TOTALPRICE FROM $table WHERE USER_ID =  '$PHPSESSID'";

$cart_results = mysql_query($get_carts)
	or die("SQL command failed - Couldn't get cart.");
	$sitems = array();
	$sqty = array();
	$count = 0;
	$shiptotal = 0;
	$shiptotals = 0;
	while ($row = mysql_fetch_array($cart_results)) 
	{
	$sel_item = $row["SEL_ITEM"];
	$sel_item_qty = $row["SEL_ITEM_QTY"];
	$sitems[$count] = $sel_item;
	$sqty[$count] = $sel_item_qty;
	$count += 1;
	}
		
	echo "<br><center><font face=verdana size=2 colour = navy> <b>Shipping Information</b></font></center>";
	echo "<br><br><center><table width=400 border=1><tr><td bgcolor=yellow>Shipping Item</td><td bgcolor=yellow>Shipping Category</td><td bgcolor=yellow>Shipping Price</td><td bgcolor=yellow>Shipping Total</td></tr>";

	$i = 0;
	foreach ($sitems as $value)
	{
		$table = "stocks";
		$sqls = "SELECT * from $table where sitem = '$value'";
		$get_cats = mysql_query($sqls)
	or die("SQL command failed - Couldn't get category for item.");
		while ($frow = mysql_fetch_array($get_cats))
		{
			$category = $frow["scat"];
		}
		$table = "shipopts";
		$sql1 = "SELECT * from $table where shipitem = '$category'";
		$get_ship = mysql_query($sql1)
	or die("SQL command failed - Couldn't get shipping price for item.");
		while ($rows = mysql_fetch_array($get_ship))
		{
			$iprice = $rows["shipitemprice"];
			$iprice = number_format($iprice,2);
		}
		$sqt = $iprice;
		$sqt = number_format($sqt,2);
		$shiptotals = $shiptotals + $sqt;
		$shiptotals = number_format($shiptotals,2);
		echo "<tr><td>$sitems[$i]</td><td>$category</td><td>$iprice</td><td>$sqt</td></tr>";
		$i++;
	}
	$shiptotal = $shiptotals + $shiprates;
	$shiptotal = number_format($shiptotal,2);
	echo "</table></center>";
	
	if ($wcurrency == "NO")
	{
		$baskets = 0;
		$baskets = $fmt_itemtot + $shiptotal;
		$baskets = number_format($baskets,2);
		echo "<br><img src=./images/order.gif border=0 height=36>N.B <font color=red>Shipping Costs</font> = <b>($currency)$shiptotal</b> i.e. ($currency)$shiprates + ($currency)$shiptotals";
		echo "<br><br><center><font face=verdana size=2 color=navy> <b>Basket Total</b> = <b><u>$currency$baskets</b></u></font><br><br><img src=./images/line.gif border=0 height=1 width=485><br>";
	}
	if ($wcurrency != "NO")
	{
		echo "<br>N.B <font color=darkgreen>Shipping Costs</font> = <b>($wcurrency)$shiptotal</b> i.e. ($wcurrency)$shiprates + ($wcurrency)$shiptotals";
		$ctotal = 0;
		$crates = $shiprates;
		$stotals = 0;
		$stotals = $shiptotals;
		$basket = 0;
		if ($scurrency == "gbp") # display shipping for UK Sterling
		{
			$ctotal = $shiptotal * $conv1;
			$ctotal = number_format($ctotal,2);
			$crates = $shiprates * $conv1;
			$crates = number_format($crates,2);
			$stotals = $stotals * $conv1;
			$stotals = number_format($stotals,2);
			echo "<br><img src=./images/order.gif border=0 height=36>N.B <font color=darkgreen>Shipping Costs</font> = <b>$currency$ctotal</b> i.e. $currency$crates + $currency$stotals";
		}
		if ($scurrency == "usd")  # display shipping for US Dollars
		{
			$ctotal = $shiptotal * $conv2;
			$ctotal = number_format($ctotal,2);
			$crates = $shiprates * $conv2;
			$crates = number_format($crates,2);
			$stotals = $stotals * $conv2;
			$stotals = number_format($stotals,2);
			echo "<br><img src=./images/order.gif border=0 height=36>N.B <font color=darkgreen>Shipping Costs</font> = <b>$currency$ctotal</b> i.e. $currency$crates + $currency$stotals";
		}
		if ($scurrency == "eur")  # display shipping for Euros
		{
			$ctotal = $shiptotal * $conv3;
			$ctotal = number_format($ctotal,2);
			$crates = $shiprates * $conv3;
			$crates = number_format($crates,2);
			$stotals = $stotals * $conv3;
			$stotals = number_format($stotals,2);
			echo "<br><img src=./images/order.gif border=0 height=36>N.B <font color=darkgreen>Shipping Costs</font> = <b>$currency$ctotal</b> i.e. $currency$crates + 
$currency$stotals";
		}
		if ($scurrency == "jpy")  # display shipping for Yen
		{
			$ctotal = $shiptotal * $conv4;
			$ctotal = number_format($ctotal,2);
			$crates = $shiprates * $conv4;
			$crates = number_format($crates,2);
			$stotals = $stotals * $conv4;
			$stotals = number_format($stotals,2);
			echo "<br><img src=./images/order.gif border=0 height=36>N.B <font color=darkgreen>Shipping Costs</font> = <b>$currency$ctotal</b> i.e. $currency$crates + $currency$stotals";
		}
		if ($scurrency == "cad")  # display shipping for Can. Dollars
		{
			$ctotal = $shiptotal * $conv5;
			$ctotal = number_format($ctotal,2);
			$crates = $shiprates * $conv5;
			$crates = number_format($crates,2);
			$stotals = $stotals * $conv5;
			$stotals = number_format($stotals,2);
			echo "<br><img src=./images/order.gif border=0 height=36>N.B <font color=darkgreen>Shipping Costs</font> = <b>$currency$ctotal</b> i.e. $currency$crates + $currency$stotals";
		}
		$basket = $convert + $ctotal;
		echo "<br><br><center><font face=verdana size=2 color=navy> <b>Basket Total</b> = <b><u>$currency$basket</b></u></font><br><br><img src=./images/line.gif border=0 height=1 width=485><br>";
	}
}

############# display which countries in zone 1, zone 2, zone 3 ############################

if ($wcurrency != "NO"){
echo "<br><br><center><img src=images/zone1.gif border=0 alt=Zone 1 height=24><p align=justify><font face=verdana size=2>Norway, Poland, Romania, Russia, Sweden, Switzerland, France, Italy, Germany, Belguim, Spain, United Kingdom, Ireland, Portugal, Holland, Greece, Luxembourg.</font></p></center>";
echo "<br><center><img src=images/zone2.gif border=0 alt=Zone 2 height=24><p align=justify><font face=verdana size=2>Brunei, China, Hong Kong, India, Indonesia, Phillippines, Kuwait, Saudi Arabia, Malaysia, Singapore, South Korea.</font></p></center>";
echo "<br><center><img src=images/zone3.gif border=0 alt=Zone 3 height=24><p align=justify><font face=verdana size=2>Thailand, Vietnam, Taiwan, South Africa, Argentina, Brazil, New Zealand.</font></p></center><br><br><br>";}
	}
	}
}
}
?>
</body>
</html>




