activate/deactivate organizations
This commit is contained in:
parent
1008d636a6
commit
5e52386233
|
|
@ -128,4 +128,8 @@ body {
|
|||
background: var(--secondary-dark);
|
||||
color : #FFFFFF;
|
||||
border: var(--secondary);
|
||||
}
|
||||
|
||||
.btn-warning{
|
||||
border-radius: 1rem;
|
||||
}
|
||||
|
|
@ -177,6 +177,8 @@ class OrganizationController extends AbstractController
|
|||
|
||||
$actions = $this->entityManager->getRepository(Actions::class)->findBy(['Organization' => $organization]);
|
||||
$activities = $this->actionService->formatActivities($actions);
|
||||
|
||||
$this->actionService->createAction("View Organization", $actingUser, $organization, $organization->getName());
|
||||
return $this->render('organization/show.html.twig', [
|
||||
'organization' => $organization,
|
||||
'newUsers' => $newUsers,
|
||||
|
|
@ -206,5 +208,34 @@ class OrganizationController extends AbstractController
|
|||
return $this->redirectToRoute('organization_index');
|
||||
}
|
||||
|
||||
#[Route(path: '/deactivate/{id}', name: 'deactivate', methods: ['POST'])]
|
||||
public function deactivate($id){
|
||||
$this->denyAccessUnlessGranted("ROLE_SUPER_ADMIN");
|
||||
$actingUser = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier());
|
||||
$organization = $this->entityManager->getRepository(Organizations::class)->find($id);
|
||||
if (!$organization) {
|
||||
throw $this->createNotFoundException(self::NOT_FOUND);
|
||||
}
|
||||
$organization->setIsActive(false);
|
||||
$this->userOrganizationService->deactivateAllUserOrganizationLinks($actingUser, null, $organization);
|
||||
$this->entityManager->persist($organization);
|
||||
$this->actionService->createAction("Deactivate Organization", $actingUser, $organization, $organization->getName());
|
||||
return $this->redirectToRoute('organization_index');
|
||||
}
|
||||
|
||||
#[Route(path: '/activate/{id}', name: 'activate', methods: ['POST'])]
|
||||
public function activate($id){
|
||||
$this->denyAccessUnlessGranted("ROLE_SUPER_ADMIN");
|
||||
$actingUser = $this->userService->getUserByIdentifier($this->getUser()->getUserIdentifier());
|
||||
$organization = $this->entityManager->getRepository(Organizations::class)->find($id);
|
||||
if (!$organization) {
|
||||
throw $this->createNotFoundException(self::NOT_FOUND);
|
||||
}
|
||||
$organization->setIsActive(true);
|
||||
$this->entityManager->persist($organization);
|
||||
$this->actionService->createAction("Activate Organization", $actingUser, $organization, $organization->getName());
|
||||
return $this->redirectToRoute('organization_index');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,20 @@
|
|||
onsubmit="return confirm('Vous allez supprimer cette organisation, êtes vous sûre?');"
|
||||
style="display: inline-block;">
|
||||
<button class="btn btn-danger" type="submit">Supprimer l'organisation</button>
|
||||
{# {% if organization.active %}#}
|
||||
{# <a href="{{ path('organization_deactivate', {'id': organization.id}) }}"#}
|
||||
{# class="btn btn-danger">Désactiver l'organisation</a>#}
|
||||
{# {% else %}#}
|
||||
{# <a href="{{ path('organization_activate', {'id': organization.id}) }}"#}
|
||||
{# class="btn btn-success">Activer l'organisation</a>#}
|
||||
{# {% endif %}#}
|
||||
</form>
|
||||
{% if organization.active %}
|
||||
<form method="POST" action="{{ path('organization_deactivate', {'id': organization.id}) }}"
|
||||
onsubmit="return confirm('Vous allez désactiver cette organisation, êtes vous sûre?');"
|
||||
style="display: inline-block;">
|
||||
<button class="btn btn-warning" type="submit">Désactiver l'organisation</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<form method="POST" action="{{ path('organization_activate', {'id': organization.id}) }}"
|
||||
onsubmit="return confirm('Vous allez re-activer cette organisation, êtes vous sûre?');"
|
||||
style="display: inline-block;">
|
||||
<button class="btn btn-primary" type="submit">Activer l'organisation</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% elseif is_granted("ROLE_ADMIN") %}
|
||||
<a href="{{ path('organization_edit', {'id': organization.id}) }}" class="btn btn-primary">Gérer mon
|
||||
organisation</a>
|
||||
|
|
@ -52,13 +59,13 @@
|
|||
} %}
|
||||
</div>
|
||||
</div>
|
||||
{# <div class="m-auto">#}
|
||||
{% include 'user/userList.html.twig' with {
|
||||
title: 'Mes utilisateurs',
|
||||
organizationId: organization.id,
|
||||
empty_message: 'Aucun utilisateurs trouvé.'
|
||||
} %}
|
||||
{# </div>#}
|
||||
{# <div class="m-auto"> #}
|
||||
{% include 'user/userList.html.twig' with {
|
||||
title: 'Mes utilisateurs',
|
||||
organizationId: organization.id,
|
||||
empty_message: 'Aucun utilisateurs trouvé.'
|
||||
} %}
|
||||
{# </div> #}
|
||||
{# APPLICATION ROW #}
|
||||
<div class="row ">
|
||||
{% for application in applications %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue