
<?php \Laravel\Section::start('content'); ?>
	<div class="container">
		<div class="page-header">
			<h1>Commandes</h1>
		</div>
		<?php echo  BHelpers::notification() ; ?>
		<?php if($commandes): ?>
		<table class="table table-striped table-hover datatable">
			<thead>
				<tr>
					<th>#</th>
					<th>Client</th>
					<th>Nb produit(s)</th>
					<th>Total HT</th>
					<th>Total TTC</th>
					<th>Statut</th>
					<th><?php echo __('admin.date_creation'); ?></th>
					<th style="text-align:right;"><?php echo __('admin.action'); ?></th>
				</tr>
			</thead>
			<tbody>
				<?php foreach($commandes as $p): ?>
				<tr>
					<td><?php echo  $p->id ; ?></td>
					<td><a href="<?php echo  URL::to_route('edit_customer', $p->customer->id) ; ?>"><?php echo  $p->customer->last_name.' '.$p->customer->first_name ; ?></a></td>
					<td><span class="label label-info"><?php echo  $p->nbarticles() ; ?></span></td>
					<td><span class="label label-success"><?php echo  $p->total_ht ; ?> &euro;</span></td>
					<td><span class="label label-success"><?php echo  $p->total_ttc ; ?> &euro;</span></td>
					<td>
						<?php if($p->statut=='traite'): ?>
						<span class="label label-success">Traité</span>
						<?php else: ?>
						<span class="label label-warning">En cours</span>
						<?php endif; ?>
					</td>
					<td><?php echo  $p->created_at ; ?></td>
					<td style="padding: 4px 8px; text-align:right;">
						<?php echo  Form::open(URL::to_route('delete_commande', $p->id), 'DELETE', array('id' => 'form_'.$p->id, 'style' => 'margin:0;')) ; ?>
						<div class="btn-group">
							<a data-toggle="tooltip" data-original-title="Modifier" class="tooltiplink btn btn-small" href="<?php echo  URL::to_route('edit_commande', array($p->id)) ; ?>"><i class="icon-pencil"></i> Modifier</a>
							<a data-toggle="tooltip" data-original-title="Supprimer" class="tooltiplink btn btn-small btn-danger" href="javascript:delete_entry(<?php echo $p->id ?>);"><i class="icon-remove icon-white"></i> Supprimer</a>
						</div>
						<?php echo  Form::close() ; ?>
					</td>
				</tr>
				<?php endforeach; ?>
			</tbody>
		</table>
		<?php else: ?>
			<em>Aucune commande pour le moment.</em>
		<?php endif; ?>
	</div>
	<script type="text/javascript">
	$(function() {
		$('.tooltiplink').tooltip({container: 'body'});
	});
	
	function delete_entry(id)
	{
		if(confirm("<?php echo __('admin.etes_vous_sur'); ?>"))
			$('#form_'+id).submit();
		else
			return false;
	}
	</script>
<?php \Laravel\Section::stop(); ?>
<?php echo view('backend::template_default')->with(get_defined_vars())->render(); ?>