Display all organization for super Admin
This commit is contained in:
parent
5a7be977ba
commit
8d095a368f
|
|
@ -10,6 +10,7 @@ use App\Form\OrganizationForm;
|
|||
use App\Service\ActionService;
|
||||
use App\Service\OrganizationsService;
|
||||
use App\Service\UserOrganizationService;
|
||||
use App\Service\UserService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
@ -26,9 +27,25 @@ class OrganizationController extends AbstractController
|
|||
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager,
|
||||
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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,23 +37,23 @@
|
|||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
{# {% if is_granted('ROLE_SUPER_ADMIN') %}#}
|
||||
{# <a class="nav-link" href="{{ path('organization_index') }}">#}
|
||||
{# <i class="icon-grid menu-icon"> {{ ux_icon('bi:buildings', {height: '15px', width: '15px'}) }}#}
|
||||
{# </i>#}
|
||||
{# <span class="menu-title">#}
|
||||
{# Organizations</span>#}
|
||||
{# </a>#}
|
||||
{# {% elseif is_granted('ROLE_ADMIN') %}#}
|
||||
{# <a class="nav-link" href="{{ path('organization_index') }}">#}
|
||||
{# <i class="icon-grid menu-icon">#}
|
||||
{# {{ ux_icon('bi:building', {height: '15px', width: '15px'}) }}#}
|
||||
{# </i>#}
|
||||
{# <span class="menu-title">#}
|
||||
{# Organization#}
|
||||
{# </span>#}
|
||||
{# </a>#}
|
||||
{# {% endif %}#}
|
||||
{% if is_granted('ROLE_SUPER_ADMIN') %}
|
||||
<a class="nav-link" href="{{ path('organization_index') }}">
|
||||
<i class="icon-grid menu-icon"> {{ ux_icon('bi:buildings', {height: '15px', width: '15px'}) }}
|
||||
</i>
|
||||
<span class="menu-title">
|
||||
Organizations</span>
|
||||
</a>
|
||||
{% elseif is_granted('ROLE_ADMIN') %}
|
||||
<a class="nav-link" href="{{ path('organization_index') }}">
|
||||
<i class="icon-grid menu-icon">
|
||||
{{ ux_icon('bi:building', {height: '15px', width: '15px'}) }}
|
||||
</i>
|
||||
<span class="menu-title">
|
||||
Organization
|
||||
</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@
|
|||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>Gestion des organisations</h1>
|
||||
{% 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 %}
|
||||
</div>
|
||||
{% if organizations|length == 0 %}
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">Aucune organisation trouvée.</td>
|
||||
<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>
|
||||
</tr>
|
||||
{% else %}
|
||||
|
|
@ -38,9 +38,9 @@
|
|||
<td>{{ organization.name }}</td>
|
||||
<td>{{ organization.email }}</td>
|
||||
<td>
|
||||
<a href="{{ path('organization_show', {'id': organization.id}) }}" class="p-3 align-middle color-primary">
|
||||
{{ ux_icon('fa6-regular:eye', {height: '30px', width: '30px'}) }}
|
||||
</a>
|
||||
{# <a href="{{ path('organization_show', {'id': organization.id}) }}" class="p-3 align-middle color-primary">#}
|
||||
{# {{ ux_icon('fa6-regular:eye', {height: '30px', width: '30px'}) }}#}
|
||||
{# </a>#}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue