src/Controller/Admin/DashboardController.php line 49

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Api\SalesforceRest\Controllers\ApiAccountController;
  4. use App\Dto\DtoRepository;
  5. use App\Entity\Account;
  6. use App\Entity\AppPushNotification;
  7. use App\Entity\Article;
  8. use App\Entity\Category;
  9. use App\Entity\Company;
  10. use App\Entity\Configuration;
  11. use App\Entity\Contact;
  12. use App\Entity\InAppNotification;
  13. use App\Entity\InAppNotificationItem;
  14. use App\Entity\Invoice;
  15. use App\Entity\InvoiceMail;
  16. use App\Entity\PushNotification;
  17. use App\Entity\Repository;
  18. use App\Entity\RepositoryFamily;
  19. use App\Entity\Resource;
  20. use App\Entity\ResourceCategory;
  21. use App\Entity\ResourceGroup;
  22. use App\Entity\ResourceWorkflow;
  23. use App\Entity\Segmentation;
  24. use App\Entity\SfCampaign;
  25. use App\Entity\SfCampaignAllocation;
  26. use App\Entity\SpecialMailText;
  27. use App\Helper\DateHelper;
  28. use App\Helper\ObjectConversionHelper;
  29. use App\Helper\StringHelper;
  30. use App\Service\ConfigurationManager;
  31. use App\Service\ContactManager;
  32. use App\Service\InvoiceMailManager;
  33. use App\Service\InvoiceManager;
  34. use App\Service\MailManager;
  35. use App\Service\MobileApplicationService;
  36. use App\Service\NotificationManager;
  37. use DateTime;
  38. use Doctrine\ORM\EntityManagerInterface;
  39. use DoctrineExtensions\Query\Mysql\Date;
  40. use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
  41. use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
  42. use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
  43. use Symfony\Component\HttpFoundation\Request;
  44. use Symfony\Component\HttpFoundation\Response;
  45. use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
  46. class DashboardController extends AbstractDashboardController
  47. {
  48.     private InvoiceManager $invoiceManager;
  49.     private ContactManager $contactManager;
  50.     private MailManager $mailManager;
  51.     private EntityManagerInterface $entityManager;
  52.     private NotificationManager $notificationManager;
  53.     private ConfigurationManager $configurationManager;
  54.     private InvoiceMailManager $invoiceMailManager;
  55.     private MobileApplicationService $mobileApplicationService;
  56.     public function __construct(EntityManagerInterface $entityManager,
  57.                                 NotificationManager $notificationManager,
  58.                                 InvoiceManager $invoiceManager,
  59.                                 ContactManager $contactManager,
  60.                                 MailManager $mailManager,
  61.                                 ConfigurationManager $configurationManager,
  62.                                 InvoiceMailManager $invoiceMailManager,
  63.                                 MobileApplicationService $mobileApplicationService
  64.     )
  65.     {
  66.         $this->invoiceManager $invoiceManager;
  67.         $this->contactManager $contactManager;
  68.         $this->mailManager $mailManager;
  69.         $this->entityManager $entityManager;
  70.         $this->notificationManager $notificationManager;
  71.         $this->configurationManager $configurationManager;
  72.         $this->invoiceMailManager $invoiceMailManager;
  73.         $this->mobileApplicationService $mobileApplicationService;
  74.     }
  75.     /**
  76.      * Show admin interface
  77.      *
  78.      * @return Response
  79.      */
  80.     public function index(): Response
  81.     {
  82.         try{
  83.             // get number of contacts in DB
  84.             $contactsNumber $this->contactManager->getNumberOfContacts();
  85.             // get number of send mails in DB
  86.             $mailsNumber $this->mailManager->getNumberOfSentMails();
  87.             // get number of sync invoices in DB
  88.             $invoicesNumber $this->invoiceManager->getNumberOfInvoices();
  89.             // Nombre total d’installation de l’application (tous les fcmTokens)
  90. //            $totalInstallationsNumber = $this->mobileApplicationService->getTotalInstallationsNumber();
  91.             // Nombre de contacts uniques ayant installé l'application (unique fcmToken)
  92.             $uniqueContactInstallationsNumber $this->mobileApplicationService->getUniqueContactInstallationsNumber();
  93.             // Nombre de contacts qui se sont connectés au moins une fois sur l'application mobile (via la table analytic)
  94.             $uniqueContactLoggedNumber $this->mobileApplicationService->getContactsLoggedNumber();
  95.             // Nombre de contacts qui se sont connectés au moins une fois sur l'application mobile pour la période donnée (graphique -> prend le mois en cours si aucun parametre)
  96.             $uniqueContactLoggedForPeriod $this->mobileApplicationService->getContactsLoggedForPeriod();
  97.             $currentDate = new \DateTime();
  98.             $currentMonthStartDate $currentDate->format('Y-m-01');
  99.             $currentMonthEndDate $currentDate->format('Y-m-t');
  100.         }
  101.         catch (\Doctrine\DBAL\Driver\Exception $e){
  102.             $this->notificationManager::addError($e->getMessage());
  103.             $contactsNumber 0;
  104.             $mailsNumber 0;
  105.             $invoicesNumber 0;
  106. //            $totalInstallationsNumber = 0;
  107.             $uniqueContactInstallationsNumber 0;
  108.             $uniqueContactLoggedNumber 0;
  109.             $uniqueContactLoggedForPeriod = [];
  110.             $currentMonthStartDate "";
  111.             $currentMonthEndDate "";
  112.         }
  113.         catch (\Doctrine\DBAL\Exception $e){
  114.             $this->notificationManager::addError($e->getMessage());
  115.             $contactsNumber 0;
  116.             $mailsNumber 0;
  117.             $invoicesNumber 0;
  118. //            $totalInstallationsNumber = 0;
  119.             $uniqueContactInstallationsNumber 0;
  120.             $uniqueContactLoggedNumber 0;
  121.             $uniqueContactLoggedForPeriod = [];
  122.             $currentMonthStartDate "";
  123.             $currentMonthEndDate "";
  124.         }
  125.         finally {
  126.             return $this->render('admin/index.html.twig',
  127.                 [
  128.                     "contactsNumber" => $contactsNumber,
  129.                     "mailsNumber" => $mailsNumber,
  130.                     "invoicesNumber" => $invoicesNumber,
  131. //                    "totalInstallationsNumber" => $totalInstallationsNumber,
  132.                     "uniqueContactInstallationsNumber" => $uniqueContactInstallationsNumber,
  133.                     "uniqueContactLoggedNumber" => $uniqueContactLoggedNumber,
  134.                     "uniqueContactLoggedForPeriod" => $uniqueContactLoggedForPeriod,
  135.                     "currentMonthStartDate" => $currentMonthStartDate,
  136.                     "currentMonthEndDate" => $currentMonthEndDate,
  137.                 ]);
  138.         }
  139.     }
  140.     /**
  141.      * To handle all contacts
  142.      * @param Request $request
  143.      * @return Response
  144.      */
  145.     public function viewAdminContacts(Request $request) : Response
  146.     {
  147.         $syncContacts $request->request->get('syncContacts');
  148.         $addContact $request->request->get('addContact');
  149.         $updateContactPassword $request->request->get('updateContactPassword');
  150.         // If the user wants to synchronize contacts
  151.         if(!is_null($syncContacts)) {
  152.             $insertedFromSalesforce $this->contactManager->syncContactsFromSF();
  153.             $this->notificationManager::addInfo(strval($insertedFromSalesforce) . ' nouveaux contacts reçus et insérés de Salesforce');
  154.         }
  155.         // If the user wants to add a contact (+ instructor or club)
  156.         elseif(!is_null($addContact)) {
  157.             $contactEmail $request->request->get('contactEmail''');
  158.             // If the email address is filled and is correct
  159.             if($contactEmail !== '' && filter_var($contactEmail,FILTER_VALIDATE_EMAIL)){
  160.                 // if the contact doesn't already exist
  161.                 if(!$this->contactManager->isContactByMail($contactEmail)){
  162.                     $contact $this->contactManager->createContact($contactEmail);
  163.                     $this->entityManager->persist($contact);
  164.                     $this->entityManager->flush();
  165.                     $this->notificationManager::addInfo('Profil de ' $contactEmail ' créé');
  166.                     // todo : create instructor or club on salesforce
  167.                 }
  168.                 // if the contact already exist
  169.                 else{
  170.                     $this->notificationManager::addError('Le contact ' $contactEmail ' existe déjà en base de données');
  171.                 }
  172.             }
  173.             // if the email address is not correct
  174.             else{
  175.                 $this->notificationManager::addError('Le champs email renseigné n\'est pas correct');
  176.             }
  177.         }
  178.         // update contact password
  179.         elseif(!is_null($updateContactPassword)) {
  180.             $contactEmail $request->request->get('contactEmail');
  181.             $contactPassword $request->request->get('contactPassword''');
  182.             if(!is_null($contactEmail) && strlen($contactPassword) > 3){
  183.                 $contact $this->contactManager->getContactByMail($contactEmail);
  184.                 // if the contact exists
  185.                 if(!is_null($contact)){
  186.                     $this->contactManager->updatePassword($contact$contactPassword);
  187.                     $this->notificationManager::addInfo('Mot de passe de ' $contactEmail ' mis à jour.');
  188.                 }
  189.                 // If the mail is bad and contact doesnt exist
  190.                 else{
  191.                     $this->notificationManager::addError('Le contact n\'existe pas');
  192.                 }
  193.             }
  194.             // If the email / password are not corrects
  195.             else{
  196.                 $this->notificationManager::addError('Le mail ou le mot de passe ne sont pas valdie');
  197.             }
  198.         }
  199.         $this->setLogs();
  200.         $this->createFlashs();
  201.         return $this->render('admin/contacts.html.twig');
  202.     }
  203.     /**
  204.      * Get all the invoices from the sage folder,
  205.      * Ask Salesforce information about them + their linked account
  206.      * Create the accounts (id + hash) and the companies in database if they don't exist and create account folders
  207.      * Copy the invoices files from sage folder to account folders,
  208.      * Send information to Salesforce that processed invoices are processed
  209.      * Move invoice file to trash folder
  210.      * @return Response
  211.      */
  212.     public function viewAdminDocuments(Request $request) : Response
  213.     {
  214.         $this->notificationManager::addInfo('Le dossier où se situent les factures de Sage est : ' $_ENV['INVOICES_FOLDER']);
  215.         $this->notificationManager::addInfo('Le dossier où seront copiées les factures est : ' $_ENV['INVOICE_PUBLIC_FOLDER']);
  216.         $this->notificationManager::addInfo('Le dossier où seront déplacées les factures une fois copiées est  : ' $_ENV['INVOICE_TRASH_FOLDER']);
  217.         $this->notificationManager::addInfo('Le nombre de factures traitées par lot est de : ' $_ENV['MAX_INVOICE_PER_BATCH']);
  218.         // If the user wants to synchronize all invoices
  219.         if(isset($_POST['synchroInvoices']) && $_POST['synchroInvoices'] == 'synchroInvoices') {
  220.             $this->invoiceManager->executeSynchronizeInvoices();
  221.         }
  222.         // If the user wants to rename all invoices
  223.         if(isset($_POST['renameInvoices']) && $_POST['renameInvoices'] == 'renameInvoices') {
  224.             $badNamesInvoices $this->invoiceManager->getBadNameInvoices($_ENV['INVOICES_FOLDER']);
  225.             $treated $this->invoiceManager->renameInvoices($badNamesInvoices);
  226.             $badNamesInvoicesNumber count($badNamesInvoices);
  227.             $this->notificationManager::addInfo(strval($badNamesInvoicesNumber) . ' documents à renommer.');
  228.             $this->notificationManager::addInfo(strval($treated). ' documents renommés.');
  229.             if($badNamesInvoicesNumber !== $treated){
  230.                 $this->notificationManager::addError(strval($badNamesInvoicesNumber) . ' factures avec nom incorrect, ' $treated ' effectués.');
  231.             }
  232.         }
  233.         $this->setLogs();
  234.         $this->createFlashs();
  235.         return $this->render('admin/documents.html.twig');
  236.     }
  237.     /**
  238.      * To handle the mails sent to contacts
  239.      * @param Request $request
  240.      * @return Response
  241.      */
  242.     public function viewAdminMails(Request $request) : Response
  243.     {
  244.         $companies $this->entityManager->getRepository(Company::class)->findAll();
  245.         $sendMail $request->request->get('sendMail');
  246.         $configureMail $request->request->get('configureMail');
  247.         $this->notificationManager::addInfo('Le nombre de mails envoyés par lot est de : ' $_ENV['MAX_EMAIL_SENT_PER_BATCH']);
  248.         $specialMailOnPriceReduction $this->configurationManager->findByName(Configuration::SPECIAL_MAIL_ON_PRICE_REDUCTION)->getValue();
  249.         // If the user wants to send all not sent mail to contacts linked to accounts of invoices
  250.         if(!is_null($configureMail)) {
  251.             $specialMailsSelected = []; // a key (company id) => ?value (template mail id, null if not selected) array
  252.             // get every special mail texts template IDs
  253.             foreach ($companies as $company){
  254.                 $specialCompanyMailText $this->entityManager->find(SpecialMailText::class, intval($request->request->get('mailTemplateId-' $company->getId())));
  255.                 // if we configured one special text for the company, null or not
  256.                 $company->setSpecialMailText($specialCompanyMailText);
  257.                 // saving in database
  258.                 $this->entityManager->persist($company);
  259.             }
  260.             // value of "do we send special emails based on price reduction ?"
  261.             $crisisBasedOnPriceReductionValue $request->request->get(Configuration::SPECIAL_MAIL_ON_PRICE_REDUCTION) == 'on' '1' '0';
  262.             $crisisBasedOnPriceReductionConfObject $this->configurationManager->findByName(Configuration::SPECIAL_MAIL_ON_PRICE_REDUCTION);
  263.             if(is_null($crisisBasedOnPriceReductionConfObject)){
  264.                 $crisisBasedOnPriceReductionConfObject = (new Configuration())
  265.                     ->setName(Configuration::SPECIAL_MAIL_ON_PRICE_REDUCTION);
  266.             }
  267.             $crisisBasedOnPriceReductionConfObject->setValue($crisisBasedOnPriceReductionValue);
  268.             $this->entityManager->persist($crisisBasedOnPriceReductionConfObject);
  269.             $specialMailOnPriceReduction $this->configurationManager->findByName(Configuration::SPECIAL_MAIL_ON_PRICE_REDUCTION)->getValue();
  270.             // Save companies default mail + configuration
  271.             $this->entityManager->flush();
  272.         }
  273.         // for mail sending
  274.         if(!is_null($sendMail)) {
  275.             $this->invoiceMailManager->executeSendInvoiceMails();
  276.             $this->setLogs();
  277.         }
  278.         $this->createFlashs();
  279.         // todo : return the good template + mailtexts
  280.         return $this->render('admin/mails.html.twig', [
  281.             'companies' => $companies,
  282.             Configuration::SPECIAL_MAIL_ON_PRICE_REDUCTION => $specialMailOnPriceReduction,
  283.         ]);
  284.     }
  285.     /**
  286.      * To add CECI and fullname in old accounts
  287.      * @param Request $request
  288.      * @return Response
  289.      */
  290.     public function viewAdminAccounts(Request $request) : Response
  291.     {
  292. //        $accounts = $this->entityManager->getRepository(Account::class)->findAll();
  293.         $limit 1000;
  294.         $accounts $this->entityManager->getRepository(Account::class)->findBy(array(
  295.             "fullName" => null,
  296.             "CECI" => null
  297.         ), ["id" => "ASC"], $limit);
  298.         $addAccountFields $request->request->get('addAccountFields');
  299.         // If the account hasn't CE/CI or fullName property
  300.         if(!is_null($addAccountFields)) {
  301.             $countEditedAccounts 0;
  302.             foreach ($accounts as $account){
  303. //                if(is_null($account->getCECI())) {
  304.                     $account->setCECI(ApiAccountController::getAccount($account->getSalesforceId())->ID_CE_CI__c);
  305. //                    $this->entityManager->persist($account);
  306. //                }
  307. //                if(is_null($account->getFullName())) {
  308.                     $account->setFullName(ApiAccountController::getAccount($account->getSalesforceId())->Name);
  309.                     $this->entityManager->persist($account);
  310. //                }
  311.                 // saving in database
  312.                 $this->entityManager->flush();
  313.                 $countEditedAccounts++;
  314.             }
  315.             $this->addFlash("success"$countEditedAccounts." compte(s) modifié(s)");
  316.             $this->addFlash("success""Limite de ".$limit." comptes par itération.");
  317.         }
  318.         $this->createFlashs();
  319.         // todo : return the good template
  320.         return $this->render('admin/accounts.html.twig', [
  321.         ]);
  322.     }
  323.     /**
  324.      * Set all logs in admin logs files
  325.      * @return void
  326.      */
  327.     protected function setLogs(): void
  328.     {
  329.         $dirError false;
  330. //         Get logs from NotificationManager
  331.         $logs $this->notificationManager->getMessages();
  332.         $finalLogs = [];
  333.         $infos = [];
  334.         $errors = [];
  335. //            Write logs with current datetime in arrays
  336.         foreach($logs['info'] as $info) {
  337.             $date = new DateTime();
  338.             $infos[] = '[' .$date->format("d-m-YTH:i:s.vP"). '] app.ERROR: ' $info;
  339.         }
  340.         foreach($logs['error'] as $error) {
  341.             $date = new DateTime();
  342.             $errors[] = '[' .$date->format("d-m-YTH:i:s.vP"). '] app.ERROR: ' $error;
  343.         }
  344.         $finalLogs[] = $infos;
  345.         $finalLogs[] = $errors;
  346. //        Check if customLogs directory exist, if not create it
  347.         if(!is_dir($_ENV['CUSTOM_LOGS_FOLDER'])) {
  348.             if (!mkdir($_ENV['CUSTOM_LOGS_FOLDER'])) {
  349.                 $dirError true;
  350.                 $this->notificationManager::addError('Erreur lors de la création du dossier ' $_ENV['CUSTOM_LOGS_FOLDER']);
  351.             }
  352.         }
  353. //        If customLogs directory exist create/update the log file of the day
  354.         if(!$dirError) {
  355.             $date = new DateTime();
  356.             foreach ($finalLogs as $logs) {
  357.                 foreach ($logs as $log) {
  358.                     file_put_contents($_ENV['CUSTOM_LOGS_FOLDER'].'/'.$date->format("d-m-Y").'.log'$logPHP_EOL,FILE_APPEND);
  359.                 }
  360.             }
  361.         }
  362.     }
  363.     /**
  364.      * Show all customLogs files
  365.      */
  366.     public function showLogs(): Response
  367.     {
  368. //        dd(file_get_contents($_ENV['CUSTOM_LOGS_FOLDER'].'/30-12-2020.log'));
  369.         $results_array = array();
  370.         if (is_dir($_ENV['CUSTOM_LOGS_FOLDER']))
  371.         {
  372.             if ($handle opendir($_ENV['CUSTOM_LOGS_FOLDER']))
  373.             {
  374.                 //Notice the parentheses I added:
  375.                 while(($file readdir($handle)) !== FALSE)
  376.                 {
  377.                     $results_array[] = $file;
  378.                 }
  379.                 closedir($handle);
  380.             }
  381.         }
  382.         //Output findings
  383.         unset($results_array[0]);
  384.         unset($results_array[1]);
  385. //        dd($results_array);
  386.         return $this->render('admin/logs.html.twig', [
  387.             'logs' => $results_array,
  388.         ]);
  389.     }
  390.     /**
  391.      * Download the log $logName in CUSTOM_LOGS_FOLDER
  392.      */
  393.     public function downloadLog($logName)
  394.     {
  395.         $response = new Response();
  396.         $response->headers->set('Content-type''application/octet-stream');
  397.         $response->headers->set('Content-Disposition'sprintf('attachment; filename="%s"'$logName));
  398.         $response->setContent(file_get_contents($_ENV['CUSTOM_LOGS_FOLDER'].'/'.$logName));
  399.         $response->setStatusCode(200);
  400.         $response->headers->set('Content-Transfer-Encoding''binary');
  401.         $response->headers->set('Pragma''no-cache');
  402.         $response->headers->set('Expires''0');
  403.         return $response;
  404.     }
  405.     /**
  406.      * Parse all errors and messages to create flash messages
  407.      */
  408.     protected function createFlashs() : void{
  409.         $messages $this->getMessages();
  410.         foreach ($messages['error'] as $error){
  411.             $this->addFlash('danger'$error);
  412.         }
  413.         foreach ($messages['info'] as $message){
  414.             $this->addFlash('success'$message);
  415.         }
  416.         $this->notificationManager::eraseMessages();
  417.     }
  418.     /**
  419.      * @return array
  420.      */
  421.     public function getMessages() : array
  422.     {
  423.         return $this->notificationManager::getMessages();
  424.     }
  425.     public function configureDashboard(): Dashboard
  426.     {
  427.         return Dashboard::new()
  428.             ->setTitle('Administration');
  429.     }
  430.     public function configureMenuItems(): iterable
  431.     {
  432.         yield MenuItem::section('Actions');
  433.         yield MenuItem::linktoRoute('Retour vers le site''fa fa-home''Index');
  434.         yield MenuItem::linktoDashboard('Dashboard''fas fa-chart-line')
  435.             ->setPermission('ROLE_ADMIN');
  436.         yield MenuItem::linkToRoute('Documents''fas fa-file-invoice''AdminDocuments')
  437.             ->setPermission('ROLE_ADMIN');
  438.         yield MenuItem::linkToRoute('Mails''fa fa-envelope''AdminMails')
  439.             ->setPermission('ROLE_ADMIN');
  440.         yield MenuItem::linkToRoute('Contacts''fas fa-id-card''AdminContacts')
  441.             ->setPermission('ROLE_ADMIN');
  442.         yield MenuItem::linkToRoute('Comptes''fas fa-id-card''AdminAccounts')
  443.             ->setPermission('ROLE_ADMIN');
  444.         yield MenuItem::linkToRoute('Logs''fa fa-history''AdminLogs')
  445.             ->setPermission('ROLE_ADMIN');
  446.         yield MenuItem::section('Base de données')
  447.             ->setPermission('ROLE_SALE');
  448.         yield MenuItem::linkToCrud('Messages de Crise''fa fa-envelope'SpecialMailText::class)
  449.             ->setPermission('ROLE_ADMIN');
  450.         yield MenuItem::linkToCrud('Liste contacts''fas fa-id-card'Contact::class)
  451.             ->setPermission('ROLE_ADMIN');
  452.         yield MenuItem::linkToCrud('Liste factures''fas fa-file-invoice'Invoice::class)
  453.             ->setPermission('ROLE_BILLING');
  454.         yield MenuItem::linkToCrud('Liste mails factures''fas fa-envelope'InvoiceMail::class)
  455.             ->setPermission('ROLE_ADMIN');
  456.         yield MenuItem::section('Blog / Communication')
  457.             ->setPermission('ROLE_WRITER');
  458.         yield MenuItem::linkToCrud('Articles''fas fa-newspaper'Article::class)
  459.             ->setPermission('ROLE_WRITER');
  460.         yield MenuItem::linkToCrud('Catégories''fas fa-tags'Category::class)
  461.             ->setPermission('ROLE_WRITER');
  462.         yield MenuItem::linkToCrud("Notes d'information"'fas fa-info-circle'PushNotification::class)
  463.             ->setPermission('ROLE_WRITER');
  464.         yield MenuItem::section('Ressources')
  465.             ->setPermission('ROLE_WRITER');
  466.         yield MenuItem::linkToCrud('Ressources''fas fa-newspaper'Resource::class)
  467.             ->setPermission('ROLE_WRITER');
  468.         yield MenuItem::linkToCrud('Catégories''fas fa-tags'ResourceCategory::class)
  469.             ->setPermission('ROLE_WRITER');
  470.         yield MenuItem::linkToCrud('Processus''fa fa-cogs'ResourceWorkflow::class)
  471.             ->setPermission('ROLE_WRITER');
  472.         yield MenuItem::linkToCrud('Etapes''fa fa-cog'ResourceGroup::class)
  473.             ->setPermission('ROLE_WRITER');
  474.         yield MenuItem::section('Leads')->setPermission('ROLE_ADMIN');
  475.         yield MenuItem::linkToRoute('Map Leads''fas fa-map-marked''AdminMapLeads')
  476.             ->setPermission('ROLE_SALE');
  477.         yield MenuItem::section('Marketing')->setPermission('ROLE_ADMIN');
  478.         yield MenuItem::linkToCrud('Segmentations''fa fa-filter'Segmentation::class)
  479.             ->setPermission('ROLE_ADMIN');
  480.         yield MenuItem::linkToCrud('Enveloppe budgétaire''fa fa-tags'SfCampaignAllocation::class)
  481.             ->setPermission('ROLE_ADMIN');
  482.         yield MenuItem::linkToCrud('Campagnes Salesforce''fa fa-tags'SfCampaign::class)
  483.             ->setPermission('ROLE_ADMIN');
  484.         yield MenuItem::linkToUrl("Coûts""fa fa-eur""adminpf/marketing-costs")
  485.             ->setPermission('ROLE_ADMIN');
  486.         yield MenuItem::section('Application mobile')->setPermission('ROLE_ADMIN');
  487.         yield MenuItem::linkToCrud('Notifications Push''fa fa-bell'AppPushNotification::class)
  488.             ->setPermission('ROLE_ADMIN');
  489.         yield MenuItem::linkToCrud('Notifications InApp''fa fa-bell'InAppNotification::class)
  490.             ->setPermission('ROLE_ADMIN');
  491.         yield MenuItem::linkToCrud('Slides pour notifications InApp''fa fa-bell'InAppNotificationItem::class)
  492.             ->setPermission('ROLE_ADMIN');
  493.     }
  494.     public function configureCrud(): Crud
  495.     {
  496.         return Crud::new()
  497.             // the first argument is the "template name", which is the same as the
  498.             // Twig path but without the `@EasyAdmin/` prefix
  499.             ->overrideTemplate('layout''bundles/EasyAdminBundle/layout.html.twig');
  500.     }
  501.     /**
  502.      * @return Response
  503.      * @throws \JsonException
  504.      */
  505.     public function mapLeadsByClub(): Response
  506.     {
  507.         $data file_get_contents($_ENV['DASHBOARD_CLUB_LEAD_API_URL']);
  508.         $json json_decode($datatrue512JSON_THROW_ON_ERROR);
  509.         if(is_array($json) && count($json) > 1) {
  510.             foreach($json as $jsonData) {
  511.                 $json['datas'][] = [
  512.                     'id' => $jsonData['user'],
  513.                     'text' => $jsonData['user'].' - '.$jsonData['name']
  514.                 ];
  515.             }
  516.             return $this->render('admin/map-leads.html.twig', [ 'json' => $json['datas'] ]);
  517.         }
  518.         return $this->render('admin/map-leads.html.twig', [ 'json' => '' ]);
  519.     }
  520. }