src/Controller/AccountController.php line 157

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace App\Controller;
  11. use App\Form\Type\ChangePasswordType;
  12. use Doctrine\ORM\EntityManagerInterface;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  14. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\Response;
  17. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. use App\Entity\User;
  20. use App\Entity\Entry;
  21. use App\Entity\Equipe;
  22. use App\Entity\Participant;
  23. use App\Repository\UserRepository;
  24. use App\Repository\ParticipantRepository;
  25. use Knp\Component\Pager\PaginatorInterface;
  26. /**
  27.  * Controller used to manage current user.
  28.  *
  29.  * @author Romain Monteil <monteil.romain@gmail.com>
  30.  */
  31. #[Route('/account'), IsGranted('ROLE_USER')]
  32. class AccountController extends AbstractController {
  33.     #[Route('/add-account'methods: ['GET''POST'], name'admin_add_account'), IsGranted('ROLE_ADMIN')]
  34.     public function addAccount(Request $requestUserRepository $usersEntityManagerInterface $entityManager): Response {
  35.         // create the user and hash its password
  36.         $invites count($users->findInvites());
  37.         $colaborateurs count($users->findColaborateurs());
  38.         $admins count($users->findAdmins());
  39.         $agents count($users->findAgents());
  40.         return $this->render('account/addAccount.html.twig', [
  41.                     'invites' => $invites,
  42.                     'colaborateurs' => $colaborateurs,
  43.                     'admins' => $admins,
  44.                     'agents' => $agents,
  45.         ]);
  46.     }
  47.     #[Route('/add-agent'methods: ['GET''POST'], name'admin_add_agent'), IsGranted('ROLE_ADMIN')]
  48.     public function addAgent(Request $requestUserRepository $usersEntityManagerInterface $entityManagerUserPasswordHasherInterface $passwordHasher): Response {
  49.         if ($request->isMethod('post')) {
  50.             // create the user and hash its password
  51.             $user = new User();
  52.             $user->setFirstname($request->get('firstname'));
  53.             $user->setLastname($request->get('lastname'));
  54.             $user->setRoles(['ROLE_AGENT''ROLE_USER']);
  55.             $user->setPostOccupied($request->get('postOccupied'));
  56.             $user->setCin($request->get('cin'));
  57.             $user->setComment($request->get('comment'));
  58.             if ($request->get('enabled') == "1") {
  59.                 $enabled '1';
  60.             } else {
  61.                 $enabled '0';
  62.             }
  63.             $user->setEnabled($enabled);
  64.             $hashedPassword $passwordHasher->hashPassword($user$request->get('basic-default-password'));
  65.             $user->setPassword($hashedPassword);
  66.             $entityManager->persist($user);
  67.             $entityManager->flush();
  68.             if ($request->files->get('image')) {
  69.                 $file $request->files->get('image');
  70.                 $user->setImage("uploads/profile/" $user->getId() . "/" $file->getClientOriginalName());
  71.                 $file->move("uploads/profile/" $user->getId() . "/"$file->getClientOriginalName());
  72.             }
  73.             $ref 'Ag' sprintf("%'.05d"$user->getId());
  74.             $user->setUsername($ref '@actech.ma');
  75.             $user->setEmail($ref '@actech.ma');
  76.             $user->setReference($ref);
  77.             if ($request->get('entry')) {
  78.                 $entry $entityManager->getRepository(Entry::class)->find($request->get('entry'));
  79.                 $entry->addAgent($user);
  80.                 $entityManager->persist($entry);
  81.             }
  82.             $equipe $entityManager->getRepository(Equipe::class)->find($request->get('equipe'));
  83.             $equipe->addAgent($user);
  84.             if ($request->get('permissions')) {
  85.                 foreach ($request->get('permissions') as $entryId) {
  86.                     $entry $entityManager->getRepository(Entry::class)->find($entryId);
  87.                     $user->addPermission($entry);
  88.                     $entityManager->persist($entry);
  89.                 }
  90.             }
  91.             $entityManager->persist($entry);
  92.             $entityManager->persist($equipe);
  93.             $entityManager->flush();
  94.             $this->addFlash('success''Compte organisateur crée avec succés');
  95.             return $this->redirectToRoute('admin_list_agents');
  96.         }
  97.         $entries $entityManager->getRepository(Entry::class)->findAll();
  98.         $equipes $entityManager->getRepository(Equipe::class)->findAll();
  99.         return $this->render('account/addAgent.html.twig', [
  100.                     'entries' => $entries,
  101.                     'equipes' => $equipes,
  102.         ]);
  103.     }
  104.     #[Route('/add-visitor'methods: ['GET''POST'], name'admin_add_visitor'), IsGranted('ROLE_ADMIN')]
  105.     public function addVisitor(Request $requestUserRepository $usersEntityManagerInterface $entityManager): Response {
  106.         if ($request->isMethod('post')) {
  107.             //////
  108.             $user = new Participant();
  109.             $user->setName($request->get('name'));
  110.             $user->setTitle($request->get('title'));
  111.             $user->setOrganization($request->get('organization'));
  112.             $entityManager->persist($user);
  113.             $entityManager->flush();
  114.             $equipe $entityManager->getRepository(Equipe::class)->findOneById($request->get('equipe'));
  115.             $ref 'AE02P' sprintf("%'.05d"$user->getId());
  116.             $user->setReference($ref);
  117.             $equipe->addParticipant($user);
  118.             $entityManager->persist($equipe);
  119.             $entityManager->persist($user);
  120.             $entityManager->flush();
  121. //                $this->addFlash('success', 'Compte VISITOR crée avec succés');
  122.             return $this->redirectToRoute('admin_show_badge9x14', [
  123.                         'id' => $user->getId(),
  124.             ]);
  125.         }
  126.         $equipes $entityManager->getRepository(Equipe::class)->findAll();
  127.         return $this->render('account/addVisitor.html.twig', [
  128.                     'equipes' => $equipes,
  129.         ]);
  130.     }
  131.     #[Route('/add-visitors-byarray'methods: ['GET''POST'], name'admin_add_visitor_byarray'), IsGranted('ROLE_ADMIN')]
  132.     public function addVisitorByarray(Request $requestUserRepository $usersEntityManagerInterface $entityManager): Response {
  133.         $lists = array(
  134.             array("val0" => "H.E. Mr. Gervais NDIRAKOBUCA""val1" => "President of the Senate""val2" => "Republic of Burundi""val3" => "RED"),
  135.             array("val0" => "Mrs. Flora NDAYISENGA""val1" => "Guest""val2" => "Republic of Burundi""val3" => "ORANGE"),
  136.             array("val0" => "Hon. Berchmans NZOYIHAYA""val1" => "Member of Parliament""val2" => "Republic of Burundi""val3" => "WHITE"),
  137.             array("val0" => "Mr. Méthode BIHOYUBUSA""val1" => "Staff delegation""val2" => "Republic of Burundi""val3" => "GREEN"),
  138.             array("val0" => "Mr. Aloys BAMPORUBUSA""val1" => "Staff delegation""val2" => "Republic of Burundi""val3" => "GREEN"),
  139.             array("val0" => "Mr. Gaspard MBONIMPA""val1" => "Staff delegation""val2" => "Republic of Burundi""val3" => "GREEN"),
  140.             array("val0" => "Ms. Louise MBONIMPA""val1" => "Staff delegation""val2" => "Republic of Burundi""val3" => "GREEN"),
  141.             array("val0" => "Mr.Jean Claude NIMUBONA""val1" => "Staff delegation""val2" => "Republic of Burundi""val3" => "GREEN"),
  142.             array("val0" => "Mr. SINZINKAYO Gilbert""val1" => "Staff delegation""val2" => "Republic of Burundi""val3" => "GREEN"),
  143.             array("val0" => "Ms. Joselyne NZIGAMISONI""val1" => "Staff delegation""val2" => "Republic of Burundi""val3" => "GREEN"),
  144.             array("val0" => "Mr. Schem HABONAYO""val1" => "Staff delegation""val2" => "Republic of Burundi""val3" => "GREEN"),
  145.             array("val0" => "H.E.Mr. Pierre NGOLO ""val1" => "President of the Senate ""val2" => "Republic of the Congo ""val3" => "RED"),
  146.             array("val0" => "Mr. Grâce Pacheli BARINGUI""val1" => "Staff delegation""val2" => "Republic of the Congo ""val3" => "GREEN"),
  147.             array("val0" => "Mr. Historiel Prestigieux NGOLO ATIPO""val1" => "Staff delegation""val2" => "Republic of the Congo ""val3" => "GREEN"),
  148.             array("val0" => "Mr. Fidèle MOUAMBOLI ""val1" => "Staff delegation""val2" => "Republic of the Congo ""val3" => "GREEN"),
  149.             array("val0" => "Mr. Gaétan ONDONGA ""val1" => "Staff delegation""val2" => "Republic of the Congo ""val3" => "GREEN"),
  150.             array("val0" => "H. E.Mr. Jean-Michel Sama Lukonde Kyenge ""val1" => "President of the Senate ""val2" => "Democratic Republic of the Congo""val3" => "RED"),
  151.             array("val0" => "Hon. KANDA KALAMBAYI Pierre""val1" => "Member of Parliament""val2" => "Democratic Republic of the Congo""val3" => "WHITE"),
  152.             array("val0" => "Hon. NGBAKO MBILISI Anastasie""val1" => "Member of Parliament""val2" => "Democratic Republic of the Congo""val3" => "WHITE"),
  153.             array("val0" => "Hon. MBUGUJE MAREMBO Anne""val1" => "Member of Parliament""val2" => "Democratic Republic of the Congo""val3" => "WHITE"),
  154.             array("val0" => "Mr. MUKASA Mwanabute Valéry""val1" => "Staff delegation""val2" => "Democratic Republic of the Congo""val3" => "GREEN"),
  155.             array("val0" => "Mr. MUGISHO NYUNDA Théophile""val1" => "Staff delegation""val2" => "Democratic Republic of the Congo""val3" => "GREEN"),
  156.             array("val0" => "Mr. NSAMBO ILUNGA KINANGI Philippe""val1" => "Staff delegation""val2" => "Democratic Republic of the Congo""val3" => "GREEN"),
  157.             array("val0" => "Mr. ILUNGA MBUYA José""val1" => "Staff delegation""val2" => "Democratic Republic of the Congo""val3" => "GREEN"),
  158.             array("val0" => "Mrs. MULUMBA MULUMBA Coco""val1" => "Staff delegation""val2" => "Democratic Republic of the Congo""val3" => "GREEN"),
  159.             array("val0" => "Mr. KASHAMA MUBENGA Hervé""val1" => "Staff delegation""val2" => "Democratic Republic of the Congo""val3" => "GREEN"),
  160.             array("val0" => "Mr. KAMBALE KALOLO Djo""val1" => "Staff delegation""val2" => "Democratic Republic of the Congo""val3" => "GREEN"),
  161.             array("val0" => "Mr. MATALA KAMANDA Titi""val1" => "Staff delegation""val2" => "Democratic Republic of the Congo""val3" => "GREEN"),
  162.             array("val0" => "Mr. KILUFYA MAKONGA KALALE John""val1" => "Staff delegation""val2" => "Democratic Republic of the Congo""val3" => "GREEN"),
  163.             array("val0" => "H.E. Ms. Kandia KAMISSOKO CAMARA ""val1" => "President of the Senate""val2" => "Republic of Côte d'ivoire""val3" => "RED"),
  164.             array("val0" => "Hon. Mrs. DIABY Makani""val1" => "Member of Parliament""val2" => "Republic of Côte d'ivoire""val3" => "WHITE"),
  165.             array("val0" => "Hon. Mr. COFFI Michel Benoit""val1" => "Member of Parliament""val2" => "Republic of Côte d'ivoire""val3" => "WHITE"),
  166.             array("val0" => "Hon. Mr. TOURE Ousmane Samassi""val1" => "Secretary General""val2" => "Republic of Côte d'ivoire""val3" => "GREEN"),
  167.             array("val0" => "Mr. DOSSAN René""val1" => "Staff delegation""val2" => "Republic of Côte d'ivoire""val3" => "GREEN"),
  168.             array("val0" => "Mr. TOURE Mathieu""val1" => "Staff delegation""val2" => "Republic of Côte d'ivoire""val3" => "GREEN"),
  169.             array("val0" => "Mr. BAMBA Lanciné Joël""val1" => "Staff delegation""val2" => "Republic of Côte d'ivoire""val3" => "GREEN"),
  170.             array("val0" => "Mr. BERTE Mamadou""val1" => "Staff delegation""val2" => "Republic of Côte d'ivoire""val3" => "GREEN"),
  171.             array("val0" => "Mrs. DEMBELE Tjegnougo""val1" => "Staff delegation""val2" => "Republic of Côte d'ivoire""val3" => "GREEN"),
  172.             array("val0" => "Mr. FANNY Adama""val1" => "Staff delegation""val2" => "Republic of Côte d'ivoire""val3" => "GREEN"),
  173.             array("val0" => "Mr. Nouho SANGARE""val1" => "Staff delegation""val2" => "Republic of Côte d'ivoire""val3" => "GREEN"),
  174.             array("val0" => "H.E. Mr. Essam Farid""val1" => "Speaker of the Senate""val2" => "Arab Republic of Egypt""val3" => "RED"),
  175.             array("val0" => "Hon. Dr. Ahmed Mohamed Abdel-ghany""val1" => "Secretary General""val2" => "Arab Republic of Egypt""val3" => "GREEN"),
  176.             array("val0" => "Hon. Mohamed Mostafa Kamal""val1" => "Member of Parliament""val2" => "Arab Republic of Egypt""val3" => "WHITE"),
  177.             array("val0" => "Mr. Mohamed Jahin Abdel-hady""val1" => "Staff delegation""val2" => "Arab Republic of Egypt""val3" => "GREEN"),
  178.             array("val0" => "Mrs. Marwa Mahmoud Hasseeb""val1" => "Staff delegation""val2" => "Arab Republic of Egypt""val3" => "GREEN"),
  179.             array("val0" => "Mr. Tareq Metwally Khalaf Metwally""val1" => "Staff delegation""val2" => "Arab Republic of Egypt""val3" => "GREEN"),
  180.             array("val0" => "Mr. Ahmed Zakareya Mohyel-din""val1" => "Staff delegation""val2" => "Arab Republic of Egypt""val3" => "GREEN"),
  181.             array("val0" => "H.E. Ms. Teresa EFUA ASANGONO""val1" => "President of the Senate""val2" => "Republic of Equatorial Guinea""val3" => "RED"),
  182.             array("val0" => "Hon. Anastasio ASUMU MUM MUÑOZ""val1" => "Member of Parliament""val2" => "Republic of Equatorial Guinea""val3" => "WHITE"),
  183.             array("val0" => "Mr. Juan Jesús Nfa NGUEMA ALENE""val1" => "Staff delegation""val2" => "Republic of Equatorial Guinea""val3" => "GREEN"),
  184.             array("val0" => "H.E. Mrs. Lindiwe T.Dlamini""val1" => "President of the Senate""val2" => "Kingdom of Eswatini""val3" => "RED"),
  185.             array("val0" => "Hon. Sisusa Monusukaphi Dlamini""val1" => "Member of Parliament""val2" => "Kingdom of Eswatini""val3" => "WHITE"),
  186.             array("val0" => "Hon. Prince Sibusiso Douglas Dlamini""val1" => "Member of Parliament""val2" => "Kingdom of Eswatini""val3" => "WHITE"),
  187.             array("val0" => "Hon. Princess Ntfombiyenkhosi Dzelisa Dlamini""val1" => "Member of Parliament""val2" => "Kingdom of Eswatini""val3" => "WHITE"),
  188.             array("val0" => "Hon. Lorraine Nkhosingisite NNxumalo""val1" => "Member of Parliament""val2" => "Kingdom of Eswatini""val3" => "WHITE"),
  189.             array("val0" => "Ms. Lungile Siyaya""val1" => "Staff delegation""val2" => "Kingdom of Eswatini""val3" => "GREEN"),
  190.             array("val0" => "H.E.Mrs Huguette Yvonne NYANA-EKOUME Epse AWORI ONANGA""val1" => "President of the Senate""val2" => "Gabonese Republic""val3" => "RED"),
  191.             array("val0" => "Hon. Elodie Diane FOUEFOUE Epse SANDJOH""val1" => "Member of Parliament""val2" => "Gabonese Republic""val3" => "WHITE"),
  192.             array("val0" => "Ms. Lygie Mathurine INDJELE NAMBA""val1" => "Staff delegation""val2" => "Gabonese Republic""val3" => "GREEN"),
  193.             array("val0" => "Mr. Alex MAYILA""val1" => "Staff delegation""val2" => "Gabonese Republic""val3" => "GREEN"),
  194.             array("val0" => "Mr. Romuald Cédric OBAME MBA""val1" => "Staff delegation""val2" => "Gabonese Republic""val3" => "GREEN"),
  195.             array("val0" => "Mr. Cédric NZENGUE LOMAS""val1" => "Staff delegation""val2" => "Gabonese Republic""val3" => "GREEN"),
  196.             array("val0" => "Mr. Felix MOUDIBANGOYI""val1" => "Staff delegation""val2" => "Gabonese Republic""val3" => "GREEN"),
  197.             array("val0" => "H.E. Ms.Mamonaheng Mokitimi""val1" => "President of the Senate""val2" => "Kingdom of Lesotho""val3" => "RED"),
  198.             array("val0" => "Hon. Mamolapo Majara""val1" => "Member of Parliament""val2" => "Kingdom of Lesotho""val3" => "WHITE"),
  199.             array("val0" => "Hon. Nthupi Bereng""val1" => "Member of Parliament""val2" => "Kingdom of Lesotho""val3" => "WHITE"),
  200.             array("val0" => "Mr. Teboho Sekese""val1" => "Staff delegation""val2" => "Kingdom of Lesotho""val3" => "GREEN"),
  201.             array("val0" => "H.E. Mr. Godswill Obot Akpabio""val1" => "President of the Senate""val2" => "Federal Republic of Nigeria""val3" => "RED"),
  202.             array("val0" => "Hon. Osita Ngwu""val1" => "Member of Parliament""val2" => "Federal Republic of Nigeria""val3" => "WHITE"),
  203.             array("val0" => "Hon. Ibrahim Hassan Dankwambo""val1" => "Member of Parliament""val2" => "Federal Republic of Nigeria""val3" => "WHITE"),
  204.             array("val0" => "Hon. Asuquo Ekpenyong""val1" => "Member of Parliament""val2" => "Federal Republic of Nigeria""val3" => "WHITE"),
  205.             array("val0" => "Hon. Titus Tartenger Zam""val1" => "Member of Parliament""val2" => "Federal Republic of Nigeria""val3" => "WHITE"),
  206.             array("val0" => "Mr. Barr. Fortune Ihua-Maduenyi""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  207.             array("val0" => "Ms. Glory Emmanuel Tende""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  208.             array("val0" => "Ms. Rosemary Ikhialose Irerua""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  209.             array("val0" => "Mrs. Ruth Tesin Sinime-Paulker""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  210.             array("val0" => "Dr. Adewale Adekanye""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  211.             array("val0" => "Ms.Florence Olanike Fofah""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  212.             array("val0" => "Mr. Uchechukwu Emmanuel Udonsi""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  213.             array("val0" => "Mr. Yusuf Baba Shehudeen""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  214.             array("val0" => "Mr. David Joseph Akhigbe""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  215.             array("val0" => "Mr. Nsikak Gregory Effiong""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  216.             array("val0" => "Mr. Temitope Brown""val1" => "Staff delegation""val2" => "Federal Republic of Nigeria""val3" => "GREEN"),
  217.             array("val0" => "Hon. Lt. Gen. (Rtd) Michael Reuben Nyambuya""val1" => "Member of Parliament""val2" => "Republic of Zimbabwe""val3" => "WHITE"),
  218.             array("val0" => "Hon. Tambudzani Mohadi""val1" => "Member of Parliament""val2" => "Republic of Zimbabwe""val3" => "WHITE"),
  219.             array("val0" => "Hon. Ranganai Bwawanda""val1" => "Member of Parliament""val2" => "Republic of Zimbabwe""val3" => "WHITE"),
  220.             array("val0" => "Hon. Spiwe Munemo""val1" => "Member of Parliament""val2" => "Republic of Zimbabwe""val3" => "WHITE"),
  221.             array("val0" => "Mr. Califinos Kudakwashe Guvi""val1" => "Staff delegation""val2" => "Republic of Zimbabwe""val3" => "GREEN"),
  222.             array("val0" => "Mrs. Mercy Kwangware""val1" => "Staff delegation""val2" => "Republic of Zimbabwe""val3" => "GREEN"),
  223.             array("val0" => "Mr. Panashe Emmanuel Muzenda""val1" => "Staff delegation""val2" => "Republic of Zimbabwe""val3" => "GREEN"),
  224.             array("val0" => "Ms. Panashe Paloma Chabwera""val1" => "Staff delegation""val2" => "Republic of Zimbabwe""val3" => "GREEN"),
  225.             array("val0" => "Mr. Appeasement Kufandirori""val1" => "Staff delegation""val2" => "Republic of Zimbabwe""val3" => "GREEN"),
  226.             array("val0" => "H.E. Mr. Rodrigo Gamarra""val1" => "President - Mercosur Parliament""val2" => "PARLASUR""val3" => "RED"),
  227.             array("val0" => "Mr. Derlis Maidana""val1" => "Member of Parliament""val2" => "PARLASUR""val3" => "WHITE"),
  228.             array("val0" => "Ms. Fabiana Martin""val1" => "Member of Parliament""val2" => "PARLASUR""val3" => "WHITE"),
  229.             array("val0" => "Mr. Alejandro Deanes""val1" => "Member of Parliament""val2" => "PARLASUR""val3" => "WHITE"),
  230.             array("val0" => "Mr. Arturo Silvera""val1" => "Mercosur Parliament Staff Member""val2" => "PARLASUR""val3" => "GREEN"),
  231.             array("val0" => "Ms. Denisse Iriarte""val1" => "Mercosur Parliament""val2" => "PARLASUR""val3" => "ORANGE"),
  232.             array("val0" => "Mr. Gustavo Cuevas""val1" => "Mercosur Parliament Staff Member""val2" => "PARLASUR""val3" => "GREEN"),
  233.             array("val0" => "Mr. Eduardo Chiliquinga""val1" => "Secretary General - Andean Parliament""val2" => "PARLANDINO""val3" => "GREEN"),
  234.             array("val0" => "H.E. Mr.René Daniel Camacho""val1" => "President of Andean Parliament""val2" => "PARLANDINO""val3" => "RED"),
  235.             array("val0" => "H.E. Mr. Sidi Mohamed OULD ERRACHID""val1" => "President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  236.             array("val0" => "Mr. Mansour LAMBARKI""val1" => "Head of Cabinet of the President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  237.             array("val0" => "H.E. Mr. El Assad ZEROUALI""val1" => "Secretary General of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  238.             array("val0" => "H.E. Mr. Abdelkader SALAMA""val1" => "First Vice-President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  239.             array("val0" => "H.E. Mr. Ahmed AKHCHICHINE""val1" => "Second Vice-President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  240.             array("val0" => "H.E. Mr. Jawad HILALI""val1" => "Third Vice-President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  241.             array("val0" => "H.E. Mr. Lahcen HADDAD""val1" => "Fourth Vice-President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  242.             array("val0" => "H.E. Mr. Yahfadouh BEN M’BAREK""val1" => "Fifth Vice-President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  243.             array("val0" => "H.E. Mr. Mohamed Salem BEN MASSAOUD""val1" => "Secretary of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  244.             array("val0" => "H.E. Mr. Salek EL MOUSSAOUI""val1" => "Secretary of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  245.             array("val0" => "H.E. Mr. Miloud MAASSID""val1" => "Secretary of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  246.             array("val0" => "H.E. Mr. Mustapha MOUCHARIK""val1" => "Quaestor of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  247.             array("val0" => "H.E. Mr. Mohammed Reda LAHMINI""val1" => "Quaestor of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  248.             array("val0" => "H.E. Mr. Abderrahmane OIFFA""val1" => "Quaestor of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "RED"),
  249.             array("val0" => "H.E. Mr. Rachid TALBI ALAMI""val1" => "President of the House of Representatives""val2" => "Kingdom of Morocco""val3" => "RED"),
  250.             array("val0" => "H.E. Mr. Abdesselam LEBBAR""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  251.             array("val0" => "H.E. Mr. Abdelkrim EL HAMSS""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  252.             array("val0" => "H.E. Mr. Mohamed EL BAKKOURI""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  253.             array("val0" => "H.E. Mr. Abdellatif MOUSTAKIM""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  254.             array("val0" => "H.E. Mr. Youssef AYDI""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  255.             array("val0" => "H.E. Mr. M'barek ESSOUBAI""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  256.             array("val0" => "H.E. Mr. Mohammed Youssef ALAOUI""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  257.             array("val0" => "H.E. Mr. Noureddine SOULAIK""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  258.             array("val0" => "H.E. Mr. Lahcen NAZIHI""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  259.             array("val0" => "H.E. Mr. Abdelkrim CHAHID""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  260.             array("val0" => "H.E. Mr. Moulay Abderrahmane BLILA""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  261.             array("val0" => "H.E. Ms. Neila TAZI""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  262.             array("val0" => "H.E. Mr. Moulay Messaoud AGNAOU""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  263.             array("val0" => "H.E. Mr. Abderrahmane DRISSI""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  264.             array("val0" => "H.E. Mr. Othmane TARMOUNIA""val1" => "Member of Parliament""val2" => "Kingdom of Morocco""val3" => "WHITE"),
  265.             array("val0" => "H.E. Ms. Nyonblee Karnga-Lawrence""val1" => "President Pro-Tempore of the Senate""val2" => "Republic of Liberia""val3" => "RED"),
  266.             array("val0" => "H.E. Mr. Rolando González Patricio""val1" => "President of PARLATINO""val2" => "PARLATINO""val3" => "RED"),
  267.             array("val0" => "Ms. Norma Calero""val1" => "PARLATINO Staff Member""val2" => "PARLATINO""val3" => "GREEN"),
  268.             array("val0" => "H.E.Ms. Nyonblee Karnga-Lawrence""val1" => "President Pro-Tempore of the Senate""val2" => "Republic of Liberia""val3" => "RED"),
  269.             array("val0" => "Hon. Abraham Darius Dillon ""val1" => "Member of Parliament""val2" => "Republic of Liberia""val3" => "WHITE"),
  270.             array("val0" => "Hon. Jonathan Boye Charles Sogbie ""val1" => "Member of Parliament""val2" => "Republic of Liberia""val3" => "WHITE"),
  271.             array("val0" => "Mr. Siafa Jallah ""val1" => "Staff delegation""val2" => "Republic of Liberia""val3" => "GREEN")
  272.         );
  273. //////
  274.         foreach ($lists as $list) {
  275. //                if ($list["1"] != "") {
  276.             $user = new Participant();
  277.             $user->setName($list["val0"]);
  278.             $user->setTitle($list["val1"]);
  279.             $user->setOrganization($list["val2"]);
  280.             $entityManager->persist($user);
  281.             $entityManager->flush();
  282.             $equipe $entityManager->getRepository(Equipe::class)->findOneByBadge($list["val3"]);
  283.             $ref 'AP02P' sprintf("%'.05d"$user->getId());
  284.             $user->setReference($ref);
  285.             $equipe->addParticipant($user);
  286.             $entityManager->persist($equipe);
  287.             $entityManager->persist($user);
  288.             $entityManager->flush();
  289. //                $this->addFlash('success', 'Compte VISITOR crée avec succés');
  290.         }
  291.         return $this->redirectToRoute('admin_show_badge_orgverso', [
  292.                     'id' => $user->getId(),
  293.         ]);
  294.         $equipes $entityManager->getRepository(Equipe::class)->findAll();
  295.         return $this->render('account/addVisitor.html.twig', [
  296.                     'equipes' => $equipes,
  297.         ]);
  298.     }
  299.     #[Route('/add-visitors'methods: ['GET''POST'], name'admin_add_visitors'), IsGranted('ROLE_ADMIN')]
  300.     public function addVisitors(Request $requestUserRepository $usersEntityManagerInterface $entityManagerUserPasswordHasherInterface $passwordHasher): Response {
  301.         if ($request->isMethod('post')) {
  302.             for ($i 1$i <= $request->get('nbVisitors'); $i++) {
  303.                 // create the user and hash its password
  304.                 $user = new User();
  305.                 $user->setEnabled('1');
  306.                 if ($request->get('typeaccess') == "VIP") {
  307.                     $role = ['ROLE_VISITOR''ROLE_USER'];
  308.                     $link 'admin_list_participants';
  309.                 } else {
  310.                     $role = ['ROLE_COLABORATEUR''ROLE_USER'];
  311.                     $link 'admin_list_colaborateurs';
  312.                 }
  313.                 $user->setRoles($role);
  314.                 $hashedPassword $passwordHasher->hashPassword($user"123456789");
  315.                 $user->setPassword($hashedPassword);
  316.                 $entityManager->persist($user);
  317.                 $entityManager->flush();
  318.                 $user->setFirstname("VISITOR");
  319.                 $user->setLastname($user->getId());
  320.                 $ref 'AV' sprintf("%'.05d"$user->getId());
  321.                 $user->setUsername($ref '@actech.ma');
  322.                 $user->setEmail($ref '@actech.ma');
  323.                 $user->setReference($ref);
  324.                 foreach ($request->get('permissions') as $entryId) {
  325.                     $entry $entityManager->getRepository(Entry::class)->find($entryId);
  326.                     $user->addPermission($entry);
  327.                     $entityManager->persist($entry);
  328.                 }
  329.                 $entityManager->persist($user);
  330.                 $entityManager->flush();
  331.             }
  332.             $this->addFlash('success'$request->get('nbVisitors') . ' Comptes ' $request->get('typeaccess') . ' crée avec succéss');
  333.             return $this->redirectToRoute($link);
  334.         }
  335.         $entries $entityManager->getRepository(Entry::class)->findAll();
  336.         return $this->render('account/addVisitors.html.twig', [
  337.                     'entries' => $entries,
  338.         ]);
  339.     }
  340.     #[Route('/{id}/edit-organisateur'methods: ['GET''POST'], name'admin_edit_organisateur'), IsGranted('ROLE_ADMIN')]
  341.     public function editOrganisateur(Request $request$idUserRepository $usersEntityManagerInterface $entityManagerUserPasswordHasherInterface $passwordHasher): Response {
  342.         $user $entityManager->getRepository(User::class)->find($id);
  343.         if ($request->isMethod('post')) {
  344.             // create the user and hash its password
  345.             $user->setFirstname($request->get('firstname'));
  346.             $user->setLastname($request->get('lastname'));
  347.             $user->setPostOccupied($request->get('postOccupied'));
  348.             $user->setCin($request->get('cin'));
  349.             $user->setComment($request->get('comment'));
  350.             if ($request->get('enabled') == "1") {
  351.                 $enabled '1';
  352.             } else {
  353.                 $enabled '0';
  354.             }
  355.             $ref 'AO' sprintf("%'.05d"$id);
  356. //            $user->setReference($ref);
  357.             $user->setEnabled($enabled);
  358.             if ($request->get('basic-default-password')) {
  359.                 $hashedPassword $passwordHasher->hashPassword($user$request->get('basic-default-password'));
  360.                 $user->setPassword($hashedPassword);
  361.             }
  362.             if ($request->files->get('image')) {
  363.                 $file $request->files->get('image');
  364.                 $user->setImage("uploads/profile/" $user->getId() . "/" $file->getClientOriginalName());
  365.                 $file->move("uploads/profile/" $user->getId() . "/"$file->getClientOriginalName());
  366.             }
  367.             $entry $entityManager->getRepository(Entry::class)->find($request->get('entry'));
  368.             $entry->addAgent($user);
  369.             if ($request->get('permissions')) {
  370.                 foreach ($request->get('permissions') as $entryId) {
  371.                     $entry $entityManager->getRepository(Entry::class)->find($entryId);
  372.                     $user->addPermission($entry);
  373.                     $entityManager->persist($entry);
  374.                 }
  375.             }
  376.             foreach ($user->getPermissions() as $entry) {
  377.                 if (!in_array($entry->getId(), $request->get('permissions'))) {
  378.                     $entry->removeVisitor($user);
  379.                     $entityManager->persist($entry);
  380.                 }
  381.             }
  382.             $entityManager->persist($entry);
  383.             $entityManager->flush();
  384.             $this->addFlash('success''Le compte #' $user->getReference() . ' a été modifier avec succées');
  385.             return $this->redirectToRoute('admin_list_agents');
  386.         }
  387.         $entries $entityManager->getRepository(Entry::class)->findAll();
  388.         $equipes $entityManager->getRepository(Equipe::class)->findAll();
  389.         return $this->render('account/editOrganisateur.html.twig', [
  390.                     'entries' => $entries,
  391.                     'equipes' => $equipes,
  392.                     'user' => $user,
  393.         ]);
  394.     }
  395.     #[Route('/{id}/edit-visitor'methods: ['GET''POST'], name'admin_edit_visitor'), IsGranted('ROLE_ADMIN')]
  396.     public function editVisitor(Request $request$idParticipantRepository $usersEntityManagerInterface $entityManager): Response {
  397.         $user $entityManager->getRepository(Participant::class)->find($id);
  398.         if ($request->isMethod('post')) {
  399. //            $user->setReference($ref);
  400.             $entityManager->persist($user);
  401.             $entityManager->flush();
  402.             $entries $entityManager->getRepository(Entry::class)->findAll();
  403.             $this->addFlash('success''Le compte #' $user->getReference() . ' a été modifier avec succéss');
  404.             return $this->redirectToRoute($link);
  405.         }
  406.         $entries $entityManager->getRepository(Entry::class)->findAll();
  407.         return $this->render('account/editVisitor.html.twig', [
  408.                     'entries' => $entries,
  409.                     'user' => $user
  410.         ]);
  411.     }
  412.     #[Route('/agents-list'name'admin_list_agents'), IsGranted('ROLE_ADMIN')]
  413.     public function listAgents(Request $requestUserRepository $users): Response {
  414.         $accounts $users->findAgents();
  415.         $invites count($users->findInvites());
  416.         $colaborateurs count($users->findColaborateurs());
  417.         $admins count($users->findAdmins());
  418.         $agents count($users->findAgents());
  419.         return $this->render('list/agentsList.html.twig', [
  420.                     'users' => $accounts,
  421.                     'invites' => $invites,
  422.                     'colaborateurs' => $colaborateurs,
  423.                     'admins' => $admins,
  424.                     'agents' => $agents,
  425.         ]);
  426.     }
  427.     #[Route('/eq-{id}/agents-list-by-equipe'name'admin_list_agents_byequipe'), IsGranted('ROLE_ADMIN')]
  428.     public function listAgentsByEquipe(Request $requestUserRepository $users$idEntityManagerInterface $entityManager): Response {
  429.         $equipe $entityManager->getRepository(Equipe::class)->find($id);
  430.         $accounts $users->findByEquipe($id);
  431.         return $this->render('list/agentsListByEquipe.html.twig', [
  432.                     'users' => $accounts,
  433.                     'equipe' => $equipe,
  434.         ]);
  435.     }
  436.     #[Route('/participant-list'name'admin_list_participants'), IsGranted('ROLE_ADMIN')]
  437.     public function listInvites(Request $requestParticipantRepository $participantsUserRepository $users): Response {
  438.         $accounts $participants->findAll();
  439.         $invites count($participants->findAll());
  440.         $colaborateurs count($users->findColaborateurs());
  441.         $admins count($users->findAdmins());
  442.         $agents count($users->findAgents());
  443.         return $this->render('list/participantsList.html.twig', [
  444.                     'users' => $accounts,
  445.                     'invites' => $invites,
  446.                     'colaborateurs' => $colaborateurs,
  447.                     'admins' => $admins,
  448.                     'agents' => $agents,
  449.         ]);
  450.     }
  451.     #[Route('/colaborateurs-list'name'admin_list_colaborateurs'), IsGranted('ROLE_ADMIN')]
  452.     public function listColaborateurs(Request $requestUserRepository $users): Response {
  453.         $accounts $users->findColaborateurs();
  454.         $invites count($users->findInvites());
  455.         $colaborateurs count($users->findColaborateurs());
  456.         $admins count($users->findAdmins());
  457.         $agents count($users->findAgents());
  458.         return $this->render('list/vvipsList.html.twig', [
  459.                     'users' => $accounts,
  460.                     'invites' => $invites,
  461.                     'colaborateurs' => $colaborateurs,
  462.                     'admins' => $admins,
  463.                     'agents' => $agents,
  464.         ]);
  465.     }
  466.     #[Route('/admins-list'name'admin_list_admins'), IsGranted('ROLE_ADMIN')]
  467.     public function listAdmins(Request $requestUserRepository $users): Response {
  468.         $accounts $users->findAdmins();
  469.         $invites count($users->findInvites());
  470.         $colaborateurs count($users->findColaborateurs());
  471.         $admins count($users->findAdmins());
  472.         $agents count($users->findAgents());
  473.         return $this->render('list/adminsList.html.twig', [
  474.                     'users' => $accounts,
  475.                     'invites' => $invites,
  476.                     'colaborateurs' => $colaborateurs,
  477.                     'admins' => $admins,
  478.                     'agents' => $agents,
  479.         ]);
  480.     }
  481. }