src/Controller/CardController.php line 93

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace App\Controller;
  11. use Doctrine\ORM\EntityManagerInterface;
  12. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. use App\Entity\User;
  18. use App\Entity\Entry;
  19. use App\Entity\Demande;
  20. use App\Entity\Participant;
  21. /**
  22.  * Controller used to manage current user.
  23.  *
  24.  * @author Romain Monteil <monteil.romain@gmail.com>
  25.  */
  26. #[Route('/card')]
  27. class CardController extends AbstractController {
  28.     #[Route('/show/{id}'methods: ['GET''POST'], name'admin_show_badge'), IsGranted('ROLE_AGENT')]
  29.     public function showCard(Request $request$idEntityManagerInterface $entityManager): Response {
  30.         // create the user and hash its password
  31.         $user $entityManager->getRepository(Participant::class)->findOneById($id);
  32. //        return $this->render('card/showCard.html.twig', [
  33.         return $this->render('card/printQrCode.html.twig', [
  34.                     'user' => $user,
  35.         ]);
  36.     }
  37.     #[Route('/show/{id}/orgrecto'methods: ['GET''POST'], name'admin_show_badge_orgrecto'), IsGranted('ROLE_AGENT')]
  38.     public function showCardOrgRecto(Request $request$idEntityManagerInterface $entityManager): Response {
  39.         // create the user and hash its password
  40.         $user $entityManager->getRepository(User::class)->findOneById($id);
  41. //        return $this->render('card/showCard.html.twig', [
  42.         return $this->render('card/showCardOrgRecto.html.twig', [
  43.                     'user' => $user,
  44.         ]);
  45.     }
  46.     #[Route('/show/{id}/matica'methods: ['GET''POST'], name'admin_show_matica_card'), IsGranted('ROLE_AGENT')]
  47.     public function maticaCard(Request $request$idEntityManagerInterface $entityManager): Response {
  48.         // create the user and hash its password
  49.         $user $entityManager->getRepository(User::class)->findOneById($id);
  50. //        return $this->render('card/showCard.html.twig', [
  51.         return $this->render('card/showCardMatica.html.twig', [
  52.                     'user' => $user,
  53.         ]);
  54.     }
  55.     #[Route('/show/{id}/orgverso'methods: ['GET''POST'], name'admin_show_badge_orgverso'), IsGranted('ROLE_AGENT')]
  56.     public function showCardOrgVerso(Request $request$idEntityManagerInterface $entityManager): Response {
  57.         // create the user and hash its password
  58.         $user $entityManager->getRepository(Participant::class)->findOneById($id);
  59. //        return $this->render('card/showCard.html.twig', [
  60.         return $this->render('card/showCardOrgVerso.html.twig', [
  61.                     'user' => $user,
  62.         ]);
  63.     }
  64.     #[Route('/list-demand'methods: ['GET''POST'], name'admin_list_demandes'), IsGranted('ROLE_ADMIN')]
  65.     public function listDemande(Request $requestEntityManagerInterface $entityManager): Response {
  66.         // create the user and hash its password
  67.         $demandes $entityManager->getRepository(Demande::class)->findAll();
  68.         return $this->render('card/listDemandes.html.twig', [
  69.                     'demandes' => $demandes,
  70.         ]);
  71.     }
  72.     #[Route('/demande'methods: ['GET''POST'], name'demande_card')]
  73.     public function demandeCard(Request $requestEntityManagerInterface $entityManager): Response {
  74.         if ($request->isMethod('post')) {
  75.             $demande = new Demande();
  76.             $demande->setName($request->get('name'));
  77.             $demande->setCin($request->get('cin'));
  78.             $demande->setComment($request->get('comment'));
  79.             $demande->setOrganisation($request->get('organisation'));
  80.             $entityManager->persist($demande);
  81.             $entityManager->flush();
  82.             if ($request->files->get('image')) {
  83.                 $file $request->files->get('image');
  84.                 $demande->setImage("uploads/request/" $demande->getId() . "/" $file->getClientOriginalName());
  85.                 $file->move("uploads/request/" $demande->getId() . "/"$file->getClientOriginalName());
  86.             }
  87.             $entityManager->persist($demande);
  88.             $entityManager->flush();
  89.             $this->addFlash('success''Demande de carte enregistrĂ© avec succĂ©ss');
  90.             return $this->redirectToRoute('demande_card', ['sent' => 'success'
  91.             ]);
  92.         }
  93.         return $this->render('card/demandeCard.html.twig');
  94.     }
  95. }