src/Controller/EvenementController.php line 175

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\HttpFoundation\Session\Session;
  4. use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage;
  5. use Symfony\Component\HttpFoundation\RequestStack;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use App\Entity\Post;
  8. use App\Entity\AncienEvenement;
  9. use Symfony\Component\HttpFoundation\JsonResponse;
  10. use App\Form\formulaireEvenementType;
  11. use App\Entity\AttachmentCongre;
  12. use App\Entity\Attachment;
  13. use App\Entity\Carousel;
  14. use App\Entity\Etape;
  15. use App\Entity\Speakers;
  16. use App\Entity\Sponsored;
  17. use App\Entity\Congre;
  18. use App\Entity\PrixVariableCongre;
  19. use App\Entity\PrixVariable;
  20. use App\Entity\PayementMethod;
  21. use App\Entity\PaymenetMethode;
  22. use Symfony\Component\HttpFoundation\Request;
  23. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  24. use Symfony\Component\Routing\Annotation\Route;
  25. use App\Entity\EvenementAVenir;
  26. use App\Entity\EvenementFormulaire;
  27. use App\Entity\ConnexionUser;
  28. use Doctrine\Persistence\ManagerRegistry;
  29. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  30. use Symfony\Component\HttpFoundation\RedirectResponse;
  31. class EvenementController extends AbstractController
  32. {
  33.         private $requestStack;
  34.         public function __construct(RequestStack $requestStack)
  35.         {
  36.             $this->requestStack $requestStack;
  37.         }
  38.     public function index(ManagerRegistry $doctrine,$id)
  39.     {
  40.        
  41.       
  42.             $title="";
  43.         if($id==1)
  44.         {
  45.             $ancien $doctrine->getRepository(Congre::class)->findAll();
  46.             $title="Congre";
  47.         }
  48.         else
  49.            if($id==2)
  50.            {
  51.           
  52.             $title="formation  avec paiment";
  53.             $repository$doctrine->getRepository(EvenementAVenir::class);
  54.             $ancien $repository->findBy(
  55.               ['category' => $title]  
  56.                  );
  57.            }
  58.            else if($id==3)
  59.            {
  60.            
  61.             $title="webinaire sans paiment";
  62.             $repository$doctrine->getRepository(EvenementAVenir::class);
  63.             $ancien $repository->findBy(
  64.               ['category' => $title]  
  65.                  );
  66.            }
  67.            else if($id==4)
  68.            {
  69.           
  70.             $title="Symposium avec paiment";
  71.             $repository$doctrine->getRepository(EvenementAVenir::class);
  72.             $ancien $repository->findBy(
  73.               ['category' => $title]  
  74.                  );
  75.            }
  76.            else
  77.                if($id==5)
  78.                {
  79.                
  80.                 $title="action humanitaire sans paiment";
  81.                 $repository$doctrine->getRepository(EvenementAVenir::class);
  82.                 $ancien $repository->findBy(
  83.                   ['category' => $title]  
  84.                      );
  85.                }
  86.                else
  87.                {
  88.                 return $this->redirectToRoute('index');
  89.                }
  90.          
  91.        $repository $doctrine->getRepository(EvenementAVenir::class);
  92.        $article $repository->findBy(
  93.          ['id' => 20]  
  94. );
  95. $article=$doctrine->getRepository(Congre::class)->findBy(array('desplay'=>1), array('id' => 'desc'),1,0);
  96. $k=1;
  97. if(count($article)<1)
  98. {
  99.     $k=0;
  100.     $article=$doctrine->getRepository(EvenementAVenir::class)->findBy(array('desplay'=>1), array('id' => 'desc'),1,0);
  101. }
  102. $repository $doctrine->getRepository(Attachment::class);
  103.         $carousel $repository->findBy(
  104.             ['evenement_id' => 20]);
  105.           
  106.      //  $repository = $doctrine->getRepository(PaymenetMethode::class);
  107.      
  108.         return $this->render('evenement/index.html.twig',['event'=>$article,'ancien'=>$ancien,'carousel'=>$carousel,'title'=>$title,'id'=>$id,'tt'=>$k]);
  109.     }
  110.     public function detail(ManagerRegistry $doctrine,$id)
  111.     {   
  112.      
  113.         
  114.         $autre=0;
  115.         $sesisonHas=0;
  116.        
  117.         $session $this->requestStack->getSession();
  118.         $session->set('typesendpaiment',1);
  119.         $evenementsprcifique=0;
  120.         if($id==49)
  121.         {
  122.             $evenementsprcifique=$id;
  123.         }
  124.         if(!$session->has('type') || !$session->has('fonction'))
  125.         {
  126.             return $this->redirectToRoute('formulaireEvenementCongreTypeDeuxtypeIdCongreFormationPaiment', [
  127.                 'id' => $id
  128.                
  129.             ]);
  130.         }
  131.         $prix=0;
  132.         if($session->get('type')=="Adhérent" || $session->get('type')=="Etudiant")
  133.         {
  134.             $prix=0;
  135.         }else 
  136.         {
  137.             $prix=20;
  138.         }
  139.         if($session->has('email') && $session->has('password'))
  140.         {
  141.             $sesisonHas=1;
  142.         }
  143.         $sesisonHas=1;
  144.     $tab=[];
  145.     $repository $doctrine->getRepository(PrixVariableCongre::class);
  146.     $etape $repository->findAll();    
  147.     foreach($etape as $a)
  148.     {
  149.         if($a->getEvenementprixId()==$id)
  150.         {
  151.             array_push($tab,['id_evenement'=>$a->getEvenementprixId(),'id_prix'=>$a->getId(),'titre'=>$a->getName(),'category'=>$a->getCategory(),'prix'=>$a->getPrix()]);
  152.          
  153.         }
  154.        
  155.          
  156.     }
  157.   
  158.   
  159.          
  160.         return $this->render('detailEvenement/index.html.twig',['sessionHas'=>$sesisonHas,'tab'=>$tab,'autre'=>$autre,'nb'=>-1,'prix'=>$prix]);
  161.     }
  162.     public function congre(ManagerRegistry $doctrine,$id)
  163.     {
  164.       
  165.         $session $this->requestStack->getSession();
  166.         $session->set('typesendpaiment'"");
  167.      
  168.        
  169.         $repository $doctrine->getRepository(Congre::class);
  170.         $article $repository->find($id);
  171.         if($article==Null)
  172.         {
  173.             return $this->redirectToRoute('index');
  174.         }
  175.         $repository $doctrine->getRepository(Carousel::class);
  176.         $carousel $repository->findBy(
  177.             ['carousel_congre_id' => $id]       
  178.        );
  179.        $repository $doctrine->getRepository(AttachmentCongre::class);
  180.        $gallerie $repository->findBy(
  181.            ['id' => $article->getId()]       
  182.       ); 
  183.       $repository $doctrine->getRepository(Etape::class);
  184.        $etape $repository->findBy(
  185.            ['etape_new_id' => $article->getId()]       
  186.       );     
  187.       $tab=[];
  188.       $tab2=[];
  189.       $tab3=[];
  190.       foreach($etape as $a)
  191.       {
  192.         //$arr = [ "id" => $bu->getId(), "name" => $bu->getName()];
  193.         array_push($tab,['Etape'=>$a->getId(),'posetion'=>$a->getPosetionEtape(),'decription'=>$a->getDescriptionEtape(),'timeN'=>$a->getTimeEtape(),'titre'=>$a->getTitreEtape()]);
  194.        
  195.         $anis=$a->getPosetionEtape();
  196.         if (!in_array($anis$tab2))
  197.             {
  198.   
  199.                array_push($tab3,$a->getPosetionEtape());
  200.   
  201.             }
  202.             array_push($tab2,$a->getPosetionEtape());
  203.       }
  204.       $repository $doctrine->getRepository(Speakers::class);
  205.        $speakers $repository->findBy(
  206.            ['evenement_speaker_id' => $id]       
  207.       ); 
  208.       $repository $doctrine->getRepository(Sponsored::class);
  209.       $sponsored $repository->findBy(
  210.           ['evenement_sponsored_id' =>$id]       
  211.      ); 
  212.      
  213.      $tab5=[];
  214.      $repository $doctrine->getRepository(PrixVariableCongre::class);
  215.      $etape $repository->findAll();    
  216.      foreach($etape as $a)
  217.      {
  218.          if($a->getEvenementprixId()==$id)
  219.          {
  220.              array_push($tab5,['id_evenement'=>$a->getEvenementprixId(),'id_prix'=>$a->getId(),'titre'=>$a->getName(),'category'=>$a->getCategory(),'prix'=>$a->getPrix()]);
  221.           
  222.          }
  223.         
  224.           
  225.      }
  226.     
  227.      
  228.     
  229.         return $this->render('congre/congre.html.twig',['article'=>$article,'gallerie'=>$gallerie,'carousel'=>$carousel,'tab'=>$tab,'tab3'=>$tab3,'speakers'=>$speakers,'sponsored'=>$sponsored,'id'=>$id,'tab5'=>$tab5]);
  230.     }
  231.     function autre(ManagerRegistry $doctrine,string $title,int $id)
  232.     {
  233.         
  234.         //$product = $doctrine->getRepository(Accueil::class)->find(4);
  235.         $ancien $doctrine->getRepository(EvenementAVenir::class)->find($id);
  236.     
  237.         $gallerie  $doctrine->getRepository(Attachment::class);
  238.         $carousel $gallerie->findBy(
  239.             ['evenement_id' => $ancien->getId()]       
  240.        );     
  241.         return $this->render('ancien/index.html.twig',['ancien'=>$ancien,'carousel'=>$carousel]);
  242.     }
  243.     public function detailautre(ManagerRegistry $doctrine,$id)
  244.     {  
  245.      
  246.         if($id==52)
  247.         {
  248.             $session $this->requestStack->getSession();
  249.             if(!$session->has('emailSend')){ return  new RedirectResponse("/formulaire/evenement/52"); }
  250.             if($session->has('email') && $session->has('password'))
  251.             {
  252.                 $repository $doctrine->getRepository(ConnexionUser::class);
  253.                 $user $repository->findOneBy(['email' => $session->get('email')]);
  254.                     
  255.                 $repository2 $doctrine->getRepository(EvenementFormulaire::class);
  256.                 $user2 $repository2->findBy(['user' => $user->getId(),'evenement'=>52]);
  257.                
  258.                 if(count($user2)==0)
  259.                 {
  260.                     return  new RedirectResponse("/formulaire/evenement/52"); 
  261.                 }
  262.               
  263.               
  264.             }
  265.         }
  266.       
  267.         $autre=1;
  268.         $sesisonHas=0;
  269.         $sesisonHas49=0;
  270.         $evenementsprcifique=0;
  271.         if($id==49)
  272.         {
  273.             $evenementsprcifique=$id;
  274.         }
  275.         if($id==52)
  276.         {
  277.             $sesisonHas=1;
  278.         }
  279.         $session $this->requestStack->getSession();
  280.         $prix=0;
  281.         if($session->has('type'))
  282.         {
  283.             if($session->get('type')=="Non adhérent")$prix=5;
  284.             $sesisonHas=1;
  285.         }
  286.         if($session->has('evenementspecifique'))
  287.         {
  288.             $sesisonHas49=1;
  289.         }
  290.     $tab=[];
  291.     $repository $doctrine->getRepository(PrixVariable::class);
  292.     $etape $repository->findAll();    
  293.     foreach($etape as $a)
  294.     {
  295.       
  296.         if($a->getEvenementprixId()==$id)
  297.         {
  298.             
  299.             array_push($tab,['id_evenement'=>$a->getEvenementprixId(),'id_prix'=>$a->getId(),'titre'=>$a->getName(),'category'=>$a->getCategory(),'prix'=>$a->getPrix()]);
  300.          
  301.         }
  302.        
  303.          
  304.     }
  305.        $nbevenement $repository->findBy(
  306.             ['id' => $id]);
  307.          $nbevenement=count($nbevenement);
  308.        
  309.           
  310.              $session->set('typesendpaiment',1);
  311.          
  312.         return $this->render('detailEvenement/index.html.twig',['sessionHas'=>$sesisonHas,'tab'=>$tab,'autre'=>$autre,'nb'=>$nbevenement,'evenementsprcifique'=>$evenementsprcifique,'sesisonHas49'=>$sesisonHas49,'prix'=>$prix]);
  313.     }
  314.     public function getall(ManagerRegistry $doctrine,$id)
  315.     {
  316.         $ancien=[];
  317.         $tab=[];
  318.         if($id==2)
  319.         {
  320.             $ancien $doctrine->getRepository(EvenementAVenir::class)->findAll();
  321.             foreach($ancien as $item)
  322.             {
  323.                 array_push($tab,['id'=>$item->getId(),'titre'=>$item->getTitre()]);
  324.               
  325.             }
  326.         }
  327.         else
  328.         {
  329.             $ancien $doctrine->getRepository(Congre::class)->findAll();
  330.             foreach($ancien as $item)
  331.             {
  332.                 array_push($tab,['id'=>$item->getId(),'titre'=>$item->getTitre()]);
  333.               
  334.             }
  335.         }
  336.         $response = new Response(json_encode($tab));
  337.         $response->headers->set('Content-Type''application/json');
  338.         return $response;
  339.     }
  340.     public function formulaireEvenement(ManagerRegistry $doctrine,Request $request,int $id)
  341.     {
  342.               $session $this->requestStack->getSession();
  343.             
  344.           
  345.                 $session $this->requestStack->getSession();
  346.                /* if($session->has('email') && $session->has('password'))
  347.                 {
  348.                     $repository = $doctrine->getRepository(ConnexionUser::class);
  349.                     $user = $repository->findOneBy(['email' => $session->get('email')]);
  350.                         
  351.                     $repository2 = $doctrine->getRepository(EvenementFormulaire::class);
  352.                     $user2 = $repository2->findBy(['user' => $user->getId(),'evenement'=>52,'pay'=>true]);
  353.                      
  354.                     if(count($user2)>0)
  355.                     {
  356.                         return  new RedirectResponse("/evenement/autre/detail/52/register/"); 
  357.                     }
  358.                   
  359.                   
  360.                 }*/
  361.             
  362.         $erreur="";
  363.         $verif=true;
  364.         $messageSuccess="";
  365.         $entityManager $doctrine->getManager();
  366.         $article = new EvenementFormulaire();
  367.         $form $this->createForm(formulaireEvenementType::class, $article);
  368.         $form->handleRequest($request);
  369.                 if ($form->isSubmitted() && $form->isValid()) {
  370.                 if($article->getType() == "Etudiant")
  371.                 {
  372.                     $erreur="C'est exclusif pour les professionnels.";
  373.                     $verif=false;
  374.                 }
  375.                 if(Empty($article->getNom()))
  376.                 {
  377.                 $erreur.="Nom invalide <br>";
  378.                 $verif=false;
  379.                 }
  380.                 else if(strlen($article->getNom())<|| strlen($article->getNom())>30)
  381.                 {
  382.                     $erreur.="Nom invalide <br>";
  383.                     $verif=false;
  384.                 }
  385.                 else
  386.                 {
  387.                     $verif=true;
  388.                 }
  389.                 if(Empty($article->getPrenom()))
  390.                 {
  391.                 $erreur.="Prénom invalide <br>";
  392.                 $verif=false;
  393.                 }
  394.                 else if(strlen($article->getPrenom())<|| strlen($article->getPrenom())>30)
  395.                 {
  396.                     $erreur.="Prénom invalide <br>";
  397.                     $verif=false;
  398.                 }
  399.                 /**** verif email */
  400.                 if(strlen($article->getEmail())<|| strlen($article->getEmail())>30)
  401.                 {
  402.                     $erreur.="Email invalide <br>";
  403.                     $verif=false;
  404.                 }
  405.                 else
  406.                 {
  407.                     $verif=true;
  408.                 }
  409.                 /***** */
  410.                 if(Empty($article->getPhone()))
  411.                 {
  412.                 $erreur.="Prénom invalide <br>";
  413.                 $verif=false;
  414.                 }
  415.                 else if(strlen($article->getPhone())<|| strlen($article->getPhone())>11)
  416.                 {
  417.                     $erreur.="Numéro de téléphone invalide <br>";
  418.                     $verif=false;
  419.                 }
  420.                 if(strlen($erreur)==0)
  421.                 {
  422.                     if($id!=52)
  423.                     {
  424.                         $erreur"Erreur lors de l'inscription";
  425.                     }else
  426.                     {
  427.                         $repository $doctrine->getRepository(EvenementFormulaire::class);
  428.                         $p $repository->findBy(
  429.                           ['phone' => $article->getPhone(),
  430.                           'evenement'=>52]  
  431.                   );
  432.                   $repository $doctrine->getRepository(EvenementFormulaire::class);
  433.                 
  434.                   $pp $repository->findBy(
  435.                     [
  436.                         'nom' => $article->getNom(),
  437.                         'prenom' => $article->getPrenom(),
  438.                         'evenement'=>52
  439.                         
  440.                     ]
  441.                 );
  442.                         if(count($p)>|| count($pp)>0)
  443.                         {
  444.                         $erreur.= "Vous êtes déjà inscrit à un événement.";
  445.                         }
  446.                         else
  447.                         {
  448.                             $repository $doctrine->getRepository(EvenementFormulaire::class);
  449.                             $evenements $repository->findBy(['evenement' => 52]);
  450.                             $count=0;
  451.                           
  452.                            
  453.                            
  454.                                 $repository $doctrine->getRepository(ConnexionUser::class);
  455.                                 $user $repository->findOneBy(['email' => $session->get('email')]);
  456.                                     
  457.                                 
  458.                              
  459.                                 $session $this->requestStack->getSession();
  460.                                 $session->set('emailSend',$article->getEmail());
  461.                                 $session->set('fonction',$article->getFonction());
  462.                                 $session->set('type',$article->getType());
  463.                                 $session->set('nom',$article->getNom());
  464.                                 $session->set('prenom',$article->getPrenom());
  465.                                 $session->set('phone',$article->getPhone());
  466.                       
  467.                                 return  new RedirectResponse("/evenement/autre/detail/52/register/"); 
  468.                               
  469.                             
  470.                          
  471.             
  472.                         }
  473.                     }
  474.                 
  475.                  /* $entityManager->persist($article);
  476.                   $entityManager->flush();*/
  477.                 }
  478.                 
  479.                 
  480.                 }
  481.                 
  482.         return $this->render('formulaireevenement/formulaire.html.twig', array(
  483.             'form' => $form->createView(),'erreur'=>$erreur,'message'=>$messageSuccess,'id'=>$id
  484.         ));
  485.     }
  486.     public function formulaireEvenementPost()
  487.     {
  488.         echo "hello";exit();
  489.     }
  490.     public function formulaireEvenementCongreDeuxType(ManagerRegistry $doctrine,Request $request)
  491.     {
  492.        
  493.         $type=$_POST['id'];
  494.         if($type==|| $type==2)
  495.         {
  496.             $session $this->requestStack->getSession();
  497.             $session->set('typesendpaiment'$type);
  498.         }
  499.         $erreur="";
  500.         $messageSuccess="1";
  501.                 $err='{"erreur": "'.$erreur.'", "message":"'.$messageSuccess.'"}';
  502.         echo $err;exit();
  503.       
  504.     }
  505.     public function programme()
  506.     {
  507.         return $this->redirect('https://programme.astp.tn/login');
  508.     }
  509.     public function programmePdf($id)
  510.     {
  511.             if($id=='-18.pdf' || $id=='18-35.pdf' || $id='+35.pdf')
  512.             {
  513.                 return $this->render('document/afficher_pdf.html.twig', array(
  514.                     'id'=>$id
  515.                 ));
  516.             }else {
  517.             }
  518.     }
  519.   
  520. }