<?php
    // Get a list of activities and fees by season
    $activities = array(
        'F' => array('FBL' => 'Football',
                     'VBL' => 'Volleyball',
                     'BSC' => 'Boys Soccer',
                     'GSC' => 'Girls Soccer',
                     'BXC' => 'Boys Cross Country',
                     'GXC' => 'Girls Cross Country'),
        'W' => array('BBX' => 'Boys Basketball',
                     'GBX' => 'Girls Basketball',
                     'BSW' => 'Boys Swimming',
                     'GSW' => 'Girls Swimming',
                     'WRE' => 'Wrestling'),
        'S' => array('BBL' => 'Baseball',
                     'SBL' => 'Softball',
                     'BTF' => 'Boys Track and Field',
                     'GTF' => 'Girls Track and Field',
                     'BTN' => 'Boys Tennis',
                     'GTN' => 'Girls Tennis',
                     'BGF' => 'Boys Golf',
                     'GGF' => 'Girls Golf')
    );
    
    $non_sports = array(
        'all'    => array('DNC', 'CHE', 'SPE', 'BND', 'ORC', 'CHO', 'SOL'),
        'left'   => array('DNC' => 'Dance/Drill',
                          'CHE' => 'Cheerleading <small>(Competitive)</small>',
                          'SPE' => 'Speech'),
        'center' => array('BND' => 'Music - Band',
                          'ORC' => 'Music - Orchestra'),
        'right'  => array('CHO' => 'Music - Choir',
                          'SOL' => 'Music - Solo')
    );
?>


