<div class="tabbable">
	<ul class="nav nav-tabs">
		<li class="active"><a href="#tab0" data-toggle="tab"><i class="icon-tasks"></i> <?php echo __('admin.informations'); ?></a></li>
		<?php if($customer): ?>
			<li><a href="#tab2" data-toggle="tab"><i class="icon-file"></i> Fichier(s) </a></li>
			<li><a href="#tab3" data-toggle="tab"><i class="icon-shopping-cart"></i> Paiements (<?php echo count($customer->payments); ?>)</a></li>
			<li><a href="#tab4" data-toggle="tab"><i class="icon-list"></i> Projets (<?php echo count($customer->projects); ?>)</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('first_name')) echo 'class="error"'; ?>>
					<td style="width:300px"><?php echo __('admin.prenom'); ?> *</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('last_name')) echo 'class="error"'; ?>>
					<td style="width:300px"><?php echo __('admin.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('email') || ($customer && $customer->email=='')) echo 'class="error"'; ?>>
					<td style="width:300px"><?php echo __('admin.adresse_email'); ?> *</td>
					<td>
						<?php echo  Form::text('email', Input::old('email', (isset($customer) ? $customer->email : NULL))); ; ?>
						<?php echo  $errors->first('email', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('tel')) echo 'class="error"'; ?>>
					<td style="width:300px">Télephone</td>
					<td>
						<?php echo  Form::text('tel', Input::old('tel', (isset($customer) ? $customer->tel : NULL)),array('class'=>'setUcFirstOnly','autocomplete'=>'off')); ; ?>
						<?php echo  $errors->first('tel', '<span class="help-inline">:message</span>') ; ?>
					</td>
				</tr>
				<tr <?php if($errors->first('password')) echo 'class="error"'; ?>>
					<td style="width:300px">
						<?php echo __('admin.mot_passe'); ?> 
						<?php if(!$customer): ?>
						*
						<?php endif; ?>
					</td>
					<td>
						<?php echo  Form::text('password','',array('autocomplete'=>'off')); ; ?>
						<?php echo  $errors->first('password', '<span class="help-inline">:message</span>') ; ?>
						<?php if($customer): ?>
						<br /><span class="help-inline"><?php echo __('admin.laisser_vide'); ?></span>
						<?php endif; ?>
					</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>
		
		<?php if($customer): ?>
			<div class="tab-pane" id="tab2">
				<div style="margin-bottom: 10px;">
					<?php echo __('admin.organiser_fichiers'); ?>
				</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"><?php echo __('admin.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>
			
			<div class="tab-pane" id="tab3">
				<div>
					<?php if(count($customer->payments)>=1): ?>
						<table class="table table-striped table-hover datatable">
							<thead>
								<tr>
									<th>#</th>
									<th>Montant</th>
									<th>Statut</th>
									<th>Projet</th>
									<th>Date</th>
								</tr>
							</thead>
							<tbody>
							<?php foreach($customer->payments as $c): ?>
								<tr>
									<td><?php echo  $c->id ; ?></td>
									<td><?php echo  $c->amount ; ?></td>
									<td>
										<?php if($c->status == 'AUTHORISED'): ?>
										<span class="label label-success"><?php echo  $c->status ; ?></span>
										<?php elseif($c->status == 'REFUSED'): ?>
										<span class="label label-important"><?php echo  $c->status ; ?></span>
										<?php else: ?>
										<span class="label label-warning"><?php echo  $c->status ; ?></span>
										<?php endif; ?>
									</td>
									<td>
										<?php if($c->project): ?>
										<a href="<?php echo URL::to_route('edit_project',array($c->project_id)); ?>"><?php echo $c->project->name; ?></a>
										<?php else: ?>
										-
										<?php endif; ?>
									</td>
									<td><?php echo  $c->updated_at ; ?></td>
								</tr>
							<?php endforeach; ?>
							</tbody>
						</table>
					<?php else: ?>
					Aucun paiement effectué actuellement.
					<?php endif; ?>
				</div>	
			</div>
			
			<div class="tab-pane" id="tab4">
				<div>
					<?php if(count($customer->projects)>=1): ?>
					<table class="table datatable table-striped table-hover datatablecustomers">
						<thead>
							<tr>
								<th>#</th>
								<th>Projet</th>
								<th>Cible</th>
								<th>Participants</th>
								<th>Date limite</th>
								<th style="text-align:right"><?php echo __('admin.action'); ?></th>
							</tr>
						</thead>
						<tbody>
							<?php foreach($customer->projects as $p): ?>
							<tr>
								<td><?php echo $p->id; ?></td>
								<td><?php echo $p->name; ?></td>
								<td><?php echo $p->cible_last_name; ?> <?php echo $p->cible_first_name; ?></td>
								<td><?php echo count($p->invites); ?></td>
								<td><?php echo $p->date_limite; ?></td>
								<td style="padding: 4px 8px; text-align:right;">
									<a class="btn btn-small" href="<?php echo  URL::to_route('edit_project', array($p->id)) ; ?>"><i class="icon-pencil"></i> <?php echo __('admin.modifier'); ?></a>
								</td>
							</tr>
							<?php endforeach; ?>
						</tbody>
					</table>
					<?php else: ?>
					<em>Aucun projet actuellement.</em>
					<?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>
