<?php
/***************************************************************************
 *                              shop_showalls.php		           *
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~	                   *	
 *   File Info:		  Lists all products                               *
 *   Copyright:      Copyright 2003 http://www.128concepts.com             *
 *	                       				                   *
 **************************************************************************/
include ("./tests.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Shopping Menu</TITLE>
<script language="JavaScript">
function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}
</script>
</HEAD>
<BODY>

<?php
include ("./config.php");


######################### if first time...url will contain PHPSESSID=xxxx         #############################
######################### code below will refresh page to remove PHPSESSID #############################
$strvar = getenv("QUERY_STRING");
$pos = strpos($strvar,'&');
if ($pos >= 0)
	@header("Location:shop_showall.php");

# code to get no. of products from database.

$table= "products";
$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.");
$itemcount = "SELECT pid FROM $table";
$res = mysql_query($itemcount,$conn);
$nprods = mysql_num_rows($res);


echo "<p align=center><img src=images/shopbag2.gif border=0><font face=verdana size=3 color=black><b>Shopping Menu - View All Products</b></font></p>";	
?>
<?php

include("./config.php");

$table = "products";
$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.");
$sql = " SELECT * from $table order by pid";
$rs = mysql_query($sql,$conn)
	or die("Could not execute SQL query!!! Possibly SQL query already been executed.");

# style 1/2 display

if ($style == 1 or $style == 2)
{
	$list = "<br><table border =\"1\" cellpadding =\"2\" cellspacing=\"0\" align=center width=100%>";
	$list.="<tr ><th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Product ID</font></font></th>";
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Image</font></font></th>";
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Product Item</font></font></th>";
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Product Description/Specifications</font></font></th>";
	if ($wcurrency == "NO")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price $currency</font></font></th>";
	if ($wcurrency == "ARS")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Peso)</font></font></th>";
	if ($wcurrency == "BRL")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Real)</font></font></th>";
	if ($wcurrency == "BND")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Brunei Dollar)</font></font></th>";
	if ($wcurrency == "CNY")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (RMB)</font></font></th>";
	if ($wcurrency == "EGY")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Egypt Pound)</font></font></th>";
	if ($wcurrency == "HKD")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (HK Dollar)</font></font></th>";
	if ($wcurrency == "INR")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (India Rupee)</font></font></th>";
	if ($wcurrency == "IDR")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Indonesia Rupiah)</font></font></th>";
	if ($wcurrency == "KWD")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Kuwait Dinar)</font></font></th>";
	if ($wcurrency == "MYR")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Ringgit)</font></font></th>";
	if ($wcurrency == "NZD")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (NZ Dollar)</font></font></th>";
	if ($wcurrency == "NOR")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Krone)</font></font></th>";
	if ($wcurrency == "PKR")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Pakistan Rupee)</font></font></th>";
	if ($wcurrency == "PHP")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Phillip. Peso)</font></font></th>";
	if ($wcurrency == "PLN")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Zloty)</font></font></th>";
	if ($wcurrency == "ROL")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Leu)</font></font></th>";
	if ($wcurrency == "RUR")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Ruble)</font></font></th>";
	if ($wcurrency == "SAR")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Riyal)</font></font></th>";
	
	if ($wcurrency == "ZAR")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Rand)</font></font></th>";
	if ($wcurrency == "SGD")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Singapore Dollar)</font></font></th>";
	if ($wcurrency == "KWR")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (S.Korea Won)</font></font></th>";
	if ($wcurrency == "SEK")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Krona)</font></font></th>";
	if ($wcurrency == "CHF")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Swiss Franc)</font></font></th>";
	if ($wcurrency == "TWD")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Taiwan Dollar)</font></font></th>";
	if ($wcurrency == "THB")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Thailand Baht)</font></font></th>";
	if ($wcurrency == "VND")
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Price (Vietnam Dong)</font></font></th>";
	$list.="<th bgcolor=#CCCCCC><font face=verdana size=2><font face=verdana color=darkred>Order/Info/Category/Stock</font></font></th>";
	$list.="</tr>";
}

