jsp
This commit is contained in:
parent
88be0086ce
commit
3be6867e5e
@ -14,15 +14,20 @@ security:
|
||||
entity:
|
||||
class: App\Entity\Employee
|
||||
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)
|
||||
|
||||
firewalls:
|
||||
dev:
|
||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||
security: false
|
||||
intern:
|
||||
main:
|
||||
lazy: true
|
||||
provider: app_intern_provider
|
||||
provider: app_combined_provider
|
||||
form_login:
|
||||
login_path: app_login
|
||||
check_path: app_login
|
||||
@ -30,20 +35,6 @@ security:
|
||||
enable_csrf: true
|
||||
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
|
||||
# https://symfony.com/doc/current/security.html#the-firewall
|
||||
|
@ -14,19 +14,42 @@ use Symfony\Component\Routing\Attribute\Route;
|
||||
#[Route('/announcement')]
|
||||
final class AnnouncementController extends AbstractController
|
||||
{
|
||||
#[Route('/', name: 'app_announcement_index', methods: ['GET'])]
|
||||
public function index(Request $request, AnnouncementRepository $announcementRepository): Response
|
||||
#[Route('/', name: 'app_announcement_index')]
|
||||
public function list(Request $request, AnnouncementRepository $announcementRepository): Response
|
||||
{
|
||||
$showNonValidated = $request->query->get('show_non_validated') === '1';
|
||||
$user = $this->getUser();
|
||||
$announcements = [];
|
||||
|
||||
$announcements = $showNonValidated
|
||||
? $announcementRepository->findBy(['status' => 'notVerified'])
|
||||
: $announcementRepository->findAll();
|
||||
if (in_array('ROLE_ADMIN', $user->getRoles())) {
|
||||
$showNonValidated = $request->query->get('show_non_validated');
|
||||
|
||||
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,
|
||||
'showNonValidated' => $showNonValidated,
|
||||
'showNonValidated' => $request->query->get('show_non_validated', false),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
<div class="container mx-auto p-6">
|
||||
<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">
|
||||
@ -22,13 +23,16 @@
|
||||
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>
|
||||
{% endif %}
|
||||
|
||||
<!-- Liste des annonces -->
|
||||
<div class="max-w-4xl mx-auto">
|
||||
|
@ -52,6 +52,8 @@
|
||||
<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 }) }}"
|
||||
@ -67,6 +69,8 @@
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Bouton de retour à la liste -->
|
||||
|
Loading…
Reference in New Issue
Block a user