<?php
	/*
	** File: UPDATE_BASKET
	** Description: update the quantities for basket
	** Version: $Revision: 1.7 $
	** Created: 04/24/1999
	** Author: Leon Atkinson
	** Email: leon@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 2000/01/03 21:35:26 $
	**
	** Log : $Log: UPDATE_BASKET,v $
	** Log : Revision 1.7  2000/01/03 21:35:26  leon
	** Log : Added upper limit to quantity
	** Log :
	** Log : Revision 1.6  1999/12/09 23:23:24  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.5  1999/11/02 19:09:45  leon
	** Log : Localized the UPDATE action modules
	** Log :
	** Log : Revision 1.4  1999/08/18 22:31:53  leon
	** Log : Returning opening PHP tag to XML-friendly tag
	** Log :
	** Log : Revision 1.3  1999/07/28 19:27:15  leon
	** Log : Mass update based on code donation from a live project
	** Log :
	**
	** Copyright (c) 1999 Working Dogs.  All rights reserved.
	*/

	//loop over each line item
	for(reset($inputBasket); $key = key($inputBasket); next($inputBasket))
	{
		//clean input data
		$key = (integer)$key;
		$inputBasket[$key] = (integer)$inputBasket[$key];

		if($inputBasket[$key] > MAX_QUANTITY)
		{
			$ActionResults[] = L_UPDATEBASKET_BADQUANTITY;
		}
		else
		{
			if($inputBasket[$key] <= 0)
			{
				//delete item
				$Query = "DELETE FROM session_sku WHERE ID=$key";
			}
			else
			{
				//update quantity
				$Query = "UPDATE session_sku ";
				$Query .= "SET Quantity=" . intval($inputBasket[$key]) . " ";
				$Query .= "WHERE ID=" . intval($key);
			}
		
			//execute query
			if(!mysql_query($Query, $DatabaseLink))
			{
				$ActionResults[] =  mysql_errno() . ": " . mysql_error();
			}
		}
	}

	$ActionResults[] = L_UPDATEBASKET_SUCCESS;
?>
