<div class="tabbable">
	<ul class="nav nav-tabs">
		<li class="active"><a href="#tab0" data-toggle="tab"><i class="icon-tasks"></i> Informations générales</a></li>
		<li><a href="#tab2" data-toggle="tab"><i class="icon-file"></i> Fichier(s) </a></li>
		<?php if($customer): ?>
		<li><a href="#tab3" data-toggle="tab"><i class="icon-shopping-cart"></i> Présence(s) (<?php echo count($customer->scans); ?>)</a></li>
		<?php endif; ?>
	</ul>
	<div class="tab-content">
		<div class="tab-pane active" id="tab0">
			<table class="table table-striped table-hover">
				<?php if($customer): ?>
				<tr>
					<td style="width:300px">ID Client</td>
					<td><strong><?php echo $customer->id; ?></strong></td>
				</tr>
				<?php endif; ?>
				<tr <?php if($errors->first('type')) echo 'class="error"'; ?>>
					<td style="width:300px">Type de client *</td>
					<td>
						<?php echo  Form::select('type', $types, Input::old('type', (isset($customer) ? $customer->type : NULL))); ; ?>
						<?php echo  $errors->first('type', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('type_inscription')) echo 'class="error"'; ?>>
					<td style="width:300px">Type d'inscription *</td>
					<td>
						<?php echo  Form::select('type_inscription', $types_inscriptions, Input::old('type_inscription', (isset($customer) ? $customer->type_inscription : NULL))); ; ?>
						<?php echo  $errors->first('type_inscription', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('last_name')) echo 'class="error"'; ?>>
					<td style="width:300px">Nom *</td>
					<td>
						<?php echo  Form::text('last_name', Input::old('last_name', (isset($customer) ? $customer->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 style="width:300px">Prénom *</td>
					<td>
						<?php echo  Form::text('first_name', Input::old('first_name', (isset($customer) ? $customer->first_name : NULL))); ; ?>
						<?php echo  $errors->first('first_name', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('fonction')) echo 'class="error"'; ?>>
					<td style="width:300px">Fonction</td>
					<td>
						<?php echo  Form::text('fonction', Input::old('fonction', (isset($customer) ? $customer->fonction : NULL))); ; ?>
						<?php echo  $errors->first('fonction', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('code_cip')) echo 'class="error"'; ?>>
					<td style="width:300px">CIP</td>
					<td>
						<?php echo  Form::text('code_cip', Input::old('code_cip', (isset($customer) ? $customer->code_cip : NULL))); ; ?>
						<?php echo  $errors->first('code_cip', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr>
					<td style="width:300px">
						QR Code<br />
						<?php if($customer): ?>
						<a target="_blank" href="<?php echo URL::to_route('qrcodepdf',array($customer->id)); ?>">Générer le badge</a>
						<?php endif; ?>
					</td>
					<td>
						<?php if($customer): ?>
						<img src="<?php echo $qr_code; ?>" alt="QR Code" title="QR Code" />
						<?php else: ?>
						Vous devez tout d'abord ajouter le client pour afficher son QR code.
						<?php endif; ?>
					</td>
				</tr>
				<tr>
					<td colspan="2"><strong>Pharmacie / Laboratoire</strong></td>
				</tr>
				<tr <?php if($errors->first('pharma_nom')) echo 'class="error"'; ?>>
					<td style="width:300px">Nom de la pharmacie / du laboratoire </td>
					<td>
						<?php echo  Form::text('pharma_nom', Input::old('pharma_nom', (isset($customer) ? $customer->pharma_nom : NULL))); ; ?>
						<?php echo  $errors->first('pharma_nom', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('pharma_cp')) echo 'class="error"'; ?>>
					<td style="width:300px">Code postal de la pharmacie / du laboratoire</td>
					<td>
						<?php echo  Form::text('pharma_cp', Input::old('pharma_cp', (isset($customer) ? $customer->pharma_cp : NULL))); ; ?>
						<?php echo  $errors->first('pharma_cp', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('pharma_city')) echo 'class="error"'; ?>>
					<td style="width:300px">Ville de la pharmacie / du laboratoire</td>
					<td>
						<?php echo  Form::text('pharma_city', Input::old('pharma_city', (isset($customer) ? $customer->pharma_city : NULL))); ; ?>
						<?php echo  $errors->first('pharma_city', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				
				<?php if($customer): ?>
				<tr>
					<td style="width:300px">Date d'ajout</td>
					<td><?php echo $customer->created_at; ?></td>
				</tr>
				<tr>
					<td style="width:300px">Dernière modification</td>
					<td><?php echo $customer->updated_at; ?></td>
				</tr>
				<?php endif; ?>
			</table>
		</div>
		
		<div class="tab-pane" id="tab2">
			<div style="margin-bottom: 10px;">
				Ajouter des fichiers privés
			</div>
			<div>
				<ul id="sortable2" class="unstyled">
				<?php if(isset($customer)): ?>
				<?php foreach($customer->files as $f): ?>
				<li>
					<input type="hidden" name="files[]" value="<?php echo  $f->id ; ?>">
					<br /><a href="<?php echo URL::to_asset('uploads/files/customers/'.$f->name);; ?>" target="_blank"><?php echo  substr($f->short_name(),0,24) ; ?></a>
					<br /><br />
					<a class="btn btn-danger delete_file">Supprimer</a></li>
				<?php endforeach; ?>
				<?php endif; ?>
				</ul>
				<div style="clear:both"><br /></div>
			</div>	

			<input class="btn" id="file_upload1" name="file_upload1" type="file" multiple="true">
			<div style="clear:both; margin-bottom: 15px;"></div>
			<div id="queue2"></div>
		</div>
		
		<?php if($customer): ?>
			<div class="tab-pane" id="tab3">
				<div>
					<?php if(count($customer->scans)>=1): ?>
						<table class="table table-striped table-hover datatable">
							<thead>
								<tr>
									<th>#</th>
									<th>Date</th>
									<th style="text-align:right">Action</th>
								</tr>
							</thead>
							<tbody>
							<?php foreach($customer->scans as $c): ?>
								<tr>
									<td><?php echo  $c->id ; ?></td>
									<td><?php echo  $c->date ; ?></td>
									<td style="text-align:right"><a class="btn btn-default" href="<?php echo URL::to_route('edit_scan',array($c->id)); ?>">Modifier</a></td>
								</tr>
							<?php endforeach; ?>
							</tbody>
						</table>
					<?php else: ?>
					Aucune présence n'a été scannée actuellement pour cet inscrit
					<?php endif; ?>
				</div>	
			</div>
		<?php endif; ?>
	</div>
</div>
<script type="text/javascript">
	$('.datepicker').datepicker({
		dateFormat: 'yy-mm-d'
	});
	var upload_script = '<?php echo URL::to_action('backend::customers@file'); ?>';
</script>
