From 545fe59fc8c94da8f9a444326673efb2606019ed Mon Sep 17 00:00:00 2001 From: Allavena Romain Date: Tue, 8 Apr 2025 10:34:00 +0200 Subject: [PATCH] =?UTF-8?q?possibilit=C3=A9=20d'accepter=20ou=20de=20refus?= =?UTF-8?q?er=20les=20candidatures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/EmployeeController.php | 26 ++++++++++++ src/Controller/ProfileController.php | 10 ++--- templates/employee/applications.html.twig | 49 ++++++++++++++++------- templates/profile/employee.html.twig | 6 +-- templates/profile/visit.html.twig | 24 +++++------ 5 files changed, 80 insertions(+), 35 deletions(-) diff --git a/src/Controller/EmployeeController.php b/src/Controller/EmployeeController.php index 1a2d60d..6d7cd17 100644 --- a/src/Controller/EmployeeController.php +++ b/src/Controller/EmployeeController.php @@ -92,5 +92,31 @@ final class EmployeeController extends AbstractController ]); } + #[Route('/application/{id}/update-status/{status}', name: 'app_employee_update_application_status', methods: ['POST'])] + public function updateApplicationStatus(int $id, string $status): Response + { + $employee = $this->getUser(); + if (!$employee instanceof Employee) { + throw $this->createAccessDeniedException('Seuls les employés peuvent accéder à cette action.'); + } + + $application = $this->internApplicationRepository->find($id); + + if (!$application) { + throw $this->createNotFoundException('Candidature introuvable.'); + } + + $company = $employee->getCompany(); + if ($application->getApplication()->getCompany() !== $company) { + throw $this->createAccessDeniedException('Cette candidature ne vous appartient pas.'); + } + + $application->setStatus($status); + $this->entityManager->flush(); + + $this->addFlash('success', 'Le statut de la candidature a bien été mis à jour.'); + + return $this->redirectToRoute('app_employee_seeApplications'); + } } diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index 8263c94..9462052 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -63,17 +63,17 @@ class ProfileController extends AbstractController ]); } - #[Route('/profile/{id}/visit', name: 'app_profile_visit')] + #[Route('/profile/visit/{id}', name: 'app_profile_visit')] public function visitProfile(EntityManagerInterface $entityManager, int $id): Response { - $user = $entityManager->getRepository(Intern::class)->find($id); + $candidat = $entityManager->getRepository(Intern::class)->find($id); - if (!$user) { + if (!$candidat) { throw $this->createNotFoundException('Utilisateur non trouvé.'); } - return $this->render('profile/index.html.twig', [ - 'user' => $user, + return $this->render('profile/visit.html.twig', [ + 'candidat' => $candidat, ]); } diff --git a/templates/employee/applications.html.twig b/templates/employee/applications.html.twig index 18efabb..eb1dc91 100644 --- a/templates/employee/applications.html.twig +++ b/templates/employee/applications.html.twig @@ -3,22 +3,41 @@ {% block title %}Liste des Candidatures{% endblock %} {% block body %} -

Candidatures reçues

+
+

Candidatures reçues

-{% for app in applications %} -
-

Annonce : {{ app.application.title }}

-

Candidat : {{ app.intern.firstName }} {{ app.intern.lastName }}

-

Date : {{ app.applicationDate|date('d/m/Y') }}

-

Statut : {{ app.status }}

+ {% for app in applications %} +
+

Annonce : {{ app.application.title }}

+

Candidat : {{ app.intern.firstName }} {{ app.intern.lastName }}

+

Date : {{ app.applicationDate|date('d/m/Y') }}

+

Statut : {{ app.status|capitalize }}

- - Voir le profil du candidat - + + Voir le profil du candidat + + + {% if app.status == 'En Attente' %} +
+
+ +
+ +
+ +
+
+ {% endif %} +
+ {% else %} +

Aucune candidature pour le moment.

+ {% endfor %}
-{% else %} -

Aucune candidature pour le moment.

-{% endfor %} - {% endblock %} diff --git a/templates/profile/employee.html.twig b/templates/profile/employee.html.twig index be1c7df..d83f460 100644 --- a/templates/profile/employee.html.twig +++ b/templates/profile/employee.html.twig @@ -8,9 +8,9 @@

Téléphone : {{ app.user.tel }}

Email : {{ app.user.mail }}

- - Voir les candidatures reçues + + Voir les candidatures reçues diff --git a/templates/profile/visit.html.twig b/templates/profile/visit.html.twig index b202ac7..8a2858a 100644 --- a/templates/profile/visit.html.twig +++ b/templates/profile/visit.html.twig @@ -7,18 +7,18 @@

Profil du candidat

-

Nom : {{ user.lastName }}

-

Prénom : {{ user.firstName }}

-

Email : {{ user.mail }}

-

Téléphone : {{ user.tel }}

-

Adresse : {{ user.address }}

+

Nom : {{ candidat.lastName }}

+

Prénom : {{ candidat.firstName }}

+

Email : {{ candidat.mail }}

+

Téléphone : {{ candidat.tel }}

+

Adresse : {{ candidat.address }}

Diplômes

    - {% if user.degrees|length > 0 %} - {% for deg in user.degrees %} + {% if candidat.degrees|length > 0 %} + {% for deg in candidat.degrees %}
  • {{ deg.degree.label }} — Obtenu le {{ deg.graduationDate|date('d/m/Y') }}
  • @@ -32,9 +32,9 @@

    Compétences

      - {% if user.skills|length > 0 %} - {% for skill in user.skills %} -
    • {{ skill.label }}
    • + {% if candidat.skills|length > 0 %} + {% for sk in candidat.skills %} +
    • {{ sk.skill.label }}
    • {% endfor %} {% else %}

      Aucune compétence renseignée.

      @@ -43,9 +43,9 @@