réparation du projet et ajout de l affichage des favoris
This commit is contained in:
parent
f7964bf9d7
commit
e0960c3404
@ -3,6 +3,7 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Announcement;
|
||||
use App\Entity\Intern;
|
||||
use App\Form\AnnouncementType;
|
||||
use App\Repository\AnnouncementRepository;
|
||||
use App\Repository\InternApplicationRepository;
|
||||
@ -40,6 +41,19 @@ final class AnnouncementController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('ROLE_INTERN', $user->getRoles())) {
|
||||
$showFavorites = $request->query->get('show_favorites');
|
||||
|
||||
/** @var Intern $intern */
|
||||
$intern = $user;
|
||||
|
||||
if ($showFavorites) {
|
||||
$announcements = $this->announcementRepository->findFavoritesByIntern($intern);
|
||||
} else {
|
||||
$announcements = $this->announcementRepository->findBy(['status' => 'Verified']);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('ROLE_EMPLOYEE', $user->getRoles())) {
|
||||
$company = $user->getCompany();
|
||||
|
||||
@ -48,10 +62,6 @@ final class AnnouncementController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('ROLE_INTERN', $user->getRoles())) {
|
||||
$announcements = $this->announcementRepository->findBy(['status' => 'Verified']);
|
||||
}
|
||||
|
||||
if ($companyName || $location || $category) {
|
||||
$announcements = $this->announcementRepository->searchAnnouncements($companyName, $location, $category);
|
||||
}
|
||||
@ -68,6 +78,7 @@ final class AnnouncementController extends AbstractController
|
||||
'announcements' => $announcements,
|
||||
'favorites' => $favorites,
|
||||
'showNonValidated' => $request->query->get('show_non_validated', false),
|
||||
'showFavorites' => $request->query->get('show_favorites', false)
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Announcement;
|
||||
use App\Entity\Intern;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
@ -38,28 +39,13 @@ class AnnouncementRepository extends ServiceEntityRepository
|
||||
return $queryBuilder->getQuery()->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Announcement[] Returns an array of Announcement objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('a')
|
||||
// ->andWhere('a.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('a.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Announcement
|
||||
// {
|
||||
// return $this->createQueryBuilder('a')
|
||||
// ->andWhere('a.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
public function findFavoritesByIntern(Intern $intern): array
|
||||
{
|
||||
return $this->createQueryBuilder('a')
|
||||
->innerJoin('a.favoritesInterns', 'fav')
|
||||
->andWhere('fav.intern = :intern')
|
||||
->setParameter('intern', $intern)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,17 @@
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||
<form method="get" class="mb-6 text-center space-y-2">
|
||||
<label class="flex items-center justify-center space-x-2">
|
||||
<input type="checkbox" name="show_favorites" value="1" {% if showFavorites %}checked{% endif %} class="rounded text-teal-500">
|
||||
<span class="text-gray-700">Afficher uniquement les annonces en favoris</span>
|
||||
</label>
|
||||
<button type="submit" class="ml-4 bg-teal-500 text-white px-4 py-2 rounded">Appliquer</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if 'ROLE_EMPLOYEE' in app.user.roles %}
|
||||
<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">
|
||||
@ -43,6 +54,7 @@
|
||||
<span class="text-green-500 font-semibold">Validée</span>
|
||||
{% endif %}
|
||||
|
||||
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
||||
<button type="submit" class="text-xl">
|
||||
{% if announcement.id in favorites %}
|
||||
@ -52,6 +64,7 @@
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<h2 class="text-3xl font-semibold mb-2">{{ announcement.title }}</h2>
|
||||
|
@ -80,6 +80,8 @@
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if 'ROLE_INTERN' 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}) }}">
|
||||
<button type="submit" class="text-yellow-500">
|
||||
@ -90,6 +92,7 @@
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Bouton de retour à la liste -->
|
||||
|
@ -16,10 +16,12 @@
|
||||
<hr class="border-black"/>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||
<div class="mt-4">
|
||||
<a href="{{ path('app_faq_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 une FAQ / Poser une question
|
||||
<i class="fas fa-plus-circle"></i> Ajouter une Question / Reponse
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<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>
|
||||
<p class="text-gray-600 mb-4">Email : {{ app.user.mail }}</p>
|
||||
|
||||
|
||||
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full"
|
||||
|
@ -59,13 +59,6 @@
|
||||
href="{{ path('app_skill_index',{id: app.user.id}) }}"> Sélectionner vos compétences
|
||||
</a>
|
||||
|
||||
|
||||
<div class="flex justify-center mt-6">
|
||||
<a class="bg-teal-500 hover:bg-teal-600 text-white py-2 px-4 rounded-full"
|
||||
href="{{ path('app_announcement_show',{id: app.user.id}) }}"> Accéder aux favoris
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<h3 class="text-lg font-semibold mt-6">Vos candidatures :</h3>
|
||||
|
||||
{% if applications|length > 0 %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user