leto12

SymfonyController

Mar 22nd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 17.99 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppBundle\Controller;
  4.  
  5.  
  6.  
  7. use AppBundle\Entity\Stage;
  8. use AppBundle\Entity\Stagiaire;
  9. use AppBundle\Form\StageType;
  10. use AppBundle\Form\StagiaireType;
  11. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  12. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpFoundation\Response;
  15.  
  16. // les objets
  17. use AppBundle\Entity\Danse;
  18. use AppBundle\Entity\Adherent;
  19. use AppBundle\Entity\Remise;
  20. use AppBundle\Entity\Professeur;
  21. use AppBundle\Entity\CoursHebdomadaire;
  22. use AppBundle\Entity\EnseignantCours;
  23. use AppBundle\Entity\TypeForfait;
  24. use AppBundle\Entity\InscriptionForfait;
  25. use AppBundle\Entity\Soiree;
  26.  
  27.  
  28. // les forms
  29. use AppBundle\Form\AdherentType;
  30. use AppBundle\Form\CoursHebdomadaireType;
  31. use AppBundle\Form\InscriptionForfaitType;
  32. use AppBundle\Form\ProfesseurType;
  33. use AppBundle\Form\SoireeType;
  34.  
  35.  
  36.  
  37. class IndexController extends Controller {
  38.  
  39.  
  40.     /**
  41.      * @Route("/")
  42.      */
  43.     public function homeAction(){
  44.  
  45.         return $this->render('home.html.twig');
  46.     }
  47.  
  48.  
  49.     /**
  50.      * @Route("/danses")
  51.      */
  52.     public function planningAction(Request $request) {
  53.  
  54.  
  55.         $repository = $this->getDoctrine()
  56.             ->getRepository('AppBundle:Danse');
  57.         $danses = $repository->findAll();
  58.  
  59.  
  60.         return $this->render('planning.html.twig',
  61.                                 array('danses' => $danses));
  62.  
  63.     }
  64.  
  65.  
  66.     /**
  67.      * @Route("/inscription")
  68.      */
  69.     public function inscriptionAction(Request $request)
  70.     {
  71.  
  72.  
  73.         $uneinscription = new InscriptionForfait();
  74.         $uneinscription->setDateInscriptionForfait(new \Datetime());
  75.         $uneinscription->setEtatInscriptionForfait('en attente');
  76.         $forminscription = $this->createForm(InscriptionForfaitType::class, $uneinscription);
  77.         $forminscription->handleRequest($request);
  78.         if ($forminscription->isSubmitted()) {
  79.             $data = $forminscription->getData();
  80.             $em = $this->getDoctrine()->getManager();
  81.             $em->persist($data);
  82.             $em->persist($data->getidAdherent());
  83.             $em->flush();
  84.             return $this->redirect($this->generateUrl('app_index_inscription'));
  85.         }
  86.  
  87.         $unstagiaire = new Stagiaire();
  88.         $formstagiaire = $this->createForm(StagiaireType::class, $unstagiaire);
  89.         $formstagiaire->handleRequest($request);
  90.         if ($formstagiaire->isSubmitted()) {
  91.             $data = $formstagiaire->getData();
  92.             $em = $this->getDoctrine()->getManager();
  93.             $em->persist($data);
  94.             $em->flush();
  95.             return $this->redirect($this->generateUrl('app_index_inscription'));
  96.         }
  97.  
  98.  
  99.         return $this->render('inscription.html.twig', array('forminscription' => $forminscription->createView(),'formstagiaire' => $formstagiaire->createView()));
  100.  
  101.  
  102.     }
  103.  
  104.  
  105.     /**
  106.      * @Route("/contact")
  107.      */
  108.     public function contactAction()
  109.     {
  110.         return $this->render('contact.html.twig');
  111.     }
  112.  
  113.     /**
  114.      * @Route("/login")
  115.      */
  116.     public function loginAction()
  117.     {
  118.         return $this->render('login.html.twig');
  119.     }
  120.  
  121.     /**
  122.      * @Route("/admin/dashboard")
  123.      */
  124.     public function dashboardAction()
  125.     {
  126.         return $this->render('dashboard.html.twig');
  127.     }
  128.  
  129.     /**
  130.      * @Route("/admin/adherents")
  131.      */
  132.     public function voiradherentAction()
  133.     {
  134.          $repository = $this->getDoctrine()
  135.             ->getRepository('AppBundle:InscriptionForfait');
  136. $inscrits = $repository->findAll();
  137.  
  138.  
  139.         return $this->render('adherents.html.twig',
  140.             array('inscrits' => $inscrits));
  141.     }
  142.  
  143.     /**
  144.      * @Route("/admin/adherent-add")
  145.      */
  146.     public function addadherentAction(Request $request)
  147.     {
  148.         $uneinscription = new InscriptionForfait();
  149.         $uneinscription->setDateInscriptionForfait(new \Datetime());
  150.         $uneinscription->setEtatInscriptionForfait('en attente');
  151.         $forminscription = $this->createForm(InscriptionForfaitType::class, $uneinscription);
  152.         $forminscription->handleRequest($request);
  153.         if ($forminscription->isSubmitted()) {
  154.             $data = $forminscription->getData();
  155.             $em = $this->getDoctrine()->getManager();
  156.             $em->persist($data);
  157.             $em->persist($data->getidAdherent());
  158.             $em->flush();
  159.             return $this->redirect($this->generateUrl('app_index_voiradherent'));
  160.         }
  161.  
  162.         return $this->render('adherent-add.html.twig', array('forminscription' => $forminscription->createView()));
  163.     }
  164.  
  165.     /**
  166.      * @Route("/admin/adherent-edit/{id}")
  167.      */
  168.     public function editadherentAction($id, Request $request)
  169.     {
  170.         $em = $this->getDoctrine()->getManager();
  171.         $linscrit = $em->getRepository('AppBundle:InscriptionForfait')->find($id);
  172.         $form = $this->createForm(new InscriptionForfaitType(), $linscrit);
  173.         $form->handleRequest($request);
  174.  
  175.         if ($form->isSubmitted())  {
  176.             $data = $form->getData();
  177.             $em->persist($data);
  178.             $em->flush();
  179.             return $this->redirect($this->generateUrl('app_index_voiradherent'));
  180.         }
  181.         return $this->render('adherent-edit.html.twig', array('form' => $form->createView()));
  182.     }
  183.  
  184.     /**
  185.      * @Route("/admin/del-adherent/{id}")
  186.      */
  187.     public function deladherentAction($id, Request $request)
  188.     {
  189.         $form = $this->createFormBuilder($id)->getForm();
  190.  
  191.         if ($form->handleRequest($request)) {
  192.             $em = $this->getDoctrine()->getManager();
  193.             $entity = $em->getRepository('AppBundle:InscriptionForfait')
  194.                 ->find($id);
  195.             $em->remove($entity);
  196.             $em->flush();
  197.             return $this->redirect($this->generateUrl('app_index_voiradherent'));
  198.         }
  199.         return $this->render('planning.html.twig');
  200.     }
  201.  
  202.     /**
  203.      * @Route("/admin/deleteform/{id}")
  204.      */
  205.     public function deleteformAction($id)
  206.     {
  207.         $deleteForm = $this->createFormBuilder($id)->getForm();
  208.         return $this->render('deleteform.html.twig',
  209.             array(
  210.                 'delete_form' => $deleteForm->createView(),
  211.             )
  212.         );
  213.     }
  214.  
  215.    /**
  216.      * @Route("/admin/profs")
  217.      */
  218.     public function voirprofAction()
  219.     {
  220.         $repository = $this->getDoctrine()
  221.             ->getRepository('AppBundle:Professeur');
  222.         $profs = $repository->findAll();
  223.         return $this->render('profs.html.twig', array('profs' => $profs));
  224.     }
  225.  
  226.     /**
  227.      * @Route("/admin/prof-add")
  228.      */
  229.     public function addprofAction(Request $request)
  230.     {
  231.         $unprof = new Professeur();
  232.         $form= $this->createForm(ProfesseurType::class, $unprof);
  233.         $form->handleRequest($request);
  234.         if ($form->isSubmitted())  {
  235.             $data = $form->getData();
  236.             $em = $this->getDoctrine()->getManager();
  237.             $em->persist($data);
  238.             $em->flush();
  239.             return $this->redirect($this->generateUrl('app_index_voirprof'));
  240.         }
  241.         return $this->render('prof-add.html.twig', array('form' => $form->createView()));
  242.     }
  243.  
  244.     /**
  245.      * @Route("/admin/prof-edit/{id}")
  246.      */
  247.     public function editprofAction($id, Request $request)
  248.     {
  249.         $em = $this->getDoctrine()->getManager();
  250.         $leprof = $em->getRepository('AppBundle:Professeur')->find($id);
  251.         $form = $this->createForm(new ProfesseurType(), $leprof);
  252.         $form->handleRequest($request);
  253.  
  254.         if ($form->isSubmitted())  {
  255.             $data = $form->getData();
  256.             $em->persist($data);
  257.             $em->flush();
  258.             return $this->redirect($this->generateUrl('app_index_voirprof'));
  259.         }
  260.         return $this->render('prof-edit.html.twig', array('form' => $form->createView()));
  261.     }
  262.  
  263.     /**
  264.      * @Route("/admin/del-prof/{id}")
  265.      */
  266.     public function delprofAction($id, Request $request)
  267.     {
  268.         $form = $this->createFormBuilder($id)->getForm();
  269.  
  270.         if ($form->handleRequest($request)) {
  271.             $em = $this->getDoctrine()->getManager();
  272.             $entity = $em->getRepository('AppBundle:Professeur')
  273.                 ->find($id);
  274.             $em->remove($entity);
  275.             $em->flush();
  276.             return $this->redirect($this->generateUrl('app_index_voirprof'));
  277.         }
  278.         return $this->render('planning.html.twig');
  279.     }
  280.  
  281.     /**
  282.      * @Route("/admin/cours")
  283.      */
  284.     public function voircoursAction()
  285.     {
  286.         $repository = $this->getDoctrine()
  287.             ->getRepository('AppBundle:CoursHebdomadaire');
  288.         $cours = $repository->findAll();
  289.  
  290.         return $this->render('cours.html.twig', array('cours' => $cours));
  291.     }
  292.  
  293.     /**
  294.      * @Route("/admin/cours-add")
  295.      */
  296.     public function addcoursAction(Request $request)
  297.     {
  298.         $uncours = new CoursHebdomadaire();
  299.         $form= $this->createForm(CoursHebdomadaireType::class, $uncours);
  300.         $form->handleRequest($request);
  301.         if ($form->isSubmitted())  {
  302.             $data = $form->getData();
  303.             $em = $this->getDoctrine()->getManager();
  304.             $em->persist($data);
  305.             $em->flush();
  306.             return $this->redirect($this->generateUrl('app_index_voircours'));
  307.         }
  308.         return $this->render('cours-add.html.twig', array('form' => $form->createView()));
  309.     }
  310.  
  311.     /**
  312.      * @Route("/admin/cours-edit/{id}")
  313.      */
  314.     public function editcoursAction($id, Request $request)
  315.     {
  316.         $em = $this->getDoctrine()->getManager();
  317.         $lecours = $em->getRepository('AppBundle:CoursHebdomadaire')->find($id);
  318.         $form = $this->createForm(new CoursHebdomadaireType(), $lecours);
  319.         $form->handleRequest($request);
  320.  
  321.         if ($form->isSubmitted())  {
  322.             $data = $form->getData();
  323.             $em->persist($data);
  324.             $em->flush();
  325.             return $this->redirect($this->generateUrl('app_index_voircours'));
  326.         }
  327.         return $this->render('cours-edit.html.twig', array('form' => $form->createView()));
  328.     }
  329.  
  330.     /**
  331.      * @Route("/admin/del-cours/{id}")
  332.      */
  333.     public function delcoursAction($id, Request $request)
  334.     {
  335.         $form = $this->createFormBuilder($id)->getForm();
  336.  
  337.         if ($form->handleRequest($request)) {
  338.             $em = $this->getDoctrine()->getManager();
  339.             $entity = $em->getRepository('AppBundle:CoursHebdomadaire')
  340.                 ->find($id);
  341.             $em->remove($entity);
  342.             $em->flush();
  343.             return $this->redirect($this->generateUrl('app_index_voircours'));
  344.         }
  345.         return $this->render('planning.html.twig');
  346.     }
  347.  
  348.     /**
  349.      * @Route("/admin/danses")
  350.      */
  351.     public function voirdansesAction()
  352.     {
  353.         return $this->render('danses.html.twig');
  354.     }
  355.  
  356.     /**
  357.      * @Route("/admin/forfaits")
  358.      */
  359.     public function voirforfaitsAction()
  360.     {
  361.         return $this->render('forfaits.html.twig');
  362.     }
  363.  
  364.     /**
  365.      * @Route("/admin/stages")
  366.      */
  367.     public function viewstageAction()
  368.     {
  369.         $repository = $this->getDoctrine()
  370.             ->getRepository('AppBundle:Stage');
  371.         $stages = $repository->findAll();
  372.  
  373.         return $this->render('stages.html.twig', array('stages' => $stages));
  374.  
  375.     }
  376.  
  377.     /**
  378.      * @Route("/admin/stage-add")
  379.      */
  380.     public function addstageAction(Request $request)
  381.     {
  382.         $unstage = new Stage();
  383.         $form= $this->createForm(StageType::class, $unstage);
  384.         $form->handleRequest($request);
  385.         if ($form->isSubmitted())  {
  386.             $data = $form->getData();
  387.             $em = $this->getDoctrine()->getManager();
  388.             $em->persist($data);
  389.             $em->flush();
  390.             return $this->redirect($this->generateUrl('app_index_viewstage'));
  391.         }
  392.         return $this->render('stage-add.html.twig', array('form' => $form->createView()));
  393.  
  394.     }
  395.  
  396.     /**
  397.      * @Route("/admin/stage-edit/{id}")
  398.      */
  399.     public function editstageAction($id, Request $request)
  400.     {
  401.         $em = $this->getDoctrine()->getManager();
  402.         $lestage = $em->getRepository('AppBundle:Stage')->find($id);
  403.         $form = $this->createForm(new StageType(), $lestage);
  404.         $form->handleRequest($request);
  405.  
  406.         if ($form->isSubmitted())  {
  407.             $data = $form->getData();
  408.             $em->persist($data);
  409.             $em->flush();
  410.             return $this->redirect($this->generateUrl('app_index_viewstage'));
  411.         }
  412.         return $this->render('stage-edit.html.twig', array('form' => $form->createView()));
  413.     }
  414.  
  415.     /**
  416.      * @Route("/admin/del-stage/{id}")
  417.      */
  418.     public function delstageAction($id, Request $request)
  419.     {
  420.         $form = $this->createFormBuilder($id)->getForm();
  421.  
  422.         if ($form->handleRequest($request)) {
  423.             $em = $this->getDoctrine()->getManager();
  424.             $entity = $em->getRepository('AppBundle:Stage')
  425.                 ->find($id);
  426.             $em->remove($entity);
  427.             $em->flush();
  428.             return $this->redirect($this->generateUrl('app_index_viewstage'));
  429.         }
  430.         return $this->render('planning.html.twig');
  431.     }
  432.  
  433.     /**
  434.      * @Route("/admin/stagiaires")
  435.      */
  436.     public function stagiairesAction()
  437.     {
  438.         $repository = $this->getDoctrine()
  439.             ->getRepository('AppBundle:Stagiaire');
  440.         $stagiaires = $repository->findAll();
  441.         return $this->render('stagiaires.html.twig', array('stagiaires' => $stagiaires));
  442.     }
  443.  
  444.     /**
  445.      * @Route("/admin/stagiaire-add")
  446.      */
  447.     public function addstagiaireAction(Request $request)
  448.     {
  449.         $unstagiaire = new Stagiaire();
  450.         $form= $this->createForm(StagiaireType::class, $unstagiaire);
  451.         $form->handleRequest($request);
  452.         if ($form->isSubmitted())  {
  453.             $data = $form->getData();
  454.             $em = $this->getDoctrine()->getManager();
  455.             $em->persist($data);
  456.             $em->flush();
  457.             return $this->redirect($this->generateUrl('app_index_stagiaires'));
  458.         }
  459.         return $this->render('stagiaire-add.html.twig', array('form' => $form->createView()));
  460.  
  461.     }
  462.  
  463.     /**
  464.      * @Route("/admin/stagiaire-edit/{id}")
  465.      */
  466.     public function editstagiaireAction($id, Request $request)
  467.     {
  468.         $em = $this->getDoctrine()->getManager();
  469.         $lestagiaire = $em->getRepository('AppBundle:Stagiaire')->find($id);
  470.         $form = $this->createForm(new StagiaireType(), $lestagiaire);
  471.         $form->handleRequest($request);
  472.  
  473.         if ($form->isSubmitted())  {
  474.             $data = $form->getData();
  475.             $em->persist($data);
  476.             $em->flush();
  477.             return $this->redirect($this->generateUrl('app_index_stagiaires'));
  478.         }
  479.         return $this->render('stagiaire-edit.html.twig', array('form' => $form->createView()));
  480.     }
  481.  
  482.     /**
  483.      * @Route("/admin/del-stagiaire/{id}")
  484.      */
  485.     public function delstagiaireAction($id, Request $request)
  486.     {
  487.         $form = $this->createFormBuilder($id)->getForm();
  488.  
  489.         if ($form->handleRequest($request)) {
  490.             $em = $this->getDoctrine()->getManager();
  491.             $entity = $em->getRepository('AppBundle:Stagiaire')
  492.                 ->find($id);
  493.             $em->remove($entity);
  494.             $em->flush();
  495.             return $this->redirect($this->generateUrl('app_index_stagiaires'));
  496.         }
  497.         return $this->render('planning.html.twig');
  498.     }
  499.  
  500.     /**
  501.      * @Route("/admin/soirees")
  502.      */
  503.     public function soireesAction()
  504.     {
  505.         $repository = $this->getDoctrine()
  506.             ->getRepository('AppBundle:Soiree');
  507.         $soirees = $repository->findAll();
  508.         return $this->render('soirees.html.twig', array('soirees' => $soirees));
  509.     }
  510.  
  511.     /**
  512.      * @Route("/admin/soiree-add")
  513.      */
  514.     public function addsoireesAction(Request $request)
  515.     {
  516.         $unesoiree = new Soiree();
  517.         $form= $this->createForm(SoireeType::class, $unesoiree);
  518.         $form->handleRequest($request);
  519.         if ($form->isSubmitted())  {
  520.             $data = $form->getData();
  521.             $em = $this->getDoctrine()->getManager();
  522.             $em->persist($data);
  523.             $em->flush();
  524.             return $this->redirect($this->generateUrl('app_index_soirees'));
  525.         }
  526.         return $this->render('soiree-add.html.twig', array('form' => $form->createView()));
  527.     }
  528.  
  529.     /**
  530.      * @Route("/admin/soiree-edit/{id}")
  531.      */
  532.     public function editsoireeAction($id, Request $request)
  533.     {
  534.         $em = $this->getDoctrine()->getManager();
  535.         $lasoiree = $em->getRepository('AppBundle:Soiree')->find($id);
  536.         $form = $this->createForm(new SoireeType(), $lasoiree);
  537.         $form->handleRequest($request);
  538.  
  539.         if ($form->isSubmitted())  {
  540.             $data = $form->getData();
  541.             $em->persist($data);
  542.             $em->flush();
  543.             return $this->redirect($this->generateUrl('app_index_soirees'));
  544.         }
  545.         return $this->render('soiree-edit.html.twig', array('form' => $form->createView()));
  546.     }
  547.  
  548.     /**
  549.      * @Route("/admin/del-soiree/{id}")
  550.      */
  551.     public function delsoireeAction($id, Request $request)
  552.     {
  553.         $form = $this->createFormBuilder($id)->getForm();
  554.  
  555.         if ($form->handleRequest($request)) {
  556.             $em = $this->getDoctrine()->getManager();
  557.             $entity = $em->getRepository('AppBundle:Soiree')
  558.                 ->find($id);
  559.             $em->remove($entity);
  560.             $em->flush();
  561.             return $this->redirect($this->generateUrl('app_index_soirees'));
  562.         }
  563.         return $this->render('planning.html.twig');
  564.     }
  565.  
  566.     /**
  567.      * @Route("/admin/event/edit/{id}")
  568.      */
  569.     public function editeventAction()
  570.     {
  571.         return $this->render('planning.html.twig');
  572.     }
  573.  
  574.     /**
  575.      * @Route("/admin/event/del/{id}")
  576.      */
  577.     public function deleventAction()
  578.     {
  579.         return $this->render('planning.html.twig');
  580.     }
  581.  
  582.  
  583. }
Advertisement
Add Comment
Please, Sign In to add comment