<?php
require("../../inc/header.inc");
require("./function.inc");
?>
<script language="javascript">

</script>
<body onload="javascript:adjust();" onresize="javascript:adjust();" leftmargin="15" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;">
<?php
$configuration=parse_ini_file($conf,true);


adjust_head();

adjust_title_head();
echo "<form name=\"myform\" action=\"csta_result.php\" method=\"post\">";
echo "<table id=\"table_up\" border=\"0\" width=\"100%\">";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "{$configuration[All][Title]}";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
		showHelp($configuration[All][HelpID]);
		echo "</td>";
	echo "</tr>";
	echo "<tr>";
		echo "<td width=\"50%\">";
		echo "&nbsp;";
		echo "</td>";
		echo "<td width=\"50%\" align=\"right\" title=\"Clear\">";
		echo "&nbsp;";
		echo "</td>";
	echo "</tr>";
echo "</table>";
adjust_title_tail();
adjust_content_head();

echo "<br>{$configuration[All][SubTitle]}<br><br>";

if(0)
{
	echo "<pre>";
	print_r($configuration);
	echo "</pre>";
}


echo "<table border=\"1\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\" bordercolordark=\"#FFFFFF\" bgcolor=\"#ffffff\">";
echo "<tr bgcolor=\"#E6E6E6\">";
for($i=0;$i<$configuration[All][MainConditionCount];$i++)
{
	echo "<td>";
	
	$mainname=$configuration[All][MainConditionListName];	
	$ctlname=$configuration[$mainname][$i];
	$definename=$configuration[$ctlname][Define];
	if(strcasecmp($configuration[$ctlname][Flag],"enable") == 0)
	{
		if(strcasecmp($configuration[$ctlname][Type],"select") == 0)
		{
			$default=$configuration[$definename][DefaultValue];
			$valuecount=$configuration[$definename][ValueCount];
			echo "{$configuration[$ctlname][ShowName]}&nbsp;";
			echo "<select name=\"{$ctlname}\">";
			for($v=0;$v<$valuecount;$v++)
			{
					echo "<option value={$v}";
					if($v == $default)
						echo " selected";
					echo ">{$configuration[$definename][$v]}</option>";
			}
			echo "</select>";
		}
		else if(strcasecmp($configuration[$ctlname][Type],"checkbox") == 0)
		{
			$default=$configuration[$definename][DefaultValue];
			echo "<input type=\"checkbox\" name=\"$ctlname\"";
			if($default == 1)
				echo " checked";
			echo ">";
			echo "{$configuration[$ctlname][ShowName]}";
		}
	}
	echo "</td>";
}


echo "<td align=\"center\">";
echo "Start Time&nbsp;";
echo "<select>";
for($i=0;$i<$configuration[All][MaxInterval];$i++)
{
	$timestr=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$i,date("Y")));
	echo "<option value={$i}>{$timestr}</option>";
}
echo "</select>";
echo "</td>";


echo "<td align=\"center\">";
echo "End Time&nbsp;";
echo "<select>";
for($i=0;$i<$configuration[All][MaxInterval];$i++)
{
	$timestr=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$i,date("Y")));
	echo "<option value={$i}>{$timestr}</option>";
}
echo "</select>";
echo "</td>";


echo "<td align=\"right\">";
echo "<input type=submit value=\"Search\" class=button>";
echo "</td>";

echo "</tr>";


echo "<tr>";
echo "<td colspan=".($configuration[All][MainConditionCount]+3).">";

echo "<table border=0 width=100%>";
for($i=0;$i<$configuration[All][SubConditionCount];$i++)
{
	if($i%4 == 0)
		echo "<tr>";
	
	
	$mainname=$configuration[All][SubConditionListName];	
	$ctlname=$configuration[$mainname][$i];
	$definename=$configuration[$ctlname][Define];
	if(strcasecmp($configuration[$ctlname][Flag],"enable") == 0)
	{
		echo "<td>";
		if(strcasecmp($configuration[$ctlname][Type],"select") == 0)
		{
			$default=$configuration[$definename][DefaultValue];
			$valuecount=$configuration[$definename][ValueCount];
			echo "{$configuration[$ctlname][ShowName]}&nbsp;";
			echo "<select name=\"{$ctlname}\">";
			for($v=0;$v<$valuecount;$v++)
			{
					echo "<option value={$v}";
					if($v == $default)
						echo " selected";
					echo ">{$configuration[$definename][$v]}</option>";
			}
			echo "</select>";
		}
		else if(strcasecmp($configuration[$ctlname][Type],"checkbox") == 0)
		{
			$default=$configuration[$definename][DefaultValue];
			echo "<input type=\"checkbox\" name=\"$ctlname\"";
			if($default == 1)
				echo " checked";
			echo ">";
			echo "{$configuration[$ctlname][ShowName]}";
		}
		echo "</td>";
	}
	
}

echo "</table>";

echo "</td>";
echo "</tr>";


echo "</table>";

echo "<input type=hidden name=conf value=\"{$conf}\">";

echo "</form>";
adjust_content_tail();
?>

