src/Controller/ValidationFicheController.php line 100

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\ResultResto44Repository;
  4. use App\Entity\ResultResto44;
  5. use App\Repository\DepartementRepository;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\HttpFoundation\RedirectResponse;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Twig\Environment;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use App\Service\AgentService;
  13. use App\Service\admin\AdminService;
  14. use Symfony\Component\HttpFoundation\RequestStack;
  15. class ValidationFicheController extends AbstractController {
  16.     private $twig;
  17.    
  18.     private $agentService;
  19.     private $depRepo;
  20.     private $requestStack;
  21.    
  22.     public function __construct(Environment $twigAgentService $agentService
  23.     DepartementRepository $depRepo,RequestStack $requestStack){
  24.        
  25.         $this->twig=$twig;
  26.         $this->agentService=$agentService;
  27.         $this->depRepo=$depRepo;
  28.         $this->requestStack $requestStack;
  29.       
  30.       
  31.     }
  32.     /**
  33.      *@Route("/depChoice", name="choice_page", methods={"GET"}) 
  34.      * 
  35.      */
  36.       public function choicePage(){
  37.         $this->denyAccessUnlessGranted('ROLE_USER',null,'access denied');
  38.         $user $this->getUser();
  39.         $items=$this->depRepo->getDepByUseridRes($user->getId());
  40.         return new Response($this->twig->render('agent/choiceList.html.twig',["items"=>$items]));
  41.       }
  42.     
  43.     /**
  44.      * @Route ("/pResto", name="fiche_valid_rest", methods={"GET"})
  45.      * 
  46.      */
  47.     public function firstView(){
  48.         $this->denyAccessUnlessGranted('ROLE_USER',null,'access denied');
  49.         $session $this->requestStack->getSession();
  50.         $dep=$session->get('dep');
  51.         $items=$this->agentService->getFicheToValidate($dep);
  52.         $deps=array("75","06","13","33","59","69","67","94");
  53.         if(in_array($dep,$deps)){
  54.             
  55.           $items=$this->agentService->getCodinseeByDep($dep);
  56.           //dd($items);
  57.           return new Response($this->twig->render("agent/codinsseChoose.html.twig",["items"=>$items]));
  58.         }else{
  59.             if(count($items)>0){
  60.                 $user $this->getUser();
  61.                 $deps=$this->depRepo->getDepByUseridRes($user->getId());
  62.                 return new Response($this->twig->render('agent/interfaceDeValidation.html.twig',['items'=>$items,"deps"=>$deps"depChoiced"=>$dep ]));
  63.             }else
  64.                 return new Response($this->twig->render('agent/validationEnd.html.twig'));
  65.         }
  66.         
  67.        
  68.     
  69.     }
  70.     /**
  71.      * @Route("/pResto/specialDep", name="fiche_valid_for_special_rest",methods={"GEt"})
  72.      */
  73.      public function specialDep(){
  74.         $this->denyAccessUnlessGranted('ROLE_USER',null,'access denied');
  75.         $session $this->requestStack->getSession();
  76.         $codinsee=$session->get('codinsee');
  77.         $dep=$session->get('dep');
  78.         $items=$this->agentService->getFicheFromSpecialDepToValidate($dep,$codinsee);
  79.         if(count($items)>0){
  80.             $user $this->getUser();
  81.                 $deps=$this->depRepo->getDepByUseridRes($user->getId());
  82.                 return new Response($this->twig->render('agent/interfaceDeValidation.html.twig',['items'=>$items,
  83.                 "deps"=>$deps"depChoiced"=>$dep,"codinsee"=>$codinsee ]));
  84.         }else
  85.             return new Response($this->twig->render('agent/validationEnd.html.twig'));
  86.      }
  87.     /**
  88.      * @Route ("/", name="home")
  89.      * 
  90.      */
  91.     public function homePage(){
  92.       
  93.         $hasAccess $this->isGranted('ROLE_USER');
  94.         if($hasAccess)
  95.             return $this->redirectToRoute("choice_page");
  96.         else 
  97.             return $this->redirectToRoute("login");
  98.     }
  99.     
  100. }