src/Controller/Filtro/FiltroFichajeController.php line 115

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Filtro;
  3. use App\Entity\Filtro\FiltroFichaje;
  4. use App\Form\Filtro\FiltroFichajeType;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\HttpFoundation\RequestStack;
  10. #[Route('/filtro/fichaje')]
  11. class FiltroFichajeController extends AbstractController
  12. {
  13.     #[Route('/'name'app_filtro_fichaje_index'methods: ['GET''POST'])]
  14.     public function index(RequestStack $requestStackRequest $request): Response
  15.     {
  16.         $session $requestStack->getSession();
  17.         $em $this->getDoctrine()->getManager();
  18.         $fichaje = new FiltroFichaje();
  19.         
  20.         if (!is_null($session->get('filtro.fichaje'))){
  21.             $fichaje unserialize($session->get('filtro.fichaje'));
  22.         }
  23.         
  24.         if(!is_null($fichaje->getEmpleada())){
  25.             $empleada$em->getRepository("App:Admin\Empleada")->find($fichaje->getEmpleada()->getId());
  26.             $fichaje->setEmpleada($empleada);
  27.         }
  28.         if(!is_null($fichaje->getProyecto())){
  29.             $proyecto$em->getRepository("App:Comun\Proyecto")->find($fichaje->getProyecto()->getId());
  30.             $fichaje->setProyecto($proyecto);
  31.         }
  32.         if(!is_null($fichaje->getTarea())){
  33.             $tarea$em->getRepository("App:Comun\Tarea")->find($fichaje->getTarea()->getId());
  34.             $fichaje->setTarea($tarea);
  35.         }        
  36.         $form $this->createForm(FiltroFichajeType::class, $fichaje);
  37.         $form->handleRequest($request);
  38.         if ($form->isSubmitted() && $form->isValid()) {
  39.             if (!is_null($fichaje->getProyecto())){
  40.                 $fichaje->setProyecto($fichaje->getProyecto());
  41.             }
  42.             if (!is_null($fichaje->getEmpleada())){
  43.                 $fichaje->setEmpleada($fichaje->getEmpleada());
  44.             }
  45.         
  46.             
  47.             $session->set('filtro.fichaje'serialize($fichaje));
  48.         
  49.             return $this->redirectToRoute('app_filtro_fichaje_index', [], Response::HTTP_SEE_OTHER);
  50.         }
  51.         return $this->renderForm('filtro/fichaje/filtro.html.twig', [
  52.             'fichaje' => $fichaje,
  53.             'form' => $form,
  54.         ]);
  55.     }
  56.     
  57.     #[Route('/indexEmpleada/'name'app_filtro_fichaje_index_empleada'methods: ['GET''POST'])]
  58.     public function indexEmpleada(RequestStack $requestStackRequest $request): Response
  59.     {
  60.         $session $requestStack->getSession();
  61.         $em $this->getDoctrine()->getManager();
  62.         $fichaje = new FiltroFichaje();
  63.         
  64.         if (!is_null($session->get('filtro.fichajeEmpleada'))){
  65.             $fichaje unserialize($session->get('filtro.fichajeEmpleada'));
  66.         }
  67.         if(!is_null($fichaje->getEmpleada())){
  68.             $empleada$em->getRepository("App:Admin\Empleada")->find($fichaje->getEmpleada()->getId());
  69.             $fichaje->setEmpleada($empleada);
  70.         }
  71.         if(!is_null($fichaje->getProyecto())){
  72.             $proyecto$em->getRepository("App:Comun\Proyecto")->find($fichaje->getProyecto()->getId());
  73.             $fichaje->setProyecto($proyecto);
  74.         }
  75.         if(!is_null($fichaje->getTarea())){
  76.             $tarea$em->getRepository("App:Comun\Tarea")->find($fichaje->getTarea()->getId());
  77.             $fichaje->setTarea($tarea);
  78.         }        
  79.         $form $this->createForm(\App\Form\Filtro\FiltroFichajeEmpleadaType::class, $fichaje);
  80.         $form->handleRequest($request);
  81.         if ($form->isSubmitted() && $form->isValid()) {
  82.             if (!is_null($fichaje->getProyecto())){
  83.                 $fichaje->setProyecto($fichaje->getProyecto());
  84.             }
  85.             if (!is_null($fichaje->getEmpleada())){
  86.                 $fichaje->setEmpleada($fichaje->getEmpleada());
  87.             }
  88.             
  89.             $session->set('filtro.fichajeEmpleada'serialize($fichaje));
  90.         
  91.             return $this->redirectToRoute('app_filtro_fichaje_index', [], Response::HTTP_SEE_OTHER);
  92.         }
  93.         return $this->renderForm('filtro/fichaje/filtroEmpleada.html.twig', [
  94.             'fichaje' => $fichaje,
  95.             'form' => $form,
  96.         ]);
  97.     }
  98.     
  99.     
  100.     
  101.     #[Route('/formtarea/{proyecto}'name'app_filtro_fichaje_formtarea'methods: ['GET'])]
  102.     public function formTarea(\App\Entity\Comun\Proyecto $proyecto=nullRequest $request): Response
  103.     {
  104.          $em $this->getDoctrine()->getManager();
  105.          $form=$this->createForm(\App\Form\Filtro\FiltroFichajeProyectoTareaType::class, null, ['proyecto'=>$proyecto]);
  106.          $form->handleRequest($request);
  107.         
  108.         return $this->renderForm('filtro/fichaje/formTarea.html.twig', [
  109.             'form'=>$form,
  110.             
  111.         ]);
  112.     }
  113.     
  114.   
  115.     #[Route('/aplicado'name'app_filtro_fichaje_aplicado'methods: ['GET'])]
  116.     public function aplicado(RequestStack $requestStack): Response
  117.     {
  118.         $session $requestStack->getSession();
  119.         
  120.         $fichaje unserialize($session->get('filtro.fichaje'));
  121.         if (!$fichaje$fichaje = new FiltroFichaje();
  122.         
  123.         return $this->renderForm('filtro/fichaje/aplicado.html.twig', [
  124.             'fichaje' => $fichaje,
  125.             
  126.         ]);
  127.     }
  128.     
  129.   
  130.     #[Route('/indexEmpleada/aplicado'name'app_filtro_fichaje_aplicado_empleada'methods: ['GET'])]
  131.     public function aplicadoEmpleada(RequestStack $requestStack): Response
  132.     {
  133.         $session $requestStack->getSession();
  134.         
  135.         $fichaje unserialize($session->get('filtro.fichajeEmpleada'));
  136.         if (!$fichaje$fichaje = new FiltroFichaje();
  137.         
  138.         return $this->renderForm('filtro/fichaje/aplicado.html.twig', [
  139.             'fichaje' => $fichaje,
  140.             
  141.         ]);
  142.     }
  143.     
  144.     #[Route('/limpiar'name'app_filtro_fichaje_limpiar'methods: ['GET'])]
  145.     public function limpiar(RequestStack $requestStack): Response
  146.     {
  147.         $session $requestStack->getSession();
  148.         
  149.         $session->set('filtro.fichaje'null);   
  150.         return $this->redirectToRoute('app_filtro_fichaje_index', [], Response::HTTP_SEE_OTHER);
  151.     }
  152.     #[Route('/indexEmpleada/limpiar'name'app_filtro_fichaje_limpiar_empleaada'methods: ['GET'])]
  153.     public function limpiarEmpleada(RequestStack $requestStack): Response
  154.     {
  155.         $session $requestStack->getSession();
  156.         
  157.         $session->set('filtro.fichajeEmpleada'null);   
  158.         return $this->redirectToRoute('app_filtro_fichaje_index', [], Response::HTTP_SEE_OTHER);
  159.     }
  160. }