From 3902207427dee30e4a024dd244775cfc9c1e5f97 Mon Sep 17 00:00:00 2001 From: noureddina Date: Fri, 20 Dec 2024 09:09:10 +0100 Subject: [PATCH 1/7] Sauvegarde des modifications avant de changer de branche --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ### From 1eb8418cff27a66e1d61d7f069cda341c86a2298 Mon Sep 17 00:00:00 2001 From: noureddina Date: Fri, 20 Dec 2024 11:37:55 +0100 Subject: [PATCH 2/7] Correctif Message --- src/Controller/MessageController.php | 2 +- src/Repository/MessageRepository.php | 26 +++++++++++++++++++++++++ templates/message/index.html.twig | 29 ++++++++++++++++------------ 3 files changed, 44 insertions(+), 13 deletions(-) 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/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/message/index.html.twig b/templates/message/index.html.twig index 4c7da31..433924d 100644 --- a/templates/message/index.html.twig +++ b/templates/message/index.html.twig @@ -17,20 +17,25 @@
{% for message in messages %} - {% if message.receiver == app.user or message.sender == app.user %} -
-
-
-

De : {{ message.sender.nickname }}

-

{{ message.sendingDate|date('d/m/Y H:i') }}

-
- - Voir la Conversation - +
+
+
+

+ De : + {% if message.sender == app.user %} + {{ message.receiver.nickname }} + {% else %} + {{ message.sender.nickname }} + {% endif %} +

+

{{ message.sendingDate|date('d/m/Y H:i') }}

-

{{ message.content }}

+ + Voir la Conversation +
- {% endif %} +

{{ message.content }}

+
{% else %}

Vous n'avez reçu aucun message.

{% endfor %} From 5aa2c3a4b5b18950a646a6f8f0c15e6e0c914c33 Mon Sep 17 00:00:00 2001 From: Romain Date: Sun, 12 Jan 2025 16:01:37 +0100 Subject: [PATCH 3/7] oui --- migrations/Version20241121141451.php | 38 --------------------- migrations/Version20241121141722.php | 40 ----------------------- migrations/Version20241121141818.php | 31 ------------------ migrations/Version20241121141912.php | 32 ------------------ migrations/Version20241121142119.php | 34 ------------------- migrations/Version20241121142432.php | 31 ------------------ migrations/Version20241121145353.php | 32 ------------------ migrations/Version20241121151633.php | 31 ------------------ migrations/Version20241121162300.php | 31 ------------------ migrations/Version20241121164509.php | 31 ------------------ src/Controller/AnnouncementController.php | 12 +++++++ templates/profile/index.html.twig | 26 ++++++++++++++- 12 files changed, 37 insertions(+), 332 deletions(-) delete mode 100644 migrations/Version20241121141451.php delete mode 100644 migrations/Version20241121141722.php delete mode 100644 migrations/Version20241121141818.php delete mode 100644 migrations/Version20241121141912.php delete mode 100644 migrations/Version20241121142119.php delete mode 100644 migrations/Version20241121142432.php delete mode 100644 migrations/Version20241121145353.php delete mode 100644 migrations/Version20241121151633.php delete mode 100644 migrations/Version20241121162300.php delete mode 100644 migrations/Version20241121164509.php 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/templates/profile/index.html.twig b/templates/profile/index.html.twig index 0c4742a..fa907bf 100644 --- a/templates/profile/index.html.twig +++ b/templates/profile/index.html.twig @@ -18,7 +18,31 @@ {% if 'ROLE_ADMIN' in app.user.roles%} {% endif %}
From d80e67c96adb914e6fbcb90ccfcba2f3e4660307 Mon Sep 17 00:00:00 2001 From: Allavena Romain Date: Mon, 31 Mar 2025 09:24:51 +0200 Subject: [PATCH 4/7] nom route annonce (aid mubarak) --- templates/base.html.twig | 4 ++-- templates/index/index.html.twig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/base.html.twig b/templates/base.html.twig index 0f85cf3..adaa054 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -27,7 +27,7 @@
@@ -60,7 +60,7 @@

Liens utiles

diff --git a/templates/index/index.html.twig b/templates/index/index.html.twig index 8fb84d2..ff61a24 100644 --- a/templates/index/index.html.twig +++ b/templates/index/index.html.twig @@ -41,7 +41,7 @@

Propositions de stages

