src/Controller/Dysfonctionnement/DysfonctionnementController.php line 57

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Dysfonctionnement;
  3. use App\Entity\bilan\Entity;
  4. use App\Entity\Domain;
  5. use App\Entity\Dysfonctionnement\CategoryConstat;
  6. use App\Entity\Dysfonctionnement\Constat;
  7. use App\Entity\Processus;
  8. use App\Entity\Source;
  9. use App\Entity\User;
  10. use App\Repository\Dysfonctionnement\CategoryConstatRepository;
  11. use App\Repository\Dysfonctionnement\ConstatRepository;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. use Symfony\Component\HttpFoundation\JsonResponse;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. /**
  18.  * @Route("/constat")
  19.  */
  20. class DysfonctionnementController extends AbstractController
  21. {
  22.     /**
  23.      * @Route("/list/dysfonctionnement", name="Constat_list", methods={"GET"})
  24.      */
  25.     public function suiviConstatDysfonctionnement(Request $request): Response
  26.     {
  27.         $domaines_list $this->getDoctrine()->getRepository(Domain::class)->findAll();
  28.         $entites_list $this->getDoctrine()->getRepository(Entity::class)->findAll();
  29.         $processus_list $this->getDoctrine()->getRepository(Processus::class)->findAll();
  30.         $sources_list $this->getDoctrine()->getRepository(Source::class)->findAll();
  31.         $users_list $this->getDoctrine()->getRepository(User::class)->findAll();
  32.         $menu="ameliorer";
  33.         $left_menu="suivi_general";
  34.         return $this->render('dysfonctionnementTemplate/dysfonctionnement/suiviGeneralDysfonctionnement.html.twig', [
  35.             'menu' => $menu,
  36.             'left_menu' => $left_menu,
  37.             'entites_list' => $entites_list,
  38.             'users_list' => $users_list,
  39.             'sources_list' => $sources_list,
  40.             'domaines_list' => $domaines_list,
  41.             'processus_list' => $processus_list
  42.         ]);
  43.     }
  44.     /**
  45.      * @Route("/analysConstatDysfonctionnement", name="analyse_Constat_dysfonctionnement", methods={"GET"})
  46.      */
  47.     public function constatDysfonctionnementData(Request $requestConstatRepository $constatRepository): Response
  48.     {
  49.         $listConstatDysfonctionnement $constatRepository->getListConstat();
  50.         $data = array("data" => $listConstatDysfonctionnement);
  51.         //dd($data);
  52.         return new JsonResponse($data);
  53.     }
  54.     /**
  55.      * @Route("/list/accident", name="constat_list_accident", methods={"GET"})
  56.      */
  57.     public function suiviConstatAccident(Request $request): Response
  58.     {
  59.         $entites_list $this->getDoctrine()->getRepository(Entity::class)->findAll();
  60.         $processus_list $this->getDoctrine()->getRepository(Processus::class)->findAll();
  61.         $users_list $this->getDoctrine()->getRepository(User::class)->findAll();
  62.         $menu="ameliorer";
  63.         $left_menu="suivi_general";
  64.         return $this->render('dysfonctionnementTemplate/dysfonctionnement/suiviGeneralAccident.html.twig', [
  65.             'menu' => $menu,
  66.             'left_menu' => $left_menu,
  67.             'entites_list' => $entites_list,
  68.             'users_list' => $users_list,
  69.             'processus_list' => $processus_list
  70.         ]);
  71.     }
  72.     /**
  73.      * @Route("/list/reclamation", name="constat_list_reclamation", methods={"GET"})
  74.      */
  75.     public function suiviConstatReclamation(Request $request): Response
  76.     {
  77.         $entites_list $this->getDoctrine()->getRepository(Entity::class)->findAll();
  78.         $processus_list $this->getDoctrine()->getRepository(Processus::class)->findAll();
  79.         $sources_list $this->getDoctrine()->getRepository(Source::class)->findAll();
  80.         $users_list $this->getDoctrine()->getRepository(User::class)->findAll();
  81.         $menu="ameliorer";
  82.         $left_menu="suivi_general";
  83.         return $this->render('dysfonctionnementTemplate/dysfonctionnement/suiviGeneralReclamation.html.twig', [
  84.             'menu' => $menu,
  85.             'left_menu' => $left_menu,
  86.             'entites_list' => $entites_list,
  87.             'sources_list' => $sources_list,
  88.             'users_list' => $users_list,
  89.             'processus_list' => $processus_list
  90.         ]);
  91.     }
  92.     /**
  93.      * @Route("/analysConstatReclamation", name="analyse_Constat_reclamation", methods={"GET"})
  94.      */
  95.     public function constatReclamationData(Request $requestConstatRepository $constatRepository): Response
  96.     {
  97.          $listConstatReclamation $constatRepository->getListConstatReclamationTransformAll();
  98.          return new JsonResponse($listConstatReclamation);
  99.     }
  100.     /**
  101.      * @Route("/configuration/configuration_terminologie", name="configurer_terminologie")
  102.      */
  103.     public function configurationTerminologie(): Response
  104.     {
  105.         $menu="ameliorer";
  106.         $left_menu="configuration_terminologie";
  107.         return $this->render('dysfonctionnementTemplate/configuration_terminologie/index.html.twig', [
  108.             'menu'=>$menu,
  109.             'left_menu'=>$left_menu
  110.         ]);
  111.     }
  112.     /**
  113.      * @Route("/configuration/configTerminologieData", name="config_terminologie", methods={"GET"})
  114.      */
  115.     public function configTerminologieData(Request $requestCategoryConstatRepository $categoryConstatRepository): Response
  116.     {
  117.         $listCategoryConstat$categoryConstatRepository->getListCategoryConstat();
  118.         $data = array("data" => $listCategoryConstat);
  119.         //dd($data);
  120.         return new JsonResponse($data);
  121.     }
  122.     /**
  123.      * @Route("/addTerm", name="add_Term", methods={"GET","POST"})
  124.      */
  125.     public function addTerm(Request $request):Response
  126.     {
  127.         $domain_list $this->getDoctrine()->getRepository(Domain::class)->findAll();
  128.         return $this->render('dysfonctionnementTemplate/configuration_terminologie/_form.html.twig', [
  129.             'domain_list' => $domain_list,
  130.         ]);
  131.     }
  132.     /**
  133.      * @Route("/addConfigTerm/new", name="config_Term_add", methods={"GET","POST"})
  134.      */
  135.     public function addConfigTerm(Request $request):Response
  136.     {
  137.         $em $this->getDoctrine()->getManager();
  138.         $domain_id $request->request->get('domain');
  139.         $domain $em->getRepository(Domain::class)->find($domain_id);
  140.         $type_constat $request->request->get('type_constat');
  141.         $category $request->request->get('category');
  142.         $categoryConstat = new CategoryConstat();
  143.         $categoryConstat->setDomain($domain);
  144.         $categoryConstat->setTypeConstat($type_constat);
  145.         $categoryConstat->setTitle($category);
  146.         $em->persist($categoryConstat);
  147.         $em->flush();
  148.         $menu="ameliorer";
  149.         $left_menu="configuration_terminologie";
  150.         return $this->redirectToRoute('configurer_terminologie');
  151.     }
  152.     /**
  153.      * @Route("/modal/config_terminologie/{id}", name="update_config_modal", methods={"GET","POST"})
  154.      */
  155.     public function priseDecisionModal(Request $requestCategoryConstat $categoryConstat): Response
  156.     {
  157.         $domain_list $this->getDoctrine()->getRepository(Domain::class)->findAll();
  158.         return $this->render('dysfonctionnementTemplate/configuration_terminologie/update_form.html.twig', [
  159.             'domain_list' => $domain_list,
  160.             'categoryConstat' => $categoryConstat
  161.         ]);
  162.     }
  163.     /**
  164.      * @Route("/update/config_terminologie/{id}", name="update_config_terminologie", methods={"GET","POST"})
  165.      */
  166.     public function updateConfigTerminologie(Request $requestCategoryConstat $categoryConstat): Response
  167.     {
  168.         $doctrine $this->getDoctrine();
  169.         $entityManager $this->getDoctrine()->getManager();
  170.         if (!$categoryConstat) {
  171.             throw $this->createNotFoundException(
  172.                 'There are no category with the following id: ' $categoryConstat->getId()
  173.             );
  174.         }
  175.         $domain_id $request->request->get('domain');
  176.         $domain $doctrine->getRepository(Domain::class)->find($domain_id);
  177.         $type_constat $request->request->get('type_constat');
  178.         $category $request->request->get('category');
  179.         $categoryConstat->setDomain($domain);
  180.         $categoryConstat->setTypeConstat($type_constat);
  181.         $categoryConstat->setTitle($category);
  182.         $entityManager->flush();
  183.         return $this->redirectToRoute('configurer_terminologie');
  184.     }
  185.     /**
  186.      * @Route("/delete/config_terminologie/{id}", name="delete_config_terminologie", methods={"GET","POST"})
  187.      */
  188.     public function deleteConfigTerminologie(Request $requestCategoryConstat $categoryConstat): Response
  189.     {
  190.         $entityManager $this->getDoctrine()->getManager();
  191.         if (!$categoryConstat) {
  192.             throw $this->createNotFoundException(
  193.                 'There are no category with the following id: ' $categoryConstat->getId()
  194.             );
  195.         }
  196.         $entityManager->remove($categoryConstat);
  197.         $entityManager->flush();
  198.         return new JsonResponse(["deleted" => 1]);
  199.     }
  200.     /**
  201.      * @Route("/modal/finRetourExp", name="finRetourExp_modal", methods={"GET"})
  202.      */
  203.     public function ModalfinRetourExp(Request $request): Response
  204.     {
  205.         $constat_id =$request->query->get('constat','');
  206.         return $this->render('dysfonctionnementTemplate/analyse/finRetourExpModal.html.twig', [
  207.             'constat_id'=>$constat_id
  208.         ]);
  209.     }
  210.     /**
  211.      * @Route("/modal/finRetourExp/save/{id}", name="save_fin_retour_exp", methods={"POST"})
  212.      */
  213.     public function save_fin_retour_exp(Constat $constat)
  214.     {
  215.         $constat->setRetourExpClosed(true);
  216.         $constat->setEnableListener(false);
  217.         $em $this->getDoctrine()->getManager();
  218.         $em->flush();
  219.         return new JsonResponse(['updated'=>1]);
  220.     }
  221. }