src/Controller/AdminController.php line 454

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Form\Type\BFFestivalandEditionType;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use App\Entity\BFChallenge;
  9. use App\Entity\BFChallengeEdition;
  10. use App\Entity\BFFestival;
  11. use App\Entity\BFEdition;
  12. use App\Entity\BFTournoi;
  13. use App\Entity\BFSeance;
  14. use App\Entity\BFUser;
  15. use App\Entity\BFResetPassword;
  16. use App\Entity\BFAdminLicences;
  17. use App\Entity\BFRouting;
  18. use App\Entity\BFSubscription;
  19. use App\Entity\BFMailChallenge;
  20. use App\Entity\BFMailFestival;
  21. use App\Entity\BFMailTournoi;
  22. use App\Entity\BFProductEdition;
  23. use App\Form\Type\BFChallengeType;
  24. use App\Form\Type\BFChallengeEditionType;
  25. use App\Form\Type\BFFestivalType;
  26. use App\Form\Type\BFFestivalOwnerType;
  27. use App\Form\Type\BFFestivalAdministratorAddType;
  28. use App\Form\Type\BFFestivalAdministratorRemoveType;
  29. use App\Form\Type\BFEditionType;
  30. use App\Form\Type\BFTournoiType
  31. use App\Form\Type\BFTournoiWithTypeType;
  32. use App\Form\Type\BFSeanceType;
  33. use App\Form\Type\BFUserDescriptionType;
  34. use App\Form\Type\BFDescriptionEditionImagesType;
  35. use App\Form\Type\BFDescriptionFestivalType;
  36. use App\Form\Type\BFDescriptionChallengeType;
  37. use App\Form\Type\ModifyPasswordType;
  38. use App\Form\Type\ModifyEmailType;
  39. use App\Form\Type\AskPasswordType;
  40. use App\Form\Type\RoutingType;
  41. use App\Form\Type\BFMailFestivalType;
  42. use App\Form\Type\BFMailTournoiType;
  43. use App\Form\Type\BFChallengeAddFestivalType;
  44. use App\Form\Type\BFProductEditionType;
  45. use App\Form\Type\FestivalFeeType;
  46. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  47. use Symfony\Component\Form\FormError;
  48. use Symfony\Component\Validator\Validator\ValidatorInterface;
  49. use App\Utilities\Mail;
  50. use Stripe\Stripe;
  51. use Stripe\StripeClient;
  52. use Stripe\StripeAccount;
  53. class AdminController extends AbstractController
  54. {
  55.     
  56.     /**
  57.     * @Route("/admin/festival-{id}", name="admin_festival")
  58.     */
  59.     public function ShowAdminFestival(int $id,ValidatorInterface $validatorRequest $request)
  60.     {
  61.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  62.         
  63.         $festival $this->getDoctrine()
  64.              ->getRepository(BFFestival::class)
  65.              ->find($id);
  66.         
  67.         $this->denyAccessUnlessGranted('edit'$festival);
  68.         
  69.         $user=$this->getUser();
  70.         
  71.         //formdescrition
  72.         $formeditfestival $this->createForm(BFFestivalType::class, $festival,[
  73.             'submit_label' => 'Editer',
  74.         ]);
  75.         
  76.         $formeditfestival->handleRequest($request);
  77.         if ($formeditfestival->isSubmitted() && $formeditfestival->isValid()) {
  78.             // $form->getData() holds the submitted values
  79.             // but, the original `$task` variable has also been updated
  80.             $festival $formeditfestival->getData();
  81.                         
  82.             $errors $validator->validate($festival);
  83.             if(count($errors)>0)
  84.             {
  85.                 foreach($errors as $error)
  86.                 {
  87.                     $this->addFlash('danger'$error->toString());
  88.                 }
  89.             }
  90.             else
  91.             {
  92.                 // ... perform some action, such as saving the task to the database
  93.                 // for example, if Task is a Doctrine entity, save it!
  94.                 $entityManager $this->getDoctrine()->getManager();
  95.                 $entityManager->persist($festival);
  96.                 $entityManager->flush();
  97.                 $this->addFlash('success''Les modifications sont enregistrées');
  98.             }
  99.             
  100.             return $this->redirect($request->getUri());
  101.         }
  102.         if($formeditfestival->isSubmitted() && !$formeditfestival->isValid())
  103.         {
  104.             foreach($formeditfestival->getErrors(true) as $error)
  105.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  106.             return $this->redirect($request->getUri());
  107.         }
  108.         
  109.         
  110.         //formowner
  111.         $emailvalue $festival->getOwner()!=null $festival->getOwner()->getEmail() : "";
  112.         $formfestivalowner $this->createForm(BFFestivalOwnerType::class, null, [
  113.             'email_value' => $emailvalue ,
  114.         ]);
  115.         
  116.         $formfestivalowner->handleRequest($request);
  117.         if ($formfestivalowner->isSubmitted() && $formfestivalowner->isValid()) {
  118.             $this->denyAccessUnlessGranted('delete'$festival);
  119.             // $form->getData() holds the submitted values
  120.             // but, the original `$task` variable has also been updated
  121.             $email $formfestivalowner->getData()['email'];
  122.             
  123.             if($email==null)
  124.             {
  125.                 $festival->setOwner(null);
  126.                 $entityManager $this->getDoctrine()->getManager();
  127.                 $entityManager->persist($festival);
  128.                 $entityManager->flush();
  129.                 
  130.                 $this->addFlash('primary''Le propriétaire du festival a été modifié');
  131.             }
  132.             else
  133.             {
  134.                 //getuser from email
  135.                 $owneruser =$this->getDoctrine()
  136.                 ->getRepository(BFUser::class)
  137.                 ->findOneBy(['email'=>$email]);
  138.                 if($owneruser!=null)
  139.                 {
  140.                     $festival->setOwner($owneruser);
  141.                     $entityManager $this->getDoctrine()->getManager();
  142.                     $entityManager->persist($festival);
  143.                     $entityManager->flush();
  144.                     
  145.                     $this->addFlash('primary''Le propriétaire du festival a été modifié');
  146.                 }
  147.                 else
  148.                 {
  149.                     $this->addFlash('danger''L\'adresse email est inconnue');
  150.                 }
  151.             }
  152.             return $this->redirect($request->getUri());
  153.         }
  154.         if($formfestivalowner->isSubmitted() && !$formfestivalowner->isValid())
  155.         {
  156.             foreach($formfestivalowner->getErrors(true) as $error)
  157.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  158.             return $this->redirect($request->getUri());
  159.         }
  160.         
  161.         //formaddadministrator
  162.         $formfestivaladministratoradd $this->createForm(BFFestivalAdministratorAddType::class, null, [
  163.         ]);
  164.         
  165.         $formfestivaladministratoradd->handleRequest($request);
  166.         if ($formfestivaladministratoradd->isSubmitted() && $formfestivaladministratoradd->isValid()) {
  167.             $this->denyAccessUnlessGranted('delete'$festival);
  168.             // $form->getData() holds the submitted values
  169.             // but, the original `$task` variable has also been updated
  170.             $email $formfestivaladministratoradd->getData()['email'];
  171.             
  172.             //getuser from email
  173.             $adminuser =$this->getDoctrine()
  174.             ->getRepository(BFUser::class)
  175.             ->findOneBy(['email'=>$email]);
  176.             
  177.             if($adminuser!=null)
  178.             {
  179.                 $festival->addAdministrator($adminuser);
  180.                 
  181.                 $entityManager $this->getDoctrine()->getManager();
  182.                 $entityManager->persist($festival);
  183.                 $entityManager->flush();
  184.                 
  185.                 $this->addFlash('primary''L\'administrateur a été ajouté');
  186.                 
  187.                 return $this->redirect($request->getUri());
  188.             }
  189.             else
  190.             {
  191.                 $this->addFlash('danger''L\'adresse email est inconnue');
  192.             }
  193.         }
  194.         if($formfestivaladministratoradd->isSubmitted() && !$formfestivaladministratoradd->isValid())
  195.         {
  196.             foreach($formfestivaladministratoradd->getErrors(true) as $error)
  197.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  198.             return $this->redirect($request->getUri());
  199.         }
  200.         
  201.         //formremoveadministrator
  202.         $formfestivaladministratorremove $this->createForm(BFFestivalAdministratorRemoveType::class, null, ['festival'=>$festival]);
  203.         
  204.         $formfestivaladministratorremove->handleRequest($request);
  205.         if ($formfestivaladministratorremove->isSubmitted() && $formfestivaladministratorremove->isValid()) {
  206.             $this->denyAccessUnlessGranted('delete'$festival);
  207.             
  208.             // $form->getData() holds the submitted values
  209.             // but, the original `$task` variable has also been updated
  210.             $administratorid $formfestivaladministratorremove->getData()['administratorstodelete'];
  211.             
  212.             $adminuser=null;
  213.             if($administratorid!=null)
  214.             {
  215.                 $adminuser =$this->getDoctrine()->getRepository(BFUser::class)->find($administratorid);
  216.             }
  217.             
  218.             if($adminuser!=null)
  219.             {
  220.                 $festival->removeAdministrator($adminuser);
  221.                 $entityManager $this->getDoctrine()->getManager();
  222.                 $entityManager->persist($festival);
  223.                 $entityManager->flush();
  224.                 
  225.                 $this->addFlash('primary''L\'administrateur a été envelé');
  226.                 
  227.                 return $this->redirect($request->getUri());
  228.             }
  229.         }
  230.         if($formfestivaladministratorremove->isSubmitted() && !$formfestivaladministratorremove->isValid())
  231.         {
  232.             foreach($formfestivaladministratorremove->getErrors(true) as $error)
  233.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  234.             return $this->redirect($request->getUri());
  235.         }
  236.         
  237.         //formrouting
  238.         $bfrouting $festival->getRoute();
  239.         if($bfrouting==null)
  240.             $bfrouting= new BFRouting();
  241.         
  242.         $formrouting $this->createForm(RoutingType::class, $bfrouting);
  243.         $formrouting->handleRequest($request);
  244.         if ($formrouting->isSubmitted() && $formrouting->isValid()) {
  245.             $this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');
  246.             $this->denyAccessUnlessGranted('option_uniqueurl_festival'$festival);
  247.             
  248.             $bfrouting $formrouting->getData();
  249.             
  250.             $entityManager $this->getDoctrine()->getManager();
  251.             if($festival->getRoute()==null)
  252.             {
  253.                 $festival->setRoute($bfrouting);
  254.                 $entityManager->persist($bfrouting);
  255.                 $entityManager->persist($festival);
  256.             }
  257.             else
  258.             {
  259.                 $entityManager->persist($bfrouting);
  260.             }
  261.             
  262.             $entityManager->flush();
  263.             
  264.             $this->addFlash('primary''La route a été enregistrée');
  265.             
  266.             return $this->redirect($request->getUri());
  267.         }
  268.         if($formrouting->isSubmitted() && !$formrouting->isValid())
  269.         {
  270.             foreach($formrouting->getErrors(true) as $error)
  271.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  272.             return $this->redirect($request->getUri());
  273.         }
  274.         
  275.         //form orderfeebf
  276.          $formfeefestival $this->createForm(FestivalFeeType::class, $festival,[
  277.             
  278.         ]);
  279.         
  280.         $formfeefestival->handleRequest($request);
  281.         if ($formfeefestival->isSubmitted() && $formfeefestival->isValid()) {
  282.             // $form->getData() holds the submitted values
  283.             // but, the original `$task` variable has also been updated
  284.             $festival $formfeefestival->getData();
  285.                         
  286.             $errors $validator->validate($festival);
  287.             if(count($errors)>0)
  288.             {
  289.                 foreach($errors as $error)
  290.                 {
  291.                     $this->addFlash('danger'$error->toString());
  292.                 }
  293.             }
  294.             else
  295.             {
  296.                 // ... perform some action, such as saving the task to the database
  297.                 // for example, if Task is a Doctrine entity, save it!
  298.                 $entityManager $this->getDoctrine()->getManager();
  299.                 $entityManager->persist($festival);
  300.                 $entityManager->flush();
  301.                 $this->addFlash('success''La commission a été changée');
  302.             }
  303.             
  304.             return $this->redirect($request->getUri());
  305.         }
  306.         if($formeditfestival->isSubmitted() && !$formeditfestival->isValid())
  307.         {
  308.             foreach($formeditfestival->getErrors(true) as $error)
  309.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  310.             return $this->redirect($request->getUri());
  311.         }
  312.         
  313.         
  314.         //offers and option list
  315.         $bfadminlicences $this->getDoctrine()->getRepository(BFAdminLicences::class)->findAllByFestival($festival);
  316.         
  317.                 
  318.         return $this->render('adminfestival.html.twig', [
  319.             'userdescription' => $user->getDescription(),
  320.             'formbffestivaledit' => $formeditfestival->createView(),
  321.             'formbffestivalowner' => $formfestivalowner->createView(),
  322.             'formbffestivaladminadd' => $formfestivaladministratoradd->createView(),
  323.             'formbffestivaladminremove' => $formfestivaladministratorremove->createView(),
  324.             'formbffestivalorderfee' => $formfeefestival->createView(),
  325.             'formrouting' =>$formrouting->createView(),
  326.             'bffestival' => $festival,
  327.             'bfadminlicences' => $bfadminlicences,
  328.             'activefestivalid' => $id,
  329.             'stripeaccountvalid' => $this->isGranted('canpay'$festival),
  330.         ]);
  331.     }
  332.     
  333.     /**
  334.     * @Route("/admin/festival-{id}/subscriptions", name="admin_festival_subscriptions")
  335.     */
  336.     public function ShowAdminFestivalSubscriptions(int $idRequest $request)
  337.     {
  338.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  339.         
  340.         $festival $this->getDoctrine()
  341.              ->getRepository(BFFestival::class)
  342.              ->find($id);
  343.         
  344.         $this->denyAccessUnlessGranted('edit'$festival);
  345.         
  346.         $user=$this->getUser();
  347.         
  348.         //countsubscribers
  349.         $subscriptions $this->getDoctrine()->getRepository(BFSubscription::class)->FindBy(['festival'=>$festival]);
  350.         
  351.         //formsendmail
  352.         $bfmailfestival = new BFMailFestival();
  353.         
  354.         $formsendmail $this->createForm(BFMailFestivalType::class, $bfmailfestival);
  355.         $formsendmail->handleRequest($request);
  356.         if ($formsendmail->isSubmitted() && $formsendmail->isValid()) {
  357.             // $form->getData() holds the submitted values
  358.             // but, the original `$task` variable has also been updated
  359.             $bfmailfestival $formsendmail->getData();
  360.                         
  361.             $bfmailfestival->setFestival($festival);
  362.             $bfmailfestival->setSubscribercount(count($subscriptions));
  363.             $bfmailfestival->setSenddate(new \DateTime('now'));
  364.             
  365.             $em =$this->getDoctrine()->getManager();
  366.             $em->persist($bfmailfestival);
  367.             $em->flush();
  368.             
  369.             $txtmessage $bfmailfestival->getText();
  370.             $subject $bfmailfestival->getSubject();
  371.             
  372.             $sendedmail=0;
  373.             
  374.             if($bfmailfestival->getIsadmin())
  375.             {
  376.                 $admins $festival->getAdministrators()->getValues();
  377.                 $owner $festival->getOwner();
  378.                 if($owner!=null)
  379.                 {
  380.                     array_push($admins$owner);
  381.                 }
  382.                 if(count($admins)==0)
  383.                 {
  384.                     $userrepository =$this->getDoctrine()->getRepository(BFUser::class);
  385.                     array_push($admins$userrepository->findByRole('ROLE_SUPER_ADMIN'));
  386.                 }
  387.                 
  388.                 $htmlmessage $this->renderView('mail/festivalmail.html.twig', [
  389.                         'subject' => $subject,
  390.                         'message' => $txtmessage,
  391.                         'festival' => $festival,
  392.                         'mailfestival' => $bfmailfestival,
  393.                         'subscriptionid' => 0,
  394.                         'attachmentname' => $bfmailfestival->getAttachmentfiletitle()? $bfmailfestival->getAttachmentfiletitle() : $bfmailfestival->getAttachmentfile(),
  395.                     ]);
  396.                 if(Mail::SendMailToBFUsers($admins$owner->getEmail(), $subject$htmlmessage$txtmessage))
  397.                     $this->addFlash('primary''Le mail de test a été envoyé à '.count($admins).' administrateurs');
  398.                 else
  399.                     $this->addFlash('danger''Impossible d\'envoyer le mail aux administrateurs ');
  400.             }
  401.             else
  402.             {
  403.                 foreach($subscriptions as $subscription)
  404.                 {
  405.                     $htmlmessage $this->renderView('mail/festivalmail.html.twig', [
  406.                         'subject' => $subject,
  407.                         'message' => $txtmessage,
  408.                         'festival' => $festival,
  409.                         'mailfestival' => $bfmailfestival,
  410.                         'subscriptionid' => $subscription->getId(),
  411.                         'attachmentname' => $bfmailfestival->getAttachmentfiletitle()? $bfmailfestival->getAttachmentfiletitle() : $bfmailfestival->getAttachmentfile(),
  412.                     ]);
  413.                     if(Mail::SendMailToBFUser($subscription->getUser(), $festival->getOwner()->getEmail(), $subject$htmlmessage$txtmessage))
  414.                         $sendedmail++;
  415.                 }
  416.                 $this->addFlash('primary''Le mail a été envoyé à '.$sendedmail.' destinataires');
  417.             }
  418.             
  419.             return $this->redirect($request->getUri());
  420.         }
  421.      
  422.         //get sendmail list
  423.         $sendmails $this->getDoctrine()->getRepository(BFMailFestival::class)->findBy(['festival'=>$festival], ['senddate'=>'DESC']);
  424.         
  425.         return $this->render('adminfestivalsubscriptions.html.twig', [
  426.             'userdescription' => $user->getDescription(),
  427.             'bffestival' => $festival,
  428.             'activefestivalid' => $id,
  429.             'countsubscription' => count($subscriptions),
  430.             'formsendmail' => $formsendmail->createView(),
  431.             'sendmails' => $sendmails,
  432.         ]);
  433.     }
  434.     
  435.     /**
  436.     * @Route("/admin/festival/create", name="admin_festival_create")
  437.     */
  438.     public function CreateAdminFestival(Request $request)
  439.     {
  440.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  441.         $user $this->getUser() ;
  442.         
  443.         $create = new BFFestival();
  444.         $createedition = new BFEdition();
  445.         $createedition->setFestival($create);
  446.         
  447.         $formbffestivalcreate $this->createForm(BFFestivalandEditionType::class, $createedition, [
  448.         ]);
  449.         
  450.         $formbffestivalcreate->handleRequest($request);
  451.         if ($formbffestivalcreate->isSubmitted() && $formbffestivalcreate->isValid()) {
  452.             // $form->getData() holds the submitted values
  453.             // but, the original `$task` variable has also been updated
  454.             $edition $formbffestivalcreate->getData();
  455.             $festival=$edition->getFestival();
  456.             if(!in_array("ROLE_SUPER_ADMIN",$user->getRoles()))
  457.                 $festival->setOwner($user);
  458.             // ... perform some action, such as saving the task to the database
  459.             // for example, if Task is a Doctrine entity, save it!
  460.             $entityManager $this->getDoctrine()->getManager();
  461.             $entityManager->persist($edition);
  462.             $entityManager->flush();
  463.             
  464.             $this->addFlash('primary''Le festival et l\'édition ont été créés');
  465.             if($edition->getIsactive())
  466.             {
  467.                 $this->addFlash('success''L\'édition est publiée');
  468.             }
  469.             return $this->redirectToRoute('admin_festival',[
  470.                 'id'=>$festival->getId(),
  471.             ]);
  472.         }
  473.         if($formbffestivalcreate->isSubmitted() && !$formbffestivalcreate->isValid())
  474.         {
  475.             foreach($formbffestivalcreate->getErrors(true) as $error)
  476.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  477.             $formbffestivalcreate->clearErrors(true);
  478.         }
  479.         
  480.         return $this->render('adminfestivalcreate.html.twig', [
  481.             'userdescription' => $user->getDescription(),
  482.             'formbffestivalcreate' => $formbffestivalcreate->createView(),
  483.             'uuid' => uniqid(),
  484.         ]);
  485.     }
  486.     
  487.     /**
  488.     * @Route("/admin/festival-{id}/edition-{idedition}", name="admin_edition")
  489.     */
  490.     public function ShowAdminEdition(int $idint $ideditionRequest $request)
  491.     {
  492.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  493.         
  494.         $edition $this->getDoctrine()
  495.             ->getRepository(BFEdition::class)
  496.             ->find($idedition);
  497.         
  498.         $festival $edition->getFestival();
  499.         
  500.         $this->denyAccessUnlessGranted('edit'$festival);
  501.         
  502.         $user$this->getUser();
  503.         
  504.         //edit about form
  505.         $formbfeditionedit $this->createForm(BFEditionType::class, $edition,[
  506.             'submit_label' => 'Editer',
  507.         ]);
  508.         
  509.         $formbfeditionedit->handleRequest($request);
  510.         if ($formbfeditionedit->isSubmitted() && $formbfeditionedit->isValid()) {
  511.             $this->denyAccessUnlessGranted('edit'$festival);
  512.             // $form->getData() holds the submitted values
  513.             // but, the original `$task` variable has also been updated
  514.             $edition $formbfeditionedit->getData();
  515.             
  516.             $edition->CleanLocation();
  517.             
  518.             // ... perform some action, such as saving the task to the database
  519.             // for example, if Task is a Doctrine entity, save it!
  520.             $entityManager $this->getDoctrine()->getManager();
  521.             $entityManager->persist($edition);
  522.             $entityManager->flush();
  523.             
  524.             $this->addFlash('success''Les modifications sont enregistrées');
  525.             
  526.             return $this->redirect($request->getUri());
  527.         }
  528.         if($formbfeditionedit->isSubmitted() && !$formbfeditionedit->isValid())
  529.         {
  530.             foreach($formbfeditionedit->getErrors(true) as $error)
  531.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  532.             return $this->redirect($request->getUri());
  533.         }
  534.         
  535.         //edit images form
  536.         $formbfeditionimagesedit $this->createForm(BFDescriptionEditionImagesType::class, $edition->getDescription(),[
  537.         ]);
  538.         
  539.         $formbfeditionimagesedit->handleRequest($request);
  540.         if ($formbfeditionimagesedit->isSubmitted() && $formbfeditionimagesedit->isValid()) {
  541.             $this->denyAccessUnlessGranted('edit'$festival);
  542.             // $form->getData() holds the submitted values
  543.             // but, the original `$task` variable has also been updated
  544.             $description $formbfeditionimagesedit->getData();
  545.             
  546.             $edition$description->getBfedition();
  547.             // ... perform some action, such as saving the task to the database
  548.             // for example, if Task is a Doctrine entity, save it!
  549.             $entityManager $this->getDoctrine()->getManager();
  550.             $entityManager->persist($edition);
  551.             $entityManager->flush();
  552.             
  553.             $this->addFlash('success''Les modifications sont enregistrées');
  554.             
  555.             return $this->redirect($request->getUri());
  556.         }
  557.         if($formbfeditionimagesedit->isSubmitted() && !$formbfeditionimagesedit->isValid())
  558.         {
  559.             foreach($formbfeditionimagesedit->getErrors(true) as $error)
  560.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  561.             return $this->redirect($request->getUri());
  562.         }
  563.         
  564.         //formrouting
  565.         $bfrouting $edition->getRoute();
  566.         if($bfrouting==null)
  567.             $bfrouting= new BFRouting();
  568.         
  569.         $formrouting $this->createForm(RoutingType::class, $bfrouting);
  570.         $formrouting->handleRequest($request);
  571.         if ($formrouting->isSubmitted() && $formrouting->isValid()) {
  572.             $this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');
  573.             $this->denyAccessUnlessGranted('option_uniqueurl_edition'$edition);
  574.             
  575.             $bfrouting $formrouting->getData();
  576.             
  577.             $entityManager $this->getDoctrine()->getManager();
  578.             if($edition->getRoute()==null)
  579.             {
  580.                 $edition->setRoute($bfrouting);
  581.                 $entityManager->persist($bfrouting);
  582.                 $entityManager->persist($edition);
  583.             }
  584.             else
  585.             {
  586.                 $entityManager->persist($bfrouting);
  587.             }
  588.             
  589.             $entityManager->flush();
  590.             
  591.             $this->addFlash('primary''La route a été enregistrée');
  592.             
  593.             return $this->redirect($request->getUri());
  594.         }
  595.         if($formrouting->isSubmitted() && !$formrouting->isValid())
  596.         {
  597.             foreach($formrouting->getErrors(true) as $error)
  598.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  599.             return $this->redirect($request->getUri());
  600.         }
  601.         
  602.         
  603.         return $this->render('adminedition.html.twig', [
  604.             'userdescription' => $user->getDescription(),
  605.             'formbfeditionedit' => $formbfeditionedit->createView(),
  606.             'formbfeditionimagesedit' => $formbfeditionimagesedit->createView(),
  607.             'formrouting' => $formrouting->createView(),
  608.             'activefestivalid' => $id,
  609.             'editionid' => $idedition,
  610.             'bfedition' => $edition,
  611.             'uuid' => uniqid(),
  612.         ]);
  613.     }
  614.     
  615.     /**
  616.     * @Route("/admin/festival-{id}/edition/create", name="admin_edition_create")
  617.     */
  618.     public function CreateAdminEdition(int $idRequest $request)
  619.     {
  620.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  621.         
  622.         //get festival
  623.         $festival $this->getDoctrine()->getRepository(BFFestival::class)->find($id);
  624.         
  625.         $this->denyAccessUnlessGranted('edit'$festival);
  626.         
  627.         $user=$this->getUser();
  628.         
  629.         $create = new BFEdition();
  630.         $create->setFestival($festival);
  631.         
  632.         $formbfeditioncreate $this->createForm(BFEditionType::class, $create,[
  633.             ]);
  634.         
  635.         $formbfeditioncreate->handleRequest($request);
  636.         if ($formbfeditioncreate->isSubmitted() && $formbfeditioncreate->isValid()) {
  637.             // $form->getData() holds the submitted values
  638.             // but, the original `$task` variable has also been updated
  639.             $edition $formbfeditioncreate->getData();
  640.             $edition->setIsactive(false);
  641.             
  642.             $edition->CleanLocation();
  643.             // ... perform some action, such as saving the task to the database
  644.             // for example, if Task is a Doctrine entity, save it!
  645.             $entityManager $this->getDoctrine()->getManager();
  646.             $entityManager->persist($edition);
  647.             $entityManager->flush();
  648.             
  649.             $this->addFlash('primary''L\'édition est créée');
  650.             return $this->redirectToRoute('admin_edition',[
  651.                 'id' => $edition->getFestival()->getId(),
  652.                 'idedition'=>$edition->getId(),
  653.             ]);
  654.         }
  655.         if($formbfeditioncreate->isSubmitted() && !$formbfeditioncreate->isValid())
  656.         {
  657.             foreach($formbfeditioncreate->getErrors(true) as $error)
  658.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  659.             $formbfeditioncreate->clearErrors(true);
  660.         }
  661.         
  662.         return $this->render('admineditioncreate.html.twig', [
  663.             'userdescription' => $user->getDescription(),
  664.             'formbfeditioncreate' => $formbfeditioncreate->createView(),
  665.             'activefestivalid' => $id,
  666.             'bffestival' => $festival,
  667.             'uuid' => uniqid(),
  668.         ]);
  669.     }
  670.     
  671.     /**
  672.     * @Route("/admin/festival-{id}/edition-{idedition}/tournois", name="admin_edition_tournois")
  673.     */
  674.     public function ShowAdminEditionTournois(int $idint $idedition)
  675.     {
  676.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  677.         
  678.         $user=$this->getUser();
  679.         
  680.         $edition $this->getDoctrine()->getRepository(BFEdition::class)->find($idedition);
  681.         
  682.         return $this->render('admineditiontournois.html.twig', [
  683.             'userdescription' => $user->getDescription(),
  684.             'activefestivalid' => $id,
  685.             'editionid' => $idedition,
  686.             'tournoiid' => 0,
  687.             'bfedition' => $edition,
  688.         ]);
  689.     }
  690.     
  691.     /**
  692.     * @Route("/admin/festival-{id}/edition-{idedition}/tournoi-{idtournoi}", name="admin_edition_tournoiid")
  693.     */
  694.     public function ShowAdminEditionTournoisById(int $idint $ideditionint $idtournoi)
  695.     {
  696.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  697.         
  698.         $user=$this->getUser();
  699.         
  700.         $edition $this->getDoctrine()->getRepository(BFEdition::class)->find($idedition);
  701.         
  702.         return $this->render('admineditiontournois.html.twig', [
  703.             'userdescription' => $user->getDescription(),
  704.             'activefestivalid' => $id,
  705.             'editionid' => $idedition,
  706.             'tournoiid' => $idtournoi,
  707.             'bfedition' => $edition,
  708.         ]);
  709.     }
  710.     
  711.     /**
  712.     * @Route("/admin/festival-{id}/edition-{idedition}/inscriptions", name="admin_edition_inscriptions")
  713.     */
  714.     public function ShowAdminEditionInscriptions(int $idint $idedition)
  715.     {
  716.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  717.         
  718.         $user=$this->getUser();
  719.         
  720.         $edition $this->getDoctrine()->getRepository(BFEdition::class)->find($idedition);
  721.         
  722.         return $this->render('admineditioninscriptions.html.twig', [
  723.             'userdescription' => $user->getDescription(),
  724.             'activefestivalid' => $id,
  725.             'editionid' => $idedition,
  726.             'editionidins' => 0,
  727.             'bfedition' => $edition,
  728.         ]); 
  729.     }
  730.     
  731.     /**
  732.     * @Route("/admin/festival-{id}/edition-{idedition}/inscriptions/contact", name="admin_edition_inscriptions_contact")
  733.     */
  734.     public function ShowAdminEditionInscriptionsContact(int $idint $ideditionRequest $request)
  735.     {
  736.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  737.         
  738.         $bfedition $this->getDoctrine()->getRepository(BFEdition::class)->find($idedition);
  739.         $festival $bfedition->getFestival();
  740.         $user=$this->getUser();
  741.         
  742.         if($bfedition==null) return null;
  743.         
  744.         $bfmailtournoi = new BFMailTournoi();
  745.         
  746.         //form contact
  747.         $formsendmail $this->createForm(BFMailTournoiType::class, $bfmailtournoi,[
  748.             'edition' => $bfedition,
  749.         ]);
  750.         $formsendmail->handleRequest($request);
  751.         if ($formsendmail->isSubmitted() && $formsendmail->isValid()) {
  752.             $bfmailtournoi $formsendmail->getData();
  753.             
  754.             $bfinscriptions $bfmailtournoi->getTournoi()->getInscriptions();
  755.             
  756.             $emails = array();
  757.             if($bfmailtournoi->getIsadmin())
  758.             {
  759.                 $admins $festival->getAdministrators()->getValues();
  760.                 $owner $festival->getOwner();
  761.                 if($owner!=null)
  762.                 {
  763.                     array_push($admins$owner);
  764.                 }
  765.                 
  766.                 foreach($admins as $admin)
  767.                 {
  768.                     array_push($emails$admin->getEmail());
  769.                 }
  770.                 
  771.             }
  772.             else
  773.             {
  774.                 foreach($bfinscriptions as $bfinscription)
  775.                 {
  776.                     $inscriptionusers $bfinscription->getAllInscriptionUser();
  777.                     foreach($inscriptionusers as $inscriptionuser)
  778.                     {
  779.                         if($inscriptionuser->getEmail()!=null)
  780.                             array_push($emails$inscriptionuser->getEmail());
  781.                     }
  782.                 }
  783.             }
  784.             
  785.             $bfmailtournoi->setSenddate(new \DateTime('now'));
  786.             
  787.             $bfmailtournoi->setReceivercount(count($emails));
  788.             
  789.             $em =$this->getDoctrine()->getManager();
  790.             $em->persist($bfmailtournoi);
  791.             $em->flush();
  792.             
  793.             $txtmessage $bfmailtournoi->getText();
  794.             $subject $bfmailtournoi->getSubject();
  795.             
  796.             $sendedmail=0;
  797.             foreach($emails as $email)
  798.             {
  799.                 $isuser $this->getDoctrine()->getRepository(BFUser::class)->findOneBy(['email'=>$email])!=null;
  800.                 $htmlmessage $this->renderView('mail/tournoimail.html.twig', [
  801.                     'subject' => $subject,
  802.                     'message' => $txtmessage,
  803.                     'festival' => $festival,
  804.                     'mailfestival' => $bfmailtournoi,
  805.                     'isuser' => $isuser,
  806.                     'email' => $email,
  807.                     'attachmentname' => $bfmailtournoi->getAttachmentfiletitle()? $bfmailtournoi->getAttachmentfiletitle() : $bfmailtournoi->getAttachmentfile(),
  808.                 ]);
  809.                 
  810.                 if($festival->getOwner()!=null)
  811.                 {
  812.                     if(Mail::SendMailToMailWithFrom($email$festival->getOwner()->getEmail(), $subject$htmlmessage$txtmessage))
  813.                         $sendedmail++;
  814.                 }
  815.                 else
  816.                 {
  817.                     if(Mail::SendMailToMail($email$subject$htmlmessage$txtmessage))
  818.                         $sendedmail++;
  819.                 }
  820.             }
  821.             $this->addFlash('primary''Le mail a été envoyé à '.$sendedmail.' destinataires');
  822.             
  823.             if($sendedmail!=count($emails))
  824.             {
  825.                 $bfmailtournoi->setReceivercount($sendedmail);
  826.                 $em->persist($bfmailtournoi);
  827.                 $em->flush();
  828.             }
  829.             
  830.             return $this->redirect($request->getUri());
  831.         }
  832.         
  833.         $sendmails=$this->getDoctrine()->getRepository(BFMailTournoi::class)->findByEdition($bfedition);
  834.         
  835.         return $this->render('admineditioninscriptionscontact.html.twig', [
  836.             'userdescription' => $user->getDescription(),
  837.             'activefestivalid' => $id,
  838.             'editionid' => $idedition,
  839.             'editionidins' => 1,
  840.             'bfedition' => $bfedition,
  841.             'formsendmail' => $formsendmail->createView(),
  842.             'sendmails' => $sendmails,
  843.         ]);
  844.     }
  845.     
  846.     /**
  847.     * @Route("/admin/festival-{id}/edition-{idedition}/tournois/create", name="admin_tournoi_create")
  848.     */
  849.     public function CreateAdminTournoi(int $idint $ideditionRequest $request)
  850.     {
  851.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  852.         
  853.         $create = new BFTournoi();
  854.         $edition $this->getDoctrine()->getRepository(BFEdition::class)->find($idedition);
  855.         
  856.         $festival $edition->getFestival();
  857.         
  858.         $this->denyAccessUnlessGranted('edit'$festival);
  859.         
  860.         $user=$this->getUser();
  861.         
  862.         $create->setEdition($edition);
  863.         
  864.         if($this->isGranted('option_inscription'$edition))
  865.         {
  866.             $formbftournoicreate $this->createForm(BFTournoiWithTypeType::class, $create, [
  867.             ]);
  868.         }
  869.         else
  870.         {
  871.             $formbftournoicreate $this->createForm(BFTournoiType::class, $create, [
  872.             ]);
  873.         }
  874.         
  875.         $formbftournoicreate->handleRequest($request);
  876.         if ($formbftournoicreate->isSubmitted() && $formbftournoicreate->isValid()) {
  877.             // $form->getData() holds the submitted values
  878.             // but, the original `$task` variable has also been updated
  879.             $tournoi $formbftournoicreate->getData();
  880.             // ... perform some action, such as saving the task to the database
  881.             // for example, if Task is a Doctrine entity, save it!
  882.             $entityManager $this->getDoctrine()->getManager();
  883.             $entityManager->persist($tournoi);
  884.             $entityManager->flush();
  885.             $edition $tournoi->getEdition();
  886.             $festival $edition->getFestival();
  887.             
  888.             $this->addFlash('primary''Le tournoi est créé');
  889.             return $this->redirectToRoute('admin_edition_tournoiid',[
  890.                 'id'=>$festival->getId(),
  891.                 'idedition'=>$edition->getId(),
  892.                 'idtournoi'=>$tournoi->getId(),
  893.             ]);
  894.         }
  895.         if($formbftournoicreate->isSubmitted() && !$formbftournoicreate->isValid())
  896.         {
  897.             foreach($formbftournoicreate->getErrors(true) as $error)
  898.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  899.             $formbftournoicreate->clearErrors(true);
  900.         }
  901.         
  902.         return $this->render('admineditiontournoiscreate.html.twig', [
  903.             'userdescription' => $user->getDescription(),
  904.             'formbftournoicreate' => $formbftournoicreate->createView(),
  905.             'activefestivalid' => $id,
  906.             'editionid' => $idedition,
  907.             'bfedition' => $edition,
  908.         ]);
  909.     }
  910.     
  911.     /**
  912.     * @Route("/admin/festival-{id}/edition-{idedition}/tournoi-{idtournoi}/seance/create", name="admin_seance_create")
  913.     */
  914.     public function CreateAdminSeance(int $idint $ideditionint $idtournoiRequest $request)
  915.     {
  916.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  917.         
  918.         $create = new BFSeance();
  919.         $tournoi$this->getDoctrine()->getRepository(BFTournoi::class)->find($idtournoi);
  920.         
  921.         $festival $tournoi->getEdition()->getFestival();
  922.         $this->denyAccessUnlessGranted('edit'$festival);
  923.         
  924.         $user=$this->getUser();
  925.         
  926.         $create->setTournoi($tournoi);
  927.         
  928.         $formbfseancecreate $this->createForm(BFSeanceType::class, $create, [
  929.         ]);
  930.             
  931.         $formbfseancecreate->handleRequest($request);
  932.         if ($formbfseancecreate->isSubmitted() && $formbfseancecreate->isValid()) {
  933.             // $form->getData() holds the submitted values
  934.             // but, the original `$task` variable has also been updated
  935.             $seance $formbfseancecreate->getData();
  936.             // ... perform some action, such as saving the task to the database
  937.             // for example, if Task is a Doctrine entity, save it!
  938.             $entityManager $this->getDoctrine()->getManager();
  939.             $entityManager->persist($seance);
  940.             $entityManager->flush();
  941.             
  942.             $tournoi=$seance->getTournoi();
  943.             $edition=$tournoi->getEdition();
  944.             $festival=$edition->getFestival();
  945.             
  946.             $this->addFlash('primary''La séance est créée');
  947.            return $this->redirectToRoute('admin_edition_tournoiid',[
  948.                 'id'=>$festival->getId(),
  949.                 'idedition'=>$edition->getId(),
  950.                 'idtournoi'=>$tournoi->getId(),
  951.             ]);
  952.         }
  953.         if($formbfseancecreate->isSubmitted() && !$formbfseancecreate->isValid())
  954.         {
  955.             foreach($formbfseancecreate->getErrors(true) as $error)
  956.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  957.             $formbfseancecreate->clearErrors(true);
  958.         }
  959.         
  960.         
  961.         return $this->render('admineditionseancecreate.html.twig', [
  962.             'userdescription' => $user->getDescription(),
  963.             'formbfseancecreate' => $formbfseancecreate->createView(),
  964.             'activefestivalid' => $id,
  965.             'editionid' => $idedition,
  966.             'tournoiid' => $idtournoi,
  967.             'bftournoi' => $tournoi,
  968.         ]);
  969.     }
  970.     
  971.      /**
  972.     * @Route("/admin/festival-{id}/edition-{idedition}/tournoi-{idtournoi}/seance-{idseance}", name="admin_seance_edit")
  973.     */
  974.     public function ShowAdminSeance(int $idint $ideditionint $idtournoiint $idseanceRequest $request)
  975.     {
  976.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  977.         
  978.         $seance $this->getDoctrine()
  979.             ->getRepository(BFSeance::class)
  980.             ->find($idseance);
  981.         
  982.         $festival=$seance->getTournoi()->getEdition()->getFestival();
  983.         $this->denyAccessUnlessGranted('edit'$festival);
  984.         
  985.         $user=$this->getUser();
  986.         
  987.         $formbfseanceedit $this->createForm(BFSeanceType::class, $seance, [
  988.             'submit_label' => 'Editer',
  989.         ]);
  990.         
  991.         $formbfseanceedit->handleRequest($request);
  992.         if ($formbfseanceedit->isSubmitted() && $formbfseanceedit->isValid()) {
  993.             // $form->getData() holds the submitted values
  994.             // but, the original `$task` variable has also been updated
  995.             $seance $formbfseanceedit->getData();
  996.             // ... perform some action, such as saving the task to the database
  997.             // for example, if Task is a Doctrine entity, save it!
  998.             $entityManager $this->getDoctrine()->getManager();
  999.             $entityManager->persist($seance);
  1000.             $entityManager->flush();
  1001.             
  1002.             $tournoi$seance->getTournoi();
  1003.             $edition $tournoi->getEdition();
  1004.             $festival $edition->getFestival();
  1005.             
  1006.             $this->addFlash('success''Les modifications sont enregistrées');
  1007.            
  1008.             
  1009.             return $this->redirectToRoute('admin_edition_tournoiid',[
  1010.                 'id'=>$id,
  1011.                 'idedition'=>$idedition,
  1012.                 'idtournoi'=>$idtournoi,
  1013.             ]);
  1014.         }
  1015.         if($formbfseanceedit->isSubmitted() && !$formbfseanceedit->isValid())
  1016.         {
  1017.             foreach($formbfseanceedit->getErrors(true) as $error)
  1018.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  1019.             return $this->redirect($request->getUri());
  1020.         }
  1021.         
  1022.         return $this->render('admineditionseance.html.twig', [
  1023.             'userdescription' => $user->getDescription(),
  1024.             'formbfseanceedit' => $formbfseanceedit->createView(),
  1025.             'activefestivalid' => $id,
  1026.             'editionid' => $idedition,
  1027.             'tournoiid' => $idtournoi,
  1028.             'bfseance' => $seance,
  1029.         ]);
  1030.     }
  1031.     
  1032.     /**
  1033.     * @Route ("admin/challenge/create", name="admin_challenge_create")
  1034.     */
  1035.     public function CreateAdminChallenge(Request $request)
  1036.     {
  1037.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1038.         $user $this->getUser() ;
  1039.         
  1040.         $create = new BFChallenge();
  1041.         
  1042.         $formbfchallengecreate $this->createForm(BFChallengeType::class, $create, [
  1043.         ]);
  1044.         
  1045.         
  1046.         $formbfchallengecreate->handleRequest($request);
  1047.         if ($formbfchallengecreate->isSubmitted() && $formbfchallengecreate->isValid()) {        
  1048.             $create->setOwner($user);
  1049.             
  1050.             $entityManager $this->getDoctrine()->getManager();
  1051.             $entityManager->persist($create);
  1052.             $entityManager->flush();
  1053.             
  1054.             $this->addFlash('primary''Le challenge est créé');
  1055.             
  1056.             return $this->redirectToRoute('admin_challenge',[
  1057.                 'idchallenge'=>$create->getId(),
  1058.             ]);
  1059.         }
  1060.         if($formbfchallengecreate->isSubmitted() && !$formbfchallengecreate->isValid())
  1061.         {
  1062.             foreach($formbfchallengecreate->getErrors(true) as $error)
  1063.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  1064.             $formbfchallengecreate->clearErrors(true);
  1065.         }
  1066.         
  1067.         return $this->render('adminchallengecreate.html.twig', [
  1068.             'userdescription' => $user->getDescription(),
  1069.             'formbfchallengecreate' => $formbfchallengecreate->createView(),
  1070.         ]);
  1071.     }
  1072.     
  1073.      /**
  1074.     * @Route("/admin/challenge-{idchallenge}", name="admin_challenge")
  1075.     */
  1076.     public function ShowAdminChallenge(int $idchallenge,ValidatorInterface $validatorRequest $request)
  1077.     {
  1078.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1079.         
  1080.         $challenge $this->getDoctrine()->getRepository(BFChallenge::class)->find($idchallenge);
  1081.         
  1082.         //$this->denyAccessUnlessGranted('edit', $challenge);
  1083.         
  1084.         $user=$this->getUser();
  1085.         $entityManager=$this->getDoctrine()->getManager();
  1086.         
  1087.         //formdescription
  1088.         $formeditchallenge $this->createForm(BFChallengeType::class, $challenge, [
  1089.             'submit_label' =>'Editer',
  1090.         ]);
  1091.         
  1092.         $formeditchallenge->handleRequest($request);
  1093.         if(($formeditchallenge->isSubmitted() && $formeditchallenge->isValid()))
  1094.         {
  1095.             $entityManager->persist($challenge);
  1096.             $entityManager->flush();
  1097.             
  1098.             $this->addFlash('success''Les modifications sont enregistrées');
  1099.         
  1100.             return $this->redirect($request->getUri());
  1101.         }
  1102.         if($formeditchallenge->isSubmitted() && !$formeditchallenge->isValid())
  1103.         {
  1104.             foreach($formeditchallenge->getErrors(true) as $error)
  1105.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  1106.             return $this->redirect($request->getUri());
  1107.         }
  1108.         
  1109.         //formfestivals
  1110.         $festivals $this->getDoctrine()->getRepository(BFFestival::class)->findAll();
  1111.         
  1112.         foreach($challenge->getFestivals() as $festival)
  1113.         {
  1114.             $key array_search($festival$festivals);
  1115.             if($key>=0)
  1116.             {
  1117.                 unset($festivals[$key]);
  1118.             }
  1119.         }
  1120.         
  1121.         
  1122.         $formfestivals $this->createForm(BFChallengeAddFestivalType::class, null,[
  1123.             'festivals' => $festivals,
  1124.         ] );
  1125.         $formfestivals->handleRequest($request);
  1126.         if($formfestivals->isSubmitted() && $formfestivals->isValid())
  1127.         {
  1128.             $selectedfestivalid $formfestivals->getData()['addfestival'];
  1129.             $selectedfestival=null;
  1130.             if($selectedfestivalid!=null)
  1131.             {
  1132.                 $selectedfestival $this->getDoctrine()->getRepository(BFFestival::class)->find($selectedfestivalid);
  1133.             }
  1134.             
  1135.             if($selectedfestival!=null)
  1136.             {
  1137.                 $challenge->addFestival($selectedfestival);
  1138.                 $entityManager $this->getDoctrine()->getManager();
  1139.                 $entityManager->persist($challenge);
  1140.                 $entityManager->flush();
  1141.                 $this->addFlash('primary''Le festival a été ajouté au challenge');
  1142.             }
  1143.             else
  1144.             {
  1145.                 $this->addFlash('danger''Impossible d\'ajouter le festival au challenge');
  1146.             }
  1147.             return $this->redirect($request->getUri());
  1148.         }
  1149.         
  1150.         
  1151.         //formowner
  1152.         $emailvalue $challenge->getOwner()!=null $challenge->getOwner()->getEmail() : "";
  1153.         $formchallengeowner $this->createForm(BFFestivalOwnerType::class, null, [
  1154.             'email_value' => $emailvalue,
  1155.         ]);
  1156.         
  1157.         $formchallengeowner->handleRequest($request);
  1158.         if ($formchallengeowner->isSubmitted() && $formchallengeowner->isValid()) 
  1159.         {
  1160.             //$this->denyAccessUnlessGranted('delete', $challenge);
  1161.             // $form->getData() holds the submitted values
  1162.             // but, the original `$task` variable has also been updated
  1163.             $email $formchallengeowner->getData()['email'];
  1164.             
  1165.             if($email==null)
  1166.             {
  1167.                 $challenge->setOwner(null);
  1168.                 $entityManager $this->getDoctrine()->getManager();
  1169.                 $entityManager->persist($challenge);
  1170.                 $entityManager->flush();
  1171.                 
  1172.                 $this->addFlash('primary''Le propriétaire du challenge a été modifié');
  1173.             }
  1174.             else
  1175.             {
  1176.                 //getuser from email
  1177.                 $owneruser =$this->getDoctrine()
  1178.                 ->getRepository(BFUser::class)
  1179.                 ->findOneBy(['email'=>$email]);
  1180.                 if($owneruser!=null)
  1181.                 {
  1182.                     $challenge->setOwner($owneruser);
  1183.                     $entityManager $this->getDoctrine()->getManager();
  1184.                     $entityManager->persist($challenge);
  1185.                     $entityManager->flush();
  1186.                     
  1187.                     $this->addFlash('primary''Le propriétaire du challenge a été modifié');
  1188.                 }
  1189.                 else
  1190.                 {
  1191.                     $this->addFlash('danger''L\'adresse email est inconnue');
  1192.                 }
  1193.             }
  1194.             return $this->redirect($request->getUri());
  1195.         }
  1196.         if($formchallengeowner->isSubmitted() && !$formchallengeowner->isValid())
  1197.         {
  1198.             foreach($formchallengeowner->getErrors(true) as $error)
  1199.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  1200.             return $this->redirect($request->getUri());
  1201.         }
  1202.         
  1203.         //formaddadministrator
  1204.         $formchallengeadministratoradd $this->createForm(BFFestivalAdministratorAddType::class, null, [
  1205.         ]);
  1206.         
  1207.         $formchallengeadministratoradd->handleRequest($request);
  1208.         if ($formchallengeadministratoradd->isSubmitted() && $formchallengeadministratoradd->isValid()) {
  1209.             //$this->denyAccessUnlessGranted('delete', $challenge);
  1210.             // $form->getData() holds the submitted values
  1211.             // but, the original `$task` variable has also been updated
  1212.             $email $formchallengeadministratoradd->getData()['email'];
  1213.             
  1214.             //getuser from email
  1215.             $adminuser =$this->getDoctrine()
  1216.             ->getRepository(BFUser::class)
  1217.             ->findOneBy(['email'=>$email]);
  1218.             
  1219.             if($adminuser!=null)
  1220.             {
  1221.                 $challenge->addAdministrator($adminuser);
  1222.                 
  1223.                 $entityManager $this->getDoctrine()->getManager();
  1224.                 $entityManager->persist($challenge);
  1225.                 $entityManager->flush();
  1226.                 
  1227.                 $this->addFlash('primary''L\'administrateur a été ajouté');
  1228.                 
  1229.                 return $this->redirect($request->getUri());
  1230.             }
  1231.             else
  1232.             {
  1233.                 $this->addFlash('danger''L\'adresse email est inconnue');
  1234.             }
  1235.         }
  1236.         if($formchallengeadministratoradd->isSubmitted() && !$formchallengeadministratoradd->isValid())
  1237.         {
  1238.             foreach($formchallengeadministratoradd->getErrors(true) as $error)
  1239.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  1240.             return $this->redirect($request->getUri());
  1241.         }
  1242.         
  1243.         //formremoveadministrator
  1244.         $formchallengeadministratorremove $this->createForm(BFFestivalAdministratorRemoveType::class, null, ['festival'=>$challenge]);
  1245.         
  1246.         $formchallengeadministratorremove->handleRequest($request);
  1247.         if ($formchallengeadministratorremove->isSubmitted() && $formchallengeadministratorremove->isValid()) {
  1248.             //$this->denyAccessUnlessGranted('delete', $challenge);
  1249.             
  1250.             // $form->getData() holds the submitted values
  1251.             // but, the original `$task` variable has also been updated
  1252.             $administratorid $formchallengeadministratorremove->getData()['administratorstodelete'];
  1253.             
  1254.             $adminuser=null;
  1255.             if($administratorid!=null)
  1256.             {
  1257.                 $adminuser =$this->getDoctrine()->getRepository(BFUser::class)->find($administratorid);
  1258.             }
  1259.             
  1260.             if($adminuser!=null)
  1261.             {
  1262.                 $challenge->removeAdministrator($adminuser);
  1263.                 $entityManager $this->getDoctrine()->getManager();
  1264.                 $entityManager->persist($challenge);
  1265.                 $entityManager->flush();
  1266.                 
  1267.                 $this->addFlash('primary''L\'administrateur a été envelé');
  1268.                 
  1269.                 return $this->redirect($request->getUri());
  1270.             }
  1271.         }
  1272.         if($formchallengeadministratorremove->isSubmitted() && !$formchallengeadministratorremove->isValid())
  1273.         {
  1274.             foreach($formchallengeadministratorremove->getErrors(true) as $error)
  1275.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  1276.             return $this->redirect($request->getUri());
  1277.         }
  1278.         
  1279.         
  1280.         return $this->render('adminchallenge.html.twig', [
  1281.             'userdescription' => $user->getDescription(),
  1282.             'bfchallenge' => $challenge,
  1283.             'formbfchallengeedit' => $formeditchallenge->createView(),
  1284.             'formbfchallengeowner' => $formchallengeowner->createView(),
  1285.             'formbfchallengeadminadd' => $formchallengeadministratoradd->createView(),
  1286.             'formbfchallengeadminremove' => $formchallengeadministratorremove->createView(),
  1287.             'formaddbffestival' => $formfestivals->createView(),
  1288.             'activechallengeid' => $idchallenge,
  1289.         ]);
  1290.     }
  1291.     
  1292.        /**
  1293.     * @Route("/admin/challenge-{idchallenge}/subscriptions", name="admin_challenge_subscriptions")
  1294.     */
  1295.     public function ShowAdminChallengeSubscriptions(int $idchallengeRequest $request)
  1296.     {
  1297.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1298.         
  1299.         $challenge $this->getDoctrine()
  1300.              ->getRepository(BFChallenge::class)
  1301.              ->find($idchallenge);
  1302.         
  1303.         $this->denyAccessUnlessGranted('edit'$challenge);
  1304.         
  1305.         $user=$this->getUser();
  1306.         
  1307.         //countsubscribers
  1308.         $subscriptions $this->getDoctrine()->getRepository(BFSubscription::class)->FindBy(['challenge'=>$challenge]);
  1309.         
  1310.         //formsendmail
  1311.         $bfmailchallenge = new BFMailChallenge();
  1312.         
  1313.         $formsendmail $this->createForm(BFMailFestivalType::class, $bfmailchallenge);
  1314.         $formsendmail->handleRequest($request);
  1315.         if ($formsendmail->isSubmitted() && $formsendmail->isValid()) {
  1316.             // $form->getData() holds the submitted values
  1317.             // but, the original `$task` variable has also been updated
  1318.             $bfmailfestival $formsendmail->getData();
  1319.                         
  1320.             $bfmailchallenge->setChallenge($challenge);
  1321.             $bfmailchallenge->setSubscribercount(count($subscriptions));
  1322.             $bfmailchallenge->setSenddate(new \DateTime('now'));
  1323.             
  1324.             $em =$this->getDoctrine()->getManager();
  1325.             $em->persist($bfmailchallenge);
  1326.             $em->flush();
  1327.             
  1328.             $txtmessage $bfmailchallenge->getText();
  1329.             $subject $bfmailchallenge->getSubject();
  1330.             
  1331.             $sendedmail=0;
  1332.             
  1333.             if($bfmailchallenge->getIsadmin())
  1334.             {
  1335.                 $admins $challenge->getAdministrators()->getValues();
  1336.                 $owner $challenge->getOwner();
  1337.                 if($owner!=null)
  1338.                 {
  1339.                     array_push($admins$owner);
  1340.                 }
  1341.                 if(count($admins)==0)
  1342.                 {
  1343.                     $userrepository =$this->getDoctrine()->getRepository(BFUser::class);
  1344.                     array_push($admins$userrepository->findByRole('ROLE_SUPER_ADMIN'));
  1345.                 }
  1346.                 
  1347.                 $htmlmessage $this->renderView('mail/challengemail.html.twig', [
  1348.                         'subject' => $subject,
  1349.                         'message' => $txtmessage,
  1350.                         'challenge' => $challenge,
  1351.                         'mailchallenge' => $bfmailchallenge,
  1352.                         'subscriptionid' => 0,
  1353.                         'attachmentname' => $bfmailchallenge->getAttachmentfiletitle()? $bfmailchallenge->getAttachmentfiletitle() : $bfmailchallenge->getAttachmentfile(),
  1354.                     ]);
  1355.                 if(Mail::SendMailToBFUsers($admins$owner->getEmail(), $subject$htmlmessage$txtmessage))
  1356.                     $this->addFlash('primary''Le mail de test a été envoyé à '.count($admins).' administrateurs');
  1357.                 else
  1358.                     $this->addFlash('danger''Impossible d\'envoyer le mail aux administrateurs ');
  1359.             }
  1360.             else
  1361.             {
  1362.                 foreach($subscriptions as $subscription)
  1363.                 {
  1364.                     $htmlmessage $this->renderView('mail/challengemail.html.twig', [
  1365.                         'subject' => $subject,
  1366.                         'message' => $txtmessage,
  1367.                         'challenge' => $challenge,
  1368.                         'mailchallenge' => $bfmailchallenge,
  1369.                         'subscriptionid' => $subscription->getId(),
  1370.                         'attachmentname' => $bfmailchallenge->getAttachmentfiletitle()? $bfmailchallenge->getAttachmentfiletitle() : $bfmailchallenge->getAttachmentfile(),
  1371.                     ]);
  1372.                     if(Mail::SendMailToBFUser($subscription->getUser(), $challenge->getOwner()->getEmail(), $subject$htmlmessage$txtmessage))
  1373.                         $sendedmail++;
  1374.                 }
  1375.                 $this->addFlash('primary''Le mail a été envoyé à '.$sendedmail.' destinataires');
  1376.             }
  1377.             
  1378.             return $this->redirect($request->getUri());
  1379.         }
  1380.      
  1381.         //get sendmail list
  1382.         $sendmails $this->getDoctrine()->getRepository(BFMailChallenge::class)->findBy(['challenge'=>$challenge], ['senddate'=>'DESC']);
  1383.         
  1384.         return $this->render('adminchallengesubscriptions.html.twig', [
  1385.             'userdescription' => $user->getDescription(),
  1386.             'bfchallenge' => $challenge,
  1387.             'countsubscription' => count($subscriptions),
  1388.             'formsendmail' => $formsendmail->createView(),
  1389.             'sendmails' => $sendmails,
  1390.             'activechallengeid' => $idchallenge,
  1391.         ]);
  1392.     }
  1393.     
  1394.     /**
  1395.     * @Route("/admin/challenge-{id}/edition/create", name="admin_challenge_edition_create")
  1396.     */
  1397.     public function CreateAdminChallengeEdition(int $idRequest $request)
  1398.     {
  1399.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1400.         
  1401.         //get challenge
  1402.         $challenge $this->getDoctrine()->getRepository(BFChallenge::class)->find($id);
  1403.         
  1404.         if($challenge==null)
  1405.             throw $this->createNotFoundException('The challenge doesn\'t exist');
  1406.         
  1407.         $this->denyAccessUnlessGranted('edit'$challenge);
  1408.         
  1409.         $user=$this->getUser();
  1410.         
  1411.         //compute possible editions
  1412.         $festivalsfromchallenge $challenge->getFestivals();
  1413.         $editionsarray= array();
  1414.         foreach($festivalsfromchallenge as $festival)
  1415.         {
  1416.             $editions $festival->getEditions();
  1417.             foreach($editions as $edition)
  1418.             {
  1419.                 $challengeeditions=$edition->getChallengeeditions();
  1420.                 //check if the edition is already in a challenge edition
  1421.                 if(count($challengeeditions)>0)
  1422.                 {
  1423.                     $isalreadyhere=false;
  1424.                     //check the possibility if the challenge is the current one
  1425.                     foreach($challengeeditions as $challengeedition)
  1426.                     {
  1427.                         //if yes we don't propose this bfedition because already in an edition of the current challenge
  1428.                         if($challengeedition->getChallenge()==$challenge)
  1429.                         {
  1430.                             $isalreadyhere=true;
  1431.                             break;
  1432.                         }
  1433.                     }
  1434.                     if(!$isalreadyhere)
  1435.                         array_push($editionsarray$edition);
  1436.                 }
  1437.                 else
  1438.                     array_push($editionsarray$edition);
  1439.             }
  1440.         }
  1441.         
  1442.         $create = new BFChallengeEdition();
  1443.         $create->setChallenge($challenge);
  1444.         
  1445.         $formbfeditioncreate $this->createForm(BFChallengeEditionType::class, $create,[
  1446.             'editions'=>$editionsarray ]);
  1447.         
  1448.         $formbfeditioncreate->handleRequest($request);
  1449.         if ($formbfeditioncreate->isSubmitted() && $formbfeditioncreate->isValid()) {
  1450.             // $form->getData() holds the submitted values
  1451.             // but, the original `$task` variable has also been updated
  1452.             $edition $formbfeditioncreate->getData();
  1453.             $edition->setIsactive(false);
  1454.             
  1455.             // ... perform some action, such as saving the task to the database
  1456.             // for example, if Task is a Doctrine entity, save it!
  1457.             $entityManager $this->getDoctrine()->getManager();
  1458.             $entityManager->persist($edition);
  1459.             $entityManager->flush();
  1460.             
  1461.             $this->addFlash('primary''L\'édition est créée');
  1462.             return $this->redirectToRoute('admin_challenge_edition',[
  1463.                 'id' => $edition->getChallenge()->getId(),
  1464.                 'idedition'=>$edition->getId(),
  1465.             ]);
  1466.             
  1467.         }
  1468.         if($formbfeditioncreate->isSubmitted() && !$formbfeditioncreate->isValid())
  1469.         {
  1470.             foreach($formbfeditioncreate->getErrors(true) as $error)
  1471.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  1472.             $formbfeditioncreate->clearErrors(true);
  1473.         }
  1474.         
  1475.         return $this->render('challenges/adminchallengeeditioncreate.html.twig', [
  1476.             'userdescription' => $user->getDescription(),
  1477.             'formbfchallengeeditioncreate' => $formbfeditioncreate->createView(),
  1478.             'challengeid' => $challenge->getId(),
  1479.             'activechallengeid' => $challenge->getId(),
  1480.             'bfchallenge' => $challenge,
  1481.         ]);
  1482.     }   
  1483.     
  1484.     /**
  1485.     * @Route("/admin/challenge/edition-{idedition}", name="admin_challenge_edition")
  1486.     */
  1487.     public function ShowAdminChallengeEdition(int $ideditionRequest $request)
  1488.     {
  1489.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1490.         
  1491.         $cedition $this->getDoctrine()
  1492.             ->getRepository(BFChallengeEdition::class)
  1493.             ->find($idedition);
  1494.         
  1495.         $challenge $cedition->getChallenge();
  1496.         
  1497.         $this->denyAccessUnlessGranted('edit'$challenge);
  1498.         
  1499.         $user$this->getUser();
  1500.         
  1501.         //compute possible editions
  1502.         $festivalsfromchallenge $challenge->getFestivals();
  1503.         $editionsarray= array();
  1504.         foreach($festivalsfromchallenge as $festival)
  1505.         {
  1506.             $editions $festival->getEditions();
  1507.             array_push($editionsarray$editions->toArray());
  1508.         }
  1509.         
  1510.         //edit about form
  1511.          $formbfchallengeeditionedit $this->createForm(BFChallengeEditionType::class, $cedition,[
  1512.             'editions'=>$editionsarray'submit_label'=>'Editer' ]);
  1513.         
  1514.         $formbfchallengeeditionedit->handleRequest($request);
  1515.         if ($formbfchallengeeditionedit->isSubmitted() && $formbfchallengeeditionedit->isValid()) {
  1516.             // $form->getData() holds the submitted values
  1517.             // but, the original `$task` variable has also been updated
  1518.             //$cedition = $formbfchallengeeditionedit->getData();
  1519.                         
  1520.             // ... perform some action, such as saving the task to the database
  1521.             // for example, if Task is a Doctrine entity, save it!
  1522.             $entityManager $this->getDoctrine()->getManager();
  1523.             $entityManager->persist($cedition);
  1524.             $entityManager->flush();
  1525.             
  1526.             $this->addFlash('success''Les modifications sont enregistrées');
  1527.             
  1528.             return $this->redirect($request->getUri());
  1529.         }
  1530.         if($formbfchallengeeditionedit->isSubmitted() && !$formbfchallengeeditionedit->isValid())
  1531.         {
  1532.             foreach($formbfchallengeeditionedit->getErrors(true) as $error)
  1533.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  1534.             return $this->redirect($request->getUri());
  1535.         }
  1536.         
  1537.         return $this->render('challenges/adminchallengeedition.html.twig', [
  1538.             'userdescription' => $user->getDescription(),
  1539.             'formbfchallengeedition' => $formbfchallengeeditionedit->createView(),
  1540.             'activechallengeid' => $challenge->getId(),
  1541.             'editionid' => $idedition,
  1542.             'bfchallengeedition' => $cedition,
  1543.         ]);
  1544.     }
  1545.     
  1546.     /**
  1547.     * @Route("/admin/edition-{id}/unactive", name="admin_bfedition_unactive")
  1548.     */
  1549.     public function UnactiveEdition(int $idRequest $request)
  1550.     {
  1551.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1552.         
  1553.          $response $this->forward('App\Controller\BFEditionController::ChangeActiveEdition', [
  1554.             'id'  => $id,
  1555.             'isactive' => false,
  1556.             'fromadmin'=> true,
  1557.              'request' =>$request,
  1558.          ]);
  1559.         
  1560.         return $response;
  1561.     }
  1562.     
  1563.     /**
  1564.     * @Route("/admin/edition-{id}/active", name="admin_bfedition_active")
  1565.     */
  1566.     public function ActiveEdition(int $idRequest $request)
  1567.     {
  1568.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1569.         
  1570.         $response $this->forward('App\Controller\BFEditionController::ChangeActiveEdition', [
  1571.             'id'  => $id,
  1572.             'isactive' => true,
  1573.             'fromadmin'=> true,
  1574.              'request' =>$request,
  1575.          ]);
  1576.         
  1577.         return $response;
  1578.     }
  1579.     
  1580.     /**
  1581.     * @Route("/admin/festival-{id}/edition-{idedition}/cardspreview", name="admin_edition_cardspreview")
  1582.     */
  1583.     public function ShowCardsPreview(int $idint $ideditionRequest $request)
  1584.     {
  1585.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1586.         
  1587.         $bfedition $this->getDoctrine()->getRepository(BFEdition::class)->find($idedition);
  1588.         $festival=$bfedition->getFestival();
  1589.         
  1590.         $this->denyAccessUnlessGranted('edit'$festival);
  1591.         
  1592.         if($this->isGranted('option_uniqueurl_festival'$festival) && $festival->getRoute()!=null)
  1593.         {
  1594.             $route $this->generateUrl('home_route',[
  1595.                 'route' => $festival->getRoute()->getRoute(),
  1596.             ]);
  1597.         }
  1598.         else if ($this->isGranted('option_uniqueurl_edition'$bfedition) && $bfedition->getRoute()!=null)
  1599.         {
  1600.             $route $this->generateUrl('home_route',[
  1601.                 'route' => $bfedition->getRoute()->getRoute(),
  1602.             ]);
  1603.         }
  1604.         else
  1605.         {
  1606.             $route $this->generateUrl('edition_view',[
  1607.                 'id' => $id,
  1608.             ]);
  1609.         }
  1610.         
  1611.         return $this->render('homepreview.html.twig', [
  1612.             'bfedition' => $bfedition,
  1613.             'bfeditionroute' => $route,
  1614.         ]);
  1615.     }
  1616.     
  1617.     
  1618.     /**
  1619.     * @Route("/admin/festival-{id}/edition-{idedition}/payements", name="admin_edition_payements")
  1620.     */
  1621.     public function ShowAdminEditionPayement($id$idedition,Request $request)
  1622.     {
  1623.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1624.         
  1625.         $bfedition $this->getDoctrine()
  1626.             ->getRepository(BFEdition::class)
  1627.             ->find($idedition);
  1628.         
  1629.         $festival $bfedition->getFestival();
  1630.         
  1631.         $this->denyAccessUnlessGranted('edit'$festival);
  1632.         
  1633.         $user$this->getUser();
  1634.         
  1635.         $producteditions $bfedition->getBfproducteditions();
  1636.         
  1637.         $producteditionsbuy=array();
  1638.         $produceditionsquantity=array();
  1639.         $producteditionssum=array();
  1640.         
  1641.         foreach($producteditions as $productedition)
  1642.         {
  1643.             $isbuy=false;
  1644.             $quantity=0;
  1645.             $sum=0;
  1646.             $ordereditions $productedition->getBFOrderEditions();
  1647.             foreach($ordereditions as $orderedition)
  1648.             {
  1649.                 $paymentintent $orderedition->getBFPaymentIntentEdition();
  1650.                 if($paymentintent->getSuccessdate()!=null && $paymentintent->getRefunddate()==null)
  1651.                 {
  1652.                     $isbuy=true;
  1653.                     $quantity+=$orderedition->getQuantity();
  1654.                     $sum+=$orderedition->getDisplayTotal();
  1655.                 }
  1656.             }
  1657.             if($isbuy)
  1658.             {
  1659.                 array_push($producteditionsbuy$productedition);
  1660.                 array_push($produceditionsquantity$quantity);
  1661.                 array_push($producteditionssum$sum);
  1662.             }
  1663.         }
  1664.         
  1665.         
  1666.         return $this->render('admineditionpayments.html.twig', [
  1667.             'userdescription' => $user->getDescription(),
  1668.             'bfedition' => $bfedition,
  1669.             'activefestivalid' => $festival->getId(),
  1670.             'editionid' => $bfedition->getId(),
  1671.             'arrayproducteditions' => $producteditionsbuy,
  1672.             'arrayquantity' => $produceditionsquantity,
  1673.             'arraysum' => $producteditionssum,
  1674.         ]);
  1675.     }
  1676.     
  1677.     /**
  1678.     * @Route("/admin/festival-{id}/edition-{idedition}/payements/create", name="admin_edition_payements_create")
  1679.     */
  1680.     public function CreateAdminProductEdition($id$idedition,Request $request)
  1681.     {
  1682.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  1683.         
  1684.         $bfedition $this->getDoctrine()
  1685.             ->getRepository(BFEdition::class)
  1686.             ->find($idedition);
  1687.         
  1688.         $festival $bfedition->getFestival();
  1689.         
  1690.         $this->denyAccessUnlessGranted('edit'$festival);
  1691.         
  1692.         $user$this->getUser();
  1693.         
  1694.         $newproduct = new BFProductEdition();
  1695.         
  1696.         //edit about form
  1697.         $formbfproductedition $this->createForm(BFProductEditionType::class, $newproduct ,[
  1698.             'edition'=> $bfedition'submit_label'=>'Créer' ]);
  1699.         
  1700.         $formbfproductedition->handleRequest($request);
  1701.         if ($formbfproductedition->isSubmitted() && $formbfproductedition->isValid()) {
  1702.             
  1703.             $newproduct->setEdition($bfedition);
  1704.             
  1705.             $entityManager $this->getDoctrine()->getManager();
  1706.             $entityManager->persist($newproduct);
  1707.             $entityManager->flush();
  1708.             
  1709.             $this->addFlash('success''Le nouveau forfait est créé');
  1710.             
  1711.             return $this->redirectToRoute('admin_edition_payements', ['id' => $id'idedition' => $idedition]);
  1712.         }
  1713.         if($formbfproductedition->isSubmitted() && !$formbfproductedition->isValid())
  1714.         {
  1715.             foreach($formbfproductedition->getErrors(true) as $error)
  1716.                 $this->addFlash('danger'"(".$error->getOrigin()->getName().") ".$error->getMessage());
  1717.             return $this->redirect($request->getUri());
  1718.         }
  1719.         
  1720.         return $this->render('payments/adminproducteditioncreate.html.twig', [
  1721.             'userdescription' => $user->getDescription(),
  1722.             'activefestivalid' => $festival->getId(),
  1723.             'editionid' => $bfedition->getId(),
  1724.             'bfedition' => $bfedition,
  1725.             'formbfproductedition' => $formbfproductedition->createView(),
  1726.         ]);
  1727.     }
  1728.     
  1729.     
  1730.     private function ClearUserResetPassword(BFUser $bfuser)
  1731.     {
  1732.         //get bfreset from user id
  1733.         $bfresetpassword $this->getDoctrine()->getRepository(BFResetPassword::class)->findOneBy(['user'=>$bfuser]);
  1734.         
  1735.         if($bfresetpassword!=null)
  1736.         {
  1737.             $entityManager $this->getDoctrine()->getManager();
  1738.             $entityManager->remove($bfresetpassword);
  1739.             $entityManager->flush();
  1740.         }
  1741.         
  1742.     }
  1743. }
  1744. ?>