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

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

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

    <style type="text/css">
    	h3 {
    		color: #1C43A6 !important;
    	}
    	
    	.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;
    	}

    	.ui-autocomplete {
		    max-height: 100px;
		    overflow-y: auto;
		    /* prevent horizontal scrollbar */
		    overflow-x: hidden;
		    font-size: 8pt;
		  }
		  /* IE 6 doesn't support max-height
		   * we use height instead, but this forces the menu to always be this tall
		   */
		  * html .ui-autocomplete {
		    height: 100px;
		  }

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

    	table thead {
    		background-color: #005fa9;
    		color: #ffffff;
    	}

    	table thead th {
    		padding: 4px 2px;
			text-align: left;
    	}    	

    	table tbody tr{
    		height: 2em;
    	}

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

    	.pending_waivers {
			margin-top: 0.5em;
    	}

    	#results {
    		width: 510px;
    		height: 550px;
    		overflow-y: auto;
    		padding-right: 8px;
    		margin-top: 0.5em;
    	}

		.item {
			border-bottom: 1px solid #dedede;
			position: relative;
			margin: 0 0 0.75em 0;
			line-height: 1.1em;
		}    	

		.item .id {
			font-size: 8pt;
			position: absolute;
			right: 0;
			top: 0;
		}

		.item .status {
			font-size: 8pt;
			position: absolute;
			right: 0;
			top: 1.25em;
		}

        .item .received {
            font-size: 8pt;
            position: absolute;
            right: 0;
            top: 2.5em;
        }

		.item .name {
			font-size: 10pt;
			font-weight: bold;
		}

		.item .school {
			font-size: 9pt;
			font-style: italic;
		}

		.item .type {
			font-size: 9pt;
			color: #7d7b7d;
		}

		.item .notify img {
			position: absolute;
			right: 60px;
			width: 24px;
		}

		.item.item_hover .type {			
			color: #fcb069;
		}

		.item.item_hover {
			color: #e17009 !important;
			cursor: pointer;
			border-bottom: 1px solid #dfeffc !important;

			background: #f5f8f9;
		}

    </style>

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

