diff --git a/.env b/.env index 7c81431..cf2916f 100644 --- a/.env +++ b/.env @@ -26,7 +26,7 @@ APP_SECRET=f024eb6ed2c61908ec7842f29b9a6334 # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4" # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" -DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8" +DATABASE_URL="postgresql://allavenavr:Btssio2024@172.20.96.1:5432/hegresphere?serverVersion=16&charset=utf8" ###< doctrine/doctrine-bundle ### ###> symfony/messenger ### diff --git a/migrations/Version20241121141451.php b/migrations/Version20241121141451.php deleted file mode 100644 index d51cde4..0000000 --- a/migrations/Version20241121141451.php +++ /dev/null @@ -1,38 +0,0 @@ -addSql('DROP SEQUENCE status_id_seq CASCADE'); - $this->addSql('DROP TABLE status'); - $this->addSql('ALTER TABLE userapp ADD is_verified BOOLEAN NOT NULL'); - $this->addSql('ALTER TABLE userapp ALTER roles SET NOT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('CREATE SEQUENCE status_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE TABLE status (id INT NOT NULL, label VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('ALTER TABLE userApp DROP is_verified'); - $this->addSql('ALTER TABLE userApp ALTER roles DROP NOT NULL'); - } -} diff --git a/migrations/Version20241121141722.php b/migrations/Version20241121141722.php deleted file mode 100644 index 6259ec7..0000000 --- a/migrations/Version20241121141722.php +++ /dev/null @@ -1,40 +0,0 @@ -addSql('ALTER TABLE userapp ALTER first_name DROP NOT NULL'); - $this->addSql('ALTER TABLE userapp ALTER last_name DROP NOT NULL'); - $this->addSql('ALTER TABLE userapp ALTER tel DROP NOT NULL'); - $this->addSql('ALTER TABLE userapp ALTER address DROP NOT NULL'); - $this->addSql('ALTER TABLE userapp ALTER mail DROP NOT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE userApp ALTER first_name SET NOT NULL'); - $this->addSql('ALTER TABLE userApp ALTER last_name SET NOT NULL'); - $this->addSql('ALTER TABLE userApp ALTER tel SET NOT NULL'); - $this->addSql('ALTER TABLE userApp ALTER address SET NOT NULL'); - $this->addSql('ALTER TABLE userApp ALTER mail SET NOT NULL'); - } -} diff --git a/migrations/Version20241121141818.php b/migrations/Version20241121141818.php deleted file mode 100644 index 7eb43e8..0000000 --- a/migrations/Version20241121141818.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE SCHEMA public'); - } -} diff --git a/migrations/Version20241121141912.php b/migrations/Version20241121141912.php deleted file mode 100644 index fbc5345..0000000 --- a/migrations/Version20241121141912.php +++ /dev/null @@ -1,32 +0,0 @@ -addSql('ALTER TABLE userapp ALTER is_verified DROP NOT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE userApp ALTER is_verified SET NOT NULL'); - } -} diff --git a/migrations/Version20241121142119.php b/migrations/Version20241121142119.php deleted file mode 100644 index 44746a0..0000000 --- a/migrations/Version20241121142119.php +++ /dev/null @@ -1,34 +0,0 @@ -addSql('ALTER TABLE intern ALTER cover_letter DROP NOT NULL'); - $this->addSql('ALTER TABLE intern ALTER resume DROP NOT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE intern ALTER cover_letter SET NOT NULL'); - $this->addSql('ALTER TABLE intern ALTER resume SET NOT NULL'); - } -} diff --git a/migrations/Version20241121142432.php b/migrations/Version20241121142432.php deleted file mode 100644 index 8226230..0000000 --- a/migrations/Version20241121142432.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE SCHEMA public'); - } -} diff --git a/migrations/Version20241121145353.php b/migrations/Version20241121145353.php deleted file mode 100644 index 439bd80..0000000 --- a/migrations/Version20241121145353.php +++ /dev/null @@ -1,32 +0,0 @@ -addSql('ALTER TABLE employee ALTER company_id DROP NOT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE employee ALTER company_id SET NOT NULL'); - } -} diff --git a/migrations/Version20241121151633.php b/migrations/Version20241121151633.php deleted file mode 100644 index b9a833a..0000000 --- a/migrations/Version20241121151633.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE SCHEMA public'); - } -} diff --git a/migrations/Version20241121162300.php b/migrations/Version20241121162300.php deleted file mode 100644 index 78a9482..0000000 --- a/migrations/Version20241121162300.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE SCHEMA public'); - } -} diff --git a/migrations/Version20241121164509.php b/migrations/Version20241121164509.php deleted file mode 100644 index e3db761..0000000 --- a/migrations/Version20241121164509.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE SCHEMA public'); - } -} diff --git a/src/Controller/AnnouncementController.php b/src/Controller/AnnouncementController.php index f9f0243..a1da498 100644 --- a/src/Controller/AnnouncementController.php +++ b/src/Controller/AnnouncementController.php @@ -56,6 +56,18 @@ final class AnnouncementController extends AbstractController #[Route('/new', name: 'app_announcement_new', methods: ['GET', 'POST'])] public function new(Request $request, EntityManagerInterface $entityManager): Response { + /*$user = $this->getUser(); + + if (in_array('ROLE_EMPLOYEE', $user->getRoles())) { + $company = $user->getCompany(); + + if (!$company) + { + echo "Compétez votre profile avant de créer une annonce"; + $this->redirectToRoute('app_user_edit',['id' => $user->getId(),]); + } + }*/ + $announcement = new Announcement(); $form = $this->createForm(AnnouncementType::class, $announcement); $form->handleRequest($request); diff --git a/src/Controller/DegreeController.php b/src/Controller/DegreeController.php index d7d54e0..d4e2469 100644 --- a/src/Controller/DegreeController.php +++ b/src/Controller/DegreeController.php @@ -3,6 +3,7 @@ namespace App\Controller; use App\Entity\Degree; +use App\Entity\InternDegree; use App\Form\DegreeType; use App\Repository\DegreeRepository; use Doctrine\ORM\EntityManagerInterface; diff --git a/src/Controller/InternController.php b/src/Controller/InternController.php index f1de7d0..0ada2cc 100644 --- a/src/Controller/InternController.php +++ b/src/Controller/InternController.php @@ -2,7 +2,9 @@ namespace App\Controller; +use App\Entity\Degree; use App\Entity\Intern; +use App\Entity\InternDegree; use App\Form\InternType; use App\Repository\InternRepository; use Doctrine\ORM\EntityManagerInterface; @@ -58,4 +60,52 @@ final class InternController extends AbstractController return $this->redirectToRoute('app_intern_index', [], Response::HTTP_SEE_OTHER); } + + #[Route('/degrees/add', name:'app_intern_add_degrees', methods:['POST'])] + public function addDegrees(Request $request, EntityManagerInterface $entityManager): Response + { + $intern = $this->getUser(); + + if (!$intern instanceof Intern) { + throw $this->createAccessDeniedException("Seuls les stagiaires peuvent sélectionner des diplômes."); + } + + $selectedDegreeIds = $request->request->all('selected_degrees'); + + if ($selectedDegreeIds == []) { + $this->addFlash('error', "Aucune sélection valide n'a été effectuée."); + return $this->redirectToRoute('app_degree_index'); + } + + $degreeRepository = $entityManager->getRepository(Degree::class); + $internDegreeRepository = $entityManager->getRepository(InternDegree::class); + + foreach ($selectedDegreeIds as $degreeId) { + $degree = $degreeRepository->find($degreeId); + + if (!$degree) { + continue; + } + + $existingInternDegree = $internDegreeRepository->findOneBy([ + 'intern' => $intern, + 'degree' => $degree + ]); + + if (!$existingInternDegree) { + $internDegree = new InternDegree(); + $internDegree->setIntern($intern); + $internDegree->setDegree($degree); + $internDegree->setGraduationDate(new \DateTime()); + + $entityManager->persist($internDegree); + } + } + + $entityManager->flush(); + + $this->addFlash('success', 'Les diplômes ont été ajoutés avec succès.'); + + return $this->redirectToRoute('app_profile'); + } } diff --git a/src/Controller/MessageController.php b/src/Controller/MessageController.php index af9633a..cca62c2 100644 --- a/src/Controller/MessageController.php +++ b/src/Controller/MessageController.php @@ -20,7 +20,7 @@ final class MessageController extends AbstractController public function index(MessageRepository $messageRepository): Response { $user = $this->getUser(); - $messages = $messageRepository->findByUser($user); + $messages = $messageRepository->findLatestMessagesByUser($user); return $this->render('message/index.html.twig', [ 'messages' => $messages, diff --git a/src/Controller/ProfileController.php b/src/Controller/ProfileController.php index 5781c19..d25e351 100644 --- a/src/Controller/ProfileController.php +++ b/src/Controller/ProfileController.php @@ -15,10 +15,8 @@ class ProfileController extends AbstractController #[Route('/profile', name: 'app_profile')] public function profile(): Response { - // Charger l'utilisateur connecté $user = $this->getUser(); - // Vérifiez les rôles si nécessaire if (!$user) { throw $this->createAccessDeniedException('Vous devez être connecté pour accéder à cette page.'); } @@ -45,4 +43,12 @@ class ProfileController extends AbstractController 'form' => $form, ]); } + + #[Route('profile/pickDegree', name: 'app_profile_pickDegree', methods: ['GET'])] + public function pickDegree(UserApp $userApp): Response + { + return $this->render('degree/index.html.twig', [ + 'user_app' => $userApp, + ]); + } } \ No newline at end of file diff --git a/src/Repository/MessageRepository.php b/src/Repository/MessageRepository.php index fd3e6b3..19bf4a6 100644 --- a/src/Repository/MessageRepository.php +++ b/src/Repository/MessageRepository.php @@ -37,4 +37,30 @@ class MessageRepository extends ServiceEntityRepository ->getQuery() ->getResult(); } + + public function findLatestMessagesByUser(UserApp $user): array + { + $query = $this->createQueryBuilder('m') + ->where('m.sender = :user OR m.receiver = :user') + ->setParameter('user', $user) + ->orderBy('m.sendingDate', 'DESC') + ->getQuery() + ->getResult(); + + $lastMessages = []; + foreach ($query as $message) { + // Identifier l'autre utilisateur dans la conversation + $otherUser = $message->getSender() === $user ? $message->getReceiver() : $message->getSender(); + $key = $otherUser->getId(); + + // Conserver uniquement le dernier message avec cet utilisateur + if (!isset($lastMessages[$key])) { + $lastMessages[$key] = $message; + } + } + + return $lastMessages; + } + + } diff --git a/templates/degree/index.html.twig b/templates/degree/index.html.twig index 670e9c5..a6016d5 100644 --- a/templates/degree/index.html.twig +++ b/templates/degree/index.html.twig @@ -6,52 +6,71 @@

