<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Controller;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use App\Entity\User;
use App\Entity\Entry;
use App\Entity\Demande;
use App\Entity\Participant;
/**
* Controller used to manage current user.
*
* @author Romain Monteil <monteil.romain@gmail.com>
*/
#[Route('/card')]
class CardController extends AbstractController {
#[Route('/show/{id}', methods: ['GET', 'POST'], name: 'admin_show_badge'), IsGranted('ROLE_AGENT')]
public function showCard(Request $request, $id, EntityManagerInterface $entityManager): Response {
// create the user and hash its password
$user = $entityManager->getRepository(Participant::class)->findOneById($id);
// return $this->render('card/showCard.html.twig', [
return $this->render('card/printQrCode.html.twig', [
'user' => $user,
]);
}
#[Route('/show/{id}/orgrecto', methods: ['GET', 'POST'], name: 'admin_show_badge_orgrecto'), IsGranted('ROLE_AGENT')]
public function showCardOrgRecto(Request $request, $id, EntityManagerInterface $entityManager): Response {
// create the user and hash its password
$user = $entityManager->getRepository(User::class)->findOneById($id);
// return $this->render('card/showCard.html.twig', [
return $this->render('card/showCardOrgRecto.html.twig', [
'user' => $user,
]);
}
#[Route('/show/{id}/matica', methods: ['GET', 'POST'], name: 'admin_show_matica_card'), IsGranted('ROLE_AGENT')]
public function maticaCard(Request $request, $id, EntityManagerInterface $entityManager): Response {
// create the user and hash its password
$user = $entityManager->getRepository(User::class)->findOneById($id);
// return $this->render('card/showCard.html.twig', [
return $this->render('card/showCardMatica.html.twig', [
'user' => $user,
]);
}
#[Route('/show/{id}/orgverso', methods: ['GET', 'POST'], name: 'admin_show_badge_orgverso'), IsGranted('ROLE_AGENT')]
public function showCardOrgVerso(Request $request, $id, EntityManagerInterface $entityManager): Response {
// create the user and hash its password
$user = $entityManager->getRepository(Participant::class)->findOneById($id);
// return $this->render('card/showCard.html.twig', [
return $this->render('card/showCardOrgVerso.html.twig', [
'user' => $user,
]);
}
#[Route('/list-demand', methods: ['GET', 'POST'], name: 'admin_list_demandes'), IsGranted('ROLE_ADMIN')]
public function listDemande(Request $request, EntityManagerInterface $entityManager): Response {
// create the user and hash its password
$demandes = $entityManager->getRepository(Demande::class)->findAll();
return $this->render('card/listDemandes.html.twig', [
'demandes' => $demandes,
]);
}
#[Route('/demande', methods: ['GET', 'POST'], name: 'demande_card')]
public function demandeCard(Request $request, EntityManagerInterface $entityManager): Response {
if ($request->isMethod('post')) {
$demande = new Demande();
$demande->setName($request->get('name'));
$demande->setCin($request->get('cin'));
$demande->setComment($request->get('comment'));
$demande->setOrganisation($request->get('organisation'));
$entityManager->persist($demande);
$entityManager->flush();
if ($request->files->get('image')) {
$file = $request->files->get('image');
$demande->setImage("uploads/request/" . $demande->getId() . "/" . $file->getClientOriginalName());
$file->move("uploads/request/" . $demande->getId() . "/", $file->getClientOriginalName());
}
$entityManager->persist($demande);
$entityManager->flush();
$this->addFlash('success', 'Demande de carte enregistré avec succéss');
return $this->redirectToRoute('demande_card', ['sent' => 'success'
]);
}
return $this->render('card/demandeCard.html.twig');
}
}