{if $smarty.session.company.preferences.hide_incentives eq "yes"}{include file="file:layouts/hiddenPageRedirector.tpl"}{/if}
{include file="layouts/forceLoggedIn.tpl"}

{* HANDLERS *}
{include_php file="shared_handle:company/participationPoints_v2"}
{include_php file="shared_handle:company/surveyList"}
{include_php file="shared_handle:company/incentivePointAdjustments"}


{assign var="pgLayout" value="layouts/withLeftNav.tpl"}
<h1>{if $smarty.session.company.preferences.title_my_incentives}{$smarty.session.company.preferences.title_my_incentives}</h1>{else}
<h1>{$page.title}</h1>{/if}

<table width="100%"><tr><td valign="top">
	<img class="iconPrize" src="blank.gif" width="1" height="1" alt="" />
</td><td valign="top" width="100%">
	{$incentiveText|default:"<em>Yearly Incentive</em><br /><br />Not Yet Determined."}	
</td></tr>
</table>
<br />
{assign var="surveyPointsEarned" value=$surveyPointsEarned|default:"0"}
{assign var="totalIncentivePointAdjustments" value=$totalIncentivePointAdjustments|default:"0"}
<h2 class="boxed"><i>Total Points Earned</i>: <em>{$totalParticipationPoints|math:"x+$surveyPointsEarned+$totalIncentivePointAdjustments"}</em></h2>

<blockquote>
<table width="700">
<tr><td valign="top">
	
	<table>
	<tr><td colspan="2">
		<h3>{if $smarty.session.company.preferences.change_word_survey}{$smarty.session.company.preferences.change_word_survey}{else}Available Surveys:</h3></td>{/if}
	    <td valign="middle"></td></tr>
	{foreach from=$surveys item=item name="loopSurveys"}
	{assign var="hideCheck" value="hide_survey_`$item.id`"}
	{if $smarty.session.company.preferences[$hideCheck] neq "yes"}
		<tr><td valign="top" nowrap="nowrap">
		{if $item.dateAvailable gt 0}
			<img class="sIco ico{$item.icon}" src="blank.gif" width="1" height="1" alt="" /></td>
		   <td valign="top"><b><u>{$item.surveyName}</u>:</b> {if $item.frequency eq "Once"}Taken{elseif (($item.dateAvailable - $smarty.now) < 43000)}<small>Available At:</small> {$item.dateAvailable|date_format2:"g:i A"}{else}<small>Available On:</small> {$item.dateAvailable|date_format2:"m/d/y"}{/if}<br />
			{$item.feedbackTitle|default:"No feedback available."}<br />
			<a href="?pg=my_feedback&surveyId={$item.id}&amp;feedbackId={$item.feedbackId}">Click here to learn more<b><i>!</i></b></a><br />
			<br /></td>
		   <td valign="middle" align="right"><em>{$item.pointsEarned}</em></td></tr>
		{else}
			<a href="javascript://" onclick="openSurvey({$item.id});"><img class="sIco ico{$item.icon}" src="blank.gif" width="1" height="1" alt="" /></a></td>
		   <td valign="top" nowrap="nowrap"><b><u>{$item.surveyName}</u>:</b> <a href="javascript://" onclick="openSurvey({$item.id});">Available Now</a><br />
			{$item.feedbackTitle|default:"No feedback available."}<br />
			<a href="?pg=my_feedback&surveyId={$item.id}&amp;feedbackId={$item.feedbackId}">Click here to learn more<b><i>!</i></b></a><br />
			<br /></td>
		   <td valign="middle" align="right"><em>{$item.pointsEarned}</em></td></tr>
		{/if}
	{/if}
	{foreachelse}
	<tr><td valign="top" colspan="3">>
		None found.</td></tr>
	{/foreach}

	<tr><td>&nbsp;</td>
	    <td align="right"><em>{if $smarty.session.company.preferences.change_word_survey}{$smarty.session.company.preferences.change_word_survey}points earned{else}Survey points earned:{/if}</em></td>
	    <td align="center"><span class="boxed">{$surveyPointsEarned|default:0}</span></td></tr>

	<tr><td colspan="2">
		<h3>{if $smarty.session.company.preferences.wellnessConnection}{$smarty.session.company.preferences.wellnessConnection}<br /><a href="?pg=wellnessConnection">Click Here</a>{else}</h3></td>
		{/if}
	    <td valign="middle"></td></tr>


	{if $smarty.session.company.preferences.hide_survey_hra neq "yes"}
		{select_query return="row" assign="aHRA"}
			dateTaken, pointsEarned FROM surveys_taken
			WHERE userId = {$user->id}
			AND surveyId = 8
			ORDER BY dateTaken DESC
			LIMIT 1
		{/select_query}
		<tr><td><img class="icoStethescope" src="blank.gif" width="1" height="1" alt="" /></td>
		    <td><b><u>HRA Score</u>:</b>
		    {if ($aHRA.dateTaken eq "") OR ($aHRA.dateTaken < $smarty.now|math:"x - 31536000")}<br /><a href="javascript://" onclick="openSurvey(8);">Available Now</a>{/if}</td>
		    <td align="center"><em>{$aHRA.pointsEarned}</em></td></tr>
	{/if}

	{if $vanity eq "onai" or $vanity eq "mycompany" or $vanity eq "zions" or $vanity eq "zions2"}
	<tr><td><img class="icoWeights" src="blank.gif" width="1" height="1" alt="" /></td>
		    <td><b><u>Consumer Tools</u>:</b><br /><em>NEW<i>!</i></em></td>
		    <td align="center"><a href="?pg=consumer_tools">Click Here</a></td></tr>
	{/if}

	{if 0 neq $totalIncentivePointAdjustments}
	<br style="clear:left;" />
	<tr><td colspan="3"><h3>Adjustments/Redemptions:</h3></td></tr>
        {foreach from=$incentivePointAdjustments item="adjustment" name="loopAdjustments"}<tr><td nowrap>
	<tr><td colspan="2"><small><i>{$adjustment.dateAssigned|date_format2:"m/d/Y"}</i> - {$adjustment.comment}</small></td>
	    <td valign="middle" align="right"><em>{$adjustment.points}</em></td></tr>
        {foreachelse}
		<tr><td colspan="3">None.</td></tr>
        {/foreach}
	<tr><td colspan="2" align="right"><em>Total:</em></td>
		<td align="center" nowrap="nowrap"><span class="boxed"><nobr>{$totalIncentivePointAdjustments|default:0}</nobr></span></td></tr>
	{/if}

	</table>

