ajout de la selection des diplomes dans le profile
This commit is contained in:
parent
1d5798a265
commit
bd50807d9f
@ -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;
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
@ -6,52 +6,55 @@
|
||||
<div class="container mx-auto p-6">
|
||||
<h1 class="text-3xl font-bold mb-4">Liste des Diplômes</h1>
|
||||
|
||||
<!-- Tableau des diplômes -->
|
||||
<div class="overflow-x-auto bg-white shadow-lg rounded-lg">
|
||||
<table class="min-w-full table-auto">
|
||||
<thead>
|
||||
<tr class="bg-gray-800 text-white">
|
||||
<th class="px-4 py-2 text-left">ID</th>
|
||||
<th class="px-4 py-2 text-left">Label</th>
|
||||
<th class="px-4 py-2 text-left">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for degree in degrees %}
|
||||
<tr class="border-b">
|
||||
<td class="px-4 py-2">{{ degree.id }}</td>
|
||||
<td class="px-4 py-2">{{ degree.label }}</td>
|
||||
<td class="px-4 py-2">
|
||||
<!-- Voir le diplôme -->
|
||||
<a href="{{ path('app_degree_show', {'id': degree.id}) }}" class="text-teal-500 hover:text-teal-700 mr-3">
|
||||
<i class="fas fa-eye"></i> Voir
|
||||
</a>
|
||||
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||
<form method="post" action="{{ path('app_intern_add_degrees') }}">
|
||||
{% endif %}
|
||||
|
||||
<!-- Modifier le diplôme -->
|
||||
<a href="{{ path('app_degree_edit', {'id': degree.id}) }}" class="text-yellow-500 hover:text-yellow-700 mr-3">
|
||||
<i class="fas fa-edit"></i> Modifier
|
||||
</a>
|
||||
|
||||
<!-- Formulaire pour supprimer le diplôme -->
|
||||
<form method="post" action="{{ path('app_degree_delete', {'id': degree.id}) }}" style="display:inline;">
|
||||
<input type="hidden" name="_method" value="DELETE">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ degree.id) }}">
|
||||
<button type="submit" class="text-red-500 hover:text-red-700">
|
||||
<i class="fas fa-trash-alt"></i> Supprimer
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
<!-- Tableau des diplômes -->
|
||||
<div class="overflow-x-auto bg-white shadow-lg rounded-lg">
|
||||
<table class="min-w-full table-auto">
|
||||
<thead>
|
||||
<tr class="bg-gray-800 text-white">
|
||||
<th class="px-4 py-2 text-left">ID</th>
|
||||
<th class="px-4 py-2 text-left">Label</th>
|
||||
<th class="px-4 py-2 text-left">Actions</th>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for degree in degrees %}
|
||||
<tr class="border-b">
|
||||
<td class="px-4 py-2">{{ degree.id }}</td>
|
||||
<td class="px-4 py-2">{{ degree.label }}</td>
|
||||
<td class="px-4 py-2">
|
||||
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||
<label>
|
||||
<input type="checkbox" name="selected_degrees[]" value="{{ degree.id }}" class="mr-2">
|
||||
Sélectionner
|
||||
</label>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||
<div class="mt-4">
|
||||
<button type="submit" class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-full">
|
||||
<i class="fas fa-check-circle"></i> Valider la sélection
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||
<!-- Lien pour ajouter un nouveau diplôme -->
|
||||
<div class="mt-4">
|
||||
<a href="{{ path('app_degree_new') }}" class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full">
|
||||
<i class="fas fa-plus-circle"></i> Ajouter un nouveau diplôme
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -12,7 +12,7 @@
|
||||
<h1 class="text-4xl md:text-5xl font-bold mb-4">Trouvez votre stage de rêve !</h1>
|
||||
<p class="text-lg mb-8">Connectez les talents aux opportunités : votre clé vers le succès professionnel</p>
|
||||
<div class="bg-white rounded-lg shadow-lg p-6 inline-block">
|
||||
<div class="flex flex-col md:flex-row space-y-4 md:space-y-0 md:space-x-4">
|
||||
<div class="flex flex-col md:flex-row space-y-4 md:space-y-0 md:space-x-4 text-black">
|
||||
<label>
|
||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Nom de l'entreprise" type="text"/>
|
||||
</label>
|
||||
|
@ -1,7 +1,16 @@
|
||||
<div class="bg-white p-6 rounded-lg shadow-md">
|
||||
<h2 class="text-xl font-semibold mb-4">Bonjour {{ app.user.firstName }} {{ app.user.lastName }}</h2>
|
||||
<p class="text-gray-700">Vous êtes employé(e) chez {{ app.user.company }}.</p>
|
||||
<h2 class="text-xl font-semibold mb-4">Bonjour {{ app.user.nickname }}</h2>
|
||||
<h3 class="text-lg font-semibold mt-6">Vous etes employé chez {{ app.user.company.name }}</h3>
|
||||
<br>
|
||||
<p class="text-gray-600">Nom : {{ app.user.firstName }}</p>
|
||||
<p class="text-gray-600">Prénom : {{ app.user.lastName }}</p>
|
||||
<p class="text-gray-600">Adresse : {{ app.user.address }}</p>
|
||||
<p class="text-gray-600">Téléphone : {{ app.user.tel }}</p>
|
||||
<p class="text-gray-600">Email : {{ app.user.mail }}</p>
|
||||
|
||||
<div class="flex justify-end mt-6">
|
||||
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full"
|
||||
href="{{ path('app_profile_edit',{id: app.user.id}) }}"> Modifier
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,8 +11,8 @@
|
||||
<h3 class="text-lg font-semibold mt-6">Vos diplômes :</h3>
|
||||
<ul class="list-disc list-inside text-gray-800">
|
||||
{% if app.user.degrees|length > 0 %}
|
||||
{% for deg in app.user.degrees %}
|
||||
<li>{{ deg.label }}</li>
|
||||
{% for internDegree in app.user.degrees %}
|
||||
<li>{{ internDegree.degree.label }}</li>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<br>
|
||||
@ -21,7 +21,7 @@
|
||||
</ul>
|
||||
<br>
|
||||
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full"
|
||||
href="{{ path('app_user_edit',{id: app.user.id}) }}"> Selectionner vos diplômes
|
||||
href="{{ path('app_degree_index',{id: app.user.id}) }}"> Selectionner vos diplômes
|
||||
</a>
|
||||
|
||||
<h3 class="text-lg font-semibold mt-6">Vos compétences :</h3>
|
||||
|
Loading…
x
Reference in New Issue
Block a user