<!DOCTYPE html>
<html lang="en">

    <!-- HTML Head -->
    <head>

        <!-- Page Title -->
        <title>            
        </title>      
        
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

        <!-- Style -->
        <style type="text/css" media="screen,print">
            
            /* Default Margins and Paddings */
            * {margin: 0; padding: 0;}


            /* No image borders by default */
            img {border: none;}

            /* Page Body */
            html, body {               

                /*width: 2550px;*/
                width: 8in;
                /*height: 3300px;*/
                height: 10.5in;

                font-family: Trebuchet MS, Helvetica, sans-serif;
                font-size: 12pt;                
                
                color: #000000;
                background: #ffffff;

                border: 1px solid white;
            }
                     

            

            .full {width: 100%;}
            .half {width: 50%;}
            .quarter {width: 25%;}

            .text_left {text-align: left;}
            .text_right {text-align: right;}
            .text_center {text-align: center;}
            .text_justify {text-align: justify;}

            .italic {font-style: italic;}            
            
            table { border-collapse: collapse; }

            #page {
                width: 8in;
                height: 10.5in;
                margin: 0;
                padding: 0;
                position: relative;
                page-break-after: always;
            }

            #header img {
                width: 1in;
                position: absolute;
                top: 0.25in;
                left: 1px;
            }

            #header .header_address {
                position: absolute;
                top: 0.25in;
                left: 1.1875in;
                font-size: 10pt;
                line-height: 105%;
            }

            #header .invoice_imprint {
                position: absolute;
                top: 0.25in;
                right: 0;
                font-size: 42pt;
                line-height: 36pt; 
            }

            #header .invoice_data table {
                position: absolute;
                top: 0.8in;
                right: 0;
                font-size: 9pt;
                border: 1px solid black;
            }

            #header .invoice_data table thead tr {
                background-color: #d8d8d8;
            }

            #header .invoice_data table thead th {
                width: 1.1in;
                border-bottom: 1px solid black;
                border-right: 1px solid black;
            }

            #header .invoice_data table tbody td {
                text-align: center;
                line-height: 0.25in;                
            }

            #header .invoice_title {
                position: absolute;
                top: 1.35in;
                left: 0;
                font-size: 18pt; 
            }

            #address_window {
                position: absolute;
               
                /*border: 1px solid black;*/
                /*border-radius: 0.25in;*/

                width: 4.5in;
                height: 1.125in;

                top: 1.8125in;
                left: -0.125in;
            }

            #address {
                margin: 0.1875in 0 0 0.875in;
                font-size: 11pt;
                line-height: 105%;
            }

            #invoice_alert {
                position: absolute;
                top: 0.40in;
                transform: rotate(-90deg);
                font-size: 9pt;
                left: 0.25in;
                letter-spacing: 3px;
                padding-bottom: 5px;
                text-decoration: underline;
            }

            #top_sign_note {
                position: absolute;
               
                border: 2px solid black;  
                border-radius: 2px;              
                width: 2.5in;
                height: 0.625in;

                top: 2in;
                right: 0;

                font-size: 11pt;                
                line-height: 110%;

                padding: 0.125in 0.125in 0 0.125in;

                text-align: justify;

                background-color: #d8d8d8;
            }

            #fold_line {
                position: absolute;
                top: 3.375in;
                width: 8in;

                height: 3px;

                border-top: 3px solid black;

                border-bottom: 1px solid black;
            }

            #section_line {
                
                margin: 0.25in auto 0.25in auto;

                width: 6in;

                border-bottom: 1px solid black;
            }

            #invoice_body {
                position: relative;
                top: 3.6in;
                width: 8in;
            }

            #school_info_bar {
                position: relative;
                top: -0.10in;                
                width: 8in;
                font-size: 11pt;
                font-weight: bold;
            }

            #fee_table {
                width: 5in;
                margin-left: 1.75in;
                font-size: 11pt;
            }

            #fee_table td.label {
                text-align: right;
                padding-right: 0.25in;
            }

            #fee_table td.value {
                
            }

            .check_box {
                width: 0.125in;
                height: 0.125in;
                border: 1px solid black;
                border-radius: 2px;
                position: relative;
                left: -0.0625in;
                top: 0.025in;
                display: inline-block;
            }

            .check_box.filled {
                background-image: url('http://www.osaa.org/images/icons/check_2_16px.png');                
                background-repeat: no-repeat;
                background-size: 12px 12px;
            }

            #regulations_agreement {
                margin-top: 0.125in;
                font-size: 10pt;
                padding: 0 0.125in;
                text-align: justify;
            }

            #signature_line {
                position: relative;
                top: 0.5in;
                left: 0.5in;
                width: 4.5in;
                border-top: 2px solid black;
                font-weight: bold;
                font-size: 13pt;
            }

            #date_line {
                position: relative;
                top: 0.25in;
                left: 5.5in;
                width: 2in;
                border-top: 2px solid black;
                font-weight: bold;
                font-size: 13pt;
            }

            #return_note {
                text-align: center;
                font-weight: bold;
                margin: 0.1875in 0 0.1875in 0;
                padding: 0.0625in 0.125in;
                background-color: #d8d8d8;
                font-size: 10pt;
            }

            #due_note td.label {
                width: 1.25in;
                text-align: right;
                vertical-align: top;
                font-size: 22pt;
                padding-right: 0.1875in;
            }

            #due_note td.value {
                line-height: 110%;
                width: 6.25in;
                text-align: justify;
                font-size: 10pt;
            }            

        </style>


        <script type="text/javascript">
            $(document).ready(function ()
            {
                  

            });                

        </script>        
                
    </head>

    <body>               

        <?php foreach ($objects as $object): ?>

        <div id="page">                      

            <div id="header">
                
                <img src="http://www.osaa.org/images/logos/OSAACircleBWjpg.jpg" />                

                <div class="header_address">
                    Oregon School Activities Association<br />
                    25200 SW Parkway Ave, Suite 1<br />
                    Wilsonville OR &nbsp;97070<br />
                    <br />
                    (503) 682-6722<br />
                    Fax: (503) 682-0960
                </div>

                <div class="invoice_imprint">
                    INVOICE
                </div>

                <div class="invoice_data">
                    <table>
                        <thead>
                            <tr>
                                <th>Date</th>
                                <th>Reference #</th>
                                <th>Invoice #</th>
                            </tr>
                        </thead>    

                        <tbody>
                            <tr>
                                <td style="border-right: 1px solid black;">
                                    <?php echo date('F j, Y', time()); ?>
                                </td>
                                <td style="border-right: 1px solid black;">
                                    <?php echo $object->invoice->number; ?>
                                </td>
                                <td>

                                </td>
                            </tr>   
                        </tbody>
                    </table>
                </div>

                <div class="invoice_title">
                    Annual Member Dues and Participation Statement for <?php echo $object->invoice->school_year; ?>-<?php echo substr(intval($object->invoice->school_year) + 1, 2, 2); ?>
                </div>

            </div>         

            <div id="address_window">
                <div id="invoice_alert">
                    INVOICE
                </div>

                <div id="address">
                    Principal / Administrator<br />
                    <?php echo $object->school->name; ?><br />
                    <?php echo $object->data->address->line_1; ?><br />
                    <?php if (!Helpers::strIsEmpty($object->data->address->line_2)): ?>
                        <?php echo $object->data->address->line_2; ?><br />
                    <?php endif; ?>
                    <?php echo $object->data->address->city; ?>, <?php echo $object->data->address->state; ?> <?php echo $object->data->address->zip; ?>                    
                </div>
            </div>

            <div id="top_sign_note">
                A <b><u>SIGNED COPY</u></b> of this invoice must be returned with your check in order to be processed.*
            </div>            

            <div id="fold_line"></div>

            <div id="invoice_body">

                <div id="school_info_bar">
                    <table>
                        <tr>
                            <td style="width: 4in;">                                
                                <?php echo (!Helpers::strIsEmpty($object->data->league)) ? $object->data->league : '- -'; ?>
                            </td>

                            <td style="width: 1.5in;">
                                ADM: <?php echo $object->data->enrollment; ?>
                            </td>

                            <td style="width: 2.5in;">
                                Due: October 15, <?php echo $object->invoice->school_year; ?>*
                            </td>
                        </tr>
                    </table>
                </div>  

                <div style="text-align: center; font-size: 12pt; margin: 0;">
                    - Athletics Offered -
                </div>              
               
                <table style="margin-left: 0.40in; font-size: 11pt;">
                    <tr>
                        <td style="vertical-align: top;">
                            <table style="width: 2.6in;">
                                <tr>
                                    <td style="padding-left: 0.2in; font-weight: bold;">Fall</td>
                                </tr>

                                <?php foreach ($activities['F'] as $slug => $activity): ?>                                    

                                    <tr>
                                        <td>
                                            <?php                                                
                                                $offered = false;
                                                foreach ($object->data->items->activity_fees as $item)
                                                {
                                                    if (Helpers::strEqual($item->activity, $slug))
                                                    {
                                                        $offered = true;                                                    
                                                    }
                                                }
                                            ?>

                                            <?php if ($offered): ?>                                            
                                                <div class="check_box filled"></div> <?php echo $activity; ?>
                                            <?php else: ?>
                                                <div class="check_box"></div> <?php echo $activity; ?>                                        
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                <?php endforeach; ?>   

                            </table>
                        </td>
                        <td style="vertical-align: top;">
                            <table style="width: 2.6in;">
                                <tr>
                                    <td style="padding-left: 0.2in; font-weight: bold;">Winter</td>
                                </tr>

                                <?php foreach ($activities['W'] as $slug => $activity): ?>                                   
                                    
                                    <tr>
                                        <td>
                                            <?php                                                
                                                $offered = false;
                                                foreach ($object->data->items->activity_fees as $item)
                                                {                                                    
                                                    if (Helpers::strEqual($item->activity, $slug))
                                                    {
                                                        $offered = true;                                                    
                                                    }
                                                }
                                            ?>

                                            <?php if ($offered): ?>                                            
                                                <div class="check_box filled"></div> <?php echo $activity; ?>
                                            <?php else: ?>
                                                <div class="check_box"></div> <?php echo $activity; ?>                                        
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                <?php endforeach; ?> 

                                <tr>
                                    <td style="padding-left: 18px; font-size: 9pt;">(+$30 Weight Control Fee)</td>
                                </tr>                            
                            </table>
                        </td>
                        <td style="vertical-align: top;">
                            <table style="width: 2.6in;">
                                <tr>
                                    <td style="padding-left: 0.2in; font-weight: bold;">Spring</td>
                                </tr>

                                <?php foreach ($activities['S'] as $slug => $activity): ?>                                   

                                    <tr>
                                        <td>
                                            <?php                                                
                                                $offered = false;
                                                foreach ($object->data->items->activity_fees as $item)
                                                {
                                                    if (Helpers::strEqual($item->activity, $slug))
                                                    {
                                                        $offered = true;                                                    
                                                    }
                                                }
                                            ?>

                                            <?php if ($offered): ?>                                            
                                                <div class="check_box filled"></div> <?php echo $activity; ?>
                                            <?php else: ?>
                                                <div class="check_box"></div> <?php echo $activity; ?>                                        
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                <?php endforeach; ?>
                            </table>
                        </td>
                    </tr>                    
                </table>

                <div style="text-align: center; font-size: 12pt; margin: 0;">
                    - Activities Offered -
                </div> 

                <table style="margin-left: 0.40in; font-size: 11pt;">
                    <tr>
                        <td style="vertical-align: top;">
                            <table style="width: 2.6in;">
                                <?php foreach ($non_sports['left'] as $slug => $activity): ?>

                                    <tr>
                                        <td>
                                            <?php                                                
                                                $offered = false;
                                                foreach ($object->data->items->activity_fees as $item)
                                                {
                                                    if (Helpers::strEqual($item->activity, $slug))
                                                    {
                                                        $offered = true;
                                                    }                                                    
                                                }
                                            ?>

                                            <?php if ($offered): ?>                                            
                                                <div class="check_box filled"></div> <?php echo $activity; ?>
                                            <?php else: ?>
                                                <div class="check_box"></div> <?php echo $activity; ?>                                        
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                <?php endforeach; ?>
                            </table>
                        </td>                        
                        <td style="vertical-align: top;">
                            <table style="width: 2.6in;">
                                <?php foreach ($non_sports['center'] as $slug => $activity): ?>

                                    <tr>
                                        <td>
                                            <?php                                                
                                                $offered = false;
                                                foreach ($object->data->items->activity_fees as $item)
                                                {
                                                    if (Helpers::strEqual($item->activity, $slug))
                                                    {
                                                        $offered = true;
                                                    }                                                    
                                                }
                                            ?>

                                            <?php if ($offered): ?>                                            
                                                <div class="check_box filled"></div> <?php echo $activity; ?>
                                            <?php else: ?>
                                                <div class="check_box"></div> <?php echo $activity; ?>                                        
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                <?php endforeach; ?>                                
                            </table>
                        </td>
                        <td style="vertical-align: top;">
                            <table style="width: 2.6in;">
                                <?php foreach ($non_sports['right'] as $slug => $activity): ?>

                                    <tr>
                                        <td>
                                            <?php                                                
                                                $offered = false;
                                                foreach ($object->data->items->activity_fees as $item)
                                                {
                                                    if (Helpers::strEqual($item->activity, $slug))
                                                    {
                                                        $offered = true;
                                                    }                                                    
                                                }
                                            ?>

                                            <?php if ($offered): ?>                                            
                                                <div class="check_box filled"></div> <?php echo $activity; ?>
                                            <?php else: ?>
                                                <div class="check_box"></div> <?php echo $activity; ?>                                        
                                            <?php endif; ?>
                                        </td>
                                    </tr>

                                <?php endforeach; ?>                                
                            </table>
                        </td>
                    </tr>                    
                </table>

                <br />

                <div style="width: 8in; margin: 0 auto; text-align: center; font-size: 9pt;">

                    (Each school involved in an approved cooperative sponsorship MUST pay the required participation fee.)

                </div>

                <div style="width: 6in; margin: 0 auto; font-size: 11pt; text-align: right; margin-top: 0.0625in; line-height: 1.75em;">

                    Total Athletics/Activities:
                    <div style="display: inline-block; width: 2.5in; text-align: right;">
                        <?php echo count($object->data->items->activity_fees); ?> &#215; $<?php echo number_format($object->data->items->activity_fees[0]->amount, 2, '.', ','); ?> = 
                        <div style="display: inline-block; width: 100px;">
                            $<?php echo number_format((count($object->data->items->activity_fees) * floatval($object->data->items->activity_fees[0]->amount)), 2, '.', ','); ?>
                        </div>
                    </div>

                    <br />

                    <?php if (count($object->data->items->special_fees) > 0): ?>

                        Wrestling Weight Control Fee:
                        <div style="display: inline-block; width: 2.5in; text-align: right;">
                            <?php echo count($object->data->items->special_fees); ?> &#215; $<?php echo number_format($object->data->items->special_fees[0]->amount, 2, '.', ','); ?> = 
                            <div style="display: inline-block; width: 100px;">
                                $<?php echo number_format((count($object->data->items->special_fees) * floatval($object->data->items->special_fees[0]->amount)), 2, '.', ','); ?>
                            </div>
                        </div>
                        
                        <br />  

                    <?php endif; ?>

                    Annual Membership Dues:
                    <div style="display: inline-block; width: 2.5in; text-align: right;">
                        <div style="display: inline-block; width: 100px;">
                            $<?php echo number_format($object->data->items->dues_fees[0]->amount, 2, '.', ','); ?>
                        </div>
                    </div>
                    
                    <br /><br />
                    
                    <b>Total Amount Due:</b>
                    <div style="display: inline-block; width: 2.5in; text-align: right;">
                        <div style="display: inline-block; width: 100px;">
                            <b>$<?php echo number_format($object->invoice->total_amount, 2, '.', ','); ?></b>
                        </div>
                    </div>    

                    <br />                

                </div>               

                <div id="regulations_agreement">
                    As a condition of this membership, this school shall be bound by the regulations, standards, rulings, and position papers of the Oregon School Activities Association and other decisions made by the Delegate Assembly and/or the Executive Board, and shall be bound to self-report any violations of the regulations to the Executive Director.
                </div>                

                <div id="signature_line">
                    Signature (Superintendent or Principal)
                </div>

                <div id="date_line">
                    Date
                </div>

                <br /><br />

                <div id="return_note">
                    Please make check payable to "Oregon School Activities Association".<br />
                    REMINDER: Return a signed copy of this invoice with your check.* Retain a copy for your records.
                </div>

                <table id="due_note">
                    <tbody>
                        <tr>
                            <td class="label">*NOTE:</td>
                            <td class="value">
                                As determined by Article 3.3.1 of the OSAA Constitution, annual dues and participation fees are payable to the OSAA <b>on or before October 15</b> of each year.
                            </td>
                        </tr>
                    </tbody>
                </table>                

            </div>

        </div>        

        <?php endforeach; ?>

    </body>    
</html>   
