Display all organization for super Admin

This commit is contained in:
Charles 2025-08-29 11:02:19 +02:00
parent 5a7be977ba
commit 8d095a368f
3 changed files with 40 additions and 23 deletions

View File

@ -10,6 +10,7 @@ use App\Form\OrganizationForm;
use App\Service\ActionService; use App\Service\ActionService;
use App\Service\OrganizationsService; use App\Service\OrganizationsService;
use App\Service\UserOrganizationService; use App\Service\UserOrganizationService;
use App\Service\UserService;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -26,9 +27,25 @@ class OrganizationController extends AbstractController
public function __construct(private readonly EntityManagerInterface $entityManager, public function __construct(private readonly EntityManagerInterface $entityManager,
private readonly OrganizationsService $organizationsService, private readonly OrganizationsService $organizationsService,
private readonly UserOrganizationService $usersOrganizationService, private readonly ActionService $actionService) private readonly UserOrganizationService $usersOrganizationService, private readonly ActionService $actionService, private readonly UserService $userService)
{ {
} }
#[Route(path: '/', name: 'index', methods: ['GET'])]
public function index(): Response
{
$this->denyAccessUnlessGranted('ROLE_ADMIN');
$user = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier());
if ($this->isGranted("ROLE_SUPER_ADMIN")){
$organizations = $this->entityManager->getRepository(Organizations::class)->findAll();
} else {
$organizations = $this->organizationsService->getOrganizationsByUser($user);
}
return $this->render('organization/index.html.twig', [
'organizations' => $organizations,
]);
}
} }

View File

@ -37,23 +37,23 @@
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
{# {% if is_granted('ROLE_SUPER_ADMIN') %}#} {% if is_granted('ROLE_SUPER_ADMIN') %}
{# <a class="nav-link" href="{{ path('organization_index') }}">#} <a class="nav-link" href="{{ path('organization_index') }}">
{# <i class="icon-grid menu-icon"> {{ ux_icon('bi:buildings', {height: '15px', width: '15px'}) }}#} <i class="icon-grid menu-icon"> {{ ux_icon('bi:buildings', {height: '15px', width: '15px'}) }}
{# </i>#} </i>
{# <span class="menu-title">#} <span class="menu-title">
{# Organizations</span>#} Organizations</span>
{# </a>#} </a>
{# {% elseif is_granted('ROLE_ADMIN') %}#} {% elseif is_granted('ROLE_ADMIN') %}
{# <a class="nav-link" href="{{ path('organization_index') }}">#} <a class="nav-link" href="{{ path('organization_index') }}">
{# <i class="icon-grid menu-icon">#} <i class="icon-grid menu-icon">
{# {{ ux_icon('bi:building', {height: '15px', width: '15px'}) }}#} {{ ux_icon('bi:building', {height: '15px', width: '15px'}) }}
{# </i>#} </i>
{# <span class="menu-title">#} <span class="menu-title">
{# Organization#} Organization
{# </span>#} </span>
{# </a>#} </a>
{# {% endif %}#} {% endif %}
</li> </li>
{% endif %} {% endif %}
</ul> </ul>

View File

@ -7,14 +7,14 @@
<div class="d-flex justify-content-between align-items-center mb-4"> <div class="d-flex justify-content-between align-items-center mb-4">
<h1>Gestion des organisations</h1> <h1>Gestion des organisations</h1>
{% if is_granted("ROLE_SUPER_ADMIN") %} {% if is_granted("ROLE_SUPER_ADMIN") %}
<a href="{{ path('organization_new') }}" class="btn btn-primary">Ajouter une organisation</a> {# <a href="{{ path('organization_new') }}" class="btn btn-primary">Ajouter une organisation</a>#}
{% endif %} {% endif %}
</div> </div>
{% if organizations|length == 0 %} {% if organizations|length == 0 %}
<tr> <tr>
<td colspan="4" class="text-center">Aucune organisation trouvée.</td> <td colspan="4" class="text-center">Aucune organisation trouvée.</td>
<td colspan="4" class="text-center"> <td colspan="4" class="text-center">
<a href="{{ path('organization_new') }}" class="btn btn-primary">Créer une organisation</a> {# <a href="{{ path('organization_new') }}" class="btn btn-primary">Créer une organisation</a>#}
</td> </td>
</tr> </tr>
{% else %} {% else %}
@ -38,9 +38,9 @@
<td>{{ organization.name }}</td> <td>{{ organization.name }}</td>
<td>{{ organization.email }}</td> <td>{{ organization.email }}</td>
<td> <td>
<a href="{{ path('organization_show', {'id': organization.id}) }}" class="p-3 align-middle color-primary"> {# <a href="{{ path('organization_show', {'id': organization.id}) }}" class="p-3 align-middle color-primary">#}
{{ ux_icon('fa6-regular:eye', {height: '30px', width: '30px'}) }} {# {{ ux_icon('fa6-regular:eye', {height: '30px', width: '30px'}) }}#}
</a> {# </a>#}
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}