while($row = mysql_fetch_array($rs))
{
	$pid = $row["pid"];
	$pitem = $row["pitem"];
	$pdes = $row["pdes"];
	$price= $row["price"];
	$price = number_format($price,2);

	################ code to display picture thumbnail ################

	$table = "stocks";
	$sqlone = "SELECT * from $table where pid = $pid";
	$resultx = @mysql_query($sqlone,$conn)
	or die("SQL command fail - ".mysql_error());
	$getrows = mysql_fetch_array($resultx);
	$picture = $getrows["spic"];
	$scat = $getrows["scat"];
	$stock = $getrows["stock"];

	if (fopen($picture,"r") == NULL)
		$picture = "./images/nopic.jpg";	// set to no picture thumbnail
	if ($scat == NULL)
		$scat = "n/a";
	if ($stock == NULL or $stock <= 0)
		$stock = "No Stock";

	#############################################################
	# style 1 display
	
	if ($style == 1 or $style ==2)
	{
		$list.= "<tr><font face=verdana size=2>";
		$list.="<td align=center bgcolor=#ACD7E3>".$row["pid"]."</td>";
		$list.="<td><img src=$picture border=0 width=64 size=64 alt=Image></td>";
		$list.="<td bgcolor=#bbeeeb>$price</td>";
		$list.="<td bgcolor=#bbdaeb>$pdes</td>";
		if ($wcurrency == "NO")
			$list.="<td>$price</td>";
		if ($wcurrency == "ARS")
			$list.="<td><img src = ./images/argntina.gif>$price</td>";
		if ($wcurrency == "BRL")
			$list.="<td><img src = ./images/brazil.gif>$price</td>";
		if ($wcurrency == "BND")
			$list.="<td><img src = ./images/brunei.gif>$price</td>";
		if ($wcurrency == "CNY")
			$list.="<td><img src = ./images/china.gif>$price</td>";
		if ($wcurrency == "EGY")
			$list.="<td><img src = ./images/egypt.gif>$price</td>";
		if ($wcurrency == "HKD")
			$list.="<td><img src = ./images/hngkng97.gif>$price</td>";
		if ($wcurrency == "INR")
			$list.="<td><img src = ./images/india.gif>$price</td>";
		if ($wcurrency == "IDR")
			$list.="<td><img src = ./images/indonsia.gif>$price</td>";
		if ($wcurrency == "KWD")
			$list.="<td><img src = ./images/kuwait.gif>$price</td>";
		if ($wcurrency == "MYR")
			$list.="<td><img src = ./images/malaysia.gif>$price</td>";
		if ($wcurrency == "NZD")
			$list.="<td><img src = ./images/newzeal.gif>$price</td>";
		if ($wcurrency == "NOR")
			$list.="<td><img src = ./images/norway.gif>$price</td>";
		if ($wcurrency == "PKR")
			$list.="<td><img src = ./images/pakistan.gif>$price</td>";
		if ($wcurrency == "PHP")
			$list.="<td><img src = ./images/phillipn.gif>$price</td>";
		if ($wcurrency == "PLN")
			$list.="<td><img src = ./images/poland.gif>$price</td>";
		if ($wcurrency == "ROL")
			$list.="<td><img src = ./images/romania.gif>$price</td>";
		if ($wcurrency == "RUR")
			$list.="<td><img src = ./images/russia.gif>$price</td>";
		if ($wcurrency == "SAR")
			$list.="<td><img src = ./images/saudiar.gif>$price</td>";
		if ($wcurrency == "SGD")
			$list.="<td><img src = ./images/singapor.gif>$price</td>";
		if ($wcurrency == "ZAR")
			$list.="<td><img src = ./images/safrica.gif>$price</td>";
		if ($wcurrency == "KWR")
			$list.="<td><img src = ./images/skorea.gif>$price</td>";
		if ($wcurrency == "SEK")
			$list.="<td><img src = ./images/sweden.gif>$price</td>";
		if ($wcurrency == "CHF")
			$list.="<td><img src = ./images/switzrld.gif>$price</td>";
		if ($wcurrency == "TWD")
			$list.="<td><img src = ./images/taiwan.gif>$price</td>";
		if ($wcurrency == "THB")
			$list.="<td><img src = ./images/thailand.gif>$price</td>";
		if ($wcurrency == "VND")
			$list.="<td><img src = ./images/vietnam.gif>$price</td>";
		
		$list.="<td bgcolor=#dfdfdf><font face=verdana size=2 color=navy>Order</font><a href=\"shop_showitem.php?pid=$pid\"><img src =./images/carts.gif border = 0 alt=Order></a><a href=\"images.php?$pid\"><font face=verdana size=2 color=blue>Info</font><img src =./images/search.gif border = 0 alt=Info></a>
		<br><font face=verdana size=2 color=#000000>$scat</font><br><font face=verdana size=2 color=#000080>[$stock]</font></td>";
		$list.="</tr></font>";
	}
}

# style 1/2 
if ($style == 1 or $style ==2)
$list.= "</table>";
$list.="<p align=left><a href=javascript:history.back()><img src=images/previous-page.gif border = 0 height=22 width = 200></a></p>";
$list.= "<p align=right><A href=.\shop_viewcart.php><font face=verdana size=2 color=darkred>View Shopping Basket</font></a><A href=.\shop_checkout.php><IMG src=./images/cart.gif width=42 height=50 border=0 alt=Cart></A></p>";
echo($list);

?>

</BODY>
</HTML>