possibilité d'accepter ou de refuser les candidatures

This commit is contained in:
Allavena Romain 2025-04-08 10:34:00 +02:00
parent 09b84379bf
commit 545fe59fc8
5 changed files with 80 additions and 35 deletions

View File

@ -92,5 +92,31 @@ final class EmployeeController extends AbstractController
]);
}
#[Route('/application/{id}/update-status/{status}', name: 'app_employee_update_application_status', methods: ['POST'])]
public function updateApplicationStatus(int $id, string $status): Response
{
$employee = $this->getUser();
if (!$employee instanceof Employee) {
throw $this->createAccessDeniedException('Seuls les employés peuvent accéder à cette action.');
}
$application = $this->internApplicationRepository->find($id);
if (!$application) {
throw $this->createNotFoundException('Candidature introuvable.');
}
$company = $employee->getCompany();
if ($application->getApplication()->getCompany() !== $company) {
throw $this->createAccessDeniedException('Cette candidature ne vous appartient pas.');
}
$application->setStatus($status);
$this->entityManager->flush();
$this->addFlash('success', 'Le statut de la candidature a bien été mis à jour.');
return $this->redirectToRoute('app_employee_seeApplications');
}
}

View File

@ -63,17 +63,17 @@ class ProfileController extends AbstractController
]);
}
#[Route('/profile/{id}/visit', name: 'app_profile_visit')]
#[Route('/profile/visit/{id}', name: 'app_profile_visit')]
public function visitProfile(EntityManagerInterface $entityManager, int $id): Response
{
$user = $entityManager->getRepository(Intern::class)->find($id);
$candidat = $entityManager->getRepository(Intern::class)->find($id);
if (!$user) {
if (!$candidat) {
throw $this->createNotFoundException('Utilisateur non trouvé.');
}
return $this->render('profile/index.html.twig', [
'user' => $user,
return $this->render('profile/visit.html.twig', [
'candidat' => $candidat,
]);
}

View File

@ -3,22 +3,41 @@
{% block title %}Liste des Candidatures{% endblock %}
{% block body %}
<h2 class="text-2xl font-bold mb-6">Candidatures reçues</h2>
<div class="max-w-2xl mx-auto mt-8">
<h2 class="text-3xl font-semibold text-center mb-8 text-gray-800">Candidatures reçues</h2>
{% for app in applications %}
<div class="border border-gray-300 rounded-lg p-4 mb-4 shadow-sm bg-white">
<p><strong>Annonce :</strong> {{ app.application.title }}</p>
<p><strong>Candidat :</strong> {{ app.intern.firstName }} {{ app.intern.lastName }}</p>
<p><strong>Date :</strong> {{ app.applicationDate|date('d/m/Y') }}</p>
<p><strong>Statut :</strong> {{ app.status }}</p>
{% for app in applications %}
<div class="border border-gray-200 rounded-2xl p-6 shadow-md bg-white space-y-2">
<p><span class="font-semibold text-gray-700">Annonce :</span> {{ app.application.title }}</p>
<p><span class="font-semibold text-gray-700">Candidat :</span> {{ app.intern.firstName }} {{ app.intern.lastName }}</p>
<p><span class="font-semibold text-gray-700">Date :</span> {{ app.applicationDate|date('d/m/Y') }}</p>
<p><span class="font-semibold text-gray-700">Statut :</span> {{ app.status|capitalize }}</p>
<a href="{{ path('app_profile_visit', { id: app.intern.id }) }}"
class="inline-block mt-2 bg-teal-500 hover:bg-teal-600 text-white px-4 py-2 rounded">
Voir le profil du candidat
</a>
<a href="{{ path('app_profile_visit', { id: app.intern.id }) }}"
class="inline-block mt-3 bg-teal-500 hover:bg-teal-600 text-white px-4 py-2 rounded shadow">
Voir le profil du candidat
</a>
{% if app.status == 'En Attente' %}
<div class="flex justify-end gap-3 mt-4">
<form method="post" action="{{ path('app_employee_update_application_status',
{id: app.id, status: 'Acceptée'}) }}">
<button type="submit" class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded shadow">
Accepter
</button>
</form>
<form method="post" action="{{ path('app_employee_update_application_status',
{id: app.id, status: 'Refusée'}) }}">
<button type="submit" class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded shadow">
Refuser
</button>
</form>
</div>
{% endif %}
</div>
{% else %}
<p class="text-center text-gray-600">Aucune candidature pour le moment.</p>
{% endfor %}
</div>
{% else %}
<p>Aucune candidature pour le moment.</p>
{% endfor %}
{% endblock %}

View File

@ -8,9 +8,9 @@
<p class="text-gray-600">Téléphone : {{ app.user.tel }}</p>
<p class="text-gray-600">Email : {{ app.user.mail }}</p>
<a href="{{ path('app_employee_seeApplications') }}"
class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded">
Voir les candidatures reçues
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full"
href="{{ path('app_employee_seeApplications') }}"> Voir les candidatures reçues
</a>

View File

@ -7,18 +7,18 @@
<h2 class="text-2xl font-bold mb-4">Profil du candidat</h2>
<div class="mb-4">
<p><strong>Nom :</strong> {{ user.lastName }}</p>
<p><strong>Prénom :</strong> {{ user.firstName }}</p>
<p><strong>Email :</strong> {{ user.mail }}</p>
<p><strong>Téléphone :</strong> {{ user.tel }}</p>
<p><strong>Adresse :</strong> {{ user.address }}</p>
<p><strong>Nom :</strong> {{ candidat.lastName }}</p>
<p><strong>Prénom :</strong> {{ candidat.firstName }}</p>
<p><strong>Email :</strong> {{ candidat.mail }}</p>
<p><strong>Téléphone :</strong> {{ candidat.tel }}</p>
<p><strong>Adresse :</strong> {{ candidat.address }}</p>
</div>
<div class="mb-4">
<h3 class="text-xl font-semibold">Diplômes</h3>
<ul class="list-disc list-inside text-gray-800 mt-2">
{% if user.degrees|length > 0 %}
{% for deg in user.degrees %}
{% if candidat.degrees|length > 0 %}
{% for deg in candidat.degrees %}
<li>
{{ deg.degree.label }} — Obtenu le {{ deg.graduationDate|date('d/m/Y') }}
</li>
@ -32,9 +32,9 @@
<div class="mb-4">
<h3 class="text-xl font-semibold">Compétences</h3>
<ul class="list-disc list-inside text-gray-800 mt-2">
{% if user.skills|length > 0 %}
{% for skill in user.skills %}
<li>{{ skill.label }}</li>
{% if candidat.skills|length > 0 %}
{% for sk in candidat.skills %}
<li>{{ sk.skill.label }}</li>
{% endfor %}
{% else %}
<p class="text-gray-500 mt-2">Aucune compétence renseignée.</p>
@ -43,9 +43,9 @@
</div>
<div class="mt-6">
<a href="{{ path('app_index') }}"
<a href="{{ path('app_employee_seeApplications') }}"
class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full">
Retour à l'accueil
Retour à la liste des candidatures
</a>
</div>
</div>