diff --git a/.gitignore b/.gitignore index 4a56b88..2338294 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,4 @@ ###< symfony/asset-mapper ### .idea -composer.lock - -/migrations/ \ No newline at end of file +composer.lock \ No newline at end of file diff --git a/composer.lock b/composer.lock index 57b814a..9f202c7 100644 --- a/composer.lock +++ b/composer.lock @@ -6249,16 +6249,16 @@ }, { "name": "symfony/stimulus-bundle", - "version": "v2.23.0", + "version": "v2.24.0", "source": { "type": "git", "url": "https://github.com/symfony/stimulus-bundle.git", - "reference": "254f4e05cbaa349d4ae68b9b2e6a22995e0887f9" + "reference": "e09840304467cda3324cc116c7f4ee23c8ff227c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stimulus-bundle/zipball/254f4e05cbaa349d4ae68b9b2e6a22995e0887f9", - "reference": "254f4e05cbaa349d4ae68b9b2e6a22995e0887f9", + "url": "https://api.github.com/repos/symfony/stimulus-bundle/zipball/e09840304467cda3324cc116c7f4ee23c8ff227c", + "reference": "e09840304467cda3324cc116c7f4ee23c8ff227c", "shasum": "" }, "require": { @@ -6298,7 +6298,7 @@ "symfony-ux" ], "support": { - "source": "https://github.com/symfony/stimulus-bundle/tree/v2.23.0" + "source": "https://github.com/symfony/stimulus-bundle/tree/v2.24.0" }, "funding": [ { @@ -6314,7 +6314,7 @@ "type": "tidelift" } ], - "time": "2025-01-16T21:55:09+00:00" + "time": "2025-03-09T21:10:04+00:00" }, { "name": "symfony/stopwatch", @@ -6914,16 +6914,16 @@ }, { "name": "symfony/ux-turbo", - "version": "v2.23.0", + "version": "v2.24.0", "source": { "type": "git", "url": "https://github.com/symfony/ux-turbo.git", - "reference": "db96cf04d70a8c820671ce55530e8bf641ada33f" + "reference": "22954300bd0b01ca46f17c7890ea15138d9cf67f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ux-turbo/zipball/db96cf04d70a8c820671ce55530e8bf641ada33f", - "reference": "db96cf04d70a8c820671ce55530e8bf641ada33f", + "url": "https://api.github.com/repos/symfony/ux-turbo/zipball/22954300bd0b01ca46f17c7890ea15138d9cf67f", + "reference": "22954300bd0b01ca46f17c7890ea15138d9cf67f", "shasum": "" }, "require": { @@ -6992,7 +6992,7 @@ "turbo-stream" ], "support": { - "source": "https://github.com/symfony/ux-turbo/tree/v2.23.0" + "source": "https://github.com/symfony/ux-turbo/tree/v2.24.0" }, "funding": [ { @@ -7008,7 +7008,7 @@ "type": "tidelift" } ], - "time": "2025-02-06T08:47:30+00:00" + "time": "2025-04-04T17:29:20+00:00" }, { "name": "symfony/validator", @@ -9903,7 +9903,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -9911,6 +9911,6 @@ "ext-ctype": "*", "ext-iconv": "*" }, - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/src/Controller/EmployeeController.php b/src/Controller/EmployeeController.php index f0b853b..0498378 100644 --- a/src/Controller/EmployeeController.php +++ b/src/Controller/EmployeeController.php @@ -3,8 +3,11 @@ namespace App\Controller; use App\Entity\Employee; +use App\Entity\InternApplication; use App\Form\EmployeeType; +use App\Repository\AnnouncementRepository; use App\Repository\EmployeeRepository; +use App\Repository\InternApplicationRepository; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -14,11 +17,19 @@ use Symfony\Component\Routing\Attribute\Route; #[Route('/employee')] final class EmployeeController extends AbstractController { + public function __construct( + private readonly EntityManagerInterface $entityManager, + private readonly EmployeeRepository $employeeRepository, + private readonly AnnouncementRepository $announcementRepository, + private readonly InternApplicationRepository $internApplicationRepository + ) + { + } #[Route(name: 'app_employee_index', methods: ['GET'])] - public function index(EmployeeRepository $employeeRepository): Response + public function index(): Response { return $this->render('employee/index.html.twig', [ - 'employees' => $employeeRepository->findAll(), + 'employees' => $this->employeeRepository->findAll(), ]); } @@ -31,13 +42,13 @@ final class EmployeeController extends AbstractController } #[Route('/{id}/edit', name: 'app_employee_edit', methods: ['GET', 'POST'])] - public function edit(Request $request, Employee $employee, EntityManagerInterface $entityManager): Response + public function edit(Request $request, Employee $employee): Response { $form = $this->createForm(EmployeeType::class, $employee); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $entityManager->flush(); + $this->entityManager->flush(); return $this->redirectToRoute('app_employee_index', [], Response::HTTP_SEE_OTHER); } @@ -49,13 +60,37 @@ final class EmployeeController extends AbstractController } #[Route('/{id}', name: 'app_employee_delete', methods: ['POST'])] - public function delete(Request $request, Employee $employee, EntityManagerInterface $entityManager): Response + public function delete(Request $request, Employee $employee): Response { if ($this->isCsrfTokenValid('delete'.$employee->getId(), $request->getPayload()->getString('_token'))) { - $entityManager->remove($employee); - $entityManager->flush(); + $this->entityManager->remove($employee); + $this->entityManager->flush(); } return $this->redirectToRoute('app_employee_index', [], Response::HTTP_SEE_OTHER); } + + #[Route('/seeApplications', name: 'app_employee_applications')] + public function seeApplications(): Response + { + $employee = $this->getUser(); + + if (!$employee instanceof Employee){ + throw $this->createAccessDeniedException('Seuls les employés peuvent accéder à cette page.'); + } + + $company = $employee->getCompany(); + + $announcements = $this->announcementRepository + ->findBy(['company' => $company]); + + $applications = $this->internApplicationRepository + ->findBy(['announcement' => $announcements]); + + return $this->render('employee/applications.html.twig', [ + 'applications' => $applications, + ]); + } + + } diff --git a/src/Controller/InternController.php b/src/Controller/InternController.php index f53321c..ff4b627 100644 --- a/src/Controller/InternController.php +++ b/src/Controller/InternController.php @@ -135,6 +135,7 @@ final class InternController extends AbstractController $internApplication->setIntern($intern); $internApplication->setApplication($announcement); $internApplication->setApplicationDate(new \DateTime()); + $internApplication->setStatus("En Attente"); $entityManager->persist($internApplication); } diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index d25e351..4277747 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -2,6 +2,9 @@ namespace App\Controller; +use App\Entity\Announcement; +use App\Entity\Intern; +use App\Entity\InternApplication; use App\Entity\UserApp; use App\Form\UserAppType; use Doctrine\ORM\EntityManagerInterface; @@ -13,7 +16,7 @@ use Symfony\Component\Routing\Attribute\Route; class ProfileController extends AbstractController { #[Route('/profile', name: 'app_profile')] - public function profile(): Response + public function profile(EntityManagerInterface $entityManager): Response { $user = $this->getUser(); @@ -21,8 +24,23 @@ class ProfileController extends AbstractController throw $this->createAccessDeniedException('Vous devez être connecté pour accéder à cette page.'); } + if ($user instanceof Intern) + { + $internApplicationRepository = $entityManager->getRepository(InternApplication::class); + + $internApplications = $internApplicationRepository->findBy([ + 'intern' => $user, + ]); + + return $this->render('profile/index.html.twig', [ + 'user' => $user, + 'applications' => $internApplications + ]); + } + return $this->render('profile/index.html.twig', [ 'user' => $user, + 'applications' => [] ]); } @@ -44,6 +62,21 @@ class ProfileController extends AbstractController ]); } + #[Route('/profile/{id}/visit', name: 'app_profile_visit')] + public function visitProfile(EntityManagerInterface $entityManager, int $id): Response + { + $user = $entityManager->getRepository(Intern::class)->find($id); + + if (!$user) { + throw $this->createNotFoundException('Utilisateur non trouvé.'); + } + + return $this->render('profile/index.html.twig', [ + 'user' => $user, + ]); + } + + #[Route('profile/pickDegree', name: 'app_profile_pickDegree', methods: ['GET'])] public function pickDegree(UserApp $userApp): Response { diff --git a/src/Entity/InternApplication.php b/src/Entity/InternApplication.php index 484a6ea..2444c8b 100644 --- a/src/Entity/InternApplication.php +++ b/src/Entity/InternApplication.php @@ -23,6 +23,9 @@ class InternApplication #[ORM\Column(type: Types::DATE_MUTABLE)] private ?\DateTimeInterface $applicationDate = null; + #[ORM\Column(length: 20)] + private ?string $status = null; + public function getId(): ?int { return $this->id; @@ -63,4 +66,14 @@ class InternApplication return $this; } + + public function getStatus(): ?string + { + return $this->status; + } + + public function setStatus(?string $status): void + { + $this->status = $status; + } } diff --git a/templates/employee/applications.html.twig b/templates/employee/applications.html.twig new file mode 100644 index 0000000..18efabb --- /dev/null +++ b/templates/employee/applications.html.twig @@ -0,0 +1,24 @@ +{% extends 'base.html.twig' %} + +{% block title %}Liste des Candidatures{% endblock %} + +{% block body %} +
Annonce : {{ app.application.title }}
+Candidat : {{ app.intern.firstName }} {{ app.intern.lastName }}
+Date : {{ app.applicationDate|date('d/m/Y') }}
+Statut : {{ app.status }}
+ + + Voir le profil du candidat + +Aucune candidature pour le moment.
+{% endfor %} + +{% endblock %} diff --git a/templates/profile/employee.html.twig b/templates/profile/employee.html.twig index 88ef603..1688471 100644 --- a/templates/profile/employee.html.twig +++ b/templates/profile/employee.html.twig @@ -8,6 +8,12 @@Téléphone : {{ app.user.tel }}
Email : {{ app.user.mail }}
+ + Voir les candidatures reçues + + +Offre : {{ appli.application.title }}
+Entreprise : {{ appli.application.company.name }}
+Date de candidature : {{ appli.applicationDate|date('d/m/Y') }}
+Statut : {{ appli.status }}
+Vous n'avez pas encore postulé à une offre.
+ {% endif %} + +