deactivate organization
This commit is contained in:
parent
993188ac4f
commit
371c511ecf
|
|
@ -178,5 +178,25 @@ class OrganizationController extends AbstractController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/deactivate/{id}', name: 'deactivate', requirements: ['id' => '\d+'], methods: ['GET', 'POST'])]
|
||||||
|
public function deactivate(Request $request): Response
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');
|
||||||
|
$id = $request->attributes->get('id');
|
||||||
|
$organization = $this->entityManager->getRepository(Organizations::class)->find($id);
|
||||||
|
if (!$organization) {
|
||||||
|
throw $this->createNotFoundException(self::NOT_FOUND);
|
||||||
|
}
|
||||||
|
if ($organization->isActive() === false) {
|
||||||
|
$this->addFlash('error', 'Organization is already deactivated');
|
||||||
|
return $this->redirectToRoute('organization_index');
|
||||||
|
}
|
||||||
|
|
||||||
|
$organization->setIsActive(false);
|
||||||
|
$this->entityManager->persist($organization);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
$this->addFlash('success', 'Organization deactivated successfully');
|
||||||
|
return $this->redirectToRoute('organization_index');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ organization.name|title }} - Dashboard</h1>
|
{{ organization.name|title }} - Dashboard</h1>
|
||||||
{% if is_granted("ROLE_SUPER_ADMIN") %}
|
{% if is_granted("ROLE_SUPER_ADMIN") %}
|
||||||
|
<a href="{{ path('organization_edit', {'id': organization.id}) }}" class="btn btn-primary">Gérer l'organisation</a>
|
||||||
|
<a href="{{ path('organization_deactivate', {'id': organization.id}) }}"
|
||||||
|
class="btn btn-danger">Désactiver l'organisation</a>
|
||||||
|
{% 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>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue