ajout candidatures
This commit is contained in:
parent
3af4232ec8
commit
0246adcc03
@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Announcement;
|
||||
use App\Entity\Degree;
|
||||
use App\Entity\Intern;
|
||||
use App\Entity\InternApplication;
|
||||
use App\Entity\InternDegree;
|
||||
use App\Form\InternType;
|
||||
use App\Repository\InternRepository;
|
||||
@ -108,4 +110,39 @@ final class InternController extends AbstractController
|
||||
|
||||
return $this->redirectToRoute('app_profile');
|
||||
}
|
||||
|
||||
#[Route('/application/send', name:'app_intern_send_application', methods:['POST'])]
|
||||
public function sendApplication(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$intern = $this->getUser();
|
||||
if (!$intern instanceof Intern) {
|
||||
throw $this->createAccessDeniedException("Seuls les stagiaires peuvent envoyer des candidatures.");
|
||||
}
|
||||
|
||||
$announcementRepository = $entityManager->getRepository(Announcement::class);
|
||||
$internApplicationRepository = $entityManager->getRepository(InternApplication::class);
|
||||
|
||||
$announcementId = $request->request->get('announcement_id');
|
||||
$announcement = $announcementRepository->find($announcementId);
|
||||
|
||||
$existingInternApplication = $internApplicationRepository->findOneBy([
|
||||
'intern' => $intern,
|
||||
'application' => $announcement
|
||||
]);
|
||||
|
||||
if (!$existingInternApplication) {
|
||||
$internApplication = new InternApplication();
|
||||
$internApplication->setIntern($intern);
|
||||
$internApplication->setApplication($announcement);
|
||||
$internApplication->setApplicationDate(new \DateTime());
|
||||
|
||||
$entityManager->persist($internApplication);
|
||||
}
|
||||
$entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'La candidature à bien été envoyée.');
|
||||
|
||||
return $this->redirectToRoute('app_profile');
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,15 @@
|
||||
<span>{{ announcement.creationDate | date('d/m/Y') }}</span>
|
||||
</div>
|
||||
|
||||
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||
<form method="post" action="{{ path('app_intern_send_application') }}">
|
||||
<input type="hidden" name="announcement_id" value="{{ announcement.id }}">
|
||||
<button type="submit" class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded">
|
||||
<i class="fas fa-paper-plane"></i> Candidater à cette offre
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||
|
||||
<!-- Boutons Modifier et Valider -->
|
||||
|
@ -28,19 +28,22 @@
|
||||
<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">
|
||||
<input type="checkbox" name="selected_degrees[]" value="{{ degree.id }}"
|
||||
class="mr-2">
|
||||
Sélectionner
|
||||
</label>
|
||||
{% endif %}
|
||||
|
||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||
<!-- Modifier le diplôme -->
|
||||
<a href="{{ path('app_degree_edit', {'id': degree.id}) }}" class="text-yellow-500 hover:text-yellow-700 mr-3">
|
||||
<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;">
|
||||
<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">
|
||||
@ -67,7 +70,8 @@
|
||||
{% 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">
|
||||
<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>
|
||||
|
@ -26,14 +26,7 @@
|
||||
|
||||
<h3 class="text-lg font-semibold mt-6">Vos compétences :</h3>
|
||||
<ul class="list-disc list-inside text-gray-800">
|
||||
{% if app.user.skills|length > 0 %}
|
||||
{% for comp in app.user.skills %}
|
||||
<li>{{ comp.label }}</li>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<br>
|
||||
Aucune pour le moment
|
||||
{% endif %}
|
||||
|
||||
</ul>
|
||||
<br>
|
||||
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full"
|
||||
@ -44,6 +37,9 @@
|
||||
<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}) }}"> Accéder aux favoris
|
||||
</a>
|
||||
<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}) }}"> Accéder aux candidatures
|
||||
</a>
|
||||
</div>
|
||||
<div class="flex justify-end mt-6">
|
||||
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full"
|
||||
|
Loading…
x
Reference in New Issue
Block a user