- Voir tout + Voir tout
From 1d5798a2654c4a8ecb533fcfdd3ec35b691ec754 Mon Sep 17 00:00:00 2001 From: Allavena Romain Date: Mon, 31 Mar 2025 10:33:45 +0200 Subject: [PATCH 5/7] retirer les routes qui n'existent pas --- templates/employee/index.html.twig | 1 - templates/employee/new.html.twig | 3 ++- templates/intern/index.html.twig | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) 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/intern/index.html.twig b/templates/intern/index.html.twig index b8c3a7f..02c128a 100644 --- a/templates/intern/index.html.twig +++ b/templates/intern/index.html.twig @@ -48,6 +48,4 @@ {% endfor %} - - Create new {% endblock %} From bd50807d9f0e5d20ef5627c27df749bf4523aafc Mon Sep 17 00:00:00 2001 From: Allavena Romain Date: Thu, 3 Apr 2025 17:01:08 +0200 Subject: [PATCH 6/7] ajout de la selection des diplomes dans le profile --- src/Controller/DegreeController.php | 1 + src/Controller/InternController.php | 50 ++++++++++++++++++ src/Controller/ProfileController.php | 10 +++- templates/degree/index.html.twig | 79 +++++++++++++++------------- templates/index/index.html.twig | 2 +- templates/profile/employee.html.twig | 13 ++++- templates/profile/intern.html.twig | 6 +-- 7 files changed, 115 insertions(+), 46 deletions(-) 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/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/templates/degree/index.html.twig b/templates/degree/index.html.twig index 670e9c5..3c63338 100644 --- a/templates/degree/index.html.twig +++ b/templates/degree/index.html.twig @@ -6,52 +6,55 @@

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 %} + + + {% endfor %} + + +
+ {% if 'ROLE_INTERN' in app.user.roles %} +
+ +
+ + {% endif %} + + {% if 'ROLE_ADMIN' in app.user.roles %} + {% endif %}
{% endblock %} diff --git a/templates/index/index.html.twig b/templates/index/index.html.twig index a35c679..44a983e 100644 --- a/templates/index/index.html.twig +++ b/templates/index/index.html.twig @@ -12,7 +12,7 @@

Trouvez votre stage de rêve !

Connectez les talents aux opportunités : votre clé vers le succès professionnel

-
+
diff --git a/templates/profile/employee.html.twig b/templates/profile/employee.html.twig index 641f9fe..88ef603 100644 --- a/templates/profile/employee.html.twig +++ b/templates/profile/employee.html.twig @@ -1,7 +1,16 @@
-

Bonjour {{ app.user.firstName }} {{ app.user.lastName }}

-

Vous êtes employé(e) chez {{ app.user.company }}.

+

Bonjour {{ app.user.nickname }}

+

Vous etes employé chez {{ app.user.company.name }}

+
+

Nom : {{ app.user.firstName }}

+

Prénom : {{ app.user.lastName }}

Adresse : {{ app.user.address }}

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

Email : {{ app.user.mail }}

+ +
diff --git a/templates/profile/intern.html.twig b/templates/profile/intern.html.twig index 5d6e0b3..d74a3ff 100644 --- a/templates/profile/intern.html.twig +++ b/templates/profile/intern.html.twig @@ -11,8 +11,8 @@

Vos diplômes :

    {% if app.user.degrees|length > 0 %} - {% for deg in app.user.degrees %} -
  • {{ deg.label }}
  • + {% for internDegree in app.user.degrees %} +
  • {{ internDegree.degree.label }}
  • {% endfor %} {% else %}
    @@ -21,7 +21,7 @@

Selectionner vos diplômes + href="{{ path('app_degree_index',{id: app.user.id}) }}"> Selectionner vos diplômes

Vos compétences :

From 028f3bdaa562b533e4f8fc2578cb245dfae86c57 Mon Sep 17 00:00:00 2001 From: Allavena Romain Date: Fri, 4 Apr 2025 08:54:23 +0200 Subject: [PATCH 7/7] rajout de la modif et suppression des diplomes --- templates/degree/index.html.twig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/templates/degree/index.html.twig b/templates/degree/index.html.twig index 3c63338..a6016d5 100644 --- a/templates/degree/index.html.twig +++ b/templates/degree/index.html.twig @@ -32,6 +32,22 @@ Sélectionner {% endif %} + + {% if 'ROLE_ADMIN' in app.user.roles %} + + + Modifier + + + +
+ + + +
+ {% endif %} {% endfor %}