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

<?php $__env->startSection('page_sub_title'); ?>    
    Student Eligibility Request Form
<?php $__env->stopSection(); ?>

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

    <style type="text/css">
    	h2 {
            color: #151515 !important;
        }

        h3 {
    		color: #1C43A6 !important;
    	}

        .no-close .ui-dialog-titlebar-close {
            display: none;
        }

    	.success_bar {
    		position: fixed;
    		top: 600px;
    		left: 0;
    		width: 100%;
    		padding: 0.25em 0;
    		line-height: 1.5em;
    		background-color: rgba(176, 255, 190, 0.0);
    		border-bottom: 2px solid rgba(13, 88, 27, 0.50);
    		border-top: 2px solid rgba(13, 88, 27, 0.50);
    		z-index: 500;
    	}

    	.success_bar .message {
    		width: 1200px;
    		margin: 0 auto;
    		font-size: 14pt;
    		color: #151515;
    	}    	

    	.page_functions {
    		width: auto !important;
    	}  

        .info_id_info {
            float: right;
        }

        .label {            
            font-weight: bold;            
            float: left;            
        }

        .info_id_info .label {            
            width: 150px;
        }

        .student_info .label {
            width: 110px;
        }

        .student_info {
            font-size: 10pt;
            line-height: 1.15em;
        }

        .odd {
            background-color: #dedede;
        }

        .student_records table {
            border-collapse: collapse;
            width: 100%;
            font-size: 8.5pt;
        }        

        .student_records table thead {
            background-color: #005FA9;
            color: #ffffff;
        }

        .student_records table thead th {            
            padding: 2px 1px;
            text-align: left;
        }

        .student_records table tbody tr {
            line-height: 2em;
        }

        .decision_history table {
            border-collapse: collapse;
            width: 100%;
            font-size: 8.5pt;
        }        

        .decision_history table thead {
            background-color: #005FA9;
            color: #ffffff;
        }

        .decision_history table thead th {            
            padding: 2px 1px;
            text-align: left;
        }

        .decision_history table tbody tr {
            line-height: 2em;
        }

        .appeal_history table {
            border-collapse: collapse;
            width: 100%;
            font-size: 8.5pt;
        }        

        .appeal_history table thead {
            background-color: #005FA9;
            color: #ffffff;
        }

        .appeal_history table thead th {            
            padding: 2px 1px;
            text-align: left;
        }

        .appeal_history table tbody tr {
            line-height: 2em;
        }

        .associated_waivers table {
            border-collapse: collapse;
            width: 100%;
            font-size: 8.5pt;
        }        

        .associated_waivers table thead {
            background-color: #005FA9;
            color: #ffffff;
        }

        .associated_waivers table thead th {            
            padding: 2px 1px;
            text-align: left;
        }

        .associated_waivers table tbody tr {
            line-height: 2em;
        }

        .waiver_files table {
            border-collapse: collapse;
            width: 100%;
            font-size: 8.5pt;
        }        

        .waiver_files table thead {
            background-color: #005FA9;
            color: #ffffff;
        }

        .waiver_files table thead th {            
            padding: 2px 1px;
            text-align: left;
        }

        .waiver_files table tbody tr {
            line-height: 2em;
        }

        /* Help Dialog */
        .help_dialog {
            font-size: 10pt;
        }

        .help_dialog h1 {
            font-size: 14pt;
            color: #005fa9 !important;
            margin: 1em 0 1em 0;
        }

        .help_dialog h2 {
            font-size: 12pt;
            color: #1C43A6 !important;
            margin: 1em 0 0.5em 0;
        }

        .help_dialog h3 {
            font-size: 10pt;
            color: #000000 !important;
            margin: 0.75em 0 0em 0;
        }

        .help_dialog ul, ol {
            margin-left: 28px;
        }

        .help_dialog dl dt {
            float: left;
            width: 200px;
            text-align: right;
            margin-right: 20px;
            font-weight: bold;
            clear: both;
        } 
        
        /* Form Action Area */
        .action_area {
            padding: 1.5em 1em 0.5em 1em;
            background-color: #f2f2f2;
            border: 1px solid black;
            margin: -9px -10px 1em 0;
            position: relative;
            height: 2em;            
        }

        .action_area .title {
            position: absolute;
            font-size: 8pt;
            top: 0;
            left: 4px;
            color: #005fa9;
        }

        .action_area .status_path {
            float: right;
        }

        .action_area .status_path .state,
        .help_dialog .status_path .state {
            display: inline-block;
            color: #999999;
        }

        .action_area .status_path img,
        .help_dialog .status_path img {
            position: relative;
            top: 2px;
        }

        .action_area .status_path .state.current,
        .help_dialog .status_path .state.current {
            font-weight: bold;
            color: #000000;
        }

        .action_area .status_path .state.complete,
        .help_dialog .status_path .state.complete {
            color: #77aa77;
        }

        /* Disallow direct printing */
        @media print {
            #content {
                display: none;
            }

            body:after {
                content: "You cannot directly print this page.  Please use the print feature.";
            }

            body {
                font-size: 16pt;
                text-align: center;
            }
        }

    </style>

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

