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

<?php $__env->startSection('page_sub_title'); ?>    
   <?php echo $info['activity']->name; ?> Special District Results
<?php $__env->stopSection(); ?>

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

    <style type="text/css">		

    	h3 {
    		color: #990000 !important;
    	}

    	h4 {
    		color: #005fa9;
    		display: inline-block;
    	}

    	table {
    		border-collapse: collapse;
    		font-size: 10pt;
    		width: 100%;
    	}

    	table thead th {
    		text-align: left;
    		border-bottom: 1px solid #aaaaaa;
    	}

    	.preview_unpublished {
    		background-color: #d0d0d0;
    		position: relative;
    		overflow: hidden;
    	}

    	.preview_watermark {
    		position: absolute;
    		opacity: 0.25;
		    font-size: 3em;
		    line-height: 115%;
		    width: 100%;
		    text-align: center;
		    z-index: 1000;
		    top: 25%;
    	}

    	.preview_watermark_note {
    		font-size: 14pt;
    	} 
    	
    	@media print {
    		#full_page_content {
    			float: none !important;    			
    		}

    		.print_break {
    			page-break-before: always !important;
    		}

    	}   	
    	

    </style>

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

<?php $__env->startSection('jquery_init'); ?>
	$('.button')
		.button()
		.css({'font-size' : '9pt'});

	$('.button.back')
		.button({ icons : { primary : 'ui-icon-arrowthick-1-w'}});

	$('.button.switch')
		.button({ icons : { primary : 'ui-icon-transferthick-e-w'}});

	$('.button.edit')
		.button({ icons : { primary : 'ui-icon-pencil'}});

	$('.button.form')
		.button({ icons : { primary : 'ui-icon-clipboard'}});
    
    $('.page_functions')
    	.css({'width' : 'auto'});

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

