<?php
	/*
	** File: department
	** Description: functions for dealing with departments
	** Created: 11/17/1999
	** Author: Leon Atkinson
	** Email: leon@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 1999/11/17 20:44:55 $
	**
	** Log : $Log: department,v $
	** Log : Revision 1.1  1999/11/17 20:44:55  leon
	** Log : I think we may need to use this to fix quick_order so that it can handle
	** Log : items in department zero.
	** 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 getDepartment($id)
	{
		GLOBAL $DatabaseLink;
		STATIC $department;
		
		if(!is_array($department))
		{
			//pull department table into array
			$Query = "SELECT ID, Name, Graphic, Parent, Description ";
			$Query .= "FROM department ";
			
			$DatabaseResult = mysql_query($Query, $DatabaseLink);

			while($DatabaseRow = mysql_fetch_object($DatabaseResult))
			{
				$department[($DatabaseRow->ID)]["Name"] = $DatabaseRow->Name;
				$department[($DatabaseRow->ID)]["Graphic"] = $DatabaseRow->Graphic;
				$department[($DatabaseRow->ID)]["Parent"] = $DatabaseRow->Parent;
				$department[($DatabaseRow->ID)]["Description"] = $DatabaseRow->Description;
			}			
		}

		return($department[$id]);
	}
	
?>