jsp
This commit is contained in:
parent
88be0086ce
commit
3be6867e5e
@ -14,15 +14,20 @@ security:
|
|||||||
entity:
|
entity:
|
||||||
class: App\Entity\Employee
|
class: App\Entity\Employee
|
||||||
property: nickname
|
property: nickname
|
||||||
|
|
||||||
|
app_combined_provider:
|
||||||
|
chain:
|
||||||
|
providers: [app_intern_provider, app_employee_provider]
|
||||||
# used to reload user from session & other features (e.g. switch_user)
|
# used to reload user from session & other features (e.g. switch_user)
|
||||||
# used to reload user from session & other features (e.g. switch_user)
|
# used to reload user from session & other features (e.g. switch_user)
|
||||||
|
|
||||||
firewalls:
|
firewalls:
|
||||||
dev:
|
dev:
|
||||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||||
security: false
|
security: false
|
||||||
intern:
|
main:
|
||||||
lazy: true
|
lazy: true
|
||||||
provider: app_intern_provider
|
provider: app_combined_provider
|
||||||
form_login:
|
form_login:
|
||||||
login_path: app_login
|
login_path: app_login
|
||||||
check_path: app_login
|
check_path: app_login
|
||||||
@ -30,20 +35,6 @@ security:
|
|||||||
enable_csrf: true
|
enable_csrf: true
|
||||||
logout:
|
logout:
|
||||||
path: app_logout
|
path: app_logout
|
||||||
# where to redirect after logout
|
|
||||||
# target: app_any_route
|
|
||||||
employee:
|
|
||||||
lazy: true
|
|
||||||
provider: app_employee_provider
|
|
||||||
form_login:
|
|
||||||
login_path: app_login
|
|
||||||
check_path: app_login
|
|
||||||
default_target_path: app_index
|
|
||||||
enable_csrf: true
|
|
||||||
logout:
|
|
||||||
path: app_logout
|
|
||||||
# where to redirect after logout
|
|
||||||
# target: app_any_route
|
|
||||||
|
|
||||||
# activate different ways to authenticate
|
# activate different ways to authenticate
|
||||||
# https://symfony.com/doc/current/security.html#the-firewall
|
# https://symfony.com/doc/current/security.html#the-firewall
|
||||||
|
@ -14,19 +14,42 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||||||
#[Route('/announcement')]
|
#[Route('/announcement')]
|
||||||
final class AnnouncementController extends AbstractController
|
final class AnnouncementController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/', name: 'app_announcement_index', methods: ['GET'])]
|
#[Route('/', name: 'app_announcement_index')]
|
||||||
public function index(Request $request, AnnouncementRepository $announcementRepository): Response
|
public function list(Request $request, AnnouncementRepository $announcementRepository): Response
|
||||||
{
|
{
|
||||||
$showNonValidated = $request->query->get('show_non_validated') === '1';
|
$user = $this->getUser();
|
||||||
|
$announcements = [];
|
||||||
|
|
||||||
$announcements = $showNonValidated
|
if (in_array('ROLE_ADMIN', $user->getRoles())) {
|
||||||
? $announcementRepository->findBy(['status' => 'notVerified'])
|
$showNonValidated = $request->query->get('show_non_validated');
|
||||||
: $announcementRepository->findAll();
|
|
||||||
|
|
||||||
|
if ($showNonValidated) {
|
||||||
|
$announcements = $announcementRepository->findBy(['status' => 'notVerified']);
|
||||||
|
}
|
||||||
|
if (!$showNonValidated){
|
||||||
|
$announcements = $announcementRepository->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('announcement/index.html.twig', [
|
}
|
||||||
|
|
||||||
|
if (in_array('ROLE_EMPLOYEE', $user->getRoles())) {
|
||||||
|
$company = $user->getCompany();
|
||||||
|
|
||||||
|
if ($company)
|
||||||
|
{
|
||||||
|
$announcements = $announcementRepository->findBy(['company' => $company]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('ROLE_INTERN', $user->getRoles()))
|
||||||
|
{
|
||||||
|
$announcements = $announcementRepository->findBy(['status' => 'verified']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rendre la vue avec les annonces
|
||||||
|
return $this->render('announcement/list.html.twig', [
|
||||||
'announcements' => $announcements,
|
'announcements' => $announcements,
|
||||||
'showNonValidated' => $showNonValidated,
|
'showNonValidated' => $request->query->get('show_non_validated', false),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<div class="container mx-auto p-6">
|
<div class="container mx-auto p-6">
|
||||||
<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 %}
|
||||||
<!-- Formulaire pour afficher uniquement les annonces non validées -->
|
<!-- 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">
|
||||||
@ -22,13 +23,16 @@
|
|||||||
Appliquer
|
Appliquer
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if 'ROLE_EMPLOYEE' in app.user.roles %}
|
||||||
<!-- Bouton pour créer une annonce -->
|
<!-- 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 %}
|
||||||
|
|
||||||
<!-- Liste des annonces -->
|
<!-- Liste des annonces -->
|
||||||
<div class="max-w-4xl mx-auto">
|
<div class="max-w-4xl mx-auto">
|
||||||
|
@ -52,6 +52,8 @@
|
|||||||
<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 %}
|
||||||
|
|
||||||
<!-- Boutons Modifier et Valider -->
|
<!-- Boutons Modifier et Valider -->
|
||||||
<div class="mt-4 flex space-x-4">
|
<div class="mt-4 flex space-x-4">
|
||||||
<a href="{{ path('app_announcement_edit', { id: announcement.id }) }}"
|
<a href="{{ path('app_announcement_edit', { id: announcement.id }) }}"
|
||||||
@ -67,6 +69,8 @@
|
|||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Bouton de retour à la liste -->
|
<!-- Bouton de retour à la liste -->
|
||||||
|
Loading…
Reference in New Issue
Block a user