src/Controller/DepotDossierController.php line 803

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\DepotDossier;
  4. use App\Entity\Notifications;
  5. use App\Entity\CommentairesControlle;
  6. use App\Entity\Planning;
  7. use App\Form\DepotDossierType;
  8. use App\Repository\DepotDossierRepository;
  9. use App\Repository\DealRepository;
  10. use App\Repository\PlanningRepository;
  11. use App\Repository\OperationStandardRepository;
  12. use App\Repository\ChampsDepotDossierRepository;
  13. use App\Repository\ChampsDeaufDepotDossierRepository;
  14. use App\Repository\EquipeRepository;
  15. use App\Repository\InstallateurRepository;
  16. use App\Repository\ObligesRepository;
  17. use App\Repository\NotificationsRepository;
  18. use App\Repository\CommentairesControlleRepository;
  19. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  20. use Symfony\Component\HttpFoundation\Request;
  21. use Symfony\Component\HttpFoundation\Response;
  22. use Symfony\Component\Routing\Annotation\Route;
  23. use App\Entity\ChampsDepotDossier;
  24. use App\Entity\Filtre;
  25. use App\Entity\FactureAaf;
  26. use App\Repository\FiltreRepository;
  27. use App\Repository\FactureAafRepository;
  28. use Datetime;
  29. use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
  30. use Symfony\Component\Security\Csrf\CsrfToken;
  31. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  32. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  33. use Symfony\Component\Process\Process;
  34. use Symfony\Component\Filesystem\Filesystem;
  35. use Symfony\Component\Finder\Finder;
  36. use Doctrine\Common\Collections\Collection;
  37. use Symfony\Component\HttpFoundation\JsonResponse;
  38. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  39. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  40. use App\Repository\SoustraitantRepository;
  41. use App\Repository\AppelqualiteRepository;
  42. use App\Entity\Appelqualite;
  43. use App\Repository\CommentaireAppelqualiteRepository;
  44. use App\Entity\CommentaireAppelqualite;
  45. /**
  46.  * @Route("/depot")
  47.  */
  48. class DepotDossierController extends AbstractController
  49. {
  50.     /**
  51.      * @Route("/", name="app_depot_dossier_index", methods={"GET", "POST"})
  52.      */
  53.     public function index(Request $request,DepotDossierRepository $depotDossierRepository,EquipeRepository $equipeRepository,InstallateurRepository $installateurRepository,
  54.     OperationStandardRepository $operationStandardRepository,ObligesRepository $obligesRepository,FiltreRepository $filtreRepository,FactureAafRepository $factureAafRepository): Response
  55.     {
  56.         if ($request->getMethod() == "POST") {
  57.             $form $request->request
  58.            // 
  59.            if ($form->get("chk_dossier") != null) {
  60.                 $idexporte=0;
  61.                 $exporte ="non";
  62.                 //dd($form->get("controller1"));
  63.                 if ($form->get("aaf") != null) {
  64.                  $factureAaf = new FactureAaf();
  65.                  $factureAaf->setDate(new Datetime());
  66.                  
  67.                  $factureAaf->setDepotaaf($form->get("depotaaf"));
  68.                  $factureAaf->setNumero($form->get("aaf"));
  69.                  $factureAafRepository->add($factureAaftrue);
  70.                 }
  71.                 foreach ($form->get("chk_dossier") as $key => $value) {
  72.                     $dossier $depotDossierRepository->findOneBy(["id"=>intval($value)]);
  73.                     if ($form->get("controller1") != '-') {
  74.                         $controller1 $equipeRepository->findOneBy(["id"=>intval($form->get("controller1"))]);
  75.                         $dossier->setControler1($controller1);
  76.                     }
  77.                     if ($form->get("controller2") != '-') {
  78.                         $controller2 $equipeRepository->findOneBy(["id"=>intval($form->get("controller2"))]);
  79.                         $dossier->setControler2($controller2);
  80.                     }
  81.                     if ($form->get("aaf") != null) {
  82.                         $dossier->setFactureAaf($factureAaf);
  83.                         $dossier->setStatus("En attente de paiement");
  84.                         
  85.                     }
  86.                     
  87.                     $depotDossierRepository->add($dossiertrue);
  88.                     
  89.                     if ($form->get("aaf") != null) {
  90.                         if ($dossier->getId() != null) {
  91.                             $factureAaf->addDossier($dossier);
  92.                         }
  93.                         
  94.                         
  95.                     }
  96.                     
  97.                 }
  98.                 // if ($form->get("aaf") != null) {
  99.                 //     dd($factureAaf);
  100.                     
  101.                 // }
  102.            }
  103.             
  104.             
  105.             
  106.         }
  107.         $equipes=[];
  108.         
  109.         foreach ($equipeRepository->findBy(["role"=>"ROLE_CONTROLER"]) as $key => $value) {
  110.             $equipes[]=$value;
  111.         }
  112.        
  113.         // dd($equipes);
  114.         $idexporte=0;
  115.         $exporte ="non";
  116.         if ($this->isGranted('ROLE_INSTALLATEUR')) {
  117.             $dossier=[];
  118.             $deals=$this->getUser()->getInstallateur()->getDeals();
  119.         
  120.             foreach ($deals as  $deal) {
  121.                
  122.                 foreach ($depotDossierRepository->findBy(["deal"=>$deal]) as $dls) {
  123.                     foreach ($depotDossierRepository->findAll() as  $value) {
  124.                         
  125.                         
  126.                         if ($value->getId() == $dls->getId()) {
  127.                             $dossier[]=$value;
  128.                         }
  129.                      }
  130.                 }
  131.                  
  132.                 
  133.             }
  134.          //dd($dossier);
  135.         }else{
  136.             $dossier=[];
  137.             $idexporte=0;
  138.             if ($request->getMethod() == "POST") {
  139.                 $form $request->request
  140.                 // 
  141.                 $filtre = new Filtre();
  142.                 $filtre->setService("Depot Dossier");
  143.                 $descrtionfiltre="";
  144.                 if($form->get("filtreinstallateur") != null ){
  145.                     $descrtionfiltre.=" Installateur : ";
  146.                     foreach ($form->get("filtreinstallateur") as $value) {
  147.                         $descrtionfiltre.=$installateurRepository->findOneBy(["id"=>intval($value)])->getSociete().";";
  148.                     }
  149.                 }
  150.                 if ($form->get("filtreoblige") != null) {
  151.                     $descrtionfiltre.=" Oblige : ";
  152.                     foreach ($form->get("filtreoblige") as $value) {
  153.                         $descrtionfiltre.=$obligesRepository->findOneBy(["id"=>intval($value)])->getSociete().";";
  154.                     }
  155.                 }
  156.                 if ($form->get("filtreequipe") != null) {
  157.                     $descrtionfiltre.=" Equipe : ";
  158.                     foreach ($form->get("filtreequipe") as $value) {
  159.                         $descrtionfiltre.=$equipeRepository->findOneBy(["id"=>intval($value)])->getPrenom().";";
  160.                     }
  161.                 }
  162.                 if ($form->get("filtreoperation") != null) {
  163.                     $descrtionfiltre.=" Operation : ";
  164.                     foreach ($form->get("filtreoperation") as $value) {
  165.                         
  166.                         $descrtionfiltre.=explode(':',$operationStandardRepository->findOneBy(["id"=>intval($value)])->getNom())[0].";";
  167.                     }
  168.                 }
  169.                 if ($form->get("filtrestatus") != null) {
  170.                     $descrtionfiltre.=" Status : ";
  171.                     foreach ($form->get("filtrestatus") as $value) {
  172.                         
  173.                         $descrtionfiltre.=$value.";";
  174.                     }
  175.                 }
  176.                 $filtre->setDescription($descrtionfiltre);
  177.                 $filtre->setDate(new Datetime());
  178.                 $filtre->setUser($this->getUser());
  179.                 $filtreRepository->add($filtretrue);
  180.                 $idexporte=$filtre->getId();
  181.                 if($form->get("filtreinstallateur") != null ){
  182.                     
  183.                     foreach ($form->get("filtreinstallateur") as $value) {
  184.                         foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
  185.                             if ($depotds->getDeal()->getInstallateur()->getId() == $value) {
  186.                                 
  187.                                 if ($form->get("filtreoblige") != null) {
  188.                                     
  189.                                    foreach ($form->get("filtreoblige") as  $obg) {
  190.                                         if ($depotds->getDeal()->getDealoblige()->getOblige()->getId() == $obg) {
  191.                                             //dd($form->get("filtrestatus"));
  192.                                             if ($form->get("filtrestatus") != null) {
  193.                                                 foreach ($form->get("filtrestatus") as $status) {
  194.                                                     if ($depotds->getStatus() == $status ) {
  195.                                                         if ($form->get("filtreequipe") != null) {
  196.                                                             foreach ($form->get("filtreequipe") as $controller) {
  197.                                                                 if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
  198.                                                                     if ($form->get("filtreoperation") != null) {
  199.                                                                         foreach ($form->get("filtreoperation") as $operation) {
  200.                                                                             
  201.                                                                             foreach ($depotds->getOperation() as $ops) {
  202.                                                                                 if ($ops->getId()==$operation) {
  203.                                                                                     $dossier[]=$depotds;
  204.                                                                                 }
  205.                                                                             }
  206.                                                                         }
  207.                 
  208.                                                                     }else{
  209.                                                                     
  210.                                                                         $dossier[]=$depotds;
  211.                                                                     }
  212.                                                                 }
  213.                                                             } 
  214.                                                         } else {
  215.                                                             $dossier[]=$depotds;
  216.                                                         }
  217.                                                     }
  218.                                                 }
  219.                                             }else{
  220.                                                 $dossier[]=$depotds;
  221.                                             }
  222.                                         }
  223.                                     }
  224.                                 } else {
  225.                                     if ($form->get("filtrestatus") != null) {
  226.                                         foreach ($form->get("filtrestatus") as $status) {
  227.                                             if ($depotds->getStatus() == $status ) {
  228.                                                 if ($form->get("filtreequipe") != null) {
  229.                                                     foreach ($form->get("filtreequipe") as $controller) {
  230.                                                         if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
  231.                                                             if ($form->get("filtreoperation") != null) {
  232.                                                                 foreach ($form->get("filtreoperation") as $operation) {
  233.                                                                     
  234.                                                                     foreach ($depotds->getOperation() as $ops) {
  235.                                                                         if ($ops->getId()==$operation) {
  236.                                                                             $dossier[]=$depotds;
  237.                                                                         }
  238.                                                                     }
  239.                                                                 }
  240.         
  241.                                                             }else{
  242.                                                             
  243.                                                                 $dossier[]=$depotds;
  244.                                                             }
  245.                                                         }
  246.                                                     } 
  247.                                                 } else {
  248.                                                     $dossier[]=$depotds;
  249.                                                 }
  250.                                             }
  251.                                         }
  252.                                     } else {
  253.                                         $dossier[]=$depotds;
  254.                                     }
  255.                                     
  256.                                    
  257.                                 }
  258.                                 
  259.                             }
  260.                         }
  261.                     }
  262.                 }else{
  263.                     if ($form->get("filtreoblige") != null) {
  264.                         foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
  265.                             foreach ($form->get("filtreoblige") as  $obg) {
  266.                                 if ($depotds->getDeal()->getDealoblige()->getOblige()->getId() == $obg) {
  267.                                     //dd($form->get("filtrestatus"));
  268.                                     if ($form->get("filtrestatus") != null) {
  269.                                         foreach ($form->get("filtrestatus") as $status) {
  270.                                             if ($depotds->getStatus() == $status ) {
  271.                                                 if ($form->get("filtreequipe") != null) {
  272.                                                     foreach ($form->get("filtreequipe") as $controller) {
  273.                                                         if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
  274.                                                             if ($form->get("filtreoperation") != null) {
  275.                                                                 foreach ($form->get("filtreoperation") as $operation) {
  276.                                                                     
  277.                                                                     foreach ($depotds->getOperation() as $ops) {
  278.                                                                         if ($ops->getId()==$operation) {
  279.                                                                             $dossier[]=$depotds;
  280.                                                                         }
  281.                                                                     }
  282.                                                                 }
  283.         
  284.                                                             }else{
  285.                                                             
  286.                                                                 $dossier[]=$depotds;
  287.                                                             }
  288.                                                         }
  289.                                                     } 
  290.                                                 } else {
  291.                                                     $dossier[]=$depotds;
  292.                                                 }
  293.                                             }
  294.                                         }
  295.                                     }else{
  296.                                         $dossier[]=$depotds;
  297.                                     }
  298.                                 }
  299.                             }
  300.                         }
  301.                     }else{
  302.                         if ($form->get("filtrestatus") != null) {
  303.                             foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
  304.                                 foreach ($form->get("filtrestatus") as $status) {
  305.                                     if ($depotds->getStatus() == $status ) {
  306.                                         
  307.                                         if ($form->get("filtreequipe") != null) {
  308.                                             foreach ($form->get("filtreequipe") as $controller) {
  309.                                                 if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
  310.                                                     if ($form->get("filtreoperation") != null) {
  311.                                                         foreach ($form->get("filtreoperation") as $operation) {
  312.                                                             
  313.                                                             foreach ($depotds->getOperation() as $ops) {
  314.                                                                 if ($ops->getId()==$operation) {
  315.                                                                     $dossier[]=$depotds;
  316.                                                                 }
  317.                                                             }
  318.                                                         }
  319.                                                     }else{
  320.                                                     
  321.                                                         $dossier[]=$depotds;
  322.                                                     }
  323.                                                 }
  324.                                             } 
  325.                                         }else 
  326.                                         {
  327.                                             $dossier[]=$depotds;
  328.                                         }
  329.                                         
  330.                                     }
  331.                                 }
  332.                             }
  333.                         }else{
  334.                             if ($form->get("filtreequipe") != null) {
  335.                                 foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
  336.                                     foreach ($form->get("filtreequipe") as $controller) {
  337.                                         if ($depotds->getControler1()) {
  338.                                             if ($depotds->getControler1()->getId() == $controller || $depotds->getControler2()->getId() == $controller ) {
  339.                                                 if ($form->get("filtreoperation") != null) {
  340.                                                     foreach ($form->get("filtreoperation") as $operation) {
  341.                                                         
  342.                                                         foreach ($depotds->getOperation() as $ops) {
  343.                                                             if ($ops->getId()==$operation) {
  344.                                                                 $dossier[]=$depotds;
  345.                                                             }
  346.                                                         }
  347.                                                     }
  348.     
  349.                                                 }else{
  350.                                                 
  351.                                                     $dossier[]=$depotds;
  352.                                                 }
  353.                                             }
  354.                                         }
  355.                                         
  356.                                     } 
  357.                                 }
  358.                             }else{
  359.                                 if ($form->get("filtreoperation") != null) {
  360.                                     foreach ($depotDossierRepository->findBy([], ['id' => 'DESC']) as $depotds) {
  361.                                         foreach ($form->get("filtreoperation") as $operation) {
  362.                                             
  363.                                             foreach ($depotds->getOperation() as $ops) {
  364.                                                 if ($ops->getId()==$operation) {
  365.                                                     $dossier[]=$depotds;
  366.                                                 }
  367.                                             }
  368.                                         }
  369.                                     }
  370.                                 }else{
  371.                                 
  372.                                     $dossier$depotDossierRepository->findBy([], ['id' => 'DESC']);
  373.                                 }
  374.                                
  375.                             }
  376.                             
  377.                         }
  378.                     }
  379.                 }
  380.                 $exporte ="oui";
  381.                 if ($form->get("chk_dossier") != null) {
  382.                     $idexporte=0;
  383.                     $exporte ="non";
  384.                 }
  385.                 
  386.             }else{
  387.                 $exporte ="non";
  388.                 if ($this->isGranted('ROLE_CONTROLER') ) {
  389.                     foreach ($depotDossierRepository->findBy(["controler1"=>$this->getUser()->getEquipe()]) as $key => $value) {
  390.                         $dossier[]=$value;
  391.                     }
  392.                     foreach ($depotDossierRepository->findBy(["controler2"=>$this->getUser()->getEquipe()]) as $key => $value) {
  393.                         $dossier[]=$value;
  394.                     }
  395.                    
  396.                 }elseif($this->isGranted('ROLE_CONTROLER')){
  397.                     
  398.                     foreach ($depotDossierRepository->findBy(["controler1"=>$this->getUser()->getEquipe()]) as $key => $value) {
  399.                         $dossier[]=$value;
  400.                     }
  401.                     
  402.                     foreach ($depotDossierRepository->findBy(["controler2"=>$this->getUser()->getEquipe()]) as $key => $value) {
  403.                         $dossier[]=$value;
  404.                     }
  405.                     //dd($dossier);
  406.                 } elseif($this->isGranted('ROLE_OBLIGE')){
  407.                     foreach ($this->getUser()->getObliges()->getDeals() as  $deal) {
  408.                         foreach ($deal->getDepotDossiers() as  $value) {
  409.                             $dossier[]=$value;
  410.                         }
  411.                        
  412.                     }
  413.                 }
  414.                 else{
  415.                     $dossier$depotDossierRepository->findAll();
  416.                 }
  417.                
  418.             }
  419.             
  420.         }
  421.         
  422.         $tab=[];
  423.         $dossiers=[];
  424.         // id,type as owner,client as name ,date,file ,batiment
  425.         foreach ($dossier as  $value) {
  426.            if ($value->getStatus() != "archive") {
  427.                 # code...
  428.             
  429.                 $tab['id']=$value->getId();
  430.                 $tab['name']=$value->getNumero();  
  431.                 $tab['owner']=$value->getDeal()->getNumero();
  432.                 $tab['owner_id']=$value->getDeal()->getId();
  433.                 $tab['icone']="ri-archive-line";
  434.                 if ($value->getControler1()) {
  435.                     $tab['controller1']=$value->getControler1()->getPrenom();
  436.                 }
  437.                 if ($value->getControler2()) {
  438.                     $tab['controller2']=$value->getControler2()->getPrenom();
  439.                 }
  440.                 
  441.             
  442.                 $ops="";
  443.                 $opi=0;
  444.                 foreach ($value->getOperation() as $key => $op) {
  445.                     if ($opi>0) {
  446.                         $ops.=";"
  447.                     }
  448.                     $ops.=explode(':',$op->getNom())[0];
  449.                 
  450.                     $opi=$opi 1;
  451.                 }
  452.                 $tab['industry_type']=$ops;
  453.                 $tab['cumac']=$value->getCumac();
  454.                 $tab['location']=$value->getNomclient().' '.$value->getPrenomclient();
  455.                 $tab['contact_email']=$value->getDeal()->getInstallateur()->getEmail();
  456.                 $tab['employee']="depot";
  457.                 if ($value->getStatus()=='Validé' || $value->getStatus()=='Payé sur AAF' || $value->getStatus()=='Déposé / AAF en cours' || $value->getStatus()=='En attente de paiement' ) {
  458.                     $tab['star_value']='<span class="badge progress-green p-2 border-0" >'.$value->getStatus().'</span>';
  459.                     $tab['row_tr']='row-green';
  460.                 } elseif($value->getStatus()=="Bloqué" || $value->getStatus()=="Non validé" ) {
  461.                     $tab['star_value']='<span class="badge progress-red p-2 border-0" >'.$value->getStatus().'</span>';
  462.                     $tab['row_tr']='row-red';
  463.                 }elseif($value->getStatus()=="Urgent") {
  464.                 $tab['star_value']='<span class="badge progress-red p-2 border-0" >'.$value->getStatus().'</span>';
  465.                 $tab['row_tr']='row-red';
  466.                 }
  467.                 elseif($value->getStatus()=="En Attente" || $value->getStatus()=="Prêt pour dépôt"){
  468.                     $tab['star_value']='<span class="badge progress-yellow p-2 border-0" >'.$value->getStatus().'</span>';
  469.                     $tab['row_tr']='row-yellow';
  470.                 }else{
  471.                     $tab['star_value']='<span class="badge progress-grey p-2 border-0" >Nouveau</span>';
  472.                     $tab['row_tr']='row-grey';
  473.                 }
  474.                 
  475.                 $tab['image_src']="#";
  476.                 $dossiers[]=$tab;
  477.            }
  478.         }
  479.         //dd($dossiers);
  480.         $dossiersjson json_encode($dossiers);
  481.         // var_dump(json_encode($clientjson ));
  482.         file_put_contents('assets/json/dossier-list.json'$dossiersjson);
  483.         return $this->render('depot_dossier/index.html.twig', [
  484.             'depot_dossiers' => $depotDossierRepository->findAll(),
  485.             'equipes'=>$equipes,
  486.             'listobliges' => $obligesRepository->findAll(),
  487.             'allInstallateurs' => $installateurRepository->findAll(),
  488.             'operationsStandard' => $operationStandardRepository->findAll(),
  489.             'exporte' => $exporte,
  490.             'idexporte' => $idexporte
  491.         ]);
  492.     }
  493.     /**
  494.      * @Route("/dossierarchives", name="app_depot_dossier_archives", methods={"GET", "POST"})
  495.      */
  496.     public function dossierarchives(Request $request,DepotDossierRepository $depotDossierRepository,EquipeRepository $equipeRepository,InstallateurRepository $installateurRepository,
  497.     OperationStandardRepository $operationStandardRepository,ObligesRepository $obligesRepository,FiltreRepository $filtreRepository,FactureAafRepository $factureAafRepository): Response
  498.     {
  499.        
  500.         if ($request->getMethod() == "POST") {
  501.             $form $request->request
  502.            
  503.            if ($form->get("chk_dossier") != null) {
  504.                 foreach ($form->get("chk_dossier") as $key => $value) {
  505.                     $dossier $depotDossierRepository->findOneBy(["id"=>intval($value)]);
  506.                     $dossier->setArchive($dossier->getStatus());
  507.                     $dossier->setStatus("archive");
  508.                     $depotDossierRepository->add($dossiertrue);
  509.                 }
  510.            }
  511.         }
  512.         
  513.        
  514.        
  515.         $dossier=$depotDossierRepository->findBy(['status' => 'archive'], ['id' => 'DESC']);;
  516.  
  517.         $tab=[];
  518.         $dossiers=[];
  519.         // id,type as owner,client as name ,date,file ,batiment
  520.         foreach ($dossier as  $value) {
  521.            if ($value->getStatus() == "archive") {
  522.                 # code...
  523.             
  524.                 $tab['id']=$value->getId();
  525.                 $tab['name']=$value->getNumero();  
  526.                 $tab['owner']=$value->getDeal()->getNumero();
  527.                 $tab['owner_id']=$value->getDeal()->getId();
  528.                 $tab['icone']="ri-delete-bin-fill";
  529.                 if ($value->getControler1()) {
  530.                     $tab['controller1']=$value->getControler1()->getPrenom();
  531.                 }
  532.                 if ($value->getControler2()) {
  533.                     $tab['controller2']=$value->getControler2()->getPrenom();
  534.                 }
  535.                 
  536.             
  537.                 $ops="";
  538.                 $opi=0;
  539.                 foreach ($value->getOperation() as $key => $op) {
  540.                     if ($opi>0) {
  541.                         $ops.=";"
  542.                     }
  543.                     $ops.=explode(':',$op->getNom())[0];
  544.                 
  545.                     $opi=$opi 1;
  546.                 }
  547.                 $tab['industry_type']=$ops;
  548.                 $tab['cumac']=$value->getCumac();
  549.                 $tab['location']=$value->getNomclient().' '.$value->getPrenomclient();
  550.                 $tab['contact_email']=$value->getDeal()->getInstallateur()->getEmail();
  551.                 $tab['employee']="depot";
  552.                if($value->getStatus()=="archive") {
  553.                 $tab['star_value']='<span class="badge progress-red p-2 border-0" >'.$value->getStatus().'</span>';
  554.                 $tab['row_tr']='row-red';
  555.                 }
  556.                 $tab['image_src']="#";
  557.                 $dossiers[]=$tab;
  558.            }
  559.         }
  560.         //dd($dossiers);
  561.         $dossiersjson json_encode($dossiers);
  562.         // var_dump(json_encode($clientjson ));
  563.         file_put_contents('assets/json/dossier-list.json'$dossiersjson);
  564.         return $this->render('depot_dossier/archives.html.twig', [
  565.             'depot_dossiers' => $depotDossierRepository->findAll()
  566.         ]);
  567.     }
  568.      /**
  569.      * @Route("/dossierdesarchives", name="app_depot_dossier_desarchives", methods={"GET", "POST"})
  570.      */
  571.     public function dossierdesarchives(Request $request,DepotDossierRepository $depotDossierRepository,EquipeRepository $equipeRepository,InstallateurRepository $installateurRepository,
  572.     OperationStandardRepository $operationStandardRepository,ObligesRepository $obligesRepository,FiltreRepository $filtreRepository,FactureAafRepository $factureAafRepository): Response
  573.     {
  574.         if ($request->getMethod() == "POST") {
  575.             $form $request->request
  576.            
  577.            if ($form->get("chk_dossier") != null) {
  578.                 foreach ($form->get("chk_dossier") as $key => $value) {
  579.                     $dossier $depotDossierRepository->findOneBy(["id"=>intval($value)]);
  580.                    
  581.                     $dossier->setStatus($dossier->getArchive());
  582.                     $depotDossierRepository->add($dossiertrue);
  583.                 }
  584.            }
  585.         }
  586.         return $this->redirectToRoute('app_depot_dossier_index', [], Response::HTTP_SEE_OTHER);
  587.     }
  588.     /**
  589.      * @Route("/historiquefiltre", name="app_filtre_index", methods={"GET", "POST"})
  590.      */
  591.     public function historiquefiltre(Request $request,FiltreRepository $filtreRepository): Response
  592.     {
  593.         $filtre$filtreRepository->findAll();
  594.         $tab=[];
  595.         $filtres=[];
  596.   
  597.         // id,type as owner,client as name ,date,file ,batiment
  598.         foreach ($filtre as  $value) {
  599.             if ($value->getExporte() != null) {
  600.                 $tab['id']=$value->getId();
  601.                 $tab['name']=$value->getDate()->format('d-m-Y');
  602.                 $tab['owner']=$value->getDescription();
  603.                 $tab['industry_type']=$value->getExporte();
  604.                 if ($value->getUser()) {
  605.                     $tab['contact_email']=$value->getUser()->getEquipe()->getPrenom();
  606.                 }
  607.                
  608.                 $filtres[]=$tab;
  609.             }
  610.             
  611.         }
  612.         //dd($filtres);
  613.         $clientjson json_encode($filtres);
  614.         // var_dump(json_encode($clientjson ));
  615.         file_put_contents('assets/json/filtre-list.json'$clientjson);
  616.         return $this->render('depot_dossier/filtre.html.twig', [
  617.             'filtres' => $filtreRepository->findAll(),
  618.         ]);
  619.     }
  620.     
  621.     /**
  622.      * @Route("/new", name="app_depot_dossier_new", methods={"GET", "POST"})
  623.      */
  624.     public function new(Request $request,DealRepository $dealRepository,DepotDossierRepository $depotDossierRepository,OperationStandardRepository $operationsStandardRepository,
  625.     ChampsDeaufDepotDossierRepository $champsDeaufDepotDossierRepository,ChampsDepotDossierRepository $champsDepotDossierRepository,FactureAafRepository $factureAafRepository): Response
  626.     {
  627.         $depotDossier = new DepotDossier();
  628.         // $form = $this->createForm(DepotDossierType::class, $depotDossier);
  629.         // $form->handleRequest($request);
  630.         if ($request->getMethod() == "POST") {
  631.             $form $request->request
  632.            //dd($form->get('operations'));
  633.             // $depotDossier->setClientfiscale($form->get('fiscale'));
  634.             $depotDossier->setCivilite($form->get('civilite'));
  635.             $depotDossier->setNomclient($form->get('nomclient'));
  636.             $depotDossier->setPrenomclient($form->get('prenomclient'));
  637.             $depotDossier->setPhone($form->get('phone'));
  638.             $depotDossier->setEmail($form->get('email'));
  639.             $depotDossier->setAdresse($form->get('adresse'));
  640.             $depotDossier->setVille($form->get('ville'));
  641.             $depotDossier->setCodepostale($form->get('postale'));
  642.             $depotDossier->setNumero($form->get('numero'));
  643.             $depotDossier->setCumac($form->get('cumac'));
  644.             // $depotDossier->setNatureoccupation($form->get('occupation'));
  645.             // $depotDossier->setTypelogement($form->get('typelogement'));
  646.             // $depotDossier->setEnergiechauffage($form->get('energiechauffage'));
  647.             // $depotDossier->setAnciennete($form->get('anciennetechauffage'));
  648.             // $depotDossier->setSystemechauffage($form->get('anciennetechauffage'));
  649.             // $depotDossier->setSurfacehabitable($form->get('surfacehabite'));
  650.             // $depotDossier->setSuperficiesol($form->get('Superficiesol'));
  651.             // $depotDossier->setParcellecadastrale($form->get('Parcelle'));
  652.             // $depotDossier->setTypemaison($form->get('Parcelle')); 
  653.             // $depotDossier->setSoussol($form->get('soussol'));
  654.             // $depotDossier->setAnciennetelogement($form->get('ancienneteloge'));
  655.             $depotDossier->setStatus("nouveau");
  656.            
  657.             $depotDossier->setDate(new Datetime());
  658.            
  659.             
  660.             
  661.             $deal$dealRepository->findOneBy(["id"=>intval($form->get('deal'))]);
  662.             $depotDossier->setDeal($deal);
  663.             // $alphas = range('A', 'Z');
  664.             // $key = substr($deal->getNumero(), 0, 2).''. random_int(001, 999).''.$alphas[random_int(0, 25)] . '' . $alphas[random_int(0, 25)] ;
  665.             // $depotDossier->setNumero($key);
  666.             if ($form->get('operations') !=null ) {
  667.                 foreach ($form->get('operations') as  $value) {
  668.                     $ops$operationsStandardRepository->findOneBy(["id"=>intval($value)]);
  669.                     $depotDossier->addOperation($ops);
  670.                 }
  671.             }
  672.             $depotDossierRepository->add($depotDossiertrue);
  673.             foreach ($champsDeaufDepotDossierRepository->findAll() as  $chmps) {
  674.                 $champsDepotDossier = new ChampsDepotDossier();
  675.                
  676.                 $champsDepotDossier->setNom($chmps->getNom());
  677.                 $champsDepotDossier->setType($chmps->getType());
  678.                 if ($chmps->getType()== 'file') {
  679.                  $champsDepotDossier->setStatus('Non Transmis');
  680.                 }
  681.                 $champsDepotDossier->setDepotdossier($depotDossier);
  682.                 
  683.                 $champsDepotDossierRepository->add($champsDepotDossiertrue);
  684.             }
  685.             // $factureAaf = new FactureAaf();
  686.             // $factureAaf->setDossier($depotDossier);
  687.             // $factureAaf->setStatus("Non Transmis");
  688.             // $factureAafRepository->add($factureAaf, true);
  689.             
  690.             return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$depotDossier->getId()], Response::HTTP_SEE_OTHER);
  691.         }
  692.         if ($this->isGranted('ROLE_INSTALLATEUR')) {
  693.             $datejr= new Datetime();
  694.             $deal=[];
  695.            foreach ($this->getUser()->getInstallateur()->getDeals() as $key => $value) {
  696.                if ($value->getStatus()=="Validé" && $value->getDatefin() > $datejr) {
  697.                 $deal[]=$value;
  698.                }
  699.            }
  700.         }else{
  701.             $deal=[];
  702.             $datejr= new Datetime();
  703.             foreach ( $dealRepository->findBy(['status'=>'Validé']) as $key => $value) {
  704.                if ($value->getDatefin() > $datejr) {
  705.                 $deal[]=$value;
  706.                }
  707.             }
  708.         }
  709.         if ($this->isGranted('ROLE_INSTALLATEUR')) {
  710.             $operations=$this->getUser()->getInstallateur()->getOperationStandards();
  711.         }else{
  712.             $operations$operationsStandardRepository->findAll();
  713.         }
  714.         
  715.         if ($request->query->get('ideal') != null ) {
  716.             $idealGet $request->query->get('ideal');
  717.         } else {
  718.             $idealGet 0;
  719.         }
  720.         
  721.         
  722.         
  723.         return $this->renderForm('depot_dossier/new.html.twig', [
  724.             'depot_dossier' => $depotDossier,
  725.             'depot' => "depot",
  726.             'operations' =>$operations,
  727.             'dealAll' => $deal,
  728.             "idealGet" => $idealGet
  729.         ]);
  730.     }
  731.     /**
  732.      * @Route("/{id}", name="app_depot_dossier_show", methods={"GET"})
  733.      */
  734.     public function show(DepotDossier $depotDossier): Response
  735.     {
  736.         return $this->render('depot_dossier/show.html.twig', [
  737.             'depot_dossier' => $depotDossier,
  738.         ]);
  739.     }
  740.     /**
  741.      * @Route("/{id}/edit", name="app_depot_dossier_edit", methods={"GET", "POST"})
  742.      */
  743.     public function edit(Request $requestDepotDossier $depotDossierDepotDossierRepository $depotDossierRepository,CsrfTokenManagerInterface $csrfTokenManager,
  744.     EquipeRepository $equipeRepository,NotificationsRepository $notificationsRepository,OperationStandardRepository $operationsStandardRepository,
  745.     PlanningRepository $planningRepository,SoustraitantRepository $soustraitantRepository,ChampsDeaufDepotDossierRepository $champsDeaufDepotDossierRepository): Response
  746.     {
  747.         // $form = $this->createForm(DepotDossierType::class, $depotDossier);
  748.         // $form->handleRequest($request);
  749.         // if ($form->isSubmitted() && $form->isValid()) {
  750.         //     $depotDossierRepository->add($depotDossier, true);
  751.         //     return $this->redirectToRoute('app_depot_dossier_index', [], Response::HTTP_SEE_OTHER);
  752.         // }
  753.         if ($this->isGranted('ROLE_INSTALLATEUR')) {
  754.             if ($this->getUser()->getInstallateur()->getId() != $depotDossier->getDeal()->getInstallateur()->getId()) {
  755.                 return $this->redirectToRoute('app_depot_dossier_index', [], Response::HTTP_SEE_OTHER);
  756.             }
  757.          }
  758.         $csrfToken $csrfTokenManager->getToken('depot_dossier_edit');
  759.         if ($request->getMethod() == "POST") {
  760.             $token $request->request->get('_token');
  761.             $id explode("A@",explode("12OU#@R",$token)[1])[0];
  762.             if ($id!=$depotDossier->getId()) {
  763.                 return $this->redirectToRoute('app_depot_dossier_edit', ['id' => $id], Response::HTTP_SEE_OTHER);
  764.             }
  765.             $form $request->request
  766.            
  767.            
  768.             if ($form->get('controler2') != null ) {
  769.                 $depotDossier->setControler2($equipeRepository->findOneBy(["id"=>intval($form->get('controler2'))]));
  770.                
  771.             }
  772.             if ($form->get('controler1') != null ) {
  773.                 $depotDossier->setControler1($equipeRepository->findOneBy(["id"=>intval($form->get('controler1'))]));
  774.                
  775.             }
  776.             //dd($form->get('dateprevisite'));
  777.             
  778.                 if ($depotDossier->getPlanning()) {
  779.                     $planning $depotDossier->getPlanning();
  780.                     
  781.                 }else{
  782.                     $planning = new Planning();
  783.                 }
  784.                     $dateprevisite date('d-m-Y'strtotime($form->get('dateprevisite'))) ;
  785.                     $datetimeprevisite = new Datetime($dateprevisite);
  786.                     $datedevis date('d-m-Y'strtotime($form->get('datedevis'))) ;
  787.                     $datetimedevis = new Datetime($datedevis);
  788.                     $dateengagement date('d-m-Y'strtotime($form->get('dateengagement'))) ;
  789.                     $datetimeengagement = new Datetime($dateengagement);
  790.                     $datetravaux date('d-m-Y'strtotime($form->get('datetravaux'))) ;
  791.                     $datetimetravaux = new Datetime($datetravaux);
  792.                     $datefacture date('d-m-Y'strtotime($form->get('datefacture'))) ;
  793.                     $datetimefacture = new Datetime($datefacture);
  794.                     
  795.                     $planning->setDateprevisite($datetimeprevisite);
  796.                     $planning->setIntervenant($form->get('intervation'));
  797.                     $planning->setDatedevis($datetimedevis);
  798.                     $planning->setSourcedevis($form->get('sourcedevis'));
  799.                     $planning->setDateengagement($datetimeengagement);
  800.                     $planning->setDatetravaux($datetimetravaux);
  801.                     $planning->setPoseur($form->get('poseur'));
  802.                     $planning->setConsigne($form->get('consigne'));
  803.                     $planning->setDatefacture($datetimefacture);
  804.                     $planning->setSourcefacture($form->get('sourcefacture'));
  805.                     $planning->setNumerofacture($form->get('numerofacture'));
  806.                     $planning->setDossier($depotDossier);
  807.                     $planningRepository->add($planningtrue);
  808.                 
  809.                 
  810.             
  811.             // $depotDossier->setClientfiscale($form->get('fiscale'));
  812.             $depotDossier->setCivilite($form->get('civilite'));
  813.             $depotDossier->setNomclient($form->get('nomclient'));
  814.             $depotDossier->setPrenomclient($form->get('prenomclient'));
  815.             $depotDossier->setPhone($form->get('phone'));
  816.             $depotDossier->setEmail($form->get('email'));
  817.             $depotDossier->setNumero($form->get('numero'));
  818.             $depotDossier->setCumac($form->get('cumac'));
  819.             if ($depotDossier->getBlocage()!="oui") {
  820.                 $depotDossier->setAdresse($form->get('adresse'));
  821.                 $depotDossier->setVille($form->get('ville'));
  822.                 $depotDossier->setCodepostale($form->get('postale'));
  823.             }
  824.            
  825.             // $depotDossier->setNatureoccupation($form->get('occupation'));
  826.             // $depotDossier->setTypelogement($form->get('typelogement'));
  827.             // $depotDossier->setEnergiechauffage($form->get('energiechauffage'));
  828.             // $depotDossier->setAnciennete($form->get('anciennetechauffage'));
  829.             // $depotDossier->setSystemechauffage($form->get('anciennetechauffage'));
  830.             // $depotDossier->setSurfacehabitable($form->get('surfacehabite'));
  831.             // $depotDossier->setSuperficiesol($form->get('Superficiesol'));
  832.             // $depotDossier->setParcellecadastrale($form->get('Parcelle'));
  833.             // $depotDossier->setTypemaison($form->get('Parcelle'));
  834.             // $depotDossier->setAnciennetelogement($form->get('ancienneteloge'));
  835.             // $depotDossier->setSoussol($form->get('soussol'));
  836.             $depotDossier->setStatus($form->get('status'));
  837.            
  838.             $depotDossier->setCommentaire($form->get('commentaire'));
  839.         
  840.                if ($form->get('operations') != null) {
  841.                 foreach ($depotDossier->getOperation() as  $value) {
  842.                     if (!in_array($value->getId(),$form->get('operations'))) {
  843.                         $depotDossier->removeOperation($value);
  844.                     }
  845.                  }
  846.                  foreach ($form->get('operations') as  $value) {
  847.                     $ops$operationsStandardRepository->findOneBy(["id"=>intval($value)]);
  848.                     $depotDossier->addOperation($ops);
  849.                 }
  850.                }else{
  851.                 foreach ($depotDossier->getOperation() as  $value) {
  852.                    
  853.                     $depotDossier->removeOperation($value);
  854.                     
  855.                  }
  856.                }
  857.                if ($form->get('soustraitants') != null) {
  858.                 foreach ($depotDossier->getSoustraitants() as  $value) {
  859.                     if (!in_array($value->getId(),$form->get('soustraitants'))) {
  860.                      $depotDossier->removeSoustraitant($value);
  861.                     }
  862.                  }
  863.                  foreach ($form->get('soustraitants') as  $value) {
  864.                     $soustraitant$soustraitantRepository->findOneBy(["id"=>intval($value)]);
  865.                     
  866.                     $depotDossier->addSoustraitant($soustraitant);
  867.                 }
  868.                }else{
  869.                 foreach ($depotDossier->getSoustraitants() as  $value) {
  870.                    
  871.                      $depotDossier->removeSoustraitant($value);
  872.                     
  873.                  }
  874.                }
  875.             $depotDossierRepository->add($depotDossiertrue);
  876.             return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$depotDossier->getId()], Response::HTTP_SEE_OTHER);
  877.         }
  878.         $notif $notificationsRepository->findOneBy(["user_id" => $this->getUser(),"statuts"=> "non lu","action" => "app_depot_dossier_edit","action_id"=>$depotDossier->getId()]);
  879.         if ($notif) {
  880.             $notif->setStatuts("lu");
  881.             $notificationsRepository->add($notiftrue);
  882.         }
  883.         $dealAll $depotDossier->getDeal()->getInstallateur()->getDeals();
  884.         $operationsStandars $depotDossier->getDeal()->getInstallateur()->getOperationStandards();
  885.         // $controles1=$equipeRepository->findBy(["role"=>'ROLE_CONTROLER']);
  886.         // $controles2=$equipeRepository->findBy(["role"=>'ROLE_CONTROLER']);
  887.         $equipes=[];
  888.         
  889.         foreach ($equipeRepository->findBy(["role"=>"ROLE_CONTROLER"]) as $key => $value) {
  890.             $equipes[]=$value;
  891.         }
  892.        
  893.         //dd($csrfToken->getValue().'12OU#@R'.$depotDossier->getId()."A@T9");
  894.         // dd($champsDeaufDepotDossierRepository->findAll());
  895.         return $this->renderForm('depot_dossier/edit.html.twig', [
  896.             "depot" =>"depot",
  897.             'depot_dossier' => $depotDossier,
  898.             'dealAll' => $dealAll,
  899.             'controles1' => $equipes,
  900.             'controles2' => $equipes,
  901.             'operationsStandars' => $operationsStandars,
  902.             "dateday"=>new Datetime(),
  903.             'csrf_token' => $csrfToken->getValue().'12OU#@R'.$depotDossier->getId()."A@T9",
  904.             'champsDeaufs' => $champsDeaufDepotDossierRepository->findAll()
  905.             
  906.         ]);
  907.     }
  908.     /**
  909.      * @Route("/{id}", name="app_depot_dossier_delete", methods={"POST"})
  910.      */
  911.     public function delete(Request $requestDepotDossier $depotDossierDepotDossierRepository $depotDossierRepository,CommentairesControlleRepository $commentairesControlleRepository
  912.     NotificationsRepository $notificationsRepository,ChampsDepotDossierRepository $champsDepotDossierRepository,FactureAafRepository $factureAafRepository,AppelqualiteRepository $appelqualiteRepository,
  913.     SoustraitantRepository $soustraitantRepository): Response
  914.     {
  915.         if ($this->isCsrfTokenValid('delete'.$depotDossier->getId(), $request->request->get('_token'))) {
  916.             foreach ($notificationsRepository->findBy(["action_id"=>$depotDossier->getId()]) as  $value) {
  917.                 $notificationsRepository->remove($valuetrue);
  918.              }
  919.             foreach ($depotDossier->getCommentairesControlles() as $commentaire) {
  920.                 $commentairesControlleRepository->remove($commentairetrue);
  921.             }
  922.             foreach ($depotDossier->getChampsDepotDossiers() as  $value) {
  923.            
  924.                 $depotDossier->removeChampsDepotDossier($value);
  925.                 $champsDepotDossierRepository->remove($valuetrue);
  926.                
  927.             }
  928.             foreach ($depotDossier->getSoustraitants() as  $value) {
  929.            
  930.                 $depotDossier->removeSoustraitant($value);
  931.                 // $soustraitantRepository->remove($value, true);
  932.                
  933.             }
  934.             
  935.             // foreach ($depotDossier->getFactureAafs() as  $value) {
  936.             //     foreach ($value->getCommentaireFactureaafs() as  $commentaire) {
  937.             //         $value->removeCommentaireFactureaaf($commentaire);
  938.     
  939.                   
  940.                 
  941.             //     }
  942.                 
  943.                
  944.             // }
  945.             foreach ($depotDossier->getAppelqualites() as  $value) {
  946.                 foreach ($value->getCommentaireAppelqualites() as  $commentaire) {
  947.                     $value->removeCommentaireAppelqualite($commentaire);
  948.     
  949.                     // $activiteDealRepository->remove($commentaire, true);
  950.                 
  951.                 }
  952.                 $depotDossier->removeAppelqualite($value);
  953.                 $appelqualiteRepository->remove($valuetrue);
  954.                
  955.             }
  956.             
  957.             $depotDossierRepository->remove($depotDossiertrue);
  958.         }
  959.         return $this->redirectToRoute('app_depot_dossier_index', [], Response::HTTP_SEE_OTHER);
  960.     }
  961.      /**
  962.      * @Route("/zip/{id}", name="app_depot_dossier_zip", methods={"GET"})
  963.      */
  964.     public function zip(DepotDossier $depotDossier): Response
  965.     {
  966.         
  967.         
  968.           
  969.         $zipFileName 'depotdossier_'.$depotDossier->getDeal()->getInstallateur()->getSociete().'_' date('d-m-Y-His') . '.zip';
  970.     
  971.         // Créez le chemin absolu vers le fichier ZIP
  972.         $zipFilePath $this->getParameter('installateur_directory') . '/archiver/' $zipFileName;
  973.     
  974.         // Utilisez la classe ZipArchive pour créer le fichier ZIP
  975.         $zip = new \ZipArchive();
  976.         $zip->open($zipFilePath\ZipArchive::CREATE \ZipArchive::OVERWRITE);
  977.     
  978.     
  979.             foreach ($depotDossier->getChampsDepotDossiers() as $value) {
  980.                 if ($value->getType()=="file") {
  981.                     if ($value->getValeur()!=null) {
  982.                      
  983.                      $filePath $this->getParameter('installateur_directory').'/'.$value->getValeur();
  984.                      $relativePath 'depotdossier_'.$depotDossier->getDeal()->getInstallateur()->getSociete()."/".$value->getValeur();
  985.                      $zip->addFile($filePath$relativePath);
  986.                     }
  987.                 }
  988.        
  989.             }
  990.             // Fermer le fichier ZIP
  991.             $zip->close();
  992.             // Envoyer le fichier ZIP en tant que réponse de téléchargement
  993.             $response = new BinaryFileResponse($zipFilePath);
  994.             $response->headers->set('Content-Type''application/zip');
  995.             $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT$zipFileName);
  996.            
  997.             return $response;
  998.         
  999.     }
  1000.       /**
  1001.      * @Route("/commentaire/{id}", methods={"POST"})
  1002.      */
  1003.     public function commentaire(Request $request,CommentairesControlleRepository $commentairesControlleRepository,
  1004.      NotificationsRepository $notificationsRepository,DepotDossier $depotDossier): JsonResponse
  1005.     
  1006.         
  1007.         
  1008.   
  1009.         if ($request->getMethod() == "POST") {
  1010.             
  1011.             // $file=$request->files->get('validedocument');
  1012.             $commentaire $request->request->get('commentaire');
  1013.             $status$request->request->get('status');
  1014.             $assigne$request->request->get('assigne');
  1015.             
  1016.              if ($commentaire) {
  1017.                
  1018.                     $commentairesControlle = new CommentairesControlle();
  1019.                     
  1020.                     $commentairesControlle->setCommentaire($commentaire);
  1021.                     $commentairesControlle->setDate(new DateTime());
  1022.                     $commentairesControlle->setDossier($depotDossier);
  1023.                     $commentairesControlle->setStatus($status);
  1024.                     $commentairesControlle->setAssigne($assigne);
  1025.                     $commentairesControlle->setControleur($this->getUser()->getEquipe());
  1026.                     $commentairesControlleRepository->add($commentairesControlletrue);
  1027.                     // if ($this->isGranted('ROLE_CONTROLER')) {
  1028.                     //     $user = $depotDossier->getControler2()->getUser();
  1029.                     //     $notifications = new Notifications();
  1030.                     //     $notifications->setUserId($user);
  1031.                     //     $notifications->setMessage("Le contrôle n°1 du dossier ".$depotDossier->getNumero()." a été validé.");
  1032.                     //     $notifications->setAction("app_depot_dossier_edit");
  1033.                     //     $notifications->setActionId($depotDossier->getId());
  1034.                     //     $notifications->setSender($this->getUser());
  1035.                     //     $notifications->setStatuts("non lu");
  1036.                     //     $notifications->setDate(new DateTime());
  1037.             
  1038.                     //     $notificationsRepository->add($notifications, true);
  1039.                     //     $admins = $equipeRepository->findAll();
  1040.                     //     foreach ($admins as $key => $value) {
  1041.                     //         $listPermissions = $value->getPermissions();
  1042.                     //         foreach ($listPermissions as $v) {
  1043.                     //             if($v == "NOTIFICATION" ){
  1044.                     //                 $notificationsAdmin = new Notifications();
  1045.                     //                 $notificationsAdmin->setUserId($value->getUser());
  1046.                     //                 $notificationsAdmin->setMessage("Le contrôle n°1 du dossier ".$depotDossier->getNumero()." a été validé.");
  1047.                     //                 $notificationsAdmin->setAction("app_depot_dossier_edit");
  1048.                     //                 $notificationsAdmin->setActionId($depotDossier->getId());
  1049.                     //                 $notificationsAdmin->setSender($this->getUser());
  1050.                     //                 $notificationsAdmin->setStatuts("non lu");
  1051.                     //                 $notificationsAdmin->setDate(new DateTime());
  1052.                         
  1053.                     //                 $notificationsRepository->add($notificationsAdmin, true);
  1054.                     //             }
  1055.                     //         }
  1056.                     //     }
  1057.                         
  1058.                     // }else{
  1059.                     // }
  1060.                     
  1061.                         
  1062.                         
  1063.                     
  1064.                    
  1065.                     return $this->json(['success' => true'message' => 'commentaire ajouter ']);
  1066.              }
  1067.         }
  1068.         return $this->json(['success' => false'error' => 'Erreur ']);
  1069.     }
  1070.        /**
  1071.      * @Route("/commentaireedite/{id}", methods={"POST"})
  1072.      */
  1073.     public function commentaireedite(Request $request,CommentairesControlleRepository $commentairesControlleRepository,CommentairesControlle $commentairesControlle ): JsonResponse
  1074.     
  1075.         
  1076.         
  1077.   
  1078.         if ($request->getMethod() == "POST") {
  1079.             
  1080.             // $file=$request->files->get('validedocument');
  1081.             $commentaire $request->request->get('commentaire');
  1082.        
  1083.             
  1084.              if ($commentaire) {
  1085.             
  1086.                     $commentairesControlle->setCommentaire($commentaire);
  1087.                     $commentairesControlle->setDate(new DateTime());
  1088.                     $commentairesControlleRepository->add($commentairesControlletrue);
  1089.                         
  1090.                         
  1091.                     
  1092.                    
  1093.                     return $this->json(['success' => true'message' => 'commentaire ajouter ']);
  1094.              }
  1095.         }
  1096.         return $this->json(['success' => false'error' => 'Erreur ']);
  1097.     }
  1098.     
  1099.     /**
  1100.      * @Route("/suprimercommentaire/{id}", methods={"POST"})
  1101.      */
  1102.     public function suprimercommentaire(Request $request ,CommentairesControlleRepository $commentairesControlleRepository,CommentairesControlle $commentairesControlle): JsonResponse
  1103.     
  1104.         
  1105.         
  1106.   
  1107.         if ($request->getMethod() == "POST") {
  1108.             
  1109.             // $file=$request->files->get('validedocument');
  1110.             $id $request->request->get('id');
  1111.              if ($id) {
  1112.                     
  1113.                 $commentairesControlleRepository->remove($commentairesControlletrue);
  1114.                     return $this->json(['success' => true'message' => 'supprimer succès']);
  1115.              }
  1116.         }
  1117.         return $this->json(['success' => false'error' => 'Erreur ']);
  1118.     }
  1119.        /**
  1120.      * @Route("/blocage/{id}", methods={"POST"})
  1121.      */
  1122.     public function blocage(Request $request,
  1123.      NotificationsRepository $notificationsRepository,DepotDossier $depotDossier,DepotDossierRepository $depotDossierRepository): JsonResponse
  1124.     
  1125.         
  1126.         
  1127.   
  1128.         if ($request->getMethod() == "POST") {
  1129.             
  1130.             // $file=$request->files->get('validedocument');
  1131.             $lock $request->request->get('lock');
  1132.           
  1133.              if ($lock) {
  1134.                
  1135.                   if ($depotDossier->getBlocage()==null || $depotDossier->getBlocage()=='non') {
  1136.                     $depotDossier->setBlocage("oui");
  1137.                   }else{
  1138.                     $depotDossier->setBlocage("non");
  1139.                   }
  1140.                     $depotDossierRepository->add($depotDossiertrue);
  1141.                     // if ($this->isGranted('ROLE_CONTROLER')) {
  1142.                     //     $user = $depotDossier->getControler2()->getUser();
  1143.                     //     $notifications = new Notifications();
  1144.                     //     $notifications->setUserId($user);
  1145.                     //     $notifications->setMessage("Le contrôle n°1 du dossier ".$depotDossier->getNumero()." a été validé.");
  1146.                     //     $notifications->setAction("app_depot_dossier_edit");
  1147.                     //     $notifications->setActionId($depotDossier->getId());
  1148.                     //     $notifications->setSender($this->getUser());
  1149.                     //     $notifications->setStatuts("non lu");
  1150.                     //     $notifications->setDate(new DateTime());
  1151.             
  1152.                     //     $notificationsRepository->add($notifications, true);
  1153.                     //     $admins = $equipeRepository->findAll();
  1154.                     //     foreach ($admins as $key => $value) {
  1155.                     //         $listPermissions = $value->getPermissions();
  1156.                     //         foreach ($listPermissions as $v) {
  1157.                     //             if($v == "NOTIFICATION" ){
  1158.                     //                 $notificationsAdmin = new Notifications();
  1159.                     //                 $notificationsAdmin->setUserId($value->getUser());
  1160.                     //                 $notificationsAdmin->setMessage("Le contrôle n°1 du dossier ".$depotDossier->getNumero()." a été validé.");
  1161.                     //                 $notificationsAdmin->setAction("app_depot_dossier_edit");
  1162.                     //                 $notificationsAdmin->setActionId($depotDossier->getId());
  1163.                     //                 $notificationsAdmin->setSender($this->getUser());
  1164.                     //                 $notificationsAdmin->setStatuts("non lu");
  1165.                     //                 $notificationsAdmin->setDate(new DateTime());
  1166.                         
  1167.                     //                 $notificationsRepository->add($notificationsAdmin, true);
  1168.                     //             }
  1169.                     //         }
  1170.                     //     }
  1171.                         
  1172.                     // }else{
  1173.                     // }
  1174.                     
  1175.                         
  1176.                         
  1177.                     
  1178.                    
  1179.                     return $this->json(['success' => true'message' => 'blocage adresse']);
  1180.              }
  1181.         }
  1182.         return $this->json(['success' => false'error' => 'Erreur ']);
  1183.     }
  1184.     /**
  1185.      * @Route("/exportedepot/{id}", name="app_exporte_depot",  methods={"GET"})
  1186.      */
  1187.     public function exporte(Filtre $filtre,DepotDossierRepository $depotDossierRepository,FiltreRepository $filtreRepository): Response
  1188.     {
  1189.         
  1190.         
  1191.         $jsonFilePath 'assets/json/dossier-list.json';
  1192.         // Étape 1 : Récupérer le contenu JSON depuis le fichier
  1193.         $jsonContent file_get_contents($jsonFilePath);
  1194.         // Étape 2 : Décoder le contenu JSON en tableau PHP
  1195.         $phpArray json_decode($jsonContenttrue);
  1196.       
  1197.         // Créer un nouveau classeur Excel
  1198.         $spreadsheet = new Spreadsheet();
  1199.                 
  1200.         // Obtenir la feuille active
  1201.         $sheet $spreadsheet->getActiveSheet();
  1202.         // Écrire des données dans la feuille
  1203.         $sheet->setCellValue('A1''Numéro dossier');
  1204.         $sheet->setCellValue('B1''Operation');
  1205.         $sheet->setCellValue('C1''Nom du Beneficiaire');
  1206.         $sheet->setCellValue('D1''Deal associé');
  1207.         $sheet->setCellValue('E1''Controller');
  1208.         $sheet->setCellValue('F1''Controller');
  1209.         $sheet->setCellValue('G1''Cumac');
  1210.         $sheet->setCellValue('H1''Status');
  1211.         $i=2;
  1212.         
  1213.         if ($phpArray === null) {
  1214.             echo "Erreur lors du décodage JSON : " json_last_error_msg();
  1215.         } else {
  1216.             // Utilisez le tableau PHP $phpArray comme bon vous semble
  1217.             foreach ($phpArray as $value) {
  1218.                 $dl=$depotDossierRepository->findOneBy(["id"=>intval($value["id"])]);
  1219.                 $sheet->setCellValue('A'.$i$dl->getNumero());
  1220.                 $ops="";
  1221.                 $opi=0;
  1222.                 foreach ($dl->getOperation() as $key => $op) {
  1223.                     if ($opi>0) {
  1224.                         $ops.=";"
  1225.                     }
  1226.                     $ops.=explode(':',$op->getNom())[0];
  1227.                 
  1228.                     $opi=$opi 1;
  1229.                 }
  1230.                 $sheet->setCellValue('B'.$i$ops);
  1231.                 $sheet->setCellValue('C'.$i$dl->getNomclient().' '.$dl->getPrenomclient());
  1232.                 $sheet->setCellValue('D'.$i,  $dl->getDeal()->getNumero());
  1233.                 if ($dl->getControler1() != null) {
  1234.                     $sheet->setCellValue('E'.$i$dl->getControler1()->getPrenom());
  1235.                 }
  1236.                 if ($dl->getControler2() != null) {
  1237.                     $sheet->setCellValue('F'.$i$dl->getControler2()->getPrenom());
  1238.                 }
  1239.                
  1240.                 
  1241.                 $sheet->setCellValue('G'.$i$dl->getCumac());
  1242.                 $sheet->setCellValue('H'.$i$dl->getStatus());
  1243.                 $i=$i+1;
  1244.             }
  1245.         }
  1246.        
  1247.         // Créer un objet Writer pour enregistrer le fichier
  1248.         $writer = new Xlsx($spreadsheet);
  1249.         // Enregistrer le fichier à un emplacement
  1250.         $now = new DateTime();
  1251.                 $date $now->format('d-m-Y H-i-s');
  1252.         $nomexecel "deal-".$this->getUser()->getEquipe()->getPrenom()."-".$date;
  1253.         $cheminFichier =$this->getParameter('installateur_directory') . "/export/export".$nomexecel.".xlsx";
  1254.         $writer->save($cheminFichier);
  1255.         $filtre->setExporte("export".$nomexecel.".xlsx");
  1256.         $filtreRepository->add($filtretrue);
  1257.         // Renvoyer la réponse avec le fichier Excel en pièce jointe
  1258.         return $this->file($cheminFichier);
  1259.     }
  1260.     
  1261.        /**
  1262.      * @Route("/{id}/archives", name="app_depot_archives", methods={"GET", "POST"})
  1263.      */
  1264.     public function archives(Request $request,DepotDossier $depotDossier): Response
  1265.     {
  1266.         
  1267.         if ($request->getMethod() == "POST") {
  1268.             $form $request->request;
  1269.         
  1270.        
  1271.         // Créez un nom de fichier unique pour le fichier ZIP
  1272.         $zipFileName 'DepotDossier_'.$depotDossier->getDeal()->getInstallateur()->getSociete().'_' date('d-m-Y-His') . '.zip';
  1273.     
  1274.         // Créez le chemin absolu vers le fichier ZIP
  1275.         $zipFilePath $this->getParameter('installateur_directory') . '/archiver/' $zipFileName;
  1276.     
  1277.         // Utilisez la classe ZipArchive pour créer le fichier ZIP
  1278.         $zip = new \ZipArchive();
  1279.         $zip->open($zipFilePath\ZipArchive::CREATE \ZipArchive::OVERWRITE);
  1280.     
  1281.       
  1282.             
  1283.             if ($form->get("chk_archiverdepot") != null ) {
  1284.                 foreach ($form->get("chk_archiverdepot") as $key => $champs) {
  1285.                     foreach ($depotDossier->getChampsDepotDossiers() as $value) {
  1286.                         if ($value->getType()=="file") {
  1287.                             if ($value->getId() == $champs) {
  1288.                                 if ($value->getValeur()!=null) {
  1289.                                     foreach ($value->getValeur() as $val) {
  1290.                                         $filePath $this->getParameter('installateur_directory').'/'.$val;
  1291.                                         $relativePath $depotDossier->getDeal()->getInstallateur()->getSociete()."/".$val;
  1292.                                         $zip->addFile($filePath$relativePath);
  1293.                                     }
  1294.                                     
  1295.                                 }
  1296.                             }
  1297.                         }
  1298.                         
  1299.                          
  1300.                     }
  1301.                 }
  1302.             }
  1303.            
  1304.            
  1305.             
  1306.             // Fermer le fichier ZIP
  1307.             $zip->close();
  1308.             // Envoyer le fichier ZIP en tant que réponse de téléchargement
  1309.             $response = new BinaryFileResponse($zipFilePath);
  1310.             $response->headers->set('Content-Type''application/zip');
  1311.             $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT$zipFileName);
  1312.             // if ($filesystem->exists($sourceFolder)) {
  1313.             //     // Supprimez tous les fichiers et dossiers à l'intérieur du dossier
  1314.             //     $filesystem->remove(glob($sourceFolder . '/*'));
  1315.             // }
  1316.             return $response;
  1317.             }
  1318.             return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$depotDossier->getId()], Response::HTTP_SEE_OTHER);
  1319.       
  1320.        
  1321.         
  1322.     }
  1323.     
  1324.      /**
  1325.      * @Route("/{id}/appel", name="app_depot_appel", methods={"GET", "POST"})
  1326.      */
  1327.     public function appel(Request $request,DepotDossier $depotDossier,AppelqualiteRepository $appelqualiteRepository,CommentaireAppelqualiteRepository $commentaireAppelqualiteRepository): Response
  1328.     {
  1329.         
  1330.         if ($request->getMethod() == "POST") {
  1331.             $form $request->request;
  1332.             $appelqualite = new Appelqualite();
  1333.             $appelqualite->setClient($form ->get('questionclient'));
  1334.             $appelqualite->setAdresse($form ->get('questionadresse'));
  1335.             $appelqualite->setInstallation($form ->get('questioninstallation'));
  1336.             $appelqualite->setTerminer($form ->get('questionterminer'));
  1337.             $appelqualite->setQualite($form ->get('questionqualite'));
  1338.             $appelqualite->setComplet($form ->get('questioncomplet'));
  1339.             $appelqualite->setSpecifique($form ->get('questionspecifique'));
  1340.             $appelqualite->setDossier($depotDossier);
  1341.             $appelqualite->setStatus($form ->get('statusappel'));
  1342.             if ($form ->get('nonclient')) {
  1343.                 $appelqualite->setNonclient($form ->get('nonclient'));
  1344.             }
  1345.             if ($form ->get('nonadresse')) {
  1346.                 $appelqualite->setNonclient($form ->get('nonadresse'));
  1347.             }
  1348.             if ($form ->get('noninstallation')) {
  1349.                 $appelqualite->setNoninstallation($form ->get('noninstallation'));
  1350.             }
  1351.             if ($form ->get('nonterminer')) {
  1352.                 $appelqualite->setNontermier($form ->get('nonterminer'));
  1353.             }
  1354.             if ($form ->get('noncomplete')) {
  1355.                 $appelqualite->setNoncomplete($form ->get('noncomplete'));
  1356.             }
  1357.             if ($form ->get('nonspecifique')) {
  1358.                 $appelqualite->setNonspecifique($form ->get('nonspecifique'));
  1359.             }
  1360.             
  1361.             if ($form ->get('ouiqualite')) {
  1362.                 $appelqualite->setOuiqualite($form ->get('ouiqualite'));
  1363.             }
  1364.             
  1365.             if ($this->getUser()->getEquipe()) {
  1366.                 $appelqualite->setEquipe($this->getUser()->getEquipe());
  1367.             }
  1368.             $appelqualiteRepository->add($appelqualitetrue);
  1369.             if ($form ->get('commentaire') != null) {
  1370.                 $commentaireAppelqualite = new CommentaireAppelqualite();
  1371.                     
  1372.                 $commentaireAppelqualite->setCommentaire($form ->get('commentaire'));
  1373.                 $commentaireAppelqualite->setDate(new DateTime());
  1374.                 $commentaireAppelqualite->setAppelqualite($appelqualite);
  1375.                 $commentaireAppelqualite->setUser($this->getUser());
  1376.     
  1377.                 $commentaireAppelqualiteRepository->add($commentaireAppelqualitetrue);
  1378.             }
  1379.             
  1380.       
  1381.            
  1382.         }
  1383.         return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$depotDossier->getId()], Response::HTTP_SEE_OTHER);
  1384.       
  1385.        
  1386.         
  1387.     }
  1388.      /**
  1389.      * @Route("/appel/{id}/edit", name="app_depot_appel_edit", methods={"GET", "POST"})
  1390.      */
  1391.     public function editappel(Request $request,Appelqualite $appelqualite,AppelqualiteRepository $appelqualiteRepository): Response
  1392.     {
  1393.         
  1394.         if ($request->getMethod() == "POST") {
  1395.             $form $request->request;
  1396.             $appelqualite->setClient($form ->get('questionclient'));
  1397.             $appelqualite->setAdresse($form ->get('questionadresse'));
  1398.             $appelqualite->setInstallation($form ->get('questioninstallation'));
  1399.             $appelqualite->setTerminer($form ->get('questionterminer'));
  1400.             $appelqualite->setQualite($form ->get('questionqualite'));
  1401.             $appelqualite->setComplet($form ->get('questioncomplet'));
  1402.             $appelqualite->setSpecifique($form ->get('questionspecifique'));
  1403.             $appelqualite->setStatus($form ->get('statusappel'));
  1404.             if ($this->getUser()->getEquipe()) {
  1405.                 $appelqualite->setEquipe($this->getUser()->getEquipe());
  1406.             }
  1407.             if ($form ->get('nonclient')) {
  1408.                 $appelqualite->setNonclient($form ->get('nonclient'));
  1409.             }
  1410.             if ($form ->get('nonadresse')) {
  1411.                 $appelqualite->setNonclient($form ->get('nonadresse'));
  1412.             }
  1413.             if ($form ->get('noninstallation')) {
  1414.                 $appelqualite->setNoninstallation($form ->get('noninstallation'));
  1415.             }
  1416.             if ($form ->get('nonterminer')) {
  1417.                 $appelqualite->setNontermier($form ->get('nonterminer'));
  1418.             }
  1419.             if ($form ->get('noncomplete')) {
  1420.                 $appelqualite->setNoncomplete($form ->get('noncomplete'));
  1421.             }
  1422.             if ($form ->get('nonspecifique')) {
  1423.                 $appelqualite->setNonspecifique($form ->get('nonspecifique'));
  1424.             }
  1425.             
  1426.             if ($form ->get('ouiqualite')) {
  1427.                 $appelqualite->setOuiqualite($form ->get('ouiqualite'));
  1428.             }
  1429.             
  1430.             
  1431.             if ($this->getUser()->getEquipe()) {
  1432.                 $appelqualite->setEquipe($this->getUser()->getEquipe());
  1433.             }
  1434.             
  1435.             $appelqualiteRepository->add($appelqualitetrue);
  1436.       
  1437.            
  1438.         }
  1439.         return $this->redirectToRoute('app_depot_dossier_edit', ['id' =>$appelqualite->getDossier()->getId()], Response::HTTP_SEE_OTHER);
  1440.       
  1441.        
  1442.         
  1443.     }
  1444.     
  1445.     /**
  1446.      * @Route("/archiverdossier/{id}", methods={"POST"})
  1447.      */
  1448.     public function archiverdossier(Request $request,DepotDossier $depotDossier,DepotDossierRepository $depotDossierRepository): JsonResponse
  1449.     
  1450.         
  1451.         
  1452.   
  1453.         if ($request->getMethod() == "POST") {
  1454.             
  1455.             // $file=$request->files->get('validedocument');
  1456.             $id $request->request->get('id');
  1457.           
  1458.              if ($id) {
  1459.                 $depotDossier->setArchive($depotDossier->getStatus());
  1460.                 $depotDossier->setStatus("archive"); 
  1461.                 $depotDossierRepository->add($depotDossiertrue);
  1462.             
  1463.         
  1464.                 return $this->json(['success' => true'message' => 'deal archive']);
  1465.              }
  1466.         }
  1467.         return $this->json(['success' => false'error' => 'Erreur ']);
  1468.     }
  1469.     
  1470. }