{include_php file="shared_handle:company_management/reports/incentives-summary"}
<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> 
	Configure</h3>

<script type="text/javascript">
{literal}
function changeOrder(ord) {
	document.forms.configure.order.value = ord;
	document.forms.configure.submit();
}
{/literal}
</script>

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

	<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>
	</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 />

<h3 class="withBG">Campaigns</h3>
{foreach from=$campaigns item="campaign"}
	<b>Campaign #{$campaign.id}</b>
	<div style="margin-left:15px;">
		<i>eStat</i>: {$campaign.estatName}<br />
		<i>Date Range</i>: {$campaign.dateStart|date_format2:"m/d/Y"} <small>({$campaign.dateStart|date_format2:"h:i:s A"})</small> to {$campaign.dateEnd|date_format2:"m/d/Y"} <small>({$campaign.dateEnd|date_format2:"h:i:s A"})</small><br />
		<i>Scoring</i>: {$campaign.value} - {$campaign.type}<br />
	</div>
	<br />
{foreachelse}
	<div style="margin-left:15px;">
		No active campaigns in the current time period.
	</div>
	<br />
{/foreach}

<h3 class="withBG">User Data</h3>
<table border="1" cellpadding="1" cellspacing="0" style="z-index:10000;">
<tr>
	<td><b>No.</b></td>
	<td><b><a href="javascript:changeOrder('username');">Username</a></b></td>
	<td><b><a href="javascript:changeOrder('lastName');">Last Name</a></b></td>
	<td><b><a href="javascript:changeOrder('firstName');">First Name</a></b></td>
	{foreach from=$campaigns item="campaign"}
		<td><b><a href="javascript:changeOrder({$campaign.id});">Campaign&nbsp;#{$campaign.id}</a></b></td>
	{/foreach}
	<td><b><a href="javascript:changeOrder('surveys');">Surveys</a></b></td>
	<td><b><a href="javascript:changeOrder('total');">Total</a></b></td>
</tr>
{foreach name="userDataLoop" from=$userData item="userData"}
<tr>
	<td>{$smarty.foreach.userDataLoop.iteration}.</td>
	<td><a href="mailto:{$userData.email|default:"unknown@unknown.com"}">{$userData.username}</a></td>
	<td>{$userData.lastName|default:"-none-"}</td>
	<td>{$userData.firstName|default:"-none-"}</td>
	{foreach from=$campaigns item="campaign"}
		<td align="right">{$userData[$campaign.id]|default:0}</td>
	{/foreach}
	<td align="right">{$userData.surveys|default:0}</td>
	<td align="right"><b>{$userData.total|default:0}</b></td>
</tr>
{/foreach}
</table>
