Display all organization for Admin

This commit is contained in:
Charles 2025-08-29 12:09:21 +02:00
parent 8d095a368f
commit e33b0b8248
2 changed files with 14 additions and 13 deletions

View File

@ -5,6 +5,7 @@ namespace App\Controller;
use App\Entity\Apps;
use App\Entity\Roles;
use App\Entity\User;
use App\Entity\UserOrganizatonApp;
use App\Entity\UsersOrganizations;
use App\Form\OrganizationForm;
use App\Service\ActionService;
@ -26,8 +27,7 @@ class OrganizationController extends AbstractController
private const ACCESS_DENIED = 'Access denied';
public function __construct(private readonly EntityManagerInterface $entityManager,
private readonly OrganizationsService $organizationsService,
private readonly UserOrganizationService $usersOrganizationService, private readonly ActionService $actionService, private readonly UserService $userService)
private readonly UserService $userService)
{
}
@ -39,7 +39,17 @@ class OrganizationController extends AbstractController
if ($this->isGranted("ROLE_SUPER_ADMIN")){
$organizations = $this->entityManager->getRepository(Organizations::class)->findAll();
} else {
$organizations = $this->organizationsService->getOrganizationsByUser($user);
//get all the UO
$uos = $this->entityManager->getRepository(UsersOrganizations::class)->findBy(['users' => $user]);
$organizations = [];
foreach ($uos as $uo) {
$roleAdmin = $this->entityManager->getRepository(Roles::class)->findOneBy(['name' => 'ADMIN']);
$uoaAdmin = $this->entityManager->getRepository(UserOrganizatonApp::class)->findOneBy(['userOrganization' => $uo, 'role' => $roleAdmin]);
if ($uoaAdmin) {
$organizations[] = $uo->getOrganization();
}
}
}
return $this->render('organization/index.html.twig', [

View File

@ -37,22 +37,13 @@
</a>
</li>
<li class="nav-item">
{% if is_granted('ROLE_SUPER_ADMIN') %}
{% if is_granted('ROLE_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 %}