<?php
	/*
	** File: fee
	** Description: functions for dealing with fees
	** Created: 10/22/1999
	** Author: Leon Atkinson
	** Email: leon@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 1999/12/16 21:58:43 $
	**
	** Log : $Log: fee,v $
	** Log : Revision 1.3  1999/12/16 21:58:43  leon
	** Log : Refactored calculateTotal.  Now with fewer queries! Gift Wrap was being
	** Log : refered to as GiftWrap in the array returned by calculateTotal, so I changed
	** Log : it in the few places it was.  That allowed me to use a general strategy
	** Log : for storing fee totals.
	** Log :
	** Log : Revision 1.2  1999/11/02 19:26:06  leon
	** Log : Added code to stop double includes
	** Log :
	** Log : Revision 1.1  1999/10/23 00:01:07  leon
	** Log : Function module to get the ID of a fee based on its name.
	** Log :
	**
	** Copyright (c) 1999 Working Dogs.  All rights reserved.
	*/

	$included_flag = 'INCLUDE_' . basename(__FILE__);
	
	if(defined($included_flag))
		//if this module has been included already, then the
		//constant will be defined.  Note the unusual use of
		//the return statement here.  Control will return to
		//the file that included it.
		return;
	
	define($included_flag, TRUE);	

	function getFeeID($feeName)
	{
		GLOBAL $DatabaseLink;
		STATIC $fee;
		
		if(!is_array($fee))
		{
			//pull fee table into array
			$Query = "SELECT ID, Name ";
			$Query .= "FROM fee ";
			$DatabaseResult = mysql_query($Query, $DatabaseLink);
			while($DatabaseRow = mysql_fetch_object($DatabaseResult))
			{
				$fee[($DatabaseRow->Name)] = $DatabaseRow->ID;
			}			
		}

		return(intval($fee[$feeName]));
	}

	function getFeeName($feeID)
	{
		GLOBAL $DatabaseLink;
		STATIC $fee;
		
		if(!is_array($fee))
		{
			//pull fee table into array
			$Query = "SELECT ID, Name ";
			$Query .= "FROM fee ";
			$DatabaseResult = mysql_query($Query, $DatabaseLink);
			while($DatabaseRow = mysql_fetch_object($DatabaseResult))
			{
				$fee[($DatabaseRow->ID)] = $DatabaseRow->Name;
			}			
		}

		return($fee[$feeID]);
	}
	
?>