<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
<HTML>
<HEAD>
<TITLE>Shopping Cart Contents - Update Cart</TITLE>
</HEAD>
<BODY>
<?
/***************************************************************************
 *			shop_updcart.php                                   *
 *                     	          				           *
 *   File Info:		  Update shopping cart                             *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           *
 ***************************************************************************/
include ("config.php");
include ("./your-header.inc");
include ("./tests.php");
echo "<center><img src=images/mouses.gif border=0><font face = Verdana size =4 color=navy>  Shopping Menu: Updating Your Shopping Cart</font><center><br><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=650 border=0>
       <TBODY>";

$table= "myorders";
$sel_item_totalprice = $sel_item_qty * $sel_item_price;
$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 = \"$user_id\"";
$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 ($itemtot < $min_cost) {
	$shipping = $shipcost;
} else {
	$shipping = 0;
}
$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);

$item_count = "SELECT SUM(SEL_ITEM_QTY) FROM $table
		WHERE USER_ID = \"$user_id\"";

$item_result = mysql_query($item_count) 
	or die("SQL command failed - Couldn't get count");
$sub_total = number_format(($fmt_itemtot + $shipping),2);
$item_count_total = mysql_result($item_result,0,"SUM(SEL_ITEM_QTY)");

$disp = "false";
if ($num_rows == "0") 
{
$title= "<tr><td align=center><img src=images/cart-contents.gif border=0></td></tr>";
echo($title);
	echo "<tr><td align=center><font color = darkred face=verdana size=2>There are no items in your cart.</font></center></td></tr>";
$disp = "true";
} 
else 
{
if ($wcurrency != "NO")
{			$lists = "<tr><td><br></td></tr>";
	   	if ($wcurrency == "ARS")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/argntina.gif></FONT></td></tr>";
		if ($wcurrency == "BRL")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/brazil.gif></FONT></td></tr>";
		if ($wcurrency == "BND")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/brunei.gif></FONT></td></tr>";
		if ($wcurrency == "CNY")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/china.gif></FONT></td></tr>";
		if ($wcurrency == "EGY")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/egypt.gif></FONT></td></tr>";
		if ($wcurrency == "HKD")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/hngkng97.gif></FONT></td></tr>";
		if ($wcurrency == "INR")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/india.gif></FONT></td></tr>";
		if ($wcurrency == "IDR")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/indonsia.gif></FONT></td></tr>";
		if ($wcurrency == "KWD")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/kuwait.gif></FONT></td></tr>";
		if ($wcurrency == "MYR")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/malaysia.gif></FONT></td></tr>";
		if ($wcurrency == "NZD")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/newzeal.gif></FONT></td></tr>";
		if ($wcurrency == "NOR")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/norway.gif></FONT></td></tr>";
		if ($wcurrency == "PKR")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/pakistan.gif></FONT></td></tr>";
		if ($wcurrency == "PHP")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/phillipn.gif></FONT></td></tr>";
		if ($wcurrency == "PLN")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/poland.gif></FONT></td></tr>";
		if ($wcurrency == "ROL")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/romania.gif></FONT></td></tr>";
		if ($wcurrency == "RUR")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/russia.gif></FONT></td></tr>";
		if ($wcurrency == "SAR")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/saudiar.gif></FONT></td></tr>";
		if ($wcurrency == "ZAR")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/safrica.gif></FONT></td></tr>";
		if ($wcurrency == "KRW")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/skorea.gif></FONT></td></tr>";
		if ($wcurrency == "SEK")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/sweden.gif></FONT></td></tr>";
		if ($wcurrency == "CHF")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/switzrld.gif></FONT></td></tr>";
		if ($wcurrency == "TWD")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/taiwan.gif></FONT></td></tr>";
		if ($wcurrency == "THB")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/thailand.gif></FONT></td></tr>";
		if ($wcurrency == "VND")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/vietnam.gif></FONT></td></tr>";
		if ($wcurrency == "SGD")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/singapor.gif></FONT></td></tr>";
		if ($wcurrency == "USD")
			$lists.="<tr><td align=center><FONT name = Verdana color = 007700 size = 2>Shopping Cart using world currency of ($wcurrency) <img src = ./images/usa.gif></FONT></td></tr>";
		echo $lists;
}

$list= "<tr><td><br></td></tr><tr><td align=center><table border=1 cellpadding=2 cellspacing=0 align = center bgcolor=$backcolor width=100%>";
$list.= "<tr>";
$list.="<td align=center bgcolor=#CCCCCC><strong>INDEX</strong></td>";
$list.="<td align=center bgcolor=#CCCCCC><strong>QUANTITY</strong></td>";
$list.="<td align=center bgcolor=#CCCCCC><strong>PRODUCT ITEM</strong></td>";
$list.="<td align=center bgcolor=#CCCCCC><strong>DESCRIPTION</strong></td>";
$list.="<td align=center bgcolor=#CCCCCC><strong width=100>PRODUCT PRICE</strong></td>";
$list.="<td align=center bgcolor=#CCCCCC width=100><strong>BASKET PRICE</strong></td>";
$list.="</tr>";
echo($list);
$a = 0;
$prods = array();
$quant =array();
while ($row = mysql_fetch_array($cart_result)) {
	$a += 1;
	$sel_item_qty = $row["SEL_ITEM_QTY"];
	$sel_item = $row["SEL_ITEM"];	
	$sel_item_title = $row["SEL_ITEM_TITLE"];
	$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);
	$prods[$a] = $sel_item;
	$quant[$a] = $sel_item_qty;
	$sel_items= str_replace(" ","%20",$sel_item);
	# display if no world currency
	if ($wcurrency == "NO")
	{
	
	$xl= "<tr><form action=./shop_updcarts.php?$a=$sel_items method=post>";
	$xl.="<td align = middle><li>$a
            	 <input type=submit value='Update'></td>";
	$xl.="<td align = middle><input type =text size =5 	name=sel_item_qty><li>[$sel_item_qty]</td>";
	$xl.="<td align = left>$sel_item</td>";
	$xl.="<td align=left>$sel_item_title</td>";
	$xl.="<td align=right>$currency $sel_item_price</td>";
	$xl.="<td align=right>$currency $fmt_item_totalprice</td>";	
	$xl.="</form></tr>";
	echo $xl;
	}else {
	# display other currency
	if ($wcurrency != "NO")
	$pl = "<tr><form action=./shop_updcarts.php?$a=$sel_items method=post>";
	$pl.="<td align = middle><li>$a<input type=submit value='Update'></td>";
	$pl.="<td align = middle><input type =text size = 5 name = sel_item_qty><li>[$sel_item_qty]</td>";
	$pl.="<td align = left>$sel_item</td><td align=left>$sel_item_title</td>";
	if ($wcurrency == "ARS")
		$pl.="<td align=right><img src = ./images/argntina.gif> $sel_item_price</td>";
	if ($wcurrency == "ARS")
		$pl.="<td align=right><img src = ./images/argntina.gif> $sel_item_totalprice</td>";
	if ($wcurrency == "BRL")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "BRL")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "BND")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "BND")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "CNY")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "CNY")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "EGY")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "EGY")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "HKD")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "HKD")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "INR")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "INR")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "IDR")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "IDR")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "KWD")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "KWD")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "MYR")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "MYR")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "NZD")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "NZD")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "NOR")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "NOR")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "PKR")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "PKR")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "PHP")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "PHP")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "PLN")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "PLN")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "ROL")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "ROL")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "RUR")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "RUR")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "SAR")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "SAR")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "ZAR")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "ZAR")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "KRW")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "KRW")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "SEK")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "SEK")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "CHF")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "CHF")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "TWD")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "TWD")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "THB")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "THB")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "VND")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "VND")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "SGD")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "SGD")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	if ($wcurrency == "USD")
		$pl.="<td align=right> $sel_item_price</td>";
	if ($wcurrency == "USD")
		$pl.="<td align=right> $sel_item_totalprice</td>";
	$pl.="</form></tr>";
	echo $pl;
	}}
}

if ($disp == "false")
echo("</table></td></tr>");
echo "<tr><td><p align=justify><img src=images/readme.gif border=0><font face=verdana size=1>  The shopping cart shows all products you wish to order ! To update a cart item, input new quantity and click on 'Update' link. The quantity value shown in the brackets is original quantity!</font></p></td></tr>";
echo "<tr><td align=center><font face=verdana size=1>Click icon to go to previous page</font><a href=javascript:history.back()><img src=images/back-to.gif border = 0 alt=Back></a></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>";

$new = "<br><table width=100% align = middle noborder = 0 noshade = 0><tr align=middle class=subtitle><td><a href=./shop_showall.php><img src = ./images/prodlist.gif border = 0></a><a href = ./shop_viewcart.php><img src =./images/viewcart.gif border =0></a><a href = ./shop_delcart.php><img src =./images/emptycart.gif border =0></a><a href = ./shop_updcart.php><img src = ./images/updatecart.gif border = 0></a></td></table>";
echo($new);
echo "<br><br>";
include ("./your-footer.inc");
?>

</BODY>
</HTML>
