src/Controller/HomeController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Taction;
  4. use App\Entity\Nv1;
  5. use App\Entity\Tdocument;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\HttpFoundation\JsonResponse;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  11. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  12. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  13. class HomeController extends AbstractController
  14. {
  15.      /**
  16.      * @Route("/home", name="home")
  17.      * @Security("is_granted('ROLE_ADMIN')")
  18.      */
  19.     public function index(Request $request): Response
  20.     {
  21.         $arrayOfpageDocument = [];
  22.         $arrayOfpageAction = [];
  23.         
  24.     
  25.         $Nv1   =  $this->getDoctrine() ->getRepository(Nv1::class)->findAll();
  26.         $userId $this->getUser()->getId();
  27.         
  28.         // $taction    =  $this->getDoctrine() ->getRepository(Taction::class)->findBy(array('suspendre'=>'0'),array('id' => 'desc'));
  29.         $limit 0;
  30.         $category null;
  31.         $code null;
  32.         $id=0;
  33.         $column='id';
  34.         $order='desc';
  35.         $id_dossier_document_plus=null;
  36.         if(isset($_GET['id_dossier_doc_plus'])){
  37.             $id_dossier_document_plus $_GET['id_dossier_doc_plus'];
  38.             $Tdocument   $this->getDoctrine()->getRepository(Tdocument::class)
  39.             ->findBy(array('suspondu'=>'0' 'folder' => $id_dossier_document_plus));
  40.             // dd($Tdocument);
  41.             return $this->render('tableBody/plus_tdocument.html.twig'
  42.             [ 'Tdocument'=>$Tdocument  ]);
  43.         }
  44.         if(isset($_GET['code'])){
  45.             $code $_GET['code'];
  46.         }
  47.         else{
  48.             $code 'N1_1';
  49.         }
  50.         if(isset($_GET['limit'])){
  51.             $limit $_GET['limit'];
  52.             $category $_GET['category'];
  53.         }
  54.         if(isset($_GET['id'])){
  55.             $id $_GET['id'];
  56.         }
  57.         if(isset($_GET['column'])){
  58.             $column $_GET['column'];
  59.         }
  60.         if(isset($_GET['order'])){
  61.             $order $_GET['order'];
  62.         }
  63.         
  64.         $Tdocument   $this->getDoctrine()->getRepository(Tdocument::class)
  65.                        ->findBy(array('suspondu'=>'0' 'code_nv' => $code'folder'=>null),array($column => $order),15$limit);
  66.                   
  67.                        
  68.         $taction    =  $this->getDoctrine() ->getRepository(Taction::class)
  69.                        ->findBy(array('suspendre'=>'0''code_nv' => $code'dossier' => null),array($column => $order),15$limit);
  70.                        
  71.         $Tdocument_Action   $this->getDoctrine()->getRepository(Tdocument::class)
  72.                         ->getDocumentHadAction($code);
  73.             
  74.         if($limit >= && $category == 'document'){
  75.             return $this->render('tableBody/tdocument.html.twig'
  76.                 [ 'Tdocument'=>$Tdocument  ]
  77.             );
  78.         }
  79.         elseif($limit >= && $category == 'action') {
  80.             return $this->render('tableBody/taction.html.twig'
  81.                 [ 'taction' =>  $taction,
  82.                     'Tdocument_Action' => $Tdocument_Action ]
  83.             );
  84.         }
  85.         // if($id >0){
  86.         //     $Tdocument_action   = $this->getDoctrine()->getRepository(Tdocument::class)
  87.         //     ->findBy(array('suspondu'=>'0' , 'id' => $id));
  88.         //     // dd($Tdocument_action);
  89.         //     return $this->render('tableBody/tdocument.html.twig', 
  90.         //     [ 'Tdocument'=>$Tdocument_action  ]
  91.         //     );
  92.         // }
  93.         if($category == null) {
  94.             $TdocumentForPagination $this->getDoctrine()->getRepository(Tdocument::class)->findBy(array('suspondu'=>'0''code_nv' => $code'folder'=>null));
  95.             $numberOfRow count($TdocumentForPagination);
  96.             $recordPerPage 15;
  97.             $num $numberOfRow/$recordPerPage;
  98.             if(fmod($num1) !== 0.00){
  99.                 $numberOfpage = (int)($num 1);
  100.             } else {
  101.                 $numberOfpage = (int)($num);
  102.             }
  103.             
  104.             //$val = '['. 1*10 .'-'. 2*10 .']';
  105.             for($i 0$i $numberOfpage$i++) {
  106.                 $val $i $recordPerPage;
  107.                 array_push($arrayOfpageDocument$val);  
  108.             }
  109.             $TdocumentForPagination $this->getDoctrine()->getRepository(Taction::class)->findBy(array('suspendre'=>'0''code_nv' => $code));
  110.             $numberOfRow count($TdocumentForPagination);
  111.             $num $numberOfRow/$recordPerPage;
  112.             if(fmod($num1) !== 0.00){
  113.                 $numberOfpage = (int)($num 1);
  114.             } else {
  115.                 $numberOfpage = (int)($num);
  116.             }
  117.             // dd($taction);
  118.             
  119.             //$val = '['. 1*10 .'-'. 2*10 .']';
  120.             for($i 0$i $numberOfpage$i++) {
  121.                 $val $i $recordPerPage;
  122.                 array_push($arrayOfpageAction$val);  
  123.             }
  124.             if($id >0){
  125.                 $Tdocument_action   $this->getDoctrine()->getRepository(Tdocument::class)
  126.                 ->findBy(array('suspondu'=>'0' 'id' => $id 'code_nv' => $code));
  127.                 // dd($Tdocument_action);
  128.                 return $this->render('home/contenu_index.html.twig'
  129.                 [   'Tdocument'=>$Tdocument_action,
  130.                     'Nv1' => $Nv1,
  131.                     'user' => $userId,
  132.                     'taction' =>  $taction
  133.                     'arrayOfpageAction' => $arrayOfpageAction
  134.                     'arrayOfpageDocument' => $arrayOfpageDocument,
  135.                     'code_niveau' => $_GET['code'],
  136.                     'Tdocument_Action' => $Tdocument_Action  ]
  137.                 );
  138.     
  139.             }
  140.             if(!isset($_GET['code'])){
  141.                 return $this->render('home/index.html.twig', [ 
  142.                     'Nv1' => $Nv1,
  143.                     'user' => $userId,
  144.                     'Tdocument'=>$Tdocument 
  145.                     'taction' =>  $taction
  146.                     'arrayOfpageAction' => $arrayOfpageAction
  147.                     'arrayOfpageDocument' => $arrayOfpageDocument,
  148.                     'code_niveau' => $code,
  149.                     'Tdocument_Action' => $Tdocument_Action
  150.                 ]);
  151.             }
  152.             else{
  153.                 return $this->render('home/contenu_index.html.twig', [ 
  154.                     'Nv1' => $Nv1,
  155.                     'user' => $userId,
  156.                     'Tdocument'=>$Tdocument 
  157.                     'taction' =>  $taction
  158.                     'arrayOfpageAction' => $arrayOfpageAction
  159.                     'arrayOfpageDocument' => $arrayOfpageDocument,
  160.                     'code_niveau' => $_GET['code'],
  161.                     'Tdocument_Action' => $Tdocument_Action
  162.                 ]);
  163.             }
  164.         }
  165.         
  166.        
  167.     }
  168.     /**
  169.      * @Route("/", name="indexHome")
  170.      */
  171.     public function home()
  172.     {
  173.         return $this->redirectToRoute('home');
  174.     }
  175.    
  176.     /**
  177.      * @Route("/paginationdocument", name="paginationDocument")
  178.      */
  179.     public function paginationDocument(Request $request)
  180.     {
  181.          // Pagination Logic
  182.          $TdocumentForPagination $this->getDoctrine()->getRepository(Tdocument::class)->findBy(array('suspondu'=>'0'));
  183.          $numberOfRow count($TdocumentForPagination);
  184.          $recordPerPage 25;
  185.          $num $numberOfRow/$recordPerPage;
  186.          if(fmod($num1) !== 0.00){
  187.              $numberOfpage = (int)($num 1);
  188.          } else {
  189.              $numberOfpage = (int)($num);
  190.          }
  191.          $arrayOfpage = [];
  192.          //$val = '['. 1*10 .'-'. 2*10 .']';
  193.          for($i 0$i $numberOfpage$i++) {
  194.              $val $i $recordPerPage;
  195.              array_push($arrayOfpage$val);  
  196.         }
  197.         return new JsonResponse($arrayOfpage);
  198.     }
  199.     /**
  200.      * @Route("/paginationaction", name="paginationAction")
  201.      */
  202.     public function paginationAction(Request $request)
  203.     {
  204.          // Pagination Logic
  205.          $TdocumentForPagination $this->getDoctrine()->getRepository(Taction::class)->findBy(array('suspendre'=>'0'));
  206.          $numberOfRow count($TdocumentForPagination);
  207.          $recordPerPage 25;
  208.          $num $numberOfRow/$recordPerPage;
  209.          if(fmod($num1) !== 0.00){
  210.              $numberOfpage = (int)($num 1);
  211.          } else {
  212.              $numberOfpage = (int)($num);
  213.          }
  214.          $arrayOfpage = [];
  215.          //$val = '['. 1*10 .'-'. 2*10 .']';
  216.          for($i 0$i $numberOfpage$i++) {
  217.              $val $i $recordPerPage;
  218.              array_push($arrayOfpage$val);  
  219.         }
  220.         return new JsonResponse($arrayOfpage);
  221.     }
  222.     /**
  223.      * @Route("/filtrationDocument", name="filtrationDocument")
  224.      */
  225.     public function filtrationDocument(Request $request) {
  226.         if(isset($_GET['intituleDocument']) && !isset($_GET['typeDocument'])) {
  227.             $Tdocument   $this->getDoctrine()->getRepository(Tdocument::class)->findByIntitule($_GET['intituleDocument'], $_GET['code']);
  228.           
  229.   
  230.         }
  231.         elseif(!isset($_GET['intituleDocument']) && isset($_GET['typeDocument'])) {
  232.             $Tdocument   $this->getDoctrine()->getRepository(Tdocument::class)->findByType($_GET['typeDocument'], $_GET['code']);
  233.         }
  234.         else {
  235.             $Tdocument   $this->getDoctrine()->getRepository(Tdocument::class)->findByIntituleType($_GET['intituleDocument'], $_GET['typeDocument'],$_GET['code']);                            
  236.         }
  237.         // dd($Tdocument);
  238.         return $this->render('tableBody/tdocument.html.twig',[
  239.             'Tdocument'=>$Tdocument  
  240.         ]);
  241.         
  242.     }
  243.     /**
  244.      * @Route("/filtrationAction", name="filtrationAction")
  245.      */
  246.     public function filtrationAction(Request $request) {
  247.         // , $_GET['code']
  248.         if(isset($_GET['intituleAction']) && !isset($_GET['typeAction'])) {
  249.             $taction $this->getDoctrine()->getRepository(Taction::class)->findByIntitule($_GET['intituleAction'], $_GET['code']);
  250.             $Tdocument_Action $this->getDoctrine()->getRepository(Tdocument::class)->findByIntituleDocumentAction($_GET['intituleAction'], $_GET['code']);
  251.         }
  252.         elseif(!isset($_GET['intituleAction']) && isset($_GET['typeAction'])) {
  253.             $taction $this->getDoctrine()->getRepository(Taction::class)->findByType($_GET['typeAction'], $_GET['code']);
  254.             $Tdocument_Action $this->getDoctrine()->getRepository(Tdocument::class)->findByTypeDocumentAction($_GET['typeAction'], $_GET['code']);
  255.         }
  256.         else {
  257.             $taction $this->getDoctrine()->getRepository(Taction::class)->findByIntituleType($_GET['intituleAction'],$_GET['typeAction'], $_GET['code']);  
  258.             $Tdocument_Action $this->getDoctrine()->getRepository(Tdocument::class)->findByIntituleTypeDocumentAction($_GET['intituleAction'],$_GET['typeAction'], $_GET['code']);                
  259.         }
  260.         return $this->render('tableBody/taction.html.twig',  [ 
  261.             'taction' =>  $taction ,
  262.             'Tdocument_Action' => $Tdocument_Action
  263.             ]);
  264.     
  265.         
  266.     }
  267.     
  268.   
  269. }