
<?php \Laravel\Section::start('content'); ?>
	<div class="container">
		<div class="page-header">
			<h1>Contrats de maintenance</h1>
		</div>
		<div style="margin-bottom: 15px;">
			<a class="btn" href="<?php echo  URL::to_route('new_maintenance') ; ?>"><i class="icon-plus"></i> Ajouter un nouveau contrat de maintenance</a>
		</div>
		<?php echo  BHelpers::notification() ; ?>
		<?php if($maintenances): ?>
		<table class="table table-striped table-hover datatable">
			<thead>
				<tr>
					<th>#</th>
					<th>Client</th>
					<th>Date du contrat</th>
					<th>Fin de l'engagement</th>
					<th>Prix/mois</th>
					<th>Travail mensuel</th>
					<th>Tâches effectuées</th>
					<th style="text-align:right;"><?php echo __('admin.action'); ?></th>
				</tr>
			</thead>
			<tbody>
			<?php foreach($maintenances as $c): ?>
				<tr>
					<td><?php echo  $c->id ; ?></td>
					<td><a href="<?php echo  URL::to_route('edit_customer', array($c->customer->id)) ; ?>"><?php echo  $c->customer->societe ; ?></a></td>
					<td><?php echo  DateFunctions::format_date($c->date_debut) ; ?></td>
					<td><?php echo  DateFunctions::format_date($c->fin_engagement) ; ?></td>
					<td><?php echo  number_format($c->prix_fixe, 2, ',', ' ') ; ?> &euro;</td>
					<td><?php echo  number_format($c->temps_initial, 2, '.', ' ') ; ?> h</td>
					<td><span class="badge badge-success"><?php echo  count($c->lignes) ; ?></span></td>
					<td style="padding: 4px 8px; text-align:right;width:172px">
						<?php echo  Form::open(URL::to_route('delete_maintenance', $c->id), 'DELETE', array('id' => 'form_'.$c->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_maintenance', array($c->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 $c->id ?>);"><i class="icon-remove icon-white"></i> Supprimer</a>
						</div>
						<?php echo  Form::close() ; ?>
					</td>
				</tr>
			<?php endforeach; ?>
			</tbody>
		</table>
		<?php else: ?>
			<em>Aucun contrat de maintenance en ce moment.</em>
		<?php endif; ?>
	</div>
	<script type="text/javascript">
	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(); ?>