{include_php file="shared_handle:company_management/reports/general"}
<h1>{$page.title}</h1>
<h2>{$smarty.session.company.companyName}</h2>

<hr />
<script src="js/js-get-data.js"></script>

<div style="width:400px;">
<h3 class="withBG">
	<div class="topRight hideShow">
		<a href="javascript:toggle('configure', '', 'showHide');"><img id="configure_img" src="./img/blank.gif" class="showHide_off" alt="show/hide" border="0" /></a></div> 
	Configure</h3>

<div id="configure" style="display:none; margin-left:20px;">
	<form method="get" action="index.php" style="margin:0px;">
	<input type="hidden" name="pg" value="{$page.name}" />

	<div style="float:right;"><small>&quot;Range Offset&quot; will allow each range to begin at an offset value.</small></div>

	<table>
	<tr>
		<td>Start Date:</td>
		<td><input type="text" name="begin" size="10" value="{$START_DATE|date_format2:"m/d/Y"}" />
	</tr>
	<tr>
		<td>End Date:</td>
		<td><input type="text" name="end" size="10" value="{$END_DATE|date_format2:"m/d/Y"}" />
	</tr>
	<tr>
		<td>Weight Range Size:</td>
		<td><input type="text" name="wrs" size="3" value="{$WEIGHT_RANGE_STEP}" style="text-align:right;" />
	</tr>
	<tr>
		<td>Weight Range Offset:</td>
		<td><input type="text" name="wro" size="3" value="{$WEIGHT_RANGE_OFFSET}" style="text-align:right;" />
	</tr>
	<tr>
		<td>BMI Range Size:</td>
		<td><input type="text" name="brs" size="3" value="{$BMI_RANGE_STEP}" style="text-align:right;" />
	</tr>
	<tr>
		<td>BMI Range Offset:</td>
		<td><input type="text" name="bro" size="3" value="{$BMI_RANGE_OFFSET}" style="text-align:right;" />
	</tr>
	<tr>
		<td>Age Range Size:</td>
		<td><input type="text" name="ars" size="3" value="{$AGE_RANGE_STEP}" style="text-align:right;" />
	</tr>
	<tr>
		<td>Age Range Offset:</td>
		<td><input type="text" name="aro" size="3" value="{$AGE_RANGE_OFFSET}" style="text-align:right;" />
	</tr>
	</table>

	<div align="right" style="clear:left;"><input type="submit" value="Submit" /></div>
	
	</form>
</div>
</div>

<hr />
<i>Report for data between <b>{$START_DATE|date_format2:"m/d/Y"}</b> and <b>{$END_DATE|date_format2:"m/d/Y"}</b>.</i>
<hr />

<table width="400">
{foreach from=$report key="sectionName" item="sectionData"}
	<tr>
		<td colspan="3"><h2 class="withBG">{$sectionName|niceText}</h2></td>
	</tr>
	{foreach from=$sectionData key="field" item="value"}
	{if $value|@is_array}
	<tr>
		<td width="25">&nbsp;</td>
		<td colspan="2">
			<h3 class="withBG">
				<div class="topRight hideShow">
					<a href="javascript:toggle('{$field}', '', 'showHide');"><img id="{$field}_img" src="./img/blank.gif" class="showHide_off" alt="show/hide" border="0" /></a></div> 
				{$field|niceText}</h3>
		</td>
	</tr>
	<tr>
		<td width="25">&nbsp;</td>
		<td colspan="2" bgcolor="#DDDDDD">
			<div id="{$field}" style="display:none;">
			<table border="0" width="99%">
			{foreach from=$value key="subField" item="subValue"}
			<tr>
				<td width="50%" align="right">
					{if $field|regex_match:"/Age/" and $subField neq "unknown"}
						{$subField} to {$subField+$AGE_RANGE_STEP-1} yrs.
					{elseif $field|regex_match:"/Weight/"}
						{$subField} to {$subField+$WEIGHT_RANGE_STEP-1} lbs.
					{elseif $field|regex_match:"/Bmi/"}
						{$subField} to {$subField+$BMI_RANGE_STEP-1}
					{elseif $field|regex_match:"/Exercise/"}
						{$subField|niceText}
					{else}
						{$subField|niceText}
					{/if}
				</td>
				<td width="50%" align="right">{$subValue}{if $subField|regex_match:"/percent/i"} %{/if}</td>
			</tr>
			{/foreach}
			</table>
			</div>
		</td>
	</tr>
	{else}
	<tr>
		<td width="25">&nbsp;</td>
		<td>{$field|niceText}</td>
		<td align="right">{if $value|regex_match:"/\.\d\d/"}{$value|number_format:2}{elseif $value|regex_match:"/\.\d/"}{$value|number_format:1}{elseif $value|regex_match:"/\d/"}{$value|number_format:0}{else}{$value}{/if}{if $field|regex_match:"/percent/i"} %{/if}</td>
	</tr>
	{/if}
	{/foreach}
{/foreach}
</table>

{if $acm->isDomainAdmin()}
<input type="button" value="TEST!" onclick="jsGetData('?pg=jsgetdata','graphFloater','reports.general');" />
<div id="graphFloater">
	<div id="gView_1" class="graphView">
	<div id="gSet_1" class="graphSet" style="display:block;">
		{section name="gSet1" loop=30}{assign var="gWidth" value=$gWidth|random:1:100}<div class="graphBar" style="width:{$gWidth}%;" onmouseover="setGraphContent(this);">Jan {$smarty.section.gSet1.iteration}.05 - 300lbs. ({$gWidth}%)</div>{/section}
		<img class="gView_1_sizer" src="blank.gif" width="1" height="1" alt="" />
	</div>
	
	<div id="gSet_2" class="graphSet" style="display:none;">
		{section name="gSet2" loop=30}{assign var="gWidth" value=$gWidth|random:1:100}<div class="graphBar" style="width:{$gWidth}%;" onmouseover="setGraphContent(this);">Jan {$smarty.section.gSet2.iteration}.05 - 300lbs. ({$gWidth}%)</div>{/section}
		<img class="gView_1_sizer" src="blank.gif" width="1" height="1" alt="" />
	</div>
	
	<div id="gSet_3" class="graphSet" style="display:none;">
		{section name="gSet3" loop=30}{assign var="gWidth" value=$gWidth|random:1:100}<div class="graphBar" style="width:{$gWidth}%;" onmouseover="setGraphContent(this);">Jan {$smarty.section.gSet3.iteration}.05 - 300lbs. ({$gWidth}%)</div>{/section}
		<img class="gView_1_sizer" src="blank.gif" width="1" height="1" alt="" />
	</div>
	</div>
	
	<h3>Legend:</h3>
	
	<table>
	<tr>
		<td><span id="gLabel_1">&nbsp;#1&nbsp;</span></td>
		<td><a href="javascript://" onclick="xToggle('gSet_1','','flag','on');graphToFront('gSet_1')">Graph 1 Title</a></td>
		<td><a href="javascript:xToggle('gSet_1','','flag');"><img class="flag_on" id="gSet_1_swap" src="blank.gif" width="1" height="1" alt="" /></a></td>
	</tr>
	<tr>
		<td><span id="gLabel_2">&nbsp;#2&nbsp;</span></td>
		<td><a href="javascript://" onclick="xToggle('gSet_2','','flag','on');graphToFront('gSet_2');">Graph 2 Title</a></td>
		<td><a href="javascript:xToggle('gSet_2','','flag');"><img class="flag_off" id="gSet_2_swap" src="blank.gif" width="1" height="1" alt="" /></a></td>
	</tr>
	<tr>
		<td><span id="gLabel_3">&nbsp;#3&nbsp;</span></td>
		<td><a href="javascript://" onclick="xToggle('gSet_3','','flag','on');graphToFront('gSet_3');">Graph 3 Title</a></td>
		<td><a href="javascript:xToggle('gSet_3','','flag');"><img class="flag_off" id="gSet_3_swap" src="blank.gif" width="1" height="1" alt="" /></a></td>
	</tr>
	</table>
	<br />
	
	<h3>Details:</h3>
	<div id="graphRowContent"></div>
</div>
{/if}
