src/Controller/ManagementController.php line 28

Open in your IDE?
  1. <?php
  2. // src/Controller/AideController.php
  3. namespace App\Controller;
  4. use App\Entity\CategorieArticleAide;
  5. use App\Entity\ArticleAide;
  6. use App\Entity\Ticket;
  7. use App\Form\TicketType;
  8. use App\Entity\CommentaireTicket;
  9. use App\Form\CommentaireTicketType;
  10. use App\Entity\ValiditeService;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  15. /**
  16.  * @Route("/{_locale}/n_dk5_dok")
  17.  */
  18. class ManagementController extends AbstractController
  19. {    
  20.     
  21.     /**
  22.      * @Route("/", name="management_index")
  23.      */
  24.     public function indexAction()
  25.     {
  26.         $em $this->getDoctrine()->getManager();
  27.         
  28.     
  29.           return $this->render('management/index.html.twig', [
  30.           
  31.         ]);
  32.         
  33.     }
  34.     
  35.     /**
  36.      * @Route("/tickets", name="management.tickets")
  37.      */
  38.     public function ticketsAction()
  39.     {
  40.         $em $this->getDoctrine()->getManager();
  41.         
  42.         $tickets $em->getRepository(Ticket::class)
  43.                         ->listeTicket();
  44.     
  45.           return $this->render('management/tickets.html.twig', [
  46.           'tickets' => $tickets
  47.         ]);
  48.         
  49.     }
  50.     
  51.     /**
  52.      * @Route("/display-ticket/{id}", name="management.display_ticket")
  53.      * @return \Symfony\Component\HttpFoundation\Response
  54.      */
  55.     public function displayTicketAction(Request $requestTicket $ticket)
  56.     {
  57.         $em $this->getDoctrine()
  58.                     ->getManager();
  59.                     
  60.         $boutique $ticket->getBoutique();
  61.         $user $this->getUser();
  62.         
  63.         
  64.         $commentaires $em->getRepository(CommentaireTicket::class)
  65.                             ->findByTicket($ticket->getId());
  66.         $commentaireTicket = new CommentaireTicket;
  67.         
  68.         $user $this->getUser();
  69.         $form $this->createForm(CommentaireTicketType::class, $commentaireTicket);
  70.         
  71.         $ok_soumission '';
  72.         $error '';
  73.         
  74.         if($request->getMethod() == 'POST'){
  75.             
  76.                $form->handleRequest($request);
  77.                if($form->isValid()){
  78.                    
  79.                    $commentaireTicket->setTicket($ticket);
  80.                    $commentaireTicket->setUser($user);
  81.                    
  82.                   $em->persist($commentaireTicket);
  83.                   $em->flush();
  84.                 
  85.                 $commentaires $em->getRepository(CommentaireTicket::class)
  86.                             ->findByTicket($ticket->getId());
  87.                 $ok_soumission =" Votre message a été pris en compte";
  88.                     
  89.                 $commentaireTicket = new CommentaireTicket;
  90.                 
  91.                 $form $this->createForm(CommentaireTicketType::class, $commentaireTicket);
  92.                     
  93.                 } else {
  94.                     $error =" Veillez corrigez vos erreurs";
  95.                 }
  96.         }
  97.         
  98.         return $this->render('management/display_ticket.html.twig', [
  99.            'boutique' => $boutique,
  100.            'ticket' => $ticket,
  101.            'form' => $form->createView(),
  102.            'commentaires' => $commentaires
  103.         ]);
  104.     }
  105.     
  106.     /**
  107.      * @Route("/sales", name="management.sales")
  108.      * @return \Symfony\Component\HttpFoundation\Response
  109.      */
  110.     public function salesAction(Request $request)
  111.     {
  112.         $em $this->getDoctrine()
  113.                     ->getManager();
  114.                     
  115.         $user $this->getUser();
  116.         
  117.         
  118.         $sales $em->getRepository(ValiditeService::class)
  119.                             ->lastSales();
  120.         
  121.         return $this->render('management/sales.html.twig', [
  122.            'sales' => $sales
  123.         ]);
  124.     }
  125. }