<?php $__env->startSection('page_title'); ?>
    OSAA - Team Editor
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_sub_title'); ?>    
    <?php echo $information['team_name_title']; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    @parent

	

<?php $__env->stopSection(); ?>

<?php $__env->startSection('jquery_init'); ?>
	$('.tooltip').tooltip();
	

	$('.button').button();		
	$('.button.back').button({ icons : { primary : 'ui-icon-arrowthick-1-w'}});		
	$('.button.save').button({ icons : { primary : 'ui-icon-disk'}})
		             /*.hover(function ()
		             		{
		             			$(this).addClass('ui-state-highlight');
		         			},
		         			function ()
		         			{
		         				$(this).removeClass('ui-state-highlight');
		         			})*/
	
					 .click(function ()
					 {
				 	     var contest = $(this).attr('data-contest')
				  		 $('#form_' + contest).submit();        
				 	 });	
	/* Limit input to numbers and a dash */
	$('.record input').bind('input', function()
	{
  	    $(this).val($(this).val().replace(/[^0-9\-]/gi, ''));
	});
  

  	/* Display any success messages */
    $('.success_message').delay(5000).fadeOut({'duration' : 2500});
    $('.success_message .ui-icon-close').click(function ()
    {
        $('.success_message').hide();
    });
	

<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_functions'); ?> 	

	<a href="<?php echo url('teams/' . $information['team']->id . '/edit'); ?>" class="button back" style="font-size: 9pt;">Edit Team</a>
	
<?php $__env->stopSection(); ?>


<?php $__env->startSection('main_content'); ?>    

	<?php if (Session::get('success')): ?>
        <div class="success_message"><span class="ui-icon ui-icon-close box_icon"></span><span class="ui-icon ui-icon-check" style="display:inline-block;"></span><?php echo Session::get('success'); ?></div>
    <?php endif; ?> 		

    <h1>Out-of-State Opponent Records</h1>

    <p>
    	Your team is scheduled to play or has played against the following out-of-state opponents.  Your opponent's records are listed below, last updated on the date shown.  Please provide your opponent's modified 
    	<?php if (Helpers::strEqual($information['activity_program']->activity, array('BSC', 'GSC'))): ?>
    		win - loss - tie
    	<?php else: ?>
    		win - loss
    	<?php endif; ?>
    	record.  <a href="<?php echo asset('docs/osaainfo/ManagingOutofStateRecordsInstructions.pdf'); ?>" target="_blank">Out-of-State Records Help</a>
    </p>
    <p>
    	<b>Modified Records:</b> Your out-of-state opponent's record needs to be modified by excluding the contest(s) against your team.  Do not include any forfeited contests in their record either.  For Oregon teams, we include regular season results and any league/district playoffs.  State playoff results are not included.  The same logic should be used when calculating season records for out of state opponents.
    </p>
    <p>
    	<b>Example:</b> Opponent is Camas (WA) with a record of 5-2.  You beat them once in a contest.  Enter their record as 5-1 (subtract 1 loss from their record because your win against them is excluded.)
    </p>

    <?php if (Session::has('errors')): ?>                
        <div class="ui-state-error" style="padding:2px 4px;"><span class="ui-icon ui-icon-alert box_icon"></span><?php foreach ($errors->all() as $error): ?><?php echo $error; ?> <?php endforeach; ?></div><br />
    <?php endif; ?>  

    <table class="oos_record_list">
    	<thead class="head">
    		<tr>
    			<th class="date">Contest Date/Time</th>
    			<th class="sport">Sport</th>
    			<th class="opponent">Opponent</th>    			
    			<th class="result">Result</th>
    			<th class="udpated_at">Last Updated</th>
    			<th class="record">
	    			<?php if (Helpers::strEqual($information['activity_program']->activity, array('BSC', 'GSC'))): ?>
			    		Record (W-L-T)
			    	<?php else: ?>
			    		Record (W-L)
			    	<?php endif; ?>
    			</th>
    			<th class="action"></th>
    		</tr>
    	</thead>

    	<tbody>
    		
    		<?php if (count($information['contests']) > 0): ?>
    			
    			<?php $i = 0; ?>

    			<?php foreach ($information['contests'] as $contest): ?>
    				
    				<?php echo Form::open (array('url' => url('/contests/' . $contest->id . '/update-oos-record'),
    									 'id'  => 'form_' . $contest->id)); ?>

    					<?php echo Form::hidden('team_id_' . $information['team']->id, $information['team']->id); ?>

	    				<tr <?php if ($i++ % 2 == 1): ?> class="odd" <?php endif; ?>>
	    					<td class="date">
	    						<?php echo date('D. m/j/Y g:i a', strtotime($contest->start_at)); ?>
	    					</td>

	    					<td class="sport">
	    						<?php echo Helpers::getActivityName($contest->activity); ?>
	    					</td>

	    					<td class="opponent">
	    						<?php if (Helpers::strEqual($contest->my_designation, 'HOME')): ?>
	    							<?php echo preg_replace('/\{.*\}/', '', $contest->away_team_name); ?>
	    						<?php else: ?>
	    							<?php echo preg_replace('/\{.*\}/', '', $contest->home_team_name); ?>
	    						<?php endif; ?>
	    					</td>
	    					
	    					<td class="result">
	    						<?php echo $contest->result; ?>
	    					</td>

	    					<td class="udpated_at">
	    						<?php echo $contest->record_updated; ?>
	    						<img src="<?php echo asset('images/icons/' . $contest->record_update_status); ?>" style="width: 24px; height: 24px; position: relative; top:3px; float: right;" class="tooltip" alt="" title="<?php echo $contest->record_stale_advisory; ?>" />
	    					</td>

	    					<td class="record">
	    						<?php echo Form::text('record_' . $contest->id, $contest->oos_opponent_record); ?>
	    						
	    					</td>

	    					<td>
	    						<div class="button save" style="font-size: 8pt; margin-bottom: 3px;" data-contest="<?php echo $contest->id; ?>">Update / Save</div>
	    					</td>	    					
	    				</tr>

    				<?php echo Form::close (); ?>
    			<?php endforeach; ?> 

    		<?php else: ?>
    			<tr>
    				<td colspan="6">There are no out-of-state opponents on your schedule.</td>
    			</tr>
    		<?php endif; ?>

    	</tbody>

    </table>   

	<?php if (count($information['contests']) > 0): ?>

	    <br /><br /><br />

	    <b>Icon Legend</b><br />

	    <img src="<?php echo asset('/images/icons/bullet_green_32px.png'); ?>" style="width:24px; height:24px; position: relative; top: 6px;" alt="" title="" /> The opponent record is up to date (less than a week old.)  No action is required.
	    <br />
	    <img src="<?php echo asset('/images/icons/bullet_yellow_32px.png'); ?>" style="width:24px; height:24px; position: relative; top: 6px;" alt="" title="" /> The opponent's record is more than a week old.  It should be updated sometime soon.
	    <br />
	    <img src="<?php echo asset('/images/icons/bullet_red_32px.png'); ?>" style="width:24px; height:24px; position: relative; top: 6px;" alt="" title="" /> The opponent record is over two weeks old.  Your immediate attention is required; the record needs to be updated now.
	    <br />
	    <img src="<?php echo asset('/images/icons/bullet_blue_32px.png'); ?>" style="width:24px; height:24px; position: relative; top: 6px;" alt="" title="" />
	    A record has not been entered for this opponent.

	<?php endif; ?> 

<?php $__env->stopSection(); ?>