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;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\Announcement;
|
use App\Entity\Announcement;
|
||||||
|
use App\Entity\Intern;
|
||||||
use App\Form\AnnouncementType;
|
use App\Form\AnnouncementType;
|
||||||
use App\Repository\AnnouncementRepository;
|
use App\Repository\AnnouncementRepository;
|
||||||
use App\Repository\InternApplicationRepository;
|
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())) {
|
if (in_array('ROLE_EMPLOYEE', $user->getRoles())) {
|
||||||
$company = $user->getCompany();
|
$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) {
|
if ($companyName || $location || $category) {
|
||||||
$announcements = $this->announcementRepository->searchAnnouncements($companyName, $location, $category);
|
$announcements = $this->announcementRepository->searchAnnouncements($companyName, $location, $category);
|
||||||
}
|
}
|
||||||
@ -68,6 +78,7 @@ final class AnnouncementController extends AbstractController
|
|||||||
'announcements' => $announcements,
|
'announcements' => $announcements,
|
||||||
'favorites' => $favorites,
|
'favorites' => $favorites,
|
||||||
'showNonValidated' => $request->query->get('show_non_validated', false),
|
'showNonValidated' => $request->query->get('show_non_validated', false),
|
||||||
|
'showFavorites' => $request->query->get('show_favorites', false)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\Announcement;
|
use App\Entity\Announcement;
|
||||||
|
use App\Entity\Intern;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
@ -38,28 +39,13 @@ class AnnouncementRepository extends ServiceEntityRepository
|
|||||||
return $queryBuilder->getQuery()->getResult();
|
return $queryBuilder->getQuery()->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
public function findFavoritesByIntern(Intern $intern): array
|
||||||
// * @return Announcement[] Returns an array of Announcement objects
|
{
|
||||||
// */
|
return $this->createQueryBuilder('a')
|
||||||
// public function findByExampleField($value): array
|
->innerJoin('a.favoritesInterns', 'fav')
|
||||||
// {
|
->andWhere('fav.intern = :intern')
|
||||||
// return $this->createQueryBuilder('a')
|
->setParameter('intern', $intern)
|
||||||
// ->andWhere('a.exampleField = :val')
|
->getQuery()
|
||||||
// ->setParameter('val', $value)
|
->getResult();
|
||||||
// ->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()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,17 @@
|
|||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% 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 %}
|
{% if 'ROLE_EMPLOYEE' in app.user.roles %}
|
||||||
<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">
|
||||||
@ -43,6 +54,7 @@
|
|||||||
<span class="text-green-500 font-semibold">Validée</span>
|
<span class="text-green-500 font-semibold">Validée</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||||
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
||||||
<button type="submit" class="text-xl">
|
<button type="submit" class="text-xl">
|
||||||
{% if announcement.id in favorites %}
|
{% if announcement.id in favorites %}
|
||||||
@ -52,6 +64,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2 class="text-3xl font-semibold mb-2">{{ announcement.title }}</h2>
|
<h2 class="text-3xl font-semibold mb-2">{{ announcement.title }}</h2>
|
||||||
|
@ -80,6 +80,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if 'ROLE_INTERN' in app.user.roles %}
|
||||||
<!-- Vérifier si c'est un favori -->
|
<!-- Vérifier si c'est un favori -->
|
||||||
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
||||||
<button type="submit" class="text-yellow-500">
|
<button type="submit" class="text-yellow-500">
|
||||||
@ -90,6 +92,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Bouton de retour à la liste -->
|
<!-- Bouton de retour à la liste -->
|
||||||
|
@ -16,10 +16,12 @@
|
|||||||
<hr class="border-black"/>
|
<hr class="border-black"/>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||||
<div class="mt-4">
|
<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">
|
<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>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<p class="text-gray-600">Prénom : {{ app.user.lastName }}</p>
|
<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">Adresse : {{ app.user.address }}</p>
|
||||||
<p class="text-gray-600">Téléphone : {{ app.user.tel }}</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"
|
<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
|
href="{{ path('app_skill_index',{id: app.user.id}) }}"> Sélectionner vos compétences
|
||||||
</a>
|
</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>
|
<h3 class="text-lg font-semibold mt-6">Vos candidatures :</h3>
|
||||||
|
|
||||||
{% if applications|length > 0 %}
|
{% if applications|length > 0 %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user