<?php
	/*
	** File: DELETE_SKU
	** Description: Removes a SKU
	** Version: $Revision: 1.7 $
	** Created: 04/13/1999
	** Author: Leon Atkinson, Shannon -jj Behrens
	** Email: leon@clearink.com, jj@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 1999/12/09 23:23:20 $
	**
	** Log : $Log: DELETE_SKU,v $
	** Log : Revision 1.7  1999/12/09 23:23:20  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.6  1999/11/09 22:21:14  leon
	** Log : More localization work.
	** Log :
	** Log : Revision 1.5  1999/08/18 22:31:49  leon
	** Log : Returning opening PHP tag to XML-friendly tag
	** Log :
	** Log : Revision 1.4  1999/08/04 01:05:54  jj
	** Log : More item and department admin stuff: mostly adding stuff to DELETE scripts.
	** Log :
	** Log : Revision 1.3  1999/07/28 19:27:13  leon
	** Log : Mass update based on code donation from a live project
	** Log :
	**
	** Copyright (c) 1999 Working Dogs.  All rights reserved.
	*/

	$continueScript = TRUE;
	

	/* 
	** Make sure the user has admin rights. 
	*/
	if( !$UserInfo["Permission"]["Administrate"] )
	{
		$ActionResults[] = L_DELETESKU_DENIED;
		$continueScript = FALSE;
	}
	
	
	
	/* 
	** Make sure we have some form of valid data. 
	*/
	if ($continueScript)
	{
		if ( !isset($sku) || $sku <= 0 )
		{
			$ActionResults[] = L_DELETESKU_BADSKU;
			$SCREEN = "admin_menu";
		}
		else if ( !isset($item) || $item <= 0 )
		{
			$ActionResults[] = L_DELETESKU_BADITEM;
			$SCREEN = "edit_sku";
		}
	}
	
	
	
	/*
	** Delete the row from the sku table.
	*/
	if ($continueScript)
	{
		$Query = "DELETE FROM sku WHERE ID=" . intval($sku);
		if(!mysql_query($Query, $DatabaseLink))
		{
			$ActionResults[] = mysql_errno() . ": " . mysql_error() . 
				"   Query was $Query";
			$continueScript = FALSE;
		}
	}
	
	
	
	/*
	** Delete from inventory table. 
	*/
	if ($continueScript)
	{
		$Query = "DELETE FROM inventory WHERE SKU=" . intval($sku);
		if(!mysql_query($Query, $DatabaseLink))
		{
			$ActionResults[] = mysql_errno() . ": " . mysql_error() . 
				"   Query was $Query";
			$continueScript = FALSE;
		}
	}



	/* 
	** If nothing went wrong, send the user back to the appropriate screen.
	*/
	if ($continueScript)
	{
		$ActionResults[] = L_DELETESKU_SUCCESS;
		$SCREEN = "admin_item";
		/* $item is set. */
	}
	
?>
