
<?php \Laravel\Section::start('content'); ?>
	<?php $localUser = Session::get('user') ; ?>
	<?php if($booking > 0): ?>
	<div class="msg warn"> 
		Only one booking allowed, cancel the existing if you wish to change
	</div>
	<?php endif; ?>
	<?php if($booking < 0): ?>
	<div class="msg err"> 
		Only identified users can book. Please <?php echo  HTML::link_to_route('login', 'login') ; ?>!
	</div>
	<?php endif; ?>
	<h1>Training slots for <?php echo  $training->tr_date ; ?></h1>
	<p><?php echo  $training->tr_comments ; ?></p>
	<?php echo  Form::open('slot/book', 'PUT', array('style' => 'display:inline ;' )) ; ?>
		<table>
		<?php foreach($slots as $slot): ?>
			<tr>
			<th width=120px"><?php echo  date('H:i',strtotime($slot->slot_time))  ; ?></th>
			<td>
			<?php if ($slot->person_id == 0 ): ?> 
				<?php if ( $booking==0 ): ?>
					<input type="radio" name="slot_chosen" id="slot_chosen" value="<?php echo $slot->id; ?>" , class="radio">
				<?php endif; ?>
			<?php else: ?>
				<?php echo  $slot->person_name ; ?>
			<?php endif; ?>
			</td>
		<?php endforeach; ?>
		</table>
		<br/><br/>
		<?php if($booking >= 0): ?>
			<?php echo  Form::hidden('person_id', $localUser['id'] ) ; ?>
			<?php if($booking==0): ?>
				<?php echo  Form::hidden('action', 'BOOK' ) ; ?>
				<?php echo  Form::submit('confirm booking' , array( 'class' => 'button')) ; ?>
			<?php else: ?>
				<?php echo  Form::hidden('slot_booked', $booking ) ; ?>
				<?php echo  Form::hidden('action', 'CANCEL' ) ; ?>
				<?php echo  Form::submit('cancel booking' , array( 'class' => 'button')) ; ?>
			<?php endif; ?>
		<?php endif; ?>
	<?php echo  Form::close(); ?>
	<br/><br/>
	<div class="notes">
	<ul>
		<li>a person cannot register for 2 trainings the same date [BR01]</li>
		<li>a person can cancel his own registration [BR02]</li>
		<li>only an administrator can create or change training slots [BR03]</li>
		<li>only an administrator can register/cancel a slot for another person	[BR04]</li>
		<li>registration period starts two days before	[BR05]</li>
		<li>registration period starts one day before, for those that booked a slot in the previous training [BR06]</li>
		<li>a booking can be cancelled up to one hour before starting time [BR07]</li>
	</div>
<?php \Laravel\Section::stop(); ?>

<?php echo view('layouts.default')->with(get_defined_vars())->render(); ?>