activate/deactivate organizations
This commit is contained in:
parent
1008d636a6
commit
5e52386233
|
|
@ -129,3 +129,7 @@ body {
|
||||||
color : #FFFFFF;
|
color : #FFFFFF;
|
||||||
border: var(--secondary);
|
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]);
|
$actions = $this->entityManager->getRepository(Actions::class)->findBy(['Organization' => $organization]);
|
||||||
$activities = $this->actionService->formatActivities($actions);
|
$activities = $this->actionService->formatActivities($actions);
|
||||||
|
|
||||||
|
$this->actionService->createAction("View Organization", $actingUser, $organization, $organization->getName());
|
||||||
return $this->render('organization/show.html.twig', [
|
return $this->render('organization/show.html.twig', [
|
||||||
'organization' => $organization,
|
'organization' => $organization,
|
||||||
'newUsers' => $newUsers,
|
'newUsers' => $newUsers,
|
||||||
|
|
@ -206,5 +208,34 @@ class OrganizationController extends AbstractController
|
||||||
return $this->redirectToRoute('organization_index');
|
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?');"
|
onsubmit="return confirm('Vous allez supprimer cette organisation, êtes vous sûre?');"
|
||||||
style="display: inline-block;">
|
style="display: inline-block;">
|
||||||
<button class="btn btn-danger" type="submit">Supprimer l'organisation</button>
|
<button class="btn btn-danger" type="submit">Supprimer l'organisation</button>
|
||||||
{# {% if organization.active %}#}
|
</form>
|
||||||
{# <a href="{{ path('organization_deactivate', {'id': organization.id}) }}"#}
|
{% if organization.active %}
|
||||||
{# class="btn btn-danger">Désactiver l'organisation</a>#}
|
<form method="POST" action="{{ path('organization_deactivate', {'id': organization.id}) }}"
|
||||||
{# {% else %}#}
|
onsubmit="return confirm('Vous allez désactiver cette organisation, êtes vous sûre?');"
|
||||||
{# <a href="{{ path('organization_activate', {'id': organization.id}) }}"#}
|
style="display: inline-block;">
|
||||||
{# class="btn btn-success">Activer l'organisation</a>#}
|
<button class="btn btn-warning" type="submit">Désactiver l'organisation</button>
|
||||||
{# {% endif %}#}
|
</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") %}
|
{% elseif is_granted("ROLE_ADMIN") %}
|
||||||
<a href="{{ path('organization_edit', {'id': organization.id}) }}" class="btn btn-primary">Gérer mon
|
<a href="{{ path('organization_edit', {'id': organization.id}) }}" class="btn btn-primary">Gérer mon
|
||||||
organisation</a>
|
organisation</a>
|
||||||
|
|
@ -52,13 +59,13 @@
|
||||||
} %}
|
} %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{# <div class="m-auto">#}
|
{# <div class="m-auto"> #}
|
||||||
{% include 'user/userList.html.twig' with {
|
{% include 'user/userList.html.twig' with {
|
||||||
title: 'Mes utilisateurs',
|
title: 'Mes utilisateurs',
|
||||||
organizationId: organization.id,
|
organizationId: organization.id,
|
||||||
empty_message: 'Aucun utilisateurs trouvé.'
|
empty_message: 'Aucun utilisateurs trouvé.'
|
||||||
} %}
|
} %}
|
||||||
{# </div>#}
|
{# </div> #}
|
||||||
{# APPLICATION ROW #}
|
{# APPLICATION ROW #}
|
||||||
<div class="row ">
|
<div class="row ">
|
||||||
{% for application in applications %}
|
{% for application in applications %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue