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

<hr />

<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> 
	Select Survey and Date Range</h3>

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

	<table>
	<tr>
		<td>Survey Name:</td>
		<td colspan="3"><select name="surveyId">
			{foreach from=$surveyList key="surveyId" item="row"}
			<option value="{$surveyId}"{if $surveyId eq $requestedSurveyId} selected="selected"{/if}>{$row.surveyName}</option>
			{/foreach}</select>
	</tr>
	<tr>
		<td>Start Date:</td>
		<td><input type="text" name="begin" size="10" value="{$START_DATE|date_format2:"m/d/Y"}" /></td>
		<td>End Date:</td>
		<td><input type="text" name="end" size="10" value="{$END_DATE|date_format2:"m/d/Y"}" /></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td colspan="3"><input type="checkbox" name="compareDates" value="1" onclick="toggleCompareDates(this);"{if $comparingDates} checked="checked"{/if}> Compare to another date range?</td>
	</tr>
	<tr>
		<td><span id="compareDatesCell_1" style="display:{if $comparingDates}block{else}none{/if};">Start Date:</span></td>
		<td><span id="compareDatesCell_2" style="display:{if $comparingDates}block{else}none{/if};"><input type="text" name="begin2" size="10" value="{$START_DATE2|date_format2:"m/d/Y"}" /></span></td>
		<td><span id="compareDatesCell_3" style="display:{if $comparingDates}block{else}none{/if};">End Date:</span></td>
		<td><span id="compareDatesCell_4" style="display:{if $comparingDates}block{else}none{/if};"><input type="text" name="end2" size="10" value="{$END_DATE2|date_format2:"m/d/Y"}" /></span></td>
	</tr>
	</table>

	<div align="center" style="clear:left;"><input type="submit" value="Load Report" /></div>	
	</form>

	<script type="text/javascript">{literal}
		function toggleCompareDates(cb) {
			var toState;
			if (cb.checked) {
				toState = 'block';
			} else {
				toState = 'none';
			}
			document.getElementById('compareDatesCell_1').style.display = toState;
			document.getElementById('compareDatesCell_2').style.display = toState;
			document.getElementById('compareDatesCell_3').style.display = toState;
			document.getElementById('compareDatesCell_4').style.display = toState;
		}
	{/literal}</script>
</div>
</div>

{if $report.surveyName}
	<hr />
	<h2>{$report.surveyName}</h2>
	<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><br />
	Taken <b>{$report.totalTimesTaken|default:0}</b> Times by <b>{$report.uniqueTimesTaken|default:0}</b> unique users<br /><br />
	{if $comparingDates}
	- and -<br /><br />
	<i>Comparing against data between <b>{$START_DATE|date_format2:"m/d/Y"}</b> and <b>{$END_DATE|date_format2:"m/d/Y"}</b>.</i><br />
	Taken <b>{$report.totalTimesTaken|default:0}</b> Times by <b>{$report.uniqueTimesTaken|default:0}</b> unique users<br /><br />
	<hr />

	<table style="border:#CCC 1px solid;background:#EEE;" cellpadding="5"><tr><td style="padding-right:10px;">
	<ol>
	{foreach name="qLoop" from=$report.questions item="q"}
		<li>{$q.question}
		<table width="100%">
		<tr>
			<td colspan="4"></td>
			<td><img src="blank.gif" width="110" height="1" alt="" /></td>
			{if $comparingDates}
			<td colspan="2"></td>
			<td><img src="blank.gif" width="110" height="1" alt="" /></td>
			{/if}
		</tr>
		{if $q.A}
		<tr>
			<td valign="top"><b>A.</b></td>
			<td width="100%"><small>{$q.A}</small></td>
			<td valign="bottom"><b>{$q.sumA|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctA|default:0}%</td>
			<td valign="bottom">{if $q.sumA > 0}<img src="img/graphBar.gif" width="{$q.pctA|ceil}" height="10" alt="" />{/if}</td>
			{if $comparingDates}
			<td valign="bottom"><b>{$q.sumA2|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctA2|default:0}%</td>
			<td valign="bottom">{if $q.sumA2 > 0}<img src="img/graphBar.gif" width="{$q.pctA2|ceil}" height="10" alt="" />{/if}</td>
			{/if}
		</tr>
		{/if}
		{if $q.B}
		<tr>
			<td valign="top"><b>B.</b></td>
			<td><small>{$q.B}</small></td>
			<td valign="bottom"><b>{$q.sumB|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctB|default:0}%</td>
			<td valign="bottom">{if $q.sumB > 0}<img src="img/graphBar.gif" width="{$q.pctB|ceil}" height="10" alt="" />{/if}</td>
			{if $comparingDates}
			<td valign="bottom"><b>{$q.sumB2|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctB2|default:0}%</td>
			<td valign="bottom">{if $q.sumB2 > 0}<img src="img/graphBar.gif" width="{$q.pctB2|ceil}" height="10" alt="" />{/if}</td>
			{/if}
		</tr>
		{/if}
		{if $q.C}
		<tr>
			<td valign="top"><b>C.</b></td>
			<td><small>{$q.C}</small></td>
			<td valign="bottom"><b>{$q.sumC|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctC|default:0}%</td>
			<td valign="bottom">{if $q.sumC > 0}<img src="img/graphBar.gif" width="{$q.pctC|ceil}" height="10" alt="" />{/if}</td>
			{if $comparingDates}
			<td valign="bottom"><b>{$q.sumC2|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctC2|default:0}%</td>
			<td valign="bottom">{if $q.sumC2 > 0}<img src="img/graphBar.gif" width="{$q.pctC2|ceil}" height="10" alt="" />{/if}</td>
			{/if}
		</tr>
		{/if}
		{if $q.D}
		<tr>
			<td valign="top"><b>D.</b></td>
			<td><small>{$q.D}</small></td>
			<td valign="bottom"><b>{$q.sumD|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctD|default:0}%</td>
			<td valign="bottom">{if $q.sumD > 0}<img src="img/graphBar.gif" width="{$q.pctD|ceil}" height="10" alt="" />{/if}</td>
			{if $comparingDates}
			<td valign="bottom"><b>{$q.sumD2|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctD2|default:0}%</td>
			<td valign="bottom">{if $q.sumD2 > 0}<img src="img/graphBar.gif" width="{$q.pctD2|ceil}" height="10" alt="" />{/if}</td>
			{/if}
		</tr>
		{/if}
		{if $q.E}
		<tr>
			<td valign="top"><b>E.</b></td>
			<td><small>{$q.E}</small></td>
			<td valign="bottom"><b>{$q.sumE|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctE|default:0}%</td>
			<td valign="bottom">{if $q.sumE > 0}<img src="img/graphBar.gif" width="{$q.pctE|ceil}" height="10" alt="" />{/if}</td>
			{if $comparingDates}
			<td valign="bottom"><b>{$q.sumE2|default:0}</b></td>
			<td valign="bottom" align="right">{$q.pctE2|default:0}%</td>
			<td valign="bottom">{if $q.sumE2 > 0}<img src="img/graphBar.gif" width="{$q.pctE2|ceil}" height="10" alt="" />{/if}</td>
			{/if}
		</tr>
		{/if}
		</table><br /><br /></li>
	{/foreach}
	</td></tr></table>
{/if}