Liste des Diplômes

- -
- - - - - - - - - - {% for degree in degrees %} - - - - + +
+
IDLabelActions
{{ degree.id }}{{ degree.label }} - - - Voir - + {% if 'ROLE_INTERN' in app.user.roles %} +
+ {% endif %} - - - Modifier - - - - - - - -
-
+ + + + + - {% endfor %} - -
IDLabelActions
-
+ + + {% for degree in degrees %} + + {{ degree.id }} + {{ degree.label }} + + {% if 'ROLE_INTERN' in app.user.roles %} + + {% endif %} + {% if 'ROLE_ADMIN' in app.user.roles %} + + + Modifier + + + +
+ + + +
+ {% endif %} + + + {% endfor %} + + +
+ + {% if 'ROLE_INTERN' in app.user.roles %} +
+ +
+ + {% endif %} + + {% if 'ROLE_ADMIN' in app.user.roles %}
Ajouter un nouveau diplôme
+ {% endif %} {% endblock %} diff --git a/templates/employee/index.html.twig b/templates/employee/index.html.twig index 1e8c132..c1ec064 100644 --- a/templates/employee/index.html.twig +++ b/templates/employee/index.html.twig @@ -45,5 +45,4 @@ - Create new {% endblock %} diff --git a/templates/employee/new.html.twig b/templates/employee/new.html.twig index 677c5b6..69f96b8 100644 --- a/templates/employee/new.html.twig +++ b/templates/employee/new.html.twig @@ -1,4 +1,5 @@ -{% extends 'base.html.twig' %} +{% extends 'base.html.twig' %} Create new + {% block title %}New Employee{% endblock %} diff --git a/templates/index/index.html.twig b/templates/index/index.html.twig index 3cbb7f0..44a983e 100644 --- a/templates/index/index.html.twig +++ b/templates/index/index.html.twig @@ -3,8 +3,8 @@ {% block title %}Accueil - Job Portal{% endblock %} {% block body %} - - + + {#