<?php 

	/* 
	** File: ADD_STATUS
	** Description: Allow company personnel to add records to the invoice_status 
	**   table in connection with a particular invoice.
	** Version: $Revision: 1.4 $
	** Created: 7/13/99
	** Author: Shannon -jj Behrens
	** Email: shannon.behrens@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 1999/12/09 23:23:17 $
	**
	** Log : $Log: ADD_STATUS,v $
	** Log : Revision 1.4  1999/12/09 23:23:17  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.3  1999/11/09 21:47:11  leon
	** Log : More localization.
	** Log :
	** Log : Revision 1.2  1999/08/18 22:31:45  leon
	** Log : Returning opening PHP tag to XML-friendly tag
	** Log :
	** Log : Revision 1.1  1999/07/28 21:16:40  leon
	** Log : New actions based on code donation from a live project
	** Log :
	**
	** Copyright (c) 1999 Working Dogs. All rights reserved. 
	**
	** Expected input: $invoice_ID, $inputStatus, $inputDescription.
	*/

	
	/* Make sure the user has admin rights. */
	if( !$UserInfo["Permission"]["Administrate"] )
	{
		print(L_ADDSTATUS_DENIED . "<BR>\n");
	}
	else
	{
		$query = "INSERT INTO invoice_status " . 
			"(Invoice, Status, Created, Description) ";
		$query .= "VALUES (";
		$query .= intval($invoice_ID) . ", ";
		$query .= intval($inputStatus) . ", ";
		$query .= "now(), ";
		$query .= "'" . addslashes( substr($inputDescription, 0, 255) ) . "')";
		/* Execute the query. */
		if (!mysql_query($query, $DatabaseLink))
		{
			$ActionResults[] = "Error: " . mysql_errno() . " which means " . 
				mysql_error() . "   Query was: $query";
		}
		else 
		{
			$ActionResults[] = L_ADDSTATUS_SUCCESS;
		}
	}

?>
		
