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

<?php $__env->startSection('page_sub_title'); ?>    
    <?php echo Helpers::getCurrentYear(); ?> OSAA Cross Country Results
<?php $__env->stopSection(); ?>

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

    <style type="text/css">

    </style>

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

<?php $__env->startSection('jquery_init'); ?>
    
    $('.tabs').tabs();
    $('.nav_button').button({ icons : {primary : 'ui-icon-arrowthick-1-w'}});

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

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

    <a class="nav_button" href="<?php echo url('/activities/bxc'); ?>" style="font-size:9pt;">Back</a>
    
<?php $__env->stopSection(); ?>


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

        // Get XC sanctioned activity records
        $sas = sanctionedactivity::where('school_year', '=', intval(Helpers::getCurrentYear()))
                                 ->whereIn('activity', array('BXC', 'GXC'))                                 
                                 ->remember(30)
                                 ->get();

        // Sort by division then gender
        $sas->sort(function($a, $b)
        {
            $a2 = intval(substr($a->division, 0, 1));
            $b2 = intval(substr($b->division, 0, 1));

            if ($a2 > $b2)
            {
                return -1;
            }
            elseif ($a2 < $b2)
            {
                return 1;
            }


            $a1 = $a->activity;
            $b1 = $b->activity;

            $cmp = strcasecmp($a1, $b1);

            if ($cmp < 0)
            {
                return -1;
            }
            elseif ($cmp > 0)
            {
                return 1;
            }            

            return 0;
        });
    ?>

    <?php /*  Results Tabs  */ ?>
    <div class="tabs awards" style="min-height: 650px;">
        
        <?php /*  Tab List  */ ?>
        <ul style="padding-left:5px;">            
            <?php foreach ($sas as $index => $sa): ?>
                <li><a href="#tabs-<?php echo $index; ?>"><?php echo $sa->division; ?> <?php echo (Helpers::strEqual($sa->activity, 'BXC')) ? 'Boys' : 'Girls'; ?></a></li>
            <?php endforeach; ?>            
        </ul>
        
        <?php /*  Div/Gender Tab  */ ?>
        <?php foreach ($sas as $index => $sa): ?>

            <?php                
                $gender = (Helpers::strEqual($sa->activity, 'BXC')) ? 'Boys' : 'Girls';
                $directory = '/docs/' . strtolower($sa->activity) . '/';
                $server_path = public_path() . $directory;                
                $team_results_file_name = strtolower(str_replace('/', '', $sa->division) . substr($gender, 0, 1) . 'team.txt');
                $individual_results_file_name = strtolower(str_replace('/', '', $sa->division) . substr($gender, 0, 1) . 'ind.txt');
            ?>

            <div id="tabs-<?php echo $index; ?>">

                <?php /*  Promotions  */ ?>
                <div class="float_right text_center" style="margin-left: 10px;">
                    <a href="http://4nsp.com/PhotosAction.aspx" target="_blank">
                        <img src="<?php echo asset('/images/ads/sponsors/NSP_111x50px.png'); ?>" alt="" title="" style="float: right;" />
                    </a>
                    <br />
                    <a href="http://4nsp.com/PhotosAction.aspx" target="_blank">Photos</a>
                </div>

                <div class="float_right text_center" style="margin-left: 10px;">
                    <a href="http://www.osaastore.com" target="_blank">
                        <img src="<?php echo asset('/images/ads/sponsors/SportsU_111x50px.png'); ?>" alt="" title="" style="float: right;" />
                    </a>
                    <br />
                    <a href="http://www.osaastore.com" target="_blank">Merchandise</a>                
                </div>

                <div class="float_right text_center">
                    <a href="http://www.osaa.org/programs" target="_blank">
                        <img src="<?php echo asset('/images/ads/sponsors/Digital_Programs_111x50.jpg'); ?>" alt="" title="" style="float: right;" />
                    </a>
                    <br />          
                    <a href="http://www.osaa.org/programs" target="_blank">Digital Program</a>              
                </div>
                
                <?php /*  Results Heading  */ ?>
                <h1 style="line-height: 1.25em;"><?php echo Helpers::getCurrentYear(); ?> OSAA / OnPoint Community Credit Union Cross Country State Championships</h1>
                <h2><?php echo $sa->division; ?> <?php echo $gender; ?> Results</h2>
            
                <?php /*  Results Text Files  */ ?>
                <div style="font-size: 10pt;">

                    <?php /*  Display team results, if they exist  */ ?>
                    <?php if (file_exists($server_path . $team_results_file_name)): ?>
                        <pre><code>         
                            <?php echo file_get_contents($server_path . $team_results_file_name); ?>        
                        </code></pre>
                    <?php else: ?>
                        Team results will be posted following the completion of the race.

                        <?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>

                            <br /><br />

                            <b>OSAA Staff:</b><br />
                            The team results file should be named "<b><?php echo $team_results_file_name; ?></b>" and uploaded via FileZilla to the folder <b><?php echo str_replace('/home/osaa/web_app/demo', '', $server_path); ?></b>.

                        <?php endif; ?>

                    <?php endif; ?>

                    <?php /*  Display individual results, if they exist  */ ?>
                    <?php if (file_exists($server_path . $individual_results_file_name)): ?>
                        <pre><code>         
                            <?php echo file_get_contents($server_path . $individual_results_file_name); ?>        
                        </code></pre>
                    <?php else: ?>
                        <br /><br />
                        Individual results will be posted following the completion of the race.

                        <?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>

                            <br /><br />

                            <b>OSAA Staff:</b><br />
                            The individual results file should be named "<b><?php echo $individual_results_file_name; ?></b>" and uploaded via FileZilla to the folder <b><?php echo str_replace('/home/osaa/web_app/demo', '', $server_path); ?></b>.

                        <?php endif; ?>

                    <?php endif; ?>
                </div>

            </div>

        <?php endforeach; ?>

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