src/Controller/CardController.php line 45

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_generate_badge'), IsGranted('ROLE_AGENT')]
  29.     public function generateBadge(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/printQrCode.html.twig', [
  33.                     'user' => $user,
  34.         ]);
  35.     }
  36.     #[Route('/show-9x14/{id}'methods: ['GET''POST'], name'admin_show_badge9x14'), IsGranted('ROLE_AGENT')]
  37.     public function showCard9x14(Request $request$idEntityManagerInterface $entityManager): Response {
  38.         // create the user and hash its password
  39.         $user $entityManager->getRepository(Participant::class)->findOneById($id);
  40. //        return $this->render('card/showCard.html.twig', [
  41.         return $this->render('card/showCard9x14.html.twig', [
  42.                     'user' => $user,
  43.         ]);
  44.     }
  45.     #[Route('/show/{id}/orgrecto'methods: ['GET''POST'], name'admin_show_badge_orgrecto'), IsGranted('ROLE_AGENT')]
  46.     public function showCardOrgRecto(Request $request$idEntityManagerInterface $entityManager): Response {
  47.         // create the user and hash its password
  48.         $user $entityManager->getRepository(User::class)->findOneById($id);
  49. //        return $this->render('card/showCard.html.twig', [
  50.         return $this->render('card/showCardOrgRecto.html.twig', [
  51.                     'user' => $user,
  52.         ]);
  53.     }
  54.     #[Route('/show/{id}/matica'methods: ['GET''POST'], name'admin_show_matica_card'), IsGranted('ROLE_AGENT')]
  55.     public function maticaCard(Request $request$idEntityManagerInterface $entityManager): Response {
  56.         // create the user and hash its password
  57.         $user $entityManager->getRepository(User::class)->findOneById($id);
  58. //        return $this->render('card/showCard.html.twig', [
  59.         return $this->render('card/showCardMatica.html.twig', [
  60.                     'user' => $user,
  61.         ]);
  62.     }
  63.     #[Route('/show/{id}/orgverso'methods: ['GET''POST'], name'admin_show_badge_orgverso'), IsGranted('ROLE_AGENT')]
  64.     public function showCardOrgVerso(Request $request$idEntityManagerInterface $entityManager): Response {
  65.         // create the user and hash its password
  66.         $user $entityManager->getRepository(Participant::class)->findOneById($id);
  67. //        return $this->render('card/showCard.html.twig', [
  68.         return $this->render('card/showCardOrgVerso.html.twig', [
  69.                     'user' => $user,
  70.         ]);
  71.     }
  72.     #[Route('/list-demand'methods: ['GET''POST'], name'admin_list_demandes'), IsGranted('ROLE_ADMIN')]
  73.     public function listDemande(Request $requestEntityManagerInterface $entityManager): Response {
  74.         // create the user and hash its password
  75.         $demandes $entityManager->getRepository(Demande::class)->findAll();
  76.         return $this->render('card/listDemandes.html.twig', [
  77.                     'demandes' => $demandes,
  78.         ]);
  79.     }
  80.     #[Route('/demande'methods: ['GET''POST'], name'demande_card')]
  81.     public function demandeCard(Request $requestEntityManagerInterface $entityManager): Response {
  82.         if ($request->isMethod('post')) {
  83.             $demande = new Demande();
  84.             $demande->setName($request->get('name'));
  85.             $demande->setCin($request->get('cin'));
  86.             $demande->setComment($request->get('comment'));
  87.             $demande->setOrganisation($request->get('organisation'));
  88.             $entityManager->persist($demande);
  89.             $entityManager->flush();
  90.             if ($request->files->get('image')) {
  91.                 $file $request->files->get('image');
  92.                 $demande->setImage("uploads/request/" $demande->getId() . "/" $file->getClientOriginalName());
  93.                 $file->move("uploads/request/" $demande->getId() . "/"$file->getClientOriginalName());
  94.             }
  95.             $entityManager->persist($demande);
  96.             $entityManager->flush();
  97.             $this->addFlash('success''Demande de carte enregistrĂ© avec succĂ©ss');
  98.             return $this->redirectToRoute('demande_card', ['sent' => 'success'
  99.             ]);
  100.         }
  101.         return $this->render('card/demandeCard.html.twig');
  102.     }
  103. }