<?php $__env->startSection('jquery_init'); ?>
	
	// Table row highlighter
	function colorRows ()
	{		
		$('table').each(function ()
		{
			var i = 0;

			$('tbody tr:visible', $(this)).each(function ()
			{
				if (i % 2 == 0)
				{
					$(this).addClass('odd');
				}
				else
				{
					$(this).removeClass('odd');
				}
				i = i + 1;
			});		
		});
	}	
	colorRows();
	
	
	// 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);
		})
	});

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

	// Buttons
	$('.report_button')
		.button({'icons':{'primary':'ui-icon-script'}})
		.css({'font-size':'9pt','margin-right':'10px'});	

	

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


    /* 
     * Primer button    
     */
    $('.primer_button')
        .button({'icons':{'primary':'ui-icon-person'}})
        .css({'font-size':'9pt', 'margin-right':'10px'});


	// Search features
	function searchTerm(search)
	{
		$('#results').empty();

		$('<div><div>')
            .attr('data-searching', 1)
            .addClass('ui-widget-overlay ui-front')
            .appendTo('body');
          
        $('<div><div>').appendTo('body')
            .attr('data-searching', 1)
            .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 />Searching...<br /><br /><img src="http://www.osaa.org/images/icons/ajax_loader3.gif" /><div style="font-size: 8pt; line-height: 105%; margin-top: 2em;">Getting results from the database...</div>');

        var data = { term : search };

        // Get search results
        var jqxhr = $.ajax(
            {
                type : 'POST',
                url : '<?php echo url('/forms/eligibility/search'); ?>',
                data : data,
                dataType : 'html'
            })
            .done(function (data)
            {                                                
                $('[data-searching]').remove();

                var results = $.parseJSON(data);
                var waivers = results.results;
                
                if (waivers.length == 0)
                {
                	$('#results').html('No waivers matched your search.');
                	return;
            	}

                $.each(waivers, function(index, waiver)
                {
                	var html = '<div class="name">' + waiver.student + '</div>';
                	html += '<div class="id">' + waiver.id + '</div>';
                	html += '<div class="status">' + waiver.status + '</div>';                    
                	html += '<div class="school">' + waiver.school + '</div>';
                	html += '<div class="type">' + waiver.year + ' ' + waiver.type + '</div>';

                	$('<div></div>')
                		.addClass('item')
                		.attr('data-id', waiver.id)
                		.appendTo('#results')
                		.html(html);
            	});
            	
				$('.item')
					.hover(function ()
					{
						$(this).addClass('item_hover');
					}, function ()
					{
						$(this).removeClass('item_hover');
					})
					.click(function()
					{
						window.location.href = '<?php echo url('/forms/eligibility'); ?>/' + $(this).attr('data-id');
					});
                
            })
            .fail(function (jqXHR, status, error)
            {                                                   
                var response = jqXHR.responseText;
                var errorData = $.parseJSON(response);
                //console.log(errorData);
                alert("There was an error while searching.\n\n" + errorData.error.message + "\n\nThis page will be reloaded.");
                location.reload();
            });
	}


	$('#search').keypress(function(e)
	{
		if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 12))
		{
			$('.search_button').click();
		}
	})	

	$('.search_button')
		.button({'icons':{'primary':'ui-icon-search'}})
		.css({'font-size':'8pt'})		
		.click(function(event)
		{
			event.preventDefault();

			var search = $('#search').val();

			if (search == '')
			{
				alert("You didn't type in any search criteria.");
				return;
			}

			searchTerm(search);
		});

	
	<?php if (Auth::check() and !Auth::User()->isOsaaUser() and count($info['users_schools']) > 0): ?>

		$('#search').val('<?php echo str_replace('\'', '\\\'', $info['users_schools']->first()->name); ?>');
		searchTerm('<?php echo str_replace('\'', '\\\'', $info['users_schools']->first()->name); ?>');

	<?php endif; ?>

	$('.login_button')
		.button({'icons':{'primary':'ui-icon-person'}})
		.css({'font-size':'8pt'});

	$('.next_button')
		.button({'icons':{'secondary':'ui-icon-play'}})
		.css({'font-size':'8pt'})
		.click(function ()
		{
			var button = $(this);

			var school_id = $('#school').val();

			window.location = "<?php echo url('/forms/eligibility/new'); ?>?school=" + school_id; 
		});

	$('.item')
		.hover(function ()
		{
			$(this).addClass('item_hover');
		}, function ()
		{
			$(this).removeClass('item_hover');
		})
		.click(function()
		{
			window.location.href = '<?php echo url('/forms/eligibility'); ?>/' + $(this).attr('data-id');
		});
	
	

	// However over viewable record
	$('tbody tr')
		.hover(function ()
		{
			$(this).css({'background-color' : '#b0dcff',
						 'cursor' : 'pointer'});
		},
		function()
		{
			$(this).css({'background-color' : '',
						 'cursor' : 'auto'});
		})
		.click(function ()
		{
			var waiver_id = $(this).attr('data-waiver-id');

			window.location = '<?php echo url('/forms/eligibility/'); ?>/' + waiver_id;
		});

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

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

	<?php if (Auth::check() and Helpers::strEqual(Auth::User()->email, array('gibbyr@osaa.org', 'amerilynr@osaa.org', 'kristiep@osaa.org', 'tomw@osaa.org', 'peterw@osaa.org'))): ?>

		<a href="<?php echo url('/forms/eligibility/report'); ?>" class="report_button">Annual Report</a>

	<?php endif; ?>

    <a href="<?php echo asset ('docs/forms/EligibilityPrimerForParents.pdf'); ?>" class="primer_button" target="_blank">For Parents</a>

	<a href="<?php echo asset ('docs/osaainfo/OnlineEligibilityInstructions.pdf'); ?>" class="help_button" target="_blank">Help</a>

	<a href="<?php echo url('/'); ?>" 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; ?> 

	<div class="columns">

		<div class="half" style="padding-right: 1%; width:51%;">
			<h1>Search</h1>

			<br />

			<label for="search" style="font-weight: bold;">Find</label>
			<input type="text" name="search" id="search" style="width: 250px;" />

			<button class="search_button" style="margin-left: 50px;">Search</button>

			<br />

			<div class="small gray">Search by ID, reference number, year, student name, or school.</div>

			<div id="results">

			</div>
			
		</div>		

		<div class="half" style="border-left: 1px solid #d9e1e0; width: 44%; padding-left: 1%; <?php /*  height: 50em;  */ ?>">

			<h1>New Eligibility Request</h1>

			<br />			

			Administrators use this section to create a new Student Eligibility Request Form.  You will need to provide the following information:

			<ul class="small" style="line-height: 1.5em; margin-top: 0.5em;">
				<li><b>Student Information</b> - including name, date of birth, parent/guardian, address, etc.</li>
				<li><b>Waiver Type</b> - type of eligibility waiver (see <a href="<?php echo url('governance/handbooks/osaa#_Toc426096849'); ?>" target="_blank">OSAA Handbook, Rule 8</a>)</li> 
				<li><b>Enrollment Records</b> - student's academic history by semester/trimester</li>
				<li><b>Additional Correspondence*</b> - some eligibility waivers require additional information or correspondence that will need to be uploaded as a separate file and attached to the request (letters, transcripts, etc.)</li>
				<li><b>Affirmation Signatures</b> - in order for your request to be submitted, you must read and agree to an affirmation statement (school administrator and student's parent/guardian or host-family)
			</ul>

			<br />

			<?php /*  Future Eligibility Notice  */ ?>
			<?php if (intval(date('Y', time())) == intval(Helpers::getCurrentYear()) and
				 intval(date('n', time())) <= 8 and
				 intval(date('j', time())) < 9): ?>
				<div class="ui-corner-all ui-state-highlight small" style="line-height: 1.15em; margin-bottom: 1em; padding: 0.5em 4px;">
					<span class="ui-icon ui-icon-alert" style="display: inline-block; vertical-align: middle; margin-right: 4px;"></span><b>Future Eligibility Notice for Waivers Prior to August 15</b><br />
					Hardship requests involving future eligibility will not be considered by the Executive Director, Executive Board, or District Athletic Committee.  The student must actually be in an ineligible status before any hardship request will be considered except for Age and/or Fifth Year waivers.
				</div>
			<?php endif; ?>

			<h3>Create a New Eligibility Request Form</h3>

			
			<?php if (!isset($info['member_schools']) or count($info['member_schools']) < 1): ?>

				<div class="ui-state-error ui-corner-all">
					<b>You do not have access to this form.</b><br /><br />
					Your account is not linked to any school with administrative privileges.<br /><br />
					<span class="small">
						Please refer to <a href="<?php echo url('/help'); ?>" style="font-weight: bold; text-decoration: underline;">OSAA Website Help</a> for instructions on linking your account to a school.
					</span>
				</div>



			<?php else: ?>
				<b>School</b>
				<select name="school" id="school" style="max-width: 300px;">				

					<?php foreach ($info['member_schools'] as $value => $name): ?>

						<option value="<?php echo $value; ?>"><?php echo $name; ?></option>

					<?php endforeach; ?>
					
				</select>

				<button class="next_button" style="margin-left: 50px;" data-search-by="name">Next</button>						
			
				<br class="clear" /><br /><br />			

				<div class="small">
					<b>* Additional Correspondence</b><br />
					Types of additional correspondence include:

					<div class="columns">
						<div class="half">						

							<u>Transcripts</u><br />
							- Current high school<br />
							- Previous high school<br />

							<br />

							<u>School Records</u><br />
							- Attendance records<br />
							- Letter authorizing release of school records to OSAA<br />

							<br />

							<u>Letter of Explanation</u><br />
							- Student and parent or guardian<br />						
							- School representative<br />
							- Other letters as relevant<br />
						</div>

						<div class="half">						

							<u>Age &amp; Fifth Year Information/Documentation</u><br />
							- Gap in student's academic progress<br />
							- Credit deficiency<br />
							- Classes needed to graduate<br />
							- Individualized Educational Program (IEP)<br />
							- Student's disability per ADA<br />
						</div>

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

				</div>

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


		</div>

		<br class="clear" />

	</div>

	<?php if (Auth::check() and Helpers::strEqual(Auth::User()->email, array('gibbyr@osaa.org', 'amerilynr@osaa.org', 'kristiep@osaa.org', 'tomw@osaa.org', 'peterw@osaa.org'))): ?>

		<br class="clear" />

		<h1 style="border-top: 2px solid #1c43a6; padding-top: 1em;">Received &amp; Pending Requests</h1>

		<div class="columns">

			<div class="half">

				<h2>Awaiting Inspection</h2>
				<div class="small gray">
					These waivers have been submitted and need to be inspected by OSAA staff.<br />
                    A yellow flag, <img src="<?php echo asset('/images/icons/yellow_flag_32px.png'); ?>" alt="" title="" style="width: 16px; height: 16px; vertical-align: middle;" />, indicates the form needs Tom's attention.
				</div>

				<?php if (count($info['waiver_objects']['received']) < 1): ?>

					There are no waivers needing inspection.

				<?php else: ?>

					<div class="pending_waivers">

						<?php foreach ($info['waiver_objects']['received'] as $waiver): ?>				

							<div class="item pending_waiver" data-id="<?php echo $waiver->waiver->id; ?>">
								<div class="name"><?php echo $waiver->student->getDisplayName(); ?></div>
			                	<div class="id"><?php echo $waiver->waiver->id; ?></div>
			                	<div class="status"><?php echo $waiver->waiver_status->slug; ?></div>
			                	<?php if (!Helpers::strIsEmpty($waiver->data->flagged_for_tom)): ?>
                                    <div class="notify">
                                        <img src="<?php echo asset('/images/icons/yellow_flag_32px.png'); ?>" alt="" title="" />
                                    </div>
                                <?php endif; ?>
                                <div class="received"><?php echo $waiver->received_at; ?></div>
                                <div class="school"><?php echo $waiver->school->name; ?></div>
			                	<div class="type"><?php echo $waiver->school_year->slug; ?> <?php echo $waiver->waiver_type->slug; ?></div>
			                </div>
			                    	
						<?php endforeach; ?>

					</div>

				<?php endif; ?>
			</div>

			<div class="half">
				<h2>Pending</h2>
				<div class="small gray">
					These waivers are awaiting an internal decision or waiting for a notification to be sent.<br />
                    A green flag, <img src="<?php echo asset('/images/icons/green_flag_32px.png'); ?>" alt="" title="" style="width: 16px; height: 16px; vertical-align: middle;" />, indicates that Tom has made an internal decision.
				</div>

				<?php if (count($info['waiver_objects']['pending']) < 1): ?>

					There are no pending waivers needing a decision.

				<?php else: ?>

					<div class="pending_waivers">

						<?php foreach ($info['waiver_objects']['pending'] as $waiver): ?>				

							<div class="item pending_waiver" data-id="<?php echo $waiver->waiver->id; ?>">
								<div class="name"><?php echo $waiver->student->getDisplayName(); ?></div>
			                	<div class="id"><?php echo $waiver->waiver->id; ?></div>
			                	<div class="status"><?php echo $waiver->waiver_status->slug; ?></div>
			                	<?php if (!Helpers::strIsEmpty($waiver->data->internal_notes)): ?>
			                		<div class="notify">
			                			<img src="<?php echo asset('/images/icons/green_flag_32px.png'); ?>" alt="" title="" />
			                		</div>
			                	<?php endif; ?>
                                <div class="received"><?php echo $waiver->received_at; ?></div>
			                	<div class="school"><?php echo $waiver->school->name; ?></div>
			                	<div class="type"><?php echo $waiver->school_year->slug; ?> <?php echo $waiver->waiver_type->slug; ?></div>
			                </div>
			                    	
						<?php endforeach; ?>

					</div>

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

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


	<?php endif; ?>

	<img src="http://www.osaa.org/images/icons/ajax_loader3.gif" style="display: none;" />
	

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