</td><td valign="top">
	<h3>Feedback:</h3>
	<table>
	<tr><td>
	<img class="icoNurse" src="blank.gif" width="1" height="1" alt="" />
	</td><td>
	<ul>
		<li><a href="javascript:viewSurveys();">Review My History</a></li>
		{if $smarty.session.company.preferences.hide_survey_hra neq "yes"}
		<li><a href="?pg=HRAScoreInfo">HRA Score Info</a></li>
		{/if}
	<ul>
	</td></tr>
	</table>
	<br />

	{if $aScales|@count gt 0} {* PARTICIPATION POINTS -- IF APPLICABLE *}
	<table align="right">
	<tr><td colspan="3"><h3>Participation Points:</h3></td></tr>
        {foreach from=$aScales item="scale" name="loopScales"}<tr><td nowrap>
	<tr><td>{$scale.name|niceText}</td>
	    <td><small>({$scale.dateStart|date_format2:"m/d/y"} - {$scale.dateEnd|date_format2:"m/d/y"})</small></td>
	    <td valign="middle" align="right"><em>{$aScores[$scale.id]|number_format:"1"}</em></td></tr>
        {foreachelse}
		<tr><td colspan="3">None.</td></tr>
        {/foreach}
	<tr><td colspan="2" align="right"><em>Participation points earned:</em></td>
		<td align="right"><span class="boxed">{$totalParticipationPoints|default:0}</span></td></tr>
	</table>
	{/if}

	</td></tr>
</table>
</blockquote>