Display all organization for Admin
This commit is contained in:
parent
8d095a368f
commit
e33b0b8248
|
|
@ -5,6 +5,7 @@ namespace App\Controller;
|
||||||
use App\Entity\Apps;
|
use App\Entity\Apps;
|
||||||
use App\Entity\Roles;
|
use App\Entity\Roles;
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
|
use App\Entity\UserOrganizatonApp;
|
||||||
use App\Entity\UsersOrganizations;
|
use App\Entity\UsersOrganizations;
|
||||||
use App\Form\OrganizationForm;
|
use App\Form\OrganizationForm;
|
||||||
use App\Service\ActionService;
|
use App\Service\ActionService;
|
||||||
|
|
@ -26,8 +27,7 @@ class OrganizationController extends AbstractController
|
||||||
private const ACCESS_DENIED = 'Access denied';
|
private const ACCESS_DENIED = 'Access denied';
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager,
|
public function __construct(private readonly EntityManagerInterface $entityManager,
|
||||||
private readonly OrganizationsService $organizationsService,
|
private readonly UserService $userService)
|
||||||
private readonly UserOrganizationService $usersOrganizationService, private readonly ActionService $actionService, private readonly UserService $userService)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,7 +39,17 @@ class OrganizationController extends AbstractController
|
||||||
if ($this->isGranted("ROLE_SUPER_ADMIN")){
|
if ($this->isGranted("ROLE_SUPER_ADMIN")){
|
||||||
$organizations = $this->entityManager->getRepository(Organizations::class)->findAll();
|
$organizations = $this->entityManager->getRepository(Organizations::class)->findAll();
|
||||||
} else {
|
} 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', [
|
return $this->render('organization/index.html.twig', [
|
||||||
|
|
|
||||||
|
|
@ -37,22 +37,13 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
{% if is_granted('ROLE_SUPER_ADMIN') %}
|
{% if 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"> {{ 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') %}
|
|
||||||
<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 %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue