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

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

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

    <style type="text/css">
    	h3 {
    		color: #1C43A6 !important;
    	}

    	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;
    	}

    	.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;
		  }


    </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 == 1)
				{
					$(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
	$('.back_button')
		.button({'icons':{'primary':' ui-icon-arrowthick-1-w'}})
		.css({'font-size':'9pt'});

	// 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'); ?>  

	<a href="<?php echo url('/forms/eligibility'); ?>" class="back_button">New Search</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 /*  There must be a search query  */ ?>
	<?php if (!Session::has('waiver_search_query')): ?>
        <br />
        <div class="ui-state-error ui-corner-all" style="padding: 0.5em 1em; height: 2em; line-height: 2em; white-space: nowrap; text-align: center; font-weight: bold;">
			<span class="ui-icon ui-icon-info" style="display:inline-block; position:relative; top:2px;"></span>
			Unable to display any search results without a search query.
		</div>        	
        
    <?php else: ?>

    	<?php    		
    		// Get the search query
    		$search_query = json_decode(Session::get('waiver_search_query'), true);
    	?>

    	<?php /*  Show the search query  */ ?>
    	<div style="display: inline-block; font-weight: bold; width: 75px;">User:</div>
    	<?php echo Auth::user()->getDisplayFullName(); ?>

    	<br />

    	<div style="display: inline-block; font-weight: bold; width: 75px;">Query:</div>
    	<?php if (Helpers::strEqual($search_query['type'], 'ID')): ?>
    		Find waiver where ID is "<?php echo $search_query['id']; ?>"
    	<?php elseif (Helpers::strEqual($search_query['type'], 'NAME')): ?>
    		<?php if (Helpers::strIsEmpty($search_query['first_name']) and Helpers::strIsEmpty($search_query['last_name'])): ?>
    			Find all waivers for
    			<?php if (Helpers::strEqual($search_query['school'], 'ALL')): ?>
    				all schools
    			<?php else: ?>
    				<?php echo $info['school']->name; ?>
    			<?php endif; ?>
    		<?php else: ?>
    			Find all waivers for
    			<?php if (Helpers::strEqual($search_query['school'], 'ALL')): ?>
    				all schools
    			<?php else: ?>
    				<?php echo $info['school']->name; ?>
    			<?php endif; ?>
    			
    			where student's
    			<?php if (Helpers::strIsEmpty($search_query['first_name'])): ?>
    				last name is "<?php echo $search_query['last_name']; ?>"
    			<?php elseif (Helpers::strIsEmpty($search_query['last_name'])): ?>
					first name is "<?php echo $search_query['first_name']; ?>"
    			<?php else: ?>
    				name is "<?php echo $search_query['first_name']; ?> <?php echo $search_query['last_name']; ?>"
    			<?php endif; ?>
    		<?php endif; ?>
    	<?php endif; ?>

    	<br />

    	<?php if (!Helpers::strIsEmpty($search_query['filters'])): ?>
    		
    		<div style="display: inline-block; font-weight: bold; width: 75px;">Filter:</div>
    		Waiver status - <?php echo $search_query['filters']; ?>
    		<br />

    	<?php endif; ?>

    	<div style="display: inline-block; font-weight: bold; width: 75px;">Results:</div>
    	<?php echo count($info['waiver_objects']); ?>

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

    		<div class="ui-state-error ui-corner-all" style="padding: 0.5em 1em; height: 2em; line-height: 2em; white-space: nowrap; text-align: center; font-weight: bold;">
				<span class="ui-icon ui-icon-info" style="display:inline-block; position:relative; top:2px;"></span>
				Your search did not return any matching results.
			</div>	


    	<?php else: ?>

    		<table>

    			<thead>
    				<tr>
    					<th>ID</td>
    					<th>Ref. #</th>
    					<th>Year</th>
    					<th>School</th>
    					<th>Student</th>
    					<th>Waiver Type</th>
    					<th>Status</th>
    					<th>Updated</ht>
    				</tr>
    			</thead>

    			<tbody>

    				<?php foreach ($info['waiver_objects'] as $object): ?>
    					
    					<tr data-waiver-id="<?php echo $object->waiver->id; ?>"
    						data-viewable="true"
    						<?php if ($object->waiver->isUserEditingAllowed()): ?> data-editable="true" <?php endif; ?>>    					
    						<td><?php echo $object->waiver->id; ?></td>
    						<td><?php echo $object->waiver->old_id; ?></td>
    						<td><?php echo $object->school_year->slug; ?></td>
    						<td><?php echo $object->school->short_name; ?></td>
    						<td>
    							<?php echo $object->student->first_name; ?>
								<?php echo $object->student->middle_initial; ?>
								<?php echo $object->student->last_name; ?>
    						</td>
    						<td><?php echo $object->waiver_type->slug; ?></td>
    						<td><?php echo $object->waiver_status->slug; ?></td>
    						<td><?php echo $object->waiver->updated_at; ?></td>
    					</tr>
    				<?php endforeach; ?> 

    			</tbody>

    		</table>

    		


    	<?php endif; ?>





    <?php endif; ?>

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