<?php
	if (!isset($information['team']))
	{
		$information['team'] = $team;
		$information['schedule'] = $team->schedule;
	}
?>

<h4><?php echo Helpers::getLevelName ($information['team']->level); ?> Schedule</h4>

<table id="schedule" style="width:100%;">
	<thead class="head ui-tabs-nav ui-widget-header ui-corner-all" >
		<tr>
			<?php if (isset($allow_edit) and $allow_edit): ?>
				<th style="width: 125px;">

				</th>
			<?php endif; ?>
			<th style="width:80px;">Status</th>			
			<th style="width:110px;">Date</th>
			<th style="width:50px;">Day</th>
			<th style="width:75px;">Time</th>
			<th>Event</th>	
			<th>Host</th>						
		</tr>
	</thead>

	<tbody>
		<?php foreach ($information['schedule'] as $item): ?>

			<?php if (Helpers::strEqual ($item->event->event_status, array('PND', 'SCHD', 'CXL', 'PPD', 'LIVE', 'DONE'))): ?>						

				<tr style="height: 3m;" data-status="<?php echo $item->event->event_status; ?>">
					<?php if (isset($allow_edit) and $allow_edit): ?>
						<td>
							<?php /* <a href="<?php echo url('meets/' . $item->meet->id . '/edit'); ?>" class="button edit" style="font-size: 7pt;">Edit</a> */ ?>
							<?php if ($item->meet->host_team == $information['team']->id or $item->meet->meet_type == 'DUAL'): ?>
								<div class="button delete" style="font-size: 7pt;" data-meet="<?php echo $item->meet->id; ?>" data-action="delete">Delete</div>
							<?php else: ?>
								<div class="button cancel" style="font-size: 7pt;" data-meet="<?php echo $item->meet->id; ?>" data-action="drop">Drop</div>
							<?php endif; ?>
						</td>
					<?php endif; ?>
					<td style="height: 3em;">						
						<?php echo $item->event->event_status; ?>
					</td>					
					<td>
						<?php if (substr($item->event->start_at, 0, 10) == substr($item->event->end_at, 0, 10)): ?>
							<?php echo date('n/j', strtotime($item->event->start_at)); ?>
						<?php else: ?>
							<?php echo date('n/j', strtotime($item->event->start_at)); ?> -
							<?php echo date('n/j', strtotime($item->event->start_at) + 60 * 60 * 24); ?>							
						<?php endif; ?>
					</td>
					<td>
						<?php if (substr($item->event->start_at, 0, 10) == substr($item->event->end_at, 0, 10)): ?>
							<?php echo date('D', strtotime($item->event->start_at)); ?>
						<?php else: ?>
							<?php echo Helpers::getDayLetter(date('D', strtotime($item->event->start_at))); ?>/<?php echo Helpers::getDayLetter(date('D', strtotime($item->event->start_at) + 60 * 60 * 24)); ?>							
						<?php endif; ?>
					</td>
					<td>
						<?php if (Helpers::strEqual(date('g:i a', strtotime($item->event->start_at)), '12:00 AM')): ?>
                		 	TBD
                		<?php else: ?>
                			<?php echo date('g:i a', strtotime($item->event->start_at)); ?>
                		<?php endif; ?>
					</td>
					<td style="padding: 0.25em 0;">
						<?php echo $item->event->name; ?>
						<?php if (!is_null($item->location_name)): ?>
							<span class="small gray note">(<?php echo $item->location_name; ?>)</span>
						<?php endif; ?>
						<?php if (!is_null($item->teams_list)): ?>
							<br />
							<span class="small gray">
								<?php echo implode(', ', $item->teams_list); ?>
							</span>
						<?php endif; ?>
					</td>
					<td>
						<?php if (!is_null($item->host_ap_id)): ?>
							<a href="<?php echo url('teams/' . $item->host_ap_id); ?>"><?php echo $item->meet->host_team_name; ?></a>
						<?php else: ?>
							<?php echo $item->meet->host_team_name; ?>
						<?php endif; ?>
					</td>									
				</tr>

			<?php endif; ?>

		<?php endforeach; ?>

		<?php if (count($information['schedule']) == 0): ?>
			<tr>
				<td colspan="5">No meets have been added to this schedule, yet.</td>
			</tr>
		<?php endif; ?>


	</tbody>

</table>
