Sélection de compétences.
This commit is contained in:
parent
57a8eba238
commit
806044e990
@ -20,7 +20,6 @@ final class AnnouncementController extends AbstractController
|
|||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$announcements = [];
|
$announcements = [];
|
||||||
|
|
||||||
// Récupérer les paramètres de recherche
|
|
||||||
$companyName = $request->query->get('company_name');
|
$companyName = $request->query->get('company_name');
|
||||||
$location = $request->query->get('location');
|
$location = $request->query->get('location');
|
||||||
$category = $request->query->get('category');
|
$category = $request->query->get('category');
|
||||||
@ -47,18 +46,27 @@ final class AnnouncementController extends AbstractController
|
|||||||
$announcements = $announcementRepository->findBy(['status' => 'Verified']);
|
$announcements = $announcementRepository->findBy(['status' => 'Verified']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filtrer les annonces en fonction des critères de recherche
|
|
||||||
if ($companyName || $location || $category) {
|
if ($companyName || $location || $category) {
|
||||||
$announcements = $announcementRepository->searchAnnouncements($companyName, $location, $category);
|
$announcements = $announcementRepository->searchAnnouncements($companyName, $location, $category);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$favorites = [];
|
||||||
|
if (in_array('ROLE_INTERN', $user->getRoles())) {
|
||||||
|
$favorites = array_map(
|
||||||
|
fn($f) => $f->getAnnouncement()->getId(),
|
||||||
|
$user->getFavorites()->toArray()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('announcement/index.html.twig', [
|
return $this->render('announcement/index.html.twig', [
|
||||||
'announcements' => $announcements,
|
'announcements' => $announcements,
|
||||||
|
'favorites' => $favorites,
|
||||||
'showNonValidated' => $request->query->get('show_non_validated', false),
|
'showNonValidated' => $request->query->get('show_non_validated', false),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[Route('/new', name: 'app_announcement_new', methods: ['GET', 'POST'])]
|
#[Route('/new', name: 'app_announcement_new', methods: ['GET', 'POST'])]
|
||||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Entity\UserApp;
|
||||||
|
use App\Entity\Announcement;
|
||||||
use App\Repository\FavorisRepository;
|
use App\Repository\FavorisRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
@ -13,15 +15,38 @@ class Favoris
|
|||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'favoris')]
|
||||||
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
private ?UserApp $user = null;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'favoris')]
|
||||||
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
private ?Announcement $announcement = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setId(int $id): static
|
public function getUser(): ?UserApp
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
return $this->user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUser(?UserApp $user): static
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAnnouncement(): ?Announcement
|
||||||
|
{
|
||||||
|
return $this->announcement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAnnouncement(?Announcement $announcement): static
|
||||||
|
{
|
||||||
|
$this->announcement = $announcement;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,84 +7,66 @@
|
|||||||
<h1 class="text-3xl font-bold mb-6 text-center">Liste des Annonces</h1>
|
<h1 class="text-3xl font-bold mb-6 text-center">Liste des Annonces</h1>
|
||||||
|
|
||||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||||
<!-- Formulaire pour afficher uniquement les annonces non validées -->
|
<form method="get" class="mb-6 text-center">
|
||||||
<form method="get" class="mb-6 text-center">
|
<label class="flex items-center justify-center space-x-2">
|
||||||
<label class="flex items-center justify-center space-x-2">
|
<input type="checkbox" name="show_non_validated" value="1" {% if showNonValidated %}checked{% endif %} class="rounded text-teal-500">
|
||||||
<input
|
<span class="text-gray-700">Afficher uniquement les annonces non validées</span>
|
||||||
type="checkbox"
|
</label>
|
||||||
name="show_non_validated"
|
<button type="submit" class="ml-4 bg-teal-500 text-white px-4 py-2 rounded mt-2">Appliquer</button>
|
||||||
value="1"
|
</form>
|
||||||
{% if showNonValidated %}checked{% endif %}
|
|
||||||
class="rounded text-teal-500"
|
|
||||||
>
|
|
||||||
<span class="text-gray-700">Afficher uniquement les annonces non validées</span>
|
|
||||||
</label>
|
|
||||||
<button type="submit" class="ml-4 bg-teal-500 text-white px-4 py-2 rounded mt-2">
|
|
||||||
Appliquer
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if 'ROLE_EMPLOYEE' in app.user.roles %}
|
{% if 'ROLE_EMPLOYEE' in app.user.roles %}
|
||||||
<!-- Bouton pour créer une annonce -->
|
<div class="text-center mb-6">
|
||||||
<div class="text-center mb-6">
|
<a href="{{ path('app_announcement_new') }}" class="bg-teal-500 text-white px-6 py-3 rounded-md hover:bg-teal-600">
|
||||||
<a href="{{ path('app_announcement_new') }}" class="bg-teal-500 text-white px-6 py-3 rounded-md hover:bg-teal-600">
|
Créer une annonce
|
||||||
Créer une annonce
|
</a>
|
||||||
</a>
|
</div>
|
||||||
</div>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- Liste des annonces -->
|
|
||||||
<div class="max-w-4xl mx-auto">
|
<div class="max-w-4xl mx-auto">
|
||||||
<div class="bg-white rounded-lg shadow-lg p-6 inline-block text-center my-10">
|
<div class="bg-white rounded-lg shadow-lg p-6 inline-block text-center my-10">
|
||||||
<form method="get" class="flex flex-col md:flex-row space-y-4 md:space-y-0 md:space-x-4 text-black">
|
<form method="get" 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="Rechercher par entreprise" type="text" name="company_name" value="{{ app.request.query.get('company_name') }}"/>
|
||||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Rechercher par entreprise" type="text" name="company_name" value="{{ app.request.query.get('company_name') }}"/>
|
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Rechercher par lieu" type="text" name="location" value="{{ app.request.query.get('location') }}"/>
|
||||||
</label>
|
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Autre recherche" type="text" name="category" value="{{ app.request.query.get('category') }}"/>
|
||||||
<label>
|
|
||||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Rechercher par lieu" type="text" name="location" value="{{ app.request.query.get('location') }}"/>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input class="border border-gray-300 rounded py-2 px-4 w-full md:w-auto" placeholder="Autre recherche" type="text" name="category" value="{{ app.request.query.get('category') }}"/>
|
|
||||||
</label>
|
|
||||||
<button type="submit" class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-6 rounded">Rechercher</button>
|
<button type="submit" class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-6 rounded">Rechercher</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% for announcement in announcements %}
|
{% for announcement in announcements %}
|
||||||
<div class="bg-white p-6 rounded-lg shadow mb-4 relative">
|
<div class="bg-white p-6 rounded-lg shadow mb-4 relative">
|
||||||
<!-- Statut en haut à droite -->
|
<div class="absolute top-4 right-4 flex items-center space-x-2">
|
||||||
<div class="absolute top-4 right-4">
|
|
||||||
{% if announcement.status == 'notVerified' %}
|
{% if announcement.status == 'notVerified' %}
|
||||||
<span class="text-red-500 font-semibold">Non validée</span>
|
<span class="text-red-500 font-semibold">Non validée</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="text-green-500 font-semibold">Validée</span>
|
<span class="text-green-500 font-semibold">Validée</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
||||||
|
<button type="submit" class="text-xl">
|
||||||
|
{% if announcement.id in favorites %}
|
||||||
|
⭐
|
||||||
|
{% else %}
|
||||||
|
☆
|
||||||
|
{% endif %}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Titre de l'annonce -->
|
|
||||||
<h2 class="text-3xl font-semibold mb-2">{{ announcement.title }}</h2>
|
<h2 class="text-3xl font-semibold mb-2">{{ announcement.title }}</h2>
|
||||||
|
|
||||||
<!-- Nom de l'entreprise -->
|
|
||||||
<p class="text-gray-600 mb-2">{{ announcement.company.name }}</p>
|
<p class="text-gray-600 mb-2">{{ announcement.company.name }}</p>
|
||||||
|
|
||||||
<div class="text-gray-500 text-sm mb-4">
|
<div class="text-gray-500 text-sm mb-4">
|
||||||
<!-- Date du stage -->
|
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<i class="fas fa-calendar-alt mr-1"></i>
|
<i class="fas fa-calendar-alt mr-1"></i> <span>Date du stage : {{ announcement.date }}</span>
|
||||||
<span>Date du stage : {{ announcement.date }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Adresse de l'entreprise -->
|
|
||||||
<div>
|
<div>
|
||||||
<i class="fas fa-map-marker-alt mr-1"></i>
|
<i class="fas fa-map-marker-alt mr-1"></i> <span>{{ announcement.company.address }}</span>
|
||||||
<span>{{ announcement.company.address }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Lien vers la page de détails -->
|
<a href="{{ path('app_announcement_show', { id: announcement.id }) }}" class="bg-teal-500 text-white px-4 py-2 rounded">
|
||||||
<a href="{{ path('app_announcement_show', { id: announcement.id }) }}"
|
|
||||||
class="bg-teal-500 text-white px-4 py-2 rounded">
|
|
||||||
Détails
|
Détails
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -94,4 +76,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -52,25 +52,16 @@
|
|||||||
<span>{{ announcement.creationDate | date('d/m/Y') }}</span>
|
<span>{{ announcement.creationDate | date('d/m/Y') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
<!-- Vérifier si c'est un favori -->
|
||||||
|
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
||||||
<!-- Boutons Modifier et Valider -->
|
<button type="submit" class="text-yellow-500">
|
||||||
<div class="mt-4 flex space-x-4">
|
{% if isFavorite %}
|
||||||
<a href="{{ path('app_announcement_edit', { id: announcement.id }) }}"
|
⭐ Retirer des favoris
|
||||||
class="bg-teal-500 text-white px-4 py-2 rounded hover:bg-teal-600">
|
{% else %}
|
||||||
Modifier l'annonce
|
☆ Ajouter aux favoris
|
||||||
</a>
|
{% endif %}
|
||||||
|
</button>
|
||||||
{% if announcement.status == 'notVerified' %}
|
</form>
|
||||||
<form method="post" action="{{ path('app_announcement_validate', { id: announcement.id }) }}">
|
|
||||||
<button type="submit" class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600">
|
|
||||||
Valider l'annonce
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Bouton de retour à la liste -->
|
<!-- Bouton de retour à la liste -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user