<?php
namespace App\Controller;
use App\Controller\Admin\DemandeCrudController;
use App\Controller\Admin\FormUserCrudController;
use App\Entity\Demande;
use App\Entity\FormUser;
use App\Entity\Meeting;
use App\Entity\User;
use App\Form\MeetingType;
use App\Repository\FormUserRepository;
use App\Repository\MeetingRepository;
use App\Security\EmailVerifier;
use App\Service\NotificationManager;
use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class MeetingController extends AbstractController
{
private $emailVerifier;
private $adminUrlGenerator;
public function __construct(EmailVerifier $emailVerifier, AdminUrlGenerator $adminUrlGenerator)
{
$this->emailVerifier = $emailVerifier;
$this->adminUrlGenerator = $adminUrlGenerator;
}
#[Route('/meeting', name: 'app_meeting', methods: ['GET'])]
public function index(MeetingRepository $meetingRepository): Response
{
$new_meeting = new Meeting();
$user = $this->getUser();
$meeting_demande = $meetingRepository->getMyMeetingsForDemande($user);
$meeting_formUser = $meetingRepository->getMyMeetingsForFormUser($user);
$meeting = array_merge($meeting_demande, $meeting_formUser);
usort($meeting, function ($a, $b) { return $a->getId() <=> $b->getId(); });
$form_meeting = $this->createForm(MeetingType::class, $new_meeting);
return $this->render('meeting/index_meeting.html.twig', [
'meeting' => $meeting,
'form_meeting' => $form_meeting->createView(),
]);
}
#[Route('/planifi-meeting/{type}/{id}', name: 'planifi_meeting')]
public function scheduleMeetingConfirm(
$id,
$type = 'formuser',
Request $request,
SessionInterface $session,
EntityManagerInterface $entityManager,
NotificationManager $notificationManager,
ValidatorInterface $validator
): Response
{
$meeting = new Meeting();
$errors = $validator->validate($meeting);
if ( $type == 'formuser' ){
$demande = $entityManager->getRepository(FormUser::class)->find($id);
}else{
$demande = $entityManager->getRepository(Demande::class)->find($id);
}
$formMeeting = $this->createForm(MeetingType::class, $meeting);
$formMeeting->handleRequest($request);
if ($formMeeting->isSubmitted()){
$meeting_creneau = $request->request->get('meeting_creneau');
$meeting_date = $request->request->get('meeting')['meeting_date'];
$meeting_date_heure = $meeting_date . ' ' . $meeting_creneau.':00';
if ( $type == 'formuser' ){
$meeting->setFormUser($demande);
}else{
$meeting->setDemande($demande);
}
$meeting->setMeetingDate(new \DateTime($meeting_date_heure));
$entityManager->persist($meeting);
$entityManager->flush();
if ( $type == 'formuser' ){
$edit_redirect_demande_url = $this->adminUrlGenerator
->setController(FormUserCrudController::class)
->setAction(Action::EDIT)
->setEntityId($id)
->set( 'meeting_id', $meeting->getId() )
->generateUrl();
$show_demande_url = $this->generateUrl('form_show', array( 'id' => $id, 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
}else{
$edit_redirect_demande_url = $this->adminUrlGenerator
->setController(DemandeCrudController::class)
->setAction(Action::EDIT)
->setEntityId($id)
->generateUrl();
$show_demande_url = $this->generateUrl('app_demande_show', array( 'id' => $id, 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
}
// send notification of reception of M//eeting : "demandeur"
$date_meeting = $meeting->getMeetingDate()->format('d-m-Y - H:m');
$demandeur = $meeting->getCreatedBy();
$edit_demande_url = $this->generateUrl('app_redirect_email', array( 'id' => $demande->getId(), 'type' => 'formuser' ), UrlGenerator::ABSOLUTE_URL );
if ( $meeting->getDemande() ){
foreach ( $meeting->getDemande()->getResponsables() as $responsable ){
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$demandeur,
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $responsable->getEmail() )
->subject('Une nouvelle réunion a été Planifié !')
->htmlTemplate('email/email_reception_meeting_schedule_responsable.html.twig')
->context([
'demandeur' => $demandeur,
'demande_url' => $show_demande_url,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Une nouvelle réunion a été Planifié !';
$notificationManager->pushMessage('Une nouvelle réclamation a été ajoutée !', $notification_message, $responsable, $edit_demande_url);
}
}
if ( $meeting->getFormUser() ){
foreach ( $meeting->getFormUser()->getResponsables() as $responsable ){
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$demandeur,
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $responsable->getEmail() )
->subject('Une nouvelle réunion a été Planifié !')
->htmlTemplate('email/email_reception_meeting_schedule_responsable.html.twig')
->context([
'demandeur' => $demandeur,
'demande_url' => $show_demande_url,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Une nouvelle réunion a été Planifié !';
$notificationManager->pushMessage('Une nouvelle réunion a été Planifiée !', $notification_message, $responsable, $edit_demande_url);
}
}
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$this->getUser(),
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $this->getUser()->getEmail() )
->subject('Planification de réunion !')
->htmlTemplate('email/email_reception_meeting_schedule_demandeur.html.twig')
->context([
'demande_url' => $show_demande_url,
'demandeur' => $demandeur,
'date_meeting' => $date_meeting,
'demande_id' => $meeting->getId(),
])
);
if ( $type == 'formuser' ){
$notification_message = 'Planification de réunion !' . $demande->getId() . ' du formulaire ' . $demande->getForm()->getNom();
}else{
$notification_message = 'Planification de réunion !' . $demande->getId() . ' du formulaire de demande d’assistance technique de l’IGPPP';
}
$notificationManager->pushMessage('Planification de réunion !', $notification_message, $this->getUser(), $show_demande_url);
// send notification of reception of Meeting : "admin"
$edit_demande_url = $this->generateUrl('app_redirect_email', array( 'id' => $demande->getId(), 'type' => 'formuser' ), UrlGenerator::ABSOLUTE_URL );
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$this->getUser(),
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $this->getParameter('EmailNotification') )
->subject('Planification de réunion !')
->htmlTemplate('email/email_reception_meeting_schedule_admin.html.twig')
->context([
'edit_demande_url' => $edit_demande_url,
'demandeur' => $demandeur,
'demande_id' => $meeting->getId(),
])
);
$admins = $entityManager->getRepository(User::class)->findByRole('ROLE_ADMIN');
foreach ( $admins as $admin){
if ( $type == 'formuser' ){
$notification_message = 'Planification de réunion !' . $demande->getId() . ' du formulaire ' . $demande->getForm()->getNom();
}else{
$notification_message = 'Planification de réunion !' . $demande->getId() . ' du formulaire de demande d’assistance technique de l’IGPPP';
}
$notificationManager->pushMessage('Planification de réunion !', $notification_message, $admin, $edit_demande_url);
}
if ( $this->isGranted('ROLE_ADMIN') || $this->isGranted('ROLE_RD' ) ){
return $this->redirect($edit_redirect_demande_url);
}
return $this->redirect($show_demande_url);
}
}
#[Route('/replanifier/meeting/{id}', name: 'reschedule_meeting')]
public function rescheduleMeeting($id,
Request $request,
Meeting $meeting,
MeetingRepository $meetingRepository,
FormUserRepository $formUserRepository,
EntityManagerInterface $entityManager,
EmailVerifier $emailVerifier,
AdminUrlGenerator $adminUrlGenerator,
NotificationManager $notificationManager): Response
{
$new_meeting = new Meeting();
$meeting = $entityManager->getRepository(Meeting::class)->find($id);
if (!$meeting) {
throw $this->createNotFoundException(
'There are no meetings with the following id: ' . $id
);
}
$form = $this->createForm(MeetingType::class, $new_meeting);
$form->handleRequest($request);
if($form->isSubmitted() )
{
$meeting = $meetingRepository->find($id);
$meeting->setIsConfirmed(false);
$meeting->setStatus(false);
$meeting_creneau = $request->request->get('meeting_creneau');
$meeting_date = $request->request->get('meeting')['meeting_date'];
$meeting_date_heure = $meeting_date . ' ' . $meeting_creneau . ':00';
$new_meeting->setMeetingDate(new \DateTime($meeting_date_heure));
$new_meeting->setFormUser($meeting->getFormUser());
$new_meeting->setDemande($meeting->getDemande());
$entityManager->persist($new_meeting);
$entityManager->flush();
if ( $meeting->getFormUser() ){
$edit_redirect_demande_url = $adminUrlGenerator->setController(FormUserCrudController::class)
->setAction(Action::EDIT)
->setEntityId($meeting->getFormUser()->getId())
->set( 'meeting_id', $new_meeting->getId() )
->generateUrl();
$show_demande_url = $this->generateUrl('form_show', array( 'id' => $meeting->getFormUser()->getId(), 'meeting_id' => $new_meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
}else if ($meeting->getDemande()){
$edit_redirect_demande_url = $adminUrlGenerator->setController(DemandeCrudController::class)
->setAction(Action::EDIT)
->setEntityId($meeting->getDemande()->getId())
->set( 'meeting_id', $new_meeting->getId() )
->generateUrl();
$show_demande_url = $this->generateUrl('app_demande_show', array( 'id' => $meeting->getDemande()->getId(), 'meeting_id' => $new_meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
}
// send notification of reception of Meeting : "demandeur"
$date_meeting = $meeting->getMeetingDate()->format('d-m-Y - H:m');
$demandeur = $meeting->getCreatedBy();
$emailVerifier->sendEmailConfirmation(
'app_verify_email',
$this->getUser(),
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $meeting->getCreatedBy()->getEmail() )
->subject('Re-planification de réunion !')
->htmlTemplate('email/email_reception_meeting_reschedule_demandeur.html.twig')
->context([
'demande_url' => $show_demande_url,
'date_meeting' => $date_meeting,
'demandeur' => $demandeur,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Re-planification de réunion !';
$notificationManager->pushMessage('Re-planification de réunion !', $notification_message, $meeting->getCreatedBy(), $show_demande_url);
$show_demande_url = $this->generateUrl('app_demande_show', array( 'id' => $id, 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
if ( $meeting->getDemande() ){
foreach ( $meeting->getDemande()->getResponsables() as $responsable ){
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$demandeur,
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $responsable->getEmail() )
->subject('Une réunion a été re-planifié !')
->htmlTemplate('email/email_reception_meeting_reschedule_responsable.html.twig')
->context([
'demandeur' => $demandeur,
'demande_url' => $show_demande_url,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Une réunion a été re-planifié !';
$notificationManager->pushMessage('Une réunion a été re-planifié !', $notification_message, $responsable, $show_demande_url);
}
}
$show_demande_url = $this->generateUrl('form_show', array( 'id' => $id, 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
if ( $meeting->getFormUser() ){
foreach ( $meeting->getFormUser()->getResponsables() as $responsable ){
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$demandeur,
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $responsable->getEmail() )
->subject('Une réunion a été re-planifié !')
->htmlTemplate('email/email_reception_meeting_reschedule_responsable.html.twig')
->context([
'demandeur' => $demandeur,
'demande_url' => $show_demande_url,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Une réunion a été re-planifié !';
$notificationManager->pushMessage('Une réunion a été re-planifié !', $notification_message, $responsable, $show_demande_url);
}
}
// send notification of reception of Meeting : "admin"
$emailVerifier->sendEmailConfirmation('app_verify_email', $this->getUser(),
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $this->getParameter('EmailNotification') )
->subject('Re-planification de réunion !')
->htmlTemplate('email/email_reception_meeting_reschedule_admin.html.twig')
->context([
'demande_url' => $edit_redirect_demande_url,
'demandeur' => $demandeur,
'date_meeting' => $date_meeting,
'demande_id' => $meeting->getId(),
])
);
$admins = $entityManager->getRepository(User::class)->findByRole('ROLE_ADMIN');
foreach ( $admins as $admin){
if ( $meeting->getFormUser()){
$notification_message = 'Re-planification de réunion !' . $id . ' du formulaire ' . $meeting->getFormUser()->getForm()->getNom();
}else if ($meeting->getDemande()){
$notification_message = 'Re-planification de réunion !' . $id. ' du formulaire de demande d’assistance technique de l’IGPPP';
}
$notificationManager->pushMessage('Re-planification réunion !', $notification_message, $admin, $edit_redirect_demande_url);
}
if ( $this->isGranted("ROLE_RD") || $this->isGranted( 'ROLE_RD' ) ) {
return $this->redirect( $edit_redirect_demande_url );
}
return $this->redirect( $show_demande_url );
}
}
#[Route('/valid/{id}', name: 'valid-meeting')]
public function validDemandeMeeting($id,
AdminUrlGenerator $adminUrlGenerator,
EntityManagerInterface $entityManager,
EmailVerifier $emailVerifier,
NotificationManager $notificationManager): Response
{
$meeting = $entityManager->getRepository(Meeting::class)->find($id);
if ( $meeting->getFormUser() ){
$edit_redirect_demande_url = $adminUrlGenerator->setController(FormUserCrudController::class)
->setAction(Action::EDIT)
->setEntityId($meeting->getFormUser()->getId())
->set( 'meeting_id', $meeting->getId() )
->generateUrl();
$show_demande_url = $this->generateUrl('form_show', array( 'id' => $meeting->getFormUser()->getId(), 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
}elseif ($meeting->getDemande()){
$edit_redirect_demande_url = $adminUrlGenerator->setController(DemandeCrudController::class)
->setAction(Action::EDIT)
->setEntityId($meeting->getDemande()->getId())
->set( 'meeting_id', $meeting->getId() )
->generateUrl();
$show_demande_url = $this->generateUrl('app_demande_show', array( 'id' => $meeting->getDemande()->getId(), 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
}
if (!$meeting) {
throw $this->createNotFoundException(
'No meeting found for id '.$id
);
}
$meeting->setIsConfirmed(1);
$meeting->setStatus(0);
$entityManager->flush();
// send notification of reception of Meeting : "demandeur"
$date_meeting = $meeting->getMeetingDate()->format('d-m-Y - H:m');
$demandeur = $meeting->getCreatedBy();
$emailVerifier->sendEmailConfirmation('app_verify_email', $this->getUser(),
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $meeting->getCreatedBy()->getEmail() )
->subject('Validation de réunion !')
->htmlTemplate('email/email_validation_meeting_demandeur.html.twig')
->context([
'demande_url' => $show_demande_url,
'date_meeting' => $date_meeting,
'demandeur' => $demandeur,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Validation de réunion !';
$notificationManager->pushMessage('Validation de réunion !', $notification_message, $meeting->getCreatedBy(), $show_demande_url);
$show_demande_url = $this->generateUrl('form_show', array( 'id' => $id, 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
if ( $meeting->getDemande() ){
foreach ( $meeting->getDemande()->getResponsables() as $responsable ){
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$demandeur,
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $responsable->getEmail() )
->subject('Une réunion a été validé !')
->htmlTemplate('email/email_reception_meeting_reschedule_responsable.html.twig')
->context([
'demandeur' => $demandeur,
'demande_url' => $show_demande_url,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Une réunion a été validé !';
$notificationManager->pushMessage('Une réunion a été validé !', $notification_message, $responsable, $show_demande_url);
}
}
if ( $meeting->getFormUser() ){
foreach ( $meeting->getFormUser()->getResponsables() as $responsable ){
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$demandeur,
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $responsable->getEmail() )
->subject('Une réunion a été validé !')
->htmlTemplate('email/email_reception_meeting_reschedule_responsable.html.twig')
->context([
'demandeur' => $demandeur,
'demande_url' => $show_demande_url,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Une réunion a été validée !';
$notificationManager->pushMessage('Une réunion a été validé!', $notification_message, $responsable, $show_demande_url);
}
}
// send notification of reception of Meeting : "admin"
$emailVerifier->sendEmailConfirmation('app_verify_email', $this->getUser(),
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $this->getParameter('EmailNotification') )
->subject('Validation de réunion !')
->htmlTemplate('email/email_validation_meeting_admin.html.twig')
->context([
'demande_url' => $edit_redirect_demande_url,
'demandeur' => $demandeur,
'date_meeting' => $date_meeting,
'demande_id' => $meeting->getId(),
])
);
$admins = $entityManager->getRepository(User::class)->findByRole('ROLE_ADMIN');
foreach ( $admins as $admin){
if ( $meeting->getFormUser()){
$notification_message = 'Validation de réunion !' . $id . ' du formulaire ' . $meeting->getFormUser()->getForm()->getNom();
}else if ($meeting->getDemande()){
$notification_message = 'Validation de réunion !' . $id. ' du formulaire de demande d’assistance technique de l’IGPPP';
}
$notificationManager->pushMessage('Validation de réunion !', $notification_message, $admin, $edit_redirect_demande_url);
}
if ( $this->isGranted('ROLE_ADMIN') || $this->isGranted('ROLE_RD' ) ){
return $this->redirect($edit_redirect_demande_url);
}
return $this->redirect($show_demande_url);
}
#[Route('/cancel/{id}', name: 'cancel-meeting')]
public function cancelDemandeMeeting($id,
EntityManagerInterface $entityManager,
EmailVerifier $emailVerifier,
NotificationManager $notificationManager,
AdminUrlGenerator $adminUrlGenerator): Response
{
$meeting = $entityManager->getRepository(Meeting::class)->find($id);
if (!$meeting) {
throw $this->createNotFoundException(
'No meeting found for id '.$id
);
}
if ( $meeting->getFormUser() ){
$edit_redirect_demande_url = $adminUrlGenerator
->setController(FormUserCrudController::class)
->setAction(Action::EDIT)
->setEntityId($id)
->set( 'meeting_id', $meeting->getId() )
->generateUrl();
$show_demande_url = $this->generateUrl('form_show', array( 'id' => $id, 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
}elseif ( $meeting->getDemande() ) {
$edit_redirect_demande_url = $adminUrlGenerator
->setController(DemandeCrudController::class)
->setAction(Action::EDIT)
->setEntityId($id)
->set( 'meeting_id', $meeting->getId() )
->generateUrl();
$show_demande_url = $this->generateUrl('app_demande_show', array( 'id' => $id, 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
}
$meeting->setIsConfirmed(0);
$meeting->setStatus(0);
$entityManager->flush();
// send notification of reception of Meeting : "demandeur"
$date_meeting = $meeting->getMeetingDate()->format('d-m-Y - H:m');
$demandeur = $meeting->getCreatedBy();
$emailVerifier->sendEmailConfirmation(
'app_verify_email',
$this->getUser(),
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $meeting->getCreatedBy()->getEmail() )
->subject('Annulation de réunion !')
->htmlTemplate('email/email_refuse_meeting_demandeur.html.twig')
->context([
'demande_url' => $show_demande_url,
'date_meeting' => $date_meeting,
'demandeur' => $demandeur,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Annulation de réunion !';
$notificationManager->pushMessage('Annulation de réunion !', $notification_message, $meeting->getCreatedBy(), $show_demande_url);
$show_demande_url = $this->generateUrl('form_show', array( 'id' => $id, 'meeting_id' => $meeting->getId() ), UrlGenerator::ABSOLUTE_URL );
if ( $meeting->getDemande() ){
foreach ( $meeting->getDemande()->getResponsables() as $responsable ){
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$demandeur,
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $responsable->getEmail() )
->subject('Une réunion a été annulée !')
->htmlTemplate('email/email_refuse_meeting_responsable.html.twig')
->context([
'demandeur' => $demandeur,
'demande_url' => $show_demande_url,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Une réunion a été annulée !';
$notificationManager->pushMessage('Une réunion a été annulée !', $notification_message, $responsable, $show_demande_url);
}
}
if ( $meeting->getFormUser() ){
foreach ( $meeting->getFormUser()->getResponsables() as $responsable ){
$this->emailVerifier->sendEmailConfirmation(
'app_verify_email',
$demandeur,
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $responsable->getEmail() )
->subject('Une réunion a été annulée!')
->htmlTemplate('email/email_refuse_meeting_responsable.html.twig')
->context([
'demandeur' => $demandeur,
'demande_url' => $show_demande_url,
'demande_id' => $meeting->getId(),
])
);
$notification_message = 'Une réunion a été annulée !';
$notificationManager->pushMessage('Une réunion a été annulée !', $notification_message, $responsable, $show_demande_url);
}
}
// send notification of reception of Meeting : "admin"
$emailVerifier->sendEmailConfirmation('app_verify_email', $this->getUser(),
(new TemplatedEmail())
->from(new Address($this->getParameter('EmailAdmin'), 'IGPPP'))
->to( $this->getParameter('EmailNotification') )
->subject('Annulation de réunion !')
->htmlTemplate('email/email_refuse_meeting_admin.html.twig')
->context([
'demande_url' => $edit_redirect_demande_url,
'demandeur' => $demandeur,
'date_meeting' => $date_meeting,
'demande_id' => $meeting->getId(),
])
);
$admins = $entityManager->getRepository(User::class)->findByRole('ROLE_ADMIN');
foreach ( $admins as $admin){
if ( $meeting->getFormUser()){
$notification_message = 'Annulation de réunion !' . $id . ' du formulaire ' . $meeting->getFormUser()->getForm()->getNom();
}else if ($meeting->getDemande()){
$notification_message = 'Annulation de réunion !' . $id. ' du formulaire de demande d’assistance technique de l’IGPPP';
}
$notificationManager->pushMessage('Annulation de réunion !', $notification_message, $admin, $edit_redirect_demande_url);
}
if ( $this->isGranted('ROLE_ADMIN') || $this->isGranted('ROLE_RD' ) ){
return $this->redirect($edit_redirect_demande_url);
}
return $this->redirect($show_demande_url);
}
}