<div class="tabbable">
	<ul class="nav nav-tabs">
		<li class="active"><a href="#tab0" data-toggle="tab"><i class="icon-user"></i> Informations générales</a></li>
		<li><a href="#tab1" data-toggle="tab"><i class="icon-tasks"></i> Accès sections</a></li>
	</ul>
	<div class="tab-content">
		<div class="tab-pane active" id="tab0">
			<table class="table table-striped">
				<tr <?php if($errors->first('valid')) echo 'class="error"'; ?>>
					<td>Statut</td>
					<td>
						<?php echo  Form::select('valid', array('y'=>'Valide','n'=>'Bloqué'), Input::old('valid', (isset($user) ? $user->valid : 'FR'))) ; ?>
						<?php echo  $errors->first('valid', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('email')) echo 'class="error"'; ?>>
					<td>Adresse Email  *</td>
					<td>
						<?php echo  Form::text('email', Input::old('email', (isset($user) ? $user->email : NULL))) ; ?>
						<?php echo  $errors->first('email', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('phone')) echo 'class="error"'; ?>>
					<td>Télephone</td>
					<td>
						<?php echo  Form::text('phone', Input::old('phone', (isset($user) ? $user->phone : NULL))) ; ?>
						<?php echo  $errors->first('phone', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('last_name')) echo 'class="error"'; ?>>
					<td>Nom *</td>
					<td>
						<?php echo  Form::text('last_name', Input::old('last_name', (isset($user) ? $user->last_name : NULL))) ; ?>
						<?php echo  $errors->first('last_name', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('first_name')) echo 'class="error"'; ?>>
					<td>Prénom *</td>
					<td>
						<?php echo  Form::text('first_name', Input::old('first_name', (isset($user) ? $user->first_name : NULL))) ; ?>
						<?php echo  $errors->first('first_name', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('password')) echo 'class="error"'; ?>>
					<td>Mot de passe</td>
					<td>
						<?php echo  Form::password('password') ; ?>
						<?php echo  $errors->first('password', '<span class="help-inline">:message</span>') ; ?>
						<?php if($user): ?>
						<br /><span class="help-inline">Laissez ce champ vide si vous ne souhaitez pas le mettre à jour</span>
						<?php endif; ?>
					</td>
				</tr>
			</table>
		</div>
		<div class="tab-pane" id="tab1">
			<table class="table table-striped">
				<tr>
					<td style="width:220px"><strong>Sections autorisées</strong></td>
					<td>
						<?php 
						$user_roles = array();
						if(isset($user))
						{
							foreach ($user->roles()->get() as $r)
								$user_roles[] = $r->id; 
						}
						?>
						<?php foreach($roles as $r): ?>
						<label class="checkbox">
						    <input name="roles[]" value="<?php echo  $r->id ; ?>" type="checkbox"<?php if(in_array($r->id, Input::old('roles', $user_roles))) echo ' checked="checked"' ?>> <?php echo  $r->name ; ?>
						</label>
						<?php endforeach; ?>
					</td>
				</tr>
			</table>
		</div>
	</div>
</div>