<?php $__env->startSection('page_title'); ?>
    OSAA - Dance/Drill Sanctioned Competition Calendar
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_sub_title'); ?>    
   OSAA <?php echo Session::get('year'); ?>-<?php echo intval(substr(Session::get('year'), 2, 2)) + 1; ?> Dance/Drill Sanctioned Competition Calendar
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    @parent
    
    <style type="text/css">        
        
        table {
            border-collapse: collapse;
            width: 100%;
            font-size: 12pt;
        }

        table thead th {
            text-align: left;
            line-height: 1.5em;
            padding-left: 0.5em;
        }

        table tbody td {
            line-height: 2em;
            padding-left: 0.5em;
        }

        tbody tr.odd {
            background-color: #f2f2f2;            
        }

    </style>

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

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

    $('.page_functions').css('width', 'auto');

    $('.button').button();
    $('.back')
        .button({'icons' : { 'primary' : ' ui-icon-arrowthick-1-w'}})
        .css('font-size', '9pt');

    $('.tabs').tabs();

    function colorRows ()
    {   
      $('table').each(function ()
      {
        var i = 0;

        $('tbody tr:visible', $(this)).each(function ()
        {
          if (i % 2 == 1)
          {
            $(this).addClass('odd');
          }
          else
          {
            $(this).removeClass('odd');
          }
          i = i + 1;
        });   


      });   
    }

    colorRows();


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

<?php $__env->startSection('page_functions'); ?>
    
    <a href="<?php echo url('/activities/dnc'); ?>" class="back">Dance/Drill</a>

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


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

    <?php
        $activity_events = activityevent::where('school_year', '=', Session::get('year'))
                                        ->where('activity', '=', 'DNC')
                                        ->where('activity_event_type', '=', 'SCMP')
                                        ->get();

        $events = array();
        
        $activity_events = $activity_events->each(function ($ae) use(&$events)
        {
            $event_object = new stdClass();

            $event = event::findOrFail($ae->event);

            if (Helpers::strEqual($event->event_status, array('PND', 'DEL', 'CXL')))
            {
                return;
            }

            $event_object->date = date('n/j/Y', strtotime($event->start_at));

            $event_object->location = 'TBD';
            $event_object->map_link = null;

            $location = location::find($event->location);

            if (!is_null($location))
            {
                $event_object->location = $location->name;
                
                $address = address::find($location->address);

                if (!is_null($address))
                {
                    $event_object->map_link = $address->getMapLink();
                }
            }

            $event_object->name = $event->name;

            $contact_data = json_decode($ae->contact_info);

            $event_object->contact_name = $contact_data->name;
            $event_object->contact_email = (!Helpers::strIsEmpty($contact_data->link)) ? Helpers::obfuscateEmailAddress($contact_data->email) : null;
            $event_object->contact_link = $contact_data->link;

            $events[] = $event_object;
        });
    ?>

    <div class="float_right" style="margin-top: -0.5em;">
        <a href="http://www.ddcaoregon.org/events/category/high-school" target="_blank">            
            DDCA High School Calendar
        </a>
    </div>    

    <h2>Calendar</h2>

    <?php if (count($events) > 0): ?>

        <table>
            <thead class="ui-widget-header">
                <tr>
                    <th>Date</th>
                    <th>Event</th>
                    <th>Location</th>
                    <th>Contact</th>
                    <th>Information</th>                    
                </tr>
            </thead>

            <tbody>
                
                <?php foreach ($events as $event): ?>

                    <tr>
                        <td><?php echo $event->date; ?></td>
                        <td><?php echo $event->name; ?></td>
                        <td>
                            <?php if (!is_null($event->map_link)): ?>
                                <a href="<?php echo $event->map_link; ?>" target="_blank"><?php echo $event->location; ?></a>
                            <?php else: ?>
                                <?php echo $event->location; ?>
                            <?php endif; ?>
                        </td> 
                        <td>
                            <?php if (!Helpers::strIsEmpty($event->contact_email)): ?>
                                <a href="mailto:<?php echo $event->contact_email; ?>"><?php echo $event->contact_name; ?></a>
                            <?php else: ?>
                                <?php echo $event->contact_name; ?>
                            <?php endif; ?>
                        </td>
                        <td>
                            <a href="<?php echo $event->contact_link; ?>" target="_blank">&raquo; More Information</a>
                        </td>
                    </tr>


                <?php endforeach; ?>

            </tbody>

        </table>


    <?php else: ?>

        <h2>No Events Scheduled</h2>

        <p>
            There are currently no sanctioned competitions scheduled for this school year.  Please check back later.
        </p>

    <?php endif; ?>

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