<?php 

	/*
	** File: basket
	** Description: show basket contents
	** Version: $Revision: 1.13 $
	** Created: 06/08/1999
	** Author: Leon Atkinson, Shannon -jj Behrens
	** Email: leon@clearink.com, jj@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 1999/11/15 19:23:24 $
	**
	** Log : $Log: basket,v $
	** Log : Revision 1.13  1999/11/15 19:23:24  leon
	** Log : Localized nav modules
	** Log :
	** Log : Revision 1.12  1999/11/09 21:00:21  leon
	** Log : Made links to order_express and order_info go in secure mode.
	** Log :
	** Log : Revision 1.11  1999/09/29 23:40:21  jj
	** Log : Cleaned up basket a bit and was able to trim off a database query. Hopefully I haven't caused any side effects :)
	** Log :
	** Log : Revision 1.10  1999/09/28 19:02:38  jj
	** Log : Icorporated Isaac's bug fix (sale prices ignored in navigation basket).
	** Log :
	** Log : Revision 1.9  1999/08/20 16:58:39  leon
	** Log : Un-doing JJ's re-fix.  SalePrice is the correct name of the variable.
	** Log :
	** Log : Revision 1.7  1999/08/20 16:21:52  leon
	** Log : Fixed typo: SalesPrice instead of SalePrice
	** Log :
	** Log : Revision 1.6  1999/08/17 17:59:04  jj
	** Log : Your basket \ empty -> Your basket \ is empty. (go ahead and make fun of me)
	** Log :
	** Log : Revision 1.5  1999/08/10 22:49:42  leon
	** Log : Added "Express Order" screen that allows the user to set shippng and
	** Log : info all on one page.  It was added to the side nav, too.
	** Log :
	** Log : Revision 1.4  1999/07/28 19:27:26  leon
	** Log : Mass update based on code donation from a live project
	** Log :
	**
	** Copyright (c) 1999 Working Dogs.  All rights reserved.
	*/



	/*
	** Start the page with a link to the "contents" screen.
	*/
	print("<BR>\n");
	print("<A HREF=\"" . ScreenURL("contents") . "\">");
	print(L_NAV_BASKET_CONTENTS);
	print("</A><BR>\n");

	/*
	** Retrieve all of the items in the user's cart.
	*/
	$Query = "SELECT ss.Quantity, s.ID, s.Name, s.ListPrice, s.SalePrice ";
	$Query .= "FROM session_sku ss, sku s ";
	$Query .= "WHERE ss.SKU = s.ID ";
	$Query .= "AND ss.Session = '$sid' ";
	$DatabaseResult = mysql_query($Query, $DatabaseLink);
	if (!mysql_num_rows($DatabaseResult))
	{
		/* Continue line from above: "Your basket<BR>is empty." */
		print(L_NAV_BASKET_EMPTY);
	}
	else 
	{
		/* List the items in a table. */
		$order_Total = 0.00;
		print("<TABLE>\n");
		while ($row = mysql_fetch_row($DatabaseResult))
		{
			/* Parse the row. */
			list($sku_Quantity, $sku_ID, $sku_Name, $sku_Price, $sku_SalePrice) = $row;
			$sku_Price = ($sku_SalePrice > 0) ? $sku_SalePrice : $sku_Price;
			$sku_Price *= $sku_Quantity;
			$order_Total += $sku_Price;

			/* Output the row. */
			print("<TR>\n");
			print("<TD><FONT SIZE=\"1\">$sku_Quantity</FONT></TD>\n");
			print("<TD><FONT SIZE=\"1\">$sku_Name</FONT></TD>\n");
			print("<TD><FONT SIZE=\"1\">\$" . number_format($sku_Price,2) . 
				"</FONT></TD>\n");
			print("</TR>\n");
		}

		/* Output totals. */
		print("<TR>\n");
		print("<TD ALIGN=\"right\" COLSPAN=\"2\">");
		print("<FONT SIZE=\"1\">total</FONT>");
		print("</TD>\n");

		print("<TD>");
		print("<FONT SIZE=\"1\">\$" . number_format($order_Total,2) . "</FONT>");
		print("</TD>\n");
		print("</TR>\n");
		print("</TABLE>\n");

		/* Links for people with stuff in their basket. */
		print("<A HREF=\"" . ScreenURL("order_info", TRUE) . "&amp;ACTION=CREATE_INVOICE\">");
		print(L_NAV_BASKET_CHECKOUT);
		print("</A><BR>\n");

		print("<A HREF=\"" . ScreenURL("order_express", TRUE) . "&amp;ACTION=CREATE_INVOICE\">");
		print(L_NAV_BASKET_EXPRESS);
		print("</A><BR>\n");

		/* Anonymous users have no wishlist. */
		if ($UserInfo["ID"] > 0)
		{
			print("<A HREF=\"" . ScreenURL("wishlist") . "&amp;ACTION=SAVE_BASKET\">");
			print(L_NAV_BASKET_WISHLIST);
			print("</A><BR>\n");
		}
	}

?>
