src/Controller/AccountController.php line 464

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" => "Hon. Alfred Okoe  Vanderpuije""val1" => "MP Chairman of the Foreign Affairs Committee of Parliament""val2" => "Republic of Ghana""val3" => "Blanc"),
  135.             array("val0" => "Mrs. Eunice Abeka""val1" => "Clerk to the Foreign Affairs Committee""val2" => "Republic of Ghana""val3" => "Vert"),
  136.             array("val0" => "Mr. Charles Atongba Fellah""val1" => "Director of Parliamentary Diplomacy""val2" => "Republic of Ghana""val3" => "Vert"),
  137.             array("val0" => "Hon.Cyriaque Nshimirimana""val1" => "Senator""val2" => "Republic of Burundi""val3" => "Blanc"),
  138.             array("val0" => "Hon.Gad Niyukuri""val1" => "Senator""val2" => "Republic of Burundi""val3" => "Blanc"),
  139.             array("val0" => "Amb.Isabelle NDAHAYO""val1" => "Secretary General of the Senate""val2" => "Republic of Burundi""val3" => "Rouge"),
  140.             array("val0" => "Mr Narcisse Ntihabose""val1" => "Advisor to the Economic, Social and Support Unit of the Quaestorship""val2" => "Republic of Burundi""val3" => "Vert"),
  141.             array("val0" => "Hon. Don Anastasio Asumu-Mum Munoz""val1" => "Senator""val2" => "Republic of Equatorial Guinea""val3" => "Blanc"),
  142.             array("val0" => "Hon. Don Juan Sima Mangue""val1" => "Senator""val2" => "Republic of Equatorial Guinea""val3" => "Blanc"),
  143.             array("val0" => "Ms. Dona Manuela Nzang Mba Nsee""val1" => "Letrada""val2" => "Republic of Equatorial Guinea""val3" => "Vert"),
  144.             array("val0" => "Mr. Don Emilio Nguema Monayong""val1" => "Official Administrativo""val2" => "Republic of Equatorial Guinea""val3" => "Vert"),
  145.             array("val0" => "Hon. TOURÉ Ousmane Samassi""val1" => "Secretary General of the Senate, Secretary General of the Association of African Senates""val2" => "Republic of Côte d'Ivoire""val3" => "Rouge"),
  146.             array("val0" => "Mr. TOURÉ Mathieu""val1" => "Diplomatic Advisor""val2" => "Republic of Côte d'Ivoire""val3" => "Vert"),
  147.             array("val0" => "Mr. DOSSAN René Kouakou""val1" => "Director of Cooperation, Local Authorities and Ivorians Living Abroad""val2" => "Republic of Côte d'Ivoire""val3" => "Vert"),
  148.             array("val0" => "Mr. OULOBOTÉ Gnono Aimé""val1" => "Advisor to the Secretary General""val2" => "Republic of Côte d'Ivoire""val3" => "Vert"),
  149.             array("val0" => "Hon. ABDOU HAMADI Ibrahim""val1" => "Vice-President of the Finance Committee""val2" => "Union of the Comoros""val3" => "Blanc"),
  150.             array("val0" => "Hon. HALIFA AMINA SAGAF""val1" => "Member of the Law Commission in the Union Assembly""val2" => "Union of the Comoros""val3" => "Blanc"),
  151.             array("val0" => "Mr. MOUSSA ABDALLAH MOUMINE""val1" => "Secretary General of the Union Assembly""val2" => "Union of the Comoros""val3" => "Rouge"),
  152.             array("val0" => "Mr. MATOIRI MOHAMED""val1" => "Protocol Director in the Union Assembly""val2" => "Union of the Comoros""val3" => "Vert"),
  153.             array("val0" => "Hon. Sibusiso Douglas Dlamini""val1" => "Senator""val2" => "Kingdom of Eswatini""val3" => "Blanc"),
  154.             array("val0" => "Hon. Lorraine Nxumalo""val1" => "Senator""val2" => "Kingdom of Eswatini""val3" => "Blanc"),
  155.             array("val0" => "Mr Bennedict Xaba Nkululeko""val1" => "Clerk to Parliament""val2" => "Kingdom of Eswatini""val3" => "Vert"),
  156.             array("val0" => "Mr. Dlamini Lunga Vulindlela""val1" => "Legal Clerk""val2" => "Kingdom of Eswatini""val3" => "Vert"),
  157.             array("val0" => "H.E Mr. Kingi Amason Jeffah""val1" => "Speaker of the Senate""val2" => "Republic of Kenya""val3" => "Rouge"),
  158.             array("val0" => "Hon. Kibwana Hamida Ali""val1" => "Senator""val2" => "Republic of Kenya""val3" => "Blanc"),
  159.             array("val0" => "Hon. Mwinzagu Raphael Chimera""val1" => "Senator""val2" => "Republic of Kenya""val3" => "Blanc"),
  160.             array("val0" => "Hon. Mutinda Maureen Tabitha""val1" => "Senator""val2" => "Republic of Kenya""val3" => "Blanc"),
  161.             array("val0" => "Hon. Abdulkadir Mohamed Yusuf""val1" => "Senator""val2" => "Republic of Kenya""val3" => "Blanc"),
  162.             array("val0" => "Mr. Furaha Benedict Emmanuel""val1" => "Chief of Staff- Speaker's Office""val2" => "Republic of Kenya""val3" => "Vert"),
  163.             array("val0" => "Ms. Ibrahim Muna Bashir""val1" => "Media Relations Officer""val2" => "Republic of Kenya""val3" => "Vert"),
  164.             array("val0" => "Ms. Atieno Vickie Venessa""val1" => "Clerk Assistant""val2" => "Republic of Kenya""val3" => "Vert"),
  165.             array("val0" => "Hon. Onyeka Peter Nwebonyi""val1" => "Member of Parliament""val2" => "Federal Republic of Nigeria""val3" => "Blanc"),
  166.             array("val0" => "Hon. Akintunde Yunus""val1" => "Member of Parliament""val2" => "Federal Republic of Nigeria""val3" => "Blanc"),
  167.             array("val0" => "Ms. Aisha Ali Kotoko""val1" => "Director of Protocol""val2" => "Federal Republic of Nigeria""val3" => "Vert"),
  168.             array("val0" => "Mr. Bakare Idowu Abib""val1" => "Deputy Director""val2" => "Federal Republic of Nigeria""val3" => "Vert"),
  169.             array("val0" => "Mr. Olusola Olugbenga Folarin""val1" => "Secretariat""val2" => "Federal Republic of Nigeria""val3" => "Vert"),
  170.             array("val0" => "Hon. Abdourahman Awaleh Yacin""val1" => "Chair of the Foreign Affairs Committee""val2" => "Republic of Djibouti""val3" => "Blanc"),
  171.             array("val0" => "Hon. Oumma Mohamed Hamid""val1" => "General Rapporteur of the Finance Committee""val2" => "Republic of Djibouti""val3" => "Blanc"),
  172.             array("val0" => "Ms. Man Mohamed Djama""val1" => "Director of Legal and Economic Expertise""val2" => "Republic of Djibouti""val3" => "Vert"),
  173.             array("val0" => "Mr. Abdoulkader Ibrahim Idriss""val1" => "Director of Legislative Procedure""val2" => "Republic of Djibouti""val3" => "Vert"),
  174.             array("val0" => "Hon. Idrissa Ali Niamey""val1" => "Vice-President CCR""val2" => "Republic of the Niger""val3" => "Blanc"),
  175.             array("val0" => "Hon. Mamane Harissou Soulemane""val1" => "Member CCR""val2" => "Republic of the Niger""val3" => "Blanc"),
  176.             array("val0" => "Hon. Balouki Essisimna Bernadette""val1" => "Chair of the External Relations and Cooperation Committee""val2" => "Togolese Republic""val3" => "Blanc"),
  177.             array("val0" => "Hon. Kpegba Kafui""val1" => "Chair of the Education, Communication and Socio-Cultural Development Committee""val2" => "Togolese Republic""val3" => "Blanc"),
  178.             array("val0" => "Mr. N'koue K. M'Madi""val1" => "Director of Legislative Services and Cooperation""val2" => "Togolese Republic""val3" => "Vert"),
  179.             array("val0" => "Mr. Lakmon Asséwè""val1" => "Administrative and Financial Director""val2" => "Togolese Republic""val3" => "Vert"),
  180.             array("val0" => "H.E Mr Mamadou Satigui Diakité""val1" => "President of the High Council of Territorial Collectivities""val2" => "Republic of Mali""val3" => "Rouge"),
  181.             array("val0" => "Hon. Diallo Mahamadou""val1" => "4th Vice-President of the Bureau of the High Council of Territorial Collectivities""val2" => "Republic of Mali""val3" => "Blanc"),
  182.             array("val0" => "Mr. Konare Issiaka""val1" => "Project Officer""val2" => "Republic of Mali""val3" => "Vert"),
  183.             array("val0" => "Mr. Diakite Mahamadou""val1" => "Technical Advisor""val2" => "Republic of Mali""val3" => "Vert"),
  184.             array("val0" => "Mr. Diallo Mory""val1" => "Secretary General of the High Council of Territorial Collectivities""val2" => "Republic of Mali""val3" => "Rouge"),
  185.             array("val0" => "Hon. Okala Bilai Nicole Arlette Eleonore""val1" => "Senator""val2" => "Republic of Cameroon""val3" => "Blanc"),
  186.             array("val0" => "Hon. Mbella Moki Charles""val1" => "Senator""val2" => "Republic of Cameroon""val3" => "Blanc"),
  187.             array("val0" => "Mr. Toumba Jaque""val1" => "Technical Advisor""val2" => "Republic of Cameroon""val3" => "Vert"),
  188.             array("val0" => "Mr. Kamga Sobngwi Jules Raymond""val1" => "Technical Advisor""val2" => "Republic of Cameroon""val3" => "Vert"),
  189.             array("val0" => "Mr. Mbav Yav Germain""val1" => """val2" => "Democratic Republic of the Congo""val3" => "Vert"),
  190.             array("val0" => "H.E. Mr. Mohamed Ould Errachid""val1" => "Speaker of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  191.             array("val0" => "H.E. Mr. Rachid Talbi El Alami""val1" => "Speaker of the House of Representatives""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  192.             array("val0" => "Mr. El Assad Zerouali""val1" => "Secretary General of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  193.             array("val0" => "Mr. Karim Zidane""val1" => "Minister Delegate in charge of Investment, Convergence and Evaluation of Public Policies""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  194.             array("val0" => "Mr. Abdelilah Hifdi""val1" => "President of the African Parliamentarians' Network on Development Evaluation (APNODE)""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  195.             array("val0" => "Dr. Edoé Djimitri Agbodjan""val1" => "Director of the Center for Learning on Evaluation and Results for Francophone Africa ""val2" => "CLEAR FA""val3" => "Vert"),
  196.             array("val0" => "Mr. Abdoulaye Gounou""val1" => "Director of Public Policy Evaluation""val2" => "Republic of Benin""val3" => "Vert"),
  197.             array("val0" => "Mr. Jamal Ramadane""val1" => "President of the Moroccan Evaluation Association (AME)""val2" => "Kingdom of Morocco""val3" => "Vert"),
  198.             array("val0" => "Mr. El Ouafi Boukili Makhoukhi""val1" => "Director of the Moroccan Academy of Diplomatic Studies""val2" => "Kingdom of Morocco""val3" => "Vert"),
  199.             array("val0" => "Mr. Abdelkader Amara""val1" => "President of the Economic, Social and Environmental Council (CESE)""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  200.             array("val0" => "Mr. Mounir Lymouri""val1" => "Mayor of the City of Tangier""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  201.             array("val0" => "Mr. Mehdi Tazi""val1" => "President of the General Confederation of Moroccan Enterprises (CGEM)""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  202.             array("val0" => "Mr. Mansour Lambarki""val1" => "President of Cabinet of the President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  203.             array("val0" => "Mr. Abdelkader Salama""val1" => "Vice-President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  204.             array("val0" => "Mr. Ahmed Akhchichine""val1" => "Vice-President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  205.             array("val0" => "Mr. Jawad Hilali""val1" => "Vice-President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  206.             array("val0" => "Mr. Lahcen Haddad""val1" => "Vice-President of the House of Councillors and Member of the Pan-African Parliament""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  207.             array("val0" => "Mr. Yahfadouh Benmbarek""val1" => "Vice-President of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  208.             array("val0" => "Mr. Mohamed Salem Benmassaoud""val1" => "Quaestor of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  209.             array("val0" => "Mr. Salek El Moussaoui""val1" => "Quaestor of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  210.             array("val0" => "Mr. Miloud Masside""val1" => "Quaestor of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  211.             array("val0" => "Mr. Mustapha Moucharik""val1" => "Secretary of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  212.             array("val0" => "Mr. Mohamed Reda Lahmini""val1" => "Secretary of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  213.             array("val0" => "Mr. Abderrahmane Oiffa""val1" => "Secretary of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  214.             array("val0" => "Mr. Abdesselam LEBBAR""val1" => "President of the Istiqlal Group for Unity and Egalitarianism of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  215.             array("val0" => "Mr. Abdelkrim EL HAMSS""val1" => "President of the Authenticity and Modernity Group of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  216.             array("val0" => "Mr. Mohamed EL BAKKOURI""val1" => "President of the National Rally of Independents Group of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  217.             array("val0" => "Mr. Abdellatif MOUSTAKIM""val1" => "President of the General Union of Moroccan Workers Group of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  218.             array("val0" => "Mr. Youssef AYDI""val1" => "President of the Socialist Group – Ittihadi Opposition of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  219.             array("val0" => "Mr. M'barek ESSOUBAI""val1" => "President of the Haraki Group of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  220.             array("val0" => "Mr. Mohammed Youssef ALAOUI""val1" => "President of the General Confederation of Moroccan Enterprises Group of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  221.             array("val0" => "Mr. Noureddine SOULAIK""val1" => "President of the Moroccan Workers’ Union Group of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  222.             array("val0" => "Mr. Lahcen NAZIHI""val1" => "Coordinator of the Democratic Confederation of Labour Grouping of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  223.             array("val0" => "Mr. Abdelkrim CHAHID""val1" => "Coordinator of the Constitutional Democratic and Social Grouping of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  224.             array("val0" => "Mr. Moulay Abderrahmane BLILA""val1" => "President of the Committee on the Interior, Local Authorities and Basic Infrastructure of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  225.             array("val0" => "Mrs. Neila TAZI""val1" => "President of the Committee on Foreign Affairs, National Defense and Moroccan Expatriates of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  226.             array("val0" => "Mr. Moulay Messaoud AGNAOU""val1" => "President of the Committee on Finance, Planning and Economic Development of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  227.             array("val0" => "Mr. Abderrahmane DRISSI""val1" => "President of the Committee on Education, Cultural and Social Affairs of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  228.             array("val0" => "Mr. Othmane TARMOUNIA""val1" => "President of the Committee on Productive Sectors of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  229.             array("val0" => "Mr. Abou Bakr Abid""val1" => "President of the Committee on Justice, Legislation and Human Rights of the House of Councillors""val2" => "Kingdom of Morocco""val3" => "Rouge"),
  230.             array("val0" => "Mr. Hassan El Fatmi""val1" => "Director of Legislation and Oversight, House of Councillors""val2" => "Kingdom of Morocco""val3" => "Vert"),
  231.             array("val0" => "Mr. Abdellatif Assaraj""val1" => "Head of the Plenary Sessions Division, House of Councillors""val2" => "Kingdom of Morocco""val3" => "Vert"),
  232.             array("val0" => "Mr. Abderrazak Naou""val1" => "Senior Advisor, House of Councillors""val2" => "Kingdom of Morocco""val3" => "Vert"),
  233.             array("val0" => "Ms. Yasmine Essalhi""val1" => "Senior Advisor, House of Councillors""val2" => "Kingdom of Morocco""val3" => "Vert"),
  234.             array("val0" => "Ms. Souad El Hammami""val1" => "Head of the Media and Communication Division, House of Councillors""val2" => "Kingdom of Morocco""val3" => "Vert"),
  235.             array("val0" => "Mr. Jamal Abardane""val1" => "Director of the Audiovisual Unit, House of Councillors""val2" => "Kingdom of Morocco""val3" => "Vert"),
  236.             array("val0" => "Ms. Sanae Akizoul""val1" => "Head of the Information Systems Division, House of Councillors""val2" => "Kingdom of Morocco""val3" => "Vert")
  237.         );
  238. //////
  239.         foreach ($lists as $list) {
  240. //                if ($list["1"] != "") {
  241.             $user = new Participant();
  242.             $user->setName($list["val0"]);
  243.             $user->setTitle($list["val1"]);
  244.             $user->setOrganization($list["val2"]);
  245.             $entityManager->persist($user);
  246.             $entityManager->flush();
  247.             $equipe $entityManager->getRepository(Equipe::class)->findOneByBadge($list["val3"]);
  248.             $ref 'APM04P' sprintf("%'.05d"$user->getId());
  249.             $user->setReference($ref);
  250.             $equipe->addParticipant($user);
  251.             $entityManager->persist($equipe);
  252.             $entityManager->persist($user);
  253.             $entityManager->flush();
  254. //                $this->addFlash('success', 'Compte VISITOR crée avec succés');
  255.         }
  256.         return $this->redirectToRoute('admin_show_badge_orgverso', [
  257.                     'id' => $user->getId(),
  258.         ]);
  259.         $equipes $entityManager->getRepository(Equipe::class)->findAll();
  260.         return $this->render('account/addVisitor.html.twig', [
  261.                     'equipes' => $equipes,
  262.         ]);
  263.     }
  264.     #[Route('/add-visitors'methods: ['GET''POST'], name'admin_add_visitors'), IsGranted('ROLE_ADMIN')]
  265.     public function addVisitors(Request $requestUserRepository $usersEntityManagerInterface $entityManagerUserPasswordHasherInterface $passwordHasher): Response {
  266.         if ($request->isMethod('post')) {
  267.             for ($i 1$i <= $request->get('nbVisitors'); $i++) {
  268.                 // create the user and hash its password
  269.                 $user = new User();
  270.                 $user->setEnabled('1');
  271.                 if ($request->get('typeaccess') == "VIP") {
  272.                     $role = ['ROLE_VISITOR''ROLE_USER'];
  273.                     $link 'admin_list_participants';
  274.                 } else {
  275.                     $role = ['ROLE_COLABORATEUR''ROLE_USER'];
  276.                     $link 'admin_list_colaborateurs';
  277.                 }
  278.                 $user->setRoles($role);
  279.                 $hashedPassword $passwordHasher->hashPassword($user"123456789");
  280.                 $user->setPassword($hashedPassword);
  281.                 $entityManager->persist($user);
  282.                 $entityManager->flush();
  283.                 $user->setFirstname("VISITOR");
  284.                 $user->setLastname($user->getId());
  285.                 $ref 'AV' sprintf("%'.05d"$user->getId());
  286.                 $user->setUsername($ref '@actech.ma');
  287.                 $user->setEmail($ref '@actech.ma');
  288.                 $user->setReference($ref);
  289.                 foreach ($request->get('permissions') as $entryId) {
  290.                     $entry $entityManager->getRepository(Entry::class)->find($entryId);
  291.                     $user->addPermission($entry);
  292.                     $entityManager->persist($entry);
  293.                 }
  294.                 $entityManager->persist($user);
  295.                 $entityManager->flush();
  296.             }
  297.             $this->addFlash('success'$request->get('nbVisitors') . ' Comptes ' $request->get('typeaccess') . ' crée avec succéss');
  298.             return $this->redirectToRoute($link);
  299.         }
  300.         $entries $entityManager->getRepository(Entry::class)->findAll();
  301.         return $this->render('account/addVisitors.html.twig', [
  302.                     'entries' => $entries,
  303.         ]);
  304.     }
  305.     #[Route('/{id}/edit-organisateur'methods: ['GET''POST'], name'admin_edit_organisateur'), IsGranted('ROLE_ADMIN')]
  306.     public function editOrganisateur(Request $request$idUserRepository $usersEntityManagerInterface $entityManagerUserPasswordHasherInterface $passwordHasher): Response {
  307.         $user $entityManager->getRepository(User::class)->find($id);
  308.         if ($request->isMethod('post')) {
  309.             // create the user and hash its password
  310.             $user->setFirstname($request->get('firstname'));
  311.             $user->setLastname($request->get('lastname'));
  312.             $user->setPostOccupied($request->get('postOccupied'));
  313.             $user->setCin($request->get('cin'));
  314.             $user->setComment($request->get('comment'));
  315.             if ($request->get('enabled') == "1") {
  316.                 $enabled '1';
  317.             } else {
  318.                 $enabled '0';
  319.             }
  320.             $ref 'AO' sprintf("%'.05d"$id);
  321. //            $user->setReference($ref);
  322.             $user->setEnabled($enabled);
  323.             if ($request->get('basic-default-password')) {
  324.                 $hashedPassword $passwordHasher->hashPassword($user$request->get('basic-default-password'));
  325.                 $user->setPassword($hashedPassword);
  326.             }
  327.             if ($request->files->get('image')) {
  328.                 $file $request->files->get('image');
  329.                 $user->setImage("uploads/profile/" $user->getId() . "/" $file->getClientOriginalName());
  330.                 $file->move("uploads/profile/" $user->getId() . "/"$file->getClientOriginalName());
  331.             }
  332.             $entry $entityManager->getRepository(Entry::class)->find($request->get('entry'));
  333.             $entry->addAgent($user);
  334.             if ($request->get('permissions')) {
  335.                 foreach ($request->get('permissions') as $entryId) {
  336.                     $entry $entityManager->getRepository(Entry::class)->find($entryId);
  337.                     $user->addPermission($entry);
  338.                     $entityManager->persist($entry);
  339.                 }
  340.             }
  341.             foreach ($user->getPermissions() as $entry) {
  342.                 if (!in_array($entry->getId(), $request->get('permissions'))) {
  343.                     $entry->removeVisitor($user);
  344.                     $entityManager->persist($entry);
  345.                 }
  346.             }
  347.             $entityManager->persist($entry);
  348.             $entityManager->flush();
  349.             $this->addFlash('success''Le compte #' $user->getReference() . ' a été modifier avec succées');
  350.             return $this->redirectToRoute('admin_list_agents');
  351.         }
  352.         $entries $entityManager->getRepository(Entry::class)->findAll();
  353.         $equipes $entityManager->getRepository(Equipe::class)->findAll();
  354.         return $this->render('account/editOrganisateur.html.twig', [
  355.                     'entries' => $entries,
  356.                     'equipes' => $equipes,
  357.                     'user' => $user,
  358.         ]);
  359.     }
  360.     #[Route('/{id}/edit-visitor'methods: ['GET''POST'], name'admin_edit_visitor'), IsGranted('ROLE_ADMIN')]
  361.     public function editVisitor(Request $request$idParticipantRepository $usersEntityManagerInterface $entityManager): Response {
  362.         $user $entityManager->getRepository(Participant::class)->find($id);
  363.         if ($request->isMethod('post')) {
  364. //            $user->setReference($ref);
  365.             $entityManager->persist($user);
  366.             $entityManager->flush();
  367.             $entries $entityManager->getRepository(Entry::class)->findAll();
  368.             $this->addFlash('success''Le compte #' $user->getReference() . ' a été modifier avec succéss');
  369.             return $this->redirectToRoute($link);
  370.         }
  371.         $entries $entityManager->getRepository(Entry::class)->findAll();
  372.         return $this->render('account/editVisitor.html.twig', [
  373.                     'entries' => $entries,
  374.                     'user' => $user
  375.         ]);
  376.     }
  377.     #[Route('/agents-list'name'admin_list_agents'), IsGranted('ROLE_ADMIN')]
  378.     public function listAgents(Request $requestUserRepository $users): Response {
  379.         $accounts $users->findAgents();
  380.         $invites count($users->findInvites());
  381.         $colaborateurs count($users->findColaborateurs());
  382.         $admins count($users->findAdmins());
  383.         $agents count($users->findAgents());
  384.         return $this->render('list/agentsList.html.twig', [
  385.                     'users' => $accounts,
  386.                     'invites' => $invites,
  387.                     'colaborateurs' => $colaborateurs,
  388.                     'admins' => $admins,
  389.                     'agents' => $agents,
  390.         ]);
  391.     }
  392.     #[Route('/eq-{id}/agents-list-by-equipe'name'admin_list_agents_byequipe'), IsGranted('ROLE_ADMIN')]
  393.     public function listAgentsByEquipe(Request $requestUserRepository $users$idEntityManagerInterface $entityManager): Response {
  394.         $equipe $entityManager->getRepository(Equipe::class)->find($id);
  395.         $accounts $users->findByEquipe($id);
  396.         return $this->render('list/agentsListByEquipe.html.twig', [
  397.                     'users' => $accounts,
  398.                     'equipe' => $equipe,
  399.         ]);
  400.     }
  401.     #[Route('/participant-list'name'admin_list_participants'), IsGranted('ROLE_ADMIN')]
  402.     public function listInvites(Request $requestParticipantRepository $participantsUserRepository $users): Response {
  403.         $accounts $participants->findAll();
  404.         $invites count($participants->findAll());
  405.         $colaborateurs count($users->findColaborateurs());
  406.         $admins count($users->findAdmins());
  407.         $agents count($users->findAgents());
  408.         return $this->render('list/participantsList.html.twig', [
  409.                     'users' => $accounts,
  410.                     'invites' => $invites,
  411.                     'colaborateurs' => $colaborateurs,
  412.                     'admins' => $admins,
  413.                     'agents' => $agents,
  414.         ]);
  415.     }
  416.     #[Route('/colaborateurs-list'name'admin_list_colaborateurs'), IsGranted('ROLE_ADMIN')]
  417.     public function listColaborateurs(Request $requestUserRepository $users): Response {
  418.         $accounts $users->findColaborateurs();
  419.         $invites count($users->findInvites());
  420.         $colaborateurs count($users->findColaborateurs());
  421.         $admins count($users->findAdmins());
  422.         $agents count($users->findAgents());
  423.         return $this->render('list/vvipsList.html.twig', [
  424.                     'users' => $accounts,
  425.                     'invites' => $invites,
  426.                     'colaborateurs' => $colaborateurs,
  427.                     'admins' => $admins,
  428.                     'agents' => $agents,
  429.         ]);
  430.     }
  431.     #[Route('/admins-list'name'admin_list_admins'), IsGranted('ROLE_ADMIN')]
  432.     public function listAdmins(Request $requestUserRepository $users): Response {
  433.         $accounts $users->findAdmins();
  434.         $invites count($users->findInvites());
  435.         $colaborateurs count($users->findColaborateurs());
  436.         $admins count($users->findAdmins());
  437.         $agents count($users->findAgents());
  438.         return $this->render('list/adminsList.html.twig', [
  439.                     'users' => $accounts,
  440.                     'invites' => $invites,
  441.                     'colaborateurs' => $colaborateurs,
  442.                     'admins' => $admins,
  443.                     'agents' => $agents,
  444.         ]);
  445.     }
  446. }