<?php
	/*
	** File: functionDateSelector
	** Description: Container for DateSelector
	** Version: $Revision: 1.4 $
	** Created: 10/10/98
	** Author: Leon Atkinson, Shannon Behrens
	** Email: leon@clearink.com, shannon.behrens@clearink.com
	** CVS Author: $Author: chris $
	** Last Revised: $Date: 1999/11/02 18:23:08 $
	**
	** Log : $Log: DateSelector,v $
	** Log : Revision 1.4  1999/11/02 18:23:08  chris
	** Log : Added support for coupons.
	** Log :
	** Log : Revision 1.3  1999/10/11 23:04:01  leon
	** Log : Removed all require()'s, added block to stop double include()'s
	** Log :
	** Log : Require wasn't giving any performance advantage because it was always
	** Log : being called with a variable.  Futhermore, using return inside a
	** Log : require()'d file does not work in PHP4.
	** Log :
	** Log : Revision 1.2  1999/08/18 22:32:02  leon
	** Log : Returning opening PHP tag to XML-friendly tag
	** Log :
	** Log : Revision 1.1  1999/07/28 21:18:32  leon
	** Log : New include modules based on code donation from a live project
	** Log :
	**
	** Copyright 1998 Clear Ink Corporation
	*/


	/*
	** Ensure that module isn't included twice
	*/

	$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: DateSelector
	** Input: STRING $inName, [INTEGER $useDate]
	** Output: 
	** Description: Creates three form fields for get month/day/year.
	**   $useDate is seconds since the epoch. It's default is time().
	**   $inName is the "prefix" to be used when naming the html elements.
	*/
	function DateSelector($inName, $useDate="")
	{
		$monthName = array(1=>"January", "February", "March",
		"April", "May", "June", "July", "August",
		"September", "October", "November", "December");
		
		if($useDate == "")
		{
			$useDate = Time(); 
		}

		print("<SELECT NAME=\"" . $inName . "Month\">\n");
		for($currentMonth = 1; $currentMonth <= 12; $currentMonth++)
		{
			echo "<OPTION VALUE=\"";
			echo intval($currentMonth);
			echo "\"";
			if(intval(date("m", $useDate))==$currentMonth)
			{
				echo " SELECTED";
			}
			echo ">".$monthName[$currentMonth]."\n";
		}
		echo "</SELECT>\n";
		
		echo "<SELECT NAME=\"" . $inName . "Day\">\n";
		for($currentDay=1; $currentDay <= 31; $currentDay++)
		{
			echo "<OPTION VALUE=\"$currentDay\"";
			if(intval(date("d", $useDate))==$currentDay)
			{
				echo " SELECTED";
			}
			echo ">$currentDay\n";
		}
		echo "</SELECT>\n";
			
		echo "<SELECT NAME=\"" . $inName . "Year\">\n";
		$startYear = date("Y", $useDate);
		if($startYear < 1997)
		{
			$startYear = date("Y");
		}
		
		for($currentYear = 1997; $currentYear <= $startYear+1;$currentYear++)
		{
			echo "<OPTION VALUE=\"$currentYear\"";
			if(date("Y", $useDate)==$currentYear)
			{
				echo " SELECTED";
			}
			echo ">$currentYear\n";
		}
		echo "</SELECT>\n";
	}
?>
