👨🔧 Ajout accès interventions pour chauffagiste + bouton remarque + sécurisation route show
This commit is contained in:
parent
aaa66849be
commit
d8cdc7dd73
@ -75,10 +75,32 @@ class InterventionController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/mes-interventions', name: 'app_intervention_mes', methods: ['GET'])]
|
||||
public function mesInterventions(InterventionRepository $interventionRepository): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_CHAUFFAGISTE');
|
||||
|
||||
$user = $this->getUser();
|
||||
$interventions = $interventionRepository->findBy(['user' => $user]);
|
||||
|
||||
return $this->render('intervention/indexChauffagiste.html.twig', [
|
||||
'interventions' => $interventions,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/{id}', name: 'app_intervention_show', methods: ['GET'])]
|
||||
public function show(Intervention $intervention): Response
|
||||
{
|
||||
$this->denyUnlessAdminOrSecretaire();
|
||||
// ✅ Si l'utilisateur est un chauffagiste, il ne peut voir que ses interventions
|
||||
if ($this->isGranted('ROLE_CHAUFFAGISTE')) {
|
||||
if ($intervention->getUser() !== $this->getUser()) {
|
||||
throw $this->createAccessDeniedException('Accès refusé à cette intervention.');
|
||||
}
|
||||
} else {
|
||||
// ✅ Sinon, seuls admin/secrétaire peuvent accéder à tout
|
||||
$this->denyUnlessAdminOrSecretaire();
|
||||
}
|
||||
|
||||
return $this->render('intervention/show.html.twig', [
|
||||
'intervention' => $intervention,
|
||||
]);
|
||||
|
@ -117,8 +117,7 @@
|
||||
|
||||
{% if is_granted('ROLE_CHAUFFAGISTE') %}
|
||||
<li><a href="{{ path('chauffagiste_dashboard') }}">Dashboard Chauffagiste</a></li>
|
||||
<li><a href="{{ path('app_intervention_index') }}">Mes interventions</a></li>
|
||||
<li><a href="{{ path('app_stock_index') }}">Pièces détachées</a></li>
|
||||
<li><a href="{{ path('app_intervention_mes') }}">Mes interventions</a></li>
|
||||
<li><a href="{{ path('app_calendrier_indexChauffagiste') }}">Mon planning</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
38
templates/intervention/indexChauffagiste.html.twig
Normal file
38
templates/intervention/indexChauffagiste.html.twig
Normal file
@ -0,0 +1,38 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Mes interventions{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>📋 Mes interventions</h1>
|
||||
|
||||
{% if interventions is not empty %}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Description</th>
|
||||
<th>Adresse</th>
|
||||
<th>Statut</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for intervention in interventions %}
|
||||
<tr>
|
||||
<td>{{ intervention.Timestamp ? intervention.Timestamp|date('d/m/Y H:i') : '' }}</td>
|
||||
<td>{{ intervention.Description }}</td>
|
||||
<td>{{ intervention.Address }}</td>
|
||||
<td>{{ intervention.Status }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_intervention_show', {'id': intervention.id}) }}" class="btn btn-primary btn-sm">
|
||||
Voir
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>Vous n’avez aucune intervention assignée.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
@ -63,14 +63,13 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if is_granted('ROLE_CHAUFFAGISTE') and intervention.user == app.user %}
|
||||
<a href="{{ path('app_intervention_remarque', {'id': intervention.id}) }}" class="btn btn-outline-primary">
|
||||
📝 Ajouter une remarque
|
||||
</a>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% if is_granted('ROLE_CHAUFFAGISTE') and intervention.user == app.user %}
|
||||
<a href="{{ path('app_intervention_remarque', {'id': intervention.id}) }}" class="btn btn-outline-primary">
|
||||
📝 Ajouter une remarque
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{{ path('app_intervention_index') }}" class="btn btn-primary">Retour à la liste</a>
|
||||
<a href="{{ path('app_intervention_edit', {'id': intervention.id}) }}" class="btn btn-warning">Modifier</a>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user