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();
|
||||
$announcements = [];
|
||||
|
||||
// Récupérer les paramètres de recherche
|
||||
$companyName = $request->query->get('company_name');
|
||||
$location = $request->query->get('location');
|
||||
$category = $request->query->get('category');
|
||||
@ -47,18 +46,27 @@ final class AnnouncementController extends AbstractController
|
||||
$announcements = $announcementRepository->findBy(['status' => 'Verified']);
|
||||
}
|
||||
|
||||
// Filtrer les annonces en fonction des critères de recherche
|
||||
if ($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', [
|
||||
'announcements' => $announcements,
|
||||
'favorites' => $favorites,
|
||||
'showNonValidated' => $request->query->get('show_non_validated', false),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[Route('/new', name: 'app_announcement_new', methods: ['GET', 'POST'])]
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Entity\UserApp;
|
||||
use App\Entity\Announcement;
|
||||
use App\Repository\FavorisRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
@ -13,15 +15,38 @@ class Favoris
|
||||
#[ORM\Column]
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -7,84 +7,66 @@
|
||||
<h1 class="text-3xl font-bold mb-6 text-center">Liste des Annonces</h1>
|
||||
|
||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||
<!-- Formulaire pour afficher uniquement les annonces non validées -->
|
||||
<form method="get" class="mb-6 text-center">
|
||||
<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"
|
||||
>
|
||||
<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>
|
||||
<form method="get" class="mb-6 text-center">
|
||||
<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">
|
||||
<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 %}
|
||||
|
||||
{% if 'ROLE_EMPLOYEE' in app.user.roles %}
|
||||
<!-- Bouton pour créer une annonce -->
|
||||
<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">
|
||||
Créer une annonce
|
||||
</a>
|
||||
</div>
|
||||
<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">
|
||||
Créer une annonce
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Liste des annonces -->
|
||||
<div class="max-w-4xl mx-auto">
|
||||
<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">
|
||||
<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') }}"/>
|
||||
</label>
|
||||
<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>
|
||||
<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') }}"/>
|
||||
<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') }}"/>
|
||||
<button type="submit" class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-6 rounded">Rechercher</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% for announcement in announcements %}
|
||||
<div class="bg-white p-6 rounded-lg shadow mb-4 relative">
|
||||
<!-- Statut en haut à droite -->
|
||||
<div class="absolute top-4 right-4">
|
||||
<div class="absolute top-4 right-4 flex items-center space-x-2">
|
||||
{% if announcement.status == 'notVerified' %}
|
||||
<span class="text-red-500 font-semibold">Non validée</span>
|
||||
{% else %}
|
||||
<span class="text-green-500 font-semibold">Validée</span>
|
||||
{% 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>
|
||||
|
||||
<!-- Titre de l'annonce -->
|
||||
<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>
|
||||
|
||||
<div class="text-gray-500 text-sm mb-4">
|
||||
<!-- Date du stage -->
|
||||
<div class="mb-2">
|
||||
<i class="fas fa-calendar-alt mr-1"></i>
|
||||
<span>Date du stage : {{ announcement.date }}</span>
|
||||
<i class="fas fa-calendar-alt mr-1"></i> <span>Date du stage : {{ announcement.date }}</span>
|
||||
</div>
|
||||
|
||||
<!-- Adresse de l'entreprise -->
|
||||
<div>
|
||||
<i class="fas fa-map-marker-alt mr-1"></i>
|
||||
<span>{{ announcement.company.address }}</span>
|
||||
<i class="fas fa-map-marker-alt mr-1"></i> <span>{{ announcement.company.address }}</span>
|
||||
</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
|
||||
</a>
|
||||
</div>
|
||||
@ -94,4 +76,3 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -52,25 +52,16 @@
|
||||
<span>{{ announcement.creationDate | date('d/m/Y') }}</span>
|
||||
</div>
|
||||
|
||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||
|
||||
<!-- Boutons Modifier et Valider -->
|
||||
<div class="mt-4 flex space-x-4">
|
||||
<a href="{{ path('app_announcement_edit', { id: announcement.id }) }}"
|
||||
class="bg-teal-500 text-white px-4 py-2 rounded hover:bg-teal-600">
|
||||
Modifier l'annonce
|
||||
</a>
|
||||
|
||||
{% if announcement.status == 'notVerified' %}
|
||||
<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 %}
|
||||
<!-- Vérifier si c'est un favori -->
|
||||
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-yellow-500">
|
||||
{% if isFavorite %}
|
||||
⭐ Retirer des favoris
|
||||
{% else %}
|
||||
☆ Ajouter aux favoris
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Bouton de retour à la liste -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user