<?php

	/*
	** File: ADD_BASKET
	** Description: add a sku to the basket
	** Version: 1.1
	** Created: 04/22/1999
	** Author: Leon Atkinson
	** Email: leon@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 2000/01/03 21:22:25 $
	**
	** Log : $Log: ADD_BASKET,v $
	** Log : Revision 1.11  2000/01/03 21:22:25  leon
	** Log : Adding a bit of error checking
	** Log :
	** Log : Revision 1.10  1999/12/09 23:23:16  leon
	** Log : Changed ActionResults use so that it's an array instead of a
	** Log : continually-growing string.  Note the little function in standard_library
	** Log : for printing out all the action results.
	** Log :
	** Log : Revision 1.9  1999/12/07 18:30:08  leon
	** Log : Fixed bug with columns not matching table.
	** Log :
	** Log : Revision 1.8  1999/11/09 21:47:10  leon
	** Log : More localization.
	** Log :
	** Log : Revision 1.7  1999/11/09 00:28:13  leon
	** Log : Changed use of notes column.  This column now stores an array of variation
	** Log : IDs in serialized form.  Names for attributes and variations are pulled
	** Log : from the database using two new functions in the attribute_functions
	** Log : include module.
	** Log :
	** Log : Revision 1.6  1999/10/26 22:32:20  leon
	** Log : Added "Add to Wishlist" button to item and quick_order pages.
	** Log :
	** Log : Revision 1.5  1999/08/18 22:31:44  leon
	** Log : Returning opening PHP tag to XML-friendly tag
	** Log :
	** Log : Revision 1.4  1999/07/28 19:27:10  leon
	** Log : Mass update based on code donation from a live project
	** Log :
	**
	** Copyright (c) 1999 Working Dogs.  All rights reserved.
	*/

	/*
	** build notes column
	*/

	//Prep data for inclusion in the database
	$notes = serialize($inputVariation);
	$sku = (integer)$sku;
	
	//validate
	if($sku <= 0)
	{
		$ActionResults[] = L_ADD_BASKET_BADSKU;
	}
	else
	{

		//check for wishlist button and user being logged in
		if(isset($wishlist_button) AND ($UserInfo["ID"]>0))
		{
			//insert into wishlist
			$Query = "INSERT INTO user_sku (User, SKU, Quantity, Notes) VALUES ";
			$Query .= "(" . $UserInfo["ID"] . ", $sku, 1, '$notes') ";
		}
		else
		{
			//insert into basket
			$Query = "INSERT INTO session_sku (Session, SKU, Quantity, Notes) VALUES ";
			$Query .= "('$sid', $sku, 1, '$notes') ";
		}
		
		//execute query
		if(!mysql_query($Query, $DatabaseLink))
		{
			$ActionResults[] =  mysql_errno() . ": " . mysql_error();
		}
		else
		{
			$ActionResults[] = L_ADD_BASKET_SUCCESS;
		}
	}
?>
