✨ feat(esyweb): Permet l'annulation de la création d'un site web et notifie les admins.
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Form\Artemis\EsyWeb\WebsiteType;
|
||||
use App\Repository\EsyWeb\WebsiteRepository;
|
||||
use App\Repository\EsyWebTutoRepository;
|
||||
use App\Service\Logger\LoggerService;
|
||||
use App\Service\Website\EventCancelWebsite;
|
||||
use App\Service\Website\EventCreatedWebsite;
|
||||
use Cocur\Slugify\Slugify;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -23,10 +24,25 @@ use Vich\UploaderBundle\Templating\Helper\UploaderHelper;
|
||||
class EsyWebController extends AbstractController
|
||||
{
|
||||
#[Route(path: '/artemis/esyweb/website', name: 'artemis_esyweb', methods: ['GET', 'POST'])]
|
||||
public function websites(LoggerService $loggerService,Request $request,EntityManagerInterface $entityManager,WebsiteRepository $websiteRepository)
|
||||
public function websites(LoggerService $loggerService,EventDispatcherInterface $eventDispatcher,Request $request,EntityManagerInterface $entityManager,WebsiteRepository $websiteRepository)
|
||||
{
|
||||
$loggerService->log("VIEW","Affiche la page de site internet",$this->getUser());
|
||||
|
||||
if($request->query->has('idCancel')) {
|
||||
$website = $websiteRepository->find($request->query->get('idCancel'));
|
||||
$key = $website->getWebsiteKeys();
|
||||
$dns = $website->getWebsiteDns();
|
||||
foreach ($key as $value)
|
||||
$entityManager->remove($value);
|
||||
foreach ($dns as $item) {
|
||||
$entityManager->remove($item);
|
||||
}
|
||||
$entityManager->remove($website);
|
||||
$entityManager->flush();
|
||||
$loggerService->log("CANCEL","Annulation de la création du site internet",$this->getUser());
|
||||
$eventDispatcher->dispatch(new EventCancelWebsite($website));
|
||||
return $this->redirectToRoute('artemis_esyweb');
|
||||
}
|
||||
if($request->query->has('idValidate')) {
|
||||
$website = $websiteRepository->find($request->query->get('idValidate'));
|
||||
$website->setState("validate");
|
||||
|
||||
20
src/Service/Website/EventCancelWebsite.php
Normal file
20
src/Service/Website/EventCancelWebsite.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Website;
|
||||
|
||||
use App\Entity\EsyWeb\Website;
|
||||
|
||||
class EventCancelWebsite
|
||||
{
|
||||
public function __construct(private readonly Website $website)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Website
|
||||
*/
|
||||
public function getWebsite(): Website
|
||||
{
|
||||
return $this->website;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
#[AsEventListener(event: EventCreatedWebsite::class, method: 'onEventCreatedWebsite', priority: 1)]
|
||||
#[AsEventListener(event: EventCancelWebsite::class, method: 'onEventCancelWebsite', priority: 1)]
|
||||
class WebsiteCreatedSubscriber
|
||||
{
|
||||
public function __construct(
|
||||
@@ -19,6 +20,23 @@ class WebsiteCreatedSubscriber
|
||||
{
|
||||
}
|
||||
|
||||
public function onEventCancelWebsite(EventCancelWebsite $event): void
|
||||
{
|
||||
$website = $event->getWebsite();
|
||||
$listEmail = [];
|
||||
foreach ($this->accountRepository->findAll() as $account) {
|
||||
if(in_array('ROLE_ROOT',$account->getRoles())) {
|
||||
$listEmail[] = $account->getEmail();
|
||||
}
|
||||
if(in_array('ROLE_ADMIN',$account->getRoles())) {
|
||||
$listEmail[] = $account->getEmail();
|
||||
}
|
||||
}
|
||||
$this->mailer->sendMulti(array_unique($listEmail),"[Mainframe] - Annulation de a création d'un site internet","mails/esyWeb/website_cancel.twig",[
|
||||
'website' => $website,
|
||||
]);
|
||||
}
|
||||
|
||||
public function onEventCreatedWebsite(EventCreatedWebsite $event) {
|
||||
$website = $event->getWebsite();
|
||||
$listEmail = [];
|
||||
|
||||
@@ -120,10 +120,14 @@
|
||||
{{ ('esyWeb_'~ website.state)|trans }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-blue-400 hover:text-blue-300">
|
||||
<a href="{{ path('artemis_esyweb_view',{id:website.id}) }}" class="block bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded">Voir le site internet</a>
|
||||
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-blue-400 hover:text-blue-300">
|
||||
{% if website.state == "created" %}
|
||||
<a href="{{ path('artemis_esyweb',{idCancel:website.id}) }}" class="block bg-red-600 hover:bg-red-700 text-white px-3 py-1 rounded">Supprimer le site internet</a>
|
||||
{% endif %}
|
||||
<a href="{{ path('artemis_esyweb_view',{id:website.id}) }}" class="block bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded">Voir le site internet</a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
|
||||
61
templates/mails/esyWeb/website_cancel.twig
Normal file
61
templates/mails/esyWeb/website_cancel.twig
Normal file
@@ -0,0 +1,61 @@
|
||||
{% extends 'mails/base.twig' %}
|
||||
|
||||
{% block content %}
|
||||
{# --- Section Principale : En-tête (Changement de couleur pour l'annulation) --- #}
|
||||
<mj-section background-color="#f5f5f5">
|
||||
<mj-column>
|
||||
<mj-text font-size="24px" font-weight="bold" color="#dc2626" align="center">
|
||||
Annulation du Projet de Site Web
|
||||
</mj-text>
|
||||
<mj-text font-size="18px" color="#333333" align="center" padding-top="0">
|
||||
La création du site internet a été annulée
|
||||
</mj-text>
|
||||
</mj-column>
|
||||
</mj-section>
|
||||
|
||||
{# --- Section Détails du Site --- #}
|
||||
<mj-section background-color="#ffffff" padding-top="30px" padding-bottom="20px">
|
||||
<mj-column>
|
||||
<mj-text font-size="16px" line-height="24px" color="#333333">
|
||||
Bonjour,
|
||||
</mj-text>
|
||||
<mj-text font-size="16px" line-height="24px" color="#333333">
|
||||
Nous vous informons que le projet de site internet suivant a été **annulé** ou **rejeté**. Le site ne sera donc pas mis en ligne.
|
||||
</mj-text>
|
||||
|
||||
{# Bloc des informations clés #}
|
||||
<mj-text font-size="16px" line-height="24px" color="#333333" padding-top="20px">
|
||||
<p style="font-weight: bold; margin-bottom: 5px;">Détails du projet annulé :</p>
|
||||
<ul>
|
||||
<li style="list-style-type: none; margin-bottom: 5px;">
|
||||
<strong>Nom du Site :</strong> {{ datas.website.title }}
|
||||
</li>
|
||||
<li style="list-style-type: none; margin-bottom: 5px;">
|
||||
<strong>Client :</strong> {{ datas.website.customer.raisonSocial }}
|
||||
</li>
|
||||
</ul>
|
||||
</mj-text>
|
||||
</mj-column>
|
||||
</mj-section>
|
||||
|
||||
{# --- Section Pied de Page (Rappel) --- #}
|
||||
<mj-section background-color="#f5f5f5" padding-top="10px" padding-bottom="10px">
|
||||
<mj-column>
|
||||
<mj-text font-size="14px" color="#888888" align="center">
|
||||
Ce message est une notification automatique d'annulation.
|
||||
</mj-text>
|
||||
</mj-column>
|
||||
</mj-section>
|
||||
|
||||
{# --- Clôture --- #}
|
||||
<mj-section background-color="#ffffff">
|
||||
<mj-column>
|
||||
<mj-text font-size="16px" line-height="24px" color="#333333">
|
||||
Cordialement,<br/>
|
||||
L'équipe SARL SITECONSEIL
|
||||
</mj-text>
|
||||
</mj-column>
|
||||
</mj-section>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user