diff --git a/src/Controller/InterventionController.php b/src/Controller/InterventionController.php index da1f290..1cd6c26 100644 --- a/src/Controller/InterventionController.php +++ b/src/Controller/InterventionController.php @@ -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, ]); diff --git a/templates/base.html.twig b/templates/base.html.twig index 900a8e7..7a2b121 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -117,8 +117,7 @@ {% if is_granted('ROLE_CHAUFFAGISTE') %}
Date | +Description | +Adresse | +Statut | ++ |
---|---|---|---|---|
{{ intervention.Timestamp ? intervention.Timestamp|date('d/m/Y H:i') : '' }} | +{{ intervention.Description }} | +{{ intervention.Address }} | +{{ intervention.Status }} | ++ + Voir + + | +
Vous n’avez aucune intervention assignée.
+ {% endif %} +{% endblock %} diff --git a/templates/intervention/show.html.twig b/templates/intervention/show.html.twig index d118dff..fe4dcc2 100644 --- a/templates/intervention/show.html.twig +++ b/templates/intervention/show.html.twig @@ -63,14 +63,13 @@ {% endif %} - {% if is_granted('ROLE_CHAUFFAGISTE') and intervention.user == app.user %} - - 📝 Ajouter une remarque - - {% endif %} - + {% if is_granted('ROLE_CHAUFFAGISTE') and intervention.user == app.user %} + + 📝 Ajouter une remarque + + {% endif %} Retour à la liste Modifier