<?php $__env->startSection('page_functions'); ?>	
	
	<?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>
		<a href="<?php echo url('/forms/registration/' . strtolower($info['activity']->slug)); ?>" class="button form">Form</a>
	<?php endif; ?>

	<?php if(Helpers::strEqual($info['activity']->slug, 'BGF')): ?>
		<a href="<?php echo url('/activities/ggf/league-results'); ?>" class="button switch">Switch to Girls Results</a>
		<a href="<?php echo url('/activities/bgf'); ?>" class="button back">Boys Golf</a>
	<?php else: ?>
		<a href="<?php echo url('/activities/bgf/league-results'); ?>" class="button switch">Switch to Boys Results</a>
		<a href="<?php echo url('/activities/ggf'); ?>" class="button back">Girls Golf</a>
	<?php endif; ?>	

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


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

	<?php foreach ($info['leagues'] as $item): ?>				

		<div class="print_break">

		<h2>
			<?php echo preg_replace('/ \(.*\)/', '', $item->league->slug); ?> <?php echo $item->league->name; ?>
			<?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>
				<a href="<?php echo url('/forms/registration/' . strtolower($info['activity']->slug) . '?league=' . $item->league->slug); ?>" class="button edit" style="font-size: 7pt !important; margin-left: 25px;">Edit</a>
			<?php endif; ?>
		</h2>

		<?php if (is_null($item->form)): ?>			
			
			The tournament director has not yet submitted <?php echo strtolower($info['activity']->name); ?> results for <?php echo preg_replace('/ \(.*\)/', '', $item->league->slug); ?> <?php echo $item->league->name; ?>.  Please check back again soon.<br />

		<?php else: ?>
			
			<h3>District Tournament</h3>
			<b>Date: </b><?php echo date('l n/j/Y', strtotime($item->data->district->event->date)); ?><br />
			<b>Location: </b><?php echo $item->data->district->event->location; ?><br />
			<b>Director: </b><?php echo $item->data->district->director->name; ?><br />

			<br />

			<?php if ($item->data->complete or (Auth::check() and Auth::user()->isOsaaUser())): ?>

				<?php if (!$item->data->complete): ?>
					<div class="preview_unpublished">
					<div class="preview_watermark">Unpublished<br />Preview<div class="preview_watermark_note">Form has not been submitted</div></div>
				<?php endif; ?>

				<div class="columns">

					<div class="half">
						<b>District Qualifying Teams</b><br />
						
						<?php foreach ($item->data->district->qualifiers->teams as $team): ?>

							<?php
								if (Helpers::strIsEmpty($team->ap_id))
								{
									continue;
								}

								$ap = activityprogram::findOrFail($team->ap_id);
								$school = school::findOrFail($ap->host_school);

								$coach = $school->getActivityProgramStaff($ap->activity, 'Coach', 'V')->first();
							?>

							<h4><?php echo $ap->name; ?></h4>

							<?php if (!is_null($coach)): ?>
								<span style="font-size: 9pt;">- <?php echo $coach->school_staff->getDisplayName(); ?>, Head Coach</span>
							<?php endif; ?>							

							<table style="margin-left: 10%; width:90%;">
								<thead>
									<tr>
										<th>#</th>
										<th>Name</th>
										<th>Scores</th>
										<th>Place</th>
									</tr>
								</thead>

								<tbody>
									<?php
										$count = 0;
									?>
									<?php foreach ($team->participants as $participant): ?>
										<?php
											if (Helpers::strIsEmpty($participant->name))		
											{
												continue;
											}

											$count++;
										?>

										<tr>
											<td><?php echo ($count); ?></td>
											<td><?php echo $participant->name; ?>, <?php echo $participant->grade; ?></td>
											<td>
												<?php if (!is_null($participant->score_1) and !is_null($participant->score_2)): ?>
													<?php echo strtoupper($participant->score_1); ?>, <?php echo strtoupper($participant->score_2); ?>
												<?php elseif (is_null($participant->score_1) and !is_null($participant->score_2)): ?>
													NS, <?php echo strtoupper($participant->score_2); ?>
												<?php elseif (!is_null($participant->score_1) and is_null($participant->score_2)): ?>
													<?php echo strtoupper($participant->score_1); ?>, NS
												<?php else: ?>
													NS, NS
												<?php endif; ?>
											</td>
											<td>
												<?php if (is_null($participant->place)): ?>
													NP												
												<?php elseif (is_numeric($participant->place)): ?>
													<?php echo Helpers::ordinalNumber($participant->place); ?>
												<?php else: ?>
													<?php echo strtoupper($participant->place); ?>
												<?php endif; ?>
											</td>
										</tr>										
									<?php endforeach; ?>

									<?php if ($count == 0): ?>
										<tr>
											<td colspan="4">There are no participants listed.</td>
										</tr>
									<?php endif; ?>
								</tbody>

							</table>
							
							<br />


						<?php endforeach; ?>

					</div>

					<div class="half">
						
						<b>District Qualifying Individuals</b><br />
						<div class="small gray note">Not from a district qualifying team.</div>
						
						<table style="margin-left: 5%; width:95%;">
							<thead>
								<tr>
									<th>#</th>
									<th>Name</th>
									<th>Scores</th>
									<th>Place</th>
									<th>Team</th>
								</tr>
							</thead>

							<tbody>

								<?php
									$count = 0;
								?>

								<?php foreach ($item->data->district->qualifiers->individuals as $participant): ?>

									<?php
										if (Helpers::strIsEmpty($participant->name))
										{
											continue;
										}
										
										$ap = activityprogram::find($participant->ap_id);

										$count++;
									?>


									<tr>
										<td><?php echo ($count); ?></td>
										<td><?php echo $participant->name; ?>, <?php echo $participant->grade; ?></td>
										<td>
											<?php if (!is_null($participant->score_1) and !is_null($participant->score_2)): ?>
												<?php echo strtoupper($participant->score_1); ?>, <?php echo strtoupper($participant->score_2); ?>
											<?php elseif (is_null($participant->score_1) and !is_null($participant->score_2)): ?>
												NS, <?php echo strtoupper($participant->score_2); ?>
											<?php elseif (!is_null($participant->score_1) and is_null($participant->score_2)): ?>
												<?php echo strtoupper($participant->score_1); ?>, NS
											<?php else: ?>
												NS, NS
											<?php endif; ?>
										</td>
										<td>
											<?php if (is_null($participant->place)): ?>
												NP												
											<?php elseif (is_numeric($participant->place)): ?>
												<?php echo Helpers::ordinalNumber($participant->place); ?>
											<?php else: ?>
												<?php echo strtoupper($participant->place); ?>
											<?php endif; ?>
										</td>
										<td>
											<?php if (!is_null($ap)): ?>
												<?php echo $ap->name; ?>
											<?php else: ?>
												No Team Listed
											<?php endif; ?>
										</td>
									</tr>										
								<?php endforeach; ?>

								<?php if ($count == 0): ?>
									<tr>
										<td colspan="5">There are no participants listed.</td>
									</tr>
								<?php endif; ?>
							</tbody>

						</table>
							
						<br />

					</div>

				</div>

				<?php if (property_exists($item->data, 'regional')): ?>					

					<br class="clear" />

					<h3>Regional Tournament</h3>
					<b>Date: </b><?php echo date('l n/j/Y', strtotime($item->data->regional->event->date)); ?><br />
					<b>Location: </b><?php echo $item->data->regional->event->location; ?><br />
					<b>Director: </b><?php echo $item->data->regional->director->name; ?><br />

					<br />

					<div class="columns">

						<div class="half">
							<b>Regional Qualifying Teams</b><br />
							
							<?php foreach ($item->data->regional->qualifiers->teams as $team): ?>

								<?php
									if (Helpers::strIsEmpty($team->ap_id))
									{
										continue;
									}

									$ap = activityprogram::findOrFail($team->ap_id);
									$school = school::findOrFail($ap->host_school);

									$coach = $school->getActivityProgramStaff($ap->activity, 'Coach', 'V')->first();
								?>

								<h4><?php echo $ap->name; ?></h4>

								<?php if (!is_null($coach)): ?>
									<span style="font-size: 9pt;">- <?php echo $coach->school_staff->getDisplayName(); ?>, Head Coach</span>
								<?php endif; ?>							

								<table style="margin-left: 10%; width:90%;">
									<thead>
										<tr>
											<th>#</th>
											<th>Name</th>
											<th>Scores</th>											
											<th>Place</th>
										</tr>
									</thead>

									<tbody>
										<?php
											$count = 0;
										?>
										<?php foreach ($team->participants as $participant): ?>
											<?php
												if (Helpers::strIsEmpty($participant->name))		
												{
													continue;
												}

												$count++;
											?>

											<tr>
												<td><?php echo ($count); ?></td>
												<td><?php echo $participant->name; ?>, <?php echo $participant->grade; ?></td>
												<td>
													<?php if (!is_null($participant->score_1) and !is_null($participant->score_2)): ?>
														<?php echo strtoupper($participant->score_1); ?>, <?php echo strtoupper($participant->score_2); ?>
													<?php elseif (is_null($participant->score_1) and !is_null($participant->score_2)): ?>
														NS, <?php echo strtoupper($participant->score_2); ?>
													<?php elseif (!is_null($participant->score_1) and is_null($participant->score_2)): ?>
														<?php echo strtoupper($participant->score_1); ?>, NS
													<?php else: ?>
														NS, NS
													<?php endif; ?>
													|
													<?php if (is_null($participant->score_3)): ?>
														NS												
													<?php else: ?>
														<?php echo strtoupper($participant->score_3); ?>
													<?php endif; ?>
												</td>
												<td>
													<?php if (is_null($participant->place)): ?>
														NP												
													<?php elseif (is_numeric($participant->place)): ?>
														<?php echo Helpers::ordinalNumber($participant->place); ?>
													<?php else: ?>
														<?php echo strtoupper($participant->place); ?>
													<?php endif; ?>
												</td>
											</tr>										
										<?php endforeach; ?>

										<?php if ($count == 0): ?>
											<tr>
												<td colspan="4">There are no participants listed.</td>
											</tr>
										<?php endif; ?>
									</tbody>

								</table>
								
								<br />


							<?php endforeach; ?>

						</div>

						<div class="half">
							
							<b>Regional Qualifying Individuals</b><br />
							<div class="small gray note">Not from a regional qualifying team.</div>
							
							<table style="margin-left: 5%; width:95%;">
								<thead>
									<tr>
										<th>#</th>
										<th>Name</th>
										<th>Scores</th>
										<th>Place</th>
										<th>Team</th>
									</tr>
								</thead>

								<tbody>

									<?php
										$count = 0;
									?>

									<?php foreach ($item->data->regional->qualifiers->individuals as $participant): ?>

										<?php
											if (Helpers::strIsEmpty($participant->name))
											{
												continue;
											}
											
											$ap = activityprogram::find($participant->ap_id);

											$count++;
										?>


										<tr>
											<td><?php echo ($count); ?></td>
											<td><?php echo $participant->name; ?>, <?php echo $participant->grade; ?></td>
											<td>
												<?php if (!is_null($participant->score_1) and !is_null($participant->score_2)): ?>
													<?php echo strtoupper($participant->score_1); ?>, <?php echo strtoupper($participant->score_2); ?>
												<?php elseif (is_null($participant->score_1) and !is_null($participant->score_2)): ?>
													NS, <?php echo strtoupper($participant->score_2); ?>
												<?php elseif (!is_null($participant->score_1) and is_null($participant->score_2)): ?>
													<?php echo strtoupper($participant->score_1); ?>, NS
												<?php else: ?>
													NS, NS
												<?php endif; ?>
												|
												<?php if (is_null($participant->score_3)): ?>
													NS												
												<?php else: ?>
													<?php echo strtoupper($participant->score_3); ?>
												<?php endif; ?>
											</td>
											<td>
												<?php if (is_null($participant->place)): ?>
													NP												
												<?php elseif (is_numeric($participant->place)): ?>
													<?php echo Helpers::ordinalNumber($participant->place); ?>
												<?php else: ?>
													<?php echo strtoupper($participant->place); ?>
												<?php endif; ?>
											</td>
											<td>
												<?php if (!is_null($ap)): ?>
													<?php echo $ap->name; ?>
												<?php else: ?>
													No Team Listed
												<?php endif; ?>
											</td>
										</tr>										
									<?php endforeach; ?>

									<?php if ($count == 0): ?>
										<tr>
											<td colspan="5">There are no participants listed.</td>
										</tr>
									<?php endif; ?>
								</tbody>

							</table>
								
							<br />

						</div>

					</div>

				<?php endif; ?>

				<br class="clear" />

				<?php if (!$item->data->complete): ?>
					</div>
				<?php endif; ?>

			<?php else: ?>
				
				These results have not been published, yet.  Please check back again soon.<br />

			<?php endif; ?>


		<?php endif; ?>

		</div>	

	
		
	<?php endforeach; ?>
	
	

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