<?php $__env->startSection('jquery_init'); ?>
			
    if(!window.console)
    {
        window.console = { log: $.noop, group: $.noop, groupEnd: $.noop };            
    }
	/*console.log($.parseJSON('<?php echo json_encode($options); ?>'));*/

    // Success bar
	$('.success_bar').animate({ 'top' : 32, 'background-color' : 'rgba(176, 255, 190, 1.0)'}, 1600, 'easeOutQuad', function ()
	{		
		$(this).delay(6000).fadeOut(4000);	

		$(this).hover(function ()
		{
			$(this).stop(true).css('opacity', '1.0');
		},
		function ()
		{
			$(this).fadeOut(4000);
		})
	});

    <?php if (Session::has('submitted') or Input::has('submitted')): ?>
        showHelp('submitted', true);
    <?php endif; ?>

    /* ShowHelp
     *
     * Shows a help topic.
     */
    function showHelp(help_topic, no_button)
    {
        if (no_button !== true)
        {
            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : true,
                    height : 725,
                    minHeight : 400,
                    width : 615,
                    minWidth : 330,
                    modal : false,                    
                    title : 'Eligibility Form Help',
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            dialog_object.html("<div class='ajax_loader' style='width:16px; height:11px; margin:4em auto; background-image: url(http://www.osaa.org/images/icons/ajax_loader2.gif); background-repeat:no-repeat;'></div>");

                            var jqxhr = $.ajax(
                                      {
                                          type : 'GET',
                                          url : '<?php echo url('forms/eligibility/' . $object->waiver->id . '/help'); ?>?topic=' + help_topic,
                                          dataType : 'html'
                                      })
                                      .done(function (returned_data)
                                      {                               
                                          dialog_object.html(returned_data);
                                      })
                                      .fail(function (jqXHR, status, error)
                                      {                                                   
                                          var response = jqXHR.responseText;
                                          var errorData = $.parseJSON(response);
                                          //console.log(errorData);
                                          alert ("There was an error looking up help information.\n\nThis page will be reloaded.");
                                          location.reload();
                                      })
                                      .complete(function ()
                                      {
                                           
                                      });                            
                            
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            $(dialog_object).remove();
                        }                
                });
        }
        else
        {
            $('<div></div>')
                .appendTo('body')
                .css({'z-index':'2000 !important'})
                .dialog(
                {                       
                    draggable : false,
                    resizable : false,
                    height : 725,
                    minHeight : 725,
                    width : 615,                    
                    modal : true,
                    dialogClass : 'no-close',
                    <?php if (Helpers::strEqual($object->waiver_type->default_handler_type, 'Executive Director')): ?>                    
                        title : 'Eligibility Form Submitted',
                    <?php else: ?>
                        title : 'Eligibility Form Ready',
                    <?php endif; ?>
                    open : function ()
                        {  
                            var dialog_object = $(this);                            

                            dialog_object.html("<div class='ajax_loader' style='width:16px; height:11px; margin:4em auto; background-image: url(http://www.osaa.org/images/icons/ajax_loader2.gif); background-repeat:no-repeat;'></div>");

                            var jqxhr = $.ajax(
                                      {
                                          type : 'GET',
                                          url : '<?php echo url('forms/eligibility/' . $object->waiver->id . '/help'); ?>?topic=' + help_topic,
                                          dataType : 'html'
                                      })
                                      .done(function (returned_data)
                                      {                               
                                          dialog_object.html(returned_data);
                                      })
                                      .fail(function (jqXHR, status, error)
                                      {                                                   
                                          var response = jqXHR.responseText;
                                          var errorData = $.parseJSON(response);
                                          //console.log(errorData);
                                          alert ("There was an error looking up help information.\n\nThis page will be reloaded.");
                                          location.reload();
                                      })
                                      .complete(function ()
                                      {
                                           $('.close_submitted_button', dialog_object)
                                               .button()
                                               .click(function ()
                                               {
                                                   window.open ("<?php echo url('/forms/eligibility/' . $object->waiver->id . '/print'); ?>");

                                                   dialog_object.dialog("close");
                                               });

                                           // Shake action items
                                          function shakeTheseActionImages (object)
                                          {
                                              var direction;
                                              if ($(object).has('[data-direction]'))
                                              {
                                                  var direction = $(object).attr('data-direction');
                                              }                                              
                                              if (typeof direction == 'undefined')        
                                              {
                                                  var direction = 'left';
                                              }          
                                              $(object).effect("shake", {direction : direction, distance : 5, times : 1}, 600, function ()
                                              {
                                                  $(this).delay(Math.floor(Math.random() * 4000) + 2000);
                                                  shakeTheseActionImages($(this));
                                              });        
                                          }  
                                          
                                          var img = $('img.action_item', dialog_object);
                                          img.position({my:"center center", at : "right+30 center", of : ".close_submitted_button"});

                                          shakeTheseActionImages(img);  
                                      });                            
                            
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            $(dialog_object).remove();
                        } 
                });
        }
    }


    /* 
     * Help button    
     */
    $('.help_button')
        .button({'icons':{'primary':'ui-icon-help'}})
        .css({'font-size':'9pt', 'margin-right':'10px'})
        .click(function(event)
        {
            var object = $(this);

            event.preventDefault();

            var topic = object.attr('data-topic');            

            showHelp(topic);
        });


    /* Close Button
     *
     */
    $('.close_button')
        .button({'icons':{'primary':' ui-icon-circle-close'}})
        .css({'font-size':'9pt'});   


    /*
     * Withdraw Button
     */
    $('[data-action="withdraw"]')
        .click(function(event)
        {
            event.preventDefault();

            var button = $(this); 
            button.blur();
            
            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    modal : true,
                    draggable : true,
                    resizable : false,
                    height : 375,
                    width : 600,                    
                    title : 'Confirm Form Withdrawal',
                    buttons: [
                        {
                            text : "Withdraw Request",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-check'},
                            click : function()
                                    {                                                       
                                        var reason = $('[name="withdraw_notes"]').val();

                                        if (reason == '')
                                        {
                                            alert('In order to withdraw this form, you must provide a reason.');
                                            return;
                                        }

                                        if ($('[name="send_notification_wtdn"]', $(this)).is('[type="hidden"]'))
                                        {
                                            var notify = 1;
                                        }
                                        else
                                        {
                                            if ($('[name="send_notification_wtdn"]', $(this)).is(':checked'))
                                            {
                                                var notify = 1;
                                            }
                                            else
                                            {
                                                var notify = 0;
                                            }
                                        }

                                        var data = { 'reason' : reason,
                                                     'notify' : notify,
                                                     'waiver_id' : <?php echo $object->waiver->id; ?> };

                                        $('<div><div>')
                                            .addClass('ui-widget-overlay ui-front')
                                            .appendTo('body');
                                          
                                        $('<div><div>').appendTo('body')
                                            .css('width', '225px')
                                            .css('height', '170px')
                                            .css('text-align', 'center')
                                            .css('padding', '0.5em')
                                            .position({my : "center center", at : "center center", of : window})
                                            .addClass('ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-di    buttons')
                                            .html('<br />Updating...<br /><br /><img src="http://www.osaa.org/images/icons/ajax_loader3.gif" /><div style="font-size: 8pt; line-height: 105%; margin-top: 2em;">Please wait, this may take a while to process...</div>');

                                        // Submit the change
                                        var jqxhr = $.ajax(
                                            {
                                                type : 'POST',
                                                url : '<?php echo url('/forms/eligibility/' . $object->waiver->id . '/withdraw'); ?>',
                                                data : data,
                                                dataType : 'html'
                                            })
                                            .done(function (data)
                                            {                                                
                                                // Reload of refresh is specified
                                                window.location.href= "<?php echo url('/forms/eligibility'); ?>";
                                            })
                                            .fail(function (jqXHR, status, error)
                                            {                                                   
                                                var response = jqXHR.responseText;
                                                var errorData = $.parseJSON(response);
                                                //console.log(errorData);
                                                alert ("There was an error saving changes.\n\nThis page will be reloaded.");
                                                location.reload();
                                            });              
                                    }
                        },                        
                        {
                            text : "Cancel",
                            'class' : "float_right",
                            'data-autofocus' : "true",
                            icons : { primary : 'ui-icon-cancel'},
                            click : function()
                                    {
                                        // Close the dialog box
                                        $(this).dialog("close"); 
                                    }
                        }
                    ],
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            var html = '<div style="font-size: 10pt; margin: 1em 0;">';
                            html += '<span class="ui-icon ui-icon-alert" style="display: inline-block; vertical-align: middle; margin-right: 4px;"></span>';
                            html += '<b>Are you sure you want to withdraw your eligibility request?</b>';
                            html += '<br /><br />';
                            html += '<div class="small gray">This cannot be undone.  If you withdraw your waiver request, your form cannot be reinstated.  If you do want to withdraw this form, please provide a reason below.</div>';
                            html += '<br />Suggested Reasons:';
                            html += '<select name="withdraw_reasons" style="margin-left: 4px;">';
                            html += '<option value=""></option>';
                            html += '<option value="No longer requesting eligibility.">Request Withdrawn</option>';
                            html += '<option value="This form was a duplicate eligibility request.">Duplicate Eligibility Request</option>';
                            <?php if (Auth::user()->isOsaaUser()): ?>
                                html += '<option value="Neglected, insufficient form left unhandled.">Neglected Insufficient Form</option>';
                            <?php endif; ?>
                            html += '</select>';

                            <?php if (Auth::user()->isOsaaUser()): ?>
                                html += '<label style="margin-left: 20px;">Send E-Mail<input type="checkbox" name="send_notification_wtdn" value="1" style="vertical-align: middle; margin-left: 10px;" /></label>';
                            <?php else: ?>
                                html += '<input type="hidden" name="send_notification_wtdn" value="1" />';
                            <?php endif; ?>

                            html += '<br /><br /><b>Reason for Withdrawal</b><br />';
                            html += '<textarea name="withdraw_notes" style="width: 100%; height: 4em;"></textarea>'
                            html += '</div>';

                            dialog_object.html(html);
                            
                            $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
                            $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');   

                            $('[data-autofocus="true"]').focus();

                            $('[name="withdraw_reasons"]', dialog_object).change(function()
                            {
                                var value = $(this).val();

                                $('[name="withdraw_notes"]').text(value);
                            });
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);
                            $(dialog_object).remove();
                        }                
                });
        });


    /* Waiver Status Helper
     *
     * Shows the waiver status description when link is clicked.
     */
    $('[name="waiver_status_help"]')
        .click(function(event)
        {
            event.preventDefault();

            var link = $(this);

            var name = $(link).attr('data-name');
            var description = $(link).attr('data-description');            

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    resizable: false,
                    height: 'auto',
                    width: 400,
                    modal: false,                   
                    title: 'Waiver Status: ' + name,
                    open : function ()
                        {  
                            var dialog_object = $(this);                            

                            dialog_object.html(description);                            
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            $(dialog_object).remove();
                        }                
                });

        });

    /* Waiver Log
     *
     * Shows the waiver log when link is clicked.
     */
    $('[name="waiver_log"]')
        .click(function(event)
        {
            event.preventDefault();

            var link = $(this);

            var data = {created_at : "<?php echo date('n/j/y g:ia', strtotime($object->waiver->created_at)); ?>",
                        updated_at : "<?php echo date('n/j/y g:ia', strtotime($object->waiver->updated_at)); ?>"};
                        

            var html = '<div style="font-size: 10pt;"><div style="display: inline-block; width: 130px;">Waiver Created:</div>' + data.created_at + '<br /><div style="display: inline-block; width: 130px;">Last Updated:</div>' + data.updated_at + '<table style="width: 100%; border-collapse: collapse; margin-top: 1em;"><tbody>';

            <?php foreach ($object->data->status_history as $log): ?>

                html += '<tr><td style="padding-right: 15px;"><?php echo date('n/j/y g:ia', strtotime($log->updated_at)); ?></td>';
                html += '<td style="padding-right: 15px;"><?php echo $log->status; ?></td>';
                html += '<td style=""><?php echo str_replace('\'', '\\\'', $log->user); ?></td></tr>';

            <?php endforeach; ?> 

            html += '</tbody></table></div>';

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    resizable: false,
                    height: 'auto',
                    width: 425,
                    modal: false,                   
                    title: 'Waiver Log',
                    open : function ()
                        {  
                            var dialog_object = $(this);                            

                            dialog_object.html(html);
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            $(dialog_object).remove();
                        }                
                });

        });

    // Download all files to a ZIP archive button
    $('.download_zip_files')
        .button({'icons' : {'secondary' : 'ui-icon-suitcase'}})
        .css({'font-size' : '8.5pt',
              'float' : 'right',              
              'position' : 'relative',
              'top' : '-0.5em'});

    // Table row highlighter
    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(); 

    /*
     * Action Area Buttons
     */
    $('.action_area a')
        .css({'font-size' : '9pt',
              'margin-right' : '1em'})
        .button()
        .each(function ()
        {
            var link = $(this);

            if (link.has('[data-icon]'))
            {
                var icon = link.attr('data-icon');
                link.button({'icons' : {'primary' : icon }});
            }

            if (link.has('[data-help]'))
            {
                var help = link.attr('data-help');
                link.tooltip({'content' : help, 'items' : 'a'});
            }
        });

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

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

    <a href="#" class="help_button" data-topic="view">Help</a>	
    <a href="<?php echo url('/forms/eligibility'); ?>" class="close_button">Close</a>
    
