
<?php \Laravel\Section::start('content'); ?>
	<div class="container">
		<div class="page-header">
			<h1>Clients</h1>
		</div>
		<div style="margin-bottom: 15px;">
			<a class="btn" href="<?php echo  URL::to_route('new_customer') ; ?>"><i class="icon-plus"></i> Nouveau client</a>
		</div>
		<?php echo  BHelpers::notification() ; ?>
		<?php if($customers): ?>
		<table class="table table-striped table-hover datatable">
			<thead>
				<tr>
					<th>#</th>
					<th><?php echo __('admin.client'); ?></th>
					<th><?php echo __('admin.email'); ?></th>
					<th><?php echo __('admin.telephone'); ?></th>
					<th>Espace client</th>
					<th>Maintenance</th>
					<th style="text-align:right"><?php echo __('admin.action'); ?></th>
				</tr>
			</thead>
			<tbody>
			<?php foreach($customers as $c): ?>
				<?php $nbperso = 0; ?>
				<tr>
					<td><?php echo  $c->id ; ?></td>
					<td><?php echo  $c->societe ; ?></td>
					<td><?php echo  $c->email ; ?></td>
					<td><?php echo  $c->tel1 ; ?></td>
					<td>
						<?php if($c->can_login=='y'): ?>
							<span class="label label-success">Oui</span>
						<?php else: ?>
							<span class="label label-warning">Non</span>
						<?php endif; ?>
					</td>
					<td>
						<?php if($c->maintenance=='y'): ?>
							<span class="label label-success">Oui</span>
						<?php else: ?>
							<span class="label label-warning">Non</span>
						<?php endif; ?>
					</td>
					<td style="text-align:right">
						<?php echo  Form::open(URL::to_route('delete_customer', $c->id), 'DELETE', array('id' => 'form_'.$c->id, 'style' => 'margin:0;')) ; ?>
						<div class="btn-group">
							<a class="btn btn-small" href="<?php echo  URL::to_route('edit_customer', array($c->id)) ; ?>"><i class="icon-pencil"></i> <?php echo __('admin.modifier'); ?></a>
							<a class="btn btn-small btn-danger" href="javascript:delete_entry(<?php echo $c->id ?>);"><i class="icon-remove icon-white"></i> <?php echo __('admin.supprimer'); ?></a>
						</div>
						<?php echo  Form::close() ; ?>
					</td>
				</tr>
			<?php endforeach; ?>
			</tbody>
		</table>
		<?php else: ?>
			<em>Aucun client actuellement</em>
		<?php endif; ?>
	</div>
	<script type="text/javascript">
	function delete_entry(id)
	{
		if(confirm("Confirmer la suppression ?"))
			$('#form_'+id).submit();
		else
			return false;
	}
	</script>
<?php \Laravel\Section::stop(); ?>
<?php echo view('backend::template_default')->with(get_defined_vars())->render(); ?>