<div style="font-size: 10pt; margin: 1em 0;">
	<span class="ui-icon ui-icon-info" style="display: inline-block; vertical-align: middle;"></span>
	Use this utility to edit a CTS record.  Click the "Save" button to commit changes to the database, or click "Cancel" to revert back to the original settings.  Note, CTS records are updated when scores are entered or updated.  Your changes may be over-ridden if a team updates the score.
</div>

<?php echo Form::open(array('url'    => url('/contest-teams-scores/' . $info['cts']->id),
					'method' => 'POST',
					'style'  => 'font-size: 10pt;')); ?>

	<?php echo Form::hidden('redirect', url('/teams/' . $info['ap']->id) . '#sub-tabs-ranking'); ?>
	<?php echo Form::hidden('cts_id', $info['cts']->id); ?>

	<div style="float: left; width: 100%;">

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">CTS ID</span><br />
			<?php echo $info['cts']->id; ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Contest ID</span><br />
			<?php echo $info['cts']->contest; ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Activity</span><br />
			<?php echo Helpers::getActivityName($info['contest']->activity); ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Division</span><br />
			<?php echo $info['contest']->division; ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Cross Division?</span><br />
			<?php echo ($info['contest']->is_cross_division) ? 'Yes' : 'No'; ?>
			<?php if ($info['contest']->is_cross_division and property_exists($info['opponent'], 'ap')): ?>
				<?php if (Helpers::strEqual($info['ap']->division, $info['contest']->division)): ?>
					vs. <?php echo $info['opponent']->ap->division; ?>
				<?php else: ?>
					vs. <?php echo $info['ap']->division; ?>
				<?php endif; ?>
			<?php endif; ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Level</span><br />
			<?php echo $info['contest']->level; ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Cross Level?</span><br />
			<?php echo ($info['contest']->is_cross_level) ? 'Yes' : 'No'; ?>
		</div>		

		<div style="float: left;">
			<span class="gray small">Team</span><br />
			<?php echo ucfirst(strtolower($info['cts']->designation)); ?>: <?php echo $info['contest']->{strtolower($info['cts']->designation) . '_team_name'}; ?>
		</div>

		<br class="clear" /><br />
	
		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Contest Date/Time</span><br />
			<?php echo date('D. n/j/y g:i a', strtotime($info['event']->start_at)); ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Contest Created At</span><br />
			<?php echo date('n/j/y g:i a', strtotime($info['contest']->created_at)); ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Contest Updated At</span><br />
			<?php echo date('n/j/y g:i a', strtotime($info['contest']->updated_at)); ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Event Created At</span><br />
			<?php echo date('n/j/y g:i a', strtotime($info['event']->created_at)); ?>
		</div>

		<div style="float: left;">
			<span class="gray small">Event Updated At</span><br />
			<?php echo date('n/j/y g:i a', strtotime($info['event']->updated_at)); ?>
		</div>

		<br class="clear" /><br />

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">CTS Created At</span><br />
			<?php echo date('n/j/y g:i a', strtotime($info['cts']->created_at)); ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">CTS Updated At</span><br />
			<?php echo date('n/j/y g:i a', strtotime($info['cts']->updated_at)); ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Final Score</span><br />
			<?php if (intval($info['contest']->home_team_score) > intval($info['contest']->away_team_score)): ?>
				<?php echo $info['contest']->home_team_score; ?> - <?php echo $info['contest']->away_team_score; ?>, <?php echo $info['contest']->home_team_name; ?>
			<?php elseif (intval($info['contest']->home_team_score) < intval($info['contest']->away_team_score)): ?>
				<?php echo $info['contest']->away_team_score; ?> - <?php echo $info['contest']->home_team_score; ?>, <?php echo $info['contest']->away_team_name; ?>
			<?php else: ?>
				<?php echo $info['contest']->home_team_score; ?> - <?php echo $info['contest']->away_team_score; ?>, Tie
			<?php endif; ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Counts As</span><br />
			<?php if ($info['cts']->is_win): ?>
				Win
			<?php elseif ($info['cts']->is_tie): ?>
				Tie
			<?php else: ?>
				Loss
			<?php endif; ?>

			<?php if ($info['cts']->is_forfeit): ?>
				<i>Forfeit</i>
			<?php endif; ?>
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Forfeit?</span><br />
			<?php echo ($info['cts']->is_forfeit) ? 'Yes' : 'No'; ?>				
		</div>

		<div style="float: left; margin-right: 25px;">
			<span class="gray small">Points/Weight</span><br />
			<?php echo round($info['cts']->points, 1); ?> / <?php echo round($info['cts']->weight, 1); ?>
		</div>

		<div style="float: left;">
			<span class="gray small">CTS Records</span><br />
			<?php echo (count($info['other_ctss']) + 1); ?>
		</div>

		<br class="clear" /><br />

		<?php if (count($info['other_ctss']) > 1): ?>

			<div class="ui-state-error" style="padding: 0.5em;">
				There are <?php echo count($info['other_ctss']); ?> other CTS records for this contest.
			</div>			

			<br />

		<?php endif; ?>


		<b>Contest Impacts for <?php echo $info['ap']->name; ?></b><br />

		<div style="float: left; margin-right: 25px;">			
			<?php echo Form::label('is_limitable', 'Contest Limits?', array('class' => '')); ?>
			<?php echo Form::checkbox('is_limitable', 1, $info['cts']->is_limitable, array('style' => 'vertical-align: middle;')); ?>			
		</div>

		<div style="float: left; margin-right: 25px;">			
			<?php echo Form::label('is_recordable', 'Overall Record?', array('class' => '')); ?>
			<?php echo Form::checkbox('is_recordable', 1, $info['cts']->is_recordable, array('style' => 'vertical-align: middle;')); ?>			
		</div>

		<div style="float: left; margin-right: 25px;">			
			<?php echo Form::label('is_league_recordable', 'League Record?', array('class' => '')); ?>
			<?php echo Form::checkbox('is_league_recordable', 1, $info['cts']->is_league_recordable, array('style' => 'vertical-align: middle;')); ?>			
		</div>

		<div style="float: left; margin-right: 25px;">			
			<?php echo Form::label('is_rankable', 'Rankable?', array('class' => '')); ?>
			<?php echo Form::checkbox('is_rankable', 1, $info['cts']->is_rankable, array('style' => 'vertical-align: middle;')); ?>			
		</div>

		<div style="float: left;">			
			<?php echo Form::label('is_colley_rankable', 'Colley Rankable?', array('class' => '')); ?>
			<?php echo Form::checkbox('is_colley_rankable', 1, $info['cts']->is_colley_rankable, array('style' => 'vertical-align: middle;')); ?>			
		</div>

		<br class="clear" /><br />

		<?php foreach ($info['other_ctss'] as $cts): ?>

			<?php echo Form::label('duplicate_impacts', 'Duplicate impacts for opposing team - ' . $cts->team_name . '?', array('class' => '')); ?>
			<?php echo Form::checkbox('duplicate_impacts', 1, 1, array('style' => 'vertical-align: middle;')); ?>			
			
			<br class="clear" /><br />

		<?php endforeach; ?>

		<b>Notes</b><br />

		<?php echo Form::textarea('notes', $info['cts']->notes, array('style' => 'height: 3em; width: 100%;')); ?>

		<br class="clear" /><br />

		<div style="border-top: 1px solid #aaaaaa; margin-bottom: 1em;"></div>

		<b>Delete CTS Record(s)</b><br />
		<div style="float: left; margin-right: 25px;">
			<?php echo Form::label('delete_record', 'Delete this CTS record?', array('class' => '')); ?>
			<?php echo Form::checkbox('delete_record', 1, 0, array('style' => 'vertical-align: middle;')); ?>			
		</div>

		<?php foreach ($info['other_ctss'] as $cts): ?>

			<div style="float: left;">
				<?php echo Form::label('delete_others', 'Also delete the related CTS record for ' . $cts->team_name . '?', array('class' => '')); ?>
				<?php echo Form::checkbox('delete_others', 1, 0, array('style' => 'vertical-align: middle;')); ?>			
			</div>

		<?php endforeach; ?>

		<br class="clear" /><br />





	</div>
	
<?php echo Form::close(); ?>