<?php $__env->stopSection(); ?>


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

 	<?php /*  Success Bar  */ ?>
 	<?php if (Session::has('success')): ?>
		<div class="success_bar">
			<div class="message">				
				<?php echo Session::get('success'); ?>
			</div>			
		</div>
	<?php endif; ?>


    <?php /*  Action Area  */ ?>
    <div class="ui-corner-bottom action_area">
        <div class="title">
            Form Actions
        </div>
        
        <?php $action_count = 0; ?>

        <?php foreach ($options['action_items'] as $action => $info): ?>

            <?php if ($info['enabled'] and Helpers::strEqual($action, array('print', 'edit', 'merge', 'withdraw'))): ?>

                <?php $action_count++; ?>

                <a href="<?php echo (isset($info['link'])) ? $info['link'] : '#'; ?>"
                   <?php if (isset($info['target'])): ?> target="<?php echo $info['target']; ?>" <?php endif; ?>
                   <?php if (isset($info['icon'])): ?> data-icon="<?php echo $info['icon']; ?>" <?php endif; ?>
                   <?php if (isset($info['help'])): ?> data-help="<?php echo $info['help']; ?>" <?php endif; ?>
                   data-action="<?php echo $action; ?>">
                   <?php echo $info['text']; ?>
                </a>

            <?php endif; ?>

        <?php endforeach; ?>

        <?php if ($action_count == 0): ?>
            No actions to perform.
        <?php endif; ?>

        <div class="status_path">
            <?php if (Helpers::strEqual($object->waiver->waiver_status, array('WORK'))): ?>
                <div class="state current">WORK</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">RECD</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">PEND</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">DONE</div>
            <?php elseif (Helpers::strEqual($object->waiver->waiver_status, array('RECD'))): ?>
                <div class="state complete">WORK</div>
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <div class="state current">RECD</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">PEND</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">DONE</div>
            <?php elseif (Helpers::strEqual($object->waiver->waiver_status, array('PEND'))): ?>
                <div class="state complete">WORK</div>
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <div class="state complete">RECD</div>
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <div class="state current">PEND</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">DONE</div>
            <?php elseif (Helpers::strEqual($object->waiver->waiver_status, array('DONE', 'ARCH'))): ?>
                <div class="state complete">WORK</div>
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <div class="state complete">RECD</div>
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <div class="state complete">PEND</div>
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <div class="state current">DONE</div>
             <?php elseif (Helpers::strEqual($object->waiver->waiver_status, array('APPL'))): ?>
                <div class="state complete">WORK</div>
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <div class="state complete">RECD</div>
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <div class="state complete">PEND</div>
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_complete.png'); ?>" alt="" title="" />
                <div class="state current">APPL</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">DONE</div>
            <?php elseif (Helpers::strEqual($object->waiver->waiver_status, array('INSF'))): ?>
                <div class="state current">INSF</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">RECD</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">PEND</div>
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <img src="<?php echo asset('/images/icons/progress_not_yet.png'); ?>" alt="" title="" />
                <div class="state">DONE</div>
            <?php elseif (Helpers::strEqual($object->waiver->waiver_status, array('WTDN'))): ?>
                <div class="state current">WTDN</div>                
            <?php endif; ?>            
        </div>
        
    </div>

    <?php if (Helpers::strEqual($object->waiver_status->slug, 'WORK')): ?>
        <?php /*  Work in Progress  */ ?>
        <div class="ui-state-highlight" style="padding: 0.25em 0.5em; margin-bottom: 1em; line-height: 32px; font-size: 14pt; font-weight: bold;">
            <img src="<?php echo asset('/images/icons/construction_64px.png'); ?>" alt="" title="" style="float: left; width: 32px; display: inline-block; margin-right: 10px;" />

            This form has not been submitted.  Click Edit for edit mode to submit the form.
            <br class="clear" />
        </div>
    <?php endif; ?>


    <?php /*  Errors  */ ?>
    <?php if (Session::has('errors')): ?>        
        <div class="error ui-state-error" style="padding: 0.5em; font-size: 12pt;">
            <span class="ui-icon ui-icon-alert box_icon"></span>
            <?php foreach ($errors->all() as $error): ?>
                <?php echo $error; ?>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>


    <?php /*  Insufficient Notes  */ ?>
    <?php if (Helpers::strEqual($object->waiver->waiver_status, 'INSF')): ?>
        <div class="error ui-state-highlight" style="padding: 0.5em; font-size: 12pt; margin-bottom: 1em;">
            <span class="ui-icon ui-icon-alert box_icon"></span>
            <b>Form Returned as Insufficient on <?php echo date('n/j/Y', strtotime(end($object->data->insufficient_notes)->returned_at)); ?></b><br />
            <?php echo end($object->data->insufficient_notes)->notes; ?> [<i><?php echo end($object->data->insufficient_notes)->user; ?></i>]
        </div>
    <?php endif; ?>

    <div class="info_id_info">
        <div class="label">Form ID Number:</div>
        <a href="#" name="waiver_log"><?php echo $object->waiver->id; ?></a>
        <?php if (!is_null($object->waiver->number)): ?>
            <br />
            <div class="label">Reference Number:</div> <?php echo $object->waiver->number; ?>
        <?php endif; ?>
        <br />
        <div class="label">Status:</div> <a href="#" name="waiver_status_help" data-name="<?php echo $object->waiver_status->name; ?>" data-description="<?php echo $object->waiver_status->description; ?>"><?php echo $object->waiver_status->slug; ?></a>
        <br />
        <div class="label">School Year:</div> <?php echo $object->school_year->name; ?>
        <br />
        <div class="label">Submitted:</div> <?php echo $object->latest_received_at; ?>
    </div>    

    <h1><?php echo $object->student->getDisplayName(); ?></h1>

    <h2><?php echo $object->waiver_type->slug; ?> Hardship Appeal</h2>

    <div style="font-size: 9pt;">
         <?php if (!Helpers::strIsEmpty($object->waiver_type->rule_link_path)): ?>
            <a href="<?php echo url($object->waiver_type->rule_link_path); ?>" target="_blank">OSAA Rule <?php echo $object->waiver_type->rule; ?></a>, handled by
        <?php else: ?>
            Handled by
        <?php endif; ?>
        <?php echo $object->waiver_type->default_handler_type; ?>
    </div>

    <div style="clear: both; margin-top: 1em;">

        <div style="width: 750px; float: left;">

            <div style="float: left;">
                <b><a href="<?php echo url('/schools/' . $object->school->id); ?>" target="_blank"><?php echo $object->school->name; ?></a></b>
                <?php if (!is_null($object->school->address)): ?>
                    <br />
                    <?php echo $object->school->address->line_1; ?><br />
                    <?php echo $object->school->address->city; ?>, <?php echo $object->school->address->state; ?> <?php echo $object->school->address->zip; ?><br />
                    <?php echo Helpers::displayCombinedPhone($object->school->getPhoneNumbers('W', false)->number); ?>
                <?php endif; ?>
            </div>

            <?php if (!is_null($object->school->principal)): ?>
                <div style="float: left; margin: 1em 0 0 50px;">
                    <?php echo $object->school->principal->getDisplayName(); ?>, Principal
                    <?php if (!Helpers::strIsEmpty($object->school->principal->email)): ?>
                        <br />
                        <?php echo $object->school->principal->getDisplayEmail(); ?>
                    <?php endif; ?>
                    <?php if (!Helpers::strIsEmpty($object->school->principal->getDisplayPhone())): ?>
                        <br />
                        <?php echo $object->school->principal->getDisplayPhone(); ?>
                    <?php endif; ?>
                </div>
            <?php endif; ?>

            <?php if (!is_null($object->school->ad)): ?>
                <div style="float: left; margin: 1em 0 0 50px;">
                    <?php echo $object->school->ad->getDisplayName(); ?>, Athletic Director
                    <?php if (!Helpers::strIsEmpty($object->school->ad->email)): ?>
                        <br />
                        <?php echo $object->school->ad->getDisplayEmail(); ?>
                    <?php endif; ?>
                    <?php if (!Helpers::strIsEmpty($object->school->ad->getDisplayPhone())): ?>
                        <br />
                        <?php echo $object->school->ad->getDisplayPhone(); ?>
                    <?php endif; ?>
                </div>
            <?php endif; ?>

            <br class="clear" />
        </div>


        <div style="width: 265px; float: left;">
            <b>Current Eligibility Status</b><br />
            <?php if (!$object->data->withdrawal->is_withdrawn): ?>
                <?php if (count($object->data->decisions) < 1): ?>
                    <?php if (Helpers::strEqual($object->waiver_type->default_handler_type, 'District Athletic Committee')): ?>
                        <?php if (Helpers::strEqual($object->waiver_status->slug, 'WORK')): ?>
                            <span style="color: #990000; font-weight: bold;">Not Eligible</span>
                        <?php else: ?>
                            <span style="color: #B727D6; font-weight: bold;">Refer to DAC Decision</span>
                        <?php endif; ?>
                    <?php else: ?>
                        <span style="color: #990000; font-weight: bold;">Not Eligible</span>
                    <?php endif; ?>
                <?php elseif ($object->data->decisions[0]->is_eligible): ?>
                    <span style="color: #0d581b; font-weight: bold;">Eligible</span><br />
                    Eligible as of <?php echo date('n/j/Y', strtotime($object->data->decisions[0]->eligible_at)); ?>
                <?php else: ?>                
                    <span style="color: #990000; font-weight: bold;">Not Eligible</span>
                    <br />
                    Ruled on <?php echo date('n/j/Y', strtotime($object->data->decisions[0]->decided_at)); ?>
                <?php endif; ?>
            <?php else: ?>                            
                <span style="color: #F79700; font-weight: bold;">Request Withdrawn <?php echo date('n/j/y', strtotime($object->data->withdrawal->withdrawn_at)); ?></span>
                <?php if (!Helpers::strIsEmpty($object->data->withdrawal->notes)): ?>
                    <br />
                    <div style="font-size: 9pt; line-height: 1.15em;"><?php echo $object->data->withdrawal->notes; ?> -<?php echo $object->data->withdrawal->user; ?></div>
                <?php endif; ?>
            <?php endif; ?>
        </div>

        <br class="clear" />
    </div>

    <br />

    <div class="student_info">

        <div style="float: left; width: 300px; margin-right: 40px;">
            <h3>Student Information</h3>        
        
            <div class="label">First Name</div><?php echo $object->student->first_name; ?><br />
            <div class="label">M.I.</div><?php echo $object->student->middle_initial; ?><br />
            <div class="label">Last Name</div><?php echo $object->student->last_name; ?><br /><br />            

            <div class="label">Grade</div>

            <?php if (Helpers::strIsEmpty($object->data->student->grade)): ?>
                Not Provided
            <?php else: ?>
                <?php echo $object->data->student->grade; ?>th
            <?php endif; ?>
            <br /><br />            
            
            <div class="label">Age</div><?php
                $now = time();
                $dob = strtotime($object->student->birth_date);

                $elasped = $now - $dob;

                $years = floor($elasped / 365 / 24 / 60 / 60);

                $elasped -= $years * 365 * 24 * 60 * 60;

                $months = floor(($elasped / 365 / 24 / 60 / 60) * 12);
                
                if ($months > 1)
                {
                    echo sprintf('%d years %d months', $years, $months);
                }
                elseif ($months == 1)
                {
                    echo sprintf('%d years %d month', $years, $months);
                }
                else
                {
                    echo sprintf('%d years', $years);   
                }
            ?><br />
            <div class="label">&nbsp;</div><span style="font-size: 9pt;">(as of <?php echo date('n/j/y', time()); ?>)</span><br />
            <div class="label">Birth Date</div><?php echo date('n/j/Y', strtotime($object->student->birth_date)); ?>
            
            <br /><br />
            
            <div class="label">Country</div><?php echo $object->student->country->name; ?>

            <br /><br />

            <div class="label">Has IEP?</div><?php echo ($object->data->student->has_iep) ? 'Yes' : 'No'; ?><br />
            <div class="label">Meeting IEP?</div><?php echo ($object->data->student->has_iep) ? (($object->data->student->meeting_iep) ? 'Yes' : 'No') : 'N/A'; ?>

            <br /><br />

            <?php if (!Helpers::strIsEmpty($object->data->student->current_school)): ?>
                
                <div class="label">Current School</div><div style="width: 185px; display: inline-block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;"><?php echo $object->data->student->current_school; ?></div>

                <br /><br />
            <?php endif; ?>

            <?php if (!Helpers::strIsEmpty($object->data->student->previous_school)): ?>
                
                <div class="label">Prev. School</div><div style="width: 185px; display: inline-block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;"><?php echo $object->data->student->previous_school; ?></div>

                <br /><br />
            <?php endif; ?>
            
        </div>

        <div class="student_records" style="float: left; width: 680px;">
            <h3>Student Enrollment Record</h3>            
            
            <table>
                <thead>
                    <tr>
                        <th>SY</th>
                        <th>GR</th>
                        <th>Period</th>
                        <th>Dates</th>
                        <th>School</th>
                        <th># Credits Earned</th>
                        <th># Classes Passed</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($object->data->student->records as $record): ?>
                        <tr>
                            <td><?php echo $record->school_year; ?>-<?php echo substr((intval($record->school_year) + 1), 2, 2); ?></td>
                            <td><?php echo $record->grade; ?></td>
                            <td><?php echo $record->period; ?></td>
                            <td><?php echo date('n/j/y', strtotime($record->first_date)); ?> to <?php echo date('n/j/y', strtotime($record->last_date)); ?></td>
                            <td><?php echo $record->school; ?></td>
                            <td><?php echo $record->credits_earned; ?></td>
                            <td><?php echo $record->classes_passed; ?></td>
                        </tr>
                    <?php endforeach; ?>

                    <?php if (count($object->data->student->records) == 0): ?>
                        <tr>
                            <td colspan="7">No student enrollment records have been added.</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <br class="clear" />

        <?php if (!Helpers::strIsEmpty($object->data->student->notes)): ?>
            <b>Notes</b><br />
            <?php echo $object->data->student->notes; ?>

            <br class="clear" />
        <?php endif; ?>

    </div>

    <br />

    <div />

        <div class="student_info" style="float: left; width: 310px; margin-right: 40px;">

            <h3>
                Residence
                <?php if ($object->data->stewards->residing->is_governing): ?>
                    with Parent/Guardian
                <?php endif; ?>
            </h3>

            <div class="label">Name</div>
            <?php if (Helpers::strIsEmpty($object->data->stewards->residing->name)): ?>
                Not Provided
            <?php else: ?>
                <?php echo $object->data->stewards->residing->name; ?>
            <?php endif; ?>

            <br />
            
            <div class="label">Relation</div>
            <?php if (Helpers::strIsEmpty($object->data->stewards->residing->relation)): ?>
                Not Provided
            <?php else: ?>
                <?php echo $object->data->stewards->residing->relation; ?>
            <?php endif; ?>

            <br /><br />

            <div class="label">Address</div>
            <?php if (!Helpers::strIsEmpty($object->data->stewards->residing->address->line_1) or 
                 !Helpers::strIsEmpty($object->data->stewards->residing->address->line_2) or 
                 !Helpers::strIsEmpty($object->data->stewards->residing->address->city) or 
                 !Helpers::strIsEmpty($object->data->stewards->residing->address->state) or 
                 !Helpers::strIsEmpty($object->data->stewards->residing->address->zip)): ?>

                <?php if (!Helpers::strIsEmpty($object->data->stewards->residing->address->line_1)): ?>
                    <?php echo $object->data->stewards->residing->address->line_1; ?><br />
                <?php endif; ?>

                <?php if (!Helpers::strIsEmpty($object->data->stewards->residing->address->line_2)): ?>
                    <div class="label">&nbsp;</div><?php echo $object->data->stewards->residing->address->line_2; ?><br />
                <?php endif; ?>
                <div class="label">&nbsp;</div><?php echo $object->data->stewards->residing->address->city; ?>, <?php echo $object->data->stewards->residing->address->state; ?> <?php echo $object->data->stewards->residing->address->zip; ?>
            <?php else: ?>
                Not Provided
            <?php endif; ?>

            <br /><br />

            <?php if (!Helpers::strIsEmpty($object->data->stewards->residing->email)): ?>                
                <div class="label">E-Mail</div><a href="mailto:<?php echo $object->data->stewards->residing->email; ?>"><?php echo $object->data->stewards->residing->email; ?></a><br /><br />
            <?php endif; ?>

            <?php if (!Helpers::strIsEmpty($object->data->stewards->residing->phone)): ?>                
                <div class="label">Phone</div><?php echo Helpers::displayCombinedPhone($object->data->stewards->residing->phone); ?>
                <br /><br />
            <?php endif; ?>

            <?php if (!Helpers::strIsEmpty($object->data->stewards->residing->notes)): ?>            
                <div class="label">Notes</div><?php echo $object->data->stewards->residing->notes; ?><br />
            <?php endif; ?>


        </div>

        <?php if (!$object->data->stewards->residing->is_governing): ?>
            <div class="student_info" style="float: left; width: 310px; margin-right: 40px;">
                
                <h3>Parent/Guardian</h3>

                <div class="label">Name</div><?php echo $object->data->stewards->governing->name; ?><br />
                <div class="label">Relation</div><?php echo $object->data->stewards->governing->relation; ?><br />

                <br />

                <div class="label">Address</div><?php echo $object->data->stewards->governing->address->line_1; ?><br />
                <?php if (!Helpers::strIsEmpty($object->data->stewards->governing->address->line_2)): ?>
                    <div class="label">&nbsp;</div><?php echo $object->data->stewards->governing->address->line_2; ?><br />
                <?php endif; ?>
                <div class="label">&nbsp;</div><?php echo $object->data->stewards->governing->address->city; ?>, <?php echo $object->data->stewards->governing->address->state; ?> <?php echo $object->data->stewards->governing->address->zip; ?><br /><br />

                <?php if (!Helpers::strIsEmpty($object->data->stewards->governing->email)): ?>                
                    <div class="label">E-Mail</div><a href="mailto:<?php echo $object->data->stewards->governing->email; ?>"><?php echo $object->data->stewards->governing->email; ?></a><br /><br />
                <?php endif; ?>

                <?php if (!Helpers::strIsEmpty($object->data->stewards->governing->phone)): ?>                
                    <div class="label">Phone</div><?php echo Helpers::displayCombinedPhone($object->data->stewards->governing->phone); ?>
                    <br /><br />
                <?php endif; ?>

                <?php if (!Helpers::strIsEmpty($object->data->stewards->governing->notes)): ?>            
                    <div class="label">Notes</div><?php echo $object->data->stewards->governing->notes; ?><br />
                <?php endif; ?>


            </div>
        <?php endif; ?>

        <?php if (!Helpers::strIsEmpty($object->data->stewards->past_residing->name) or             
             !Helpers::strIsEmpty($object->data->stewards->past_residing->address->line_1) or 
             !Helpers::strIsEmpty($object->data->stewards->past_residing->address->line_2) or 
             !Helpers::strIsEmpty($object->data->stewards->past_residing->address->city) or             
             !Helpers::strIsEmpty($object->data->stewards->past_residing->address->zip) or
             !Helpers::strIsEmpty($object->data->stewards->past_residing->email) or
             !Helpers::strIsEmpty($object->data->stewards->past_residing->phone) or 
             !Helpers::strIsEmpty($object->data->stewards->past_residing->notes) or
             $object->data->stewards->past_residing->is_same): ?>
            <div class="student_info" style="float: left; width: 310px;">
                
                <h3>Last Year's Residence</h3>

                <?php if ($object->data->stewards->past_residing->is_same): ?>
                
                    <b>Same as current address</b>    
                
                <?php else: ?>

                    <div class="label">Name</div><?php echo $object->data->stewards->past_residing->name; ?><br />
                    <div class="label">Relation</div><?php echo $object->data->stewards->past_residing->relation; ?><br />

                    <br />

                    <div class="label">Address</div><?php echo $object->data->stewards->past_residing->address->line_1; ?><br />
                    <?php if (!Helpers::strIsEmpty($object->data->stewards->past_residing->address->line_2)): ?>
                        <div class="label">&nbsp;</div><?php echo $object->data->stewards->past_residing->address->line_2; ?><br />
                    <?php endif; ?>
                    <div class="label">&nbsp;</div><?php echo $object->data->stewards->past_residing->address->city; ?>, <?php echo $object->data->stewards->past_residing->address->state; ?> <?php echo $object->data->stewards->past_residing->address->zip; ?><br /><br />

                    <?php if (!Helpers::strIsEmpty($object->data->stewards->past_residing->email)): ?>                
                        <div class="label">E-Mail</div><a href="mailto:<?php echo $object->data->stewards->past_residing->email; ?>"><?php echo $object->data->stewards->past_residing->email; ?></a><br /><br />
                    <?php endif; ?>

                    <?php if (!Helpers::strIsEmpty($object->data->stewards->past_residing->phone)): ?>                
                        <div class="label">Phone</div><?php echo Helpers::displayCombinedPhone($object->data->stewards->past_residing->phone); ?>
                        <br /><br />
                    <?php endif; ?>

                    <?php if (!Helpers::strIsEmpty($object->data->stewards->past_residing->notes)): ?>            
                        <div class="label">Notes</div><?php echo $object->data->stewards->past_residing->notes; ?><br />
                    <?php endif; ?>

                <?php endif; ?>                

            </div>
        <?php endif; ?>
        

        <br class="clear" />
    </div>

    <br />

    <?php if (!Helpers::strIsEmpty($object->data->notes)): ?>
        <div class="student_info">
            <h3>Notes</h3>
            <b>General Notes</b><br />
            <?php echo $object->data->notes; ?>        
        </div>

        <br />
    <?php endif; ?>    

    <?php /* 
    <div class="decision_history">
        <h3>Decisions</h3>   

        <table>
            <thead>
                <tr>
                    <th>Type</th>
                    <th>Status</th>
                    <th>Decision</th>
                    <th style="padding-right: 10px;">Decided</th>
                    <th style="padding-right: 10px;">Notified</th>
                    <th>Notes</th>
                </tr>
            </thead>

            <tbody>
                <?php if (!Helpers::strEqual($object->waiver_status->slug, array('WORK', 'INSF'))): ?>

                    <?php $count = 0; ?>
                    <?php foreach ($object->data->decisions as $decision): ?>
                        <?php if (!Helpers::strIsEmpty($decision->type)): ?>
                            <?php $count++; ?>
                            <tr>
                                <td style="white-space: nowrap; padding-right: 10px;"><?php echo $decision->type; ?></td>
                                <td style="white-space: nowrap; padding-right: 10px;">
                                    <?php if (Helpers::strIsEmpty($decision->decided_at)): ?>                                        
                                        
                                        <?php if (Helpers::strEqual($object->waiver_status->slug, 'WTDN')): ?>
                                            No Decision Made - Withdrawn
                                        <?php else: ?>
                                            Waiting for decision
                                        <?php endif; ?>

                                    <?php else: ?>

                                        Decision Made

                                    <?php endif; ?>
                                </td>
                                <td style="white-space: nowrap; padding-right: 10px;">
                                    <?php if (Helpers::strIsEmpty($decision->decided_at)): ?>
                                        - -
                                    <?php else: ?>
                                        <?php if ($decision->is_eligible): ?>
                                            Waiver Approved
                                        <?php else: ?>
                                            Waiver Denied
                                        <?php endif; ?>
                                    <?php endif; ?>
                                </td>
                                <td style="white-space: nowrap; padding-right: 10px;">
                                    <?php if (Helpers::strIsEmpty($decision->decided_at)): ?>
                                        - -
                                    <?php else: ?>
                                        <?php echo date('n/j/y', strtotime($decision->decided_at)); ?>
                                    <?php endif; ?>
                                </td>
                                <td style="white-space: nowrap; padding-right: 10px;">
                                    <?php if (Helpers::strIsEmpty($decision->decided_at)): ?>
                                        - -
                                    <?php else: ?>
                                        
                                        <?php if (Helpers::strIsEmpty($decision->notified_at)): ?>
                                            - -
                                        <?php else: ?>
                                            <?php echo date('n/j/y', strtotime($decision->notified_at)); ?>
                                        <?php endif; ?>

                                    <?php endif; ?>
                                </td>
                                <td style="line-height: 1.25em;">
                                    <?php if (Helpers::strIsEmpty($decision->notes)): ?>
                                        - -
                                    <?php else: ?>
                                        <?php echo $decision->notes; ?>
                                    <?php endif; ?>
                                </td>
                            </tr>
                        <?php endif; ?>
                    <?php endforeach; ?>

                    <?php if ($count == 0): ?>
                        <tr>
                            <td colspan="6">
                                A decision regarding this student's eligibility had not been made yet.
                            </td>
                        </tr>
                    <?php endif; ?>
                <?php else: ?>

                    <tr>
                        <td colspan="6">
                            <?php if (Helpers::strEqual($object->waiver_status->slug, 'INSF')): ?>
                                Waiting for additional information to be provided before a decision can be made.
                            <?php else: ?>
                                Waiting for the form to be submitted before a decision can be made.
                            <?php endif; ?>
                        </td>
                    </tr>

                <?php endif; ?>
            </tbody>

        </table>
    </div>

    <br />

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

        <div class="appeal_history">
            <h3>Appeals</h3>   

            <table>
                <thead>
                    <tr>
                        <th>Type</th>
                        <th>Requested At</th>
                        <th>Scheduled At</th>                    
                        <th>Attending</th>
                        <th>Notes</th>
                    </tr>
                </thead>

                <tbody>
                    <?php $count = 0; ?>
                    <?php foreach ($object->data->appeals as $appeal): ?>
                        <?php if (!Helpers::strIsEmpty($appeal->type)): ?>
                            <?php $count++; ?>
                            <tr>
                                <td><?php echo $appeal->type; ?></td>
                                <td>
                                    <?php if (Helpers::strIsEmpty($appeal->requested_at)): ?>
                                        - -
                                    <?php else: ?>
                                        <?php echo date('n/j/y', strtotime($appeal->requested_at)); ?>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <?php if (Helpers::strIsEmpty($appeal->scheduled_at)): ?>
                                        - -
                                    <?php else: ?>
                                        <?php echo date('l n/j/y g:ia', strtotime($appeal->scheduled_at)); ?>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <?php if (Helpers::strIsEmpty($appeal->attending)): ?>
                                        - -
                                    <?php else: ?>
                                        
                                        <?php echo $appeal->attending; ?>

                                    <?php endif; ?>
                                </td>
                                <td>
                                    <?php if (Helpers::strIsEmpty($appeal->notes)): ?>
                                        - -
                                    <?php else: ?>
                                        <?php echo $appeal->notes; ?>
                                    <?php endif; ?>
                                </td>
                            </tr>
                        <?php endif; ?>
                    <?php endforeach; ?>

                    <?php if ($count == 0): ?>
                        <tr>
                            <td colspan="5">
                                The decision has not been appealed.
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>

            </table>
        </div>

        <br />
    <?php endif; ?>

     */ ?>

    <div class="waiver_files">
        
        <a href="<?php echo url('/forms/eligibility/' . $object->waiver->id . '/files/zip'); ?>" target="_blank" class="download_zip_files">Download All Files</a>

        <h3>Waiver Files</h3>
        
        <table>
            <thead>
                <tr>                    
                    <th>Code</th>
                    <th>FID</th>
                    <th>Name</th>
                    <th>Type</th>
                    <th>Uploaded</th>
                    <th>Link</th>
                </tr>
            </thead>

            <tbody>
                
                <?php foreach ($object->waiver_files as $file): ?>

                    <tr>
                        <td><?php echo $file->file_type_object->slug; ?></td>
                        <td><?php echo $file->id; ?></td>
                        <td><?php echo $file->path; ?></td>
                        <td><?php echo $file->file_type_object->name; ?></td>
                        <td><?php echo date('n/j/y g:ia', strtotime($file->updated_at)); ?></td>
                        <td><a href="<?php echo url('/forms/eligibility/' . $object->waiver->id . '/files/' . $file->id); ?>" target="_blank" class="no_print">View/Download</a></td>
                    </tr>

                <?php endforeach; ?>               
                

                <?php if (count($object->waiver_files) == 0): ?>

                    <tr>
                        <td colspan="6">
                            There are no supplemental files associated with this waiver.
                        </td>
                    </tr>

                <?php endif; ?>  

            </tbody>
        </table>

    </div>

    <br />


    <div class="associated_waivers">        

        <h3>
            Associated Waivers for <?php echo $object->student->last_name; ?>, <?php echo $object->student->first_name; ?> <?php echo $object->student->middle_initial; ?>            
        </h3>

        <table>
            <thead>
                <tr>
                    <th>ID #</th>
                    <th>Ref #</th>
                    <th>Year</th>
                    <th>Status</th>
                    <th>Type</th>
                    <th>School</th>
                    <th>Outcome</th>
                </tr>
            </thead>

            <tbody>

                <?php foreach ($object->other_waivers as $other_waiver): ?>
                
                    <tr>
                        <td>
                            <a href="<?php echo url('/forms/eligibility/' . $other_waiver->id ); ?>" target="_blank"><?php echo $other_waiver->id; ?></a>
                        </td>

                        <td>
                            <?php if (Helpers::strIsEmpty($other_waiver->number)): ?>
                                - -
                            <?php else: ?>
                                <?php echo $other_waiver->number; ?>
                            <?php endif; ?>
                        </td>

                        <td>
                            <?php echo $other_waiver->school_year; ?>-<?php echo (intval(substr($other_waiver->school_year, 2, 2)) + 1); ?>
                        </td>                    

                        <td>
                            <?php echo $other_waiver->waiver_status; ?>
                        </td>

                        <td>
                            <?php echo $other_waiver->waiver_type; ?>
                        </td>

                        <td>
                            <?php echo $other_waiver->school->short_name; ?>
                        </td>

                        <td>
                            <?php if (Helpers::strEqual($other_waiver->waiver_status, array('WORK'))): ?>
                                Form has not been submitted yet
                            <?php elseif (Helpers::strEqual($other_waiver->waiver_status, array('RECD', 'PEND'))): ?>
                                Decision is pending
                            <?php elseif (Helpers::strEqual($other_waiver->waiver_status, array('INSF'))): ?>
                                Insufficient, awaiting additional information
                            <?php elseif (Helpers::strEqual($other_waiver->waiver_status, array('WTDN'))): ?>
                                Waiver has been withdrawn
                            <?php else: ?>
                                <?php if (count($other_waiver->data->decisions) > 0 and $other_waiver->data->decisions[0]->is_eligible): ?>
                                    Eligible - Waiver Approved
                                <?php else: ?>
                                    Not Eligible - Waiver Denied
                                <?php endif; ?>
                            <?php endif; ?>
                        </td>
                    </tr>                

                <?php endforeach; ?>             

                <?php if (count($object->other_waivers) == 0): ?>

                    <tr>
                        <td colspan="7">
                            This student has no other eligibility waivers on file.
                        </td>
                    </tr>

                <?php endif; ?>  

            </tbody>
        </table>
    </div>

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