src/Services/EtapsService.php line 123

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  */
  5. namespace App\Services;
  6. use App\Entity\Alert;
  7. use App\Entity\CategoryDocument;
  8. use App\Entity\CommentDoc;
  9. use App\Entity\CommentEtap;
  10. use App\Entity\ContratConstruction;
  11. use App\Entity\DimensionEtap160;
  12. use App\Entity\Document;
  13. use App\Entity\DocUpload;
  14. use App\Entity\Etap0;
  15. use App\Entity\Etap1;
  16. use App\Entity\Etap121;
  17. use App\Entity\Etap159;
  18. use App\Entity\Etap160;
  19. use App\Entity\Etap161;
  20. use App\Entity\Etap171;
  21. use App\Entity\Etap172;
  22. use App\Entity\Etap173;
  23. use App\Entity\Etap174;
  24. use App\Entity\Etap175;
  25. use App\Entity\Etap1Pcm;
  26. use App\Entity\Etap2;
  27. use App\Entity\Etap201;
  28. use App\Entity\Etap23;
  29. use App\Entity\Etap24Champs;
  30. use App\Entity\Etap26Champs;
  31. use App\Entity\Etap2Pcm;
  32. use App\Entity\Etap3;
  33. use App\Entity\Etap4;
  34. use App\Entity\Etap5;
  35. use App\Entity\Etap6;
  36. use App\Entity\Etap601;
  37. use App\Entity\Etap602;
  38. use App\Entity\Etap7;
  39. use App\Entity\Etap71;
  40. use App\Entity\Etap71Litige;
  41. use App\Entity\Etap71LitigeCommentaire;
  42. use App\Entity\Etap8;
  43. use App\Entity\Etap80;
  44. use App\Entity\Etap9;
  45. use App\Entity\Etap10;
  46. use App\Entity\Etap11;
  47. use App\Entity\Etap12;
  48. use App\Entity\Etap13;
  49. use App\Entity\Etap14;
  50. use App\Entity\Etap15;
  51. use App\Entity\Etap16;
  52. use App\Entity\Etap17;
  53. use App\Entity\Etap18;
  54. use App\Entity\Etap19;
  55. use App\Entity\Etap20;
  56. use App\Entity\Etap21;
  57. use App\Entity\Etap22;
  58. use App\Entity\Etap24;
  59. use App\Entity\Etap25;
  60. use App\Entity\Etap26;
  61. use App\Entity\Etaps;
  62. use App\Entity\EtapsCategory;
  63. use App\Entity\Fournisseur;
  64. use App\Entity\FournisseurProject;
  65. use App\Entity\ImfomationContratAchat;
  66. use App\Entity\JalonPaiementContratConstruction;
  67. use App\Entity\JalonPaiementEtap16;
  68. use App\Entity\ModuleInformation;
  69. use App\Entity\NumeroCardi;
  70. use App\Entity\OnduleurInformation;
  71. use App\Entity\ParametrageXlsProject;
  72. use App\Entity\PrixAnnexeContratConstruction;
  73. use App\Entity\PrixAnnexeEtap16;
  74. use App\Entity\Project;
  75. use App\Entity\Spv;
  76. use App\Entity\StatusConsruction;
  77. use App\Entity\StatusFoncier;
  78. use App\Entity\StatusRaccordement;
  79. use App\Entity\StatusTracker;
  80. use App\Entity\StatusTrackerConstruction;
  81. use App\Entity\StatusUrbanisme;
  82. use App\Entity\Toiture160;
  83. use App\Entity\TypeValorisation;
  84. use App\Entity\User;
  85. use App\Entity\VisiteTerrain;
  86. use App\Entity\VisiteTerrainV2;
  87. use App\Form\ProjectType;
  88. use App\Form\UserType;
  89. use Kunnu\Dropbox\Dropbox;
  90. use Kunnu\Dropbox\DropboxApp;
  91. use Kunnu\Dropbox\Exceptions\DropboxClientException;
  92. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  93. use Doctrine\ORM\EntityManagerInterface;
  94. use Symfony\Component\Form\FormFactoryInterface;
  95. use Symfony\Component\HttpFoundation\File\UploadedFile;
  96. use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
  97. use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  98. use Symfony\Contracts\Translation\TranslatorInterface;
  99. use Symfony\Component\Security\Core\Security;
  100. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  101. use Twig\Environment;
  102. use App\Entity\Centrale;
  103. use Symfony\Component\Validator\Constraints as Assert;
  104. use Symfony\Component\Validator\Validator\ValidatorInterface;
  105. use PhpOffice\PhpSpreadsheet\IOFactory;
  106. class EtapsService
  107. {
  108.     private $em;
  109.     private $trans;
  110.     private $params;
  111.     private $security;
  112.     private $session;
  113.     private $twig;
  114.     private $notification;
  115.     public function __construct(
  116.         Environment $twig,
  117.         SessionInterface $session,
  118.         Security $security,
  119.         ParameterBagInterface $params,
  120.         EntityManagerInterface $em,
  121.         TranslatorInterface $trans,
  122.         ValidatorInterface $validator,
  123.         FlashBagInterface $flashBag,
  124.         UserPasswordEncoderInterface $passwordEncoder,
  125.         Notifications $notifications,
  126.         FormFactoryInterface $form
  127.     ) {
  128.         $this->em = $em;
  129.         $this->trans = $trans;
  130.         $this->params = $params;
  131.         $this->security = $security;
  132.         $this->session = $session;
  133.         $this->twig = $twig;
  134.         $this->validator = $validator;
  135.         $this->form = $form;
  136.         $this->flashBag = $flashBag;
  137.         $this->passwordEncoder = $passwordEncoder;
  138.         $this->notification = $notifications;
  139.     }
  140.     public function addComment($request)
  141.     {
  142.         $comment = $request->get('comment');
  143.         $etapNum = $request->get('etapNum');
  144.         $tokenUser = $request->get('tokenUser');
  145.         $tokenProject = $request->get('tokenProject');
  146.         $commentEtapId = $request->get('commentEtapId');
  147.         if($comment  and $tokenUser and $tokenProject){
  148.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  149.             $user = $this->em->getRepository(User::class)->findOneBy(['token'=>$tokenUser]);
  150.             if($project && $user){
  151.                 if($commentEtapId){
  152.                     $commentEntity = $this->em->getRepository(CommentEtap::class)->find($commentEtapId);
  153.                     if(!$commentEntity){
  154.                         $commentEntity = new CommentEtap();
  155.                     }
  156.                 }else{
  157.                     $commentEntity = new CommentEtap();
  158.                 }
  159.                 $commentEntity->setProject($project);
  160.                 $commentEntity->setUser($user);
  161.                 $commentEntity->setComment($comment);
  162.                 $commentEntity->setEtapNum($etapNum);
  163.                 $this->em->persist($commentEntity);
  164.                 $this->em->flush();
  165.                 return [
  166.                     'commentEntity' => $commentEntity,
  167.                     'success' => true
  168.                 ];
  169.             }
  170.          }
  171.         return [
  172.             'success' => false
  173.         ];
  174.     }
  175.     public function deleteComment($request)
  176.     {
  177.         $commentEtapId = $request->get('commentEtapId');
  178.         if($commentEtapId){
  179.             $commentEntity = $this->em->getRepository(CommentEtap::class)->find($commentEtapId);
  180.             if($commentEntity) {
  181.                 $this->em->remove($commentEntity);
  182.                 $this->em->flush();
  183.                 return [
  184.                     'success' => true
  185.                 ];
  186.             }
  187.         }
  188.         return [
  189.             'success' => false
  190.         ];
  191.     }
  192.     public function changeStatusNextEtap($etap){
  193.         if(is_object($etap)){
  194.             $this->em->refresh($etap);
  195.             $project = $etap->getProject();
  196.             $category = $etap->getEtap()->getCategory();
  197.             $etapNexNum = $etap->getEtap()->getEtapsNum()+1;
  198.             $etapLigne = $this->em->getRepository(Etaps::class)->getEtapByCreteria($category,$etapNexNum,$project);
  199.             if(!$etapLigne){
  200.                 $etapLigne = $this->em->getRepository(Etaps::class)->getEtapByCreteria($category,$etapNexNum+2,$project);
  201.                 if(!$etapLigne){
  202.                     $etapLigne = $this->em->getRepository(Etaps::class)->getEtapByCreteria($category,$etapNexNum+3,$project);
  203.                     if(!$etapLigne){
  204.                         $etapLigne = $this->em->getRepository(Etaps::class)->getEtapByCreteria($category,$etapNexNum+4,$project);
  205.                         if(!$etapLigne){
  206.                             $nexCategoryNum = $category->getNum()+1;
  207.                             $nexCategoryEntity = $this->em->getRepository(EtapsCategory::class)->findOneBy(['num'=>$nexCategoryNum]);
  208.                             if($nexCategoryEntity){
  209.                                 $etapLigne = $this->em->getRepository(Etaps::class)->getEtapByCreteria($nexCategoryEntity,0,$project);
  210.                                 if(!$etapLigne){
  211.                                     $etapLigne = $this->em->getRepository(Etaps::class)->getEtapByCreteria($nexCategoryEntity,1,$project);
  212.                                 }
  213.                             }
  214.                         }
  215.                     }
  216.                 }
  217.             }
  218.             if($etapLigne){
  219.                 $nextEtapClass = 'App\\Entity\\Etap' . $etapLigne->getNum();
  220.                 $nexEtap = $this->em->getRepository($nextEtapClass)->findOneBy(['project' => $project->getId()]);
  221.                 if ($nexEtap) {
  222.                     if ($nexEtap->getStatus() == Etaps::STATUS_EN_COURS) {
  223.                         $this->em->persist($nexEtap);
  224.                         $this->em->flush();
  225.                         $project = $etap->getProject();
  226.                         $project->setNumEtapEncours($nexEtap->getEtap()->getNum());
  227.                         $this->em->persist($project);
  228.                         $this->em->flush();
  229.                     }
  230.                 }
  231.             }
  232.         }
  233.     }
  234.     public function changeStatuEtapValideNotNeedCondition($etap){
  235.         if(is_object($etap)){
  236.             $this->em->refresh($etap);
  237.             if(!$etap->getEtap()->getIsNeedCondition()){
  238.                 $etap->setStatus(Etaps::STATUS_VALIDE);
  239.                 $etap->setValideAt(new \DateTime());
  240.                 $this->em->persist($etap);
  241.                 $this->em->flush();
  242.             }
  243.             $this->changeStatusNextEtap($etap);
  244.         }
  245.     }
  246.     private function checkUserAction($user,$project,$etap){
  247.         if(in_array('ROLE_DEV',$user->getRoles())){
  248.             if($user->getId() == $project->getDeveloppeur()->getId()){
  249.                 if($etap->getStatus() == Etaps::STATUS_FERMEE  or $etap->getStatus() == Etaps::STATUS_REFUSE ){
  250.                     return false;
  251.                 }
  252.             }
  253.         }elseif(in_array('ROLE_EPC',$user->getRoles())){
  254.             if($user->getId() == $project->getEpc()->getId()) {
  255.                 if ($etap->getStatus() == Etaps::STATUS_FERMEE or $etap->getStatus() == Etaps::STATUS_REFUSE) {
  256.                     return  false;
  257.                 }
  258.             }
  259.         }
  260.         return true;
  261.     }
  262.     public function changeStatus($etap,$status,$commentRefuse=null,$commentDemande=null){
  263.         if(is_object($etap)){
  264.             $etap->setStatus($status);
  265.             if($status == Etaps::STATUS_VALIDE){
  266.                 $etap->setValideAt(new \DateTime());
  267.             }
  268.             if($commentRefuse){
  269.                 $etap->setCommentRefuse($commentRefuse) ;
  270.                 $etap->setRefuseAt(new \DateTime());
  271.             }
  272.             if($commentDemande){
  273.                 $etap->setCommentDemande($commentDemande);
  274.                 $etap->setCommentDemandeAt(new \DateTime());
  275.             }
  276.             $this->em->persist($etap);
  277.             $this->em->flush();
  278.         }
  279.     }
  280.     public function addArchiveDoc($array){
  281.         if(count($array)> 0){
  282.             foreach ($array as $item){
  283.                 $item->setIsArchived(1);
  284.                 $this->em->persist($item);
  285.                 $this->em->flush();
  286.             }
  287.         }
  288.     }
  289.     public function submitEtap0($request,$user)
  290.     {
  291.         $fileInfoArchiMultiple = $request->get('fileInfoArchiMultiple');
  292.         $fileMsaAttestationMultiple = $request->get('fileMsaAttestationMultiple');
  293.         $fileMsaReleveExploitationMultiple = $request->get('fileMsaReleveExploitationMultiple');
  294.         $fileFicheBesoinAgricoleMultiple = $request->get('fileFicheBesoinAgricoleMultiple');
  295.         $fileLettreMotivationMultiple = $request->get('fileLettreMotivationMultiple');
  296.         $fileICPEMultiple = $request->get('fileICPEMultiple');
  297.         $fileReglementUrbanismeMultiple = $request->get('fileReglementUrbanismeMultiple');
  298.         $fileAutreEtap0Multiple = $request->get('fileAutreEtap0Multiple');
  299.         $commentaireEtap0 = $request->get('commentaireEtap0');
  300.         $architecte = $request->get('architecte');
  301.         $etapToken = $request->get('etapToken');
  302.         $tokenProject = $request->get('tokenProject');
  303.         if($etapToken and $tokenProject){
  304.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  305.             $etap = $this->em->getRepository(Etap0::class)->findOneBy(['token'=>$etapToken]);
  306.             if($project && $etap){
  307.                 if(!$this->checkUserAction($user,$project,$etap)){
  308.                     return [
  309.                         'success' => false
  310.                     ];
  311.                 }
  312.                 if($fileInfoArchiMultiple){
  313.                     $array = explode(',',$fileInfoArchiMultiple);
  314.                     foreach ($array as $item){
  315.                         $fileInfoArchiMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  316.                         if($fileInfoArchiMultipleEntity){
  317.                             $nomenclature = $this->getNomenclature($etap,$fileInfoArchiMultipleEntity,'Infos pour archi (bardage, aménagement intérieur, solution EP, borne incendie…)');
  318.                             $etap->addFileInfoArchiMultiple($fileInfoArchiMultipleEntity);
  319.                             $this->uploadFileToDropbox($fileInfoArchiMultipleEntity,$project,"Urbanisme/".$fileInfoArchiMultipleEntity->getId().$nomenclature);
  320.                         }
  321.                     }
  322.                 }
  323.                 if($fileMsaAttestationMultiple){
  324.                     $array = explode(',',$fileMsaAttestationMultiple);
  325.                     foreach ($array as $item){
  326.                         $fileMsaAttestationMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  327.                         if($fileMsaAttestationMultipleEntity){
  328.                             $nomenclature = $this->getNomenclature($etap,$fileMsaAttestationMultipleEntity,'MSA Attestation');
  329.                             $etap->addFileMsaAttestationMultiple($fileMsaAttestationMultipleEntity);
  330.                             $this->uploadFileToDropbox($fileMsaAttestationMultipleEntity,$project,"Urbanisme/".$fileMsaAttestationMultipleEntity->getId().$nomenclature);
  331.                         }
  332.                     }
  333.                 }
  334.                 if($fileMsaReleveExploitationMultiple){
  335.                     $array = explode(',',$fileMsaReleveExploitationMultiple);
  336.                     foreach ($array as $item){
  337.                         $fileMsaReleveExploitationMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  338.                         if($fileMsaReleveExploitationMultipleEntity){
  339.                             $nomenclature = $this->getNomenclature($etap,$fileMsaReleveExploitationMultipleEntity,'MSA Relevé d’exploitation');
  340.                             $etap->addFileMsaReleveExploitationMultiple($fileMsaReleveExploitationMultipleEntity);
  341.                             $this->uploadFileToDropbox($fileMsaReleveExploitationMultipleEntity,$project,"Urbanisme/".$fileMsaReleveExploitationMultipleEntity->getId().$nomenclature);
  342.                         }
  343.                     }
  344.                 }
  345.                 if($fileFicheBesoinAgricoleMultiple){
  346.                     $array = explode(',',$fileFicheBesoinAgricoleMultiple);
  347.                     foreach ($array as $item){
  348.                         $fileFicheBesoinAgricoleMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  349.                         if($fileFicheBesoinAgricoleMultipleEntity){
  350.                             $nomenclature = $this->getNomenclature($etap,$fileFicheBesoinAgricoleMultipleEntity,'Fiche de besoins agricoles');
  351.                             $etap->addFileFicheBesoinAgricoleMultiple($fileFicheBesoinAgricoleMultipleEntity);
  352.                             $this->uploadFileToDropbox($fileFicheBesoinAgricoleMultipleEntity,$project,"Urbanisme/".$fileFicheBesoinAgricoleMultipleEntity->getId().$nomenclature);
  353.                         }
  354.                     }
  355.                 }
  356.                 if($fileLettreMotivationMultiple){
  357.                     $array = explode(',',$fileLettreMotivationMultiple);
  358.                     foreach ($array as $item){
  359.                         $fileLettreMotivationMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  360.                         if($fileLettreMotivationMultipleEntity){
  361.                             $nomenclature = $this->getNomenclature($etap,$fileLettreMotivationMultipleEntity,'Lettre de motivation');
  362.                             $etap->addFileLettreMotivationMultiple($fileLettreMotivationMultipleEntity);
  363.                             $this->uploadFileToDropbox($fileLettreMotivationMultipleEntity,$project,"Urbanisme/".$fileLettreMotivationMultipleEntity->getId().$nomenclature);
  364.                         }
  365.                     }
  366.                 }
  367.                 if($fileICPEMultiple){
  368.                     $array = explode(',',$fileICPEMultiple);
  369.                     foreach ($array as $item){
  370.                         $fileICPEMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  371.                         if($fileICPEMultipleEntity){
  372.                             $nomenclature = $this->getNomenclature($etap,$fileICPEMultipleEntity,'ICPE (attestation non-soumission ou preuve de dépôt déclaration)');
  373.                             $etap->addFileICPEMultiple($fileICPEMultipleEntity);
  374.                             $this->uploadFileToDropbox($fileICPEMultipleEntity,$project,"Urbanisme/".$fileICPEMultipleEntity->getId().$nomenclature);
  375.                         }
  376.                     }
  377.                 }
  378.                 if($fileReglementUrbanismeMultiple){
  379.                     $array = explode(',',$fileReglementUrbanismeMultiple);
  380.                     foreach ($array as $item){
  381.                         $fileReglementUrbanismeMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  382.                         if($fileReglementUrbanismeMultipleEntity){
  383.                             $nomenclature = $this->getNomenclature($etap,$fileReglementUrbanismeMultipleEntity,'Règlement d’urbanisme » (PLU / PLUi)');
  384.                             $etap->addFileReglementUrbanismeMultiple($fileReglementUrbanismeMultipleEntity);
  385.                             $this->uploadFileToDropbox($fileReglementUrbanismeMultipleEntity,$project,"Urbanisme/".$fileReglementUrbanismeMultipleEntity->getId().$nomenclature);
  386.                         }
  387.                     }
  388.                 }
  389.                 if($fileAutreEtap0Multiple){
  390.                     $array = explode(',',$fileAutreEtap0Multiple);
  391.                     foreach ($array as $item){
  392.                         $fileAutreEtap0MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  393.                         if($fileAutreEtap0MultipleEntity){
  394.                             $nomenclature = $this->getNomenclature($etap,$fileAutreEtap0MultipleEntity,'Règlement d’urbanisme » (PLU / PLUi)');
  395.                             $etap->addFileAutreEtap0Multiple($fileAutreEtap0MultipleEntity);
  396.                             $this->uploadFileToDropbox($fileAutreEtap0MultipleEntity,$project,"Urbanisme/".$fileAutreEtap0MultipleEntity->getId().$nomenclature);
  397.                         }
  398.                     }
  399.                 }
  400.                 if($commentaireEtap0 and $commentaireEtap0 != ''){
  401.                     $etap->setCommentaireEtap0($commentaireEtap0);
  402.                 }else{
  403.                     $etap->setCommentaireEtap0(null);
  404.                 }
  405.                 if($architecte and $architecte != 0){
  406.                     $fournisseur = $this->em->getRepository(Fournisseur::class)->find($architecte);
  407.                     if($fournisseur){
  408.                         $etap->setArchitecte($fournisseur);
  409.                     }else{
  410.                         $etap->setArchitecte(null);
  411.                     }
  412.                 }else {
  413.                     $etap->setArchitecte(null);
  414.                 }
  415.                 $this->em->persist($etap);
  416.                 $this->em->flush();
  417.                 $this->updateStatusTracker($project); // set status tracker
  418.                 $this->flashBag->add(
  419.                     'success',
  420.                     'L\'opération a Ã©té effectuée avec succès.'
  421.                 );
  422.                 return [
  423.                     'etap' => $etap,
  424.                     'success' => true
  425.                 ];
  426.             }
  427.         }
  428.         return [
  429.             'success' => false
  430.         ];
  431.     }
  432.     public function submitEtap1($request,$user)
  433.     {
  434.         $fileDossierPcDpMultiple = $request->get('fileDossierPcDpMultiple');
  435.         $fileAutreDocPcMultiple = $request->get('fileAutreDocPcMultiple');
  436.         $fileRecepisseComplementPcMultiple = $request->get('fileRecepisseComplementPcMultiple');
  437.         $fileDemandeComplementPcMultiple = $request->get('fileDemandeComplementPcMultiple');
  438.         $fileRecepisseDepotPcMultiple = $request->get('fileRecepisseDepotPcMultiple');
  439.         $fileArretePcDpMultiple = $request->get('fileArretePcDpMultiple');
  440.         $fileCertificatNonOppositionEtap1Multiple = $request->get('fileCertificatNonOppositionEtap1Multiple');
  441.         $dateArretePcEtap = $request->get('dateArretePcEtap');
  442.         $referenceDp = $request->get('referenceDp');
  443.         $referencePc = $request->get('referencePc');
  444.         $dateDepotPc = $request->get('dateDepotPc');
  445.         $dateDemandeComplement = $request->get('dateDemandeComplement');
  446.         $isDelaiInstruction = $request->get('isDelaiInstruction');
  447.         $delaiInstruction = $request->get('delaiInstruction');
  448.         $dateDepotComplement = $request->get('dateDepotComplement');
  449.         $isNotDateDemandeComplement = $request->get('isNotDateDemandeComplement');
  450.         $isDateArretePcProrogation = $request->get('isDateArretePcProrogation');
  451.         $champLibre = $request->get('champLibre');
  452.         // dp mixte
  453.         $fileDossierPcDpMixteMultiple = $request->get('fileDossierPcDpMixteMultiple');
  454.         $fileAutreDocPcDpMixteMultiple = $request->get('fileAutreDocPcDpMixteMultiple');
  455.         $fileRecepisseComplementPcDpMixteMultiple = $request->get('fileRecepisseComplementPcDpMixteMultiple');
  456.         $fileDemandeComplementPcDpMixteMultiple = $request->get('fileDemandeComplementPcDpMixteMultiple');
  457.         $fileRecepisseDepotPcDpMixteMultiple = $request->get('fileRecepisseDepotPcDpMixteMultiple');
  458.         $fileArretePcDpMixteMultiple = $request->get('fileArretePcDpMixteMultiple');
  459.         $dateArretePcDpMixte = $request->get('dateArretePcDpMixte');
  460.         $referencePcDpMixte = $request->get('referencePcDpMixte');
  461.         $dateDepotPcDpMixte = $request->get('dateDepotPcDpMixte');
  462.         $dateDemandeComplementPcDpMixte = $request->get('dateDemandeComplementPcDpMixte');
  463.         $isDelaiInstructionPcDpMixte = $request->get('isDelaiInstructionPcDpMixte');
  464.         $delaiInstructionPcDpMixte = $request->get('delaiInstructionPcDpMixte');
  465.         $dateDepotComplementPcDpMixte = $request->get('dateDepotComplementPcDpMixte');
  466.         $isDateArretePcProrogationPcDpMixte = $request->get('isDateArretePcProrogationPcDpMixte');
  467.         $champLibrePcDpMixte = $request->get('champLibrePcDpMixte');
  468.         // dp mixte
  469.         $etapToken = $request->get('etapToken');
  470.         $tokenProject = $request->get('tokenProject');
  471.         $etap1Pcm = $request->get('etap1Pcm');
  472.         if($etapToken and $tokenProject){
  473.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  474.             $etap = $this->em->getRepository(Etap1::class)->findOneBy(['token'=>$etapToken]);
  475.             if($project && $etap){
  476.                 if(!$this->checkUserAction($user,$project,$etap)){
  477.                     return [
  478.                         'success' => false
  479.                     ];
  480.                 }
  481.                 if($etap1Pcm){
  482.                     foreach ($etap1Pcm as $item){
  483.                         if(isset($item['id']) and $item['id'] != ''){
  484.                             $etap1PcmEntity = $this->em->getRepository(Etap1Pcm::class)->findOneBy(['token'=>$item['id']]) ;
  485.                         }else{
  486.                             $etap1PcmEntity = new Etap1Pcm() ;
  487.                         }
  488.                         if(isset($item['fileDossierPcmpMultiple']) and $item['fileDossierPcmpMultiple'] != ''){
  489.                             $array = explode(',',$item['fileDossierPcmpMultiple']);
  490.                             foreach ($array as $item1){
  491.                                 $fileDossierPcmpMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  492.                                 $nomenclature = $this->getNomenclature($etap,$fileDossierPcmpMultipleEntity,'Dossier PCM');
  493.                                 $etap1PcmEntity->addFileDossierPcmpMultiple($fileDossierPcmpMultipleEntity);
  494.                                 $this->uploadFileToDropbox($fileDossierPcmpMultipleEntity,$project,"Urbanisme/".$fileDossierPcmpMultipleEntity->getId().$nomenclature);
  495.                             }
  496.                         }
  497.                         if(isset($item['fileArretePcmMultiple']) and $item['fileArretePcmMultiple'] != ''){
  498.                             $array = explode(',',$item['fileArretePcmMultiple']);
  499.                             foreach ($array as $item1){
  500.                                 $fileArretePcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  501.                                 $nomenclature = $this->getNomenclature($etap,$fileArretePcmMultipleEntity,'Arrêté PCM (Permis de construire modificatif)');
  502.                                 $etap1PcmEntity->addFileArretePcmMultiple($fileArretePcmMultipleEntity);
  503.                                 $this->uploadFileToDropbox($fileArretePcmMultipleEntity,$project,"Urbanisme/".$fileArretePcmMultipleEntity->getId().$nomenclature);
  504.                             }
  505.                         }
  506.                         if(isset($item['fileRecepisseDepotPcmMultiple']) and $item['fileRecepisseDepotPcmMultiple'] != ''){
  507.                             $array = explode(',',$item['fileRecepisseDepotPcmMultiple']);
  508.                             foreach ($array as $item1){
  509.                                 $fileRecepisseDepotPcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  510.                                 $nomenclature = $this->getNomenclature($etap,$fileRecepisseDepotPcmMultipleEntity,'Récépissé dépôt PCM');
  511.                                 $etap1PcmEntity->addFileRecepisseDepotPcmMultiple($fileRecepisseDepotPcmMultipleEntity);
  512.                                 $this->uploadFileToDropbox($fileRecepisseDepotPcmMultipleEntity,$project,"Urbanisme/".$fileRecepisseDepotPcmMultipleEntity->getId().$nomenclature);
  513.                             }
  514.                         }
  515.                         if(isset($item['fileDemandeComplementPcmMultiple']) and $item['fileDemandeComplementPcmMultiple'] != ''){
  516.                             $array = explode(',',$item['fileDemandeComplementPcmMultiple']);
  517.                             foreach ($array as $item1){
  518.                                 $fileDemandeComplementPcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  519.                                 $nomenclature = $this->getNomenclature($etap,$fileDemandeComplementPcmMultipleEntity,'Demande compléments PCM');
  520.                                 $etap1PcmEntity->addFileDemandeComplementPcmMultiple($fileDemandeComplementPcmMultipleEntity);
  521.                                 $this->uploadFileToDropbox($fileDemandeComplementPcmMultipleEntity,$project,"Urbanisme/".$fileDemandeComplementPcmMultipleEntity->getId().$nomenclature);
  522.                             }
  523.                         }
  524.                         if(isset($item['fileRecepisseComplementPcmMultiple']) and $item['fileRecepisseComplementPcmMultiple'] != ''){
  525.                             $array = explode(',',$item['fileRecepisseComplementPcmMultiple']);
  526.                             foreach ($array as $item1){
  527.                                 $fileRecepisseComplementPcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  528.                                 $nomenclature = $this->getNomenclature($etap,$fileRecepisseComplementPcmMultipleEntity,'Récépissé compléments PCM');
  529.                                 $etap1PcmEntity->addFileRecepisseComplementPcmMultiple($fileRecepisseComplementPcmMultipleEntity);
  530.                                 $this->uploadFileToDropbox($fileRecepisseComplementPcmMultipleEntity,$project,"Urbanisme/".$fileRecepisseComplementPcmMultipleEntity->getId().$nomenclature);
  531.                             }
  532.                         }
  533.                         if(isset($item['fileAutreDocPcmMultiple']) and $item['fileAutreDocPcmMultiple'] != ''){
  534.                             $array = explode(',',$item['fileAutreDocPcmMultiple']);
  535.                             foreach ($array as $item1){
  536.                                 $fileAutreDocPcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  537.                                 $nomenclature = $this->getNomenclature($etap,$fileAutreDocPcmMultipleEntity,'Autre (prolongation délai d’instruction) PCM');
  538.                                 $etap1PcmEntity->addFileAutreDocPcmMultiple($fileAutreDocPcmMultipleEntity);
  539.                                 $this->uploadFileToDropbox($fileAutreDocPcmMultipleEntity,$project,"Urbanisme/".$fileAutreDocPcmMultipleEntity->getId().$nomenclature);
  540.                             }
  541.                         }
  542.                         if(isset($item['dateArretePcm']) and $item['dateArretePcm'] != ''){
  543.                             $etap1PcmEntity->setDateArretePcm(new \DateTime($item['dateArretePcm']));
  544.                         }else{
  545.                             $etap1PcmEntity->setDateArretePcm(null);
  546.                         }
  547.                         if(isset($item['referencePcm']) and $item['referencePcm'] != ''){
  548.                             $etap1PcmEntity->setReferencePcm($item['referencePcm']);
  549.                         }else{
  550.                             $etap1PcmEntity->setReferencePcm(null);
  551.                         }
  552.                         if(isset($item['dateDepotPcm']) and $item['dateDepotPcm'] != ''){
  553.                             $etap1PcmEntity->setDateDepotPCM(new \DateTime($item['dateDepotPcm']));
  554.                         }else{
  555.                             $etap1PcmEntity->setDateDepotPCM(null);
  556.                         }
  557.                         if(isset($item['dateDemandeComplement']) and $item['dateDemandeComplement'] != ''){
  558.                             $etap1PcmEntity->setDateDemandeComplement(new \DateTime($item['dateDemandeComplement']));
  559.                         }else{
  560.                             $etap1PcmEntity->setDateDemandeComplement(null);
  561.                         }
  562.                         if(isset($item['isDelaiInstruction'])){
  563.                             $etap1PcmEntity->setIsDelaiInstruction($item['isDelaiInstruction']);
  564.                         }
  565.                         if(isset($item['delaiInstruction'])){
  566.                             $etap1PcmEntity->setDelaiInstruction((int)$item['delaiInstruction']);
  567.                         }
  568.                         if(isset($item['isDateArretePcmProrogation'])){
  569.                             $etap1PcmEntity->setIsDateArretePCMProrogation($item['isDateArretePcmProrogation']);
  570.                         }
  571.                         if(isset($item['isNotDateDemandeComplementPcm'])){
  572.                             $etap1PcmEntity->setIsNotDateDemandeComplementPcm($item['isNotDateDemandeComplementPcm']);
  573.                         }
  574.                         if(isset($item['dateDepotComplement']) and $item['dateDepotComplement'] != ''){
  575.                             $etap1PcmEntity->setDateDepotComplement(new \DateTime($item['dateDepotComplement']));
  576.                         }else{
  577.                             $etap1PcmEntity->setDateDepotComplement(null);
  578.                         }
  579.                         if(isset($item['champLibrePcm'])){
  580.                             $etap1PcmEntity->setChampLibrePcm($item['champLibrePcm']);
  581.                         }
  582.                         $etap1PcmEntity->setEtap1($etap);
  583.                         $this->em->persist($etap1PcmEntity);
  584.                         $this->em->flush();
  585.                     }
  586.                 }
  587.                 if($project->getTypologieProject() && $project->getTypologieProject()->getId() == 1){
  588.                     $str = 'DP';
  589.                 }else{
  590.                     $str = 'PC';
  591.                 }
  592.                 if($fileDossierPcDpMultiple){
  593.                     $array = explode(',',$fileDossierPcDpMultiple);
  594.                     foreach ($array as $item){
  595.                         $fileDossierPcDpMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  596.                         if($fileDossierPcDpMultipleEntity){
  597.                             $nomenclature = $this->getNomenclature($etap,$fileDossierPcDpMultipleEntity,'Dossier '.$str);
  598.                             $etap->addFileDossierPcDpMultiple($fileDossierPcDpMultipleEntity);
  599.                             $this->uploadFileToDropbox($fileDossierPcDpMultipleEntity,$project,"Urbanisme/".$fileDossierPcDpMultipleEntity->getId().$nomenclature);
  600.                         }
  601.                     }
  602.                 }
  603.                 if($fileArretePcDpMultiple){
  604.                     $array = explode(',',$fileArretePcDpMultiple);
  605.                     foreach ($array as $item){
  606.                         $fileArretePcDpMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  607.                         if($fileArretePcDpMultipleEntity){
  608.                             $nomenclature = $this->getNomenclature($etap,$fileArretePcDpMultipleEntity,'Arrêté '.$str);
  609.                             $etap->addFileArretePcDpMultiple($fileArretePcDpMultipleEntity);
  610.                             $this->uploadFileToDropbox($fileArretePcDpMultipleEntity,$project,"Urbanisme/".$fileArretePcDpMultipleEntity->getId().$nomenclature);
  611.                         }
  612.                     }
  613.                 }
  614.                 if($fileCertificatNonOppositionEtap1Multiple){
  615.                     $array = explode(',',$fileCertificatNonOppositionEtap1Multiple);
  616.                     foreach ($array as $item){
  617.                         $fileCertificatNonOppositionEtap1MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  618.                         if($fileCertificatNonOppositionEtap1MultipleEntity){
  619.                             $nomenclature = $this->getNomenclature($etap,$fileCertificatNonOppositionEtap1MultipleEntity,'certificat de non-opposition');
  620.                             $etap->addFileCertificatNonOppositionEtap1Multiple($fileCertificatNonOppositionEtap1MultipleEntity);
  621.                             $this->uploadFileToDropbox($fileCertificatNonOppositionEtap1MultipleEntity,$project,"Urbanisme/".$fileCertificatNonOppositionEtap1MultipleEntity->getId().$nomenclature);
  622.                         }
  623.                     }
  624.                 }
  625.                 if($fileRecepisseDepotPcMultiple){
  626.                     $array = explode(',',$fileRecepisseDepotPcMultiple);
  627.                     foreach ($array as $item){
  628.                         $fileRecepisseDepotPcMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  629.                         if($fileRecepisseDepotPcMultipleEntity){
  630.                             $nomenclature = $this->getNomenclature($etap,$fileRecepisseDepotPcMultipleEntity,'Récépissé dépôt '.$str);
  631.                             $etap->addFileRecepisseDepotPcMultiple($fileRecepisseDepotPcMultipleEntity);
  632.                             $this->uploadFileToDropbox($fileRecepisseDepotPcMultipleEntity,$project,"Urbanisme/".$fileRecepisseDepotPcMultipleEntity->getId().$nomenclature);
  633.                         }
  634.                     }
  635.                 }
  636.                 if($fileDemandeComplementPcMultiple){
  637.                     $array = explode(',',$fileDemandeComplementPcMultiple);
  638.                     foreach ($array as $item){
  639.                         $fileDemandeComplementPcMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  640.                         if($fileDemandeComplementPcMultipleEntity){
  641.                             $nomenclature = $this->getNomenclature($etap,$fileDemandeComplementPcMultipleEntity,'Demande compléments '.$str);
  642.                             $etap->addFileDemandeComplementPcMultiple($fileDemandeComplementPcMultipleEntity);
  643.                             $this->uploadFileToDropbox($fileDemandeComplementPcMultipleEntity,$project,"Urbanisme/".$fileDemandeComplementPcMultipleEntity->getId().$nomenclature);
  644.                         }
  645.                     }
  646.                 }
  647.                 if($fileRecepisseComplementPcMultiple){
  648.                     $array = explode(',',$fileRecepisseComplementPcMultiple);
  649.                     foreach ($array as $item){
  650.                         $fileRecepisseComplementPcMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  651.                         if($fileRecepisseComplementPcMultipleEntity){
  652.                             $nomenclature = $this->getNomenclature($etap,$fileRecepisseComplementPcMultipleEntity,'Récépissé compléments '.$str);
  653.                             $etap->addFileRecepisseComplementPcMultiple($fileRecepisseComplementPcMultipleEntity);
  654.                             $this->uploadFileToDropbox($fileRecepisseComplementPcMultipleEntity,$project,"Urbanisme/".$fileRecepisseComplementPcMultipleEntity->getId().$nomenclature);
  655.                         }
  656.                     }
  657.                 }
  658.                 if($fileAutreDocPcMultiple){
  659.                     $array = explode(',',$fileAutreDocPcMultiple);
  660.                     foreach ($array as $item){
  661.                         $fileAutreDocPcMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  662.                         if($fileAutreDocPcMultipleEntity){
  663.                             $nomenclature = $this->getNomenclature($etap,$fileAutreDocPcMultipleEntity,'Autre (prolongation délai d’instruction) '.$str);
  664.                             $etap->addFileAutreDocPcMultiple($fileAutreDocPcMultipleEntity);
  665.                             $this->uploadFileToDropbox($fileAutreDocPcMultipleEntity,$project,"Urbanisme/".$fileAutreDocPcMultipleEntity->getId().$nomenclature);
  666.                         }
  667.                     }
  668.                 }
  669.                 if($dateArretePcEtap){
  670.                     $etap->setDateArretePcDp(new \DateTime($dateArretePcEtap));
  671.                     $project->setDateArretePc(new \DateTime($dateArretePcEtap));
  672.                 }else{
  673.                     $etap->setDateArretePcDp(null);
  674.                     $project->setDateArretePc(null);
  675.                 }
  676.                 if($referenceDp){
  677.                     $etap->setReferenceDp($referenceDp);
  678.                 }
  679.                 if($referencePc){
  680.                     $etap->setReferencePc($referencePc);
  681.                 }
  682.                 if($dateDepotPc){
  683.                     $etap->setDateDepotPc(new \DateTime($dateDepotPc));
  684.                 }else{
  685.                     $etap->setDateDepotPc(null);
  686.                 }
  687.                 if($dateDemandeComplement){
  688.                     $etap->setDateDemandeComplement(new \DateTime($dateDemandeComplement));
  689.                 }else{
  690.                     $etap->setDateDemandeComplement(null);
  691.                 }
  692.                 $etap->setIsDelaiInstruction($isDelaiInstruction);
  693.                 $etap->setIsNotDateDemandeComplement($isNotDateDemandeComplement);
  694.                 $etap->setDelaiInstruction((int)$delaiInstruction);
  695.                 $etap->setIsDateArretePcProrogation($isDateArretePcProrogation);
  696.                 $etap->setChampLibre($champLibre);
  697.                 if($dateDepotComplement){
  698.                     $etap->setDateDepotComplement(new \DateTime($dateDepotComplement));
  699.                 }else{
  700.                     $etap->setDateDepotComplement(null);
  701.                 }
  702.                 // dp mixte
  703.                 if($fileDossierPcDpMixteMultiple){
  704.                     $array = explode(',',$fileDossierPcDpMixteMultiple);
  705.                     foreach ($array as $item){
  706.                         $fileDossierPcDpMixteMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  707.                         if($fileDossierPcDpMixteMultipleEntity){
  708.                             $nomenclature = $this->getNomenclature($etap,$fileDossierPcDpMixteMultipleEntity,'Dossier dp (mixte)');
  709.                             $etap->addFileDossierPcDpMixteMultiple($fileDossierPcDpMixteMultipleEntity);
  710.                             $this->uploadFileToDropbox($fileDossierPcDpMixteMultipleEntity,$project,"Urbanisme/".$fileDossierPcDpMixteMultipleEntity->getId().$nomenclature);
  711.                         }
  712.                     }
  713.                 }
  714.                 if($fileArretePcDpMixteMultiple){
  715.                     $array = explode(',',$fileArretePcDpMixteMultiple);
  716.                     foreach ($array as $item){
  717.                         $fileArretePcDpMixteMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  718.                         if($fileArretePcDpMixteMultipleEntity){
  719.                             $nomenclature = $this->getNomenclature($etap,$fileArretePcDpMixteMultipleEntity,'Arrêté dp (mixte)');
  720.                             $etap->addFileArretePcDpMixteMultiple($fileArretePcDpMixteMultipleEntity);
  721.                             $this->uploadFileToDropbox($fileArretePcDpMixteMultipleEntity,$project,"Urbanisme/".$fileArretePcDpMixteMultipleEntity->getId().$nomenclature);
  722.                         }
  723.                     }
  724.                 }
  725.                 if($fileRecepisseDepotPcDpMixteMultiple){
  726.                     $array = explode(',',$fileRecepisseDepotPcDpMixteMultiple);
  727.                     foreach ($array as $item){
  728.                         $fileRecepisseDepotPcDpMixteMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  729.                         if($fileRecepisseDepotPcDpMixteMultipleEntity){
  730.                             $nomenclature = $this->getNomenclature($etap,$fileRecepisseDepotPcDpMixteMultipleEntity,'Récépissé dépôt dp (mixte)');
  731.                             $etap->addFileRecepisseDepotPcDpMixteMultiple($fileRecepisseDepotPcDpMixteMultipleEntity);
  732.                             $this->uploadFileToDropbox($fileRecepisseDepotPcDpMixteMultipleEntity,$project,"Urbanisme/".$fileRecepisseDepotPcDpMixteMultipleEntity->getId().$nomenclature);
  733.                         }
  734.                     }
  735.                 }
  736.                 if($fileDemandeComplementPcDpMixteMultiple){
  737.                     $array = explode(',',$fileDemandeComplementPcDpMixteMultiple);
  738.                     foreach ($array as $item){
  739.                         $fileDemandeComplementPcDpMixteMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  740.                         if($fileDemandeComplementPcDpMixteMultipleEntity){
  741.                             $nomenclature = $this->getNomenclature($etap,$fileDemandeComplementPcDpMixteMultipleEntity,'Demande compléments dp (mixte)');
  742.                             $etap->addFileDemandeComplementPcDpMixteMultiple($fileDemandeComplementPcDpMixteMultipleEntity);
  743.                             $this->uploadFileToDropbox($fileDemandeComplementPcDpMixteMultipleEntity,$project,"Urbanisme/".$fileDemandeComplementPcDpMixteMultipleEntity->getId().$nomenclature);
  744.                         }
  745.                     }
  746.                 }
  747.                 if($fileRecepisseComplementPcDpMixteMultiple){
  748.                     $array = explode(',',$fileRecepisseComplementPcDpMixteMultiple);
  749.                     foreach ($array as $item){
  750.                         $fileRecepisseComplementPcDpMixteMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  751.                         if($fileRecepisseComplementPcDpMixteMultipleEntity){
  752.                             $nomenclature = $this->getNomenclature($etap,$fileRecepisseComplementPcDpMixteMultipleEntity,'Récépissé compléments dp (mixte)');
  753.                             $etap->addFileRecepisseComplementPcDpMixteMultiple($fileRecepisseComplementPcDpMixteMultipleEntity);
  754.                             $this->uploadFileToDropbox($fileRecepisseComplementPcDpMixteMultipleEntity,$project,"Urbanisme/".$fileRecepisseComplementPcDpMixteMultipleEntity->getId().$nomenclature);
  755.                         }
  756.                     }
  757.                 }
  758.                 if($fileAutreDocPcDpMixteMultiple){
  759.                     $array = explode(',',$fileAutreDocPcDpMixteMultiple);
  760.                     foreach ($array as $item){
  761.                         $fileAutreDocPcDpMixteMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  762.                         if($fileAutreDocPcDpMixteMultipleEntity){
  763.                             $nomenclature = $this->getNomenclature($etap,$fileAutreDocPcDpMixteMultipleEntity,'Autre (prolongation délai d’instruction) dp (mixte)');
  764.                             $etap->addFileAutreDocPcDpMixteMultiple($fileAutreDocPcDpMixteMultipleEntity);
  765.                             $this->uploadFileToDropbox($fileAutreDocPcDpMixteMultipleEntity,$project,"Urbanisme/".$fileAutreDocPcDpMixteMultipleEntity->getId().$nomenclature);
  766.                         }
  767.                     }
  768.                 }
  769.                 if($dateArretePcDpMixte){
  770.                     $etap->setDateArretePcDpMixte(new \DateTime($dateArretePcDpMixte));
  771.                 }else{
  772.                     $etap->setDateArretePcDpMixte(null);
  773.                 }
  774.                 if($referencePcDpMixte){
  775.                     $etap->setReferencePcDpMixte($referencePcDpMixte);
  776.                 }
  777.                 if($dateDepotPcDpMixte){
  778.                     $etap->setDateDepotPcDpMixte(new \DateTime($dateDepotPcDpMixte));
  779.                 }else{
  780.                     $etap->setDateDepotPcDpMixte(null);
  781.                 }
  782.                 if($dateDemandeComplementPcDpMixte){
  783.                     $etap->setDateDemandeComplementPcDpMixte(new \DateTime($dateDemandeComplementPcDpMixte));
  784.                 }else{
  785.                     $etap->setDateDemandeComplementPcDpMixte(null);
  786.                 }
  787.                 $etap->setIsDelaiInstructionPcDpMixte($isDelaiInstructionPcDpMixte);
  788.                 $etap->setDelaiInstructionPcDpMixte($delaiInstructionPcDpMixte);
  789.                 $etap->setIsDateArretePcProrogationPcDpMixte($isDateArretePcProrogationPcDpMixte);
  790.                 $etap->setChampLibrePcDpMixte($champLibrePcDpMixte);
  791.                 if($dateDepotComplementPcDpMixte){
  792.                     $etap->setDateDepotComplementPcDpMixte(new \DateTime($dateDepotComplementPcDpMixte));
  793.                 }else{
  794.                     $etap->setDateDepotComplementPcDpMixte(null);
  795.                 }
  796.                 //dp mixte
  797.                 $this->em->persist($etap);
  798.                 $this->em->persist($project);
  799.                 $this->em->flush();
  800.                 $this->updateStatusTracker($project); // set status tracker
  801.                 $this->notification->addAlertPc($project);
  802.                 $this->addAlertEtap1AndEtap2($project);
  803.                 $this->flashBag->add(
  804.                     'success',
  805.                     'L\'opération a Ã©té effectuée avec succès.'
  806.                 );
  807.                 return [
  808.                     'etap' => $etap,
  809.                     'success' => true
  810.                 ];
  811.             }
  812.         }
  813.         return [
  814.             'success' => false
  815.         ];
  816.     }
  817.     public function submitEtap2($request,$user)
  818.     {
  819.         $filePVPassageHuissierMultiple = $request->get('filePVPassageHuissierMultiple');
  820.         $fileCertificatNonRecoursMultiple = $request->get('fileCertificatNonRecoursMultiple');
  821.         $fileCertificatNonRetraitMultiple = $request->get('fileCertificatNonRetraitMultiple');
  822.         $fileCertificatNonOppositionMultiple = $request->get('fileCertificatNonOppositionMultiple');
  823.         $fileDemandeAnrMarieMultiple = $request->get('fileDemandeAnrMarieMultiple');
  824.         $fileDemandeAnrTaMultiple = $request->get('fileDemandeAnrTaMultiple');
  825.         $fileAttestationHonneurAnrMairieTaMultiple = $request->get('fileAttestationHonneurAnrMairieTaMultiple');
  826.         $date1PassageHuissier = $request->get('date1PassageHuissier');
  827.         $date2PassageHuissier = $request->get('date2PassageHuissier');
  828.         $date3PassageHuissier = $request->get('date3PassageHuissier');
  829.         $datePcDpPurge = $request->get('datePcDpPurge');
  830.         $fournisseurId = $request->get('fournisseur');
  831.         $etapToken = $request->get('etapToken');
  832.         $tokenProject = $request->get('tokenProject');
  833.         $etap2Pcm = $request->get('etap2Pcm');
  834.         if($etapToken and $tokenProject){
  835.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  836.             $etap = $this->em->getRepository(Etap2::class)->findOneBy(['token'=>$etapToken]);
  837.             if($project && $etap){
  838.                 if(!$this->checkUserAction($user,$project,$etap)){
  839.                     return [
  840.                         'success' => false
  841.                     ];
  842.                 }
  843.                 if($etap2Pcm) {
  844.                     foreach ($etap2Pcm as $item) {
  845.                         if (isset($item['id']) and $item['id'] != '') {
  846.                             $etap2PcmEntity = $this->em->getRepository(Etap2Pcm::class)->findOneBy(['token' => $item['id']]);
  847.                         } else {
  848.                             $etap2PcmEntity = new Etap2Pcm();
  849.                         }
  850.                         if (isset($item['filePVPassageHuissierPcmMultiple']) and $item['filePVPassageHuissierPcmMultiple'] != '') {
  851.                             $array = explode(',', $item['filePVPassageHuissierPcmMultiple']);
  852.                             foreach ($array as $item1) {
  853.                                 $filePVPassageHuissierPcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token' => $item1]);
  854.                                 $nomenclature = $this->getNomenclature($etap, $filePVPassageHuissierPcmMultipleEntity, 'PV passage huissier PCM');
  855.                                 $etap2PcmEntity->addFilePVPassageHuissierPcmMultiple($filePVPassageHuissierPcmMultipleEntity);
  856.                             }
  857.                         }
  858.                         if (isset($item['fileCertificatNonRecoursPcmMultiple']) and $item['fileCertificatNonRecoursPcmMultiple'] != '') {
  859.                             $array = explode(',', $item['fileCertificatNonRecoursPcmMultiple']);
  860.                             foreach ($array as $item1) {
  861.                                 $fileCertificatNonRecoursPcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token' => $item1]);
  862.                                 $nomenclature = $this->getNomenclature($etap, $fileCertificatNonRecoursPcmMultipleEntity, 'Certificat de non-recours (Tribunal Administratif) PCM');
  863.                                 $etap2PcmEntity->addFileCertificatNonRecoursPcmMultiple($fileCertificatNonRecoursPcmMultipleEntity);
  864.                             }
  865.                         }
  866.                         if (isset($item['fileCertificatNonRetraitPcmMultiple']) and $item['fileCertificatNonRetraitPcmMultiple'] != '') {
  867.                             $array = explode(',', $item['fileCertificatNonRetraitPcmMultiple']);
  868.                             foreach ($array as $item1) {
  869.                                 $fileCertificatNonRetraitPcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token' => $item1]);
  870.                                 $nomenclature = $this->getNomenclature($etap, $fileCertificatNonRetraitPcmMultipleEntity, 'Certificat de non-retrait (Mairie) PCM');
  871.                                 $etap2PcmEntity->addFileCertificatNonRetraitPcmMultiple($fileCertificatNonRetraitPcmMultipleEntity);
  872.                             }
  873.                         }
  874.                         if (isset($item['fileDemandeAnrMariePcmMultiple']) and $item['fileDemandeAnrMariePcmMultiple'] != '') {
  875.                             $array = explode(',', $item['fileDemandeAnrMariePcmMultiple']);
  876.                             foreach ($array as $item1) {
  877.                                 $fileDemandeAnrMariePcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token' => $item1]);
  878.                                 $nomenclature = $this->getNomenclature($etap, $fileDemandeAnrMariePcmMultipleEntity, 'Demande d’ANR Mairie PCM');
  879.                                 $etap2PcmEntity->addFileDemandeAnrMariePcmMultiple($fileDemandeAnrMariePcmMultipleEntity);
  880.                             }
  881.                         }
  882.                         if (isset($item['fileDemandeAnrTaPcmMultiple']) and $item['fileDemandeAnrTaPcmMultiple'] != '') {
  883.                             $array = explode(',', $item['fileDemandeAnrTaPcmMultiple']);
  884.                             foreach ($array as $item1) {
  885.                                 $fileDemandeAnrTaPcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token' => $item1]);
  886.                                 $nomenclature = $this->getNomenclature($etap, $fileDemandeAnrTaPcmMultipleEntity, 'Demande d’ANR TA PCM');
  887.                                 $etap2PcmEntity->addFileDemandeAnrTaPcmMultiple($fileDemandeAnrTaPcmMultipleEntity);
  888.                             }
  889.                         }
  890.                         if (isset($item['fileAttestationHonneurAnrMairieTaPcmMultiple']) and $item['fileAttestationHonneurAnrMairieTaPcmMultiple'] != '') {
  891.                             $array = explode(',', $item['fileAttestationHonneurAnrMairieTaPcmMultiple']);
  892.                             foreach ($array as $item1) {
  893.                                 $fileAttestationHonneurAnrMairieTaPcmMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token' => $item1]);
  894.                                 $nomenclature = $this->getNomenclature($etap, $fileAttestationHonneurAnrMairieTaPcmMultipleEntity, 'Attestation sur l’honneur ANR Mairie / TA PCM');
  895.                                 $etap2PcmEntity->addFileAttestationHonneurAnrMairieTaPcmMultiple($fileAttestationHonneurAnrMairieTaPcmMultipleEntity);
  896.                             }
  897.                         }
  898.                         if(isset($item['date1PassageHuissierPcm']) and $item['date1PassageHuissierPcm'] != ''){
  899.                             $etap2PcmEntity->setDate1PassageHuissierPcm(new \DateTime($item['date1PassageHuissierPcm']));
  900.                         }else{
  901.                             $etap2PcmEntity->setDate1PassageHuissierPcm(null);
  902.                         }
  903.                         if(isset($item['date2PassageHuissierPcm']) and $item['date2PassageHuissierPcm'] != ''){
  904.                             $etap2PcmEntity->setDate2PassageHuissierPcm(new \DateTime($item['date2PassageHuissierPcm']));
  905.                         }else{
  906.                             $etap2PcmEntity->setDate2PassageHuissierPcm(null);
  907.                         }
  908.                         if(isset($item['date3PassageHuissierPcm']) and $item['date3PassageHuissierPcm'] != ''){
  909.                             $etap2PcmEntity->setDate3PassageHuissierPcm(new \DateTime($item['date3PassageHuissierPcm']));
  910.                         }else{
  911.                             $etap2PcmEntity->setDate3PassageHuissierPcm(null);
  912.                         }
  913.                         if(isset($item['date3PassageHuissierPcm']) and $item['date3PassageHuissierPcm'] != ''){
  914.                             $etap2PcmEntity->setDate3PassageHuissierPcm(new \DateTime($item['date3PassageHuissierPcm']));
  915.                         }else{
  916.                             $etap2PcmEntity->setDate3PassageHuissierPcm(null);
  917.                         }
  918.                         if(isset($item['fournisseuritem']) and $item['fournisseuritem'] != 0){
  919.                             $fournisseur = $this->em->getRepository(Fournisseur::class)->find($item['fournisseuritem']);
  920.                             if($fournisseur){
  921.                                 $etap2PcmEntity->setFournisseurPcm($fournisseur);
  922.                             }else{
  923.                                 $etap2PcmEntity->setFournisseurPcm(null);
  924.                             }
  925.                         }else {
  926.                             $etap2PcmEntity->setFournisseurPcm(null);
  927.                         }
  928.                         $etap2PcmEntity->setEtap2($etap);
  929.                         $this->em->persist($etap2PcmEntity);
  930.                         $this->em->flush();
  931.                     }
  932.                 }
  933.                 if($filePVPassageHuissierMultiple){
  934.                     $array = explode(',',$filePVPassageHuissierMultiple);
  935.                     foreach ($array as $item){
  936.                         $filePVPassageHuissierMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  937.                         $nomenclature = $this->getNomenclature($etap,$filePVPassageHuissierMultipleEntity,'PV passage huissier');
  938.                         $etap->addFilePVPassageHuissierMultiple($filePVPassageHuissierMultipleEntity);
  939.                         $this->uploadFileToDropbox($filePVPassageHuissierMultipleEntity,$project,"Urbanisme/".$filePVPassageHuissierMultipleEntity->getId().$nomenclature);
  940.                     }
  941.                 }
  942.                 if($fileCertificatNonRecoursMultiple){
  943.                     $array = explode(',',$fileCertificatNonRecoursMultiple);
  944.                     foreach ($array as $item){
  945.                         $fileCertificatNonRecoursMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  946.                         $nomenclature = $this->getNomenclature($etap,$fileCertificatNonRecoursMultipleEntity,'Certificat de non-recours');
  947.                         $etap->addFileCertificatNonRecoursMultiple($fileCertificatNonRecoursMultipleEntity);
  948.                         $this->uploadFileToDropbox($fileCertificatNonRecoursMultipleEntity,$project,"Urbanisme/".$fileCertificatNonRecoursMultipleEntity->getId().$nomenclature);
  949.                     }
  950.                 }
  951.                 if($fileCertificatNonRetraitMultiple){
  952.                     $array = explode(',',$fileCertificatNonRetraitMultiple);
  953.                     foreach ($array as $item){
  954.                         $fileCertificatNonRetraitMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  955.                         $nomenclature = $this->getNomenclature($etap,$fileCertificatNonRetraitMultipleEntity,'Certificat de non-retrait');
  956.                         $etap->addFileCertificatNonRetraitMultiple($fileCertificatNonRetraitMultipleEntity);
  957.                         $this->uploadFileToDropbox($fileCertificatNonRetraitMultipleEntity,$project,"Urbanisme/".$fileCertificatNonRetraitMultipleEntity->getId().$nomenclature);
  958.                     }
  959.                 }
  960.                 if($fileCertificatNonOppositionMultiple){
  961.                     $array = explode(',',$fileCertificatNonOppositionMultiple);
  962.                     foreach ($array as $item){
  963.                         $fileCertificatNonOppositionMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  964.                         $nomenclature = $this->getNomenclature($etap,$fileCertificatNonOppositionMultipleEntity,'Certificat de non-opposition');
  965.                         $etap->addFileCertificatNonOppositionMultiple($fileCertificatNonOppositionMultipleEntity);
  966.                         $this->uploadFileToDropbox($fileCertificatNonOppositionMultipleEntity,$project,"Urbanisme/".$fileCertificatNonOppositionMultipleEntity->getId().$nomenclature);
  967.                     }
  968.                 }
  969.                 if($fileDemandeAnrMarieMultiple){
  970.                     $array = explode(',',$fileDemandeAnrMarieMultiple);
  971.                     foreach ($array as $item){
  972.                         $fileDemandeAnrMarieMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  973.                         $nomenclature = $this->getNomenclature($etap,$fileDemandeAnrMarieMultipleEntity,'Demande d’ANR Mairie');
  974.                         $etap->addFileDemandeAnrMarieMultiple($fileDemandeAnrMarieMultipleEntity);
  975.                         $this->uploadFileToDropbox($fileDemandeAnrMarieMultipleEntity,$project,"Urbanisme/".$fileDemandeAnrMarieMultipleEntity->getId().$nomenclature);
  976.                     }
  977.                 }
  978.                 if($fileDemandeAnrTaMultiple){
  979.                     $array = explode(',',$fileDemandeAnrTaMultiple);
  980.                     foreach ($array as $item){
  981.                         $fileDemandeAnrTaMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  982.                         $nomenclature = $this->getNomenclature($etap,$fileDemandeAnrTaMultipleEntity,'Demande d’ANR TA');
  983.                         $etap->addFileDemandeAnrTaMultiple($fileDemandeAnrTaMultipleEntity);
  984.                         $this->uploadFileToDropbox($fileDemandeAnrTaMultipleEntity,$project,"Urbanisme/".$fileDemandeAnrTaMultipleEntity->getId().$nomenclature);
  985.                     }
  986.                 }
  987.                 if($fileAttestationHonneurAnrMairieTaMultiple){
  988.                     $array = explode(',',$fileAttestationHonneurAnrMairieTaMultiple);
  989.                     foreach ($array as $item){
  990.                         $fileAttestationHonneurAnrMairieTaMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  991.                         $nomenclature = $this->getNomenclature($etap,$fileAttestationHonneurAnrMairieTaMultipleEntity,'Attestation sur l’honneur ANR Mairie / TA');
  992.                         $etap->addFileAttestationHonneurAnrMairieTaMultiple($fileAttestationHonneurAnrMairieTaMultipleEntity);
  993.                         $this->uploadFileToDropbox($fileAttestationHonneurAnrMairieTaMultipleEntity,$project,"Urbanisme/".$fileAttestationHonneurAnrMairieTaMultipleEntity->getId().$nomenclature);
  994.                     }
  995.                 }
  996.                 if($date1PassageHuissier){
  997.                     $etap->setDate1PassageHuissier(new \DateTime($date1PassageHuissier));
  998.                 }else{
  999.                     $etap->setDate1PassageHuissier(null);
  1000.                 }
  1001.                 if($date2PassageHuissier){
  1002.                     $etap->setDate2PassageHuissier(new \DateTime($date2PassageHuissier));
  1003.                 }else{
  1004.                     $etap->setDate2PassageHuissier(null);
  1005.                 }
  1006.                 if($date3PassageHuissier){
  1007.                     $etap->setDate3PassageHuissier(new \DateTime($date3PassageHuissier));
  1008.                 }else{
  1009.                     $etap->setDate3PassageHuissier(null);
  1010.                 }
  1011.                 if($datePcDpPurge){
  1012.                     $etap->setDatePcDpPurge(new \DateTime($datePcDpPurge));
  1013.                 }else{
  1014.                     $etap->setDatePcDpPurge(null);
  1015.                 }
  1016.                 if($fournisseurId and $fournisseurId != 0){
  1017.                     $fournisseur = $this->em->getRepository(Fournisseur::class)->find($fournisseurId);
  1018.                     if($fournisseur){
  1019.                         $etap->setFournisseur($fournisseur);
  1020.                     }else{
  1021.                         $etap->setFournisseur(null);
  1022.                     }
  1023.                 }else {
  1024.                     $etap->setFournisseur(null);
  1025.                 }
  1026.                 $this->em->persist($etap);
  1027.                 $this->em->flush();
  1028.                 $this->updateStatusTracker($project); // set status tracker
  1029.                 $this->addAlertEtap1AndEtap2($project);
  1030.                 $this->flashBag->add(
  1031.                     'success',
  1032.                     'L\'opération a Ã©té effectuée avec succès.'
  1033.                 );
  1034.                 return [
  1035.                     'etap' => $etap,
  1036.                     'success' => true
  1037.                 ];
  1038.             }
  1039.         }
  1040.         return [
  1041.             'success' => false
  1042.         ];
  1043.     }
  1044.     public function submitEtap3($request,$user)
  1045.     {
  1046.         $fileDocDrocMultiple = $request->get('fileDocDrocMultiple');
  1047.         $dateDocDrocEtap = $request->get('dateDocDrocEtap');
  1048.         $etapToken = $request->get('etapToken');
  1049.         $tokenProject = $request->get('tokenProject');
  1050.         if($etapToken and $tokenProject){
  1051.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1052.             $etap = $this->em->getRepository(Etap3::class)->findOneBy(['token'=>$etapToken]);
  1053.             if($project && $etap){
  1054.                 if(!$this->checkUserAction($user,$project,$etap)){
  1055.                     return [
  1056.                         'success' => false
  1057.                     ];
  1058.                 }
  1059.                 if($fileDocDrocMultiple){
  1060.                     $array = explode(',',$fileDocDrocMultiple);
  1061.                     foreach ($array as $item){
  1062.                         $fileDocDrocMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1063.                         $nomenclature = $this->getNomenclature($etap,$fileDocDrocMultipleEntity,'DOC / DROC');
  1064.                         $etap->addFileDocDrocMultiple($fileDocDrocMultipleEntity);
  1065.                         $this->uploadFileToDropbox($fileDocDrocMultipleEntity,$project,"Urbanisme/".$fileDocDrocMultipleEntity->getId().$nomenclature);
  1066.                     }
  1067.                 }
  1068.                 if($dateDocDrocEtap){
  1069.                     $etap->setDateDocDroc(new \DateTime($dateDocDrocEtap));
  1070.                 }else{
  1071.                     $etap->setDateDocDroc(null);
  1072.                 }
  1073.                 $this->em->persist($etap);
  1074.                 $this->em->flush();
  1075.                 $this->updateStatusTracker($project); // set status tracker
  1076.                 $this->flashBag->add(
  1077.                     'success',
  1078.                     'L\'opération a Ã©té effectuée avec succès.'
  1079.                 );
  1080.                 return [
  1081.                     'etap' => $etap,
  1082.                     'success' => true
  1083.                 ];
  1084.             }
  1085.         }
  1086.         return [
  1087.             'success' => false
  1088.         ];
  1089.     }
  1090.     public function submitEtap4($request,$user)
  1091.     {
  1092.         $fileDaactMultiple = $request->get('fileDaactMultiple');
  1093.         $dateDaactEtap = $request->get('dateDaactEtap');
  1094.         $dateSignatureDaact = $request->get('dateSignatureDaact');
  1095.         $etapToken = $request->get('etapToken');
  1096.         $tokenProject = $request->get('tokenProject');
  1097.         if($etapToken and $tokenProject){
  1098.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1099.             $etap = $this->em->getRepository(Etap4::class)->findOneBy(['token'=>$etapToken]);
  1100.             if($project && $etap){
  1101.                 if(!$this->checkUserAction($user,$project,$etap)){
  1102.                     return [
  1103.                         'success' => false
  1104.                     ];
  1105.                 }
  1106.                 if($fileDaactMultiple){
  1107.                     $array = explode(',',$fileDaactMultiple);
  1108.                     foreach ($array as $item){
  1109.                         $fileDaactMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1110.                         $nomenclature = $this->getNomenclature($etap,$fileDaactMultipleEntity,'DAACT');
  1111.                         $etap->addFileDaactMultiple($fileDaactMultipleEntity);
  1112.                         $this->uploadFileToDropbox($fileDaactMultipleEntity,$project,"Urbanisme/".$fileDaactMultipleEntity->getId().$nomenclature);
  1113.                     }
  1114.                 }
  1115.                 if($dateDaactEtap){
  1116.                     $etap->setDateDaact(new \DateTime($dateDaactEtap));
  1117.                 }else{
  1118.                     $etap->setDateDaact(null);
  1119.                 }
  1120.                 if($dateSignatureDaact){
  1121.                     $etap->setDateSignatureDaact(new \DateTime($dateSignatureDaact));
  1122.                 }else{
  1123.                     $etap->setDateSignatureDaact(null);
  1124.                 }
  1125.                 $this->em->persist($etap);
  1126.                 $this->em->flush();
  1127.                 $this->updateStatusTracker($project); // set status tracker
  1128.                 $this->flashBag->add(
  1129.                     'success',
  1130.                     'L\'opération a Ã©té effectuée avec succès.'
  1131.                 );
  1132.                 return [
  1133.                     'etap' => $etap,
  1134.                     'success' => true
  1135.                 ];
  1136.             }
  1137.         }
  1138.         return [
  1139.             'success' => false
  1140.         ];
  1141.     }
  1142.     public function submitEtap5($request,$user)
  1143.     {
  1144.         $filePromessebailMultiple = $request->get('filePromessebailMultiple');
  1145.         $fileLeveeOptionMultiple = $request->get('fileLeveeOptionMultiple');
  1146.         $fileActeSubstitutionMultiple = $request->get('fileActeSubstitutionMultiple');
  1147.         $dateExpirationPromesseBailEtap = $request->get('dateExpirationPromesseBailEtap');
  1148.         $LeveeOption = $request->get('leveeOption');
  1149.         $d1Etap = $request->get('d1Etap');
  1150.         $d2Etap = $request->get('d2Etap');
  1151.         $loyerConfirme = $request->get('loyerConfirme');
  1152.         $loyerEnNature = $request->get('loyerEnNature');
  1153.         $soulteConfirme = $request->get('soulteConfirme');
  1154.         $typeBail = $request->get('typeBail');
  1155.         $dureeBail = $request->get('dureeBail');
  1156.         $terrassement = $request->get('terrassement');
  1157.         $tranchee = $request->get('tranchee');
  1158.         $bardage = $request->get('bardage');
  1159.         $renovationCharpente = $request->get('renovationCharpente');
  1160.         $desamiantage = $request->get('desamiantage');
  1161.         $fileLoiMultiple = $request->get('fileLoiMultiple');
  1162.         $filePromesseAchatMultiple = $request->get('filePromesseAchatMultiple');
  1163.         $dateSignature = $request->get('dateSignature');
  1164.         $dateFinExclusiviteLoi = $request->get('dateFinExclusiviteLoi');
  1165.         $dateEcheancePromesse = $request->get('dateEcheancePromesse');
  1166.         $honoraireApporteur = $request->get('honoraireApporteur');
  1167.         $indemniteTransitoire = $request->get('indemniteTransitoire');
  1168.         $puissanceSignee = $request->get('puissanceSignee');
  1169.         $prixAchatFoncier = $request->get('prixAchatFoncier');
  1170.         $unitePrixAchat = $request->get('unitePrixAchat');
  1171.         $etapToken = $request->get('etapToken');
  1172.         $tokenProject = $request->get('tokenProject');
  1173.         if($etapToken and $tokenProject){
  1174.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1175.             $etap = $this->em->getRepository(Etap5::class)->findOneBy(['token'=>$etapToken]);
  1176.             if($project && $etap){
  1177.                 if(!$this->checkUserAction($user,$project,$etap)){
  1178.                     return [
  1179.                         'success' => false
  1180.                     ];
  1181.                 }
  1182.                 if($filePromessebailMultiple){
  1183.                     $array = explode(',',$filePromessebailMultiple);
  1184.                     foreach ($array as $item){
  1185.                         $filePromessebailMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1186.                         $nomenclature = $this->getNomenclature($etap,$filePromessebailMultipleEntity,'Promesse de bail');
  1187.                         $etap->addFilePromessebailMultiple($filePromessebailMultipleEntity);
  1188.                         $this->uploadFileToDropbox($filePromessebailMultipleEntity,$project,"Maitrise foncière/".$filePromessebailMultipleEntity->getId().$nomenclature);
  1189.                     }
  1190.                 }
  1191.                 if($fileLeveeOptionMultiple){
  1192.                     $array = explode(',',$fileLeveeOptionMultiple);
  1193.                     foreach ($array as $item){
  1194.                         $fileLeveeOptionMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1195.                         $nomenclature = $this->getNomenclature($etap,$fileLeveeOptionMultipleEntity,'Levée d’option');
  1196.                         $etap->addFileLeveeOptionMultiple($fileLeveeOptionMultipleEntity);
  1197.                         $this->uploadFileToDropbox($fileLeveeOptionMultipleEntity,$project,"Maitrise foncière/".$fileLeveeOptionMultipleEntity->getId().$nomenclature);
  1198.                     }
  1199.                 }
  1200.                 if($fileActeSubstitutionMultiple){
  1201.                     $array = explode(',',$fileActeSubstitutionMultiple);
  1202.                     foreach ($array as $item){
  1203.                         $fileActeSubstitutionMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1204.                         $nomenclature = $this->getNomenclature($etap,$fileActeSubstitutionMultipleEntity,'Acte de substitution');
  1205.                         $etap->addFileActeSubstitutionMultiple($fileActeSubstitutionMultipleEntity);
  1206.                         $this->uploadFileToDropbox($fileActeSubstitutionMultipleEntity,$project,"Maitrise foncière/".$fileActeSubstitutionMultipleEntity->getId().$nomenclature);
  1207.                     }
  1208.                 }
  1209.                 if($fileLoiMultiple){
  1210.                     $array = explode(',',$fileLoiMultiple);
  1211.                     foreach ($array as $item){
  1212.                         $fileLoiMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1213.                         $nomenclature = $this->getNomenclature($etap,$fileLoiMultipleEntity,'LOI');
  1214.                         $etap->addFileLoiMultiple($fileLoiMultipleEntity);
  1215.                         $this->uploadFileToDropbox($fileLoiMultipleEntity,$project,"Maitrise foncière/".$fileLoiMultipleEntity->getId().$nomenclature);
  1216.                     }
  1217.                 }
  1218.                 if($filePromesseAchatMultiple){
  1219.                     $array = explode(',',$filePromesseAchatMultiple);
  1220.                     foreach ($array as $item){
  1221.                         $filePromesseAchatMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1222.                         $nomenclature = $this->getNomenclature($etap,$filePromesseAchatMultipleEntity,'Promesse d\'achat');
  1223.                         $etap->addFilePromesseAchatMultiple($filePromesseAchatMultipleEntity);
  1224.                         $this->uploadFileToDropbox($filePromesseAchatMultipleEntity,$project,"Maitrise foncière/".$filePromesseAchatMultipleEntity->getId().$nomenclature);
  1225.                     }
  1226.                 }
  1227.                 if($dateSignature){
  1228.                     $etap->setDateSignature(new \DateTime($dateSignature));
  1229.                 }else{
  1230.                     $etap->setDateSignature(null);
  1231.                 }
  1232.                 if($dateFinExclusiviteLoi){
  1233.                     $etap->setDateFinExclusiviteLoi(new \DateTime($dateFinExclusiviteLoi));
  1234.                 }else{
  1235.                     $etap->setDateFinExclusiviteLoi(null);
  1236.                 }
  1237.                 if($dateEcheancePromesse){
  1238.                     $etap->setDateEcheancePromesse(new \DateTime($dateEcheancePromesse));
  1239.                 }else{
  1240.                     $etap->setDateEcheancePromesse(null);
  1241.                 }
  1242.                 if($dateExpirationPromesseBailEtap){
  1243.                     $etap->setDateExpirationPromesseBail(new \DateTime($dateExpirationPromesseBailEtap));
  1244.                 }else{
  1245.                     $etap->setDateExpirationPromesseBail(null);
  1246.                 }
  1247.                 if($LeveeOption){
  1248.                     $etap->setLeveeOption(new \DateTime($LeveeOption));
  1249.                 }else{
  1250.                     $etap->setLeveeOption(null);
  1251.                 }
  1252.                 $etap->setD1((int)$d1Etap);
  1253.                 $etap->setD2((int)$d2Etap);
  1254.                 $etap->setLoyerConfirme($loyerConfirme);
  1255.                 $project->setLoyerVise($loyerConfirme);
  1256.                 $etap->setLoyerEnNature($loyerEnNature);
  1257.                 $etap->setSoulteConfirme($soulteConfirme);
  1258.                 $project->setSoulteVise($soulteConfirme);
  1259.                 $etap->setTypeBail($typeBail);
  1260.                 $etap->setTerrassement($terrassement);
  1261.                 $etap->setTranchee($tranchee);
  1262.                 $etap->setBardage($bardage);
  1263.                 $etap->setRenovationCharpente($renovationCharpente);
  1264.                 $etap->setDesamiantage($desamiantage);
  1265.                 $etap->setDureeBail($dureeBail);
  1266.                 $etap->setHonoraireApporteur($honoraireApporteur);
  1267.                 $etap->setIndemniteTransitoire($indemniteTransitoire);
  1268.                 $etap->setPuissanceSignee($puissanceSignee);
  1269.                 $etap->setPrixAchatFoncier($prixAchatFoncier);
  1270.                 $etap->setUnitePrixAchat($unitePrixAchat);
  1271.                 $this->em->persist($etap);
  1272.                 $this->em->persist($project);
  1273.                 $this->em->flush();
  1274.                 $project->setDateExpirationPromesseBail($etap->getDateExpirationPromesseBail());
  1275.                 $project->setD1($etap->getD1());
  1276.                 $this->em->persist($project);
  1277.                 $this->em->flush();
  1278.                 $this->updateStatusTracker($project); // set status tracker
  1279.                 $this->flashBag->add(
  1280.                     'success',
  1281.                     'L\'opération a Ã©té effectuée avec succès.'
  1282.                 );
  1283.                 $this->notification->addAlertBail($project);
  1284.                 return [
  1285.                     'etap' => $etap,
  1286.                     'success' => true
  1287.                 ];
  1288.             }
  1289.         }
  1290.         return [
  1291.             'success' => false
  1292.         ];
  1293.     }
  1294.     public function submitEtap6($request,$user)
  1295.     {
  1296.         $fileEtatDecriptifMultiple = $request->get('fileEtatDecriptifMultiple');
  1297.         $fileEtatHypothecaireMultiple = $request->get('fileEtatHypothecaireMultiple');
  1298.         $filePublicationSPRMultiple = $request->get('filePublicationSPRMultiple');
  1299.         $fileTitreProprieteMultiple = $request->get('fileTitreProprieteMultiple');
  1300.         $fileAutreEtap6 = $request->get('fileAutreEtap6');
  1301.         $fileProcurationBailleur = $request->get('fileProcurationBailleur');
  1302.         $fileStatuts = $request->get('fileStatuts');
  1303.         $fileKbis = $request->get('fileKbis');
  1304.         $fileAccordMl = $request->get('fileAccordMl');
  1305.         $fileLivretFamille = $request->get('fileLivretFamille');
  1306.         $fileCarteIdentite = $request->get('fileCarteIdentite');
  1307.         $fileExtraitMatriceCadastrale = $request->get('fileExtraitMatriceCadastrale');
  1308.         $nomNotaire = $request->get('nomNotaire');
  1309.         $parcellesProjet = $request->get('parcellesProjet');
  1310.         $proprietaires = $request->get('proprietaires');
  1311.         $situationFonciere = $request->get('situationFonciere');
  1312.         $statutMainlevee = $request->get('statutMainlevee');
  1313.         $etapToken = $request->get('etapToken');
  1314.         $tokenProject = $request->get('tokenProject');
  1315.         if($etapToken and $tokenProject){
  1316.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1317.             $etap = $this->em->getRepository(Etap6::class)->findOneBy(['token'=>$etapToken]);
  1318.             if($project && $etap){
  1319.                 if(!$this->checkUserAction($user,$project,$etap)){
  1320.                     return [
  1321.                         'success' => false
  1322.                     ];
  1323.                 }
  1324.                 if($fileEtatDecriptifMultiple){
  1325.                     $array = explode(',',$fileEtatDecriptifMultiple);
  1326.                     foreach ($array as $item){
  1327.                         $fileEtatDecriptifMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1328.                         $nomenclature = $this->getNomenclature($etap,$fileEtatDecriptifMultipleEntity,'Détachement parcellaire');
  1329.                         $etap->addFileEtatDecriptifMultiple($fileEtatDecriptifMultipleEntity);
  1330.                         $this->uploadFileToDropbox($fileEtatDecriptifMultipleEntity,$project,"Maitrise foncière/".$fileEtatDecriptifMultipleEntity->getId().$nomenclature);
  1331.                     }
  1332.                 }
  1333.                 if($fileEtatHypothecaireMultiple){
  1334.                     $array = explode(',',$fileEtatHypothecaireMultiple);
  1335.                     foreach ($array as $item){
  1336.                         $fileEtatHypothecaireMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1337.                         $nomenclature = $this->getNomenclature($etap,$fileEtatHypothecaireMultipleEntity,'Etat hypothécaire');
  1338.                         $etap->addFileEtatHypothecaireMultiple($fileEtatHypothecaireMultipleEntity);
  1339.                         $this->uploadFileToDropbox($fileEtatHypothecaireMultipleEntity,$project,"Maitrise foncière/".$fileEtatHypothecaireMultipleEntity->getId().$nomenclature);
  1340.                     }
  1341.                 }
  1342.                 if($filePublicationSPRMultiple){
  1343.                     $array = explode(',',$filePublicationSPRMultiple);
  1344.                     foreach ($array as $item){
  1345.                         $filePublicationSPRMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1346.                         $nomenclature = $this->getNomenclature($etap,$filePublicationSPRMultipleEntity,'Publication SPF');
  1347.                         $etap->addFilePublicationSPRMultiple($filePublicationSPRMultipleEntity);
  1348.                         $this->uploadFileToDropbox($filePublicationSPRMultipleEntity,$project,"Maitrise foncière/".$filePublicationSPRMultipleEntity->getId().$nomenclature);
  1349.                     }
  1350.                 }
  1351.                 if($fileTitreProprieteMultiple){
  1352.                     $array = explode(',',$fileTitreProprieteMultiple);
  1353.                     foreach ($array as $item){
  1354.                         $fileTitreProprieteMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1355.                         $nomenclature = $this->getNomenclature($etap,$fileTitreProprieteMultipleEntity,'Titre de propriété');
  1356.                         $etap->addFileTitreProprieteMultiple($fileTitreProprieteMultipleEntity);
  1357.                         $this->uploadFileToDropbox($fileTitreProprieteMultipleEntity,$project,"Maitrise foncière/".$fileTitreProprieteMultipleEntity->getId().$nomenclature);
  1358.                     }
  1359.                 }
  1360.                 if($fileAutreEtap6){
  1361.                     $array = explode(',',$fileAutreEtap6);
  1362.                     foreach ($array as $item){
  1363.                         $fileAutreEtap6Entity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1364.                         $nomenclature = $this->getNomenclature($etap,$fileAutreEtap6Entity,'Autres (Cession de bail, projet de bail…)');
  1365.                         $etap->addFileAutreEtap6($fileAutreEtap6Entity);
  1366.                         $this->uploadFileToDropbox($fileAutreEtap6Entity,$project,"Maitrise foncière/".$fileAutreEtap6Entity->getId().$nomenclature);
  1367.                     }
  1368.                 }
  1369.                 if($fileProcurationBailleur){
  1370.                     $array = explode(',',$fileProcurationBailleur);
  1371.                     foreach ($array as $item){
  1372.                         $fileProcurationBailleurEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1373.                         $nomenclature =  $this->getNomenclature($etap,$fileProcurationBailleurEntity,'Autres (Cession de bail, projet de bail…)');
  1374.                         $etap->addFileProcurationBailleur($fileProcurationBailleurEntity);
  1375.                         $this->uploadFileToDropbox($fileProcurationBailleurEntity,$project,"Maitrise foncière/".$fileProcurationBailleurEntity->getId().$nomenclature);
  1376.                     }
  1377.                 }
  1378.                 if($fileStatuts){
  1379.                     $array = explode(',',$fileStatuts);
  1380.                     foreach ($array as $item){
  1381.                         $fileStatutsEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1382.                         $nomenclature =  $this->getNomenclature($etap,$fileStatutsEntity,'Statuts');
  1383.                         $etap->addFileStatuts($fileStatutsEntity);
  1384.                         $this->uploadFileToDropbox($fileStatutsEntity,$project,"Maitrise foncière/".$fileStatutsEntity->getId().$nomenclature);
  1385.                     }
  1386.                 }
  1387.                 if($fileKbis){
  1388.                     $array = explode(',',$fileKbis);
  1389.                     foreach ($array as $item){
  1390.                         $fileKbisEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1391.                         $nomenclature =  $this->getNomenclature($etap,$fileKbisEntity,'Kbis');
  1392.                         $etap->addFileKbi($fileKbisEntity);
  1393.                         $this->uploadFileToDropbox($fileKbisEntity,$project,"Maitrise foncière/".$fileKbisEntity->getId().$nomenclature);
  1394.                     }
  1395.                 }
  1396.                 if($fileAccordMl){
  1397.                     $array = explode(',',$fileAccordMl);
  1398.                     foreach ($array as $item){
  1399.                         $fileAccordMlEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1400.                         $nomenclature =  $this->getNomenclature($etap,$fileAccordMlEntity,' Accord ML');
  1401.                         $etap->addFileAccordMl($fileAccordMlEntity);
  1402.                         $this->uploadFileToDropbox($fileAccordMlEntity,$project,"Maitrise foncière/".$fileAccordMlEntity->getId().$nomenclature);
  1403.                     }
  1404.                 }
  1405.                 if($fileLivretFamille){
  1406.                     $array = explode(',',$fileLivretFamille);
  1407.                     foreach ($array as $item){
  1408.                         $fileLivretFamilleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1409.                         $nomenclature =  $this->getNomenclature($etap,$fileLivretFamilleEntity,'Livret de famille');
  1410.                         $etap->addFileLivretFamille($fileLivretFamilleEntity);
  1411.                         $this->uploadFileToDropbox($fileLivretFamilleEntity,$project,"Maitrise foncière/".$fileLivretFamilleEntity->getId().$nomenclature);
  1412.                     }
  1413.                 }
  1414.                 if($fileCarteIdentite){
  1415.                     $array = explode(',',$fileCarteIdentite);
  1416.                     foreach ($array as $item){
  1417.                         $fileCarteIdentiteEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1418.                         $nomenclature =  $this->getNomenclature($etap,$fileCarteIdentiteEntity,' Carte d’identité');
  1419.                         $etap->addFileCarteIdentite($fileCarteIdentiteEntity);
  1420.                         $this->uploadFileToDropbox($fileCarteIdentiteEntity,$project,"Maitrise foncière/".$fileCarteIdentiteEntity->getId().$nomenclature);
  1421.                     }
  1422.                 }
  1423.                 if($fileExtraitMatriceCadastrale){
  1424.                     $array = explode(',',$fileExtraitMatriceCadastrale);
  1425.                     foreach ($array as $item){
  1426.                         $fileExtraitMatriceCadastraleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1427.                         $nomenclature =  $this->getNomenclature($etap,$fileExtraitMatriceCadastraleEntity,'Extrait de matrice cadastrale');
  1428.                         $etap->addFileExtraitMatriceCadastrale($fileExtraitMatriceCadastraleEntity);
  1429.                         $this->uploadFileToDropbox($fileExtraitMatriceCadastraleEntity,$project,"Maitrise foncière/".$fileExtraitMatriceCadastraleEntity->getId().$nomenclature);
  1430.                     }
  1431.                 }
  1432.                 $etap->setNomNotaire($nomNotaire);
  1433.                 $etap->setParcellesProjet($parcellesProjet);
  1434.                 $etap->setProprietaires($proprietaires);
  1435.                 $etap->setSituationFonciere($situationFonciere);
  1436.                 $etap->setStatutMainlevee($statutMainlevee);
  1437.                 $this->em->persist($etap);
  1438.                 $this->em->flush();
  1439.                 $this->updateStatusTracker($project); // set status tracker
  1440.                 $this->flashBag->add(
  1441.                     'success',
  1442.                     'L\'opération a Ã©té effectuée avec succès.'
  1443.                 );
  1444.                 return [
  1445.                     'etap' => $etap,
  1446.                     'success' => true
  1447.                 ];
  1448.             }
  1449.         }
  1450.         return [
  1451.             'success' => false
  1452.         ];
  1453.     }
  1454.     public function submitEtap601($request,$user)
  1455.     {
  1456.         $fileEtatDecriptifMultiple = $request->get('fileEtatDecriptifMultiple');
  1457.         $filePlanServitudesMultiple = $request->get('filePlanServitudesMultiple');
  1458.         $dateLancement = $request->get('dateLancement');
  1459.         $dateIntervention = $request->get('dateIntervention');
  1460.         $fournisseurId = $request->get('fournisseurId');
  1461.         $etapToken = $request->get('etapToken');
  1462.         $tokenProject = $request->get('tokenProject');
  1463.         if($etapToken and $tokenProject){
  1464.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1465.             $etap = $this->em->getRepository(Etap601::class)->findOneBy(['token'=>$etapToken]);
  1466.             if($project && $etap){
  1467.                 if(!$this->checkUserAction($user,$project,$etap)){
  1468.                     return [
  1469.                         'success' => false
  1470.                     ];
  1471.                 }
  1472.                 if($fileEtatDecriptifMultiple){
  1473.                     $array = explode(',',$fileEtatDecriptifMultiple);
  1474.                     foreach ($array as $item){
  1475.                         $fileEtatDecriptifMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1476.                         $nomenclature = $this->getNomenclature($etap,$fileEtatDecriptifMultipleEntity,'DA / EDDV');
  1477.                         $etap->addFileEtatDecriptifMultiple($fileEtatDecriptifMultipleEntity);
  1478.                         $this->uploadFileToDropbox($fileEtatDecriptifMultipleEntity,$project,"Maitrise foncière/".$fileEtatDecriptifMultipleEntity->getId().$nomenclature);
  1479.                     }
  1480.                 }
  1481.                 if($filePlanServitudesMultiple){
  1482.                     $array = explode(',',$filePlanServitudesMultiple);
  1483.                     foreach ($array as $item){
  1484.                         $filePlanServitudesMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1485.                         $nomenclature =  $this->getNomenclature($etap,$filePlanServitudesMultipleEntity,'Plan de servitudes');
  1486.                         $etap->addFilePlanServitudesMultiple($filePlanServitudesMultipleEntity);
  1487.                         $this->uploadFileToDropbox($filePlanServitudesMultipleEntity,$project,"Maitrise foncière/".$filePlanServitudesMultipleEntity->getId().$nomenclature);
  1488.                     }
  1489.                 }
  1490.                 if($dateLancement){
  1491.                     $etap->setDateLancement(new \DateTime($dateLancement));
  1492.                 }else{
  1493.                     $etap->setDateLancement(null);
  1494.                 }
  1495.                 if($dateIntervention){
  1496.                     $etap->setDateIntervention(new \DateTime($dateIntervention));
  1497.                 }else{
  1498.                     $etap->setDateIntervention(null);
  1499.                 }
  1500.                 if($fournisseurId and $fournisseurId != 0){
  1501.                     $fournisseur = $this->em->getRepository(Fournisseur::class)->find($fournisseurId);
  1502.                     if($fournisseur){
  1503.                         $etap->setFournisseur($fournisseur);
  1504.                     }else{
  1505.                         $etap->setFournisseur(null);
  1506.                     }
  1507.                 }else {
  1508.                     $etap->setFournisseur(null);
  1509.                 }
  1510.                 $this->em->persist($etap);
  1511.                 $this->em->flush();
  1512.                 $this->updateStatusTracker($project); // set status tracker
  1513.                 $this->flashBag->add(
  1514.                     'success',
  1515.                     'L\'opération a Ã©té effectuée avec succès.'
  1516.                 );
  1517.                 return [
  1518.                     'etap' => $etap,
  1519.                     'success' => true
  1520.                 ];
  1521.             }
  1522.         }
  1523.         return [
  1524.             'success' => false
  1525.         ];
  1526.     }
  1527.     public function submitEtap602($request,$user)
  1528.     {
  1529.         $fileProcurationBailleur = $request->get('fileProcurationBailleur');
  1530.         $dateLancement = $request->get('dateLancement');
  1531.         $dateEnvoiPocuration = $request->get('dateEnvoiPocuration');
  1532.         $dateSignatureProcuration = $request->get('dateSignatureProcuration');
  1533.         $fournisseurId = $request->get('fournisseurId');
  1534.         $etapToken = $request->get('etapToken');
  1535.         $tokenProject = $request->get('tokenProject');
  1536.         if($etapToken and $tokenProject){
  1537.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1538.             $etap = $this->em->getRepository(Etap602::class)->findOneBy(['token'=>$etapToken]);
  1539.             if($project && $etap){
  1540.                 if(!$this->checkUserAction($user,$project,$etap)){
  1541.                     return [
  1542.                         'success' => false
  1543.                     ];
  1544.                 }
  1545.                 if($fileProcurationBailleur){
  1546.                     $array = explode(',',$fileProcurationBailleur);
  1547.                     foreach ($array as $item){
  1548.                         $fileProcurationBailleurEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1549.                         $nomenclature = $this->getNomenclature($etap,$fileProcurationBailleurEntity,'Procuration Bailleur');
  1550.                         $etap->addFileProcurationBailleur($fileProcurationBailleurEntity);
  1551.                         $this->uploadFileToDropbox($fileProcurationBailleurEntity,$project,"Maitrise foncière/".$fileProcurationBailleurEntity->getId().$nomenclature);
  1552.                     }
  1553.                 }
  1554.                 if($dateLancement){
  1555.                     $etap->setDateLancement(new \DateTime($dateLancement));
  1556.                 }else{
  1557.                     $etap->setDateLancement(null);
  1558.                 }
  1559.                 if($dateEnvoiPocuration){
  1560.                     $etap->setDateEnvoiPocuration(new \DateTime($dateEnvoiPocuration));
  1561.                 }else{
  1562.                     $etap->setDateEnvoiPocuration(null);
  1563.                 }
  1564.                 if($dateSignatureProcuration){
  1565.                     $etap->setDateSignatureProcuration(new \DateTime($dateSignatureProcuration));
  1566.                 }else{
  1567.                     $etap->setDateSignatureProcuration(null);
  1568.                 }
  1569.                 if($fournisseurId and $fournisseurId != 0){
  1570.                     $fournisseur = $this->em->getRepository(Fournisseur::class)->find($fournisseurId);
  1571.                     if($fournisseur){
  1572.                         $etap->setFournisseur($fournisseur);
  1573.                         if(!$fournisseur->getUser()){
  1574.                             $dataUser = $this->addUserFournisseurInProject($fournisseur);
  1575.                             if(isset($dataUser['success']) and $dataUser['success'] and $dataUser['user']){
  1576.                                 $user = $dataUser['user'];
  1577.                                 $user->setFournisseur($fournisseur);
  1578.                                 $this->em->persist($user);
  1579.                                 $fournisseur->setUser($user);
  1580.                             }
  1581.                         }
  1582.                         $fournisseur->setIsNotaire(true);
  1583.                         $fournisseur->setIsErpAccee(true);
  1584.                         $projectFournisseur = $this->em->getRepository(FournisseurProject::class)->findOneBy(['project'=>$project,'titre'=>'Notaire']);
  1585.                         $projectFournisseur->setFournisseur($fournisseur);
  1586.                         $projectFournisseur->setTitre('Notaire');
  1587.                         $projectFournisseur->setProject($project);
  1588.                         $this->em->persist($projectFournisseur);
  1589.                         $this->em->persist($fournisseur);
  1590.                     }else{
  1591.                         $etap->setFournisseur(null);
  1592.                     }
  1593.                 }else {
  1594.                     $etap->setFournisseur(null);
  1595.                 }
  1596.                 $this->em->persist($etap);
  1597.                 $this->em->flush();
  1598.                 $this->updateStatusTracker($project); // set status tracker
  1599.                 $this->flashBag->add(
  1600.                     'success',
  1601.                     'L\'opération a Ã©té effectuée avec succès.'
  1602.                 );
  1603.                 return [
  1604.                     'etap' => $etap,
  1605.                     'success' => true
  1606.                 ];
  1607.             }
  1608.         }
  1609.         return [
  1610.             'success' => false
  1611.         ];
  1612.     }
  1613.     public function submitEtap7($request,$user)
  1614.     {
  1615.         $fileBailSigneMultiple = $request->get('fileBailSigneMultiple');
  1616.         $fileAvenantBailMultiple = $request->get('fileAvenantBailMultiple');
  1617.         $filePreuvePublicationsSPFMultiple = $request->get('filePreuvePublicationsSPFMultiple');
  1618.         $dateSignatureBail = $request->get('dateSignatureBail');
  1619.         $dateFinBail = $request->get('dateFinBail');
  1620.         $nomBailleur = $request->get('nomBailleur');
  1621.         $etapToken = $request->get('etapToken');
  1622.         $tokenProject = $request->get('tokenProject');
  1623.         if($etapToken and $tokenProject){
  1624.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1625.             $etap = $this->em->getRepository(Etap7::class)->findOneBy(['token'=>$etapToken]);
  1626.             if($project && $etap){
  1627.                 if(!$this->checkUserAction($user,$project,$etap)){
  1628.                     return [
  1629.                         'success' => false
  1630.                     ];
  1631.                 }
  1632.                 if($fileBailSigneMultiple){
  1633.                     $array = explode(',',$fileBailSigneMultiple);
  1634.                     foreach ($array as $item){
  1635.                         $fileBailSigneMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1636.                         $nomenclature =  $this->getNomenclature($etap,$fileBailSigneMultipleEntity,'Bail signé (avec l’ensemble des annexes)');
  1637.                         $etap->addFileBailSigneMultiple($fileBailSigneMultipleEntity);
  1638.                         $this->uploadFileToDropbox($fileBailSigneMultipleEntity,$project,"Maitrise foncière/".$fileBailSigneMultipleEntity->getId().$nomenclature);
  1639.                     }
  1640.                 }
  1641.                 if($fileAvenantBailMultiple){
  1642.                     $array = explode(',',$fileAvenantBailMultiple);
  1643.                     foreach ($array as $item){
  1644.                         $fileAvenantBailMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1645.                         $nomenclature =  $this->getNomenclature($etap,$fileAvenantBailMultipleEntity,'Avenant au bail');
  1646.                         $etap->addFileAvenantBailMultiple($fileAvenantBailMultipleEntity);
  1647.                         $this->uploadFileToDropbox($fileAvenantBailMultipleEntity,$project,"Maitrise foncière/".$fileAvenantBailMultipleEntity->getId().$nomenclature);
  1648.                     }
  1649.                 }
  1650.                 if($filePreuvePublicationsSPFMultiple){
  1651.                     $array = explode(',',$filePreuvePublicationsSPFMultiple);
  1652.                     foreach ($array as $item){
  1653.                         $filePreuvePublicationsSPFMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1654.                         $nomenclature =  $this->getNomenclature($etap,$filePreuvePublicationsSPFMultipleEntity,'Preuve de publications SPF"');
  1655.                         $etap->addFilePreuvePublicationsSPFMultiple($filePreuvePublicationsSPFMultipleEntity);
  1656.                     }
  1657.                 }
  1658.                 if($dateSignatureBail){
  1659.                     $etap->setDateSignatureBail(new \DateTime($dateSignatureBail));
  1660.                 }else{
  1661.                     $etap->setDateSignatureBail(null);
  1662.                 }
  1663.                 if($dateFinBail){
  1664.                     $etap->setDateFinBail(new \DateTime($dateFinBail));
  1665.                 }else{
  1666.                     $etap->setDateFinBail(null);
  1667.                 }
  1668.                 $etap->setNomBailleur($nomBailleur);
  1669.                 $this->em->persist($etap);
  1670.                 $this->em->flush();
  1671.                 $this->updateStatusTracker($project); // set status tracker
  1672.                 $this->flashBag->add(
  1673.                     'success',
  1674.                     'L\'opération a Ã©té effectuée avec succès.'
  1675.                 );
  1676.                 $this->notification->addAlertBail($project);
  1677.                 return [
  1678.                     'etap' => $etap,
  1679.                     'success' => true
  1680.                 ];
  1681.             }
  1682.         }
  1683.         return [
  1684.             'success' => false
  1685.         ];
  1686.     }
  1687.     public function submitEtap71($request,$user)
  1688.     {
  1689.         $etapToken = $request->get('etapToken');
  1690.         $tokenProject = $request->get('tokenProject');
  1691.         $etap71Litige = $request->get('etap71Litige');
  1692.         if($etapToken and $tokenProject){
  1693.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1694.             $etap = $this->em->getRepository(Etap71::class)->findOneBy(['token'=>$etapToken]);
  1695.             if($project && $etap){
  1696.                 if(!$this->checkUserAction($user,$project,$etap)){
  1697.                     return [
  1698.                         'success' => false
  1699.                     ];
  1700.                 }
  1701.                 if($etap71Litige) {
  1702.                     foreach ($etap71Litige as $item) {
  1703.                         if (isset($item['id']) and $item['id'] != '') {
  1704.                             $etap71LitigeEntity = $this->em->getRepository(Etap71Litige::class)->findOneBy(['token' => $item['id']]);
  1705.                         } else {
  1706.                             $etap71LitigeEntity = new Etap71Litige();
  1707.                         }
  1708.                         if (isset($item['fileDocLitigeMultiple']) and $item['fileDocLitigeMultiple'] != '') {
  1709.                             $array = explode(',', $item['fileDocLitigeMultiple']);
  1710.                             foreach ($array as $item1) {
  1711.                                 $fileDocLitigeMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token' => $item1]);
  1712.                                 $nomenclature = $this->getNomenclature($etap, $fileDocLitigeMultipleEntity, 'Litige document');
  1713.                                 $etap71LitigeEntity->addFileDocLitigeMultiple($fileDocLitigeMultipleEntity);
  1714.                             }
  1715.                         }
  1716.                         if(isset($item['titreLitige']) and $item['titreLitige'] != ''){
  1717.                             $etap71LitigeEntity->setTitreLitige($item['titreLitige']);
  1718.                         }else{
  1719.                             $etap71LitigeEntity->setTitreLitige(null);
  1720.                         }
  1721.                         $etap71LitigeEntity->setEtap71($etap);
  1722.                         $this->em->persist($etap71LitigeEntity);
  1723.                         $this->em->flush();
  1724.                         if (isset($item['comments'])) {
  1725.                           foreach ($item['comments'] as $comments){
  1726.                               if(isset($comments['id']) and $comments['id'] != ''){
  1727.                                   $comment = $this->em->getRepository(Etap71LitigeCommentaire::class)->find($comments['id']);
  1728.                               }else{
  1729.                                   $comment = new Etap71LitigeCommentaire();
  1730.                                   $comment->setCreatedAt(new \DateTime('now',new \DateTimeZone('Europe/Paris')));
  1731.                                   $comment->setUserCreated($this->security->getUser());
  1732.                               }
  1733.                               $comment->setComment($comments['comment']);
  1734.                               $comment->setEtap71Litige($etap71LitigeEntity);
  1735.                               $this->em->persist($comment);
  1736.                               $this->em->flush();
  1737.                           }
  1738.                         }
  1739.                     }
  1740.                 }
  1741.                 $this->em->persist($etap);
  1742.                 $this->em->flush();
  1743.                 $this->updateStatusTracker($project); // set status tracker
  1744.                 $this->flashBag->add(
  1745.                     'success',
  1746.                     'L\'opération a Ã©té effectuée avec succès.'
  1747.                 );
  1748.                 return [
  1749.                     'etap' => $etap,
  1750.                     'success' => true
  1751.                 ];
  1752.             }
  1753.         }
  1754.         return [
  1755.             'success' => false
  1756.         ];
  1757.     }
  1758.     public function submitEtap80($request,$user)
  1759.     {
  1760.         $fileIPR = $request->get('fileIPR');
  1761.         $filePRAC = $request->get('filePRAC');
  1762.         $distancePdl = $request->get('distancePdl');
  1763.         $natureRaccordement = $request->get('natureRaccordement');
  1764.         $etapToken = $request->get('etapToken');
  1765.         $tokenProject = $request->get('tokenProject');
  1766.         if($etapToken and $tokenProject){
  1767.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1768.             $etap = $this->em->getRepository(Etap80::class)->findOneBy(['token'=>$etapToken]);
  1769.             if($project && $etap){
  1770.                 if(!$this->checkUserAction($user,$project,$etap)){
  1771.                     return [
  1772.                         'success' => false
  1773.                     ];
  1774.                 }
  1775.                 if($fileIPR){
  1776.                     $array = explode(',',$fileIPR);
  1777.                     foreach ($array as $item){
  1778.                         $fileIPREntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1779.                         $nomenclature =  $this->getNomenclature($etap,$fileIPREntity,'IPR');
  1780.                         $etap->addFileIPR($fileIPREntity);
  1781.                         $this->uploadFileToDropbox($fileIPREntity,$project,"Raccordement ENEDIS/".$fileIPREntity->getId().$nomenclature);
  1782.                     }
  1783.                 }
  1784.                 if($filePRAC){
  1785.                     $array = explode(',',$filePRAC);
  1786.                     foreach ($array as $item){
  1787.                         $filePRACEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1788.                         $nomenclature =  $this->getNomenclature($etap,$filePRACEntity,'PRAC');
  1789.                         $etap->addFilePRAC($filePRACEntity);
  1790.                         $this->uploadFileToDropbox($filePRACEntity,$project,"Raccordement ENEDIS/".$filePRACEntity->getId().$nomenclature);
  1791.                     }
  1792.                 }
  1793.                 $etap->setDistancePdl($distancePdl);
  1794.                 $etap->setNatureRaccordement($natureRaccordement);
  1795.                 $this->em->persist($etap);
  1796.                 $this->em->flush();
  1797.                 $this->updateStatusTracker($project); // set status tracker
  1798.                 $this->flashBag->add(
  1799.                     'success',
  1800.                     'L\'opération a Ã©té effectuée avec succès.'
  1801.                 );
  1802.                 return [
  1803.                     'etap' => $etap,
  1804.                     'success' => true
  1805.                 ];
  1806.             }
  1807.         }
  1808.         return [
  1809.             'success' => false
  1810.         ];
  1811.     }
  1812.     public function submitEtap8($request,$user)
  1813.     {
  1814.         $fileKbisEtsMultiple = $request->get('fileKbisEtsMultiple');
  1815.         $profileCreateur = $request->get('profileCreateur');
  1816.         $adresseEtablissement = $request->get('adresseEtablissement');
  1817.         $cityEtablissement = $request->get('cityEtablissement');
  1818.         $codePostalEtablissement = $request->get('codePostalEtablissement');
  1819.         $latEtablissement = $request->get('latEtablissement');
  1820.         $longiEtablissement = $request->get('longiEtablissement');
  1821.         $numParcelleEtablissement = $request->get('numParcelleEtablissement');
  1822.         $siretEts = $request->get('siretEts');
  1823.         $spvEtablissement = $request->get('spvEtablissement');
  1824.         $etapToken = $request->get('etapToken');
  1825.         $tokenProject = $request->get('tokenProject');
  1826.         if($etapToken and $tokenProject){
  1827.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1828.             $etap = $this->em->getRepository(Etap8::class)->findOneBy(['token'=>$etapToken]);
  1829.             if($project && $etap){
  1830.                 if(!$this->checkUserAction($user,$project,$etap)){
  1831.                     return [
  1832.                         'success' => false
  1833.                     ];
  1834.                 }
  1835.                 if($fileKbisEtsMultiple){
  1836.                     $array = explode(',',$fileKbisEtsMultiple);
  1837.                     foreach ($array as $item){
  1838.                         $fileKbisEtsMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1839.                         $nomenclature =  $this->getNomenclature($etap,$fileKbisEtsMultipleEntity,'Kbis de l’ETS');
  1840.                         $etap->addFileKbisEtsMultiple($fileKbisEtsMultipleEntity);
  1841.                         $this->uploadFileToDropbox($fileKbisEtsMultipleEntity,$project,"Raccordement ENEDIS/".$fileKbisEtsMultipleEntity->getId().$nomenclature);
  1842.                     }
  1843.                 }
  1844.                 $etap->setProfileCreateur($profileCreateur);
  1845.                 $etap->setAdresseEtablissement($adresseEtablissement);
  1846.                 $etap->setCityEtablissement($cityEtablissement);
  1847.                 $etap->setCodePostalEtablissement($codePostalEtablissement);
  1848.                 $etap->setLatEtablissement($latEtablissement);
  1849.                 $etap->setLongiEtablissement($longiEtablissement);
  1850.                 $etap->setNumParcelleEtablissement($numParcelleEtablissement);
  1851.                 $etap->setSiretEts($siretEts);
  1852.                 if($spvEtablissement){
  1853.                     $spvEtablissementEntity = $this->em->getRepository(Spv::class)->find($spvEtablissement);
  1854.                     $etap->setSpvEtablissement($spvEtablissementEntity);
  1855.                 }
  1856.                 $this->em->persist($etap);
  1857.                 $this->em->flush();
  1858.                 $this->updateStatusTracker($project); // set status tracker
  1859.                 $this->flashBag->add(
  1860.                     'success',
  1861.                     'L\'opération a Ã©té effectuée avec succès.'
  1862.                 );
  1863.                 return [
  1864.                     'etap' => $etap,
  1865.                     'success' => true
  1866.                 ];
  1867.             }
  1868.         }
  1869.         return [
  1870.             'success' => false
  1871.         ];
  1872.     }
  1873.     public function submitEtap9($request,$user)
  1874.     {
  1875.         $fileMailEnedisConfirmationMultiple = $request->get('fileMailEnedisConfirmationMultiple');
  1876.         $fileDemandeRaccordementMultiple = $request->get('fileDemandeRaccordementMultiple');
  1877.         $fileGarantieBancaireMultiple = $request->get('fileGarantieBancaireMultiple');
  1878.         $dateT0 = $request->get('dateT0');
  1879.         $dateMaximaleAchevement = $request->get('dateMaximaleAchevement');
  1880.         $dateConsignation = $request->get('dateConsignation');
  1881.         $tarifFit = $request->get('tarifFit');
  1882.         $etapToken = $request->get('etapToken');
  1883.         $tokenProject = $request->get('tokenProject');
  1884.         if($etapToken and $tokenProject){
  1885.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  1886.             $etap = $this->em->getRepository(Etap9::class)->findOneBy(['token'=>$etapToken]);
  1887.             if($project && $etap){
  1888.                 if(!$this->checkUserAction($user,$project,$etap)){
  1889.                     return [
  1890.                         'success' => false
  1891.                     ];
  1892.                 }
  1893.                 $etap24 = $this->em->getRepository(Etap24::class)->findOneBy(['project'=>$project->getId()]);
  1894.                 if($fileMailEnedisConfirmationMultiple){
  1895.                     $array = explode(',',$fileMailEnedisConfirmationMultiple);
  1896.                     foreach ($array as $item){
  1897.                         $fileMailEnedisConfirmationMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1898.                         $nomenclature =  $this->getNomenclature($etap,$fileMailEnedisConfirmationMultipleEntity,'Mail d’ENEDIS de confirmation');
  1899.                         $etap->addFileMailEnedisConfirmationMultiple($fileMailEnedisConfirmationMultipleEntity);
  1900.                         $this->uploadFileToDropbox($fileMailEnedisConfirmationMultipleEntity,$project,"Raccordement ENEDIS/".$fileMailEnedisConfirmationMultipleEntity->getId().$nomenclature);
  1901.                         if(count($etap24->getEtap24Champs()) > 0) {
  1902.                             foreach ($etap24->getEtap24Champs() as $etap24Cahmps){
  1903.                                 if($etap24Cahmps->getTypeValorisation() && ($etap24Cahmps->getTypeValorisation()->getCategory() == TypeValorisation::type_ao_cre or $etap24Cahmps->getTypeValorisation()->getCategory() == TypeValorisation::type_guichet_ouvert)){
  1904.                                     $etap24Cahmps->addFileMailEnedisConfirmationEtap25Multiple($fileMailEnedisConfirmationMultipleEntity);
  1905.                                     $this->em->persist($etap24Cahmps);
  1906.                                 }
  1907.                             }
  1908.                         }
  1909.                     }
  1910.                 }
  1911.                 if($fileDemandeRaccordementMultiple){
  1912.                     $array = explode(',',$fileDemandeRaccordementMultiple);
  1913.                     foreach ($array as $item){
  1914.                         $fileDemandeRaccordementMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1915.                         $nomenclature =  $this->getNomenclature($etap,$fileDemandeRaccordementMultipleEntity,'Demande de raccordement');
  1916.                         $etap->addFileDemandeRaccordementMultiple($fileDemandeRaccordementMultipleEntity);
  1917.                         $this->uploadFileToDropbox($fileDemandeRaccordementMultipleEntity,$project,"Raccordement ENEDIS/".$fileDemandeRaccordementMultipleEntity->getId().$nomenclature);
  1918.                         if(count($etap24->getEtap24Champs()) > 0) {
  1919.                             foreach ($etap24->getEtap24Champs() as $etap24Cahmps){
  1920.                                 if($etap24Cahmps->getTypeValorisation() && ($etap24Cahmps->getTypeValorisation()->getCategory() == TypeValorisation::type_ao_cre or $etap24Cahmps->getTypeValorisation()->getCategory() == TypeValorisation::type_guichet_ouvert)){
  1921.                                     $etap24Cahmps->addFileDemandeRaccordementEtap25Multiple($fileDemandeRaccordementMultipleEntity);
  1922.                                     $this->em->persist($etap24Cahmps);
  1923.                                 }
  1924.                             }
  1925.                         }
  1926.                     }
  1927.                 }
  1928.                 if($fileGarantieBancaireMultiple){
  1929.                     $array = explode(',',$fileGarantieBancaireMultiple);
  1930.                     foreach ($array as $item){
  1931.                         $fileGarantieBancaireMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  1932.                         $nomenclature =  $this->getNomenclature($etap,$fileGarantieBancaireMultipleEntity,'Garantie bancaire');
  1933.                         $etap->addFileGarantieBancaireMultiple($fileGarantieBancaireMultipleEntity);
  1934.                         if(count($etap24->getEtap24Champs()) > 0) {
  1935.                             foreach ($etap24->getEtap24Champs() as $etap24Cahmps){
  1936.                                 if($etap24Cahmps->getTypeValorisation() && ($etap24Cahmps->getTypeValorisation()->getCategory() == TypeValorisation::type_ao_cre)){
  1937.                                     $etap24Cahmps->addFileGarantieBancaireEtap25Multiple($fileGarantieBancaireMultipleEntity);
  1938.                                     $this->em->persist($etap24Cahmps);
  1939.                                 }
  1940.                             }
  1941.                         }
  1942.                     }
  1943.                 }
  1944.                 if($dateT0){
  1945.                     $etap->setDateT0(new \DateTime($dateT0));
  1946.                     $project->setDateT0Date(new \DateTime($dateT0));
  1947.                     if(count($etap24->getEtap24Champs()) > 0) {
  1948.                         foreach ($etap24->getEtap24Champs() as $etap24Cahmps) {
  1949.                             $etap24Cahmps->setDateT0(new \DateTime($dateT0));
  1950.                             $this->em->persist($etap24Cahmps);
  1951.                         }
  1952.                     }
  1953.                 }else{
  1954.                     $etap->setDateT0(null);
  1955.                     $project->setDateT0Date(null);
  1956.                     foreach ($etap24->getEtap24Champs() as $etap24Cahmps) {
  1957.                         $etap24Cahmps->setDateT0(null);
  1958.                         $this->em->persist($etap24Cahmps);
  1959.                     }
  1960.                 }
  1961.                 if($dateMaximaleAchevement){
  1962.                     $etap->setDateMaximaleAchevement(new \DateTime($dateMaximaleAchevement));
  1963.                 }else{
  1964.                     $etap->setDateMaximaleAchevement(null);
  1965.                 }
  1966.                 if($dateConsignation){
  1967.                     $etap->setDateConsignation(new \DateTime($dateConsignation));
  1968.                 }else{
  1969.                     $etap->setDateConsignation(null);
  1970.                 }
  1971.                 $etap->setTarifFit($tarifFit);
  1972.                 $project->setTarifRevente($tarifFit);
  1973.                 $this->em->persist($etap);
  1974.                 $this->em->flush();
  1975.                 $this->notification->addAlertT0($project);
  1976.                 $this->updateStatusTracker($project); // set status tracker
  1977.                 $this->flashBag->add(
  1978.                     'success',
  1979.                     'L\'opération a Ã©té effectuée avec succès.'
  1980.                 );
  1981.                 return [
  1982.                     'etap' => $etap,
  1983.                     'success' => true
  1984.                 ];
  1985.             }
  1986.         }
  1987.         return [
  1988.             'success' => false
  1989.         ];
  1990.     }
  1991.     public function submitEtap10($request,$user)
  1992.     {
  1993.         $filePtfMultiple = $request->get('filePtfMultiple');
  1994.         $fileCrdSigneeMultiple = $request->get('fileCrdSigneeMultiple');
  1995.         $filePreuveVirementMultiple = $request->get('filePreuveVirementMultiple');
  1996.         $fileCrdSigneeSansPtfMultiple = $request->get('fileCrdSigneeSansPtfMultiple');
  1997.         $filePreuveVirementSansPtfMultiple = $request->get('filePreuveVirementSansPtfMultiple');
  1998.         $fileAvenantCrdMultiple = $request->get('fileAvenantCrdMultiple');
  1999.         $fileAvenantCrdMesMultiple = $request->get('fileAvenantCrdMesMultiple');
  2000.         $isPtf= $request->get('isPtf');
  2001.         $montantAcompte= $request->get('montantAcompte');
  2002.         $montantCoutTotal= $request->get('montantCoutTotal');
  2003.         $montantAcompteSansPtf= $request->get('montantAcompteSansPtf');
  2004.         $montantCrdSansPtf= $request->get('montantCrdSansPtf');
  2005.         $referenceEnedis = $request->get('referenceEnedis');
  2006.         $avenantCrdMes = $request->get('avenantCrdMes');
  2007.         $etapToken = $request->get('etapToken');
  2008.         $tokenProject = $request->get('tokenProject');
  2009.         if($etapToken and $tokenProject){
  2010.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  2011.             $etap = $this->em->getRepository(Etap10::class)->findOneBy(['token'=>$etapToken]);
  2012.             if($project && $etap){
  2013.                 if(!$this->checkUserAction($user,$project,$etap)){
  2014.                     return [
  2015.                         'success' => false
  2016.                     ];
  2017.                 }
  2018.                 if($filePtfMultiple){
  2019.                     $array = explode(',',$filePtfMultiple);
  2020.                     foreach ($array as $item){
  2021.                         $filePtfMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2022.                         $nomenclature =  $this->getNomenclature($etap,$filePtfMultipleEntity,'PTF');
  2023.                         $etap->addFilePtfMultiple($filePtfMultipleEntity);
  2024.                         $this->uploadFileToDropbox($filePtfMultipleEntity,$project,"Raccordement ENEDIS/".$filePtfMultipleEntity->getId().$nomenclature);
  2025.                     }
  2026.                 }
  2027.                 if($fileCrdSigneeMultiple){
  2028.                     $array = explode(',',$fileCrdSigneeMultiple);
  2029.                     foreach ($array as $item){
  2030.                         $fileCrdSigneeMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2031.                         if($item && $fileCrdSigneeMultipleEntity){
  2032.                             $nomenclature =  $this->getNomenclature($etap,$fileCrdSigneeMultipleEntity,'CRD signée');
  2033.                             $etap->addFileCrdSigneeMultiple($fileCrdSigneeMultipleEntity);
  2034.                             $this->uploadFileToDropbox($fileCrdSigneeMultipleEntity,$project,"Raccordement ENEDIS/".$fileCrdSigneeMultipleEntity->getId().$nomenclature);
  2035.                         }
  2036.                      }
  2037.                 }
  2038.                 if($filePreuveVirementMultiple){
  2039.                     $array = explode(',',$filePreuveVirementMultiple);
  2040.                     foreach ($array as $item){
  2041.                         $filePreuveVirementMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2042.                         $nomenclature =  $this->getNomenclature($etap,$filePreuveVirementMultipleEntity,'Preuve de virement');
  2043.                         $etap->addFilePreuveVirementMultiple($filePreuveVirementMultipleEntity);
  2044.                         $this->uploadFileToDropbox($filePreuveVirementMultipleEntity,$project,"Raccordement ENEDIS/".$filePreuveVirementMultipleEntity->getId().$nomenclature);
  2045.                     }
  2046.                 }
  2047.                 if($fileCrdSigneeSansPtfMultiple){
  2048.                     $array = explode(',',$fileCrdSigneeSansPtfMultiple);
  2049.                     foreach ($array as $item){
  2050.                         $fileCrdSigneeSansPtfMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2051.                         $nomenclature =  $this->getNomenclature($etap,$fileCrdSigneeSansPtfMultipleEntity,'CRD signée');
  2052.                         $etap->addFileCrdSigneeSansPtfMultiple($fileCrdSigneeSansPtfMultipleEntity);
  2053.                         $this->uploadFileToDropbox($fileCrdSigneeSansPtfMultipleEntity,$project,"Raccordement ENEDIS/".$fileCrdSigneeSansPtfMultipleEntity->getId().$nomenclature);
  2054.                     }
  2055.                 }
  2056.                 if($filePreuveVirementSansPtfMultiple){
  2057.                     $array = explode(',',$filePreuveVirementSansPtfMultiple);
  2058.                     foreach ($array as $item){
  2059.                         $filePreuveVirementSansPtfMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2060.                         $nomenclature =  $this->getNomenclature($etap,$filePreuveVirementSansPtfMultipleEntity,'Preuve de virement');
  2061.                         $etap->addFilePreuveVirementSansPtfMultiple($filePreuveVirementSansPtfMultipleEntity);
  2062.                         $this->uploadFileToDropbox($filePreuveVirementSansPtfMultipleEntity,$project,"Raccordement ENEDIS/".$filePreuveVirementSansPtfMultipleEntity->getId().$nomenclature);
  2063.                     }
  2064.                 }
  2065.                 if($fileAvenantCrdMesMultiple){
  2066.                     $array = explode(',',$fileAvenantCrdMesMultiple);
  2067.                     foreach ($array as $item){
  2068.                         $fileAvenantCrdMesMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2069.                         $nomenclature =  $this->getNomenclature($etap,$fileAvenantCrdMesMultipleEntity,'Avenant CRD pour MES');
  2070.                         $etap->addFileAvenantCrdMesMultiple($fileAvenantCrdMesMultipleEntity);
  2071.                         $this->uploadFileToDropbox($fileAvenantCrdMesMultipleEntity,$project,"Raccordement ENEDIS/".$fileAvenantCrdMesMultipleEntity->getId().$nomenclature);
  2072.                     }
  2073.                 }
  2074.                 if($fileAvenantCrdMultiple){
  2075.                     $array = explode(',',$fileAvenantCrdMultiple);
  2076.                     foreach ($array as $item){
  2077.                         $fileAvenantCrdMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2078.                         $nomenclature =  $this->getNomenclature($etap,$fileAvenantCrdMultipleEntity,'Avenant CRD');
  2079.                         $etap->addFileAvenantCrdMultiple($fileAvenantCrdMultipleEntity);
  2080.                         $this->uploadFileToDropbox($fileAvenantCrdMultipleEntity,$project,"Raccordement ENEDIS/".$fileAvenantCrdMultipleEntity->getId().$nomenclature);
  2081.                     }
  2082.                 }
  2083.                 $etap->setIsPtf($isPtf);
  2084.                 $etap->setMontantAcompte($montantAcompte);
  2085.                 $etap->setMontantCoutTotal($montantCoutTotal);
  2086.                 $etap->setMontantAcompteSansPtf($montantAcompteSansPtf);
  2087.                 $etap->setMontantCrdSansPtf($montantCrdSansPtf);
  2088.                 $etap->setReferenceEnedis($referenceEnedis);
  2089.                 $etap->setAvenantCrdMes($avenantCrdMes);
  2090.                 $this->em->persist($etap);
  2091.                 $this->em->flush();
  2092.                 $this->updateStatusTracker($project); // set status tracker
  2093.                 $this->flashBag->add(
  2094.                     'success',
  2095.                     'L\'opération a Ã©té effectuée avec succès.'
  2096.                 );
  2097.                 return [
  2098.                     'etap' => $etap,
  2099.                     'success' => true
  2100.                 ];
  2101.             }
  2102.         }
  2103.         return [
  2104.             'success' => false
  2105.         ];
  2106.     }
  2107.     public function submitEtap11($request,$user)
  2108.     {
  2109.         $filePreuveVirement = $request->get('filePreuveVirement');
  2110.         $etapToken = $request->get('etapToken');
  2111.         $tokenProject = $request->get('tokenProject');
  2112.         if($etapToken and $tokenProject){
  2113.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  2114.             $etap = $this->em->getRepository(Etap11::class)->findOneBy(['token'=>$etapToken]);
  2115.             if($project && $etap){
  2116.                 if(!$this->checkUserAction($user,$project,$etap)){
  2117.                     return [
  2118.                         'success' => false
  2119.                     ];
  2120.                 }
  2121.                 if($filePreuveVirement){
  2122.                     $filePreuveVirementEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$filePreuveVirement]);
  2123.                     $nomenclature =  $this->getNomenclature($etap,$filePreuveVirementEntity,'Preuve de virement');
  2124.                     $etap->setFilePreuveVirement($filePreuveVirementEntity);
  2125.                     $this->uploadFileToDropbox($filePreuveVirementEntity,$project,"Raccordement ENEDIS/".$nomenclature);
  2126.                 }
  2127.                 $this->em->persist($etap);
  2128.                 $this->em->flush();
  2129.                 $this->updateStatusTracker($project); // set status tracker
  2130.                 $this->flashBag->add(
  2131.                     'success',
  2132.                     'L\'opération a Ã©té effectuée avec succès.'
  2133.                 );
  2134.                 return [
  2135.                     'etap' => $etap,
  2136.                     'success' => true
  2137.                 ];
  2138.             }
  2139.         }
  2140.         return [
  2141.             'success' => false
  2142.         ];
  2143.     }
  2144.     public function submitEtap12($request,$user)
  2145.     {
  2146.         $fileCexSigneMultiple = $request->get('fileCexSigneMultiple');
  2147.         $fileCardiSigneMultiple = $request->get('fileCardiSigneMultiple');
  2148.         $fileAvenantCardiMultiple = $request->get('fileAvenantCardiMultiple');
  2149.         $numeroCardi = $request->get('numeroCardi');
  2150.         $numeroCardiMultiple = $request->get('numeroCardiMultiple');
  2151.         $identifiantEnedis = $request->get('identifiantEnedis');
  2152.         $etapToken = $request->get('etapToken');
  2153.         $tokenProject = $request->get('tokenProject');
  2154.         if($etapToken and $tokenProject){
  2155.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  2156.             $etap = $this->em->getRepository(Etap12::class)->findOneBy(['token'=>$etapToken]);
  2157.             if($project && $etap){
  2158.                 if(!$this->checkUserAction($user,$project,$etap)){
  2159.                     return [
  2160.                         'success' => false
  2161.                     ];
  2162.                 }
  2163.                 if($fileCexSigneMultiple){
  2164.                     $array = explode(',',$fileCexSigneMultiple);
  2165.                     foreach ($array as $item){
  2166.                         $fileCexSigneMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2167.                         if($fileCexSigneMultipleEntity){
  2168.                            $nomenclature = $this->getNomenclature($etap,$fileCexSigneMultipleEntity,'CEX signé');
  2169.                            $etap->addFileCexSigneMultiple($fileCexSigneMultipleEntity);
  2170.                            $this->uploadFileToDropbox($fileCexSigneMultipleEntity,$project,"Raccordement ENEDIS/".$fileCexSigneMultipleEntity->getId().$nomenclature);
  2171.                         }
  2172.                     }
  2173.                 }
  2174.                 if($fileCardiSigneMultiple){
  2175.                     $array = explode(',',$fileCardiSigneMultiple);
  2176.                     foreach ($array as $item){
  2177.                         $fileCardiSigneMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2178.                         if($fileCardiSigneMultipleEntity){
  2179.                             $nomenclature = $this->getNomenclature($etap,$fileCardiSigneMultipleEntity,'CARDi signé');
  2180.                             $etap->addFileCardiSigneMultiple($fileCardiSigneMultipleEntity);
  2181.                             $this->uploadFileToDropbox($fileCardiSigneMultipleEntity,$project,"Raccordement ENEDIS/".$fileCardiSigneMultipleEntity->getId().$nomenclature);
  2182.                         }
  2183.                    }
  2184.                 }
  2185.                 if($fileAvenantCardiMultiple){
  2186.                     $array = explode(',',$fileAvenantCardiMultiple);
  2187.                     foreach ($array as $item){
  2188.                         $fileAvenantCardiMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2189.                         if($fileAvenantCardiMultipleEntity){
  2190.                             $nomenclature = $this->getNomenclature($etap,$fileAvenantCardiMultipleEntity,'Avenant CARDi');
  2191.                             $etap->addFileAvenantCardiMultiple($fileAvenantCardiMultipleEntity);
  2192.                             $this->uploadFileToDropbox($fileAvenantCardiMultipleEntity,$project,"Raccordement ENEDIS/".$fileAvenantCardiMultipleEntity->getId().$nomenclature);
  2193.                         }
  2194.                     }
  2195.                 }
  2196.                 $etap->setNumeroCardi($numeroCardi);
  2197.                 $etap->setIdentifiantEnedis($identifiantEnedis);
  2198.                 $this->em->persist($etap);
  2199.                 $this->em->flush();
  2200.                 if($numeroCardiMultiple){
  2201.                     foreach ($numeroCardiMultiple as $item){
  2202.                         if(isset($item['id'])&& !empty($item['id'])){
  2203.                             $numeroCardiEntity = $this->em->getRepository(NumeroCardi::class)->find($item['id']);
  2204.                             if($numeroCardiEntity){
  2205.                                 $numeroCardiEntity->setNumeroCardi($item['numeroCardi']);
  2206.                                 $numeroCardiEntity->setIdentifiantEnedis($item['identifiantEnedis']);
  2207.                                 $numeroCardiEntity->setEtap12($etap);
  2208.                                 $this->em->persist($numeroCardiEntity);
  2209.                                 $this->em->flush();
  2210.                             }
  2211.                         }else{
  2212.                             $numeroCardiEntity = new NumeroCardi();
  2213.                             $numeroCardiEntity->setNumeroCardi($item['numeroCardi']);
  2214.                             $numeroCardiEntity->setIdentifiantEnedis($item['identifiantEnedis']);
  2215.                             $numeroCardiEntity->setEtap12($etap);
  2216.                             $this->em->persist($numeroCardiEntity);
  2217.                             $this->em->flush();
  2218.                         }
  2219.                     }
  2220.                 }
  2221.                 $this->updateStatusTracker($project); // set status tracker
  2222.                 $this->flashBag->add(
  2223.                     'success',
  2224.                     'L\'opération a Ã©té effectuée avec succès.'
  2225.                 );
  2226.                 return [
  2227.                     'etap' => $etap,
  2228.                     'success' => true
  2229.                 ];
  2230.             }
  2231.         }
  2232.         return [
  2233.             'success' => false
  2234.         ];
  2235.     }
  2236.     public function submitEtap121($request,$user)
  2237.     {
  2238.         $fileDocument121Multiple = $request->get('fileDocument121Multiple');
  2239.         $datePrevisionnelleInstallationPDL = $request->get('datePrevisionnelleInstallationPDL');
  2240.         $dateInstallationPDL = $request->get('dateInstallationPDL');
  2241.         $dateMiseSousTensionEnedis = $request->get('dateMiseSousTensionEnedis');
  2242.         $etapToken = $request->get('etapToken');
  2243.         $tokenProject = $request->get('tokenProject');
  2244.         if($etapToken and $tokenProject){
  2245.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  2246.             $etap = $this->em->getRepository(Etap121::class)->findOneBy(['token'=>$etapToken]);
  2247.             if($project && $etap){
  2248.                 if(!$this->checkUserAction($user,$project,$etap)){
  2249.                     return [
  2250.                         'success' => false
  2251.                     ];
  2252.                 }
  2253.                 if($dateMiseSousTensionEnedis){
  2254.                     $etap->setDateMiseSousTensionEnedis(new \DateTime($dateMiseSousTensionEnedis));
  2255.                 }else{
  2256.                     $etap->setDateMiseSousTensionEnedis(null);
  2257.                 }
  2258.                 if($dateInstallationPDL){
  2259.                     $etap->setDateInstallationPDL(new \DateTime($dateInstallationPDL));
  2260.                 }else{
  2261.                     $etap->setDateInstallationPDL(null);
  2262.                 }
  2263.                 if($datePrevisionnelleInstallationPDL){
  2264.                     $etap->setDatePrevisionnelleInstallationPDL(new \DateTime($datePrevisionnelleInstallationPDL));
  2265.                 }else{
  2266.                     $etap->setDatePrevisionnelleInstallationPDL(null);
  2267.                 }
  2268.                 if($fileDocument121Multiple){
  2269.                     $array = explode(',',$fileDocument121Multiple);
  2270.                     foreach ($array as $item){
  2271.                         $fileDocument121MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2272.                         $nomenclature = $this->getNomenclature($etap,$fileDocument121MultipleEntity,'Installation PDL');
  2273.                         $etap->addFileDocument121Multiple($fileDocument121MultipleEntity);
  2274.                         $this->uploadFileToDropbox($fileDocument121MultipleEntity,$project,"Raccordement ENEDIS/".$fileDocument121MultipleEntity->getId().$nomenclature);
  2275.                     }
  2276.                 }
  2277.                 $this->em->persist($etap);
  2278.                 $this->em->flush();
  2279.                 $this->updateStatusTracker($project); // set status tracker
  2280.                 $this->flashBag->add(
  2281.                     'success',
  2282.                     'L\'opération a Ã©té effectuée avec succès.'
  2283.                 );
  2284.                 return [
  2285.                     'etap' => $etap,
  2286.                     'success' => true
  2287.                 ];
  2288.             }
  2289.         }
  2290.         return [
  2291.             'success' => false
  2292.         ];
  2293.     }
  2294.     public function submitEtap13($request,$user)
  2295.     {
  2296.         $fileConsuelMultiple = $request->get('fileConsuelMultiple');
  2297.         $fileAttestationBureauControleMultiple = $request->get('fileAttestationBureauControleMultiple');
  2298.         $fileDREMultiple = $request->get('fileDREMultiple');
  2299.         $dateConsuel = $request->get('dateConsuel');
  2300.         $etapToken = $request->get('etapToken');
  2301.         $tokenProject = $request->get('tokenProject');
  2302.         if($etapToken and $tokenProject){
  2303.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  2304.             $etap = $this->em->getRepository(Etap13::class)->findOneBy(['token'=>$etapToken]);
  2305.             if($project && $etap){
  2306.                 $etap20 = $this->em->getRepository(Etap20::class)->findOneBy(['project'=>$project->getId()]);
  2307.                 if(!$this->checkUserAction($user,$project,$etap)){
  2308.                     return [
  2309.                         'success' => false
  2310.                     ];
  2311.                 }
  2312.                 if($fileConsuelMultiple){
  2313.                     $array = explode(',',$fileConsuelMultiple);
  2314.                     foreach ($array as $item){
  2315.                         $fileConsuelMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2316.                         $nomenclature = $this->getNomenclature($etap,$fileConsuelMultipleEntity,'Consuel');
  2317.                         $etap->addFileConsuelMultiple($fileConsuelMultipleEntity);
  2318.                         $etap20->addFileConsuelEtap20Multiple($fileConsuelMultipleEntity);
  2319.                         $this->uploadFileToDropbox($fileConsuelMultipleEntity,$project,"Raccordement ENEDIS/".$fileConsuelMultipleEntity->getId().$nomenclature);
  2320.                     }
  2321.                 }
  2322.                 if($fileAttestationBureauControleMultiple){
  2323.                     $array = explode(',',$fileAttestationBureauControleMultiple);
  2324.                     foreach ($array as $item){
  2325.                         $fileAttestationBureauControleMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2326.                         $nomenclature = $this->getNomenclature($etap,$fileAttestationBureauControleMultipleEntity,'Attestation bureau de contrôle S21');
  2327.                         $etap->addFileAttestationBureauControleMultiple($fileAttestationBureauControleMultipleEntity);
  2328.                         $this->uploadFileToDropbox($fileAttestationBureauControleMultipleEntity,$project,"Raccordement ENEDIS/".$fileAttestationBureauControleMultipleEntity->getId().$nomenclature);
  2329.                     }
  2330.                 }
  2331.                 if($fileDREMultiple){
  2332.                     $array = explode(',',$fileDREMultiple);
  2333.                     foreach ($array as $item){
  2334.                         $fileDREMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2335.                         $nomenclature = $this->getNomenclature($etap,$fileDREMultipleEntity,'DRE');
  2336.                         $etap->addFileDREMultiple($fileDREMultipleEntity);
  2337.                         $this->uploadFileToDropbox($fileDREMultipleEntity,$project,"Raccordement ENEDIS/".$fileDREMultipleEntity->getId().$nomenclature);
  2338.                     }
  2339.                 }
  2340.                 if($dateConsuel){
  2341.                     $etap->setDateConsuel(new \DateTime($dateConsuel));
  2342.                     $etap20->setDateConsuelEtap20(new \DateTime($dateConsuel));
  2343.                 }else{
  2344.                     $etap->setDateConsuel(null);
  2345.                     $etap20->setDateConsuelEtap20(null);
  2346.                 }
  2347.                 $this->em->persist($etap20);
  2348.                 $this->em->persist($etap);
  2349.                 $this->em->flush();
  2350.                 $this->notification->addAlertPc($project);
  2351.                 $this->notification->addAlertT0($project);
  2352.                 $this->updateStatusTracker($project); // set status tracker
  2353.                 $this->flashBag->add(
  2354.                     'success',
  2355.                     'L\'opération a Ã©té effectuée avec succès.'
  2356.                 );
  2357.                 return [
  2358.                     'etap' => $etap,
  2359.                     'success' => true
  2360.                 ];
  2361.             }
  2362.         }
  2363.         return [
  2364.             'success' => false
  2365.         ];
  2366.     }
  2367.     public function submitEtap14($request,$user)
  2368.     {
  2369.         $fileDoeMultiple = $request->get('fileDoeMultiple');
  2370.         $fileARPE = $request->get('fileARPE');
  2371.         $fileDEIE = $request->get('fileDEIE');
  2372.         $fileAttestationS21Multiple = $request->get('fileAttestationS21Multiple');
  2373.         $dateMiseEnService = $request->get('dateMiseEnService');
  2374.         $dateMesPrevisionnelle = $request->get('dateMesPrevisionnelle');
  2375.         $adresseMiseEnService = $request->get('adresseMiseEnService');
  2376.         $cityMiseEnService = $request->get('cityMiseEnService');
  2377.         $codePostalMiseEnService = $request->get('codePostalMiseEnService');
  2378.         $firstnameProprietaire = $request->get('firstnameProprietaire');
  2379.         $lastnameProprietaire = $request->get('lastnameProprietaire');
  2380.         $phoneProprietaire = $request->get('phoneProprietaire');
  2381.         $emailProprietaire = $request->get('emailProprietaire');
  2382.         $procedureAcces = $request->get('procedureAcces');
  2383.         $etapToken = $request->get('etapToken');
  2384.         $tokenProject = $request->get('tokenProject');
  2385.         if($etapToken and $tokenProject){
  2386.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  2387.             $etap = $this->em->getRepository(Etap14::class)->findOneBy(['token'=>$etapToken]);
  2388.             if($project && $etap){
  2389.                 $etap21 = $this->em->getRepository(Etap21::class)->findOneBy(['project'=>$project->getId()]);
  2390.                 if(!$this->checkUserAction($user,$project,$etap)){
  2391.                     return [
  2392.                         'success' => false
  2393.                     ];
  2394.                 }
  2395.                 if($fileDoeMultiple){
  2396.                     $array = explode(',',$fileDoeMultiple);
  2397.                     foreach ($array as $item){
  2398.                         $fileDoeMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2399.                         $nomenclature = $this->getNomenclature($etap,$fileDoeMultipleEntity,'Attestation de mise en service');
  2400.                         $etap->addFileDoeMultiple($fileDoeMultipleEntity);
  2401. //                        $this->uploadFileToDropbox($fileDoeMultipleEntity,$project,"Raccordement ENEDIS/".$fileDoeMultipleEntity->getId().$nomenclature);
  2402.                     }
  2403.                 }
  2404.                 if($fileARPE){
  2405.                     $array = explode(',',$fileARPE);
  2406.                     foreach ($array as $item){
  2407.                         $fileARPEEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2408.                         $nomenclature = $this->getNomenclature($etap,$fileARPEEntity,'ARPE');
  2409.                         $etap->addFileARPE($fileARPEEntity);
  2410.                     }
  2411.                 }
  2412.                 if($fileDEIE){
  2413.                     $array = explode(',',$fileDEIE);
  2414.                     foreach ($array as $item){
  2415.                         $fileDEIEEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2416.                         $nomenclature = $this->getNomenclature($etap,$fileDEIEEntity,'DEIE');
  2417.                         $etap->addFileDEIE($fileDEIEEntity);
  2418.                     }
  2419.                 }
  2420.                 if($fileAttestationS21Multiple){
  2421.                     $array = explode(',',$fileAttestationS21Multiple);
  2422.                     foreach ($array as $item){
  2423.                         $fileAttestationS21MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2424.                         $nomenclature = $this->getNomenclature($etap,$fileAttestationS21MultipleEntity,'Attestation S21 (attestation de conformité) ');
  2425.                         $etap->addFileAttestationS21Multiple($fileAttestationS21MultipleEntity);
  2426. //                        $this->uploadFileToDropbox($fileAttestationS21MultipleEntity,$project,"Raccordement ENEDIS/".$fileAttestationS21MultipleEntity->getId().$nomenclature);
  2427.                     }
  2428.                 }
  2429.                 if($dateMiseEnService){
  2430.                     $etap->setDateMiseEnService(new \DateTime($dateMiseEnService));
  2431.                     $project->setDateMiseEnService(new \DateTime($dateMiseEnService));
  2432.                     $etap21->setDateMiseEnService(new \DateTime($dateMiseEnService));
  2433.                 }else{
  2434.                     $etap->setDateMiseEnService(null);
  2435.                     $project->setDateMiseEnService(null);
  2436.                     $etap21->setDateMiseEnService(null);
  2437.                 }
  2438.                 if($dateMesPrevisionnelle){
  2439.                     $etap->setDateMesPrevisionnelle(new \DateTime($dateMesPrevisionnelle));
  2440.                 }else{
  2441.                     $etap->setDateMesPrevisionnelle(null);
  2442.                 }
  2443.                     $etap->setAdresseMiseEnService($adresseMiseEnService);
  2444.                     $etap->setCityMiseEnService($cityMiseEnService);
  2445.                     $etap->setCodePostalMiseEnService($codePostalMiseEnService);
  2446.                     $etap->setFirstnameProprietaire($firstnameProprietaire);
  2447.                     $etap->setLastnameProprietaire($lastnameProprietaire);
  2448.                     $etap->setPhoneProprietaire($phoneProprietaire);
  2449.                     $etap->setEmailProprietaire($emailProprietaire);
  2450.                     $etap->setProcedureAcces($procedureAcces);
  2451.                 $this->em->persist($etap);
  2452.                 $this->em->flush();
  2453.                 $this->updateStatusTracker($project); // set status tracker
  2454.                 $this->flashBag->add(
  2455.                     'success',
  2456.                     'L\'opération a Ã©té effectuée avec succès.'
  2457.                 );
  2458.                 return [
  2459.                     'etap' => $etap,
  2460.                     'success' => true
  2461.                 ];
  2462.             }
  2463.         }
  2464.         return [
  2465.             'success' => false
  2466.         ];
  2467.     }
  2468.     public function submitEtap15($request,$user)
  2469.     {
  2470.         $fileContratAchatSigneMultiple = $request->get('fileContratAchatSigneMultiple');
  2471.         $fileAttestionProducteurMultiple = $request->get('fileAttestionProducteurMultiple');
  2472.         $fileAttestionInstallateurMultiple = $request->get('fileAttestionInstallateurMultiple');
  2473.         $fileArContratAchatMultiple = $request->get('fileArContratAchatMultiple');
  2474.         $dateDebutContratAchat = $request->get('dateDebutContratAchat');
  2475.         $dateFinContratAchat = $request->get('dateFinContratAchat');
  2476.         $tarifContratAchat = $request->get('tarifContratAchat');
  2477.         $peridiciteFacturation = $request->get('peridiciteFacturation');
  2478.         $numeroContratAchat = $request->get('numeroContratAchat');
  2479.         $informationMultiple = $request->get('informationMultiple');
  2480.         $etapToken = $request->get('etapToken');
  2481.         $tokenProject = $request->get('tokenProject');
  2482.         if($etapToken and $tokenProject){
  2483.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  2484.             $etap = $this->em->getRepository(Etap15::class)->findOneBy(['token'=>$etapToken]);
  2485.             if($project && $etap){
  2486.                 if(!$this->checkUserAction($user,$project,$etap)){
  2487.                     return [
  2488.                         'success' => false
  2489.                     ];
  2490.                 }
  2491.                 if($informationMultiple){
  2492.                     foreach ($informationMultiple as $item){
  2493.                         if(isset($item['id'])&& !empty($item['id'])){
  2494.                             $informationMultipleEntity = $this->em->getRepository(ImfomationContratAchat::class)->find($item['id']);
  2495.                             if($informationMultipleEntity){
  2496.                                 $informationMultipleEntity->setTarifContratAchat($item['tarifContratAchat']);
  2497.                                 if($item['dateDebutContratAchat']){
  2498.                                     $informationMultipleEntity->setDateDebutContratAchat(new \DateTime($item['dateDebutContratAchat']));
  2499.                                 }else{
  2500.                                     $informationMultipleEntity->setDateDebutContratAchat(null);
  2501.                                 }
  2502.                                 if($item['dateFinContratAchat']){
  2503.                                     $informationMultipleEntity->setDateFinContratAchat(new \DateTime($item['dateFinContratAchat']));
  2504.                                 }else{
  2505.                                     $informationMultipleEntity->setDateFinContratAchat(null);
  2506.                                 }
  2507.                                 $informationMultipleEntity->setPeridiciteFacturation($item['peridiciteFacturation']);
  2508.                                 $informationMultipleEntity->setNumeroContratAchat($item['numeroContratAchat']);
  2509.                                 $informationMultipleEntity->setTypeContrat($item['typeContrat']);
  2510.                                 $informationMultipleEntity->setEtap15($etap);
  2511.                                 $this->em->persist($informationMultipleEntity);
  2512.                                 $this->em->flush();
  2513.                             }
  2514.                         }else{
  2515.                             $informationMultipleEntity = new ImfomationContratAchat();
  2516.                             $informationMultipleEntity->setTarifContratAchat($item['tarifContratAchat']);
  2517.                             if($item['dateDebutContratAchat']){
  2518.                                 $informationMultipleEntity->setDateDebutContratAchat(new \DateTime($item['dateDebutContratAchat']));
  2519.                             }else{
  2520.                                 $informationMultipleEntity->setDateDebutContratAchat(null);
  2521.                             }
  2522.                             if($item['dateFinContratAchat']){
  2523.                                 $informationMultipleEntity->setDateFinContratAchat(new \DateTime($item['dateFinContratAchat']));
  2524.                             }else{
  2525.                                 $informationMultipleEntity->setDateFinContratAchat(null);
  2526.                             }
  2527.                             $informationMultipleEntity->setPeridiciteFacturation($item['peridiciteFacturation']);
  2528.                             $informationMultipleEntity->setNumeroContratAchat($item['numeroContratAchat']);
  2529.                             $informationMultipleEntity->setTypeContrat($item['typeContrat']);
  2530.                             $informationMultipleEntity->setEtap15($etap);
  2531.                             $this->em->persist($informationMultipleEntity);
  2532.                             $this->em->flush();
  2533.                         }
  2534.                     }
  2535.                 }
  2536.                 if($fileContratAchatSigneMultiple){
  2537.                     $array = explode(',',$fileContratAchatSigneMultiple);
  2538.                     foreach ($array as $item){
  2539.                         $fileContratAchatSigneMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2540.                         $nomenclature = $this->getNomenclature($etap,$fileContratAchatSigneMultipleEntity,'Contrat d’achat signé');
  2541.                         $etap->addFileContratAchatSigneMultiple($fileContratAchatSigneMultipleEntity);
  2542.                         $this->uploadFileToDropbox($fileContratAchatSigneMultipleEntity,$project,"Raccordement ENEDIS/".$fileContratAchatSigneMultipleEntity->getId().$nomenclature);
  2543.                     }
  2544.                 }
  2545.                 if($fileAttestionProducteurMultiple){
  2546.                     $array = explode(',',$fileAttestionProducteurMultiple);
  2547.                     foreach ($array as $item){
  2548.                         $fileAttestionProducteurMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2549.                         $nomenclature = $this->getNomenclature($etap,$fileAttestionProducteurMultipleEntity,'Attestation de producteur');
  2550.                         $etap->addFileAttestionProducteurMultiple($fileAttestionProducteurMultipleEntity);
  2551.                         $this->uploadFileToDropbox($fileAttestionProducteurMultipleEntity,$project,"Raccordement ENEDIS/".$fileAttestionProducteurMultipleEntity->getId().$nomenclature);
  2552.                     }
  2553.                 }
  2554.                 if($fileAttestionInstallateurMultiple){
  2555.                     $array = explode(',',$fileAttestionInstallateurMultiple);
  2556.                     foreach ($array as $item){
  2557.                         $fileAttestionInstallateurMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2558.                         $nomenclature = $this->getNomenclature($etap,$fileAttestionInstallateurMultipleEntity,'Attestation de l’installateur');
  2559.                         $etap->addFileAttestionInstallateurMultiple($fileAttestionInstallateurMultipleEntity);
  2560.                         $this->uploadFileToDropbox($fileAttestionInstallateurMultipleEntity,$project,"Raccordement ENEDIS/".$fileAttestionInstallateurMultipleEntity->getId().$nomenclature);
  2561.                     }
  2562.                 }
  2563.                 if($fileArContratAchatMultiple){
  2564.                     $array = explode(',',$fileArContratAchatMultiple);
  2565.                     foreach ($array as $item){
  2566.                         $fileArContratAchatMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2567.                         $nomenclature = $this->getNomenclature($etap,$fileArContratAchatMultipleEntity,'AR Contrat d’achat');
  2568.                         $etap->addFileArContratAchatMultiple($fileArContratAchatMultipleEntity);
  2569.                     }
  2570.                 }
  2571.                 if($dateDebutContratAchat){
  2572.                     $etap->setDateDebutContratAchat(new \DateTime($dateDebutContratAchat));
  2573.                 }
  2574.                 if($dateFinContratAchat){
  2575.                     $etap->setDateFinContratAchat(new \DateTime($dateFinContratAchat));
  2576.                 }
  2577.                 $etap->setTarifContratAchat($tarifContratAchat);
  2578.                 $etap->setPeridiciteFacturation($peridiciteFacturation);
  2579.                 $etap->setNumeroContratAchat($numeroContratAchat);
  2580.                 $this->em->persist($etap);
  2581.                 $this->em->flush();
  2582.                 $this->updateStatusTracker($project); // set status tracker
  2583.                 $this->flashBag->add(
  2584.                     'success',
  2585.                     'L\'opération a Ã©té effectuée avec succès.'
  2586.                 );
  2587.                 return [
  2588.                     'etap' => $etap,
  2589.                     'success' => true
  2590.                 ];
  2591.             }
  2592.         }
  2593.         return [
  2594.             'success' => false
  2595.         ];
  2596.     }
  2597.     public function submitEtap16($request,$user)
  2598.     {
  2599.         $etapToken = $request->get('etapToken');
  2600.         $tokenProject = $request->get('tokenProject');
  2601.         $contratConstruction = $request->get('contratConstruction');
  2602.         if($etapToken and $tokenProject){
  2603.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  2604.             $etap = $this->em->getRepository(Etap16::class)->findOneBy(['token'=>$etapToken]);
  2605.             if($project && $etap){
  2606.                 if(!$this->checkUserAction($user,$project,$etap)){
  2607.                     return [
  2608.                         'success' => false
  2609.                     ];
  2610.                 }
  2611.                 if($contratConstruction){
  2612.                     foreach ($contratConstruction as $itemContratConstruction){
  2613.                         if(isset($itemContratConstruction['id']) and $itemContratConstruction['id'] != ''){
  2614.                             $contratConstructionEntity = $this->em->getRepository(ContratConstruction::class)->findOneBy(['token'=>$itemContratConstruction['id']]) ;
  2615.                         }else{
  2616.                             $contratConstructionEntity = new ContratConstruction() ;
  2617.                         }
  2618.                         $contratConstructionEntity->setEtap16($etap);
  2619.                         $this->em->persist($contratConstructionEntity);
  2620.                         $this->em->flush();
  2621.                         if(isset($itemContratConstruction['fileContratEpcMultiple']) and $itemContratConstruction['fileContratEpcMultiple'] != ''){
  2622.                             $array = explode(',',$itemContratConstruction['fileContratEpcMultiple']);
  2623.                             foreach ($array as $item){
  2624.                                 $fileContratEpcMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2625.                                 if(isset($itemContratConstruction['nameContrat'])  && $contratConstructionEntity->getTitre() == 'Contrat lot Bâtiment'){
  2626.                                     $nomenclature = $this->getNomenclatureContratConstruction($etap,$fileContratEpcMultipleEntity,'Contrat lot Bâtiment',$itemContratConstruction['nameContrat']);
  2627.                                 }elseif (isset($itemContratConstruction['nameContrat'])  && $contratConstructionEntity->getTitre() == 'Contrat lot PV'){
  2628.                                     $nomenclature = $this->getNomenclatureContratConstruction($etap,$fileContratEpcMultipleEntity,'Contrat lot PV',$itemContratConstruction['nameContrat']);
  2629.                                 }elseif (isset($itemContratConstruction['nameContrat'])  && $contratConstructionEntity->getTitre() == 'Contrat EPC'){
  2630.                                     $nomenclature = $this->getNomenclatureContratConstruction($etap,$fileContratEpcMultipleEntity,'Contrat EPC',$itemContratConstruction['nameContrat']);
  2631.                                 }else{
  2632.                                     $nomenclature = $this->getNomenclature($etap,$fileContratEpcMultipleEntity,'Contrat de construction');
  2633.                                 }
  2634.                                 $contratConstructionEntity->addFileContratEpcMultiple($fileContratEpcMultipleEntity);
  2635.                                 $this->uploadFileToDropbox($fileContratEpcMultipleEntity,$project,"Contrats de development et construction/".$fileContratEpcMultipleEntity->getId().$nomenclature);
  2636.                             }
  2637.                         }
  2638.                         if(isset($itemContratConstruction['fileDemandeAgrementMultiple']) and $itemContratConstruction['fileDemandeAgrementMultiple'] != ''){
  2639.                             $array = explode(',',$itemContratConstruction['fileDemandeAgrementMultiple']);
  2640.                             foreach ($array as $item){
  2641.                                 $fileDemandeAgrementMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2642.                                 $nomenclature = $this->getNomenclature($etap,$fileDemandeAgrementMultipleEntity,'Demande d’Agrément');
  2643.                                 $contratConstructionEntity->addFileDemandeAgrementMultiple($fileDemandeAgrementMultipleEntity);
  2644.                                 $this->uploadFileToDropbox($fileDemandeAgrementMultipleEntity,$project,"Contrats de development et construction/".$fileDemandeAgrementMultipleEntity->getId().$nomenclature);
  2645.                             }
  2646.                         }
  2647.                         if(isset($itemContratConstruction['fileAnnexesMultiple']) and $itemContratConstruction['fileAnnexesMultiple'] != ''){
  2648.                             $array = explode(',',$itemContratConstruction['fileAnnexesMultiple']);
  2649.                             foreach ($array as $item){
  2650.                                 $fileAnnexesMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2651.                                 $nomenclature = $this->getNomenclature($etap,$fileAnnexesMultipleEntity,'Annexes (fiches techniques…)');
  2652.                                 $contratConstructionEntity->addFileAnnexesMultiple($fileAnnexesMultipleEntity);
  2653.                                 $this->uploadFileToDropbox($fileAnnexesMultipleEntity,$project,"Contrats de development et construction/".$fileAnnexesMultipleEntity->getId().$nomenclature);
  2654.                             }
  2655.                         }
  2656.                         if(isset($itemContratConstruction['prixEpc']) and $itemContratConstruction['prixEpc'] != ''){
  2657.                             $contratConstructionEntity->setPrixEpc($itemContratConstruction['prixEpc']);
  2658.                         }else {
  2659.                             $contratConstructionEntity->setPrixEpc(null);
  2660.                         }
  2661.                         if(isset($itemContratConstruction['nameContrat']) and $itemContratConstruction['nameContrat'] != ''){
  2662.                             $contratConstructionEntity->setNameContrat($itemContratConstruction['nameContrat']);
  2663.                         }else {
  2664.                             $contratConstructionEntity->setNameContrat(null);
  2665.                         }
  2666.                         if(isset($itemContratConstruction['fournisseurSelected']) and $itemContratConstruction['fournisseurSelected'] != 0){
  2667.                             $fournisseur = $this->em->getRepository(Fournisseur::class)->find($itemContratConstruction['fournisseurSelected']);
  2668.                             if($fournisseur){
  2669.                                 $contratConstructionEntity->setFournisseur($fournisseur);
  2670.                             }else{
  2671.                                 $contratConstructionEntity->setFournisseur(null);
  2672.                             }
  2673.                         }else {
  2674.                             $contratConstructionEntity->setFournisseur(null);
  2675.                         }
  2676.                         if(isset($itemContratConstruction['jalonsPaiement']) and $itemContratConstruction['jalonsPaiement']){
  2677.                             foreach ($itemContratConstruction['jalonsPaiement'] as $value){
  2678.                                 if(isset($value['id'])&& !empty($value['id'])){
  2679.                                     $jalonsPaiementEntity = $this->em->getRepository(JalonPaiementContratConstruction::class)->find($value['id']);
  2680.                                     if($jalonsPaiementEntity){
  2681.                                         $jalonsPaiementEntity->setNomJalonsPaiement($value['nomJalonsPaiement']);
  2682.                                         $jalonsPaiementEntity->setPourcentJalonsPaiement($value['pourcentJalonsPaiement']);
  2683.                                         $jalonsPaiementEntity->setContratConstruction($contratConstructionEntity);
  2684.                                         $this->em->persist($jalonsPaiementEntity);
  2685.                                         $this->em->flush();
  2686.                                     }
  2687.                                 }else{
  2688.                                     $jalonsPaiementEntity = new JalonPaiementContratConstruction();
  2689.                                     $jalonsPaiementEntity->setNomJalonsPaiement($value['nomJalonsPaiement']);
  2690.                                     $jalonsPaiementEntity->setPourcentJalonsPaiement($value['pourcentJalonsPaiement']);
  2691.                                     $jalonsPaiementEntity->setContratConstruction($contratConstructionEntity);
  2692.                                     $this->em->persist($jalonsPaiementEntity);
  2693.                                     $this->em->flush();
  2694.                                 }
  2695.                             }
  2696.                         }
  2697.                         if(isset($itemContratConstruction['prixAnnexe']) and  $itemContratConstruction['prixAnnexe']){
  2698.                             foreach ($itemContratConstruction['prixAnnexe'] as $value){
  2699.                                 if(isset($value['id'])&& !empty($value['id'])){
  2700.                                     $prixAnnexeEntity = $this->em->getRepository(PrixAnnexeContratConstruction::class)->find($value['id']);
  2701.                                     if($prixAnnexeEntity){
  2702.                                         $prixAnnexeEntity->setNom(isset($value['nomPrixAnnexe'])?$value['nomPrixAnnexe']:null);
  2703.                                         $prixAnnexeEntity->setPrix(isset($value['prixPrixAnnexe'])?$value['prixPrixAnnexe']:null);
  2704.                                         $prixAnnexeEntity->setContratConstruction($contratConstructionEntity);
  2705.                                         $this->em->persist($prixAnnexeEntity);
  2706.                                         $this->em->flush();
  2707.                                     }
  2708.                                 }else{
  2709.                                     $prixAnnexeEntity = new PrixAnnexeContratConstruction();
  2710.                                     $prixAnnexeEntity->setNom(isset($value['nomPrixAnnexe'])?$value['nomPrixAnnexe']:null);
  2711.                                     $prixAnnexeEntity->setPrix(isset($value['prixPrixAnnexe'])?$value['prixPrixAnnexe']:null);
  2712.                                     $prixAnnexeEntity->setContratConstruction($contratConstructionEntity);
  2713.                                     $this->em->persist($prixAnnexeEntity);
  2714.                                     $this->em->flush();
  2715.                                 }
  2716.                             }
  2717.                         }
  2718.                         $contratConstructionEntity->setEtap16($etap);
  2719.                         $this->em->persist($contratConstructionEntity);
  2720.                         $this->em->flush();
  2721.                     }
  2722.                 }
  2723.                 $this->em->persist($etap);
  2724.                 $this->em->flush();
  2725.                 $this->updateStatusTracker($project); // set status tracker
  2726.                 $this->flashBag->add(
  2727.                     'success',
  2728.                     'L\'opération a Ã©té effectuée avec succès.'
  2729.                 );
  2730.                 return [
  2731.                     'etap' => $etap,
  2732.                     'success' => true
  2733.                 ];
  2734.             }
  2735.         }
  2736.         return [
  2737.             'success' => false
  2738.         ];
  2739.     }
  2740.     public function addOrUpdateCategory($categorys,$setEtap,$etap,$project){
  2741.         if($categorys){
  2742.             foreach ($categorys as $item){
  2743.                 if(isset($item['id'])&& !empty($item['id'])){
  2744.                     $categorysEntity = $this->em->getRepository(CategoryDocument::class)->find($item['id']);
  2745.                     if($categorysEntity){
  2746.                         $categorysEntity->setName($item['nomCategorys']);
  2747.                         $categorysEntity->{$setEtap}($etap);
  2748.                         $this->em->persist($categorysEntity);
  2749.                         $this->em->flush();
  2750.                     }
  2751.                 }else{
  2752.                     $categorysEntity = new CategoryDocument();
  2753.                     $categorysEntity->setName($item['nomCategorys']);
  2754.                     $categorysEntity->{$setEtap}($etap);
  2755.                     $this->em->persist($categorysEntity);
  2756.                     $this->em->flush();
  2757.                 }
  2758.                 if(isset($item['documents'])){
  2759.                     foreach ($item['documents'] as $document){
  2760.                         if(isset($document['id'])&& !empty($document['id'])){
  2761.                             $documentEntity = $this->em->getRepository(Document::class)->find($document['id']);
  2762.                             if($documentEntity){
  2763.                                 if(isset($document['nomDocument']) && !empty($document['nomDocument'])) {
  2764.                                     $documentEntity->setName($document['nomDocument']);
  2765.                                     $documentEntity->setCategory($categorysEntity);
  2766.                                     if (isset($document['fileToken']) && !empty($document['fileToken'])) {
  2767.                                         $doc = $this->em->getRepository(DocUpload::class)->findOneBy(['token' => $document['fileToken']]);
  2768.                                         $documentEntity->setDocUpload($doc);
  2769.                                         $nomenclature = $this->getNomenclature($etap, $doc, $document['nomDocument']);
  2770.                                         $this->uploadFileToDropbox($doc, $project, "Contrats de development et construction/" . $nomenclature);
  2771.                                     }
  2772.                                     $this->em->persist($documentEntity);
  2773.                                     $this->em->flush();
  2774.                                 }
  2775.                             }
  2776.                         }else{
  2777.                             if(isset($document['nomDocument']) && !empty($document['nomDocument'])){
  2778.                                 $documentEntity = new Document();
  2779.                                 if($documentEntity){
  2780.                                     $documentEntity->setName($document['nomDocument']);
  2781.                                     $documentEntity->setCategory($categorysEntity);
  2782.                                     if(isset($document['fileToken'])&& !empty($document['fileToken'])){
  2783.                                         $doc = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$document['fileToken']]);
  2784.                                         $documentEntity->setDocUpload($doc);
  2785.                                         $nomenclature =  $this->getNomenclature($etap,$doc,$document['nomDocument']);
  2786.                                         $this->uploadFileToDropbox($doc,$project,"Contrats de development et construction/".$nomenclature);
  2787.                                     }
  2788.                                     $this->em->persist($documentEntity);
  2789.                                     $this->em->flush();
  2790.                                 }
  2791.                             }
  2792.                         }
  2793.                     }
  2794.                 }
  2795.             }
  2796.         }
  2797.     }
  2798.     public function submitEtap160($request,$user)
  2799.     {
  2800.         $biPenteAsymetrique = $request->get('biPenteAsymetrique');
  2801.         $biPenteSymetrique = $request->get('biPenteSymetrique');
  2802.         $lat = $request->get('lat');
  2803.         $longi = $request->get('longi');
  2804.         $moduleInformation = $request->get('moduleInformation');
  2805.         $onduleurInformation = $request->get('onduleurInformation');
  2806.         $dimension = $request->get('dimension');
  2807.         $toiture = $request->get('toiture');
  2808.         $fileDiagnostiqueCharpenteMultiple = $request->get('fileDiagnostiqueCharpenteMultiple');
  2809.         $fileNoticesHydrauliquesMultiple = $request->get('fileNoticesHydrauliquesMultiple');
  2810.         $fileEtudeSoleMultiple = $request->get('fileEtudeSoleMultiple');
  2811.         $fileEvaluationCarboneModuleMultiple = $request->get('fileEvaluationCarboneModuleMultiple');
  2812.         $fileFicheTechniqueModuleMultiple = $request->get('fileFicheTechniqueModuleMultiple');
  2813.         $fileFicheTechniqueOnduleurMultiple = $request->get('fileFicheTechniqueOnduleurMultiple');
  2814.         $fileAttestationBrigageOnduleurMultiple = $request->get('fileAttestationBrigageOnduleurMultiple');
  2815.         $fileFicheGarantiOnduleurMultiple = $request->get('fileFicheGarantiOnduleurMultiple');
  2816.         $fileFicheSystemeIntegrationMultiple = $request->get('fileFicheSystemeIntegrationMultiple');
  2817.         $categorys = $request->get('categorys');
  2818.         $etapToken = $request->get('etapToken');
  2819.         $tokenProject = $request->get('tokenProject');
  2820.         if($etapToken and $tokenProject){
  2821.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  2822.             $etap = $this->em->getRepository(Etap160::class)->findOneBy(['token'=>$etapToken]);
  2823.             $etap159 = $this->em->getRepository(Etap159::class)->findOneBy(['token'=>$etapToken]);
  2824.             if($project && $etap){
  2825.                 if(!$this->checkUserAction($user,$project,$etap)){
  2826.                     return [
  2827.                         'success' => false
  2828.                     ];
  2829.                 }
  2830.                 $etap159 = $this->em->getRepository(Etap159::class)->findOneBy(['project'=>$project->getId()]);
  2831.                 if($fileDiagnostiqueCharpenteMultiple){
  2832.                     $array = explode(',',$fileDiagnostiqueCharpenteMultiple);
  2833.                     foreach ($array as $item){
  2834.                         $fileDiagnostiqueCharpenteMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2835.                         $nomenclature = $this->getNomenclature($etap,$fileDiagnostiqueCharpenteMultipleEntity,'Diagnostic charpente');
  2836.                         $etap->addFileDiagnostiqueCharpenteMultiple($fileDiagnostiqueCharpenteMultipleEntity);
  2837.                         $etap159->addFileDiagnostiqueCharpente159Multiple($fileDiagnostiqueCharpenteMultipleEntity);
  2838.                         $this->uploadFileToDropbox($fileDiagnostiqueCharpenteMultipleEntity,$project,"Contrats de development et construction/".$fileDiagnostiqueCharpenteMultipleEntity->getId().$nomenclature);
  2839.                     }
  2840.                     $this->em->persist($etap159);
  2841.                     $this->em->flush();
  2842.                 }
  2843.                 if($fileNoticesHydrauliquesMultiple){
  2844.                     $array = explode(',',$fileNoticesHydrauliquesMultiple);
  2845.                     foreach ($array as $item){
  2846.                         $fileNoticesHydrauliquesMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2847.                         $nomenclature = $this->getNomenclature($etap,$fileNoticesHydrauliquesMultipleEntity,'Notices hydrauliques ou Ã©tudes gestion eaux pluviales');
  2848.                         $etap->addFileNoticesHydrauliquesMultiple($fileNoticesHydrauliquesMultipleEntity);
  2849.                         $this->uploadFileToDropbox($fileNoticesHydrauliquesMultipleEntity,$project,"Contrats de development et construction/".$fileNoticesHydrauliquesMultipleEntity->getId().$nomenclature);
  2850.                     }
  2851.                     $this->em->persist($etap159);
  2852.                     $this->em->flush();
  2853.                 }
  2854.                 if($fileEtudeSoleMultiple){
  2855.                     $array = explode(',',$fileEtudeSoleMultiple);
  2856.                     foreach ($array as $item){
  2857.                         $fileEtudeSoleMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2858.                         $nomenclature = $this->getNomenclature($etap,$fileEtudeSoleMultipleEntity,'Étude de sol');
  2859.                         $etap->addFileEtudeSoleMultiple($fileEtudeSoleMultipleEntity);
  2860.                         $etap159->addFileGeotechnique159Multiple($fileEtudeSoleMultipleEntity);
  2861.                         $this->uploadFileToDropbox($fileEtudeSoleMultipleEntity,$project,"Contrats de development et construction/".$fileEtudeSoleMultipleEntity->getId().$nomenclature);
  2862.                     }
  2863.                 }
  2864.                 if($fileEvaluationCarboneModuleMultiple){
  2865.                     $array = explode(',',$fileEvaluationCarboneModuleMultiple);
  2866.                     foreach ($array as $item){
  2867.                         $fileEvaluationCarboneModuleMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2868.                         $nomenclature = $this->getNomenclature($etap,$fileEvaluationCarboneModuleMultipleEntity,'Evaluation carbone des modules ');
  2869.                         $etap->addFileEvaluationCarboneModuleMultiple($fileEvaluationCarboneModuleMultipleEntity);
  2870.                         $this->uploadFileToDropbox($fileEvaluationCarboneModuleMultipleEntity,$project,"Contrats de development et construction/".$fileEvaluationCarboneModuleMultipleEntity->getId().$nomenclature);
  2871.                     }
  2872.                 }
  2873.                 if($fileFicheTechniqueModuleMultiple){
  2874.                     $array = explode(',',$fileFicheTechniqueModuleMultiple);
  2875.                     foreach ($array as $item){
  2876.                         $fileFicheTechniqueModuleMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2877.                         $nomenclature = $this->getNomenclature($etap,$fileFicheTechniqueModuleMultipleEntity,'Fiche technique modules ');
  2878.                         $etap->addFileFicheTechniqueModuleMultiple($fileFicheTechniqueModuleMultipleEntity);
  2879.                         $this->uploadFileToDropbox($fileFicheTechniqueModuleMultipleEntity,$project,"Contrats de development et construction/".$fileFicheTechniqueModuleMultipleEntity->getId().$nomenclature);
  2880.                     }
  2881.                 }
  2882.                 if($fileFicheTechniqueOnduleurMultiple){
  2883.                     $array = explode(',',$fileFicheTechniqueOnduleurMultiple);
  2884.                     foreach ($array as $item){
  2885.                         $fileFicheTechniqueOnduleurMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2886.                         $nomenclature = $this->getNomenclature($etap,$fileFicheTechniqueOnduleurMultipleEntity,'Fiche technique onduleurs ');
  2887.                         $etap->addFileFicheTechniqueOnduleurMultiple($fileFicheTechniqueOnduleurMultipleEntity);
  2888.                         $this->uploadFileToDropbox($fileFicheTechniqueOnduleurMultipleEntity,$project,"Contrats de development et construction/".$fileFicheTechniqueOnduleurMultipleEntity->getId().$nomenclature);
  2889.                     }
  2890.                 }
  2891.                 if($fileAttestationBrigageOnduleurMultiple){
  2892.                     $array = explode(',',$fileAttestationBrigageOnduleurMultiple);
  2893.                     foreach ($array as $item){
  2894.                         $fileAttestationBrigageOnduleurMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2895.                         $nomenclature = $this->getNomenclature($etap,$fileAttestationBrigageOnduleurMultipleEntity,'Attestation de bridage  ');
  2896.                         $etap->addFileAttestationBrigageOnduleurMultiple($fileAttestationBrigageOnduleurMultipleEntity);
  2897.                         $this->uploadFileToDropbox($fileAttestationBrigageOnduleurMultipleEntity,$project,"Contrats de development et construction/".$fileAttestationBrigageOnduleurMultipleEntity->getId().$nomenclature);
  2898.                     }
  2899.                 }
  2900.                 if($fileFicheGarantiOnduleurMultiple){
  2901.                     $array = explode(',',$fileFicheGarantiOnduleurMultiple);
  2902.                     foreach ($array as $item){
  2903.                         $fileFicheGarantiOnduleurMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2904.                         $nomenclature = $this->getNomenclature($etap,$fileFicheGarantiOnduleurMultipleEntity,'Fiches de garantie onduleur');
  2905.                         $etap->addFileFicheGarantiOnduleurMultiple($fileFicheGarantiOnduleurMultipleEntity);
  2906.                         $this->uploadFileToDropbox($fileFicheGarantiOnduleurMultipleEntity,$project,"Contrats de development et construction/".$fileFicheGarantiOnduleurMultipleEntity->getId().$nomenclature);
  2907.                     }
  2908.                 }
  2909.                 if($fileFicheSystemeIntegrationMultiple){
  2910.                     $array = explode(',',$fileFicheSystemeIntegrationMultiple);
  2911.                     foreach ($array as $item){
  2912.                         $fileFicheSystemeIntegrationMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  2913.                         $nomenclature = $this->getNomenclature($etap,$fileFicheSystemeIntegrationMultipleEntity,'Fiche technique système d’intégration ');
  2914.                         $etap->addFileFicheSystemeIntegrationMultiple($fileFicheSystemeIntegrationMultipleEntity);
  2915.                         $this->uploadFileToDropbox($fileFicheSystemeIntegrationMultipleEntity,$project,"Contrats de development et construction/".$fileFicheSystemeIntegrationMultipleEntity->getId().$nomenclature);
  2916.                     }
  2917.                 }
  2918.                 if($moduleInformation){
  2919.                     foreach ($moduleInformation as $item){
  2920.                         if(isset($item['id'])&& !empty($item['id'])){
  2921.                             $moduleInformationEntity = $this->em->getRepository(ModuleInformation::class)->find($item['id']);
  2922.                             if($moduleInformationEntity){
  2923.                                 $moduleInformationEntity->setMarque($item['marqueModuleInformation']);
  2924.                                 $moduleInformationEntity->setReference($item['referenceModuleInformation']);
  2925.                                 $moduleInformationEntity->setPan($item['panModuleInformation']);
  2926.                                 $moduleInformationEntity->setNbr($item['nbrModuleInformation']);
  2927.                                 $moduleInformationEntity->setEtap160($etap);
  2928.                                 $this->em->persist($moduleInformationEntity);
  2929.                                 $this->em->flush();
  2930.                             }
  2931.                         }else{
  2932.                             $moduleInformationEntity = new ModuleInformation();
  2933.                             $moduleInformationEntity->setMarque($item['marqueModuleInformation']);
  2934.                             $moduleInformationEntity->setReference($item['referenceModuleInformation']);
  2935.                             $moduleInformationEntity->setPan($item['panModuleInformation']);
  2936.                             $moduleInformationEntity->setNbr($item['nbrModuleInformation']);
  2937.                             $moduleInformationEntity->setEtap160($etap);
  2938.                             $this->em->persist($moduleInformationEntity);
  2939.                             $this->em->flush();
  2940.                         }
  2941.                     }
  2942.                 }
  2943.                 if($onduleurInformation){
  2944.                     foreach ($onduleurInformation as $item){
  2945.                         if(isset($item['id'])&& !empty($item['id'])){
  2946.                             $onduleurInformationEntity = $this->em->getRepository(OnduleurInformation::class)->find($item['id']);
  2947.                             if($onduleurInformationEntity){
  2948.                                 $onduleurInformationEntity->setMarque($item['marqueOnduleurInformation']);
  2949.                                 $onduleurInformationEntity->setPuissance($item['puissanceOnduleurInformation']);
  2950.                                 $onduleurInformationEntity->setPan($item['panOnduleurInformation']);
  2951.                                 $onduleurInformationEntity->setNbr($item['nbrOnduleurInformation']);
  2952.                                 $onduleurInformationEntity->setEtap160($etap);
  2953.                                 $this->em->persist($onduleurInformationEntity);
  2954.                                 $this->em->flush();
  2955.                             }
  2956.                         }else{
  2957.                             $onduleurInformationEntity = new OnduleurInformation();
  2958.                             $onduleurInformationEntity->setMarque($item['marqueOnduleurInformation']);
  2959.                             $onduleurInformationEntity->setPuissance($item['puissanceOnduleurInformation']);
  2960.                             $onduleurInformationEntity->setPan($item['panOnduleurInformation']);
  2961.                             $onduleurInformationEntity->setNbr($item['nbrOnduleurInformation']);
  2962.                             $onduleurInformationEntity->setEtap160($etap);
  2963.                             $this->em->persist($onduleurInformationEntity);
  2964.                             $this->em->flush();
  2965.                         }
  2966.                     }
  2967.                 }
  2968.                 if($dimension){
  2969.                     foreach ($dimension as $item){
  2970.                         if(isset($item['id'])&& !empty($item['id'])){
  2971.                             $dimensionEntity = $this->em->getRepository(DimensionEtap160::class)->find($item['id']);
  2972.                             if($dimensionEntity){
  2973.                                 $dimensionEntity->setLargeur($item['largeurDimension']);
  2974.                                 $dimensionEntity->setLangueur($item['langueurDimension']);
  2975.                                 $dimensionEntity->setHauteurFaitage($item['hauteurFaitageDimension']);
  2976.                                 $dimensionEntity->setHauteurEgout($item['hauteurEgoutDimension']);
  2977.                                 $dimensionEntity->setPan($item['panDimension']);
  2978.                                 $dimensionEntity->setEtap160($etap);
  2979.                                 $this->em->persist($dimensionEntity);
  2980.                                 $this->em->flush();
  2981.                             }
  2982.                         }else{
  2983.                             $dimensionEntity = new DimensionEtap160();
  2984.                             $dimensionEntity->setLargeur($item['largeurDimension']);
  2985.                             $dimensionEntity->setLangueur($item['langueurDimension']);
  2986.                             $dimensionEntity->setHauteurFaitage($item['hauteurFaitageDimension']);
  2987.                             $dimensionEntity->setHauteurEgout($item['hauteurEgoutDimension']);
  2988.                             $dimensionEntity->setPan($item['panDimension']);
  2989.                             $dimensionEntity->setEtap160($etap);
  2990.                             $this->em->persist($dimensionEntity);
  2991.                             $this->em->flush();
  2992.                         }
  2993.                     }
  2994.                 }
  2995.                 if($toiture){
  2996.                     foreach ($toiture as $item){
  2997.                         if(isset($item['id'])&& !empty($item['id'])){
  2998.                             $toitureEntity = $this->em->getRepository(Toiture160::class)->find($item['id']);
  2999.                             if($toitureEntity){
  3000.                                 $toitureEntity->setTypeCouverture($item['typeCouvertureToiture']);
  3001.                                 $toitureEntity->setAngleToiture($item['angleToitureToiture']);
  3002.                                 $toitureEntity->setAzimutToiture($item['azimutToitureToiture']);
  3003.                                 $toitureEntity->setPan($item['panToiture']);
  3004.                                 $toitureEntity->setEtap160($etap);
  3005.                                 $this->em->persist($toitureEntity);
  3006.                                 $this->em->flush();
  3007.                             }
  3008.                         }else{
  3009.                             $toitureEntity = new Toiture160();
  3010.                             $toitureEntity->setTypeCouverture($item['typeCouvertureToiture']);
  3011.                             $toitureEntity->setAngleToiture($item['angleToitureToiture']);
  3012.                             $toitureEntity->setAzimutToiture($item['azimutToitureToiture']);
  3013.                             $toitureEntity->setPan($item['panToiture']);
  3014.                             $toitureEntity->setEtap160($etap);
  3015.                             $this->em->persist($toitureEntity);
  3016.                             $this->em->flush();
  3017.                         }
  3018.                     }
  3019.                 }
  3020.                 $this->addOrUpdateCategory($categorys,'setEtap160',$etap,$project);
  3021.                 $etap->setBiPenteAsymetrique($biPenteAsymetrique);
  3022.                 $etap->setBiPenteSymetrique($biPenteSymetrique);
  3023.                 $etap->setLat($lat);
  3024.                 $etap->setLongi($longi);
  3025.                 $project->setLat($longi);
  3026.                 $project->setLongi($lat);
  3027.                 $this->em->persist($etap);
  3028.                 $this->em->flush();
  3029.                 $this->updateStatusTracker($project); // set status tracker
  3030.                 $this->flashBag->add(
  3031.                     'success',
  3032.                     'L\'opération a Ã©té effectuée avec succès.'
  3033.                 );
  3034.                 return [
  3035.                     'etap' => $etap,
  3036.                     'success' => true
  3037.                 ];
  3038.             }
  3039.         }
  3040.         return [
  3041.             'success' => false
  3042.         ];
  3043.     }
  3044.     public function submitEtap161($request,$user)
  3045.     {
  3046.         $fileQualiPVInstallateurMultiple = $request->get('fileQualiPVInstallateurMultiple');
  3047.         $categorys = $request->get('categorys');
  3048.         $etapToken = $request->get('etapToken');
  3049.         $tokenProject = $request->get('tokenProject');
  3050.         if($etapToken and $tokenProject){
  3051.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3052.             $etap = $this->em->getRepository(Etap161::class)->findOneBy(['token'=>$etapToken]);
  3053.             if($project && $etap){
  3054.                 if(!$this->checkUserAction($user,$project,$etap)){
  3055.                     return [
  3056.                         'success' => false
  3057.                     ];
  3058.                 }
  3059.                 if($fileQualiPVInstallateurMultiple){
  3060.                     $array = explode(',',$fileQualiPVInstallateurMultiple);
  3061.                     foreach ($array as $item){
  3062.                         $fileQualiPVInstallateurMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3063.                         $nomenclature = $this->getNomenclature($etap,$fileQualiPVInstallateurMultipleEntity,'QualiPV de l’installateur');
  3064.                         $etap->addFileQualiPVInstallateurMultiple($fileQualiPVInstallateurMultipleEntity);
  3065.                         $this->uploadFileToDropbox($fileQualiPVInstallateurMultipleEntity,$project,"Raccordement ENEDIS/".$fileQualiPVInstallateurMultipleEntity->getId().$nomenclature);
  3066.                     }
  3067.                 }
  3068.                 $this->addOrUpdateCategory($categorys,'setEtap161',$etap,$project);
  3069.                 $this->em->persist($etap);
  3070.                 $this->em->flush();
  3071.                 $this->updateStatusTracker($project); // set status tracker
  3072.                 $this->flashBag->add(
  3073.                     'success',
  3074.                     'L\'opération a Ã©té effectuée avec succès.'
  3075.                 );
  3076.                 return [
  3077.                     'etap' => $etap,
  3078.                     'success' => true
  3079.                 ];
  3080.             }
  3081.         }
  3082.         return [
  3083.             'success' => false
  3084.         ];
  3085.     }
  3086.     public function addEtap601()
  3087.     {
  3088.         $projects = $this->em->getRepository(Project::class)->findAll();
  3089.         foreach ($projects as $project){
  3090.             $etap6 = $this->em->getRepository(Etap6::class)->findOneBy(['project'=>$project->getId()]);
  3091.             $etap601 = $this->em->getRepository(Etap601::class)->findOneBy(['project'=>$project->getId()]);
  3092.             $etap = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_601]);
  3093.             if(!$etap601){
  3094.                 $etap601 = new Etap601();
  3095.                 $etap601->setProject($project);
  3096.                 $etap601->setEtap($etap);
  3097.                 if($etap6 && count($etap6->getFileEtatDecriptifMultiple()) > 0){
  3098.                     foreach ($etap6->getFileEtatDecriptifMultiple() as $item){
  3099.                         $etap601->addFileEtatDecriptifMultiple($item);
  3100.                     }
  3101.                 }
  3102.                 $etap601->setStatus(Etaps::STATUS_EN_COURS);
  3103.                 $this->em->persist($etap601);
  3104.                 $this->em->flush();
  3105.             }
  3106.         }
  3107.     }
  3108.     public function addEtap602()
  3109.     {
  3110.         $projects = $this->em->getRepository(Project::class)->findAll();
  3111.         foreach ($projects as $project){
  3112.             $etap6 = $this->em->getRepository(Etap6::class)->findOneBy(['project'=>$project->getId()]);
  3113.             $etap602 = $this->em->getRepository(Etap602::class)->findOneBy(['project'=>$project->getId()]);
  3114.             $etap = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_602]);
  3115.             if(!$etap602){
  3116.                 $etap602 = new Etap602();
  3117.                 $etap602->setProject($project);
  3118.                 $etap602->setEtap($etap);
  3119.                 if($etap6 && count($etap6->getFileProcurationBailleur()) > 0){
  3120.                     foreach ($etap6->getFileProcurationBailleur() as $item){
  3121.                         $etap602->addFileProcurationBailleur($item);
  3122.                     }
  3123.                 }
  3124.                 $etap602->setStatus(Etaps::STATUS_EN_COURS);
  3125.                 $this->em->persist($etap602);
  3126.                 $this->em->flush();
  3127.             }
  3128.         }
  3129.     }
  3130.     public function addEtap0()
  3131.     {
  3132.         $projects = $this->em->getRepository(Project::class)->findAll();
  3133.         foreach ($projects as $project){
  3134.             $etap0 = $this->em->getRepository(Etap0::class)->findOneBy(['project'=>$project->getId()]);
  3135.             $etap = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_0]);
  3136.             if(!$etap0){
  3137.                 $etap0 = new Etap0();
  3138.                 $etap0->setProject($project);
  3139.                 $etap0->setEtap($etap);
  3140.                 $etap0->setStatus(Etaps::STATUS_EN_COURS);
  3141.                 $this->em->persist($etap0);
  3142.                 $this->em->flush();
  3143.             }
  3144.         }
  3145.     }
  3146.     public function addEtap121()
  3147.     {
  3148.         $projects = $this->em->getRepository(Project::class)->findAll();
  3149.         foreach ($projects as $project){
  3150.             $etap121 = $this->em->getRepository(Etap121::class)->findOneBy(['project'=>$project->getId()]);
  3151.             $etap = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_121]);
  3152.             if(!$etap121){
  3153.                 $etap121 = new Etap121();
  3154.                 $etap121->setProject($project);
  3155.                 $etap121->setEtap($etap);
  3156.                 $etap121->setStatus(Etaps::STATUS_EN_COURS);
  3157.                 $this->em->persist($etap121);
  3158.                 $this->em->flush();
  3159.             }
  3160.         }
  3161.     }
  3162.     public function addEtap159()
  3163.     {
  3164.         $projects = $this->em->getRepository(Project::class)->findAll();
  3165.         foreach ($projects as $project){
  3166.             $etap159 = $this->em->getRepository(Etap159::class)->findOneBy(['project'=>$project->getId()]);
  3167.             $etap = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_159]);
  3168.             if(!$etap159){
  3169.                 $etap159 = new Etap159();
  3170.                 $etap159->setProject($project);
  3171.                 $etap159->setEtap($etap);
  3172.                 $etap159->setStatus(Etaps::STATUS_EN_COURS);
  3173.                 $this->em->persist($etap159);
  3174.                 $this->em->flush();
  3175.             }
  3176.         }
  3177.     }
  3178.     public function addEtap23()
  3179.     {
  3180.         $projects = $this->em->getRepository(Project::class)->findAll();
  3181.         foreach ($projects as $project){
  3182.             $etap23 = $this->em->getRepository(Etap23::class)->findOneBy(['project'=>$project->getId()]);
  3183.             $etap = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_23]);
  3184.             if(!$etap23){
  3185.                 $etap23 = new Etap23();
  3186.                 $etap23->setProject($project);
  3187.                 $etap23->setEtap($etap);
  3188.                 $etap23->setStatus(Etaps::STATUS_EN_COURS);
  3189.                 $this->em->persist($etap23);
  3190.                 $this->em->flush();
  3191.             }
  3192.         }
  3193.     }
  3194.     public function copyEtap16ToContratConstruction()
  3195.     {
  3196.         $projects = $this->em->getRepository(Project::class)->findAll();
  3197.         foreach ($projects as $project){
  3198.             $etap16 = $this->em->getRepository(Etap16::class)->findOneBy(['project'=>$project->getId()]);
  3199.             if($etap16 and count($etap16->getContratConstruction()) == 0){
  3200.                 $contratConstruction = new ContratConstruction();
  3201.                 $contratConstruction->setEtap16($etap16);
  3202.                 $contratConstruction->setPrixEpc($etap16->getPrixEpc());
  3203.                 $this->em->persist($contratConstruction);
  3204.                 $this->em->flush();
  3205.                 $fileContratEpcMultiples = $etap16->getFileContratEpcMultiple();
  3206.                 $fileAnnexesMultiple = $etap16->getFileAnnexesMultiple();
  3207.                 $jalonPaiements = $etap16->getJalonPaiement();
  3208.                 $prixAnnexes = $etap16->getPrixAnnexe();
  3209.                 if($fileAnnexesMultiple){
  3210.                     foreach ($fileAnnexesMultiple as $item){
  3211.                         $contratConstruction->addFileAnnexesMultiple($item);
  3212.                     }
  3213.                 }
  3214.                 if($fileContratEpcMultiples){
  3215.                     foreach ($fileContratEpcMultiples as $item){
  3216.                         $contratConstruction->addFileContratEpcMultiple($item);
  3217.                     }
  3218.                 }
  3219.                 if($jalonPaiements){
  3220.                     foreach ($jalonPaiements as $item){
  3221.                         $jalonPaiementEntity = new JalonPaiementContratConstruction();
  3222.                         $jalonPaiementEntity->setContratConstruction($contratConstruction);
  3223.                         $jalonPaiementEntity->setNomJalonsPaiement($item->getNomJalonsPaiement());
  3224.                         $jalonPaiementEntity->setPourcentJalonsPaiement($item->getPourcentJalonsPaiement());
  3225.                         $this->em->persist($jalonPaiementEntity);
  3226.                         $this->em->flush();
  3227.                     }
  3228.                 }
  3229.                 if($prixAnnexes){
  3230.                     foreach ($prixAnnexes as $item){
  3231.                         $prixAnnexeEntity = new PrixAnnexeContratConstruction();
  3232.                         $prixAnnexeEntity->setContratConstruction($contratConstruction);
  3233.                         $prixAnnexeEntity->setNom($item->getNom());
  3234.                         $prixAnnexeEntity->setPrix($item->getPrix());
  3235.                         $this->em->persist($prixAnnexeEntity);
  3236.                         $this->em->flush();
  3237.                     }
  3238.                 }
  3239.                 $this->em->persist($contratConstruction);
  3240.                 $this->em->flush();
  3241.             }
  3242.         }
  3243.     }
  3244.     public function submitEtap17($request,$user)
  3245.     {
  3246.         $filePlanExecution = $request->get('filePlanExecution');
  3247.         $fileDocumentGeometre = $request->get('fileDocumentGeometre');
  3248.         $etapToken = $request->get('etapToken');
  3249.         $tokenProject = $request->get('tokenProject');
  3250.         if($etapToken and $tokenProject){
  3251.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3252.             $etap = $this->em->getRepository(Etap17::class)->findOneBy(['token'=>$etapToken]);
  3253.             if($project && $etap){
  3254.                 if(!$this->checkUserAction($user,$project,$etap)){
  3255.                     return [
  3256.                         'success' => false
  3257.                     ];
  3258.                 }
  3259.                 if($filePlanExecution){
  3260.                     $array = explode(',',$filePlanExecution);
  3261.                     foreach ($array as $item){
  3262.                         $filePlanExecutionEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3263.                         $nomenclature =  $this->getNomenclature($etap,$filePlanExecutionEntity,'Plan exécution et Ã©tude de structure');
  3264.                         $etap->addFilePlanExecution($filePlanExecutionEntity);
  3265.                         $this->uploadFileToDropbox($filePlanExecutionEntity,$project,"Contrats de development et construction/".$filePlanExecutionEntity->getId().$nomenclature);
  3266.                     }
  3267.                 }
  3268.                 if($fileDocumentGeometre){
  3269.                     $array = explode(',',$fileDocumentGeometre);
  3270.                     foreach ($array as $item){
  3271.                         $fileDocumentGeometreEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3272.                         $nomenclature = $this->getNomenclature($etap,$fileDocumentGeometreEntity,'Documents de géomètre');
  3273.                         $etap->addFileDocumentGeometre($fileDocumentGeometreEntity);
  3274.                         $this->uploadFileToDropbox($fileDocumentGeometreEntity,$project,"Contrats de development et construction/".$fileDocumentGeometreEntity->getId().$nomenclature);
  3275.                     }
  3276.                 }
  3277.                 $this->em->persist($etap);
  3278.                 $this->em->flush();
  3279.                 $this->updateStatusTracker($project); // set status tracker
  3280.                 $this->flashBag->add(
  3281.                     'success',
  3282.                     'L\'opération a Ã©té effectuée avec succès.'
  3283.                 );
  3284.                 return [
  3285.                     'etap' => $etap,
  3286.                     'success' => true
  3287.                 ];
  3288.             }
  3289.         }
  3290.         return [
  3291.             'success' => false
  3292.         ];
  3293.     }
  3294.     public function submitEtap18($request,$user)
  3295.     {
  3296.         $filePhotosFondation = $request->get('filePhotosFondation');
  3297.         $dateFinDesFondation = $request->get('dateFinDesFondation');
  3298.         $etapToken = $request->get('etapToken');
  3299.         $tokenProject = $request->get('tokenProject');
  3300.         if($etapToken and $tokenProject){
  3301.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3302.             $etap = $this->em->getRepository(Etap18::class)->findOneBy(['token'=>$etapToken]);
  3303.             if($project && $etap){
  3304.                 if(!$this->checkUserAction($user,$project,$etap)){
  3305.                     return [
  3306.                         'success' => false
  3307.                     ];
  3308.                 }
  3309.                 if($filePhotosFondation){
  3310.                     $array = explode(',',$filePhotosFondation);
  3311.                     foreach ($array as $item){
  3312.                         $filePhotosFondationEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3313.                         $nomenclature =  $this->getNomenclature($etap,$filePhotosFondationEntity,'Photos des fondations');
  3314.                         $etap->addFilePhotosFondation($filePhotosFondationEntity);
  3315.                         $this->uploadFileToDropbox($filePhotosFondationEntity,$project,"Contrats de development et construction/".$filePhotosFondationEntity->getId().$nomenclature);
  3316.                     }
  3317.                 }
  3318.                 if($dateFinDesFondation){
  3319.                     $etap->setDateFinDesFondation(new \DateTime($dateFinDesFondation));
  3320.                 }else{
  3321.                     $etap->setDateFinDesFondation(null);
  3322.                 }
  3323.                 $this->em->persist($etap);
  3324.                 $this->em->flush();
  3325.                 $this->updateStatusTracker($project); // set status tracker
  3326.                 $this->flashBag->add(
  3327.                     'success',
  3328.                     'L\'opération a Ã©té effectuée avec succès.'
  3329.                 );
  3330.                 return [
  3331.                     'etap' => $etap,
  3332.                     'success' => true
  3333.                 ];
  3334.             }
  3335.         }
  3336.         return [
  3337.             'success' => false
  3338.         ];
  3339.     }
  3340.     public function submitEtap19($request,$user)
  3341.     {
  3342.         $filePhotosBatiment = $request->get('filePhotosBatiment');
  3343.         $dateFinBatiment = $request->get('dateFinBatiment');
  3344.         $datePosePv = $request->get('datePosePv');
  3345.         $etapToken = $request->get('etapToken');
  3346.         $tokenProject = $request->get('tokenProject');
  3347.         if($etapToken and $tokenProject){
  3348.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3349.             $etap = $this->em->getRepository(Etap19::class)->findOneBy(['token'=>$etapToken]);
  3350.             if($project && $etap){
  3351.                 if(!$this->checkUserAction($user,$project,$etap)){
  3352.                     return [
  3353.                         'success' => false
  3354.                     ];
  3355.                 }
  3356.                 if($filePhotosBatiment){
  3357.                     $filePhotosBatimentEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$filePhotosBatiment]);
  3358.                     $nomenclature = $this->getNomenclature($etap,$filePhotosBatimentEntity,'Photos du bâtiment');
  3359.                     $etap->setFilePhotosBatiment($filePhotosBatimentEntity);
  3360.                     $this->uploadFileToDropbox($filePhotosBatimentEntity,$project,"Contrats de development et construction/".$nomenclature);
  3361.                 }
  3362.                 if($dateFinBatiment){
  3363.                     $etap->setDateFinBatiment(new \DateTime($dateFinBatiment));
  3364.                 }else{
  3365.                     $etap->setDateFinBatiment(null);
  3366.                 }
  3367.                 if($datePosePv){
  3368.                     $etap->setDatePosePv(new \DateTime($datePosePv));
  3369.                 }else{
  3370.                     $etap->setDatePosePv(null);
  3371.                 }
  3372.                 $this->em->persist($etap);
  3373.                 $this->em->flush();
  3374.                 $this->updateStatusTracker($project); // set status tracker
  3375.                 $this->flashBag->add(
  3376.                     'success',
  3377.                     'L\'opération a Ã©té effectuée avec succès.'
  3378.                 );
  3379.                 return [
  3380.                     'etap' => $etap,
  3381.                     'success' => true
  3382.                 ];
  3383.             }
  3384.         }
  3385.         return [
  3386.             'success' => false
  3387.         ];
  3388.     }
  3389.     public function submitEtap20($request,$user)
  3390.     {
  3391.         $fileConsuelEtap20Multiple = $request->get('fileConsuelEtap20Multiple');
  3392.         $dateConsuelEtap20 = $request->get('dateConsuelEtap20');
  3393.         $etapToken = $request->get('etapToken');
  3394.         $tokenProject = $request->get('tokenProject');
  3395.         if($etapToken and $tokenProject){
  3396.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3397.             $etap = $this->em->getRepository(Etap20::class)->findOneBy(['token'=>$etapToken]);
  3398.             if($project && $etap){
  3399.                 $etap13 = $this->em->getRepository(Etap13::class)->findOneBy(['project'=>$project->getId()]);
  3400.                 if(!$this->checkUserAction($user,$project,$etap)){
  3401.                     return [
  3402.                         'success' => false
  3403.                     ];
  3404.                 }
  3405.                 if($fileConsuelEtap20Multiple){
  3406.                     $array = explode(',',$fileConsuelEtap20Multiple);
  3407.                     foreach ($array as $item){
  3408.                         $fileConsuelEtap20MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3409.                         $nomenclature = $this->getNomenclature($etap,$fileConsuelEtap20MultipleEntity,'Consuel');
  3410.                         $etap->addFileConsuelEtap20Multiple($fileConsuelEtap20MultipleEntity);
  3411.                         $etap13->addFileConsuelMultiple($fileConsuelEtap20MultipleEntity);
  3412.                         $this->uploadFileToDropbox($fileConsuelEtap20MultipleEntity,$project,"Contrats de development et construction/".$fileConsuelEtap20MultipleEntity->getId().$nomenclature);
  3413.                     }
  3414.                 }
  3415.                 if($dateConsuelEtap20){
  3416.                     $etap->setDateConsuelEtap20(new \DateTime($dateConsuelEtap20));
  3417.                     $etap13->setDateConsuel(new \DateTime($dateConsuelEtap20));
  3418.                 }else{
  3419.                     $etap->setDateConsuelEtap20(null);
  3420.                     $etap13->setDateConsuel(null);
  3421.                 }
  3422.                 $this->em->persist($etap);
  3423.                 $this->em->persist($etap13);
  3424.                 $this->em->flush();
  3425.                 $this->updateStatusTracker($project); // set status tracker
  3426.                 $this->flashBag->add(
  3427.                     'success',
  3428.                     'L\'opération a Ã©té effectuée avec succès.'
  3429.                 );
  3430.                 return [
  3431.                     'etap' => $etap,
  3432.                     'success' => true
  3433.                 ];
  3434.             }
  3435.         }
  3436.         return [
  3437.             'success' => false
  3438.         ];
  3439.     }
  3440.     public function submitEtap201($request,$user)
  3441.     {
  3442.         $fileDoeEtap201Multiple = $request->get('fileDoeEtap201Multiple');
  3443.         $etapToken = $request->get('etapToken');
  3444.         $tokenProject = $request->get('tokenProject');
  3445.         if($etapToken and $tokenProject){
  3446.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3447.             $etap = $this->em->getRepository(Etap201::class)->findOneBy(['token'=>$etapToken]);
  3448.             if($project && $etap){
  3449.                 if(!$this->checkUserAction($user,$project,$etap)){
  3450.                     return [
  3451.                         'success' => false
  3452.                     ];
  3453.                 }
  3454.                 if($fileDoeEtap201Multiple){
  3455.                     $array = explode(',',$fileDoeEtap201Multiple);
  3456.                     foreach ($array as $item){
  3457.                         $fileDoeEtap201MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3458.                         $nomenclature = $this->getNomenclature($etap,$fileDoeEtap201MultipleEntity,'DOE');
  3459.                         $etap->addFileDoeEtap201Multiple($fileDoeEtap201MultipleEntity);
  3460.                         $this->uploadFileToDropbox($fileDoeEtap201MultipleEntity,$project,"Contrats de development et construction/".$fileDoeEtap201MultipleEntity->getId().$nomenclature);
  3461.                     }
  3462.                 }
  3463.                 $this->em->persist($etap);
  3464.                 $this->em->flush();
  3465.                 $this->updateStatusTracker($project); // set status tracker
  3466.                 $this->flashBag->add(
  3467.                     'success',
  3468.                     'L\'opération a Ã©té effectuée avec succès.'
  3469.                 );
  3470.                 return [
  3471.                     'etap' => $etap,
  3472.                     'success' => true
  3473.                 ];
  3474.             }
  3475.         }
  3476.         return [
  3477.             'success' => false
  3478.         ];
  3479.     }
  3480.     public function submitEtap21($request,$user)
  3481.     {
  3482.         $fileTestReceptionMultiple = $request->get('fileTestReceptionMultiple');
  3483.         $dateRaccordement = $request->get('dateRaccordement');
  3484.         $dateMiseEnService = $request->get('dateMiseEnService');
  3485.         $etapToken = $request->get('etapToken');
  3486.         $tokenProject = $request->get('tokenProject');
  3487.         if($etapToken and $tokenProject){
  3488.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3489.             $etap = $this->em->getRepository(Etap21::class)->findOneBy(['token'=>$etapToken]);
  3490.             if($project && $etap){
  3491.                 $etap14 = $this->em->getRepository(Etap14::class)->findOneBy(['project'=>$project->getId()]);
  3492.                 if(!$this->checkUserAction($user,$project,$etap)){
  3493.                     return [
  3494.                         'success' => false
  3495.                     ];
  3496.                 }
  3497.                 if($fileTestReceptionMultiple){
  3498.                     $array = explode(',',$fileTestReceptionMultiple);
  3499.                     foreach ($array as $item){
  3500.                         $fileTestReceptionMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3501.                         $nomenclature = $this->getNomenclature($etap,$fileTestReceptionMultipleEntity,'tests de réception');
  3502.                         $etap->addFileTestReceptionMultiple($fileTestReceptionMultipleEntity);
  3503.                         $this->uploadFileToDropbox($fileTestReceptionMultipleEntity,$project,"Contrats de development et construction/".$fileTestReceptionMultipleEntity->getId().$nomenclature);
  3504.                     }
  3505.                 }
  3506.                 if($dateRaccordement){
  3507.                     $etap->setDateRaccordement(new \DateTime($dateRaccordement));
  3508.                 }else{
  3509.                     $etap->setDateRaccordement(null);
  3510.                 }
  3511.                 if($dateMiseEnService){
  3512.                     $etap->setDateMiseEnService(new \DateTime($dateMiseEnService));
  3513.                     $etap14->setDateMiseEnService(new \DateTime($dateMiseEnService));
  3514.                     $project->setDateMiseEnService(new \DateTime($dateMiseEnService));
  3515.                 }else{
  3516.                     $etap->setDateMiseEnService(null);
  3517.                     $etap14->setDateMiseEnService(null);
  3518.                     $project->setDateMiseEnService(null);
  3519.                 }
  3520.                 $this->em->persist($etap);
  3521.                 $this->em->flush();
  3522.                 $this->updateStatusTracker($project); // set status tracker
  3523.                 $this->flashBag->add(
  3524.                     'success',
  3525.                     'L\'opération a Ã©té effectuée avec succès.'
  3526.                 );
  3527.                 return [
  3528.                     'etap' => $etap,
  3529.                     'success' => true
  3530.                 ];
  3531.             }
  3532.         }
  3533.         return [
  3534.             'success' => false
  3535.         ];
  3536.     }
  3537.     public function submitEtap22($request,$user)
  3538.     {
  3539.         $fileTestPrMultiple = $request->get('fileTestPrMultiple');
  3540.         $etapToken = $request->get('etapToken');
  3541.         $tokenProject = $request->get('tokenProject');
  3542.         if($etapToken and $tokenProject){
  3543.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3544.             $etap = $this->em->getRepository(Etap22::class)->findOneBy(['token'=>$etapToken]);
  3545.             if($project && $etap){
  3546.                 if(!$this->checkUserAction($user,$project,$etap)){
  3547.                     return [
  3548.                         'success' => false
  3549.                     ];
  3550.                 }
  3551.                 if($fileTestPrMultiple){
  3552.                     $array = explode(',',$fileTestPrMultiple);
  3553.                     foreach ($array as $item){
  3554.                         $fileTestPrMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3555.                         $nomenclature = $this->getNomenclature($etap,$fileTestPrMultipleEntity,'Tests de PR');
  3556.                         $etap->addFileTestPrMultiple($fileTestPrMultipleEntity);
  3557.                         $this->uploadFileToDropbox($fileTestPrMultipleEntity,$project,"Contrats de development et construction/".$fileTestPrMultipleEntity->getId().$nomenclature);
  3558.                     }
  3559.                 }
  3560.                 $this->em->persist($etap);
  3561.                 $this->em->flush();
  3562.                 $this->updateStatusTracker($project); // set status tracker
  3563.                 $this->flashBag->add(
  3564.                     'success',
  3565.                     'L\'opération a Ã©té effectuée avec succès.'
  3566.                 );
  3567.                 return [
  3568.                     'etap' => $etap,
  3569.                     'success' => true
  3570.                 ];
  3571.             }
  3572.         }
  3573.         return [
  3574.             'success' => false
  3575.         ];
  3576.     }
  3577.     public function submitEtap171($request,$user)
  3578.     {
  3579.         $filePVDemarrageMultiple = $request->get('filePVDemarrageMultiple');
  3580.         $fileDocEtap171Multiple = $request->get('fileDocEtap171Multiple');
  3581.         $fileOrderServiceMultiple = $request->get('fileOrderServiceMultiple');
  3582.         $filePlanningPrevisionnelMultiple = $request->get('filePlanningPrevisionnelMultiple');
  3583.         $fileCheminAccesMultiple = $request->get('fileCheminAccesMultiple');
  3584.         $filePhotosPlateformeMultiple = $request->get('filePhotosPlateformeMultiple');
  3585.         $dateRealisationPlateforme = $request->get('dateRealisationPlateforme');
  3586.         $chemainAcces = $request->get('chemainAcces');
  3587.         $filePGCMultiple = $request->get('filePGCMultiple');
  3588.         $fileRapportVisiteSpsMultiple = $request->get('fileRapportVisiteSpsMultiple');
  3589.         $fileDIUOMultiple = $request->get('fileDIUOMultiple');
  3590.         $fileHarmonisationMultiple = $request->get('fileHarmonisationMultiple');
  3591.         $filePPSPSMultiple = $request->get('filePPSPSMultiple');
  3592.         $fileMissionLLEMultiple = $request->get('fileMissionLLEMultiple');
  3593.         $categorys = $request->get('categorys');
  3594.         $etapToken = $request->get('etapToken');
  3595.         $tokenProject = $request->get('tokenProject');
  3596.         if($etapToken and $tokenProject){
  3597.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3598.             $etap = $this->em->getRepository(Etap171::class)->findOneBy(['token'=>$etapToken]);
  3599.             if($project && $etap){
  3600.                 if(!$this->checkUserAction($user,$project,$etap)){
  3601.                     return [
  3602.                         'success' => false
  3603.                     ];
  3604.                 }
  3605.                 if($filePVDemarrageMultiple){
  3606.                     $array = explode(',',$filePVDemarrageMultiple);
  3607.                     foreach ($array as $item){
  3608.                         $filePVDemarrageMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3609.                        if($filePVDemarrageMultipleEntity){
  3610.                             $nomenclature = $this->getNomenclature($etap,$filePVDemarrageMultipleEntity,'PV de démarrage');
  3611.                             $etap->addFilePVDemarrageMultiple($filePVDemarrageMultipleEntity);
  3612.                             $this->uploadFileToDropbox($filePVDemarrageMultipleEntity,$project,"Contrats de development et construction/".$filePVDemarrageMultipleEntity->getId().$nomenclature);
  3613.                        }
  3614.                     }
  3615.                 }
  3616.                 if($fileDocEtap171Multiple){
  3617.                     $array = explode(',',$fileDocEtap171Multiple);
  3618.                     foreach ($array as $item){
  3619.                         $fileDocEtap171MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3620.                         if($fileDocEtap171MultipleEntity){
  3621.                            $nomenclature = $this->getNomenclature($etap,$fileDocEtap171MultipleEntity,'DOC');
  3622.                            $etap->addFileDocEtap171Multiple($fileDocEtap171MultipleEntity);
  3623.                            $this->uploadFileToDropbox($fileDocEtap171MultipleEntity,$project,"Contrats de development et construction/".$fileDocEtap171MultipleEntity->getId().$nomenclature);
  3624.                         }
  3625.                      }
  3626.                 }
  3627.                 if($fileOrderServiceMultiple){
  3628.                     $array = explode(',',$fileOrderServiceMultiple);
  3629.                     foreach ($array as $item){
  3630.                         $fileOrderServiceMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3631.                         $nomenclature = $this->getNomenclature($etap,$fileOrderServiceMultipleEntity,'Ordre de service');
  3632.                         $etap->addFileOrderServiceMultiple($fileOrderServiceMultipleEntity);
  3633.                         $this->uploadFileToDropbox($fileOrderServiceMultipleEntity,$project,"Contrats de development et construction/".$fileOrderServiceMultipleEntity->getId().$nomenclature);
  3634.                     }
  3635.                 }
  3636.                 if($filePlanningPrevisionnelMultiple){
  3637.                     $array = explode(',',$filePlanningPrevisionnelMultiple);
  3638.                     foreach ($array as $item){
  3639.                         $filePlanningPrevisionnelMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3640.                         $nomenclature = $this->getNomenclature($etap,$filePlanningPrevisionnelMultipleEntity,'Planning prévisionnel');
  3641.                         $etap->addFilePlanningPrevisionnelMultiple($filePlanningPrevisionnelMultipleEntity);
  3642.                         $this->uploadFileToDropbox($filePlanningPrevisionnelMultipleEntity,$project,"Contrats de development et construction/".$filePlanningPrevisionnelMultipleEntity->getId().$nomenclature);
  3643.                     }
  3644.                 }
  3645.                 if($fileCheminAccesMultiple){
  3646.                     $array = explode(',',$fileCheminAccesMultiple);
  3647.                     foreach ($array as $item){
  3648.                         $fileCheminAccesMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3649.                         $nomenclature = $this->getNomenclature($etap,$fileCheminAccesMultipleEntity,'Chemin d’accès');
  3650.                         $etap->addFileCheminAccesMultiple($fileCheminAccesMultipleEntity);
  3651.                         $this->uploadFileToDropbox($fileCheminAccesMultipleEntity,$project,"Contrats de development et construction/".$fileCheminAccesMultipleEntity->getId().$nomenclature);
  3652.                     }
  3653.                 }
  3654.                 if($filePhotosPlateformeMultiple){
  3655.                     $array = explode(',',$filePhotosPlateformeMultiple);
  3656.                     foreach ($array as $item){
  3657.                         $filePhotosPlateformeMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3658.                         $nomenclature = $this->getNomenclature($etap,$filePhotosPlateformeMultipleEntity,'Photos de la plateforme');
  3659.                         $etap->addFilePhotosPlateformeMultiple($filePhotosPlateformeMultipleEntity);
  3660.                         $this->uploadFileToDropbox($filePhotosPlateformeMultipleEntity,$project,"Contrats de development et construction/".$filePhotosPlateformeMultipleEntity->getId().$nomenclature);
  3661.                     }
  3662.                 }
  3663.                 if($filePGCMultiple){
  3664.                     $array = explode(',',$filePGCMultiple);
  3665.                     foreach ($array as $item){
  3666.                         $filePGCMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3667.                         $nomenclature = $this->getNomenclature($etap,$filePGCMultipleEntity,'PGC ');
  3668.                         $etap->addFilePGCMultiple($filePGCMultipleEntity);
  3669.                         $this->uploadFileToDropbox($filePGCMultipleEntity,$project,"Contrats de development et construction/".$filePGCMultipleEntity->getId().$nomenclature);
  3670.                     }
  3671.                 }
  3672.                 if($fileRapportVisiteSpsMultiple){
  3673.                     $array = explode(',',$fileRapportVisiteSpsMultiple);
  3674.                     foreach ($array as $item){
  3675.                         $fileRapportVisiteSpsMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3676.                         $nomenclature = $this->getNomenclature($etap,$fileRapportVisiteSpsMultipleEntity,'Rapport de visite SPS ');
  3677.                         $etap->addFileRapportVisiteSpsMultiple($fileRapportVisiteSpsMultipleEntity);
  3678.                         $this->uploadFileToDropbox($fileRapportVisiteSpsMultipleEntity,$project,"Contrats de development et construction/".$fileRapportVisiteSpsMultipleEntity->getId().$nomenclature);
  3679.                     }
  3680.                 }
  3681.                 if($fileDIUOMultiple){
  3682.                     $array = explode(',',$fileDIUOMultiple);
  3683.                     foreach ($array as $item){
  3684.                         $fileDIUOMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3685.                         $nomenclature = $this->getNomenclature($etap,$fileDIUOMultipleEntity,'DIUO ');
  3686.                         $etap->addFileDIUOMultiple($fileDIUOMultipleEntity);
  3687.                         $this->uploadFileToDropbox($fileDIUOMultipleEntity,$project,"Contrats de development et construction/".$fileDIUOMultipleEntity->getId().$nomenclature);
  3688.                     }
  3689.                 }
  3690.                 if($fileHarmonisationMultiple){
  3691.                     $array = explode(',',$fileHarmonisationMultiple);
  3692.                     foreach ($array as $item){
  3693.                         $fileHarmonisationMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3694.                         $nomenclature = $this->getNomenclature($etap,$fileHarmonisationMultipleEntity,'Harmonisation ');
  3695.                         $etap->addFileHarmonisationMultiple($fileHarmonisationMultipleEntity);
  3696.                         $this->uploadFileToDropbox($fileHarmonisationMultipleEntity,$project,"Contrats de development et construction/".$fileHarmonisationMultipleEntity->getId().$nomenclature);
  3697.                     }
  3698.                 }
  3699.                 if($filePPSPSMultiple){
  3700.                     $array = explode(',',$filePPSPSMultiple);
  3701.                     foreach ($array as $item){
  3702.                         $filePPSPSMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3703.                         $nomenclature = $this->getNomenclature($etap,$filePPSPSMultipleEntity,'PPSPS ');
  3704.                         $etap->addFilePPSPSMultiple($filePPSPSMultipleEntity);
  3705.                         $this->uploadFileToDropbox($filePPSPSMultipleEntity,$project,"Contrats de development et construction/".$filePPSPSMultipleEntity->getId().$nomenclature);
  3706.                     }
  3707.                 }
  3708.                 if($fileMissionLLEMultiple){
  3709.                     $array = explode(',',$fileMissionLLEMultiple);
  3710.                     foreach ($array as $item){
  3711.                         $fileMissionLLEMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3712.                         $nomenclature = $this->getNomenclature($etap,$fileMissionLLEMultipleEntity,'Mission L / LE');
  3713.                         $etap->addFileMissionLLEMultiple($fileMissionLLEMultipleEntity);
  3714.                         $this->uploadFileToDropbox($fileMissionLLEMultipleEntity,$project,"Contrats de development et construction/".$fileMissionLLEMultipleEntity->getId().$nomenclature);
  3715.                     }
  3716.                 }
  3717.                 
  3718.                 if($dateRealisationPlateforme){
  3719.                     $etap->setDateRealisationPlateforme(new \DateTime($dateRealisationPlateforme));
  3720.                 }else{
  3721.                     $etap->setDateRealisationPlateforme(null);
  3722.                 }
  3723.                 $etap->setChemainAcces($chemainAcces);
  3724.                 $this->addOrUpdateCategory($categorys,'setEtap171',$etap,$project);
  3725.                 $this->em->persist($etap);
  3726.                 $this->em->flush();
  3727.                 $this->updateStatusTracker($project); // set status tracker
  3728.                 $this->flashBag->add(
  3729.                     'success',
  3730.                     'L\'opération a Ã©té effectuée avec succès.'
  3731.                 );
  3732.                 return [
  3733.                     'etap' => $etap,
  3734.                     'success' => true
  3735.                 ];
  3736.             }
  3737.         }
  3738.         return [
  3739.             'success' => false
  3740.         ];
  3741.     }
  3742.     public function submitEtap172($request,$user)
  3743.     {
  3744.         $fileNoteCalculBetonFeraillageMultiple = $request->get('fileNoteCalculBetonFeraillageMultiple');
  3745.         $filePlanImplantationBatimentAvecDalleBetonMultiple = $request->get('filePlanImplantationBatimentAvecDalleBetonMultiple');
  3746.         $filePVReceptionMultiple = $request->get('filePVReceptionMultiple');
  3747.         $fileFondationTermineesMultiple = $request->get('fileFondationTermineesMultiple');
  3748.         $fileDalleBetonShelterMultiple = $request->get('fileDalleBetonShelterMultiple');
  3749.         $fileCheminAccesMultiple = $request->get('fileCheminAccesMultiple');
  3750.         $filePhotosPlateformeMultiple = $request->get('filePhotosPlateformeMultiple');
  3751.         $dateDebutFondationEtap = $request->get('dateDebutFondationEtap');
  3752.         $categorys = $request->get('categorys');
  3753.         $etapToken = $request->get('etapToken');
  3754.         $tokenProject = $request->get('tokenProject');
  3755.         if($etapToken and $tokenProject){
  3756.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3757.             $etap = $this->em->getRepository(Etap172::class)->findOneBy(['token'=>$etapToken]);
  3758.             if($project && $etap){
  3759.                 if(!$this->checkUserAction($user,$project,$etap)){
  3760.                     return [
  3761.                         'success' => false
  3762.                     ];
  3763.                 }
  3764.                 if($fileNoteCalculBetonFeraillageMultiple){
  3765.                     $array = explode(',',$fileNoteCalculBetonFeraillageMultiple);
  3766.                     foreach ($array as $item){
  3767.                         $fileNoteCalculBetonFeraillageMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3768.                         $nomenclature = $this->getNomenclature($etap,$fileNoteCalculBetonFeraillageMultipleEntity,'Note de calcul béton et féraillage');
  3769.                         $etap->addFileNoteCalculBetonFeraillageMultiple($fileNoteCalculBetonFeraillageMultipleEntity);
  3770.                         $this->uploadFileToDropbox($fileNoteCalculBetonFeraillageMultipleEntity,$project,"Contrats de development et construction/".$fileNoteCalculBetonFeraillageMultipleEntity->getId().$nomenclature);
  3771.                     }
  3772.                 }
  3773.                 if($filePlanImplantationBatimentAvecDalleBetonMultiple){
  3774.                     $array = explode(',',$filePlanImplantationBatimentAvecDalleBetonMultiple);
  3775.                     foreach ($array as $item){
  3776.                         $filePlanImplantationBatimentAvecDalleBetonMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3777.                         $nomenclature = $this->getNomenclature($etap,$filePlanImplantationBatimentAvecDalleBetonMultipleEntity,'Plan implantation bâtiment avec dalle béton du local onduleur');
  3778.                         $etap->addFilePlanImplantationBatimentAvecDalleBetonMultiple($filePlanImplantationBatimentAvecDalleBetonMultipleEntity);
  3779.                         $this->uploadFileToDropbox($filePlanImplantationBatimentAvecDalleBetonMultipleEntity,$project,"Contrats de development et construction/".$filePlanImplantationBatimentAvecDalleBetonMultipleEntity->getId().$nomenclature);
  3780.                     }
  3781.                 }
  3782.                 if($filePVReceptionMultiple){
  3783.                     $array = explode(',',$filePVReceptionMultiple);
  3784.                     foreach ($array as $item){
  3785.                         $filePVReceptionMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3786.                         $nomenclature = $this->getNomenclature($etap,$filePVReceptionMultipleEntity,'PV de réception');
  3787.                         $etap->addFilePVReceptionMultiple($filePVReceptionMultipleEntity);
  3788.                         $this->uploadFileToDropbox($filePVReceptionMultipleEntity,$project,"Contrats de development et construction/".$filePVReceptionMultipleEntity->getId().$nomenclature);
  3789.                     }
  3790.                 }
  3791.                 if($fileFondationTermineesMultiple){
  3792.                     $array = explode(',',$fileFondationTermineesMultiple);
  3793.                     foreach ($array as $item){
  3794.                         $fileFondationTermineesMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3795.                         $nomenclature = $this->getNomenclature($etap,$fileFondationTermineesMultipleEntity,'Fondations terminées');
  3796.                         $etap->addFileFondationTermineesMultiple($fileFondationTermineesMultipleEntity);
  3797.                         $this->uploadFileToDropbox($fileFondationTermineesMultipleEntity,$project,"Contrats de development et construction/".$fileFondationTermineesMultipleEntity->getId().$nomenclature);
  3798.                     }
  3799.                 }
  3800.                 if($fileDalleBetonShelterMultiple){
  3801.                     $array = explode(',',$fileDalleBetonShelterMultiple);
  3802.                     foreach ($array as $item){
  3803.                         $fileDalleBetonShelterMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3804.                         $nomenclature = $this->getNomenclature($etap,$fileDalleBetonShelterMultipleEntity,'Dalle béton shelter');
  3805.                         $etap->addFileDalleBetonShelterMultiple($fileDalleBetonShelterMultipleEntity);
  3806.                         $this->uploadFileToDropbox($fileDalleBetonShelterMultipleEntity,$project,"Contrats de development et construction/".$fileDalleBetonShelterMultipleEntity->getId().$nomenclature);
  3807.                     }
  3808.                 }
  3809.                 if($fileCheminAccesMultiple){
  3810.                     $array = explode(',',$fileCheminAccesMultiple);
  3811.                     foreach ($array as $item){
  3812.                         $fileCheminAccesMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3813.                         $nomenclature = $this->getNomenclature($etap,$fileCheminAccesMultipleEntity,'Chemin d’accès');
  3814.                         $etap->addFileCheminAccesMultiple($fileCheminAccesMultipleEntity);
  3815.                         $this->uploadFileToDropbox($fileCheminAccesMultipleEntity,$project,"Contrats de development et construction/".$fileCheminAccesMultipleEntity->getId().$nomenclature);
  3816.                     }
  3817.                 }
  3818.                 if($filePhotosPlateformeMultiple){
  3819.                     $array = explode(',',$filePhotosPlateformeMultiple);
  3820.                     foreach ($array as $item){
  3821.                         $filePhotosPlateformeMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3822.                         $nomenclature = $this->getNomenclature($etap,$filePhotosPlateformeMultipleEntity,'Photos de la plateforme');
  3823.                         $etap->addFilePhotosPlateformeMultiple($filePhotosPlateformeMultipleEntity);
  3824.                         $this->uploadFileToDropbox($filePhotosPlateformeMultipleEntity,$project,"Contrats de development et construction/".$filePhotosPlateformeMultipleEntity->getId().$nomenclature);
  3825.                     }
  3826.                 }
  3827.                 if($dateDebutFondationEtap){
  3828.                     $etap->setDateDebutFondation(new \DateTime($dateDebutFondationEtap));
  3829.                 }else{
  3830.                     $etap->setDateDebutFondation(null);
  3831.                 }
  3832.                 $this->addOrUpdateCategory($categorys,'setEtap172',$etap,$project);
  3833.                 $this->em->persist($etap);
  3834.                 $this->em->flush();
  3835.                 $this->updateStatusTracker($project); // set status tracker
  3836.                 $this->flashBag->add(
  3837.                     'success',
  3838.                     'L\'opération a Ã©té effectuée avec succès.'
  3839.                 );
  3840.                 return [
  3841.                     'etap' => $etap,
  3842.                     'success' => true
  3843.                 ];
  3844.             }
  3845.         }
  3846.         return [
  3847.             'success' => false
  3848.         ];
  3849.     }
  3850.     public function submitEtap173($request,$user)
  3851.     {
  3852.         $fileNoteCalculCharpente173Multiple = $request->get('fileNoteCalculCharpente173Multiple');
  3853.         $filePhotoRenforcementcharpente173Multiple = $request->get('filePhotoRenforcementcharpente173Multiple');
  3854.         $fileOssatureSecondaireBardage173Multiple = $request->get('fileOssatureSecondaireBardage173Multiple');
  3855.         $filePhotoRenforcementBardage173Multiple = $request->get('filePhotoRenforcementBardage173Multiple');
  3856.         $filePVreception173Multiple = $request->get('filePVreception173Multiple');
  3857.         $filePhotoRenforcementCouvertureTermine173Multiple = $request->get('filePhotoRenforcementCouvertureTermine173Multiple');
  3858.         $filePlansCharpente173Multiple = $request->get('filePlansCharpente173Multiple');
  3859.         $filePlansCharpente173SigneMultiple = $request->get('filePlansCharpente173SigneMultiple');
  3860.         $fileVues3d173Multiple = $request->get('fileVues3d173Multiple');
  3861.         $filePlanCouverture173Multiple = $request->get('filePlanCouverture173Multiple');
  3862.         $filePlanDescriptionTravauxRenforcementCharpente173Multiple = $request->get('filePlanDescriptionTravauxRenforcementCharpente173Multiple');
  3863.         $filePlanDescriptionTravauxDeposeCouverture173Multiple = $request->get('filePlanDescriptionTravauxDeposeCouverture173Multiple');
  3864.         $categorys = $request->get('categorys');
  3865.         $etapToken = $request->get('etapToken');
  3866.         $tokenProject = $request->get('tokenProject');
  3867.         $debutCharpenteEtap = $request->get('debutCharpenteEtap');
  3868.         $finCharpenteEtap = $request->get('finCharpenteEtap');
  3869.         $debutCouvertureEtap = $request->get('debutCouvertureEtap');
  3870.         $finCouvertureEtap = $request->get('finCouvertureEtap');
  3871.         if($etapToken and $tokenProject){
  3872.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  3873.             $etap = $this->em->getRepository(Etap173::class)->findOneBy(['token'=>$etapToken]);
  3874.             if($project && $etap){
  3875.                 if(!$this->checkUserAction($user,$project,$etap)){
  3876.                     return [
  3877.                         'success' => false
  3878.                     ];
  3879.                 }
  3880.                 if($debutCharpenteEtap){
  3881.                     $etap->setDateDebutCharpente(new \DateTime($debutCharpenteEtap));
  3882.                 }else{
  3883.                     $etap->setDateDebutCharpente(null);
  3884.                 }
  3885.                 if($finCharpenteEtap){
  3886.                     $etap->setDateFinCharpente(new \DateTime($finCharpenteEtap));
  3887.                 }else{
  3888.                     $etap->setDateFinCharpente(null);
  3889.                 }
  3890.                 if($debutCouvertureEtap){
  3891.                     $etap->setDateDebutCouverture(new \DateTime($debutCouvertureEtap));
  3892.                 }else{
  3893.                     $etap->setDateDebutCouverture(null);
  3894.                 }
  3895.                 if($finCouvertureEtap){
  3896.                     $etap->setDateFinCouverture(new \DateTime($finCouvertureEtap));
  3897.                 }else{
  3898.                     $etap->setDateFinCouverture(null);
  3899.                 }
  3900.                 if($fileNoteCalculCharpente173Multiple){
  3901.                     $array = explode(',',$fileNoteCalculCharpente173Multiple);
  3902.                     foreach ($array as $item){
  3903.                         $fileNoteCalculCharpente173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3904.                         $nomenclature = $this->getNomenclature($etap,$fileNoteCalculCharpente173MultipleEntity,'Notes de calcul charpente');
  3905.                         $etap->addFileNoteCalculCharpente173Multiple($fileNoteCalculCharpente173MultipleEntity);
  3906.                         $this->uploadFileToDropbox($fileNoteCalculCharpente173MultipleEntity,$project,"Contrats de development et construction/".$fileNoteCalculCharpente173MultipleEntity->getId().$nomenclature);
  3907.                     }
  3908.                 }
  3909.                 if($filePhotoRenforcementcharpente173Multiple){
  3910.                     $array = explode(',',$filePhotoRenforcementcharpente173Multiple);
  3911.                     foreach ($array as $item){
  3912.                         $filePhotoRenforcementcharpente173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3913.                         $nomenclature = $this->getNomenclature($etap,$filePhotoRenforcementcharpente173MultipleEntity,'Photos de renforcement charpente');
  3914.                         $etap->addFilePhotoRenforcementcharpente173Multiple($filePhotoRenforcementcharpente173MultipleEntity);
  3915.                         $this->uploadFileToDropbox($filePhotoRenforcementcharpente173MultipleEntity,$project,"Contrats de development et construction/".$filePhotoRenforcementcharpente173MultipleEntity->getId().$nomenclature);
  3916.                     }
  3917.                 }
  3918.                 if($fileOssatureSecondaireBardage173Multiple){
  3919.                     $array = explode(',',$fileOssatureSecondaireBardage173Multiple);
  3920.                     foreach ($array as $item){
  3921.                         $fileOssatureSecondaireBardage173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3922.                         $nomenclature = $this->getNomenclature($etap,$fileOssatureSecondaireBardage173MultipleEntity,'Plan de bardage');
  3923.                         $etap->addFileOssatureSecondaireBardage173Multiple($fileOssatureSecondaireBardage173MultipleEntity);
  3924.                         $this->uploadFileToDropbox($fileOssatureSecondaireBardage173MultipleEntity,$project,"Contrats de development et construction/".$fileOssatureSecondaireBardage173MultipleEntity->getId().$nomenclature);
  3925.                     }
  3926.                 }
  3927.                 if($filePhotoRenforcementBardage173Multiple){
  3928.                     $array = explode(',',$filePhotoRenforcementBardage173Multiple);
  3929.                     foreach ($array as $item){
  3930.                         $filePhotoRenforcementBardage173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3931.                         $nomenclature = $this->getNomenclature($etap,$filePhotoRenforcementBardage173MultipleEntity,'Photos de renforcement des bardages');
  3932.                         $etap->addFilePhotoRenforcementBardage173Multiple($filePhotoRenforcementBardage173MultipleEntity);
  3933.                         $this->uploadFileToDropbox($filePhotoRenforcementBardage173MultipleEntity,$project,"Contrats de development et construction/".$filePhotoRenforcementBardage173MultipleEntity->getId().$nomenclature);
  3934.                     }
  3935.                 }
  3936.                 if($filePVreception173Multiple){
  3937.                     $array = explode(',',$filePVreception173Multiple);
  3938.                     foreach ($array as $item){
  3939.                         $filePVreception173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3940.                         $nomenclature = $this->getNomenclature($etap,$filePVreception173MultipleEntity,'PV de réception');
  3941.                         $etap->addFilePVreception173Multiple($filePVreception173MultipleEntity);
  3942.                         $this->uploadFileToDropbox($filePVreception173MultipleEntity,$project,"Contrats de development et construction/".$filePVreception173MultipleEntity->getId().$nomenclature);
  3943.                     }
  3944.                 }
  3945.                 if($filePhotoRenforcementCouvertureTermine173Multiple){
  3946.                     $array = explode(',',$filePhotoRenforcementCouvertureTermine173Multiple);
  3947.                     foreach ($array as $item){
  3948.                         $filePhotoRenforcementCouvertureTermine173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3949.                         $nomenclature = $this->getNomenclature($etap,$filePhotoRenforcementCouvertureTermine173MultipleEntity,'Photos de renforcement de la couverture terminée');
  3950.                         $etap->addFilePhotoRenforcementCouvertureTermine173Multiple($filePhotoRenforcementCouvertureTermine173MultipleEntity);
  3951.                         $this->uploadFileToDropbox($filePhotoRenforcementCouvertureTermine173MultipleEntity,$project,"Contrats de development et construction/".$filePhotoRenforcementCouvertureTermine173MultipleEntity->getId().$nomenclature);
  3952.                     }
  3953.                 }
  3954.                 if($filePlansCharpente173Multiple){
  3955.                     $array = explode(',',$filePlansCharpente173Multiple);
  3956.                     foreach ($array as $item){
  3957.                         $filePlansCharpente173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3958.                         $nomenclature = $this->getNomenclature($etap,$filePlansCharpente173MultipleEntity,'Plans de charpente');
  3959.                         $etap->addFilePlansCharpente173Multiple($filePlansCharpente173MultipleEntity);
  3960.                         $this->uploadFileToDropbox($filePlansCharpente173MultipleEntity,$project,"Contrats de development et construction/".$filePlansCharpente173MultipleEntity->getId().$nomenclature);
  3961.                     }
  3962.                 }
  3963.                 if($filePlansCharpente173SigneMultiple){
  3964.                     $array = explode(',',$filePlansCharpente173SigneMultiple);
  3965.                     foreach ($array as $item){
  3966.                         $filePlansCharpente173SigneMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3967.                         $nomenclature = $this->getNomenclature($etap,$filePlansCharpente173SigneMultipleEntity,'Plans de charpente Singé par bailleur');
  3968.                         $etap->addFilePlansCharpente173SigneMultiple($filePlansCharpente173SigneMultipleEntity);
  3969.                         $this->uploadFileToDropbox($filePlansCharpente173SigneMultipleEntity,$project,"Contrats de development et construction/".$filePlansCharpente173SigneMultipleEntity->getId().$nomenclature);
  3970.                     }
  3971.                 }
  3972.                 if($fileVues3d173Multiple){
  3973.                     $array = explode(',',$fileVues3d173Multiple);
  3974.                     foreach ($array as $item){
  3975.                         $fileVues3d173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3976.                         $nomenclature = $this->getNomenclature($etap,$fileVues3d173MultipleEntity,'Vues 3D');
  3977.                         $etap->addFileVues3d173Multiple($fileVues3d173MultipleEntity);
  3978.                         $this->uploadFileToDropbox($fileVues3d173MultipleEntity,$project,"Contrats de development et construction/".$fileVues3d173MultipleEntity->getId().$nomenclature);
  3979.                     }
  3980.                 }
  3981.                 if($filePlanCouverture173Multiple){
  3982.                     $array = explode(',',$filePlanCouverture173Multiple);
  3983.                     foreach ($array as $item){
  3984.                         $filePlanCouverture173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3985.                         $nomenclature = $this->getNomenclature($etap,$filePlanCouverture173MultipleEntity,'Plan de couverture');
  3986.                         $etap->addFilePlanCouverture173Multiple($filePlanCouverture173MultipleEntity);
  3987.                         $this->uploadFileToDropbox($filePlanCouverture173MultipleEntity,$project,"Contrats de development et construction/".$filePlanCouverture173MultipleEntity->getId().$nomenclature);
  3988.                     }
  3989.                 }
  3990.                 if($filePlanDescriptionTravauxRenforcementCharpente173Multiple){
  3991.                     $array = explode(',',$filePlanDescriptionTravauxRenforcementCharpente173Multiple);
  3992.                     foreach ($array as $item){
  3993.                         $filePlanDescriptionTravauxRenforcementCharpente173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  3994.                         $nomenclature = $this->getNomenclature($etap,$filePlanDescriptionTravauxRenforcementCharpente173MultipleEntity,'Plan et descriptifs des travaux de renforcement de charpente');
  3995.                         $etap->addFilePlanDescriptionTravauxRenforcementCharpente173Multiple($filePlanDescriptionTravauxRenforcementCharpente173MultipleEntity);
  3996.                         $this->uploadFileToDropbox($filePlanDescriptionTravauxRenforcementCharpente173MultipleEntity,$project,"Contrats de development et construction/".$filePlanDescriptionTravauxRenforcementCharpente173MultipleEntity->getId().$nomenclature);
  3997.                     }
  3998.                 }
  3999.                 if($filePlanDescriptionTravauxDeposeCouverture173Multiple){
  4000.                     $array = explode(',',$filePlanDescriptionTravauxDeposeCouverture173Multiple);
  4001.                     foreach ($array as $item){
  4002.                         $filePlanDescriptionTravauxDeposeCouverture173MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4003.                         $nomenclature = $this->getNomenclature($etap,$filePlanDescriptionTravauxDeposeCouverture173MultipleEntity,'Plan et descriptifs des travaux de dépose , repose de couverture');
  4004.                         $etap->addFilePlanDescriptionTravauxDeposeCouverture173Multiple($filePlanDescriptionTravauxDeposeCouverture173MultipleEntity);
  4005.                         $this->uploadFileToDropbox($filePlanDescriptionTravauxDeposeCouverture173MultipleEntity,$project,"Contrats de development et construction/".$filePlanDescriptionTravauxDeposeCouverture173MultipleEntity->getId().$nomenclature);
  4006.                     }
  4007.                 }
  4008.                 $this->addOrUpdateCategory($categorys,'setEtap173',$etap,$project);
  4009.                 $this->em->persist($etap);
  4010.                 $this->em->flush();
  4011.                 $this->updateStatusTracker($project); // set status tracker
  4012.                 $this->flashBag->add(
  4013.                     'success',
  4014.                     'L\'opération a Ã©té effectuée avec succès.'
  4015.                 );
  4016.                 return [
  4017.                     'etap' => $etap,
  4018.                     'success' => true
  4019.                 ];
  4020.             }
  4021.         }
  4022.         return [
  4023.             'success' => false
  4024.         ];
  4025.     }
  4026.     public function submitEtap174($request,$user)
  4027.     {
  4028.         $filePlanCalepinageModule174Multiple = $request->get('filePlanCalepinageModule174Multiple');
  4029.         $filePlanCaplageStrings174Multiple = $request->get('filePlanCaplageStrings174Multiple');
  4030.         $fileNoteCalculSousLisePV174Multiple = $request->get('fileNoteCalculSousLisePV174Multiple');
  4031.         $fileSchemaUnifilaireInstallation174Multiple = $request->get('fileSchemaUnifilaireInstallation174Multiple');
  4032.         $fileShemaAgencementShelterPhotos174Multiple = $request->get('fileShemaAgencementShelterPhotos174Multiple');
  4033.         $fileTestPrMiseService174Multiple = $request->get('fileTestPrMiseService174Multiple');
  4034.         $fileShemaUnifilaireSystemeMonitoring174Multiple = $request->get('fileShemaUnifilaireSystemeMonitoring174Multiple');
  4035.         $fileTestVerificationTravauxElectriqueFiche174Multiple = $request->get('fileTestVerificationTravauxElectriqueFiche174Multiple');
  4036.         $filePVReception174Multiple = $request->get('filePVReception174Multiple');
  4037.         $filePhotosGenerateur174Multiple = $request->get('filePhotosGenerateur174Multiple');
  4038.         $filePvTerminees174Multiple = $request->get('filePvTerminees174Multiple');
  4039.         $fileDescentesCables174Multiple = $request->get('fileDescentesCables174Multiple');
  4040.         $fileRaccordementLocalOnduleur174Multiple = $request->get('fileRaccordementLocalOnduleur174Multiple');
  4041.         $debutPosePvEtap = $request->get('debutPosePvEtap');
  4042.         $finPosePvEtap = $request->get('finPosePvEtap');
  4043.         $categorys = $request->get('categorys');
  4044.         $etapToken = $request->get('etapToken');
  4045.         $tokenProject = $request->get('tokenProject');
  4046.         if($etapToken and $tokenProject){
  4047.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  4048.             $etap = $this->em->getRepository(Etap174::class)->findOneBy(['token'=>$etapToken]);
  4049.             if($project && $etap){
  4050.                 if(!$this->checkUserAction($user,$project,$etap)){
  4051.                     return [
  4052.                         'success' => false
  4053.                     ];
  4054.                 }
  4055.                 if($debutPosePvEtap){
  4056.                     $etap->setDateDebutPosePv(new \DateTime($debutPosePvEtap));
  4057.                 }else{
  4058.                     $etap->setDateDebutPosePv(null);
  4059.                 }
  4060.                 if($finPosePvEtap){
  4061.                     $etap->setDateFinPosePv(new \DateTime($finPosePvEtap));
  4062.                 }else{
  4063.                     $etap->setDateFinPosePv(null);
  4064.                 }
  4065.                 if($filePlanCalepinageModule174Multiple){
  4066.                     $array = explode(',',$filePlanCalepinageModule174Multiple);
  4067.                     foreach ($array as $item){
  4068.                         $filePlanCalepinageModule174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4069.                         $nomenclature = $this->getNomenclature($etap,$filePlanCalepinageModule174MultipleEntity,'Plan de calepinage / câblage');
  4070.                         $etap->addFilePlanCalepinageModule174Multiple($filePlanCalepinageModule174MultipleEntity);
  4071.                         $this->uploadFileToDropbox($filePlanCalepinageModule174MultipleEntity,$project,"Contrats de development et construction/".$filePlanCalepinageModule174MultipleEntity->getId().$nomenclature);
  4072.                     }
  4073.                 }
  4074.                 if($filePlanCaplageStrings174Multiple){
  4075.                     $array = explode(',',$filePlanCaplageStrings174Multiple);
  4076.                     foreach ($array as $item){
  4077.                         $filePlanCaplageStrings174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4078.                         $nomenclature = $this->getNomenclature($etap,$filePlanCaplageStrings174MultipleEntity,'Plan de câblage des strings');
  4079.                         $etap->addFilePlanCaplageStrings174Multiple($filePlanCaplageStrings174MultipleEntity);
  4080.                         $this->uploadFileToDropbox($filePlanCaplageStrings174MultipleEntity,$project,"Contrats de development et construction/".$filePlanCaplageStrings174MultipleEntity->getId().$nomenclature);
  4081.                     }
  4082.                 }
  4083.                 if($fileNoteCalculSousLisePV174Multiple){
  4084.                     $array = explode(',',$fileNoteCalculSousLisePV174Multiple);
  4085.                     foreach ($array as $item){
  4086.                         $fileNoteCalculSousLisePV174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4087.                         $nomenclature = $this->getNomenclature($etap,$fileNoteCalculSousLisePV174MultipleEntity,'Note de calcul sous Lise PV');
  4088.                         $etap->addFileNoteCalculSousLisePV174Multiple($fileNoteCalculSousLisePV174MultipleEntity);
  4089.                         $this->uploadFileToDropbox($fileNoteCalculSousLisePV174MultipleEntity,$project,"Contrats de development et construction/".$fileNoteCalculSousLisePV174MultipleEntity->getId().$nomenclature);
  4090.                     }
  4091.                 }
  4092.                 if($fileSchemaUnifilaireInstallation174Multiple){
  4093.                     $array = explode(',',$fileSchemaUnifilaireInstallation174Multiple);
  4094.                     foreach ($array as $item){
  4095.                         $fileSchemaUnifilaireInstallation174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4096.                         $nomenclature = $this->getNomenclature($etap,$fileSchemaUnifilaireInstallation174MultipleEntity,'Schéma Unifilaire de l’installation');
  4097.                         $etap->addFileSchemaUnifilaireInstallation174Multiple($fileSchemaUnifilaireInstallation174MultipleEntity);
  4098.                         $this->uploadFileToDropbox($fileSchemaUnifilaireInstallation174MultipleEntity,$project,"Contrats de development et construction/".$fileSchemaUnifilaireInstallation174MultipleEntity->getId().$nomenclature);
  4099.                     }
  4100.                 }
  4101.                 if($fileShemaAgencementShelterPhotos174Multiple){
  4102.                     $array = explode(',',$fileShemaAgencementShelterPhotos174Multiple);
  4103.                     foreach ($array as $item){
  4104.                         $fileShemaAgencementShelterPhotos174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4105.                         $nomenclature = $this->getNomenclature($etap,$fileShemaAgencementShelterPhotos174MultipleEntity,'Schéma d’agencement du shelter ou photos');
  4106.                         $etap->addFileShemaAgencementShelterPhotos174Multiple($fileShemaAgencementShelterPhotos174MultipleEntity);
  4107.                         $this->uploadFileToDropbox($fileShemaAgencementShelterPhotos174MultipleEntity,$project,"Contrats de development et construction/".$fileShemaAgencementShelterPhotos174MultipleEntity->getId().$nomenclature);
  4108.                     }
  4109.                 }
  4110.                 if($fileTestPrMiseService174Multiple){
  4111.                     $array = explode(',',$fileTestPrMiseService174Multiple);
  4112.                     foreach ($array as $item){
  4113.                         $fileTestPrMiseService174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4114.                         $nomenclature = $this->getNomenclature($etap,$fileTestPrMiseService174MultipleEntity,'Test de PR Ã  la mise en service');
  4115.                         $etap->addFileTestPrMiseService174Multiple($fileTestPrMiseService174MultipleEntity);
  4116.                         $this->uploadFileToDropbox($fileTestPrMiseService174MultipleEntity,$project,"Contrats de development et construction/".$fileTestPrMiseService174MultipleEntity->getId().$nomenclature);
  4117.                     }
  4118.                 }
  4119.                 if($fileShemaUnifilaireSystemeMonitoring174Multiple){
  4120.                     $array = explode(',',$fileShemaUnifilaireSystemeMonitoring174Multiple);
  4121.                     foreach ($array as $item){
  4122.                         $fileShemaUnifilaireSystemeMonitoring174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4123.                         $nomenclature = $this->getNomenclature($etap,$fileShemaUnifilaireSystemeMonitoring174MultipleEntity,'Schéma unifilaire du système de monitoring');
  4124.                         $etap->addFileShemaUnifilaireSystemeMonitoring174Multiple($fileShemaUnifilaireSystemeMonitoring174MultipleEntity);
  4125.                         $this->uploadFileToDropbox($fileShemaUnifilaireSystemeMonitoring174MultipleEntity,$project,"Contrats de development et construction/".$fileShemaUnifilaireSystemeMonitoring174MultipleEntity->getId().$nomenclature);
  4126.                     }
  4127.                 }
  4128.                 if($fileTestVerificationTravauxElectriqueFiche174Multiple){
  4129.                     $array = explode(',',$fileTestVerificationTravauxElectriqueFiche174Multiple);
  4130.                     foreach ($array as $item){
  4131.                         $fileTestVerificationTravauxElectriqueFiche174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4132.                         $nomenclature = $this->getNomenclature($etap,$fileTestVerificationTravauxElectriqueFiche174MultipleEntity,'Tests et vérifications des travaux Ã©lectriques, fiche d’auto-contrôle de l’installateur');
  4133.                         $etap->addFileTestVerificationTravauxElectriqueFiche174Multiple($fileTestVerificationTravauxElectriqueFiche174MultipleEntity);
  4134.                         $this->uploadFileToDropbox($fileTestVerificationTravauxElectriqueFiche174MultipleEntity,$project,"Contrats de development et construction/".$fileTestVerificationTravauxElectriqueFiche174MultipleEntity->getId().$nomenclature);
  4135.                     }
  4136.                 }
  4137.                 if($filePVReception174Multiple){
  4138.                     $array = explode(',',$filePVReception174Multiple);
  4139.                     foreach ($array as $item){
  4140.                         $filePVReception174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4141.                         $nomenclature = $this->getNomenclature($etap,$filePVReception174MultipleEntity,'PV de réception');
  4142.                         $etap->addFilePVReception174Multiple($filePVReception174MultipleEntity);
  4143.                         $this->uploadFileToDropbox($filePVReception174MultipleEntity,$project,"Contrats de development et construction/".$filePVReception174MultipleEntity->getId().$nomenclature);
  4144.                     }
  4145.                 }
  4146.                 if($filePhotosGenerateur174Multiple){
  4147.                     $array = explode(',',$filePhotosGenerateur174Multiple);
  4148.                     foreach ($array as $item){
  4149.                         $filePhotosGenerateur174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4150.                         $nomenclature = $this->getNomenclature($etap,$filePhotosGenerateur174MultipleEntity,'Photos de la centrale solaire');
  4151.                         $etap->addFilePhotosGenerateur174Multiple($filePhotosGenerateur174MultipleEntity);
  4152.                         $this->uploadFileToDropbox($filePhotosGenerateur174MultipleEntity,$project,"Contrats de development et construction/".$filePhotosGenerateur174MultipleEntity->getId().$nomenclature);
  4153.                     }
  4154.                 }
  4155.                 if($filePvTerminees174Multiple){
  4156.                     $array = explode(',',$filePvTerminees174Multiple);
  4157.                     foreach ($array as $item){
  4158.                         $filePvTerminees174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4159.                         $nomenclature = $this->getNomenclature($etap,$filePvTerminees174MultipleEntity,'Pv terminées');
  4160.                         $etap->addFilePvTerminees174Multiple($filePvTerminees174MultipleEntity);
  4161.                         $this->uploadFileToDropbox($filePvTerminees174MultipleEntity,$project,"Contrats de development et construction/".$filePvTerminees174MultipleEntity->getId().$nomenclature);
  4162.                     }
  4163.                 }
  4164.                 if($fileDescentesCables174Multiple){
  4165.                     $array = explode(',',$fileDescentesCables174Multiple);
  4166.                     foreach ($array as $item){
  4167.                         $fileDescentesCables174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4168.                         $nomenclature = $this->getNomenclature($etap,$fileDescentesCables174MultipleEntity,'Descentes de câbles');
  4169.                         $etap->addFileDescentesCables174Multiple($fileDescentesCables174MultipleEntity);
  4170.                         $this->uploadFileToDropbox($fileDescentesCables174MultipleEntity,$project,"Contrats de development et construction/".$fileDescentesCables174MultipleEntity->getId().$nomenclature);
  4171.                     }
  4172.                 }
  4173.                 if($fileRaccordementLocalOnduleur174Multiple){
  4174.                     $array = explode(',',$fileRaccordementLocalOnduleur174Multiple);
  4175.                     foreach ($array as $item){
  4176.                         $fileRaccordementLocalOnduleur174MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4177.                         $nomenclature = $this->getNomenclature($etap,$fileRaccordementLocalOnduleur174MultipleEntity,'Raccordement du local onduleur');
  4178.                         $etap->addFileRaccordementLocalOnduleur174Multiple($fileRaccordementLocalOnduleur174MultipleEntity);
  4179.                         $this->uploadFileToDropbox($fileRaccordementLocalOnduleur174MultipleEntity,$project,"Contrats de development et construction/".$fileRaccordementLocalOnduleur174MultipleEntity->getId().$nomenclature);
  4180.                     }
  4181.                 }
  4182.                 $this->addOrUpdateCategory($categorys,'setEtap174',$etap,$project);
  4183.                 $this->em->persist($etap);
  4184.                 $this->em->flush();
  4185.                 $this->updateStatusTracker($project); // set status tracker
  4186.                 $this->flashBag->add(
  4187.                     'success',
  4188.                     'L\'opération a Ã©té effectuée avec succès.'
  4189.                 );
  4190.                 return [
  4191.                     'etap' => $etap,
  4192.                     'success' => true
  4193.                 ];
  4194.             }
  4195.         }
  4196.         return [
  4197.             'success' => false
  4198.         ];
  4199.     }
  4200.     public function submitEtap175($request,$user)
  4201.     {
  4202.         $fileNoteCalculCableAcLiaison175Multiple = $request->get('fileNoteCalculCableAcLiaison175Multiple');
  4203.         $filePlanTranchee175Multiple = $request->get('filePlanTranchee175Multiple');
  4204.         $fileDaact175Multiple = $request->get('fileDaact175Multiple');
  4205.         $filePVReception175Multiple = $request->get('filePVReception175Multiple');
  4206.         $filePhotosLiaisonTerminee175Multiple = $request->get('filePhotosLiaisonTerminee175Multiple');
  4207.         $dateAchevementTraveauxEtap = $request->get('dateAchevementTraveauxEtap');
  4208.         $categorys = $request->get('categorys');
  4209.         $etapToken = $request->get('etapToken');
  4210.         $tokenProject = $request->get('tokenProject');
  4211.         if($etapToken and $tokenProject){
  4212.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  4213.             $etap = $this->em->getRepository(Etap175::class)->findOneBy(['token'=>$etapToken]);
  4214.             if($project && $etap){
  4215.                 if(!$this->checkUserAction($user,$project,$etap)){
  4216.                     return [
  4217.                         'success' => false
  4218.                     ];
  4219.                 }
  4220.                 if($dateAchevementTraveauxEtap){
  4221.                     $etap->setDateAchevementTraveaux(new \DateTime($dateAchevementTraveauxEtap));
  4222.                 }else{
  4223.                     $etap->setDateAchevementTraveaux(null);
  4224.                 }
  4225.                 if($fileNoteCalculCableAcLiaison175Multiple){
  4226.                     $array = explode(',',$fileNoteCalculCableAcLiaison175Multiple);
  4227.                     foreach ($array as $item){
  4228.                         $fileNoteCalculCableAcLiaison175MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4229.                         $nomenclature = $this->getNomenclature($etap,$fileNoteCalculCableAcLiaison175MultipleEntity,'Notes de calcul des câbles AC de la liaison');
  4230.                         $etap->addFileNoteCalculCableAcLiaison175Multiple($fileNoteCalculCableAcLiaison175MultipleEntity);
  4231.                         $this->uploadFileToDropbox($fileNoteCalculCableAcLiaison175MultipleEntity,$project,"Contrats de development et construction/".$fileNoteCalculCableAcLiaison175MultipleEntity->getId().$nomenclature);
  4232.                     }
  4233.                 }
  4234.                 if($filePlanTranchee175Multiple){
  4235.                     $array = explode(',',$filePlanTranchee175Multiple);
  4236.                     foreach ($array as $item){
  4237.                         $filePlanTranchee175MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4238.                         $nomenclature = $this->getNomenclature($etap,$filePlanTranchee175MultipleEntity,'Plans de la tranchée (coupe et plan de localisation)');
  4239.                         $etap->addFilePlanTranchee175Multiple($filePlanTranchee175MultipleEntity);
  4240.                         $this->uploadFileToDropbox($filePlanTranchee175MultipleEntity,$project,"Contrats de development et construction/".$filePlanTranchee175MultipleEntity->getId().$nomenclature);
  4241.                     }
  4242.                 }
  4243.                 if($fileDaact175Multiple){
  4244.                     $array = explode(',',$fileDaact175Multiple);
  4245.                     foreach ($array as $item){
  4246.                         $fileDaact175MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4247.                         $nomenclature = $this->getNomenclature($etap,$fileDaact175MultipleEntity,'DAACT : cerfa signé tamponné mairie');
  4248.                         $etap->addFileDaact175Multiple($fileDaact175MultipleEntity);
  4249.                         $this->uploadFileToDropbox($fileDaact175MultipleEntity,$project,"Contrats de development et construction/".$fileDaact175MultipleEntity->getId().$nomenclature);
  4250.                     }
  4251.                 }
  4252.                 if($filePVReception175Multiple){
  4253.                     $array = explode(',',$filePVReception175Multiple);
  4254.                     foreach ($array as $item){
  4255.                         $filePVReception175MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4256.                         $nomenclature = $this->getNomenclature($etap,$filePVReception175MultipleEntity,'PV de réception');
  4257.                         $etap->addFilePVReception175Multiple($filePVReception175MultipleEntity);
  4258.                         $this->uploadFileToDropbox($filePVReception175MultipleEntity,$project,"Contrats de development et construction/".$filePVReception175MultipleEntity->getId().$nomenclature);
  4259.                     }
  4260.                 }
  4261.                 if($filePhotosLiaisonTerminee175Multiple){
  4262.                     $array = explode(',',$filePhotosLiaisonTerminee175Multiple);
  4263.                     foreach ($array as $item){
  4264.                         $filePhotosLiaisonTerminee175MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4265.                         $nomenclature = $this->getNomenclature($etap,$filePhotosLiaisonTerminee175MultipleEntity,'Photos de la liaison terminée');
  4266.                         $etap->addFilePhotosLiaisonTerminee175Multiple($filePhotosLiaisonTerminee175MultipleEntity);
  4267.                         $this->uploadFileToDropbox($filePhotosLiaisonTerminee175MultipleEntity,$project,"Contrats de development et construction/".$filePhotosLiaisonTerminee175MultipleEntity->getId().$nomenclature);
  4268.                     }
  4269.                 }
  4270.                 $this->addOrUpdateCategory($categorys,'setEtap175',$etap,$project);
  4271.                 $this->em->persist($etap);
  4272.                 $this->em->flush();
  4273.                 $this->updateStatusTracker($project); // set status tracker
  4274.                 $this->flashBag->add(
  4275.                     'success',
  4276.                     'L\'opération a Ã©té effectuée avec succès.'
  4277.                 );
  4278.                 return [
  4279.                     'etap' => $etap,
  4280.                     'success' => true
  4281.                 ];
  4282.             }
  4283.         }
  4284.         return [
  4285.             'success' => false
  4286.         ];
  4287.     }
  4288.     public function submitEtap159($request,$user)
  4289.     {
  4290.         $fileVisiteTechnique159Multiple = $request->get('fileVisiteTechnique159Multiple');
  4291.         $fileEtudeProductible159Multiple = $request->get('fileEtudeProductible159Multiple');
  4292.         $fileGeotechnique159Multiple = $request->get('fileGeotechnique159Multiple');
  4293.         $fileDiagnostiqueCharpente159Multiple = $request->get('fileDiagnostiqueCharpente159Multiple');
  4294.         $fileDesignPreCRD159Multiple = $request->get('fileDesignPreCRD159Multiple');
  4295.         $fileDesignPostCRD159Multiple = $request->get('fileDesignPostCRD159Multiple');
  4296.         $filePlanMasseSituationTranchee159Multiple = $request->get('filePlanMasseSituationTranchee159Multiple');
  4297.         $filePlanCalepinage159Multiple = $request->get('filePlanCalepinage159Multiple');
  4298.         $fileSchemaUnifilaire159Multiple = $request->get('fileSchemaUnifilaire159Multiple');
  4299.         $filePlansAutocadMultiple = $request->get('filePlansAutocadMultiple');
  4300.         $filePlansDwgMultiple = $request->get('filePlansDwgMultiple');
  4301.         $etatCharpente = $request->get('etatCharpente');
  4302.         $typeToitureExistante = $request->get('typeToitureExistante');
  4303.         $typeRenovation = $request->get('typeRenovation');
  4304.         $typeToiturePoser = $request->get('typeToiturePoser');
  4305.         $etapToken = $request->get('etapToken');
  4306.         $tokenProject = $request->get('tokenProject');
  4307.         if($etapToken and $tokenProject){
  4308.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  4309.             $etap = $this->em->getRepository(Etap159::class)->findOneBy(['token'=>$etapToken]);
  4310.             $etap160 = $this->em->getRepository(Etap160::class)->findOneBy(['project'=>$project->getId()]);
  4311.             if($project && $etap){
  4312.                 if(!$this->checkUserAction($user,$project,$etap)){
  4313.                     return [
  4314.                         'success' => false
  4315.                     ];
  4316.                 }
  4317.                 if($filePlansAutocadMultiple){
  4318.                     $array = explode(',',$filePlansAutocadMultiple);
  4319.                     foreach ($array as $item){
  4320.                         $filePlansAutocadMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4321.                         $nomenclature = $this->getNomenclature($etap,$filePlansAutocadMultipleEntity,'Plans Autocad');
  4322.                         $etap->addFilePlansAutocadMultiple($filePlansAutocadMultipleEntity);
  4323.                         $this->uploadFileToDropbox($filePlansAutocadMultipleEntity,$project,"Contrats de development et construction/".$filePlansAutocadMultipleEntity->getId().$nomenclature);
  4324.                     }
  4325.                 }
  4326.                 if($filePlansDwgMultiple){
  4327.                     $array = explode(',',$filePlansDwgMultiple);
  4328.                     foreach ($array as $item){
  4329.                         $filePlansDwgMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4330.                         $nomenclature = $this->getNomenclature($etap,$filePlansDwgMultipleEntity,'Plans dwg');
  4331.                         $etap->addFilePlansDwgMultiple($filePlansDwgMultipleEntity);
  4332.                         $this->uploadFileToDropbox($filePlansDwgMultipleEntity,$project,"Contrats de development et construction/".$filePlansDwgMultipleEntity->getId().$nomenclature);
  4333.                     }
  4334.                 }
  4335.                 if($fileVisiteTechnique159Multiple){
  4336.                     $array = explode(',',$fileVisiteTechnique159Multiple);
  4337.                     foreach ($array as $item){
  4338.                         $fileVisiteTechnique159MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4339.                         $nomenclature = $this->getNomenclature($etap,$fileVisiteTechnique159MultipleEntity,'Visite technique');
  4340.                         $etap->addFileVisiteTechnique159Multiple($fileVisiteTechnique159MultipleEntity);
  4341.                         $this->uploadFileToDropbox($fileVisiteTechnique159MultipleEntity,$project,"Contrats de development et construction/".$fileVisiteTechnique159MultipleEntity->getId().$nomenclature);
  4342.                     }
  4343.                 }
  4344.                 if($fileEtudeProductible159Multiple){
  4345.                     $array = explode(',',$fileEtudeProductible159Multiple);
  4346.                     foreach ($array as $item){
  4347.                         $fileEtudeProductible159MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4348.                         $nomenclature = $this->getNomenclature($etap,$fileEtudeProductible159MultipleEntity,'Etude de productible');
  4349.                         $etap->addFileEtudeProductible159Multiple($fileEtudeProductible159MultipleEntity);
  4350.                         $this->uploadFileToDropbox($fileEtudeProductible159MultipleEntity,$project,"Contrats de development et construction/".$fileEtudeProductible159MultipleEntity->getId().$nomenclature);
  4351.                         $project->setFileEtudeProductible($fileEtudeProductible159MultipleEntity) ;
  4352.                         $this->em->persist($project);
  4353.                     }
  4354.                 }
  4355.                 if($fileGeotechnique159Multiple){
  4356.                     $array = explode(',',$fileGeotechnique159Multiple);
  4357.                     foreach ($array as $item){
  4358.                         $fileGeotechnique159MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4359.                         $nomenclature = $this->getNomenclature($etap,$fileGeotechnique159MultipleEntity,'Etude de sol');
  4360.                         $etap->addFileGeotechnique159Multiple($fileGeotechnique159MultipleEntity);
  4361.                         $etap160->addFileEtudeSoleMultiple($fileGeotechnique159MultipleEntity);
  4362.                         $this->uploadFileToDropbox($fileGeotechnique159MultipleEntity,$project,"Contrats de development et construction/".$fileGeotechnique159MultipleEntity->getId().$nomenclature);
  4363.                     }
  4364.                 }
  4365.                 if($fileDiagnostiqueCharpente159Multiple){
  4366.                     $array = explode(',',$fileDiagnostiqueCharpente159Multiple);
  4367.                     foreach ($array as $item){
  4368.                         $fileDiagnostiqueCharpente159MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4369.                         if($fileDiagnostiqueCharpente159MultipleEntity){
  4370.                             $nomenclature = $this->getNomenclature($etap,$fileDiagnostiqueCharpente159MultipleEntity,'Diagnostic charpente');
  4371.                             $etap->addFileDiagnostiqueCharpente159Multiple($fileDiagnostiqueCharpente159MultipleEntity);
  4372.                             $etap160->addFileDiagnostiqueCharpenteMultiple($fileDiagnostiqueCharpente159MultipleEntity);
  4373.                             $this->uploadFileToDropbox($fileDiagnostiqueCharpente159MultipleEntity,$project,"Contrats de development et construction/".$fileDiagnostiqueCharpente159MultipleEntity->getId().$nomenclature);
  4374.                         }
  4375.                     }
  4376.                     $this->em->persist($etap160);
  4377.                     $this->em->flush();
  4378.                 }
  4379.                 if($fileDesignPreCRD159Multiple){
  4380.                     $array = explode(',',$fileDesignPreCRD159Multiple);
  4381.                     foreach ($array as $item){
  4382.                         $fileDesignPreCRD159MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4383.                         $nomenclature = $this->getNomenclature($etap,$fileDesignPreCRD159MultipleEntity,'Design pré-CRD');
  4384.                         $etap->addFileDesignPreCRD159Multiple($fileDesignPreCRD159MultipleEntity);
  4385.                         $this->uploadFileToDropbox($fileDesignPreCRD159MultipleEntity,$project,"Contrats de development et construction/".$fileDesignPreCRD159MultipleEntity->getId().$nomenclature);
  4386.                     }
  4387.                 }
  4388.                 if($fileDesignPostCRD159Multiple){
  4389.                     $array = explode(',',$fileDesignPostCRD159Multiple);
  4390.                     foreach ($array as $item){
  4391.                         $fileDesignPostCRD159MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4392.                         $nomenclature = $this->getNomenclature($etap,$fileDesignPostCRD159MultipleEntity,'Design post-CRD');
  4393.                         $etap->addFileDesignPostCRD159Multiple($fileDesignPostCRD159MultipleEntity);
  4394.                         $this->uploadFileToDropbox($fileDesignPostCRD159MultipleEntity,$project,"Contrats de development et construction/".$fileDesignPostCRD159MultipleEntity->getId().$nomenclature);
  4395.                     }
  4396.                 }
  4397.                 if($filePlanMasseSituationTranchee159Multiple){
  4398.                     $array = explode(',',$filePlanMasseSituationTranchee159Multiple);
  4399.                     foreach ($array as $item){
  4400.                         $filePlanMasseSituationTranchee159MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4401.                         $nomenclature = $this->getNomenclature($etap,$filePlanMasseSituationTranchee159MultipleEntity,'Plan de masse et de situation avec tranchée');
  4402.                         $etap->addFilePlanMasseSituationTranchee159Multiple($filePlanMasseSituationTranchee159MultipleEntity);
  4403.                         $this->uploadFileToDropbox($filePlanMasseSituationTranchee159MultipleEntity,$project,"Contrats de development et construction/".$filePlanMasseSituationTranchee159MultipleEntity->getId().$nomenclature);
  4404.                     }
  4405.                 }
  4406.                 if($filePlanCalepinage159Multiple){
  4407.                     $array = explode(',',$filePlanCalepinage159Multiple);
  4408.                     foreach ($array as $item){
  4409.                         $filePlanCalepinage159MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4410.                         $nomenclature = $this->getNomenclature($etap,$filePlanCalepinage159MultipleEntity,'Plan de calepinage');
  4411.                         $etap->addFilePlanCalepinage159Multiple($filePlanCalepinage159MultipleEntity);
  4412.                         $this->uploadFileToDropbox($filePlanCalepinage159MultipleEntity,$project,"Contrats de development et construction/".$filePlanCalepinage159MultipleEntity->getId().$nomenclature);
  4413.                     }
  4414.                 }
  4415.                 if($fileSchemaUnifilaire159Multiple){
  4416.                     $array = explode(',',$fileSchemaUnifilaire159Multiple);
  4417.                     foreach ($array as $item){
  4418.                         $fileSchemaUnifilaire159MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4419.                         $nomenclature = $this->getNomenclature($etap,$fileSchemaUnifilaire159MultipleEntity,'Schéma unifilaire');
  4420.                         $etap->addFileSchemaUnifilaire159Multiple($fileSchemaUnifilaire159MultipleEntity);
  4421.                         $this->uploadFileToDropbox($fileSchemaUnifilaire159MultipleEntity,$project,"Contrats de development et construction/".$fileSchemaUnifilaire159MultipleEntity->getId().$nomenclature);
  4422.                     }
  4423.                 }
  4424.                 $etap->setEtatCharpente($etatCharpente);
  4425.                 $etap->setTypeToitureExistante($typeToitureExistante);
  4426.                 $etap->setTypeRenovation($typeRenovation);
  4427.                 $etap->setTypeToiturePoser($typeToiturePoser);
  4428.                 $this->em->persist($etap);
  4429.                 $this->em->flush();
  4430.                 $this->updateStatusTracker($project); // set status tracker
  4431.                 $this->flashBag->add(
  4432.                     'success',
  4433.                     'L\'opération a Ã©té effectuée avec succès.'
  4434.                 );
  4435.                 return [
  4436.                     'etap' => $etap,
  4437.                     'success' => true
  4438.                 ];
  4439.             }
  4440.         }
  4441.         return [
  4442.             'success' => false
  4443.         ];
  4444.     }
  4445.     public function submitEtap23($request,$user)
  4446.     {
  4447.         $etapToken = $request->get('etapToken');
  4448.         $tokenProject = $request->get('tokenProject');
  4449.         $filePhotosVisiteTerainEtap23Multiple = $request->get('filePhotosVisiteTerainEtap23Multiple');
  4450.         $visiteTerrain = $request->get('visiteTerrain');
  4451.         if($etapToken and $tokenProject){
  4452.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  4453.             $etap = $this->em->getRepository(Etap23::class)->findOneBy(['token'=>$etapToken]);
  4454.             if($project && $etap){
  4455.                 if(!$this->checkUserAction($user,$project,$etap)){
  4456.                     return [
  4457.                         'success' => false
  4458.                     ];
  4459.                 }
  4460.                 if($filePhotosVisiteTerainEtap23Multiple){
  4461.                     $array = explode(',',$filePhotosVisiteTerainEtap23Multiple);
  4462.                     foreach ($array as $item){
  4463.                         $filePhotosVisiteTerainEtap23MultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item]);
  4464.                         $nomenclature = $this->getNomenclature($etap,$filePhotosVisiteTerainEtap23MultipleEntity,'photo visite terrain');
  4465.                         $etap->addFilePhotosVisiteTerainEtap23Multiple($filePhotosVisiteTerainEtap23MultipleEntity);
  4466.                     }
  4467.                 }
  4468. //                if($visiteTerrain){
  4469. //                    foreach ($visiteTerrain as $item){
  4470. //                        if(isset($item['id']) and $item['id'] != '') {
  4471. //                            $visiteTerrainEntity = $this->em->getRepository(VisiteTerrainV2::class)->findOneBy(['token' => $item['id']]);
  4472. //                            if (isset($item['filePhotosVisiteTerainV2Multiple']) and $item['filePhotosVisiteTerainV2Multiple'] != '') {
  4473. //                                $array = explode(',', $item['filePhotosVisiteTerainV2Multiple']);
  4474. //                                foreach ($array as $item1) {
  4475. //                                    $filePhotosVisiteTerainMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token' => $item1]);
  4476. //                                    $nomenclature = $this->getNomenclature($etap, $filePhotosVisiteTerainMultipleEntity, 'photos visite terrain');
  4477. //                                    $visiteTerrainEntity->addfilePhotosVisiteTerainV2Multiple($filePhotosVisiteTerainMultipleEntity);
  4478. ////                                    $this->uploadFileToDropbox($filePhotosVisiteTerainMultipleEntity, $project, "Contrats de development et construction/" . $filePhotosVisiteTerainMultipleEntity->getId() . $nomenclature);
  4479. //                                }
  4480. //                            }
  4481. //                            $visiteTerrainEntity->setEtap23($etap);
  4482. //                            $this->em->persist($visiteTerrainEntity);
  4483. //                            $this->em->flush();
  4484. //                        }
  4485. //                    }
  4486. //                }
  4487.                 $this->em->persist($etap);
  4488.                 $this->em->flush();
  4489.                 $this->updateStatusTracker($project); // set status tracker
  4490.                 $this->flashBag->add(
  4491.                     'success',
  4492.                     'L\'opération a Ã©té effectuée avec succès.'
  4493.                 );
  4494.                 return [
  4495.                     'etap' => $etap,
  4496.                     'success' => true
  4497.                 ];
  4498.             }
  4499.         }
  4500.         return [
  4501.             'success' => false
  4502.         ];
  4503.     }
  4504.     public function completudeValideEtapProject($project){
  4505.         $array = [];
  4506.         if($project) {
  4507.             $cats = $this->em->getRepository(EtapsCategory::class)->findAll();
  4508.             $catColor = ['#FFC56D','#009DCA','#649B0F','#E24242','#ED4B9E'];
  4509.             $i = 0;
  4510.             foreach ($cats as $cat) {
  4511.                 $etaps = $this->em->getRepository(Etaps::class)->findBy(['category' => $cat->getId()]);
  4512.                 $etapValidCount = 0 ;
  4513.                 $etapCount = 0 ;
  4514.                 if($etaps){
  4515.                     foreach ($etaps as $etap) {
  4516.                         if( !$etap->getIsDeleteNewConstruction()){
  4517.                             $etapCount = $etapCount + 1;
  4518.                             $etapEntityClass = 'App\\Entity\\Etap' . $etap->getNum();
  4519.                             $etapEntity = $this->em->getRepository($etapEntityClass)->findOneBy(['project' => $project->getId()]);
  4520.                             if($etapEntity->getStatus() == Etaps::STATUS_VALIDE){
  4521.                                 $etapValidCount = $etapValidCount + 1;
  4522.                             }
  4523.                             $array['category'][$cat->getId()]['id'] = $cat->getId();
  4524.                             $array['category'][$cat->getId()]['name'] = $cat->getName();
  4525.                             $array['category'][$cat->getId()]['etapsValidCount'] = $etapValidCount;
  4526.                             $array['category'][$cat->getId()]['etapsCount'] = $etapCount;
  4527.                         }
  4528.                     }
  4529.                 }else{
  4530.                     $array['category'][$cat->getId()]['id'] = $cat->getId();
  4531.                     $array['category'][$cat->getId()]['name'] = $cat->getName();
  4532.                     $array['category'][$cat->getId()]['etapsValidCount'] = 0;
  4533.                     $array['category'][$cat->getId()]['etapsCount'] = 0;
  4534.                 }
  4535.                 if($i > 5)
  4536.                     $i = 0;
  4537.                 $array['category'][$cat->getId()]['color'] = $catColor[$i];
  4538.                 $i = $i + 1;
  4539.             }
  4540.             $pourcentageGlobale = 0;
  4541.             foreach ($array['category'] as &$item){
  4542.                 $pourcentage = (int)$item['etapsCount'] ? (((int)$item['etapsValidCount'] / (int)$item['etapsCount']) * 100 ) : 0.0 ;
  4543.                 $item['pourcentage'] = number_format($pourcentage,1);
  4544.                 $pourcentageGlobale = $pourcentage +  $pourcentageGlobale;
  4545.             }
  4546.             if($pourcentageGlobale > 0){
  4547.                 $array['pourcentageGlobale'] = number_format($pourcentageGlobale / count($cats),1);
  4548.             }else{
  4549.                 $array['pourcentageGlobale'] = 0.0;
  4550.             }
  4551.         }
  4552.         return $array;
  4553.     }
  4554.     public function completudeValideDocumentEtapProject($project){
  4555.         $array = [];
  4556.         if($project) {
  4557.             $cats = $this->em->getRepository(EtapsCategory::class)->findAll();
  4558.             $catColor = ['#B1C40C','#0CA3C4','#520CC4','#C47A0C','#ED4B9E'];
  4559.             $i = 0;
  4560.             foreach ($cats as $cat) {
  4561.                 $etaps = $this->em->getRepository(Etaps::class)->findBy(['category' => $cat->getId()]);
  4562.                 $docsUploadeCount = 0 ;
  4563.                 $docsCount = 0 ;
  4564.                 if($cat->getNum() == 5){
  4565.                     if($etaps) {
  4566.                         foreach ($etaps as $etap) {
  4567.                             if (!$etap->getIsDeleteNewConstruction()) {
  4568.                                 $etapEntityClass = 'App\\Entity\\Etap' . $etap->getNum();
  4569.                                 $etapEntity = $this->em->getRepository($etapEntityClass)->findOneBy(['project' => $project->getId()]);
  4570.                                 if($etap->getNum() == 24){
  4571.                                 }elseif ($etap->getNum() == 25){
  4572.                                     $etap25Champs = $etapEntity ? $etapEntity->getEtap24Champs() : null;
  4573.                                     if(count($etap25Champs) > 0){
  4574.                                         foreach ($etap25Champs as $champ){
  4575.                                             $typeValorisation = $champ->getTypeValorisation() ? $champ->getTypeValorisation()->getCategory() : null;
  4576.                                             if($typeValorisation == TypeValorisation::type_guichet_ouvert){
  4577.                                                 $fileCount = $this->checkDocNotArchive($champ->getFileDemandeRaccordementEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4578.                                                 $fileCount = $this->checkDocNotArchive($champ->getFileMailEnedisConfirmationEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4579.                                             }elseif ($typeValorisation == TypeValorisation::type_ao_cre){
  4580.                                                 $fileCount = $this->checkDocNotArchive($champ->getFileGarantieBancaireEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4581.                                                 $fileCount = $this->checkDocNotArchive($champ->getFileRecepisseDemandeAoMultiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4582.                                                 $fileCount = $this->checkDocNotArchive($champ->getFileLettreLaureaMultiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4583.                                             }elseif ($typeValorisation == TypeValorisation::type_acc || $typeValorisation == TypeValorisation::type_aci || $typeValorisation == TypeValorisation::type_ppa){
  4584.                                             }elseif ($typeValorisation == TypeValorisation::type_spot){
  4585.                                             }
  4586.                                         }
  4587.                                     }
  4588.                                 } elseif ($etap->getNum() == 26){
  4589.                                     $etap24Champs = $etapEntity ? $etapEntity->getEtap24Champs() : null;
  4590.                                     if(count($etap24Champs) > 0){
  4591.                                         foreach ($etap24Champs as $etap24Champ){
  4592.                                             foreach ($etap24Champ->getEtap26Champs() as $champ){
  4593.                                                 $typeValorisation = $etap24Champ->getTypeValorisation() ? $etap24Champ->getTypeValorisation()->getCategory() : null;
  4594.                                                 if($typeValorisation == TypeValorisation::type_guichet_ouvert or $typeValorisation == TypeValorisation::type_ao_cre){
  4595.                                                     $fileCount = $this->checkDocNotArchive($champ->getFileContratAchatSigneEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4596.                                                     $fileCount = $this->checkDocNotArchive($champ->getFileAttestionProducteurEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4597.                                                     $fileCount = $this->checkDocNotArchive($champ->getFileAttestionInstallateurEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4598.                                                     $fileCount = $this->checkDocNotArchive($champ->getFileArContratAchatEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4599.                                                 }elseif ($typeValorisation == TypeValorisation::type_acc || $typeValorisation == TypeValorisation::type_aci || $typeValorisation == TypeValorisation::type_ppa || $typeValorisation == TypeValorisation::type_fer){
  4600.                                                     $fileCount = $this->checkDocNotArchive($champ->getFileContratAchatSigneEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4601.                                                 }elseif ($typeValorisation == TypeValorisation::type_spot){
  4602.                                                     $fileCount = $this->checkDocNotArchive($champ->getFileContratAchatSigneEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  4603.                                                 }
  4604.                                             }
  4605.                                         }
  4606.                                     }
  4607.                                 }
  4608.                             }
  4609.                         }
  4610.                         $array['category'][$cat->getId()]['id'] = $cat->getId();
  4611.                         $array['category'][$cat->getId()]['name'] = $cat->getName();
  4612.                         $array['category'][$cat->getId()]['num'] = $cat->getNum();
  4613.                         $array['category'][$cat->getId()]['docsUploadeCount'] = $docsUploadeCount;
  4614.                         $array['category'][$cat->getId()]['docsCount'] = $docsCount;
  4615.                     }
  4616.                 }
  4617.                 else{
  4618.                     if($etaps){
  4619.                         foreach ($etaps as $etap) {
  4620.                             if($project->getIsNewConstruction()){
  4621.                                 if( !$etap->getIsDeleteNewConstruction()){
  4622.                                     $etapEntityClass = 'App\\Entity\\Etap' . $etap->getNum();
  4623.                                     $etapEntity = $this->em->getRepository($etapEntityClass)->findOneBy(['project' => $project->getId()]);
  4624.                                     $classMetadata = $this->em->getClassMetadata($etapEntityClass);
  4625.                                     $data = $this->getNbrDocUploadByEtap($etapEntity,$classMetadata);
  4626.                                     $docsUploadeCount = $docsUploadeCount + $data['docsUploadeCount'];
  4627.                                     $docsCount = $docsCount + $data['docsCount'];
  4628.                                     $array['category'][$cat->getId()]['id'] = $cat->getId();
  4629.                                     $array['category'][$cat->getId()]['name'] = $cat->getName();
  4630.                                     $array['category'][$cat->getId()]['num'] = $cat->getNum();
  4631.                                     $array['category'][$cat->getId()]['docsUploadeCount'] = $docsUploadeCount;
  4632.                                     $array['category'][$cat->getId()]['docsCount'] = $docsCount;
  4633.                                 }
  4634.                             }else{
  4635.                                 if( !$etap->getIsDelete()){
  4636.                                     $etapEntityClass = 'App\\Entity\\Etap' . $etap->getNum();
  4637.                                     $etapEntity = $this->em->getRepository($etapEntityClass)->findOneBy(['project' => $project->getId()]);
  4638.                                     $classMetadata = $this->em->getClassMetadata($etapEntityClass);
  4639.                                     $data = $this->getNbrDocUploadByEtap($etapEntity,$classMetadata);
  4640.                                     $docsUploadeCount = $docsUploadeCount + $data['docsUploadeCount'];
  4641.                                     $docsCount = $docsCount + $data['docsCount'];
  4642.                                     $array['category'][$cat->getId()]['id'] = $cat->getId();
  4643.                                     $array['category'][$cat->getId()]['name'] = $cat->getName();
  4644.                                     $array['category'][$cat->getId()]['num'] = $cat->getNum();
  4645.                                     $array['category'][$cat->getId()]['docsUploadeCount'] = $docsUploadeCount;
  4646.                                     $array['category'][$cat->getId()]['docsCount'] = $docsCount;
  4647.                                 }
  4648.                             }
  4649.                         }
  4650.                     }else{
  4651.                         $array['category'][$cat->getId()]['id'] = $cat->getId();
  4652.                         $array['category'][$cat->getId()]['name'] = $cat->getName();
  4653.                         $array['category'][$cat->getId()]['num'] = $cat->getNum();
  4654.                         $array['category'][$cat->getId()]['docsUploadeCount'] = 0;
  4655.                         $array['category'][$cat->getId()]['docsCount'] = 0;
  4656.                     }
  4657.                 }
  4658.                 if($i > 5)
  4659.                     $i = 0;
  4660.                 $array['category'][$cat->getId()]['color'] = $catColor[$i];
  4661.                 $i = $i + 1;
  4662.             }
  4663.             $pourcentageGlobale = 0;
  4664.             $docsUploadeCountGlobale = 0;
  4665.             $docsCountGlobale = 0;
  4666.             foreach ($array['category'] as &$item){
  4667.                 $pourcentage = (int)$item['docsCount'] ? (((int)$item['docsUploadeCount'] / (int)$item['docsCount']) * 100) : 0.0 ;
  4668.                 $item['pourcentage'] = number_format($pourcentage,1);
  4669.                 $item['pourcentage_str'] = (int)$item['docsUploadeCount'].'/'.(int)$item['docsCount'].' doc(s)';
  4670.                 $pourcentageGlobale = $pourcentage +  $pourcentageGlobale;
  4671.                 $docsUploadeCountGlobale = (int)$item['docsUploadeCount'] +  $docsUploadeCountGlobale;
  4672.                 $docsCountGlobale = (int)$item['docsCount'] +  $docsCountGlobale;
  4673.             }
  4674.             if($pourcentageGlobale > 0){
  4675.                 $array['pourcentageGlobale'] = number_format($pourcentageGlobale / count($cats),1);
  4676.                 $array['docsUploadeCountGlobale'] = $docsUploadeCountGlobale;
  4677.                 $array['docsCountGlobale'] = $docsCountGlobale;
  4678.             }else{
  4679.                 $array['pourcentageGlobale'] = 0.0;
  4680.                 $array['docsUploadeCountGlobale'] = $docsUploadeCountGlobale;
  4681.                 $array['docsCountGlobale'] = $docsCountGlobale;
  4682.             }
  4683.         }
  4684.         return $array;
  4685.     }
  4686.     private function arrayFilesNotUtile(){
  4687.         $array = [
  4688.             'fileArretePcDp',
  4689.             'fileDossierPcDp',
  4690.             'filePVPassageHuissier',
  4691.             'fileCertificatNonRecours',
  4692.             'fileCertificatNonRetrait',
  4693.             'fileCertificatNonOpposition',
  4694.             'fileCertificatNonOppositionMultiple',
  4695.             'fileDocDroc',
  4696.             'fileDaact',
  4697.             'filePromessebail',
  4698.             'fileEtatDecriptif',
  4699.             'fileEtatHypothecaire',
  4700.             'filePublicationSPR',
  4701.             'fileTitrePropriete',
  4702.             'fileBailSigne',
  4703.             'fileAvenantBail',
  4704.             'fileKbisEts',
  4705.             'fileConsuel',
  4706.             'fileContratEpc',
  4707.             'fileAnnexes',
  4708.             'fileConsuelEtap20',
  4709.             'fileTestReception',
  4710.             'fileTestPr',
  4711.             'fileDiagnostiqueCharpente',
  4712.             'fileEtudeSole',
  4713.             'fileDocEtap171',
  4714.             'fileOrderService',
  4715.             'filePlanningPrevisionnel',
  4716.             'filePVDemarrage',
  4717.             'fileCheminAcces',
  4718.             'fileDalleBetonShelter',
  4719.             'fileFondationTerminees',
  4720.             'fileNoteCalculBetonFeraillage',
  4721.             'filePhotosPlateforme',
  4722.             'filePlanImplantationBatimentAvecDalleBeton',
  4723.             'filePVReception',
  4724.             'fileNoteCalculCharpente173',
  4725.             'fileOssatureSecondaireBardage173',
  4726.             'filePhotoRenforcementBardage173Multiple',
  4727.             'filePhotoRenforcementcharpente173Multiple',
  4728.             'filePhotoRenforcementCouvertureTermine173Multiple',
  4729.             'filePlanCouverture173',
  4730.             'filePlanDescriptionTravauxDeposeCouverture173',
  4731.             'filePlanDescriptionTravauxRenforcementCharpente173',
  4732.             'filePlansCharpente173',
  4733.             'filePVreception173',
  4734.             'fileVues3d173',
  4735.             'fileDescentesCables174',
  4736.             'fileNoteCalculSousLisePV174',
  4737.             'filePhotosGenerateur174',
  4738.             'filePlanCalepinageModule174',
  4739.             'filePlanCaplageStrings174',
  4740.             'filePVReception174',
  4741.             'filePvTerminees174',
  4742.             'filePvTerminees174Multiple',
  4743.             'fileRaccordementLocalOnduleur174',
  4744.             'fileSchemaUnifilaireInstallation174',
  4745.             'fileShemaAgencementShelterPhotos174',
  4746.             'fileShemaUnifilaireSystemeMonitoring174',
  4747.             'fileTestPrMiseService174',
  4748.             'fileTestPrMiseService174Multiple',
  4749.             'filePhotosLiaisonTerminee175Multiple',
  4750.             'filePVReception175Multiple',
  4751.             'fileDaact175175Multiple',
  4752.             'fileTestVerificationTravauxElectriqueFiche174',
  4753.             'fileDaact175',
  4754.             'fileNoteCalculCableAcLiaison175',
  4755.             'filePhotosLiaisonTerminee175',
  4756.             'filePhotosLiaisonTerminee175',
  4757.             'filePlanTranchee175',
  4758.             'filePVReception175',
  4759.             'fileDoeEtap201',
  4760.             'fileMailEnedisConfirmation',
  4761.             'fileCrdSignee',
  4762.             'fileCrdSigneeSansPtf',
  4763.             'filePreuveVirement',
  4764.             'filePreuveVirementSansPtf',
  4765.             'filePtf',
  4766.             'fileCardiSigne',
  4767.             'fileCexSigne',
  4768.             'fileDoe',
  4769.             'fileAttestionInstallateur',
  4770.             'fileAttestionProducteur',
  4771.             'filePhotosMultiple',
  4772.             'fileGarantieBancaireMultiple',
  4773.             'fileContratAchatSigne'
  4774.         ];
  4775.         return $array;
  4776.     }
  4777.     public function getNbrDocUploadByEtap($etap,$classMetadata){
  4778.         $fieldNames = $classMetadata->getAssociationNames();
  4779.         $targetEntity = 'App\Entity\DocUpload';
  4780.         $docsUploadeCount = 0 ;
  4781.         $docsCount = 0 ;
  4782.         $isFilePreuveVirementMultiple = null;
  4783.         $isFileCrdSigneefMultiple = null;
  4784.         if($etap){
  4785.             foreach ($fieldNames as $fieldName) {
  4786.                 if(!in_array($fieldName,$this->arrayFilesNotUtile())){
  4787.                     $associationMappings = $classMetadata->getAssociationMapping($fieldName);
  4788.                     if ($associationMappings['type'] === \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_ONE && $associationMappings['targetEntity'] === $targetEntity) {
  4789.                         $docsCount = $docsCount + 1;
  4790.                         $nameGeteurFiled = 'get'.ucfirst($fieldName);
  4791.                         $filedValue = $etap->{$nameGeteurFiled}();
  4792.                         if($filedValue){
  4793.                             $isNotArchive = false;
  4794.                             if(!$filedValue->getIsArchived()) {
  4795.                                 $isNotArchive= true;
  4796.                             }
  4797.                             if($isNotArchive){
  4798.                                 $docsUploadeCount = $docsUploadeCount +1;
  4799.                             }
  4800.                         }
  4801.                     }
  4802.                     if ($associationMappings['type'] === \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_MANY && $associationMappings['targetEntity'] === $targetEntity) {
  4803.                        if($etap->getEtap()){
  4804.                            if($etap->getEtap()->getNum() != 172 or ($etap->getEtap()->getNum() == 172 and  !in_array($fieldName ,['filePhotosPlateformeMultiple','fileCheminAccesMultiple']))){
  4805.                                if(in_array($fieldName ,['filePreuveVirementSansPtfMultiple','filePreuveVirementMultiple'])){
  4806.                                    $isFilePreuveVirementMultiple = true;
  4807.                                }elseif(in_array($fieldName ,['fileCrdSigneeSansPtfMultiple','fileCrdSigneeMultiple'])){
  4808.                                    $isFileCrdSigneefMultiple = true;
  4809.                                }else{
  4810.                                    $docsCount = $docsCount + 1;
  4811.                                }
  4812.                                $nameGeteurFiled = 'get'.ucfirst($fieldName);
  4813.                                $filedValue = $etap->{$nameGeteurFiled}();
  4814.                                if(!$filedValue->isEmpty()){
  4815.                                    $isNotArchive = false;
  4816.                                    foreach ($filedValue as $item) {
  4817.                                        if(!$item->getIsArchived()) {
  4818.                                            $isNotArchive= true;
  4819.                                        }
  4820.                                    }
  4821.                                    if($isNotArchive){
  4822.                                        if(in_array($fieldName ,['filePreuveVirementSansPtfMultiple','filePreuveVirementMultiple'])){
  4823.                                            $isFilePreuveVirementMultiple = true;
  4824.                                        }elseif(in_array($fieldName ,['fileCrdSigneeSansPtfMultiple','fileCrdSigneeMultiple'])){
  4825.                                            $isFileCrdSigneefMultiple = true;
  4826.                                        }else{
  4827.                                            $docsUploadeCount = $docsUploadeCount +1;
  4828.                                        }
  4829.                                    }
  4830.                                }
  4831.                            }
  4832.                        }
  4833.                     }
  4834.                 }
  4835.             }
  4836.             if($isFilePreuveVirementMultiple){
  4837.                 $docsUploadeCount = $docsUploadeCount +1;
  4838.                 $docsCount = $docsCount + 1;
  4839.             }
  4840.             if($isFileCrdSigneefMultiple){
  4841.                 $docsUploadeCount = $docsUploadeCount +1;
  4842.                 $docsCount = $docsCount + 1;
  4843.             }
  4844.         }
  4845.         return [
  4846.             'docsUploadeCount' => $docsUploadeCount,
  4847.             'docsCount' => $docsCount,
  4848.         ];
  4849.     }
  4850.     public function getNbrDocUploadByEtapDetail($etap,$classMetadata){
  4851.         $fieldNames = $classMetadata->getAssociationNames();
  4852.         $targetEntity = 'App\Entity\DocUpload';
  4853.         $docsUploadeCount = 0 ;
  4854.         $docsCount = 0 ;
  4855.         $isFilePreuveVirementMultiple = null;
  4856.         $isFileCrdSigneefMultiple = null;
  4857.         foreach ($fieldNames as $fieldName) {
  4858.             if(!in_array($fieldName,$this->arrayFilesNotUtile())){
  4859.                 $associationMappings = $classMetadata->getAssociationMapping($fieldName);
  4860.                 if ($associationMappings['type'] === \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_ONE && $associationMappings['targetEntity'] === $targetEntity) {
  4861.                     $docsCount = $docsCount + 1;
  4862.                     $nameGeteurFiled = 'get'.ucfirst($fieldName);
  4863.                     $filedValue = $etap->{$nameGeteurFiled}();
  4864.                     if($filedValue){
  4865.                         $isNotArchive = false;
  4866.                         if(!$filedValue->getIsArchived()) {
  4867.                             $isNotArchive= true;
  4868.                         }
  4869.                         if($isNotArchive){
  4870.                             $docsUploadeCount = $docsUploadeCount +1;
  4871.                         }
  4872.                     }
  4873.                 }
  4874.                 if ($associationMappings['type'] === \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_MANY && $associationMappings['targetEntity'] === $targetEntity) {
  4875.                         $docsCount = $docsCount + 1;
  4876.                         $nameGeteurFiled = 'get'.ucfirst($fieldName);
  4877.                         $filedValue = $etap->{$nameGeteurFiled}();
  4878.                         if(!$filedValue->isEmpty()){
  4879.                             $isNotArchive = false;
  4880.                             foreach ($filedValue as $item) {
  4881.                                 if(!$item->getIsArchived()) {
  4882.                                     $isNotArchive= true;
  4883.                                 }
  4884.                             }
  4885.                             if($isNotArchive){
  4886.                                 $docsUploadeCount = $docsUploadeCount +1;
  4887.                             }
  4888.                         }
  4889.                 }
  4890.             }
  4891.         }
  4892.         return [
  4893.             'docsUploadeCount' => $docsUploadeCount,
  4894.             'docsCount' => $docsCount,
  4895.         ];
  4896.     }
  4897.      public function getNomenclatureContratConstruction($etap,$file,$stringFile,$nomContrat){
  4898.         if(is_object($etap) && is_object($file)){
  4899.             $nameProject = $etap->getProject()->getName();
  4900.             $nameSpv = $etap->getProject()->getSpv()->getName();
  4901.             $extension = substr($file->getPath(), strrpos($file->getPath(), ".",-1) + 1);
  4902.             $nomContrat = $nomContrat ? $nomContrat :'';
  4903.             $nomenclature = $nameProject.' - '.$nameSpv.' - '.$stringFile.' - '.$nomContrat.'.'.$extension;
  4904.             $file->setNomenclature($nomenclature);
  4905.             $this->em->persist($file);
  4906.             $this->em->flush();
  4907.             return $nomenclature;
  4908.         }
  4909.         return false;
  4910.      }
  4911.     public function getNomenclature($etap,$file,$stringFile){
  4912.         if(is_object($etap) && is_object($file)){
  4913.             $nameProject = $etap->getProject()->getName();
  4914.             $nameSpv = $etap->getProject()->getSpv()? $etap->getProject()->getSpv()->getName() : '';
  4915.             $extension = substr($file->getPath(), strrpos($file->getPath(), ".",-1) + 1);
  4916.             $nomenclature = $nameProject.' - '.$nameSpv.' - '.$stringFile.'.'.$extension;
  4917.             $file->setNomenclature($nomenclature);
  4918.             $this->em->persist($file);
  4919.             $this->em->flush();
  4920.             return $nomenclature;
  4921.         }
  4922.         return false;
  4923.     }
  4924.     public function uploadFileToDropbox($doc,$project,$pathTo){
  4925. //        $dropboxKey = $this->params->get('dropbox_key');
  4926. //        $dropboxSecret = $this->params->get('dropbox_secret');
  4927. //        $dropboxToken= $this->params->get('dropbox_token');
  4928. //        $app = new DropboxApp($dropboxKey,$dropboxSecret,$dropboxToken);
  4929. //        $dropbox = new Dropbox($app);
  4930. //        if(is_object($doc) && is_object($project) ) {
  4931. //            try {
  4932. //                $path = $this->params->get('uploads_directory') . '/' . $doc->getPath();
  4933. //                $userName = $project->getUserCreated()->getFirstname().' '.$project->getUserCreated()->getLastname();
  4934. //                $pathTo = "/Projets signés/".trim($project->getSpv()->getName())."/Fichiers Projets/".trim($userName)."/".trim($project->getName())."/".trim($pathTo);
  4935. //                $file = $dropbox->upload($path,$pathTo );
  4936. //                $doc->setIdDropBox($file->getId());
  4937. //                $doc->setPathDropbox($file->getPathDisplay());
  4938. //                $this->em->persist($doc);
  4939. //                $this->em->flush();
  4940. //                return true;
  4941. //            } catch (DropboxClientException $e) {
  4942. //                return false;
  4943. //            }
  4944. //        }
  4945.         return true;
  4946.     }
  4947.     public function addCommentDoc($request,$doc)
  4948.     {
  4949.         $commentText = $request->get('commentText');
  4950.         $docTokenParent = $request->get('docTokenParent');
  4951.         if($commentText and $doc){
  4952.             $commentEntity = new CommentDoc();
  4953.             $commentEntity->setDocUpload($doc);
  4954.             $commentEntity->setUserCreated($this->security->getUser());
  4955.             $commentEntity->setTextComment($commentText);
  4956.             if($docTokenParent){
  4957.                 $parentDoc = $this->em->getRepository(CommentDoc::class)->find((int)$docTokenParent);
  4958.                 if($parentDoc){
  4959.                     $commentEntity->setParentComment($parentDoc);
  4960.                 }
  4961.             }
  4962.             $this->em->persist($commentEntity);
  4963.             $this->em->flush();
  4964.             return [
  4965.                 'commentEntity' => $commentEntity,
  4966.                 'success' => true
  4967.             ];
  4968.         }
  4969.         return [
  4970.             'success' => false
  4971.         ];
  4972.     }
  4973.     public function addTitreDoc($request,$doc)
  4974.     {
  4975.         $titreDoc = $request->get('titreDoc');
  4976.         if($titreDoc and $doc){
  4977.             $doc->setTitreDoc($titreDoc);
  4978.             $this->em->persist($doc);
  4979.             $this->em->flush();
  4980.             return [
  4981.                 'success' => true
  4982.             ];
  4983.         }
  4984.         return [
  4985.             'success' => false
  4986.         ];
  4987.     }
  4988.     public function addDateDoc($request,$doc)
  4989.     {
  4990.         $dateDoc = $request->get('dateDoc');
  4991.         if($dateDoc and $doc){
  4992.             $doc->setCreatedAt(new \DateTime($dateDoc));
  4993.             $this->em->persist($doc);
  4994.             $this->em->flush();
  4995.             return [
  4996.                 'success' => true
  4997.             ];
  4998.         }
  4999.         return [
  5000.             'success' => false
  5001.         ];
  5002.     }
  5003.     function groupSousCommentItems($menu, $level = 0)
  5004.     {
  5005.         $menuArray = [
  5006.             'id' => $menu->getId(),
  5007.             'textComment' => $menu->getTextComment(),
  5008.             'doc' => $menu->getDocUpload(),
  5009.             'user' => $menu->getUserCreated(),
  5010.             'createdAt' => $menu->getCreatedAt(),
  5011.             'level' => $level,
  5012.             'sub_menus' => [],
  5013.         ];
  5014.         $tab = [];
  5015. //        $menuArray['url_sub_menu'] = $this->getUrlSubComment($menu,$tab);
  5016.         foreach ($menu->getSubComments() as $subMenu) {
  5017.             $menuArray['sub_menus'][] = $this->groupSousCommentItems($subMenu,$level + 1);
  5018.         }
  5019.         return $menuArray;
  5020.     }
  5021.     function groupMenuTab($menus)
  5022.     {
  5023.         $array = [];
  5024.         foreach ($menus as $menu) {
  5025.             if($menu->getParentComment() == null){
  5026.                 $array[] = $this->groupSousCommentItems($menu);
  5027.             }
  5028.         }
  5029.         return $array;
  5030.     }
  5031.     function getUrlSubComment($menu,&$array)
  5032.     {
  5033.         if($menu){
  5034.             $array[] = $menu->getUrl();
  5035.             if($menu->getSubMenus()){
  5036.                 foreach ($menu->getSubMenus() as $item){
  5037.                     $this->getUrlSubComment($item,$array);
  5038.                 }
  5039.             }
  5040.         }
  5041.         return $array;
  5042.     }
  5043.     public function updateStatusTrackerAllProjects(){
  5044.         $projects = $this->em->getRepository(Project::class)->findAll();
  5045.         foreach ($projects as $project){
  5046.             $this->updateStatusTracker($project);
  5047.         }
  5048.     }
  5049.     public function updateStatusTracker($project,$isDev5 = false){
  5050.         if($project){
  5051.             // Développement
  5052.             $isDev0 = false;
  5053.             $isDev1 = false;
  5054.             $isDev2 = false;
  5055.             $isDev3 = false;
  5056.             $etap5 = $this->em->getRepository(Etap5::class)->findOneBy(['project'=>$project->getId()]);
  5057.             if($project->getFilePromessebail()){
  5058.                 $isDev0 = true ;
  5059.             }elseif ($etap5 && $this->checkDocNotArchive($etap5->getFilePromessebailMultiple())) {
  5060.                 $isDev0 = true ;
  5061.             }
  5062.             $etap1 = $this->em->getRepository(Etap1::class)->findOneBy(['project'=>$project->getId()]);
  5063.             if($etap1 && $this->checkDocNotArchive($etap1->getFileArretePcDpMultiple())){
  5064.                 $isDev1 = true ;
  5065.             }elseif ($etap1 && $etap1->getDateArretePcDp()) {
  5066.                 $isDev1 = true ;
  5067.             }
  5068.             $etap10 = $this->em->getRepository(Etap10::class)->findOneBy(['project'=>$project->getId()]);
  5069.             if($etap10 && $this->checkDocNotArchive( $etap10->getFileCrdSigneeMultiple())){
  5070.                 $isDev2 = true ;
  5071.             }elseif ($etap10 && $this->checkDocNotArchive($etap10->getFileCrdSigneeSansPtfMultiple())) {
  5072.                 $isDev2 = true ;
  5073.             }
  5074.             $etap7 = $this->em->getRepository(Etap7::class)->findOneBy(['project'=>$project->getId()]);
  5075. //            if($etap7 && $this->checkDocNotArchive($etap7->getFileBailSigneMultiple()) && $isDev1 && $isDev2 ){
  5076.             if($etap7 && $this->checkDocNotArchive($etap7->getFileBailSigneMultiple())){
  5077.                 $isDev3 = true ;
  5078.             }
  5079.             // Construction
  5080.             $isDev4 = false;
  5081.             $isDev5New = false;
  5082.             $isDev6 = false;
  5083.             $dateNow = new \DateTime();
  5084.             $dateNow1 = new \DateTime($dateNow->format('Y-m-d').' 23:59:59');
  5085.             $etap172 = $this->em->getRepository(Etap172::class)->findOneBy(['project'=>$project->getId()]);
  5086.             $etap173 = $this->em->getRepository(Etap173::class)->findOneBy(['project'=>$project->getId()]);
  5087.             $etap174 = $this->em->getRepository(Etap174::class)->findOneBy(['project'=>$project->getId()]);
  5088.             if($etap172 && $etap172->getDateDebutFondation() && ($dateNow1 >= $etap172->getDateDebutFondation())){
  5089.                 $isDev4 = true ;
  5090.             }elseif ($etap173 && $etap173->getDateDebutCharpente() && ($dateNow1 >= $etap173->getDateDebutCharpente()) ){
  5091.                 $isDev4 = true ;
  5092.             }elseif ($etap173 && $etap173->getDateDebutCouverture() && ($dateNow1 >= $etap173->getDateDebutCouverture()) ){
  5093.                 $isDev4 = true ;
  5094.             }elseif ($etap174 && $etap174->getDateDebutPosePv() && ($dateNow1 >= $etap174->getDateDebutPosePv()) ){
  5095.                 $isDev4 = true ;
  5096.             }
  5097.             $etap175 = $this->em->getRepository(Etap175::class)->findOneBy(['project'=>$project->getId()]);
  5098.             if($etap175 && $etap175->getDateAchevementTraveaux() && ($dateNow1 >= $etap175->getDateAchevementTraveaux()) ){
  5099.                 $isDev5New = true ;
  5100.             }
  5101.             $etap20 = $this->em->getRepository(Etap20::class)->findOneBy(['project'=>$project->getId()]);
  5102.             $etap13 = $this->em->getRepository(Etap13::class)->findOneBy(['project'=>$project->getId()]);
  5103.             if($etap20 && $this->checkDocNotArchive($etap20->getFileConsuelEtap20Multiple())){
  5104.                 $isDev6 = true ;
  5105.             }elseif ($etap20 && $etap20->getDateConsuelEtap20()) {
  5106.                 $isDev6 = true ;
  5107.             }
  5108.             if($etap13 && $this->checkDocNotArchive($etap13->getFileConsuelMultiple())){
  5109.                 $isDev6 = true ;
  5110.             }elseif ($etap13 && $etap13->getFileConsuel()) {
  5111.                 $isDev6 = true ;
  5112.             }elseif ($etap13 && $etap13->getDateConsuel()) {
  5113.                 $isDev6 = true ;
  5114.             }
  5115.             // Exploitation
  5116.             $isOperating = false;
  5117.             $etap14 = $this->em->getRepository(Etap14::class)->findOneBy(['project'=>$project->getId()]);
  5118.             if($etap14 && $etap14->getDateMiseEnService()){
  5119.                 $isOperating = true ;
  5120.             }elseif ($project->getDateMiseEnService()) {
  5121.                 $isOperating = true ;
  5122.             }
  5123.             $status = 0;
  5124.             $statusAdministrateur = 0;
  5125.             if($isOperating){
  5126.                 $status = StatusTracker::STATUS_operating;
  5127.             }elseif ($isDev6){
  5128.                 $status = StatusTracker::STATUS_dev_6;
  5129.             }elseif ($isDev5New){
  5130.                 $status = StatusTracker::STATUS_dev_5;
  5131.             }elseif ($isDev4){
  5132.                 $status = StatusTracker::STATUS_dev_4;
  5133.             }elseif ($isDev3){
  5134.                 $status = StatusTracker::STATUS_dev_3;
  5135.             }elseif ($isDev2){
  5136.                 $status = StatusTracker::STATUS_dev_2;
  5137.             }elseif ($isDev1){
  5138.                 $status = StatusTracker::STATUS_dev_1;
  5139.             }elseif ($isDev0){
  5140.                 $status = StatusTracker::STATUS_dev_0;
  5141.             }
  5142.             if(in_array($status,[StatusTracker::STATUS_operating])){
  5143.                 $statusAdministrateur = Project::STATUS_CUSTOM_EXPLOITATION;
  5144.             }elseif (in_array($status,[StatusTracker::STATUS_dev_6,StatusTracker::STATUS_dev_5,StatusTracker::STATUS_dev_4])){
  5145.                 $statusAdministrateur = Project::STATUS_CUSTOM_CONSTRUCTION;
  5146.             }elseif (in_array($status,[StatusTracker::STATUS_dev_3,StatusTracker::STATUS_dev_2,StatusTracker::STATUS_dev_1,StatusTracker::STATUS_dev_0])){
  5147.                 $statusAdministrateur = Project::STATUS_CUSTOM_DEVELOPPEMENT;
  5148.             }
  5149.             $statusTrackerProject = $this->em->getRepository(StatusTracker::class)->findOneBy(['project'=>$project->getId()],['createdAt'=>'desc']);
  5150.             if($statusTrackerProject){
  5151.                 if($statusTrackerProject->getStatus() != $status){
  5152.                     $entity = new StatusTracker();
  5153.                     $entity->setProject($project);
  5154.                     $entity->setStatus($status);
  5155.                     $entity->setStatusAdministratif($statusAdministrateur);
  5156.                     $this->em->persist($entity);
  5157.                     $project->setStatusAdministratif($statusAdministrateur);
  5158.                     $project->setStatusTrackerActuel($status);
  5159.                     $this->em->persist($project);
  5160.                     $this->em->flush();
  5161.                 }else{
  5162.                     $statusTrackerProject->setProject($project);
  5163.                     $statusTrackerProject->setStatus($status);
  5164.                     $statusTrackerProject->setStatusAdministratif($statusAdministrateur);
  5165.                     $this->em->persist($statusTrackerProject);
  5166.                     $project->setStatusAdministratif($statusAdministrateur);
  5167.                     $project->setStatusTrackerActuel($status);
  5168.                     $this->em->persist($project);
  5169.                     $this->em->flush();
  5170.                 }
  5171.             }else{
  5172.                 $entity = new StatusTracker();
  5173.                 $entity->setProject($project);
  5174.                 $entity->setStatus($status);
  5175.                 $entity->setStatusAdministratif($statusAdministrateur);
  5176.                 $this->em->persist($entity);
  5177.                 $project->setStatusAdministratif($statusAdministrateur);
  5178.                 $project->setStatusTrackerActuel($status);
  5179.                 $this->em->persist($project);
  5180.                 $this->em->flush();
  5181.             }
  5182.             $this->updateStatusUrbanisme($project);
  5183.             $this->updateStatusFoncier($project);
  5184.             $this->updateStatusTrackerConstruction($project);
  5185.             $this->updateStatusTrackerConstruction($project);
  5186.         }
  5187.     }
  5188.     public function checkDocNotArchive($array){
  5189.         $isNotVide = false;
  5190.         if($array){
  5191.             foreach ($array as $item){
  5192.                 if(!$item->getIsArchived()){
  5193.                     $isNotVide = true;
  5194.                     break;
  5195.                 }
  5196.             }
  5197.         }
  5198.         return $isNotVide ;
  5199.     }
  5200.     public function getChampsUpdates(){
  5201.         $array = [];
  5202.         $array[0]['name'] = 'SPV';$array[0]['value'] = 'projet-1-etap-0-spv' ;
  5203.         $array[1]['name'] = 'Adresse';$array[1]['value'] = 'projet-1-etap-0-adresse' ;
  5204.         $array[2]['name'] = 'Code postal';$array[2]['value'] = 'projet-1-etap-0-codePostal' ;
  5205.         $array[3]['name'] = 'Ville';$array[3]['value'] = 'projet-1-etap-0-city' ;
  5206.         $array[4]['name'] = 'Point GPS de la Future Centrale (Latitude)';$array[4]['value'] = 'projet-1-etap-0-longi' ;
  5207.         $array[5]['name'] = 'Point GPS de la Future Centrale (Longitude)';$array[5]['value'] = 'projet-1-etap-0-lat' ;
  5208.         $array[6]['name'] = 'Parcelle';$array[6]['value'] = 'projet-1-etap-0-numParcelle' ;
  5209.         $array[7]['name'] = 'Date T0 du projet';$array[7]['value'] = 'projet-1-etap-0-DateT0Date-1' ;
  5210.         $array[8]['name'] = 'Statut Administratif';$array[8]['value'] = 'projet-1-etap-0-statusAdministratif' ;
  5211.         $array[9]['name'] = 'Reference PC/DP (Etape 1 Timeline Urbanisme)';$array[9]['value'] = 'projet-0-etap-1-referencePc' ;
  5212.         $array[10]['name'] = 'Date Arrete PC/DP (Etape 1 Timeline Urbanisme)';$array[10]['value'] = 'projet-0-etap-1-dateArretePcDp-1' ;
  5213.         $array[11]['name'] = 'Date 1 passage huissier PC (Etape 2 Timeline Urbanisme)';$array[11]['value'] = 'projet-0-etap-2-date1PassageHuissier-1' ;
  5214.         $array[12]['name'] = 'Date 2 passage huissier PC (Etape 2 Timeline Urbanisme)';$array[12]['value'] = 'projet-0-etap-2-date2PassageHuissier-1' ;
  5215.         $array[13]['name'] = 'Date 3 passage huissier PC (Etape 2 Timeline Urbanisme)';$array[13]['value'] = 'projet-0-etap-2-date3PassageHuissier-1' ;
  5216.         $array[14]['name'] = 'Date PDB (Etape 1 Timeline Foncier)';$array[14]['value'] = 'projet-0-etap-5-dateExpirationPromesseBail-1' ;
  5217.         $array[15]['name'] = 'Loyer';$array[15]['value'] = 'projet-0-etap-5-loyerConfirme' ;
  5218.         $array[16]['name'] = 'Soulte';$array[16]['value'] = 'projet-0-etap-5-soulteConfirme' ;
  5219.         $array[17]['name'] = 'Duree du bail';$array[17]['value'] = 'projet-0-etap-5-dureeBail' ;
  5220.         $array[17001]['name'] = 'Durée de prorogation (en mois)';$array[17001]['value'] = 'projet-0-etap-5-d2' ;
  5221.         $array[18]['name'] = 'SIRET de l\'ETS';$array[18]['value'] = 'projet-0-etap-8-siretEts' ;
  5222.         $array[19]['name'] = 'Numero de parcelle';$array[19]['value'] = 'projet-0-etap-8-numParcelleEtablissement' ;
  5223. //        $array[20]['name'] = 'Tarif Fit prévisionnel';$array[20]['value'] = 'projet-0-etap-9-tarifFit' ;
  5224.         $array[21]['name'] = 'Reference Enedis';$array[21]['value'] = 'projet-0-etap-10-referenceEnedis' ;
  5225.         $array[22]['name'] = 'Numero de contrat (CARDI)';$array[22]['value'] = 'projet-0-etap-12-numeroCardiMultiple-0-numeroCardi' ;
  5226.         $array[23]['name'] = 'Date du consuel';$array[23]['value'] = 'projet-0-etap-13-dateConsuel-1' ;
  5227.         $array[24]['name'] = 'Nom du bailleur';$array[24]['value'] = 'projet-0-etap-14-firstnameProprietaire' ;
  5228.         $array[25]['name'] = 'Prenom du bailleur';$array[25]['value'] = 'projet-0-etap-14-lastnameProprietaire' ;
  5229.         $array[26]['name'] = 'Numero de telephone du proprietaire';$array[26]['value'] = 'projet-0-etap-14-phoneProprietaire' ;
  5230.         $array[27]['name'] = 'E-mail du proprietaire';$array[27]['value'] = 'projet-0-etap-14-emailProprietaire' ;
  5231.         $array[28]['name'] = 'Numero de contrat d\'Achat(BTA) (Etape 8 Timeline raccordement)';$array[28]['value'] = 'projet-0-etap-15-informationMultiple-0-numeroContratAchat' ;
  5232.         $array[28001]['name'] = 'Type de contrat (Etape 8 Timeline raccordement)';$array[28001]['value'] = 'projet-0-etap-15-informationMultiple-0-typeContrat' ;
  5233.         $array[29]['name'] = 'Capacité installée (KWc)';$array[29]['value'] = 'projet-1-etap-0-capacite' ;
  5234.         $array[1030]['name'] = 'Capacité injectée (kVA)';$array[1030]['value'] = 'projet-1-etap-0-puissance' ;
  5235.         $array[30]['name'] = 'Productible (P50)';$array[30]['value'] = 'projet-1-etap-0-productible' ;
  5236.         $array[30]['name'] = 'Type de batîment';$array[30]['value'] = 'projet-1-etap-0-typeBatimentProject' ;
  5237.         $array[31]['name'] = 'Date de dépôt de la DOC / DROC (Etape 3 Timeline Urbanisme)';$array[31]['value'] = 'projet-0-etap-3-dateDocDroc-1' ;
  5238.         $array[32]['name'] = 'Date de dépôt de la DAACT (Etape 4 Timeline Urbanisme)';$array[32]['value'] = 'projet-0-etap-4-dateDaact-1' ;
  5239.         $array[33]['name'] = 'Durée de validité (en mois) (Etape 1 Timeline foncier)';$array[33]['value'] = 'projet-0-etap-5-d1' ;
  5240.         $array[60]['name'] = 'Durée de prorogation (en mois) (Etape 1 Timeline foncier)';$array[60]['value'] = 'projet-0-etap-5-d2' ;
  5241.         $array[34]['name'] = 'Contrepartie en nature (Etape 1 Timeline foncier)';$array[34]['value'] = 'projet-0-etap-5-loyerEnNature' ;
  5242.         $array[34]['name'] = 'Nom du notaire (Etape 2 Timeline foncier)';$array[34]['value'] = 'projet-0-etap-6-nomNotaire' ;
  5243. //        $array[35]['name'] = 'Date maximale d\'achèvement des travaux (Etape 2 Timeline raccordement)';$array[35]['value'] = 'projet-0-etap-9-dateMaximaleAchevement-1' ;
  5244.         $array[36]['name'] = 'Montant acompte (Etape 3 Timeline raccordement)';$array[36]['value'] = 'projet-0-etap-10-montantAcompte' ;
  5245.         $array[37]['name'] = 'Montant coût total (Etape 3 Timeline raccordement)';$array[37]['value'] = 'projet-0-etap-10-montantCoutTotal' ;
  5246.         $array[37]['name'] = 'Numéro PRM (Etape 4 Timeline raccordement)';$array[37]['value'] = 'projet-0-etap-12-numeroCardiMultiple-0-identifiantEnedis' ;
  5247.         $array[38]['name'] = 'Date du consuel (Etape 5 Timeline raccordement)';$array[38]['value'] = 'projet-0-etap-13-dateConsuel-1' ;
  5248.         $array[39]['name'] = 'Date de mise en service (Etape 6 Timeline raccordement)';$array[39]['value'] = 'projet-0-etap-14-dateMiseEnService-1' ;
  5249.         $array[40]['name'] = 'Tarif (Etape 8 Timeline raccordement)';$array[40]['value'] = 'projet-0-etap-15-tarifContratAchat' ;
  5250.         $array[41]['name'] = 'Date de début de contrat d’achat (Etape 8 Timeline raccordement)';$array[41]['value'] = 'projet-0-etap-15-dateDebutContratAchat-1' ;
  5251.         $array[42]['name'] = 'Date de fin de contrat d’achat (Etape 8 Timeline raccordement)';$array[42]['value'] = 'projet-0-etap-15-dateFinContratAchat-1' ;
  5252.         $array[43]['name'] = 'Périodicité de la facturation (Etape 8 Timeline raccordement)';$array[43]['value'] = 'projet-0-etap-15-peridiciteFacturation' ;
  5253.         $array[44]['name'] = 'Date début des fondations (Etape 4-2 Timeline construction)';$array[44]['value'] = 'projet-0-etap-172-dateDebutFondation-1' ;
  5254.         $array[45]['name'] = 'Début renfort charpente (Etape 4-3 Timeline construction)';$array[45]['value'] = 'projet-0-etap-173-dateDebutCharpente-1' ;
  5255.         $array[46]['name'] = 'Fin renfort charpente (Etape 4-3 Timeline construction)';$array[46]['value'] = 'projet-0-etap-173-dateFinCharpente-1' ;
  5256.         $array[47]['name'] = 'Début couverture (Etape 4-3 Timeline construction)';$array[47]['value'] = 'projet-0-etap-173-dateDebutCouverture-1' ;
  5257.         $array[48]['name'] = 'Fin couverture (Etape 4-3 Timeline construction)';$array[48]['value'] = 'projet-0-etap-173-dateFinCouverture-1' ;
  5258.         $array[49]['name'] = 'Début pose PV (Etape 4-4 Timeline construction)';$array[49]['value'] = 'projet-0-etap-174-dateDebutPosePv-1' ;
  5259.         $array[50]['name'] = 'Fin pose PV (Etape 4-4 Timeline construction)';$array[50]['value'] = 'projet-0-etap-174-dateFinPosePv-1' ;
  5260.         $array[51]['name'] = 'Date d’achèvement des travaux (Etape 4-5 Timeline construction)';$array[51]['value'] = 'projet-0-etap-175-dateAchevementTraveaux-1' ;
  5261.         $array[52]['name'] = 'Date du consuel (Etape 5 Timeline construction)';$array[52]['value'] = 'projet-0-etap-20-dateConsuelEtap20-1' ;
  5262.         $array[53]['name'] = 'Date du raccordement (Etape 7 Timeline construction)';$array[53]['value'] = 'projet-0-etap-21-dateRaccordement-1' ;
  5263.         $array[54]['name'] = 'Date de mise en service (Etape 7 Timeline construction)';$array[54]['value'] = 'projet-0-etap-21-dateMiseEnService-1' ;
  5264.         $array[55]['name'] = 'Prix EPC (Etape 3 Timeline construction)';$array[55]['value'] = 'projet-0-etap-16-prixEpc' ;
  5265.         $array[56]['name'] = 'Budget Développement';$array[56]['value'] = 'projet-1-etap-0-budgetDeveloppement' ;
  5266.         $array[57]['name'] = 'Budget Construction';$array[57]['value'] = 'projet-1-etap-0-budgetConstruction' ;
  5267.         $array[58]['name'] = 'Budget Exploitation';$array[58]['value'] = 'projet-1-etap-0-budgetExploitation' ;
  5268.         $array[59]['name'] = 'Stade de construction';$array[59]['value'] = 'projet-1-etap-0-stadeConstruction' ;
  5269.         $array[60]['name'] = 'Etat charpente (Etape 0 Timeline Construction)';$array[60]['value'] = 'projet-0-etap-159-etatCharpente' ;
  5270.         $array[61]['name'] = 'Type de toiture existante (Etape 0 Timeline Construction)';$array[61]['value'] = 'projet-0-etap-159-typeToitureExistante' ;
  5271.         $array[62]['name'] = 'Type de rénovation (Etape 0 Timeline Construction)';$array[62]['value'] = 'projet-0-etap-159-typeRenovation' ;
  5272.         $array[63]['name'] = 'Type de toiture Ã  poser (Etape 0 Timeline Construction)';$array[63]['value'] = 'projet-0-etap-159-typeToiturePoser' ;
  5273.         $array[64]['name'] = 'Terrassement (Etape 1 Timeline foncier)';$array[64]['value'] = 'projet-0-etap-5-terrassement' ;
  5274.         $array[65]['name'] = 'Tranchée (Etape 1 Timeline foncier)';$array[65]['value'] = 'projet-0-etap-5-tranchee' ;
  5275.         $array[66]['name'] = 'Bardage (Etape 1 Timeline foncier)';$array[66]['value'] = 'projet-0-etap-5-bardage' ;
  5276.         $array[67]['name'] = 'Rénovation charpente (Etape 1 Timeline foncier)';$array[67]['value'] = 'projet-0-etap-5-renovationCharpente' ;
  5277.         $array[68]['name'] = 'Désamiantage (Etape 1 Timeline foncier)';$array[68]['value'] = 'projet-0-etap-5-desamiantage' ;
  5278.         $array[69]['name'] = 'Montant coût total (Etape 3 Timeline Raccordement)';$array[69]['value'] = 'projet-0-etap-10-montantCoutTotal' ;
  5279.         $array[70]['name'] = 'Adresse (Etape 7 Timeline raccordement)';$array[70]['value'] = 'projet-0-etap-14-adresseMiseEnService' ;
  5280.         $array[71]['name'] = 'Code postal (Etape 7 Timeline raccordement)';$array[71]['value'] = 'projet-0-etap-14-codePostalMiseEnService' ;
  5281.         $array[72]['name'] = 'Ville (Etape 7 Timeline raccordement)';$array[72]['value'] = 'projet-0-etap-14-cityMiseEnService' ;
  5282.         $array[74]['name'] = 'Commentaire';$array[74]['value'] = 'projet-1-etap-0-commentProject2-0-comment' ;
  5283.         $array[73]['name'] = 'Productible (P90)';$array[73]['value'] = 'projet-1-etap-0-productibleP90' ;
  5284.         $array[75]['name'] = 'Levée d’option date';$array[75]['value'] = 'projet-0-etap-5-leveeOption-1' ;
  5285.         $array[76]['name'] = 'les parcelles du projet (Etape 2 Timeline Foncier)';$array[76]['value'] = 'projet-0-etap-6-parcellesProjet' ;
  5286.         $array[77]['name'] = 'les propriétaires (Etape 2 Timeline Foncier)';$array[77]['value'] = 'projet-0-etap-6-proprietaires' ;
  5287.         $array[78]['name'] = 'Situation foncière (Etape 2 Timeline Foncier)';$array[78]['value'] = 'projet-0-etap-6-situationFonciere' ;
  5288.         $array[79]['name'] = 'Statut Mainlevée (Etape 2 Timeline Foncier)';$array[79]['value'] = 'projet-0-etap-6-statutMainlevee' ;
  5289.         $array[3000]['name'] = 'Marque Module (Étape 1  Timeline Construction)';$array[3000]['value'] = 'projet-0-etap-160-moduleInformation-0-marque-moduleInformation' ;
  5290.         $array[3001]['name'] = 'Puissance crête (Étape 1  Timeline Construction)';$array[3001]['value'] = 'projet-0-etap-160-moduleInformation-0-reference-moduleInformation' ;
  5291.         $array[3002]['name'] = 'Nombre de modules (Étape 1  Timeline Construction)';$array[3002]['value'] = 'projet-0-etap-160-moduleInformation-0-nbr-moduleInformation' ;
  5292.         $array[3003]['name'] = 'Marque Onduleur (Étape 1  Timeline Construction)';$array[3003]['value'] = 'projet-0-etap-160-onduleurInformation-0-marque-onduleurInformation' ;
  5293.         $array[3004]['name'] = 'Puissance Onduleur (Étape 1  Timeline Construction)';$array[3004]['value'] = 'projet-0-etap-160-onduleurInformation-0-puissance-onduleurInformation' ;
  5294.         $array[3005]['name'] = 'Nombre de Onduleurs (Étape 1  Timeline Construction)';$array[3005]['value'] = 'projet-0-etap-160-onduleurInformation-0-nbr-onduleurInformation' ;
  5295.         $array[3006]['name'] = 'Responsable construction';$array[3006]['value'] = 'projet-1-etap-0-responsableUser' ;
  5296.         $array[3007]['name'] = 'Installateur';$array[3007]['value'] = 'projet-1-etap-0-fournisseurProject-Installateur' ;
  5297.         $array[3008]['name'] = 'Charpentier';$array[3008]['value'] = 'projet-1-etap-0-fournisseurProject-Charpentier' ;
  5298.         $array[3010]['name'] = 'Mainteneur';$array[3010]['value'] = 'projet-1-etap-0-fournisseurProject-Mainteneur' ;
  5299.         $array[3009]['name'] = 'Epc';$array[3009]['value'] = 'projet-1-etap-0-fournisseur' ;
  5300.         // Champs projet (Détail projet) â€” indices 5000+
  5301.         $array[5000]['name'] = 'Achat - Location';$array[5000]['value'] = 'projet-1-etap-0-achatLocation' ;
  5302.         $array[5001]['name'] = 'Date de sourcing';$array[5001]['value'] = 'projet-1-etap-0-dateSourcing-1' ;
  5303.         $array[5002]['name'] = 'Date de T0 non reçu';$array[5002]['value'] = 'projet-1-etap-0-dateT0NonRecu' ;
  5304.         $array[5003]['name'] = 'Département';$array[5003]['value'] = 'projet-1-etap-0-departement' ;
  5305.         $array[5004]['name'] = 'Entreprise';$array[5004]['value'] = 'projet-1-etap-0-entreprise' ;
  5306.         $array[5005]['name'] = 'Famille du projet';$array[5005]['value'] = 'projet-1-etap-0-familleProject' ;
  5307.         $array[5006]['name'] = 'Indemnité transitoire (k€/an)';$array[5006]['value'] = 'projet-1-etap-0-indemiteTransitoire' ;
  5308.         $array[5007]['name'] = 'Arrêté PC non reçu';$array[5007]['value'] = 'projet-1-etap-0-isArretePcNonRecu' ;
  5309.         $array[5008]['name'] = 'Promesse de vente signée';$array[5008]['value'] = 'projet-1-etap-0-isPromesseAchatSignee' ;
  5310.         $array[5009]['name'] = 'Promesse de bail signée';$array[5009]['value'] = 'projet-1-etap-0-isPromesseBailSignee' ;
  5311.         $array[5010]['name'] = 'Prix d’achat foncier (€) (Détail projet)';$array[5010]['value'] = 'projet-1-etap-0-prixAchatFoncier' ;
  5312.         $array[5011]['name'] = 'Prix d’achat foncier (k€/ha)';$array[5011]['value'] = 'projet-1-etap-0-prixAchatFoncierKHa' ;
  5313.         $array[5012]['name'] = 'Prix d’achat foncier (k€/MWc)';$array[5012]['value'] = 'projet-1-etap-0-prixAchatFoncierKMWc' ;
  5314.         $array[5013]['name'] = 'Productible (P50)';$array[5013]['value'] = 'projet-1-etap-0-productible' ;
  5315.         $array[5014]['name'] = 'Ranking';$array[5014]['value'] = 'projet-1-etap-0-ranking' ;
  5316.         $array[5015]['name'] = 'Ratio CAPEX/Puissance';$array[5015]['value'] = 'projet-1-etap-0-ratioCapexPuissance' ;
  5317.         $array[5016]['name'] = 'Rémunération exploitant agricole';$array[5016]['value'] = 'projet-1-etap-0-remunerationExploitantAgricole' ;
  5318.         $array[5017]['name'] = 'Rendement EBE/CAPEX';$array[5017]['value'] = 'projet-1-etap-0-rendementEbeCapex' ;
  5319.         $array[5018]['name'] = 'Rendement EBE/CAPEX PPA 70 Euros';$array[5018]['value'] = 'projet-1-etap-0-rendementEbeCapexPPA' ;
  5320.         $array[5019]['name'] = 'Soulte (Détail projet)';$array[5019]['value'] = 'projet-1-etap-0-soulteVise' ;
  5321.         $array[5020]['name'] = 'Sourcing';$array[5020]['value'] = 'projet-1-etap-0-sourcing' ;
  5322.         $array[5021]['name'] = 'Sous-famille du projet';$array[5021]['value'] = 'projet-1-etap-0-sousFamilleProject' ;
  5323.         $array[5022]['name'] = 'Surface disponible (en ha)';$array[5022]['value'] = 'projet-1-etap-0-surfaceDisponible' ;
  5324.         $array[5023]['name'] = 'Surface exploitable (en ha)';$array[5023]['value'] = 'projet-1-etap-0-surfaceExploitable' ;
  5325.         $array[5024]['name'] = 'Tarif Fit prévisionnel (Détail projet)';$array[5024]['value'] = 'projet-1-etap-0-tarifRevente' ;
  5326.         $array[5025]['name'] = 'Tranche';$array[5025]['value'] = 'projet-1-etap-0-tranche' ;
  5327.         $array[5026]['name'] = 'TRI';$array[5026]['value'] = 'projet-1-etap-0-tri' ;
  5328.         $array[5027]['name'] = 'TRI PPA Ã  70 euros';$array[5027]['value'] = 'projet-1-etap-0-triPpaMin' ;
  5329.         $array[5028]['name'] = 'TRI avec Prime';$array[5028]['value'] = 'projet-1-etap-0-triPrime' ;
  5330.         $array[5029]['name'] = 'Typologie du projet';$array[5029]['value'] = 'projet-1-etap-0-typologieProject' ;
  5331.         $array[5030]['name'] = 'Unité de mesure';$array[5030]['value'] = 'projet-1-etap-0-uniteMesure' ;
  5332.         $array[5031]['name'] = 'Zonage PLU';$array[5031]['value'] = 'projet-1-etap-0-zonagePlu' ;
  5333.         // Champs Ã©tapes â€” indices 5100+
  5334.         $array[5100]['name'] = 'Nom de l’architecte (Etape 0 Timeline Urbanisme)';$array[5100]['value'] = 'projet-0-etap-0-architecte' ;
  5335.         $array[5101]['name'] = 'Champ libre PC (Etape 1 Timeline Urbanisme)';$array[5101]['value'] = 'projet-0-etap-1-champLibre' ;
  5336.         $array[5102]['name'] = 'Date demande de compléments PC (Etape 1 Timeline Urbanisme)';$array[5102]['value'] = 'projet-0-etap-1-dateDemandeComplement-1' ;
  5337.         $array[5103]['name'] = 'Date demande de compléments DP Mixte (Etape 1 Timeline Urbanisme)';$array[5103]['value'] = 'projet-0-etap-1-dateDemandeComplementPcDpMixte-1' ;
  5338.         $array[5104]['name'] = 'Date de dépôt compléments PC (Etape 1 Timeline Urbanisme)';$array[5104]['value'] = 'projet-0-etap-1-dateDepotComplement-1' ;
  5339.         $array[5105]['name'] = 'Date de dépôt compléments DP Mixte (Etape 1 Timeline Urbanisme)';$array[5105]['value'] = 'projet-0-etap-1-dateDepotComplementPcDpMixte-1' ;
  5340.         $array[5106]['name'] = 'Date de dépôt PC (Etape 1 Timeline Urbanisme)';$array[5106]['value'] = 'projet-0-etap-1-dateDepotPc-1' ;
  5341.         $array[5107]['name'] = 'Date de dépôt DP Mixte (Etape 1 Timeline Urbanisme)';$array[5107]['value'] = 'projet-0-etap-1-dateDepotPcDpMixte-1' ;
  5342.         $array[5108]['name'] = 'Délai d’instruction PC (Etape 1 Timeline Urbanisme)';$array[5108]['value'] = 'projet-0-etap-1-delaiInstruction' ;
  5343.         $array[5109]['name'] = 'Délai d’instruction DP Mixte (Etape 1 Timeline Urbanisme)';$array[5109]['value'] = 'projet-0-etap-1-delaiInstructionPcDpMixte' ;
  5344.         $array[5110]['name'] = 'Prorogation PC (Etape 1 Timeline Urbanisme)';$array[5110]['value'] = 'projet-0-etap-1-isDateArretePcProrogation' ;
  5345.         $array[5111]['name'] = 'Prorogation DP Mixte (Etape 1 Timeline Urbanisme)';$array[5111]['value'] = 'projet-0-etap-1-isDateArretePcProrogationPcDpMixte' ;
  5346.         $array[5112]['name'] = 'Pas de compléments PC (Etape 1 Timeline Urbanisme)';$array[5112]['value'] = 'projet-0-etap-1-isNotDateDemandeComplement' ;
  5347.         $array[5113]['name'] = 'Référence DP (Etape 1 Timeline Urbanisme)';$array[5113]['value'] = 'projet-0-etap-1-referenceDp' ;
  5348.         $array[5114]['name'] = 'Référence DP Mixte (Etape 1 Timeline Urbanisme)';$array[5114]['value'] = 'projet-0-etap-1-referencePcDpMixte' ;
  5349.         $array[5115]['name'] = 'Date PC purgé (Etape 2 Timeline Urbanisme)';$array[5115]['value'] = 'projet-0-etap-2-datePcDpPurge-1' ;
  5350.         $array[5116]['name'] = 'Date de signature de la DAACT (Etape 4 Timeline Urbanisme)';$array[5116]['value'] = 'projet-0-etap-4-dateSignatureDaact-1' ;
  5351.         $array[5117]['name'] = 'Date de fin d’exclusivité LOI (Etape 1 Timeline Foncier)';$array[5117]['value'] = 'projet-0-etap-5-dateFinExclusiviteLoi-1' ;
  5352.         $array[5118]['name'] = 'Date de signature LOI (Etape 1 Timeline Foncier)';$array[5118]['value'] = 'projet-0-etap-5-dateSignature-1' ;
  5353.         $array[5119]['name'] = 'Honoraire apporteur (Etape 1 Timeline Foncier)';$array[5119]['value'] = 'projet-0-etap-5-honoraireApporteur' ;
  5354.         $array[5120]['name'] = 'Indemnité transitoire (Etape 1 Timeline Foncier)';$array[5120]['value'] = 'projet-0-etap-5-indemniteTransitoire' ;
  5355.         $array[5121]['name'] = 'Contrepartie en nature (Etape 1 Timeline Foncier)';$array[5121]['value'] = 'projet-0-etap-5-loyerEnNature' ;
  5356.         $array[5122]['name'] = 'Prix d’achat foncier (Etape 1 Timeline Foncier)';$array[5122]['value'] = 'projet-0-etap-5-prixAchatFoncier' ;
  5357.         $array[5123]['name'] = 'Puissance signée (Etape 1 Timeline Foncier)';$array[5123]['value'] = 'projet-0-etap-5-puissanceSignee' ;
  5358.         $array[5124]['name'] = 'Type de bail (Etape 1 Timeline Foncier)';$array[5124]['value'] = 'projet-0-etap-5-typeBail' ;
  5359.         $array[5125]['name'] = 'Unité du prix d’achat (Etape 1 Timeline Foncier)';$array[5125]['value'] = 'projet-0-etap-5-unitePrixAchat' ;
  5360.         $array[5126]['name'] = 'Date de fin de bail (Etape 3 Timeline Foncier)';$array[5126]['value'] = 'projet-0-etap-7-dateFinBail-1' ;
  5361.         $array[5127]['name'] = 'Date de signature du bail (Etape 3 Timeline Foncier)';$array[5127]['value'] = 'projet-0-etap-7-dateSignatureBail-1' ;
  5362.         $array[5128]['name'] = 'Nom du bailleur (Etape 3 Timeline Foncier)';$array[5128]['value'] = 'projet-0-etap-7-nomBailleur' ;
  5363.         $array[5129]['name'] = 'Adresse de l’ETS (Etape 1 Timeline Raccordement)';$array[5129]['value'] = 'projet-0-etap-8-adresseEtablissement' ;
  5364.         $array[5130]['name'] = 'Ville de l’ETS (Etape 1 Timeline Raccordement)';$array[5130]['value'] = 'projet-0-etap-8-cityEtablissement' ;
  5365.         $array[5131]['name'] = 'Code postal de l’ETS (Etape 1 Timeline Raccordement)';$array[5131]['value'] = 'projet-0-etap-8-codePostalEtablissement' ;
  5366.         $array[5132]['name'] = 'Latitude de l’ETS (Etape 1 Timeline Raccordement)';$array[5132]['value'] = 'projet-0-etap-8-latEtablissement' ;
  5367.         $array[5133]['name'] = 'Longitude de l’ETS (Etape 1 Timeline Raccordement)';$array[5133]['value'] = 'projet-0-etap-8-longiEtablissement' ;
  5368.         $array[5134]['name'] = 'Profil du créateur (Etape 1 Timeline Raccordement)';$array[5134]['value'] = 'projet-0-etap-8-profileCreateur' ;
  5369.         $array[5135]['name'] = 'SPV confirmation ou changement (Etape 1 Timeline Raccordement)';$array[5135]['value'] = 'projet-0-etap-8-spvEtablissement' ;
  5370.         $array[5136]['name'] = 'Date de consignation (Etape 2 Timeline Raccordement)';$array[5136]['value'] = 'projet-0-etap-9-dateConsignation-1' ;
  5371.         $array[5137]['name'] = 'Date maximale d’achèvement des travaux (Etape 2 Timeline Raccordement)';$array[5137]['value'] = 'projet-0-etap-9-dateMaximaleAchevement-1' ;
  5372.         $array[5138]['name'] = 'Date T0 (Etape 2 Timeline Raccordement)';$array[5138]['value'] = 'projet-0-etap-9-dateT0-1' ;
  5373.         $array[5139]['name'] = 'Tarif Fit prévisionnel (Etape 2 Timeline Raccordement)';$array[5139]['value'] = 'projet-0-etap-9-tarifFit' ;
  5374.         $array[5140]['name'] = 'Date de MES prévisionnelle (Etape 7 Timeline Raccordement)';$array[5140]['value'] = 'projet-0-etap-14-dateMesPrevisionnelle-1' ;
  5375.         $array[5141]['name'] = 'Procédure d’accès (Etape 7 Timeline Raccordement)';$array[5141]['value'] = 'projet-0-etap-14-procedureAcces' ;
  5376.         $array[5142]['name'] = 'Date fin des fondations (Timeline Construction)';$array[5142]['value'] = 'projet-0-etap-18-dateFinDesFondation-1' ;
  5377.         $array[5143]['name'] = 'Date fin du bâtiment (Timeline Construction)';$array[5143]['value'] = 'projet-0-etap-19-dateFinBatiment-1' ;
  5378.         $array[5144]['name'] = 'Date pose des PV (Timeline Construction)';$array[5144]['value'] = 'projet-0-etap-19-datePosePv-1' ;
  5379.         $array[5145]['name'] = 'Date de visite terrain (Compte rendu)';$array[5145]['value'] = 'projet-0-etap-23-visiteTerrainV2-0-dateVisiteTerrain' ;
  5380.         $array[5146]['name'] = 'Distance PDL (Timeline Raccordement)';$array[5146]['value'] = 'projet-0-etap-80-distancePdl' ;
  5381.         $array[5147]['name'] = 'Nature du raccordement (Timeline Raccordement)';$array[5147]['value'] = 'projet-0-etap-80-natureRaccordement' ;
  5382.         $array[5148]['name'] = 'Date d’installation du PDL (Timeline Raccordement)';$array[5148]['value'] = 'projet-0-etap-121-dateInstallationPDL-1' ;
  5383.         $array[5149]['name'] = 'Date de mise sous tension ENEDIS (Timeline Raccordement)';$array[5149]['value'] = 'projet-0-etap-121-dateMiseSousTensionEnedis-1' ;
  5384.         $array[5150]['name'] = 'Date prévisionnelle d’installation du PDL (Timeline Raccordement)';$array[5150]['value'] = 'projet-0-etap-121-datePrevisionnelleInstallationPDL-1' ;
  5385.         $array[5151]['name'] = 'Bi-pente asymétrique (Étape 1 Timeline Construction)';$array[5151]['value'] = 'projet-0-etap-160-biPenteAsymetrique' ;
  5386.         $array[5152]['name'] = 'Bi-pente symétrique (Étape 1 Timeline Construction)';$array[5152]['value'] = 'projet-0-etap-160-biPenteSymetrique' ;
  5387.         $array[5153]['name'] = 'Date réalisation de la plateforme (Etape 4-1 Timeline construction)';$array[5153]['value'] = 'projet-0-etap-171-dateRealisationPlateforme-1' ;
  5388.         $array[5154]['name'] = 'Date d’intervention du géomètre (Timeline Foncier)';$array[5154]['value'] = 'projet-0-etap-601-dateIntervention-1' ;
  5389.         $array[5155]['name'] = 'Date de lancement géomètre (Timeline Foncier)';$array[5155]['value'] = 'projet-0-etap-601-dateLancement-1' ;
  5390.         $array[5156]['name'] = 'Date d’envoi des procurations (Timeline Foncier)';$array[5156]['value'] = 'projet-0-etap-602-dateEnvoiPocuration-1' ;
  5391.         $array[5157]['name'] = 'Date de lancement notaire (Timeline Foncier)';$array[5157]['value'] = 'projet-0-etap-602-dateLancement-1' ;
  5392.         $array[5158]['name'] = 'Date de signature des procurations côté bailleur (Timeline Foncier)';$array[5158]['value'] = 'projet-0-etap-602-dateSignatureProcuration-1' ;
  5393.         return $array ;
  5394.     }
  5395.     public function getNameOfArrayChompsExport($value){
  5396.         $array = $this->getChampsExport();
  5397.         $name = '';
  5398.         foreach ($array['category'] as $item2){
  5399.             foreach ($item2['detail'] as $item){
  5400.                 $tab = explode('-',$value);
  5401.                 if($tab[1] == ParametrageXlsProject::type_row_etap){
  5402.                     if($value == $item['value']){
  5403.                         $name = $item['champs'];
  5404.                     }
  5405.                 }else{
  5406.                     if(isset($tab[3]) && isset($tab[4]) && isset($tab[5]) && $tab[3] == 0 && $tab[4] == 0 && $tab[5] == 0){
  5407.                         if($value == $item['value']){
  5408.                             $name = $item['champs'];
  5409.                         }
  5410.                     }else{
  5411.                         if(str_contains($value, $item['value'])){
  5412.                             if($name != ''){
  5413.                                 $name .= ','.$item['champs'];
  5414.                             }else{
  5415.                                 $name = $item['champs'];
  5416.                             }
  5417.                         }
  5418.                     }
  5419.                 }
  5420.             }
  5421.         }
  5422.         return $name;
  5423.     }
  5424.     public function getChampsExport(){
  5425.         $array = [];
  5426.         $array['category'][0]['num'] = 0;
  5427.         $array['category'][0]['name'] = 'Détail projet';
  5428.         $array['category'][0]['detail'][0]['champs'] = 'Nom du projet';$array['category'][0]['detail'][0]['name'] = 'Nom du projet';$array['category'][0]['detail'][0]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-name' ;
  5429.         $array['category'][0]['detail'][1]['champs'] = 'Famille du projet';$array['category'][0]['detail'][1]['name'] = 'Famille du projet';$array['category'][0]['detail'][1]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-familleProject' ;
  5430.         $array['category'][0]['detail'][2]['champs'] = 'Typologie du projet';$array['category'][0]['detail'][2]['name'] = 'Typologie du projet';$array['category'][0]['detail'][2]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-typologieProject' ;
  5431.         $array['category'][0]['detail'][3]['champs'] = 'Adresse';$array['category'][0]['detail'][3]['name'] = 'Adresse';$array['category'][0]['detail'][3]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-adresse' ;
  5432.         $array['category'][0]['detail'][4]['champs'] = 'Code postal';$array['category'][0]['detail'][4]['name'] = 'Code postal';$array['category'][0]['detail'][4]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-codePostal' ;
  5433.         $array['category'][0]['detail'][5]['champs'] = 'Ville';$array['category'][0]['detail'][5]['name'] = 'Ville';$array['category'][0]['detail'][5]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-city' ;
  5434.         $array['category'][0]['detail'][6]['champs'] = 'N° de parcelle';$array['category'][0]['detail'][6]['name'] = 'N° de parcelle';$array['category'][0]['detail'][6]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-numParcelle' ;
  5435.         $array['category'][0]['detail'][7]['champs'] = 'Latitude';$array['category'][0]['detail'][7]['name'] = 'Latitude';$array['category'][0]['detail'][7]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-longi' ;
  5436.         $array['category'][0]['detail'][8]['champs'] = 'Longitude';$array['category'][0]['detail'][8]['name'] = 'Longitude';$array['category'][0]['detail'][8]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-lat' ;
  5437.         $array['category'][0]['detail'][9]['champs'] = 'Capacité installée (KWc)';$array['category'][0]['detail'][9]['name'] = 'Capacité installée (KWc)';$array['category'][0]['detail'][9]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-capacite' ;
  5438.         $array['category'][0]['detail'][11109]['champs'] = 'Capacité injectée (kVA)';$array['category'][0]['detail'][11109]['name'] = 'Capacité injectée (kVA)';$array['category'][0]['detail'][11109]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-puissance' ;
  5439.         $array['category'][0]['detail'][10]['champs'] = 'Productible (p50)';$array['category'][0]['detail'][10]['name'] = 'Productible (P50)';$array['category'][0]['detail'][10]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-productible' ;
  5440.         $array['category'][0]['detail'][11110]['champs'] = 'Productible (p90)';$array['category'][0]['detail'][11110]['name'] = 'Productible (P90)';$array['category'][0]['detail'][11110]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-productibleP90' ;
  5441.         $array['category'][0]['detail'][11]['champs'] = 'Date de T0';$array['category'][0]['detail'][11]['name'] = 'Date de T0';$array['category'][0]['detail'][11]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-dateT0Date-1' ;
  5442.         $array['category'][0]['detail'][12]['champs'] = 'Date arrêté PC';$array['category'][0]['detail'][12]['name'] = 'Date arrêté PC';$array['category'][0]['detail'][12]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-dateArretePc-1' ;
  5443.         $array['category'][0]['detail'][13]['champs'] = 'Loyer';$array['category'][0]['detail'][13]['name'] = 'Loyer';$array['category'][0]['detail'][13]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-loyerVise' ;
  5444.         $array['category'][0]['detail'][14]['champs'] = 'Soulte';$array['category'][0]['detail'][14]['name'] = 'Soulte';$array['category'][0]['detail'][14]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-soulteVise' ;
  5445.         $array['category'][0]['detail'][15]['champs'] = 'Type de batîment';$array['category'][0]['detail'][15]['name'] = 'Type de batîment';$array['category'][0]['detail'][15]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-typeBatimentProject' ;
  5446.         $array['category'][0]['detail'][16]['champs'] = 'SPV';$array['category'][0]['detail'][16]['name'] = 'SPV';$array['category'][0]['detail'][16]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-spv' ;
  5447.         $array['category'][0]['detail'][17]['champs'] = 'Étude de productible';$array['category'][0]['detail'][17]['name'] = 'Étude de productible';$array['category'][0]['detail'][17]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-fileEtudeProductible-2' ;
  5448.         $array['category'][0]['detail'][18]['champs'] = 'Promesse de bail';$array['category'][0]['detail'][18]['name'] = 'Promesse de bail';$array['category'][0]['detail'][18]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-filePromessebail-2' ;
  5449.         $array['category'][0]['detail'][19]['champs'] = 'Visite Technique';$array['category'][0]['detail'][19]['name'] = 'Visite Technique  ';$array['category'][0]['detail'][19]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-fileDocCompementaire-2' ;
  5450.         $array['category'][0]['detail'][19001]['champs'] = 'Code projet';$array['category'][0]['detail'][19001]['name'] = 'Code projet';$array['category'][0]['detail'][19001]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-codeProject' ;
  5451.         $array['category'][0]['detail'][154]['champs'] = 'Statut administratif';$array['category'][0]['detail'][154]['name'] = 'Statut administratif';$array['category'][0]['detail'][154]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-1' ;
  5452.         $array['category'][0]['detail'][155]['champs'] = 'Statut tracker';$array['category'][0]['detail'][155]['name'] = 'Statut tracker';$array['category'][0]['detail'][155]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-2' ;
  5453.         $array['category'][0]['detail'][15500]['champs'] = 'Statut Construction';$array['category'][0]['detail'][15500]['name'] = 'Statut Construction';$array['category'][0]['detail'][15500]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-11' ;
  5454.         $array['category'][0]['detail'][156]['champs'] = 'Avancement Urbanisme';$array['category'][0]['detail'][156]['name'] = 'Avancement Urbanisme';$array['category'][0]['detail'][156]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-3' ;
  5455.         $array['category'][0]['detail'][157]['champs'] = 'Avancement Foncier';$array['category'][0]['detail'][157]['name'] = 'Avancement Foncier';$array['category'][0]['detail'][157]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-4' ;
  5456.         $array['category'][0]['detail'][158]['champs'] = 'Avancement Raccordement';$array['category'][0]['detail'][158]['name'] = 'Avancement Raccordement';$array['category'][0]['detail'][158]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-5' ;
  5457.         $array['category'][0]['detail'][159]['champs'] = 'Avancement Construction';$array['category'][0]['detail'][159]['name'] = 'Avancement Construction';$array['category'][0]['detail'][159]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-6' ;
  5458.         $array['category'][0]['detail'][15900]['champs'] = 'Avancement Valorisation';$array['category'][0]['detail'][15900]['name'] = 'Avancement Valorisation';$array['category'][0]['detail'][15900]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-13' ;
  5459.         $array['category'][0]['detail'][160]['champs'] = 'Stade de construction';$array['category'][0]['detail'][160]['name'] = 'Stade de construction';$array['category'][0]['detail'][160]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-stadeConstruction' ;
  5460.         $array['category'][0]['detail'][161]['champs'] = 'Développeur';$array['category'][0]['detail'][161]['name'] = 'Développeur';$array['category'][0]['detail'][161]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-developpeur' ;
  5461. //        $array['category'][0]['detail'][162]['champs'] = 'Fournisseur';$array['category'][0]['detail'][162]['name'] = 'Fournisseur';$array['category'][0]['detail'][162]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-fournisseur' ;
  5462.         $array['category'][0]['detail'][163]['champs'] = 'Responsable construction';$array['category'][0]['detail'][163]['name'] = 'Responsable construction';$array['category'][0]['detail'][163]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-responsableUser' ;
  5463.         $array['category'][0]['detail'][170]['champs'] = 'Responsable développement';$array['category'][0]['detail'][170]['name'] = 'Responsable développement';$array['category'][0]['detail'][170]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-responsableDeveloppement' ;
  5464.         $array['category'][0]['detail'][168]['champs'] = 'Constructeur';$array['category'][0]['detail'][168]['name'] = 'Constructeur';$array['category'][0]['detail'][168]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-constructeurUser' ;
  5465.         $array['category'][0]['detail'][169]['champs'] = 'Commentaires projet';$array['category'][0]['detail'][169]['name'] = 'Commentaires projet';$array['category'][0]['detail'][169]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-commentProject2' ;
  5466.         $array['category'][0]['detail'][211]['champs'] = 'Schéma contstruction';$array['category'][0]['detail'][211]['name'] = 'Schéma contstruction (Detail projet)';$array['category'][0]['detail'][211]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-schemaConstruction' ;
  5467.         $array['category'][0]['detail'][212]['champs'] = 'EPC';$array['category'][0]['detail'][212]['name'] = 'EPC';$array['category'][0]['detail'][212]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-fournisseur' ;
  5468.         $array['category'][0]['detail'][213]['champs'] = 'Instalateur';$array['category'][0]['detail'][213]['name'] = 'Instalateur';$array['category'][0]['detail'][213]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-fournisseurProject-0-fournisseur-instalateur' ;
  5469.         $array['category'][0]['detail'][214]['champs'] = 'Charpentier';$array['category'][0]['detail'][214]['name'] = 'Charpentier';$array['category'][0]['detail'][214]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-fournisseurProject-0-fournisseur-charpentier' ;
  5470.         $array['category'][0]['detail'][229]['champs'] = 'Sous Famille du projet';$array['category'][0]['detail'][229]['name'] = 'Sous Famille du projet';$array['category'][0]['detail'][229]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-sousFamilleProject' ;
  5471.         $array['category'][0]['detail'][230]['champs'] = 'Surface disponible';$array['category'][0]['detail'][230]['name'] = 'Surface disponible';$array['category'][0]['detail'][230]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-surfaceDisponible' ;
  5472.         $array['category'][0]['detail'][231]['champs'] = 'Zonage plu';$array['category'][0]['detail'][231]['name'] = 'Zonage plu';$array['category'][0]['detail'][231]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-zonagePlu' ;
  5473.         $array['category'][0]['detail'][232]['champs'] = 'Surface exploitable';$array['category'][0]['detail'][232]['name'] = 'Surface exploitable';$array['category'][0]['detail'][232]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-surfaceExploitable' ;
  5474. //        $array['category'][0]['detail'][233]['champs'] = 'prix achat Foncier';$array['category'][0]['detail'][233]['name'] = 'prix achat Foncier';$array['category'][0]['detail'][233]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-prixAchatFoncier' ;
  5475. //        $array['category'][0]['detail'][234]['champs'] = 'unité achat Foncier';$array['category'][0]['detail'][234]['name'] = 'unité achat Foncier';$array['category'][0]['detail'][234]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-uniteAchatFoncier' ;
  5476.         $array['category'][0]['detail'][235]['champs'] = 'Indemnité transitoire (k€/an)';$array['category'][0]['detail'][235]['name'] = 'Indemnité transitoire (k€/an)';$array['category'][0]['detail'][235]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-indemiteTransitoire' ;
  5477.         $array['category'][0]['detail'][236]['champs'] = 'Rémunération exploitant agricole';$array['category'][0]['detail'][236]['name'] = 'Rémunération exploitant agricole';$array['category'][0]['detail'][236]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-remunerationExploitantAgricole' ;
  5478.         $array['category'][0]['detail'][237]['champs'] = 'Sourcing';$array['category'][0]['detail'][237]['name'] = 'Sourcing';$array['category'][0]['detail'][237]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-sourcing' ;
  5479.         $array['category'][0]['detail'][238]['champs'] = 'Date de sourcing';$array['category'][0]['detail'][238]['name'] = 'Date de sourcing';$array['category'][0]['detail'][238]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-dateSourcing-1' ;
  5480.         $array['category'][0]['detail'][239]['champs'] = 'Durée d\'exploitation';$array['category'][0]['detail'][239]['name'] = 'Durée d\'exploitation';$array['category'][0]['detail'][239]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-dureeExploitation' ;
  5481.         $array['category'][0]['detail'][240]['champs'] = 'Tri';$array['category'][0]['detail'][240]['name'] = 'Tri';$array['category'][0]['detail'][240]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-tri' ;
  5482.         $array['category'][0]['detail'][241]['champs'] = 'Tri avec Prime';$array['category'][0]['detail'][241]['name'] = 'Tri avec Prime';$array['category'][0]['detail'][241]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-triPrime' ;
  5483.         $array['category'][0]['detail'][242]['champs'] = 'TRI CRE min';$array['category'][0]['detail'][242]['name'] = 'TRI CRE min';$array['category'][0]['detail'][242]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-triCreMin' ;
  5484.         $array['category'][0]['detail'][243]['champs'] = 'Tri avec Prime';$array['category'][0]['detail'][243]['name'] = 'Tri avec Prime';$array['category'][0]['detail'][243]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-triCreMin' ;
  5485.         $array['category'][0]['detail'][244]['champs'] = 'TRI PPA Ã  70 euros';$array['category'][0]['detail'][244]['name'] = 'TRI PPA Ã  70 euros';$array['category'][0]['detail'][244]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-triPpaMin' ;
  5486.         $array['category'][0]['detail'][245]['champs'] = 'Rendement EBE/CAPEX.';$array['category'][0]['detail'][245]['name'] = 'Rendement EBE/CAPEX.';$array['category'][0]['detail'][245]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-rendementEbeCapex' ;
  5487.         $array['category'][0]['detail'][246]['champs'] = 'Ratio CAPEX/PUISSANCE';$array['category'][0]['detail'][246]['name'] = 'Ratio CAPEX/PUISSANCE';$array['category'][0]['detail'][246]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-ratioCapexPuissance' ;
  5488.         $array['category'][0]['detail'][247]['champs'] = 'Rendement EBE/CAPEX PPA 70 Euros';$array['category'][0]['detail'][247]['name'] = 'Rendement EBE/CAPEX PPA 70 Euros';$array['category'][0]['detail'][247]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-rendementEbeCapexPPA' ;
  5489.         $array['category'][0]['detail'][248]['champs'] = 'Ranking';$array['category'][0]['detail'][248]['name'] = 'Ranking';$array['category'][0]['detail'][248]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-ranking' ;
  5490.         $array['category'][0]['detail'][249]['champs'] = 'Date RTB tarifié';$array['category'][0]['detail'][249]['name'] = 'Date RTB tarifié';$array['category'][0]['detail'][249]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-dateRTBtarifie-1' ;
  5491.         $array['category'][0]['detail'][250]['champs'] = 'Prix d’achat foncier (k€/MWc)';$array['category'][0]['detail'][250]['name'] = 'Prix d’achat foncier (k€/MWc)';$array['category'][0]['detail'][250]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-prixAchatFoncierKMWc' ;
  5492.         $array['category'][0]['detail'][251]['champs'] = 'Prix d’achat foncier (k€/ha)';$array['category'][0]['detail'][251]['name'] = 'Prix d’achat foncier (k€/ha)';$array['category'][0]['detail'][251]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-prixAchatFoncierKHa' ;
  5493.         $array['category'][0]['detail'][189]['champs'] = 'Date de création';$array['category'][0]['detail'][189]['name'] = 'Date de création';$array['category'][0]['detail'][189]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-createdAt-1' ;
  5494.         $array['category'][0]['detail'][208]['champs'] = 'Statut Urbanisme';$array['category'][0]['detail'][208]['name'] = 'Statut Urbanisme';$array['category'][0]['detail'][208]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-7' ;
  5495.         $array['category'][0]['detail'][209]['champs'] = 'Statut Foncier';$array['category'][0]['detail'][209]['name'] = 'Statut Foncier';$array['category'][0]['detail'][209]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-8' ;
  5496.         $array['category'][0]['detail'][2090]['champs'] = 'Date Objectif dépôt PC/DP';$array['category'][0]['detail'][2090]['name'] = 'Date Objectif dépôt PC/DP';$array['category'][0]['detail'][2090]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-dateDepotPc-1' ;
  5497.         $array['category'][0]['detail'][2091]['champs'] = 'Date Objectif PC/DP obtenu';$array['category'][0]['detail'][2091]['name'] = 'Date Objectif PC/DP obtenu';$array['category'][0]['detail'][2091]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-dateObtentionPc-1' ;
  5498.         $array['category'][0]['detail'][2092]['champs'] = 'Département';$array['category'][0]['detail'][2092]['name'] = 'Département';$array['category'][0]['detail'][2092]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-departement' ;
  5499.         $array['category'][0]['detail'][2093]['champs'] = 'Achat - Location';$array['category'][0]['detail'][2093]['name'] = 'Achat - Location';$array['category'][0]['detail'][2093]['value'] = 'projet-'.ParametrageXlsProject::type_row_project.'-etap-0-achatLocation' ;
  5500.         $array['category'][1]['num'] = 1;
  5501.         $array['category'][1]['name'] = 'Urbanisme';
  5502.         $array['category'][1]['detail'][20]['champs'] = 'Dossier PC/DP';$array['category'][1]['detail'][20]['name'] = 'Dossier PC/DP (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][20]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-fileDossierPcDpMultiple-2' ;
  5503.         $array['category'][1]['detail'][21]['champs'] = 'Arrêté PC/DP';$array['category'][1]['detail'][21]['name'] = 'Arrêté PC/DP (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][21]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-fileArretePcDpMultiple-2' ;
  5504.         $array['category'][1]['detail'][22]['champs'] = 'Date arrété';$array['category'][1]['detail'][22]['name'] = 'Date arrété (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][22]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-dateArretePcDp-1' ;
  5505.         $array['category'][1]['detail'][23]['champs'] = 'Référence PC';$array['category'][1]['detail'][23]['name'] = 'Référence PC (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][23]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-referencePc' ;
  5506.         $array['category'][1]['detail'][24]['champs'] = 'Référence DP';$array['category'][1]['detail'][24]['name'] = 'Référence DP (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][24]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-referenceDp' ;
  5507.         $array['category'][1]['detail'][24001]['champs'] = 'Récépissé dépôt PC/DP';$array['category'][1]['detail'][24001]['name'] = 'Récépissé dépôt PC/DP (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][24001]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-fileRecepisseDepotPcMultiple-2' ;
  5508.         $array['category'][1]['detail'][24002]['champs'] = 'Demande compléments PC/DP';$array['category'][1]['detail'][24002]['name'] = 'Demande compléments PC/DP (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][24002]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-fileDemandeComplementPcMultiple-2' ;
  5509.         $array['category'][1]['detail'][24003]['champs'] = 'Récépissé compléments PC/DP';$array['category'][1]['detail'][24003]['name'] = 'Demande compléments PC/DP (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][24003]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-fileRecepisseComplementPcMultiple-2' ;
  5510.         $array['category'][1]['detail'][25]['champs'] = 'PV passage huissier';$array['category'][1]['detail'][25]['name'] = 'PV passage huissier (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][25]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-filePVPassageHuissierMultiple-2' ;
  5511.         $array['category'][1]['detail'][26]['champs'] = 'Certificat de non-recours';$array['category'][1]['detail'][26]['name'] = 'Certificat de non-recours (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][26]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-fileCertificatNonRecoursMultiple-2' ;
  5512.         $array['category'][1]['detail'][27]['champs'] = 'Certificat de non-retrait';$array['category'][1]['detail'][27]['name'] = 'Certificat de non-retrait (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][27]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-fileCertificatNonRetraitMultiple-2' ;
  5513.         $array['category'][1]['detail'][28]['champs'] = 'Certificat de non-opposition';$array['category'][1]['detail'][28]['name'] = 'Certificat de non-opposition (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][28]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-fileCertificatNonOppositionEtap1Multiple-2' ;
  5514.         $array['category'][1]['detail'][28001]['champs'] = 'Demande d’ANR Mairie';$array['category'][1]['detail'][28001]['name'] = 'Demande d’ANR Mairie (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][28001]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-fileDemandeAnrMarieMultiple-2' ;
  5515.         $array['category'][1]['detail'][28002]['champs'] = 'Demande d’ANR TA';$array['category'][1]['detail'][28002]['name'] = 'Demande d’ANR TA (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][28002]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-fileDemandeAnrTaMultiple-2' ;
  5516.         $array['category'][1]['detail'][28003]['champs'] = 'Attestation sur l’honneur ANR Mairie / TA';$array['category'][1]['detail'][28003]['name'] = 'Attestation sur l’honneur ANR Mairie / TA (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][28003]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-fileAttestationHonneurAnrMairieTaMultiple-2' ;
  5517.         $array['category'][1]['detail'][29]['champs'] = 'Date 1er passage huissier';$array['category'][1]['detail'][29]['name'] = 'Date 1er passage huissier (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][29]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-date1PassageHuissier-1' ;
  5518.         $array['category'][1]['detail'][30]['champs'] = 'Date 2ème passage huissier';$array['category'][1]['detail'][30]['name'] = 'Date 2ème passage huissier (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][30]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-date2PassageHuissier-1' ;
  5519.         $array['category'][1]['detail'][31]['champs'] = 'Date 3ème passage huissier';$array['category'][1]['detail'][31]['name'] = 'Date 3ème passage huissier (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][31]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-date3PassageHuissier-1' ;
  5520.         $array['category'][1]['detail'][32]['champs'] = 'DOC / DROC';$array['category'][1]['detail'][32]['name'] = 'DOC / DROC (Etape 3 Timeline Urbanisme)';$array['category'][1]['detail'][32]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-3-fileDocDrocMultiple-2' ;
  5521.         $array['category'][1]['detail'][33]['champs'] = 'Date de dépôt de la DOC / DROC';$array['category'][1]['detail'][33]['name'] = 'Date de dépôt de la DOC / DROC (Etape 3 Timeline Urbanisme)';$array['category'][1]['detail'][33]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-3-dateDocDroc-1' ;
  5522.         $array['category'][1]['detail'][34]['champs'] = 'DAACT';$array['category'][1]['detail'][34]['name'] = 'DAACT (Etape 4 Timeline Urbanisme)';$array['category'][1]['detail'][34]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-4-fileDaactMultiple-2' ;
  5523.         $array['category'][1]['detail'][35]['champs'] = 'Date de dépôt de la DAACT';$array['category'][1]['detail'][35]['name'] = 'Date de dépôt de la DAACT (Etape 4 Timeline Urbanisme)';$array['category'][1]['detail'][35]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-4-dateDaact-1' ;
  5524.         $array['category'][1]['detail'][36]['champs'] = 'Date de signature de la DAACT';$array['category'][1]['detail'][36]['name'] = 'Date de signature de la DAACT (Etape 4 Timeline Urbanisme)';$array['category'][1]['detail'][36]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-4-dateSignatureDaact-1' ;
  5525.         $array['category'][1]['detail'][10001]['champs'] = 'Infos pour archi (bardage, aménagement intérieur, solution EP, borne incendie…)';$array['category'][1]['detail'][10001]['name'] = 'Infos pour archi (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10001]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-fileInfoArchiMultiple-2' ;
  5526.         $array['category'][1]['detail'][10002]['champs'] = 'MSA Attestation';$array['category'][1]['detail'][10002]['name'] = 'MSA Attestation (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10002]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-fileMsaAttestationMultiple-2' ;
  5527.         $array['category'][1]['detail'][10003]['champs'] = 'MSA Relevé d’exploitation';$array['category'][1]['detail'][10003]['name'] = 'MSA Relevé d’exploitation (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10003]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-fileMsaReleveExploitationMultiple-2' ;
  5528.         $array['category'][1]['detail'][10004]['champs'] = 'Fiche de besoins agricoles';$array['category'][1]['detail'][10004]['name'] = 'Fiche de besoins agricoles (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10004]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-fileFicheBesoinAgricoleMultiple-2' ;
  5529.         $array['category'][1]['detail'][10005]['champs'] = 'Lettre de motivation';$array['category'][1]['detail'][10005]['name'] = 'Lettre de motivation (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10005]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-fileLettreMotivationMultiple-2' ;
  5530.         $array['category'][1]['detail'][10006]['champs'] = 'ICPE  (attestation non-soumission ou preuve de dépôt déclaration)';$array['category'][1]['detail'][10006]['name'] = 'ICPE  (attestation non-soumission ou preuve de dépôt déclaration) (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10006]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-fileICPEMultiple-2' ;
  5531.         $array['category'][1]['detail'][10007]['champs'] = 'Règlement d’urbanisme Â» (PLU / PLUi)';$array['category'][1]['detail'][10007]['name'] = 'Règlement d’urbanisme Â» (PLU / PLUi) (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10007]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-fileReglementUrbanismeMultiple-2' ;
  5532.         $array['category'][1]['detail'][10008]['champs'] = 'Autre (CDPENAF, Natura 2000…)';$array['category'][1]['detail'][10008]['name'] = 'Autre (CDPENAF, Natura 2000…) (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10008]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-fileAutreEtap0Multiple-2' ;
  5533.         $array['category'][1]['detail'][10009]['champs'] = 'Nom de l’architecte ';$array['category'][1]['detail'][10009]['name'] = 'Nom de l’architecte (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10009]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-architecte' ;
  5534.         $array['category'][1]['detail'][10010]['champs'] = 'Commentaires';$array['category'][1]['detail'][10010]['name'] = 'Commentaires (Etape 0 Timeline urbanisme)';$array['category'][1]['detail'][10010]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-0-commentaireEtap0' ;
  5535.         $array['category'][1]['detail'][10011]['champs'] = 'Dossier PCM';$array['category'][1]['detail'][10011]['name'] = 'Dossier PCM (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10011]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-2-fileDossierPcmpMultiple-1' ;
  5536.         $array['category'][1]['detail'][10012]['champs'] = 'Récépissé dépôt PCM';$array['category'][1]['detail'][10012]['name'] = 'Récépissé dépôt PCM (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10012]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-2-fileRecepisseDepotPcmMultiple-1' ;
  5537.         $array['category'][1]['detail'][10013]['champs'] = 'Demande compléments PCM';$array['category'][1]['detail'][10013]['name'] = 'Demande compléments PCM (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10013]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-2-fileDemandeComplementPcmMultiple-1' ;
  5538.         $array['category'][1]['detail'][10014]['champs'] = 'Récépissé compléments PCM';$array['category'][1]['detail'][10014]['name'] = 'Récépissé compléments PCM (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10014]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-2-fileRecepisseComplementPcmMultiple-1' ;
  5539.         $array['category'][1]['detail'][10015]['champs'] = 'Arrêté PCM';$array['category'][1]['detail'][10015]['name'] = 'Arrêté PCM (Permis de construire modificatif) (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10015]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-2-fileArretePcmMultiple-1' ;
  5540.         $array['category'][1]['detail'][10016]['champs'] = 'Autre (prolongation délai d’instruction) PCM';$array['category'][1]['detail'][10016]['name'] = 'Autre (prolongation délai d’instruction) PCM (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10016]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-2-fileAutreDocPcmMultiple-1' ;
  5541.         $array['category'][1]['detail'][10017]['champs'] = 'Date arrété PCM';$array['category'][1]['detail'][10017]['name'] = 'Date arrété PCM (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10017]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-1-dateArretePcm' ;
  5542.         $array['category'][1]['detail'][10018]['champs'] = 'Date demande de compléments PCM';$array['category'][1]['detail'][10018]['name'] = 'Date demande de compléments PCM (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10018]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-1-dateDemandeComplement' ;
  5543.         $array['category'][1]['detail'][10019]['champs'] = 'Délai d’instruction (mois)  PCM';$array['category'][1]['detail'][10019]['name'] = 'Délai d’instruction (mois)  PCM (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10019]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-0-delaiInstruction' ;
  5544.         $array['category'][1]['detail'][10020]['champs'] = 'Date de dépôt compléments PCM';$array['category'][1]['detail'][10020]['name'] = 'Date de dépôt compléments PCM (Etape 1 Timeline Urbanisme)';$array['category'][1]['detail'][10020]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-1-etap1Pcm-1-dateDepotComplement' ;
  5545.         $array['category'][1]['detail'][10021]['champs'] = 'PV passage huissier PCM';$array['category'][1]['detail'][10021]['name'] = 'PV passage huissier PCM (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][10021]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-etap2Pcm-2-filePVPassageHuissierPcmMultiple-1' ;
  5546.         $array['category'][1]['detail'][10022]['champs'] = 'Certificat de non-recours PCM';$array['category'][1]['detail'][10022]['name'] = 'Certificat de non-recours PCM (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][10022]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-etap2Pcm-2-fileCertificatNonRecoursPcmMultiple-1' ;
  5547.         $array['category'][1]['detail'][10023]['champs'] = 'Certificat de non-retrait PCM';$array['category'][1]['detail'][10023]['name'] = 'Certificat de non-retrait PCM (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][10023]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-etap2Pcm-2-fileCertificatNonRetraitPcmMultiple-1' ;
  5548.         $array['category'][1]['detail'][10024]['champs'] = 'Demande d’ANR Mairie PCM';$array['category'][1]['detail'][10024]['name'] = 'Demande d’ANR Mairie PCM (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][10024]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-etap2Pcm-2-fileDemandeAnrMariePcmMultiple-1' ;
  5549.         $array['category'][1]['detail'][10025]['champs'] = 'Demande d’ANR TA PCM';$array['category'][1]['detail'][10025]['name'] = 'Demande d’ANR TA PCM (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][10025]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-etap2Pcm-2-fileDemandeAnrTaPcmMultiple-1' ;
  5550.         $array['category'][1]['detail'][10026]['champs'] = 'Attestation sur l’honneur ANR Mairie / TA PCM';$array['category'][1]['detail'][10026]['name'] = 'Attestation sur l’honneur ANR Mairie / TA PCM (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][10026]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-etap2Pcm-2-fileAttestationHonneurAnrMairieTaPcmMultiple-1' ;
  5551.         $array['category'][1]['detail'][10027]['champs'] = 'Date 1er passage huissier PCM';$array['category'][1]['detail'][10027]['name'] = 'Date 1er passage huissier PCM (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][10027]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-etap2Pcm-1-date1PassageHuissierPcm' ;
  5552.         $array['category'][1]['detail'][10028]['champs'] = 'Date 2ème passage huissier PCM';$array['category'][1]['detail'][10028]['name'] = 'Date 2ème passage huissier PCM (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][10028]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-etap2Pcm-1-date2PassageHuissierPcm' ;
  5553.         $array['category'][1]['detail'][10029]['champs'] = 'Date 3ème passage huissier PCM';$array['category'][1]['detail'][10029]['name'] = 'Date 3ème passage huissier PCM (Etape 2 Timeline Urbanisme)';$array['category'][1]['detail'][10029]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-2-etap2Pcm-1-date3PassageHuissierPcm' ;
  5554.         $array['category'][2]['num'] = 2;
  5555.         $array['category'][2]['name'] = 'Foncier';
  5556.         $array['category'][2]['detail'][36]['champs'] = 'Promesse de bail';$array['category'][2]['detail'][36]['name'] = 'Promesse de bail (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][36]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-filePromessebailMultiple-2' ;
  5557.         $array['category'][2]['detail'][37]['champs'] = 'Date PDB';$array['category'][2]['detail'][37]['name'] = 'Date PDB (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][37]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-dateExpirationPromesseBail-1' ;
  5558.         $array['category'][2]['detail'][38]['champs'] = 'Durée de validité (en mois)';$array['category'][2]['detail'][38]['name'] = 'Durée de validité (en mois) (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][38]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-d1' ;
  5559.         $array['category'][2]['detail'][39]['champs'] = 'Durée de prorogation (en mois)';$array['category'][2]['detail'][39]['name'] = 'Durée de prorogation (en mois) (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][39]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-d2' ;
  5560.         $array['category'][2]['detail'][40]['champs'] = 'Contrepartie en nature';$array['category'][2]['detail'][40]['name'] = 'Contrepartie en nature (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][40]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-loyerEnNature' ;
  5561.         $array['category'][2]['detail'][41]['champs'] = 'Type de bail';$array['category'][2]['detail'][41]['name'] = 'Type de bail (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][41]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-typeBail' ;
  5562.         $array['category'][2]['detail'][42]['champs'] = 'Durée du bail en année';$array['category'][2]['detail'][42]['name'] = 'Durée du bail en année (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][42]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-dureeBail' ;
  5563.         $array['category'][2]['detail'][43]['champs'] = 'DA / EDDV';$array['category'][2]['detail'][43]['name'] = 'DA / EDDV (Etape 3 Timeline Foncier)';$array['category'][2]['detail'][43]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-601-fileEtatDecriptifMultiple-2' ;
  5564.         $array['category'][2]['detail'][43001]['champs'] = 'Plan de servitudes';$array['category'][2]['detail'][43001]['name'] = 'Plan de servitudes (Etape 3 Timeline Foncier)';$array['category'][2]['detail'][43001]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-601-filePlanServitudesMultiple-2' ;
  5565.         $array['category'][2]['detail'][44]['champs'] = 'Etat hypothécaire';$array['category'][2]['detail'][44]['name'] = 'Etat hypothécaire (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][44]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-fileEtatHypothecaireMultiple-2' ;
  5566.         $array['category'][2]['detail'][45]['champs'] = 'Publication SPF ';$array['category'][2]['detail'][45]['name'] = 'Publication SPF (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][45]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-filePublicationSPRMultiple-2' ;
  5567.         $array['category'][2]['detail'][46]['champs'] = 'Titre de propriété ';$array['category'][2]['detail'][46]['name'] = 'Titre de propriété (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][46]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-fileTitreProprieteMultiple-2' ;
  5568.         $array['category'][2]['detail'][47]['champs'] = 'Autres (Cession de bail, projet de bail…)';$array['category'][2]['detail'][47]['name'] = 'Autres (Cession de bail, projet de bail…) (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][47]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-fileAutreEtap6-2' ;
  5569.         $array['category'][2]['detail'][48]['champs'] = 'Procuration Bailleur ';$array['category'][2]['detail'][48]['name'] = 'Procuration Bailleur (Etape 4 Timeline Foncier)';$array['category'][2]['detail'][48]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-602-fileProcurationBailleur-2' ;
  5570.         $array['category'][2]['detail'][49]['champs'] = 'Nom du notaire ';$array['category'][2]['detail'][49]['name'] = 'Nom du notaire (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][49]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-nomNotaire' ;
  5571.         $array['category'][2]['detail'][50]['champs'] = 'Bail signé';$array['category'][2]['detail'][50]['name'] = 'Bail signé (Etape 3 Timeline Foncier)';$array['category'][2]['detail'][50]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-7-fileBailSigneMultiple-2' ;
  5572.         $array['category'][2]['detail'][51]['champs'] = 'Avenant au bail';$array['category'][2]['detail'][51]['name'] = 'Avenant au bail (Etape 3 Timeline Foncier)';$array['category'][2]['detail'][51]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-7-fileAvenantBailMultiple-2' ;
  5573.         $array['category'][2]['detail'][10030]['champs'] = 'Date d’intervention';$array['category'][2]['detail'][10030]['name'] = 'Date d’intervention (Etape 3 Timeline Foncier)';$array['category'][2]['detail'][10030]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-601-dateIntervention-1' ;
  5574.         $array['category'][2]['detail'][224]['champs'] = 'Preuve de publications SPF';$array['category'][2]['detail'][224]['name'] = 'Preuve de publications SPF (Etape 3 Timeline Foncier)';$array['category'][2]['detail'][224]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-7-filePreuvePublicationsSPFMultiple-2' ;
  5575.         $array['category'][2]['detail'][228]['champs'] = 'Litige';$array['category'][2]['detail'][228]['name'] = 'Litige';$array['category'][2]['detail'][228]['value'] = 'projet-'.ParametrageXlsProject::type_row_const.'-etap-0-0-0-12' ;
  5576.         $array['category'][2]['detail'][226]['champs'] = 'Litige documents';$array['category'][2]['detail'][226]['name'] = 'Litige documents';$array['category'][2]['detail'][226]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-71-etap71Litige-2-fileDocLitigeMultiple-3' ;
  5577.         $array['category'][2]['detail'][227]['champs'] = 'Litige commentaires';$array['category'][2]['detail'][227]['name'] = 'Litige commentaires';$array['category'][2]['detail'][227]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-71-etap71Litige-0-etap71LitigeCommentaire-comment' ;
  5578.         $array['category'][2]['detail'][183]['champs'] = 'Terrassement';$array['category'][2]['detail'][183]['name'] = 'Terrassement (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][183]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-terrassement' ;
  5579.         $array['category'][2]['detail'][184]['champs'] = 'Tranchée';$array['category'][2]['detail'][184]['name'] = 'Tranchée (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][184]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-tranchee' ;
  5580.         $array['category'][2]['detail'][185]['champs'] = 'Bardage';$array['category'][2]['detail'][185]['name'] = 'Bardage (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][185]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-bardage' ;
  5581.         $array['category'][2]['detail'][186]['champs'] = 'Rénovation charpente';$array['category'][2]['detail'][186]['name'] = 'Rénovation charpente (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][186]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-renovationCharpente' ;
  5582.         $array['category'][2]['detail'][187]['champs'] = 'Désamiantage';$array['category'][2]['detail'][187]['name'] = 'Désamiantage (Etape 1 Timeline Foncier)';$array['category'][2]['detail'][187]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-desamiantage' ;
  5583.         $array['category'][2]['detail'][191]['champs'] = 'Levée d’option date';$array['category'][2]['detail'][191]['name'] = 'Levée d’option date';$array['category'][2]['detail'][191]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-leveeOption-1' ;
  5584.         $array['category'][2]['detail'][190]['champs'] = 'Levée d’option doc';$array['category'][2]['detail'][190]['name'] = 'Levée d’option doc';$array['category'][2]['detail'][190]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-fileLeveeOptionMultiple-2' ;
  5585.         $array['category'][2]['detail'][19100]['champs'] = 'Acte de substitution';$array['category'][2]['detail'][19100]['name'] = 'Acte de substitution';$array['category'][2]['detail'][19100]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-fileActeSubstitutionMultiple-2' ;
  5586.         $array['category'][2]['detail'][19101]['champs'] = 'LOI';$array['category'][2]['detail'][19101]['name'] = 'LOI';$array['category'][2]['detail'][19101]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-fileLoiMultiple-2' ;
  5587.         $array['category'][2]['detail'][19102]['champs'] = 'Promesse d\'achat';$array['category'][2]['detail'][19102]['name'] = 'Promesse d\'achat';$array['category'][2]['detail'][19102]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-filePromesseAchatMultiple-2' ;
  5588.         $array['category'][2]['detail'][19103]['champs'] = 'Date de signature LOI';$array['category'][2]['detail'][19103]['name'] = 'Date de signature LOI';$array['category'][2]['detail'][19103]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-dateSignature-1';
  5589.         $array['category'][2]['detail'][19104]['champs'] = 'Date de fin d’exclusivité LOI';$array['category'][2]['detail'][19104]['name'] = 'Date de fin d’exclusivité LOI';$array['category'][2]['detail'][19104]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-dateFinExclusiviteLoi-1';
  5590.         $array['category'][2]['detail'][19105]['champs'] = 'Honoraire apporteur';$array['category'][2]['detail'][19105]['name'] = 'Honoraire apporteur';$array['category'][2]['detail'][19105]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-honoraireApporteur';
  5591.         $array['category'][2]['detail'][19106]['champs'] = 'Indemnité transitoire';$array['category'][2]['detail'][19106]['name'] = 'Indemnité transitoire';$array['category'][2]['detail'][19106]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-indemniteTransitoire';
  5592.         $array['category'][2]['detail'][191060]['champs'] = 'Puissance signée';$array['category'][2]['detail'][191060]['name'] = 'Puissance signée';$array['category'][2]['detail'][191060]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-puissanceSignee';
  5593.         $array['category'][2]['detail'][19107]['champs'] = 'Prix d’achat foncier';$array['category'][2]['detail'][19107]['name'] = 'Prix d’achat foncier';$array['category'][2]['detail'][19107]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-prixAchatFoncier';
  5594.         $array['category'][2]['detail'][19108]['champs'] = 'Unité du prix d’achat';$array['category'][2]['detail'][19108]['name'] = 'Unité du prix d’achat';$array['category'][2]['detail'][19108]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-5-unitePrixAchat';
  5595.         $array['category'][2]['detail'][192]['champs'] = 'Extrait de matrice cadastrale';$array['category'][2]['detail'][192]['name'] = 'Extrait de matrice cadastrale (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][192]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-fileExtraitMatriceCadastrale-2' ;
  5596.         $array['category'][2]['detail'][193]['champs'] = 'Carte d’identité';$array['category'][2]['detail'][193]['name'] = 'Carte d’identité (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][193]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-fileCarteIdentite-2' ;
  5597.         $array['category'][2]['detail'][194]['champs'] = 'Livret de famille ';$array['category'][2]['detail'][194]['name'] = 'Livret de famille (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][194]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-fileLivretFamille-2' ;
  5598.         $array['category'][2]['detail'][195]['champs'] = 'Accord ML ';$array['category'][2]['detail'][195]['name'] = 'Accord ML (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][195]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-fileAccordMl-2' ;
  5599.         $array['category'][2]['detail'][196]['champs'] = 'Kbis ';$array['category'][2]['detail'][196]['name'] = 'Kbis (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][196]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-fileKbis-2' ;
  5600.         $array['category'][2]['detail'][197]['champs'] = 'Statuts ';$array['category'][2]['detail'][197]['name'] = 'Statuts (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][197]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-fileStatuts-2' ;
  5601.         $array['category'][2]['detail'][198]['champs'] = 'les parcelles du projet';$array['category'][2]['detail'][198]['name'] = 'les parcelles du projet (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][198]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-parcellesProjet' ;
  5602.         $array['category'][2]['detail'][199]['champs'] = 'les propriétaires';$array['category'][2]['detail'][199]['name'] = 'les propriétaires (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][199]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-proprietaires' ;
  5603.         $array['category'][2]['detail'][200]['champs'] = 'Situation foncière';$array['category'][2]['detail'][200]['name'] = 'Situation foncière (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][200]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-situationFonciere' ;
  5604.         $array['category'][2]['detail'][201]['champs'] = 'Statut Mainlevée ';$array['category'][2]['detail'][201]['name'] = 'Statut Mainlevée (Etape 2 Timeline Foncier)';$array['category'][2]['detail'][201]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-6-statutMainlevee' ;
  5605.         $array['category'][3]['num'] = 3;
  5606.         $array['category'][3]['name'] = 'Raccordement';
  5607.         $array['category'][3]['detail'][52001]['champs'] = 'IPR';$array['category'][3]['detail'][52001]['name'] = 'IPR (Etape 0 Timeline Raccordement)';$array['category'][3]['detail'][52001]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-80-fileIPR-2' ;
  5608.         $array['category'][3]['detail'][52002]['champs'] = 'PRAC';$array['category'][3]['detail'][52002]['name'] = 'PRAC (Etape 0 Timeline Raccordement)';$array['category'][3]['detail'][52002]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-80-filePRAC-2' ;
  5609.         $array['category'][3]['detail'][52003]['champs'] = 'Distance PDL';$array['category'][3]['detail'][52003]['name'] = 'Distance PDL  (Etape 0 Timeline Raccordement)';$array['category'][3]['detail'][52003]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-80-distancePdl' ;
  5610.         $array['category'][3]['detail'][52004]['champs'] = 'Nature du raccordement ';$array['category'][3]['detail'][52004]['name'] = 'Nature du raccordement  (Etape 0 Timeline Raccordement)';$array['category'][3]['detail'][52004]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-80-natureRaccordemenT' ;
  5611.         $array['category'][3]['detail'][52]['champs'] = 'Kbis de l’ETS';$array['category'][3]['detail'][52]['name'] = 'Kbis de l’ETS (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][52]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-fileKbisEtsMultiple-2' ;
  5612.         $array['category'][3]['detail'][53]['champs'] = 'Profil du créateur';$array['category'][3]['detail'][53]['name'] = 'Profil du créateur (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][53]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-profileCreateur' ;
  5613.         $array['category'][3]['detail'][54]['champs'] = 'Adresse';$array['category'][3]['detail'][54]['name'] = 'Adresse (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][54]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-adresseEtablissement' ;
  5614.         $array['category'][3]['detail'][55]['champs'] = 'Ville';$array['category'][3]['detail'][55]['name'] = 'Ville (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][55]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-cityEtablissement' ;
  5615.         $array['category'][3]['detail'][56]['champs'] = 'Code postal';$array['category'][3]['detail'][56]['name'] = 'Code postal (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][56]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-codePostalEtablissement' ;
  5616.         $array['category'][3]['detail'][57]['champs'] = 'Latitude';$array['category'][3]['detail'][57]['name'] = 'Latitude (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][57]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-latEtablissement' ;
  5617.         $array['category'][3]['detail'][58]['champs'] = 'Longitude';$array['category'][3]['detail'][58]['name'] = 'Longitude (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][58]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-longiEtablissement' ;
  5618.         $array['category'][3]['detail'][59]['champs'] = 'Numéro de parcelle';$array['category'][3]['detail'][59]['name'] = 'Numéro de parcelle (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][59]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-numParcelleEtablissement' ;
  5619.         $array['category'][3]['detail'][60]['champs'] = 'SIRET de l’ETS';$array['category'][3]['detail'][60]['name'] = 'SIRET de l’ETS (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][60]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-siretEts' ;
  5620.         $array['category'][3]['detail'][61]['champs'] = 'SPV confirmation ou changement';$array['category'][3]['detail'][61]['name'] = 'SPV confirmation ou changement (Etape 1 Timeline Raccordement)';$array['category'][3]['detail'][61]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-8-spvEtablissement' ;
  5621.         $array['category'][3]['detail'][62]['champs'] = 'Mail d’ENEDIS de confirmation';$array['category'][3]['detail'][62]['name'] = 'Mail d’ENEDIS de confirmation (Etape 2 Timeline Raccordement)';$array['category'][3]['detail'][62]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-9-fileMailEnedisConfirmationMultiple-2' ;
  5622.         $array['category'][3]['detail'][62001]['champs'] = 'Demande de raccordement';$array['category'][3]['detail'][62001]['name'] = 'Demande de raccordement (Etape 2 Timeline Raccordement)';$array['category'][3]['detail'][62001]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-9-fileDemandeRaccordementMultiple-2' ;
  5623. //        $array['category'][3]['detail'][62002]['champs'] = 'Garantie bancaire';$array['category'][3]['detail'][62002]['name'] = 'Garantie bancaire (Etape 2 Timeline Raccordement)';$array['category'][3]['detail'][62002]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-9-fileGarantieBancaireMultiple-2' ;
  5624. //        $array['category'][3]['detail'][63]['champs'] = 'Date maximale d\'achèvement des travaux';$array['category'][3]['detail'][63]['name'] = 'Date maximale d\'achèvement des travaux (Etape 2 Timeline Raccordement)';$array['category'][3]['detail'][63]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-9-dateMaximaleAchevement-1' ;
  5625. //        $array['category'][3]['detail'][64]['champs'] = 'Tarif Fit prévisionnel';$array['category'][3]['detail'][64]['name'] = 'Tarif Fit prévisionnel (Etape 2 Timeline Raccordement)';$array['category'][3]['detail'][64]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-9-tarifFit' ;
  5626.         $array['category'][3]['detail'][65]['champs'] = 'Date T0';$array['category'][3]['detail'][65]['name'] = 'Date T0 (Etape 2 Timeline Raccordement)';$array['category'][3]['detail'][65]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-9-dateT0-1' ;
  5627.         $array['category'][3]['detail'][66]['champs'] = 'PTF';$array['category'][3]['detail'][66]['name'] = 'PTF (Etape 3 Timeline Raccordement)';$array['category'][3]['detail'][66]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-10-filePtfMultiple-2' ;
  5628.         $array['category'][3]['detail'][67]['champs'] = 'CRD signée';$array['category'][3]['detail'][67]['name'] = 'CRD signée (Etape 3 Timeline Raccordement)';$array['category'][3]['detail'][67]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-10-fileCrdSigneeMultiple-2' ;
  5629.         $array['category'][3]['detail'][68]['champs'] = 'Preuve de virement';$array['category'][3]['detail'][68]['name'] = 'Preuve de virement (Etape 3 Timeline Raccordement)';$array['category'][3]['detail'][68]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-10-filePreuveVirementMultiple-2' ;
  5630.         $array['category'][3]['detail'][6800]['champs'] = 'Avenant CRD';$array['category'][3]['detail'][6800]['name'] = 'Avenant CRD (Etape 3 Timeline Raccordement)';$array['category'][3]['detail'][6800]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-10-fileAvenantCrdMultiple-2' ;
  5631.         $array['category'][3]['detail'][6801]['champs'] = 'Avenant CRD pour MES';$array['category'][3]['detail'][6801]['name'] = 'Avenant CRD pour MES (Etape 3 Timeline Raccordement)';$array['category'][3]['detail'][6801]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-10-fileAvenantCrdMesMultiple-2' ;
  5632.         $array['category'][3]['detail'][69]['champs'] = 'Montant acompte ';$array['category'][3]['detail'][69]['name'] = 'Montant acompte (Etape 3 Timeline Raccordement)';$array['category'][3]['detail'][69]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-10-montantAcompte' ;
  5633.         $array['category'][3]['detail'][6900]['champs'] = 'Avenant CRD TEXT ';$array['category'][3]['detail'][6900]['name'] = 'Avenant CRD TEXT (Etape 3 Timeline Raccordement)';$array['category'][3]['detail'][6900]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-10-avenantCrdMes' ;
  5634.         $array['category'][3]['detail'][70]['champs'] = 'Montant coût total';$array['category'][3]['detail'][70]['name'] = 'Montant coût total (Etape 3 Timeline Raccordement)';$array['category'][3]['detail'][70]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-10-montantCoutTotal' ;
  5635.         $array['category'][3]['detail'][71]['champs'] = 'Référence ENEDIS ';$array['category'][3]['detail'][71]['name'] = 'Référence ENEDIS (Etape 3 Timeline Raccordement)';$array['category'][3]['detail'][71]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-10-referenceEnedis' ;
  5636.         $array['category'][3]['detail'][72]['champs'] = 'CEX signé';$array['category'][3]['detail'][72]['name'] = 'CEX signé (Etape 4 Timeline Raccordement)';$array['category'][3]['detail'][72]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-12-fileCexSigneMultiple-2' ;
  5637.         $array['category'][3]['detail'][73]['champs'] = 'CARDi signé';$array['category'][3]['detail'][73]['name'] = 'CARDi signé (Etape 4 Timeline Raccordement)';$array['category'][3]['detail'][73]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-12-fileCardiSigneMultiple-2' ;
  5638.         $array['category'][3]['detail'][74]['champs'] = 'Numéro de contrat';$array['category'][3]['detail'][74]['name'] = 'Numéro de contrat (Etape 4 Timeline Raccordement)';$array['category'][3]['detail'][74]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-12-numeroCardiMultiple-0-numeroCardi' ;
  5639.         $array['category'][3]['detail'][75]['champs'] = 'Numéro PRM';$array['category'][3]['detail'][75]['name'] = 'Numéro PRM (Etape 4 Timeline Raccordement)';$array['category'][3]['detail'][75]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-12-numeroCardiMultiple-0-identifiantEnedis' ;
  5640.         $array['category'][3]['detail'][76]['champs'] = 'Consuel';$array['category'][3]['detail'][76]['name'] = 'Consuel (Etape 5 Timeline Raccordement)';$array['category'][3]['detail'][76]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-13-fileConsuelMultiple-2' ;
  5641.         $array['category'][3]['detail'][77]['champs'] = 'Date du consuel ';$array['category'][3]['detail'][77]['name'] = 'Date du consuel (Etape 5 Timeline Raccordement)';$array['category'][3]['detail'][77]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-13-dateConsuel-1' ;
  5642.         $array['category'][3]['detail'][9976]['champs'] = 'Attestation bureau de contrôle S21';$array['category'][3]['detail'][9976]['name'] = 'Attestation bureau de contrôle S21 (Etape 5 Timeline Raccordement)';$array['category'][3]['detail'][9976]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-13-fileAttestationBureauControleMultiple-2' ;
  5643.         $array['category'][3]['detail'][9977]['champs'] = 'DRE';$array['category'][3]['detail'][9977]['name'] = 'DRE (Etape 5 Timeline Raccordement)';$array['category'][3]['detail'][9977]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-13-fileDREMultiple-2' ;
  5644.         $array['category'][3]['detail'][78]['champs'] = 'Attestation de mise en service';$array['category'][3]['detail'][78]['name'] = 'Attestation de mise en service (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][78]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-fileDoeMultiple-2' ;
  5645.         $array['category'][3]['detail'][78001]['champs'] = 'ARPE';$array['category'][3]['detail'][78001]['name'] = 'ARPE (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][78001]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-fileARPE-2' ;
  5646.         $array['category'][3]['detail'][78002]['champs'] = 'DEIE';$array['category'][3]['detail'][78002]['name'] = 'DEIE (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][78002]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-fileDEIE-2' ;
  5647.         $array['category'][3]['detail'][79]['champs'] = 'Date de mise en service';$array['category'][3]['detail'][79]['name'] = 'Date de mise en service (Etape7 Timeline Raccordement)';$array['category'][3]['detail'][79]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-dateMiseEnService-1' ;
  5648.         $array['category'][3]['detail'][80]['champs'] = 'Adresse';$array['category'][3]['detail'][80]['name'] = 'Adresse (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][80]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-adresseMiseEnService' ;
  5649.         $array['category'][3]['detail'][81]['champs'] = 'Ville';$array['category'][3]['detail'][81]['name'] = 'Ville (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][81]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-cityMiseEnService' ;
  5650.         $array['category'][3]['detail'][82]['champs'] = 'Code postal';$array['category'][3]['detail'][82]['name'] = 'Code postal (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][82]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-codePostalMiseEnService' ;
  5651.         $array['category'][3]['detail'][83]['champs'] = 'Nom du bailleur';$array['category'][3]['detail'][83]['name'] = 'Nom du bailleur (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][83]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-firstnameProprietaire' ;
  5652.         $array['category'][3]['detail'][84]['champs'] = 'Prénom du bailleur';$array['category'][3]['detail'][84]['name'] = 'Prénom du bailleur (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][84]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-lastnameProprietaire' ;
  5653.         $array['category'][3]['detail'][85]['champs'] = 'N° de téléphone du propriétaire';$array['category'][3]['detail'][85]['name'] = 'N° de téléphone du propriétaire (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][85]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-phoneProprietaire' ;
  5654.         $array['category'][3]['detail'][86]['champs'] = 'E-mail du propriétaire';$array['category'][3]['detail'][86]['name'] = 'E-mail du propriétaire (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][86]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-emailProprietaire' ;
  5655.         $array['category'][3]['detail'][87]['champs'] = 'Procédure d’accès';$array['category'][3]['detail'][87]['name'] = 'Procédure d’accès (Etape 7 Timeline Raccordement)';$array['category'][3]['detail'][87]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-14-procedureAcces' ;
  5656.         $array['category'][3]['detail'][164]['champs'] = 'Date prévisionnelle d’installation du PDL';$array['category'][3]['detail'][164]['name'] = 'Date prévisionnelle d’installation du PDL (Etape 5 Timeline Raccordement)';$array['category'][3]['detail'][164]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-121-datePrevisionnelleInstallationPDL-1' ;
  5657.         $array['category'][3]['detail'][166]['champs'] = 'Date d’installation du PDL';$array['category'][3]['detail'][166]['name'] = 'Date d’installation du PDL (Etape 5 Timeline Raccordement)';$array['category'][3]['detail'][166]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-121-dateInstallationPDL-1' ;
  5658.         $array['category'][3]['detail'][167]['champs'] = 'Date de mise sous tension ENEDIS';$array['category'][3]['detail'][167]['name'] = 'Date de mise sous tension ENEDIS (Etape 5 Timeline Raccordement)';$array['category'][3]['detail'][167]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-121-dateMiseSousTensionEnedis-1' ;
  5659.         $array['category'][3]['detail'][165]['champs'] = 'Installation PDL';$array['category'][3]['detail'][165]['name'] = 'Installation PDL (Etape 5 Timeline Raccordement)';$array['category'][3]['detail'][165]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-121-fileDocument121Multiple-2' ;
  5660.         $array['category'][3]['detail'][210]['champs'] = 'Avenant CARDi';$array['category'][3]['detail'][210]['name'] = 'Avenant CARDi (Etape 4 Timeline Raccordement)';$array['category'][3]['detail'][210]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-12-fileAvenantCardiMultiple-2' ;
  5661.         $array['category'][4]['num'] = 4;
  5662.         $array['category'][4]['name'] = 'Construction';
  5663.         $array['category'][4]['detail'][96]['champs'] = 'Diagnostic charpente';$array['category'][4]['detail'][96]['name'] = 'Diagnostic charpente (Etape 1 Timeline Construction)';$array['category'][4]['detail'][96]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-160-fileDiagnostiqueCharpenteMultiple-2' ;
  5664.         $array['category'][4]['detail'][97]['champs'] = 'Étude de sol';$array['category'][4]['detail'][97]['name'] = 'Étude de sol (Etape 1 Timeline Construction)';$array['category'][4]['detail'][97]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-160-fileEtudeSoleMultiple-2' ;
  5665.         $array['category'][4]['detail'][100]['champs'] = 'PV de démarrage';$array['category'][4]['detail'][100]['name'] = 'PV de démarrage (Etape 4-1 Timeline Construction)';$array['category'][4]['detail'][100]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-171-filePVDemarrageMultiple-2' ;
  5666.         $array['category'][4]['detail'][101]['champs'] = 'DOC';$array['category'][4]['detail'][101]['name'] = 'DOC (Etape 4-1 Timeline Construction)';$array['category'][4]['detail'][101]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-171-fileDocEtap171Multiple-2' ;
  5667.         $array['category'][4]['detail'][102]['champs'] = 'Ordre de service';$array['category'][4]['detail'][102]['name'] = 'Ordre de service (Etape 4-1 Timeline Construction)';$array['category'][4]['detail'][102]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-171-fileOrderServiceMultiple-2' ;
  5668.         $array['category'][4]['detail'][103]['champs'] = 'Planning prévisionnel';$array['category'][4]['detail'][103]['name'] = 'Planning prévisionnel (Etape 4-1 Timeline Construction)';$array['category'][4]['detail'][103]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-171-filePlanningPrevisionnelMultiple-2' ;
  5669.         $array['category'][4]['detail'][1030]['champs'] = 'PGC';$array['category'][4]['detail'][1030]['name'] = 'PGC (Etape 4-1 Timeline Construction)';$array['category'][4]['detail'][1030]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-171-filePGCMultiple-2' ;
  5670.         $array['category'][4]['detail'][1031]['champs'] = 'PPSPS';$array['category'][4]['detail'][1031]['name'] = 'PPSPS (Etape 4-1 Timeline Construction)';$array['category'][4]['detail'][1031]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-171-filePPSPSMultiple-2' ;
  5671.         $array['category'][4]['detail'][1032]['champs'] = 'Harmonisation';$array['category'][4]['detail'][1032]['name'] = 'Harmonisation (Etape 4-1 Timeline Construction)';$array['category'][4]['detail'][1032]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-171-fileHarmonisationMultiple-2' ;
  5672.         $array['category'][4]['detail'][1033]['champs'] = 'Rapport de visite SPS';$array['category'][4]['detail'][1033]['name'] = 'Rapport de visite SPS (Etape 4-1 Timeline Construction)';$array['category'][4]['detail'][1033]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-171-fileRapportVisiteSpsMultiple-2' ;
  5673.         $array['category'][4]['detail'][1034]['champs'] = 'DIUO';$array['category'][4]['detail'][1034]['name'] = 'DIUO (Etape 4-1 Timeline Construction)';$array['category'][4]['detail'][1034]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-171-DIUO-2' ;
  5674.         $array['category'][4]['detail'][104]['champs'] = 'Note de calcul béton et féraillage';$array['category'][4]['detail'][104]['name'] = 'Note de calcul béton et féraillage (Etape 4-2 Timeline Construction)';$array['category'][4]['detail'][104]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-172-fileNoteCalculBetonFeraillageMultiple-2' ;
  5675.         $array['category'][4]['detail'][105]['champs'] = 'Plan implantation bâtiment avec dalle béton du local onduleur';$array['category'][4]['detail'][105]['name'] = 'Plan implantation bâtiment avec dalle béton du local onduleur (Etape 4-2 Timeline Construction)';$array['category'][4]['detail'][105]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-172-filePlanImplantationBatimentAvecDalleBetonMultiple-2' ;
  5676.         $array['category'][4]['detail'][106]['champs'] = 'PV de réception';$array['category'][4]['detail'][106]['name'] = 'PV de réception (Etape 4-2 Timeline Construction)';$array['category'][4]['detail'][106]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-172-filePVReceptionMultiple-2' ;
  5677.         $array['category'][4]['detail'][107]['champs'] = 'Fondations terminées ';$array['category'][4]['detail'][107]['name'] = 'Fondations terminées (Etape 4-2 Timeline Construction)';$array['category'][4]['detail'][107]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-172-fileFondationTermineesMultiple-2' ;
  5678.         $array['category'][4]['detail'][108]['champs'] = 'Dalle béton shelter ';$array['category'][4]['detail'][108]['name'] = 'Dalle béton shelter (Etape 4-2 Timeline Construction)';$array['category'][4]['detail'][108]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-172-fileDalleBetonShelterMultiple-2' ;
  5679.         $array['category'][4]['detail'][109]['champs'] = 'Chemin d’accès ';$array['category'][4]['detail'][109]['name'] = 'Chemin d’accès (Etape 4-2 Timeline Construction)';$array['category'][4]['detail'][109]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-172-fileCheminAccesMultiple-2' ;
  5680.         $array['category'][4]['detail'][110]['champs'] = 'Photos de la plateforme';$array['category'][4]['detail'][110]['name'] = 'Photos de la plateforme (Etape 4-2 Timeline Construction)';$array['category'][4]['detail'][110]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-172-filePhotosPlateformeMultiple-2' ;
  5681.         $array['category'][4]['detail'][111]['champs'] = 'Date debut des fondations';$array['category'][4]['detail'][111]['name'] = 'Date debut des fondations (Etape 4-2 Timeline Construction)';$array['category'][4]['detail'][111]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-172-dateDebutFondation-1' ;
  5682.         $array['category'][4]['detail'][112]['champs'] = 'Notes de calcul charpente';$array['category'][4]['detail'][112]['name'] = 'Notes de calcul charpente (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][112]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-fileNoteCalculCharpente173Multiple-2' ;
  5683. //        $array['category'][4]['detail'][113]['champs'] = 'Photos de renforcement charpente';$array['category'][4]['detail'][113]['name'] = 'Photos de renforcement charpente (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][113]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-filePhotoRenforcementcharpente173Multiple-2' ;
  5684.         $array['category'][4]['detail'][114]['champs'] = 'Plan de bardage';$array['category'][4]['detail'][114]['name'] = 'Plan de bardage (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][114]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-fileOssatureSecondaireBardage173Multiple-2' ;
  5685. //        $array['category'][4]['detail'][115]['champs'] = 'Photos de renforcement des bardages';$array['category'][4]['detail'][115]['name'] = 'Photos de renforcement des bardages (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][115]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-filePhotoRenforcementBardage173Multiple-2' ;
  5686.         $array['category'][4]['detail'][116]['champs'] = 'PV réception lot charpente / couverture / bardage';$array['category'][4]['detail'][116]['name'] = 'PV réception lot charpente / couverture / bardage (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][116]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-filePVreception173Multiple-2' ;
  5687. //        $array['category'][4]['detail'][117]['champs'] = 'Photos de renforcement de la couverture terminée';$array['category'][4]['detail'][117]['name'] = 'Photos de renforcement de la couverture terminée (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][117]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-filePhotoRenforcementCouvertureTermine173Multiple-2' ;
  5688.         $array['category'][4]['detail'][118]['champs'] = 'Plans de charpente';$array['category'][4]['detail'][118]['name'] = 'Plans de charpente (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][118]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-filePlansCharpente173Multiple-2' ;
  5689.         $array['category'][4]['detail'][1181]['champs'] = 'Plans de charpente signé par le bailleur';$array['category'][4]['detail'][1181]['name'] = 'Plans de charpente (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][1181]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-filePlansCharpente173SigneMultiple-2' ;
  5690.         $array['category'][4]['detail'][119]['champs'] = 'Vues 3D';$array['category'][4]['detail'][119]['name'] = 'Vues 3D (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][119]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-fileVues3d173Multiple-2' ;
  5691.         $array['category'][4]['detail'][120]['champs'] = 'Plan de couverture';$array['category'][4]['detail'][120]['name'] = 'Plan de couverture (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][120]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-filePlanCouverture173Multiple-2' ;
  5692.         $array['category'][4]['detail'][121]['champs'] = 'Plan et descriptifs des travaux de renforcement de charpente';$array['category'][4]['detail'][121]['name'] = 'Plan et descriptifs des travaux de renforcement de charpente (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][121]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-filePlanDescriptionTravauxRenforcementCharpente173Multiple-2' ;
  5693.         $array['category'][4]['detail'][122]['champs'] = 'Plan et descriptifs des travaux de dépose , repose de couverture';$array['category'][4]['detail'][122]['name'] = 'Plan et descriptifs des travaux de dépose , repose de couverture (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][122]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-filePlanDescriptionTravauxDeposeCouverture173Multiple-2' ;
  5694.         $array['category'][4]['detail'][123]['champs'] = 'Date Début Charpente';$array['category'][4]['detail'][123]['name'] = 'Date Début Charpente (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][123]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-dateDebutCharpente-1' ;
  5695.         $array['category'][4]['detail'][124]['champs'] = 'Date Fin Charpente';$array['category'][4]['detail'][124]['name'] = 'Date Fin Charpente (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][124]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-dateFinCharpente-1' ;
  5696.         $array['category'][4]['detail'][125]['champs'] = 'Date Début Couverture';$array['category'][4]['detail'][125]['name'] = 'Date Début Couverture (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][125]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-dateDebutCouverture-1' ;
  5697.         $array['category'][4]['detail'][126]['champs'] = 'Date Fin Couverture';$array['category'][4]['detail'][126]['name'] = 'Date Fin Couverture (Etape 4-3 Timeline Construction)';$array['category'][4]['detail'][126]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-173-dateFinCouverture-1' ;
  5698.         $array['category'][4]['detail'][127]['champs'] = 'Plan de calepinage / câblage';$array['category'][4]['detail'][127]['name'] = 'Plan de calepinage / câblage (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][127]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-filePlanCalepinageModule174Multiple-2' ;
  5699. //        $array['category'][4]['detail'][128]['champs'] = 'Plan de câblage des strings';$array['category'][4]['detail'][128]['name'] = 'Plan de câblage des strings (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][128]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-filePlanCaplageStrings174Multiple-2' ;
  5700.         $array['category'][4]['detail'][129]['champs'] = 'Note de calcul sous Lise PV';$array['category'][4]['detail'][129]['name'] = 'Note de calcul sous Lise PV (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][129]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-fileNoteCalculSousLisePV174Multiple-2' ;
  5701.         $array['category'][4]['detail'][130]['champs'] = 'Schéma Unifilaire de l’installation';$array['category'][4]['detail'][130]['name'] = 'Schéma Unifilaire de l’installation (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][130]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-fileSchemaUnifilaireInstallation174Multiple-2' ;
  5702.         $array['category'][4]['detail'][131]['champs'] = 'Schéma d’agencement du shelter ou photos';$array['category'][4]['detail'][131]['name'] = 'Schéma d’agencement du shelter ou photos (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][131]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-fileShemaAgencementShelterPhotos174Multiple-2' ;
  5703. //        $array['category'][4]['detail'][132]['champs'] = 'Test de PR Ã  la mise en service';$array['category'][4]['detail'][132]['name'] = 'Test de PR Ã  la mise en service (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][132]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-fileTestPrMiseService174Multiple-2' ;
  5704.         $array['category'][4]['detail'][133]['champs'] = 'Schéma unifilaire du système de monitoring';$array['category'][4]['detail'][133]['name'] = 'Schéma unifilaire du système de monitoring (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][133]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-fileShemaUnifilaireSystemeMonitoring174Multiple-2' ;
  5705.         $array['category'][4]['detail'][134]['champs'] = 'Tests et vérifications des travaux Ã©lectriques, fiche d’auto-contrôle de l’installateur ';$array['category'][4]['detail'][134]['name'] = 'Tests et vérifications des travaux Ã©lectriques, fiche d’auto-contrôle de l’installateur (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][134]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-fileTestVerificationTravauxElectriqueFiche174Multiple-2' ;
  5706.         $array['category'][4]['detail'][135]['champs'] = 'PV de réception (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][135]['name'] = 'PV de réception (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][135]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-filePVReception174Multiple-2' ;
  5707.         $array['category'][4]['detail'][136]['champs'] = 'Photos de la centrale solaire';$array['category'][4]['detail'][136]['name'] = 'Photos de la centrale solaire (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][136]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-filePhotosGenerateur174Multiple-2' ;
  5708. //        $array['category'][4]['detail'][127]['name'] = 'Pv terminées (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][127]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-filePvTerminees174Multiple-2' ;
  5709.         $array['category'][4]['detail'][137]['champs'] = 'Descentes de câbles';$array['category'][4]['detail'][137]['name'] = 'Descentes de câbles (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][137]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-fileDescentesCables174Multiple-2' ;
  5710.         $array['category'][4]['detail'][138]['champs'] = 'Raccordement du local onduleur';$array['category'][4]['detail'][138]['name'] = 'Raccordement du local onduleur (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][138]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-fileRaccordementLocalOnduleur174Multiple-2' ;
  5711.         $array['category'][4]['detail'][139]['champs'] = 'Date Début Pose PV ';$array['category'][4]['detail'][139]['name'] = 'Date Début Pose PV (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][139]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-dateDebutPosePv-1' ;
  5712.         $array['category'][4]['detail'][140]['champs'] = 'Date Fin Pose PV ';$array['category'][4]['detail'][140]['name'] = 'Date Fin Pose PV (Etape 4-4 Timeline Construction)';$array['category'][4]['detail'][140]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-174-dateFinPosePv-1' ;
  5713.         $array['category'][4]['detail'][141]['champs'] = 'Notes de calcul des câbles AC de la liaison ';$array['category'][4]['detail'][141]['name'] = 'Notes de calcul des câbles AC de la liaison (Etape 4-5 Timeline Construction)';$array['category'][4]['detail'][141]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-175-fileNoteCalculCableAcLiaison175Multiple-2' ;
  5714.         $array['category'][4]['detail'][142]['champs'] = 'Plans de la tranchée';$array['category'][4]['detail'][142]['name'] = 'Plans de la tranchée (Etape 4-5 Timeline Construction)';$array['category'][4]['detail'][142]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-175-filePlanTranchee175Multiple-2' ;
  5715. //        $array['category'][4]['detail'][143]['champs'] = 'DAACT';$array['category'][4]['detail'][143]['name'] = 'DAACT (Etape 4-5 Timeline Construction)';$array['category'][4]['detail'][143]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-175-fileDaact175Multiple-2' ;
  5716. //        $array['category'][4]['detail'][144]['champs'] = 'PV de réception';$array['category'][4]['detail'][144]['name'] = 'PV de réception (Etape 4-5 Timeline Construction)';$array['category'][4]['detail'][144]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-175-filePVReception175Multiple-2' ;
  5717. //        $array['category'][4]['detail'][145]['champs'] = 'Photos de la liaison terminée';$array['category'][4]['detail'][145]['name'] = 'Photos de la liaison terminée (Etape 4-5 Timeline Construction)';$array['category'][4]['detail'][145]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-175-filePhotosLiaisonTerminee175Multiple-2' ;
  5718.         $array['category'][4]['detail'][146]['champs'] = 'Date achévement des travaux';$array['category'][4]['detail'][146]['name'] = 'Date achévement des travaux (Etape 4-5 Timeline Construction)';$array['category'][4]['detail'][146]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-175-dateAchevementTraveaux-1' ;
  5719.         $array['category'][4]['detail'][147]['champs'] = 'Consuel';$array['category'][4]['detail'][147]['name'] = 'Consuel (Etape 5 Timeline Construction)';$array['category'][4]['detail'][147]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-20-fileConsuelEtap20Multiple-2' ;
  5720.         $array['category'][4]['detail'][148]['champs'] = 'Date du consuel';$array['category'][4]['detail'][148]['name'] = 'Date du consuel  (Etape 5 Timeline Construction)';$array['category'][4]['detail'][148]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-20-dateConsuelEtap20-1' ;
  5721.         $array['category'][4]['detail'][149]['champs'] = 'DOE';$array['category'][4]['detail'][149]['name'] = 'DOE (Etape 6 Timeline Construction)';$array['category'][4]['detail'][149]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-201-fileDoeEtap201Multiple-2' ;
  5722.         $array['category'][4]['detail'][150]['champs'] = 'tests de réception';$array['category'][4]['detail'][150]['name'] = 'tests de réception (Etape 7 Timeline Construction)';$array['category'][4]['detail'][150]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-21-fileTestReceptionMultiple-2' ;
  5723.         $array['category'][4]['detail'][151]['champs'] = 'Date du raccordement';$array['category'][4]['detail'][151]['name'] = 'Date du raccordement (Etape 7 Timeline Construction)';$array['category'][4]['detail'][151]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-21-dateRaccordement-1' ;
  5724.         $array['category'][4]['detail'][152]['champs'] = 'Date de mise en service';$array['category'][4]['detail'][152]['name'] = 'Date de mise en service (Etape 7 Timeline Construction)';$array['category'][4]['detail'][152]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-21-dateMiseEnService-1' ;
  5725.         $array['category'][4]['detail'][153]['champs'] = 'Tests de PR';$array['category'][4]['detail'][153]['name'] = 'Tests de PR (Etape 8 Timeline Construction)';$array['category'][4]['detail'][153]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-22-fileTestPrMultiple-2' ;
  5726.         $array['category'][4]['detail'][170]['champs'] = 'Visite technique';$array['category'][4]['detail'][170]['name'] = 'Visite technique (Etape 0 Timeline Construction)';$array['category'][4]['detail'][170]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-fileVisiteTechnique159Multiple-2' ;
  5727.         $array['category'][4]['detail'][171]['champs'] = 'Etude de productible';$array['category'][4]['detail'][171]['name'] = 'Etude de productible (Etape 0 Timeline Construction)';$array['category'][4]['detail'][171]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-fileEtudeProductible159Multiple-2' ;
  5728.         $array['category'][4]['detail'][172]['champs'] = 'Etude de sol';$array['category'][4]['detail'][172]['name'] = 'Etude géotechnique/étude structure (Etape 0 Timeline Construction)';$array['category'][4]['detail'][172]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-fileGeotechnique159Multiple-2' ;
  5729.         $array['category'][4]['detail'][173]['champs'] = 'Diagnostic charpente';$array['category'][4]['detail'][173]['name'] = 'Diagnostique charpente (Etape 0 Timeline Construction)';$array['category'][4]['detail'][173]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-fileDiagnostiqueCharpente159Multiple-2' ;
  5730.         $array['category'][4]['detail'][174]['champs'] = 'Design pré-CRD';$array['category'][4]['detail'][174]['name'] = 'Design pré-CRD (Etape 0 Timeline Construction)';$array['category'][4]['detail'][174]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-fileDesignPreCRD159Multiple-2' ;
  5731.         $array['category'][4]['detail'][175]['champs'] = 'Design post-CRD ';$array['category'][4]['detail'][175]['name'] = 'Design post-CRD  (Etape 0 Timeline Construction)';$array['category'][4]['detail'][175]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-fileDesignPostCRD159Multiple-2' ;
  5732.         $array['category'][4]['detail'][176]['champs'] = 'Plan de masse et de situation avec tranchée ';$array['category'][4]['detail'][176]['name'] = 'Plan de masse et de situation avec tranchée  (Etape 0 Timeline Construction)';$array['category'][4]['detail'][176]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-filePlanMasseSituationTranchee159Multiple-2' ;
  5733.         $array['category'][4]['detail'][177]['champs'] = 'Plan de calepinage';$array['category'][4]['detail'][177]['name'] = 'Plan de calepinage (Etape 0 Timeline Construction)';$array['category'][4]['detail'][177]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-filePlanCalepinage159Multiple-2' ;
  5734.         $array['category'][4]['detail'][178]['champs'] = 'Schéma unifilaire';$array['category'][4]['detail'][178]['name'] = 'Schéma unifilaire (Etape 0 Timeline Construction)';$array['category'][4]['detail'][178]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-fileSchemaUnifilaire159Multiple-2' ;
  5735.         $array['category'][4]['detail'][179]['champs'] = 'Etat charpente ';$array['category'][4]['detail'][179]['name'] = 'Etat charpente (Etape 0 Timeline Construction)';$array['category'][4]['detail'][179]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-etatCharpente' ;
  5736.         $array['category'][4]['detail'][17900]['champs'] = 'Plans Autocad ';$array['category'][4]['detail'][17900]['name'] = 'Plans Autocad (Etape 0 Timeline Construction)';$array['category'][4]['detail'][17900]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-filePlansAutocadMultiple-2' ;
  5737.         $array['category'][4]['detail'][17901]['champs'] = 'Plans dwg ';$array['category'][4]['detail'][17901]['name'] = 'Plans dwg (Etape 0 Timeline Construction)';$array['category'][4]['detail'][17901]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-filePlansDwgMultiple-2' ;
  5738.         $array['category'][4]['detail'][180]['champs'] = 'Type de toiture existante ';$array['category'][4]['detail'][180]['name'] = 'Type de toiture existante (Etape 0 Timeline Construction)';$array['category'][4]['detail'][180]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-typeToitureExistante' ;
  5739.         $array['category'][4]['detail'][181]['champs'] = 'Type de rénovation ';$array['category'][4]['detail'][181]['name'] = 'Type de rénovation (Etape 0 Timeline Construction)';$array['category'][4]['detail'][181]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-typeRenovation' ;
  5740.         $array['category'][4]['detail'][182]['champs'] = 'Type de toiture Ã  poser ';$array['category'][4]['detail'][182]['name'] = 'Type de toiture Ã  poser (Etape 0 Timeline Construction)';$array['category'][4]['detail'][182]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-159-typeToiturePoser' ;
  5741.         $array['category'][4]['detail'][202]['champs'] = 'Marque Module';$array['category'][4]['detail'][202]['name'] = 'Marque Module  (Étape 1  Timeline Construction)'; $array['category'][4]['detail'][202]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-160-moduleInformation-0-marque' ;
  5742.         $array['category'][4]['detail'][203]['champs'] = 'Puissance crête';$array['category'][4]['detail'][203]['name'] = 'Puissance crête  (Étape 1  Timeline Construction)'; $array['category'][4]['detail'][203]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-160-moduleInformation-0-reference' ;
  5743.         $array['category'][4]['detail'][204]['champs'] = 'Nombre de modules';$array['category'][4]['detail'][204]['name'] = 'Nombre de modules  (Étape 1  Timeline Construction)'; $array['category'][4]['detail'][204]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-160-moduleInformation-0-nbr' ;
  5744.         $array['category'][4]['detail'][205]['champs'] = 'Marque Onduleur';$array['category'][4]['detail'][205]['name'] = 'Marque Onduleur  (Étape 1  Timeline Construction)'; $array['category'][4]['detail'][205]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-160-onduleurInformation-0-marque' ;
  5745.         $array['category'][4]['detail'][206]['champs'] = 'Puissance Onduleur';$array['category'][4]['detail'][206]['name'] = 'Puissance Onduleur  (Étape 1  Timeline Construction)'; $array['category'][4]['detail'][206]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-160-onduleurInformation-0-puissance' ;
  5746.         $array['category'][4]['detail'][207]['champs'] = 'Nombre de Onduleurs';$array['category'][4]['detail'][207]['name'] = 'Nombre de Onduleurs  (Étape 1  Timeline Construction)'; $array['category'][4]['detail'][207]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-160-onduleurInformation-0-nbr' ;
  5747.         $array['category'][4]['detail'][215]['champs'] = 'Contrat de EPC signé';$array['category'][4]['detail'][215]['name'] = 'Contrat EPC (Etape 3 Timeline Construction)';$array['category'][4]['detail'][215]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-16-contratConstruction-2-fileContratEpcMultiple-1' ;
  5748.         $array['category'][4]['detail'][216]['champs'] = 'Annexes de EPC';$array['category'][4]['detail'][216]['name'] = 'Annexes EPC (fiches techniques…) (Etape 3 Timeline Construction)';$array['category'][4]['detail'][216]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-16-contratConstruction-2-fileAnnexesMultiple-1' ;
  5749.         $array['category'][4]['detail'][217]['champs'] = 'Demande d’agrément de EPC';$array['category'][4]['detail'][217]['name'] = 'Demande d’agrément EPC (Etape 3 Timeline Construction)';$array['category'][4]['detail'][217]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-16-contratConstruction-2-fileDemandeAgrementMultiple-1' ;
  5750.         $array['category'][4]['detail'][218]['champs'] = 'Contrat lot PV signé';$array['category'][4]['detail'][218]['name'] = 'Contrat lot PV signé (Etape 3 Timeline Construction)';$array['category'][4]['detail'][218]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-16-contratConstruction-2-fileContratEpcMultiple-2' ;
  5751.         $array['category'][4]['detail'][219]['champs'] = 'Annexes lot PV';$array['category'][4]['detail'][219]['name'] = 'Annexes lot PV (fiches techniques…) (Etape 3 Timeline Construction)';$array['category'][4]['detail'][219]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-16-contratConstruction-2-fileAnnexesMultiple-2' ;
  5752.         $array['category'][4]['detail'][220]['champs'] = 'Demande d’agrément lot PV';$array['category'][4]['detail'][220]['name'] = 'Demande d’agrément lot PV (Etape 3 Timeline Construction)';$array['category'][4]['detail'][220]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-16-contratConstruction-2-fileDemandeAgrementMultiple-2' ;
  5753.         $array['category'][4]['detail'][221]['champs'] = 'Contrat lot bâtiment signé';$array['category'][4]['detail'][221]['name'] = 'Contrat lot bâtiment signé (Etape 3 Timeline Construction)';$array['category'][4]['detail'][221]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-16-contratConstruction-2-fileContratEpcMultiple-3' ;
  5754.         $array['category'][4]['detail'][222]['champs'] = 'Annexes lot bâtiment ';$array['category'][4]['detail'][222]['name'] = 'Annexes lot bâtiment (fiches techniques…) (Etape 3 Timeline Construction)';$array['category'][4]['detail'][222]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-16-contratConstruction-2-fileAnnexesMultiple-3' ;
  5755.         $array['category'][4]['detail'][223]['champs'] = 'Demande d’agrément lot bâtiment';$array['category'][4]['detail'][223]['name'] = 'Demande d’agrément lot bâtiment (Etape 3 Timeline Construction)';$array['category'][4]['detail'][223]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-16-contratConstruction-2-fileDemandeAgrementMultiple-3' ;
  5756.         $array['category'][5]['num'] = 5;
  5757.         $array['category'][5]['name'] = 'Valorisation';
  5758.         $array['category'][5]['detail'][10031]['champs'] = 'Type de valorisation';$array['category'][5]['detail'][10031]['name'] = 'Type de valorisation';$array['category'][5]['detail'][10031]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-typeValorisation' ;
  5759.         $array['category'][5]['detail'][10032]['champs'] = 'Sous choix de valorisation';$array['category'][5]['detail'][10032]['name'] = 'Sous choix de valorisation';$array['category'][5]['detail'][10032]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-sousChoixValorisation' ;
  5760.         $array['category'][5]['detail'][10033]['champs'] = 'Sous choix de valorisation (champ libre)';$array['category'][5]['detail'][10033]['name'] = 'Sous choix de valorisation (champ libre)';$array['category'][5]['detail'][10033]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-sousChoixValorisationLibre' ;
  5761.         $array['category'][5]['detail'][10034]['champs'] = 'Durée du contrat ';$array['category'][5]['detail'][10034]['name'] = 'Durée du contrat ';$array['category'][5]['detail'][10034]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-dureeContrat' ;
  5762.         $array['category'][5]['detail'][10035]['champs'] = 'Date T0';$array['category'][5]['detail'][10035]['name'] = 'Date T0 (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10035]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-1-dateT0' ;
  5763.         $array['category'][5]['detail'][10036]['champs'] = 'Tarif Fit prévisionnel';$array['category'][5]['detail'][10036]['name'] = 'Tarif Fit prévisionnel (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10036]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-tarifFit' ;
  5764.         $array['category'][5]['detail'][10037]['champs'] = 'Date maximale d\'achèvement des travaux';$array['category'][5]['detail'][10037]['name'] = 'Date maximale d\'achèvement des travaux (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10037]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-1-dateMaximaleAchevement' ;
  5765.         $array['category'][5]['detail'][10038]['champs'] = 'Type d’AO/Période de candidature';$array['category'][5]['detail'][10038]['name'] = 'Type d’AO/Période de candidature (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10038]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-typeAoPeriodeCandidature' ;
  5766.         $array['category'][5]['detail'][10039]['champs'] = 'Date de consignation';$array['category'][5]['detail'][10039]['name'] = 'Date de consignation (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10039]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-1-dateConsignation' ;
  5767.         $array['category'][5]['detail'][10040]['champs'] = 'Date de dépôt AO';$array['category'][5]['detail'][10040]['name'] = 'Date de dépôt AO (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10040]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-1-dateDepotAo' ;
  5768.         $array['category'][5]['detail'][10041]['champs'] = 'Notification Lauréat AO';$array['category'][5]['detail'][10041]['name'] = 'Notification Lauréat AO (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10041]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-1-dateNotificationLaureatAo' ;
  5769.         $array['category'][5]['detail'][10042]['champs'] = 'Agrégateur';$array['category'][5]['detail'][10042]['name'] = 'Agrégateur (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10042]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-agregateur' ;
  5770.         $array['category'][5]['detail'][10043]['champs'] = 'Frais de gestion';$array['category'][5]['detail'][10043]['name'] = 'Frais de gestion (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10043]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-fraisGestion' ;
  5771.         $array['category'][5]['detail'][10044]['champs'] = 'Unité Frais de Gestion';$array['category'][5]['detail'][10044]['name'] = 'Unité Frais de Gestion (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10044]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-uniteFraisGestion' ;
  5772.         $array['category'][5]['detail'][10045]['champs'] = 'Contrepartie';$array['category'][5]['detail'][10045]['name'] = 'Contrepartie (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10045]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-0-contrepartie' ;
  5773.         $array['category'][5]['detail'][10046]['champs'] = 'Garantie bancaire';$array['category'][5]['detail'][10046]['name'] = 'Garantie bancaire (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10046]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-2-fileGarantieBancaireEtap25Multiple' ;
  5774.         $array['category'][5]['detail'][10047]['champs'] = 'Demande de raccordement';$array['category'][5]['detail'][10047]['name'] = 'Demande de raccordement (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10047]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-2-fileDemandeRaccordementEtap25Multiple' ;
  5775.         $array['category'][5]['detail'][10048]['champs'] = 'Mail d’ENEDIS de confirmation';$array['category'][5]['detail'][10048]['name'] = 'Mail d’ENEDIS de confirmation (Etape 2 Timeline Valorisation)';$array['category'][5]['detail'][10048]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-2-fileMailEnedisConfirmationEtap25Multiple' ;
  5776.         $array['category'][5]['detail'][10049]['champs'] = 'Contrat d’achat signé';$array['category'][5]['detail'][10049]['name'] = 'Contrat d’achat signé (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10049]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-fileContratAchatSigneEtap25Multiple-1' ;
  5777.         $array['category'][5]['detail'][10050]['champs'] = 'Attestation de producteur';$array['category'][5]['detail'][10050]['name'] = 'Attestation de producteur (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10050]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-fileAttestionProducteurEtap25Multiple-1' ;
  5778.         $array['category'][5]['detail'][10051]['champs'] = 'Attestation de l’installateur';$array['category'][5]['detail'][10051]['name'] = 'Attestation de l’installateur (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10051]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-fileAttestionInstallateurEtap25Multiple-1' ;
  5779.         $array['category'][5]['detail'][10052]['champs'] = 'AR Contrat d’achat';$array['category'][5]['detail'][10052]['name'] = 'AR Contrat d’achat (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10052]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-fileArContratAchatEtap25Multiple-1' ;
  5780.         $array['category'][5]['detail'][10053]['champs'] = 'Tarif Fit Contrat d’Achat';$array['category'][5]['detail'][10053]['name'] = 'Tarif Fit Contrat d’Achat (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10053]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-tarifContratAchat1-3' ;
  5781.         $array['category'][5]['detail'][10054]['champs'] = 'Périodicité de la facturation';$array['category'][5]['detail'][10054]['name'] = 'Périodicité de la facturation (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10054]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-peridiciteFacturation1-3' ;
  5782.         $array['category'][5]['detail'][10055]['champs'] = 'Numéro de contrat d’achat';$array['category'][5]['detail'][10055]['name'] = 'Numéro de contrat d’achat (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10055]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-numeroContratAchat1-3' ;
  5783.         $array['category'][5]['detail'][10056]['champs'] = 'Type de contrat';$array['category'][5]['detail'][10056]['name'] = 'Type de contrat (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10056]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-typeContrat1-3' ;
  5784.         $array['category'][5]['detail'][10057]['champs'] = 'Agrégateur';$array['category'][5]['detail'][10057]['name'] = 'Agrégateur (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10057]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-agregateurEtap25-3' ;
  5785.         $array['category'][5]['detail'][10058]['champs'] = 'Contrepartie';$array['category'][5]['detail'][10058]['name'] = 'Contrepartie (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10058]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-contrepartieEtap25-3' ;
  5786.         $array['category'][5]['detail'][10059]['champs'] = 'Date de début de contrat d’achat';$array['category'][5]['detail'][10059]['name'] = 'Date de début de contrat d’achat (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10059]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-dateDebutContratAchat1-2' ;
  5787.         $array['category'][5]['detail'][10060]['champs'] = 'Date de fin de contrat d’achat';$array['category'][5]['detail'][10060]['name'] = 'Date de fin de contrat d’achat (Etape 3 Timeline Valorisation)';$array['category'][5]['detail'][10060]['value'] = 'projet-'.ParametrageXlsProject::type_row_etap.'-etap-24-etap24Champs-3-etap26Champs-dateFinContratAchat1-2' ;
  5788.         return $array ;
  5789.     }
  5790.     public function verouillerEtaps(){
  5791.         $etaps = $this->em->getRepository(Etaps::class)->findAll();
  5792.         foreach ($etaps as $etap){
  5793.             $etapClass = 'App\\Entity\\Etap' . $etap->getNum();
  5794.             $etapsEntity = $this->em->getRepository($etapClass)->findBy(['status' => Etaps::STATUS_FERMEE]);
  5795.             if($etapsEntity){
  5796.                 foreach ($etapsEntity as $etapEntity){
  5797.                     if ($etapEntity) {
  5798.                         if ($etapEntity->getStatus() == Etaps::STATUS_FERMEE) {
  5799.                             $etapEntity->setStatus(Etaps::STATUS_EN_COURS);
  5800.                             $this->em->persist($etapEntity);
  5801.                         }
  5802.                     }
  5803.                 }
  5804.             }
  5805.             $this->em->flush();
  5806.         }
  5807.     }
  5808.     public function checkEtapStatusColorByDoc($etapEntity){
  5809.         if($etapEntity && $etapEntity->getEtap() && $etapEntity->getEtap()->getCategory() && $etapEntity->getEtap()->getCategory()->getNum() == 5){
  5810.             $docsUploadeCount = 0;
  5811.             $docsCount = 0;
  5812.             if($etapEntity->getEtap()->getNum() == 24){
  5813.                 $etap25Champs = $etapEntity->getEtap24Champs();
  5814.                 if(count($etap25Champs) > 0){
  5815.                     return "#86D687";
  5816.                 }else{
  5817.                     return "red"; // rouge
  5818.                 }
  5819.             }elseif ($etapEntity->getEtap()->getNum() == 25){
  5820.                 $etap25Champs = $etapEntity->getEtap24Champs();
  5821.                 if(count($etap25Champs) > 0){
  5822.                     foreach ($etap25Champs as $champ){
  5823.                         $typeValorisation = $champ->getTypeValorisation() ? $champ->getTypeValorisation()->getCategory() : null;
  5824.                         if($typeValorisation == TypeValorisation::type_guichet_ouvert){
  5825.                             $fileCount = $this->checkDocNotArchive($champ->getFileDemandeRaccordementEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5826.                             $fileCount = $this->checkDocNotArchive($champ->getFileMailEnedisConfirmationEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5827.                         }elseif ($typeValorisation == TypeValorisation::type_ao_cre){
  5828.                             $fileCount = $this->checkDocNotArchive($champ->getFileGarantieBancaireEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5829.                             $fileCount = $this->checkDocNotArchive($champ->getFileRecepisseDemandeAoMultiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5830.                             $fileCount = $this->checkDocNotArchive($champ->getFileLettreLaureaMultiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5831.                         }elseif ($typeValorisation == TypeValorisation::type_acc || $typeValorisation == TypeValorisation::type_aci || $typeValorisation == TypeValorisation::type_ppa){
  5832.                         }elseif ($typeValorisation == TypeValorisation::type_spot){
  5833.                         }
  5834.                     }
  5835.                 }
  5836.             } elseif ($etapEntity->getEtap()->getNum() == 26){
  5837.                 $etap24Champs = $etapEntity->getEtap24Champs();
  5838.                 if(count($etap24Champs) > 0){
  5839.                     foreach ($etap24Champs as $etap24Champ){
  5840.                         foreach ($etap24Champ->getEtap26Champs() as $champ){
  5841.                             $typeValorisation = $etap24Champ->getTypeValorisation() ? $etap24Champ->getTypeValorisation()->getCategory() : null;
  5842.                             if($typeValorisation == TypeValorisation::type_guichet_ouvert or $typeValorisation == TypeValorisation::type_ao_cre){
  5843.                                 $fileCount = $this->checkDocNotArchive($champ->getFileContratAchatSigneEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5844.                                 $fileCount = $this->checkDocNotArchive($champ->getFileAttestionProducteurEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5845.                                 $fileCount = $this->checkDocNotArchive($champ->getFileAttestionInstallateurEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5846.                                 $fileCount = $this->checkDocNotArchive($champ->getFileArContratAchatEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5847.                             }elseif ($typeValorisation == TypeValorisation::type_acc || $typeValorisation == TypeValorisation::type_aci || $typeValorisation == TypeValorisation::type_ppa || $typeValorisation == TypeValorisation::type_fer){
  5848.                                 $fileCount = $this->checkDocNotArchive($champ->getFileContratAchatSigneEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5849.                             }elseif ($typeValorisation == TypeValorisation::type_spot){
  5850.                                 $fileCount = $this->checkDocNotArchive($champ->getFileContratAchatSigneEtap25Multiple())? 1 : 0 ; $docsUploadeCount = $docsUploadeCount + $fileCount ;$docsCount = $docsCount + 1;
  5851.                             }
  5852.                         }
  5853.                     }
  5854.                 }
  5855.             }
  5856.             if($docsUploadeCount == 0){
  5857.                 return "red"; // rouge
  5858.             }elseif ($docsUploadeCount == $docsCount){
  5859.                 return "#86D687"; // vert
  5860.             }else{
  5861.                 return "#ff9f43"; // orange
  5862.             }
  5863.         }else{
  5864.             if($etapEntity) {
  5865.                 $etapEntityClass = 'App\\Entity\\Etap' . $etapEntity->getEtap()->getNum();
  5866.                 $classMetadata = $this->em->getClassMetadata($etapEntityClass);
  5867.                 $data = $this->getNbrDocUploadByEtap($etapEntity, $classMetadata);
  5868.                 $docsUploadeCount = $data['docsUploadeCount'];
  5869.                 $docsCount = $data['docsCount'];
  5870.                 if ($docsUploadeCount == 0) {
  5871.                     return "red"; // rouge
  5872.                 } elseif ($docsUploadeCount == $docsCount) {
  5873.                     return "#86D687"; // vert
  5874.                 } else {
  5875.                     return "#ff9f43"; // orange
  5876.                 }
  5877.             }else{
  5878.                 return "red"; // rouge 
  5879.             }
  5880.         }
  5881.     }
  5882.     public function checkEtapStatusColorByDocEtap4Construction($project){
  5883.         $docsUploadeCountGlobal = 0;
  5884.         $docsCountGlobal = 0;
  5885.         $etap171 = $this->em->getRepository(Etap171::class)->findOneBy(['project'=>$project->getId()]);
  5886.         $etap172 = $this->em->getRepository(Etap172::class)->findOneBy(['project'=>$project->getId()]);
  5887.         $etap173 = $this->em->getRepository(Etap173::class)->findOneBy(['project'=>$project->getId()]);
  5888.         $etap174 = $this->em->getRepository(Etap174::class)->findOneBy(['project'=>$project->getId()]);
  5889.         $etap175 = $this->em->getRepository(Etap175::class)->findOneBy(['project'=>$project->getId()]);
  5890.         $etapEntityClass = 'App\\Entity\\Etap' . $etap171->getEtap()->getNum();
  5891.         $classMetadata171 = $this->em->getClassMetadata($etapEntityClass);
  5892.         $data = $this->getNbrDocUploadByEtap($etap171,$classMetadata171);
  5893.         $docsUploadeCountGlobal += $data['docsUploadeCount'] ;
  5894.         $docsCountGlobal +=$data['docsCount'] ;
  5895.         $etapEntityClass = 'App\\Entity\\Etap' . $etap172->getEtap()->getNum();
  5896.         $classMetadata172 = $this->em->getClassMetadata($etapEntityClass);
  5897.         $data = $this->getNbrDocUploadByEtap($etap172,$classMetadata172);
  5898.         $docsUploadeCountGlobal += $data['docsUploadeCount'] ;
  5899.         $docsCountGlobal +=$data['docsCount'] ;
  5900.         $etapEntityClass = 'App\\Entity\\Etap' . $etap173->getEtap()->getNum();
  5901.         $classMetadata173 = $this->em->getClassMetadata($etapEntityClass);
  5902.         $data = $this->getNbrDocUploadByEtap($etap173,$classMetadata173);
  5903.         $docsUploadeCountGlobal += $data['docsUploadeCount'] ;
  5904.         $docsCountGlobal +=$data['docsCount'] ;
  5905.         $etapEntityClass = 'App\\Entity\\Etap' . $etap174->getEtap()->getNum();
  5906.         $classMetadata174 = $this->em->getClassMetadata($etapEntityClass);
  5907.         $data = $this->getNbrDocUploadByEtap($etap174,$classMetadata174);
  5908.         $docsUploadeCountGlobal += $data['docsUploadeCount'] ;
  5909.         $docsCountGlobal +=$data['docsCount'] ;
  5910.         $etapEntityClass = 'App\\Entity\\Etap' . $etap175->getEtap()->getNum();
  5911.         $classMetadata175 = $this->em->getClassMetadata($etapEntityClass);
  5912.         $data = $this->getNbrDocUploadByEtap($etap175,$classMetadata175);
  5913.         $docsUploadeCountGlobal += $data['docsUploadeCount'] ;
  5914.         $docsCountGlobal +=$data['docsCount'] ;
  5915.         if($docsUploadeCountGlobal == 0){
  5916.             return "red"; // rouge
  5917.         }elseif ($docsUploadeCountGlobal == $docsCountGlobal){
  5918.             return "#86D687"; // vert
  5919.         }else{
  5920.             return "#ff9f43"; // orange
  5921.         }
  5922.     }
  5923.     public function checkEtapStatusColorByDocEtap3Construction($project){
  5924.         $docsUploadeCount = 0;
  5925.         $docsCount = 0;
  5926.         $etap16 = $this->em->getRepository(Etap16::class)->findOneBy(['project'=>$project->getId()]);
  5927.         $contratConstruction = $etap16->getContratConstruction();
  5928.         foreach ($contratConstruction as $item){
  5929.             $etapEntityClass = 'App\\Entity\\ContratConstruction' ;
  5930.             $classMetadata = $this->em->getClassMetadata($etapEntityClass);
  5931.             $data = $this->getNbrDocUploadByEtapDetail($item,$classMetadata);
  5932.             $docsUploadeCount += $data['docsUploadeCount'] ;
  5933.             $docsCount +=$data['docsCount'] ;
  5934.         }
  5935.         if($docsUploadeCount == 0){
  5936.             return "red"; // rouge
  5937.         }elseif ($docsUploadeCount == $docsCount){
  5938.             return "#86D687"; // vert
  5939.         }else{
  5940.             return "#ff9f43"; // orange
  5941.         }
  5942.     }
  5943.     public function copyFileDoeToEtap201(){
  5944.         $date = new \DateTime('2023-11-15');
  5945.         $does = $this->em->getRepository(Etap14::class)->findDoeEtap14ByDate($date);
  5946.         foreach ($does as $doe){
  5947.             $etap201 = $this->em->getRepository(Etap201::class)->findOneBy(['project'=>$doe['id']]);
  5948.             if($etap201){
  5949.                 $doeDoc = $this->em->getRepository(DocUpload::class)->find($doe['idDoc']);
  5950.                 $docUpload = new DocUpload();
  5951.                 $docUpload->setName($doeDoc->getName());
  5952.                 $docUpload->setCreatedAt($doeDoc->getCreatedAt());
  5953.                 $docUpload->setUserCreated($doeDoc->getUserCreated());
  5954.                 $docUpload->setTitreDoc($doeDoc->getTitreDoc());
  5955.                 $fileNameCopy = $doe['id'].'-'.time().$doeDoc->getPath();
  5956.                 $file = $this->params->get('uploads_directory') . '/' . $doeDoc->getPath();
  5957.                 $fileCopy = $this->params->get('uploads_directory'). '/' . $fileNameCopy;
  5958.                 copy($file , $fileCopy);
  5959.                 $docUpload->setPath($fileNameCopy);
  5960.                 $this->em->persist($docUpload);
  5961.                 $this->em->flush();
  5962.                 $etap201->addFileDoeEtap201Multiple($docUpload);
  5963.                 $this->em->persist($etap201);
  5964.                 $this->em->flush();
  5965.                 $this->getNomenclature($etap201,$docUpload,'DOE');
  5966.             }
  5967.         }
  5968.     }
  5969.     public function getProjectsActive(){
  5970.         $projects = $this->em->getRepository(Project::class)->findAllProjectActive();
  5971.         return $projects;
  5972.     }
  5973.     public function updateStatusUrbanisme($project){
  5974.         $str = '';
  5975.         $etap0 = $this->em->getRepository(Etap0::class)->findOneBy(['project'=>$project->getId()]);
  5976.         $etap1 = $this->em->getRepository(Etap1::class)->findOneBy(['project'=>$project->getId()]);
  5977.         $etap2 = $this->em->getRepository(Etap2::class)->findOneBy(['project'=>$project->getId()]);
  5978.         $etap3 = $this->em->getRepository(Etap3::class)->findOneBy(['project'=>$project->getId()]);
  5979.         $etap4 = $this->em->getRepository(Etap4::class)->findOneBy(['project'=>$project->getId()]);
  5980.         $etap16 = $this->em->getRepository(Etap16::class)->findOneBy(['project'=>$project->getId()]);
  5981.         $etap174 = $this->em->getRepository(Etap174::class)->findOneBy(['project'=>$project->getId()]);
  5982.         $etap171 = $this->em->getRepository(Etap171::class)->findOneBy(['project'=>$project->getId()]);
  5983.         $date1PassageHuissierModif2mois = null;
  5984.         if($etap2){
  5985.             $date1PassageHuissier = $etap2->getDate1PassageHuissier();
  5986.             if($date1PassageHuissier){
  5987.                 $date1PassageHuissierModif =  new \DateTime($date1PassageHuissier->format('d-m-Y'));
  5988.                 $date1PassageHuissierModif2mois =  $date1PassageHuissierModif->modify('+2 months');
  5989.             }
  5990.         }
  5991.         if($etap4 && $this->checkDocNotArchive($etap4->getFileDaactMultiple())) {
  5992.             $str = 'DAACT OK';
  5993.         }elseif($etap174 && ($etap174->getDateFinPosePv() && ($etap174->getDateFinPosePv() <= new \DateTime('now')))){
  5994.             if($etap4 && $etap4->getDateDaact()) {
  5995.                 $str = 'DAACT signée Ã  recup. ('.$etap4->getDateDaact()->format('d/m').')';
  5996.             }else{
  5997.                 $str = 'DAACT Ã  déposer';
  5998.             }
  5999.         }elseif(($project->getTypologieProject() && ($project->getTypologieProject()->getId() == 2)) &&  (($etap16 && count($etap16->getContratConstruction()) > 0 && $this->checkDocNotArchive($etap16->getContratConstruction()[0]->getFileContratEpcMultiple())) || ($etap171 && $etap171->getDateRealisationPlateforme()))  ){
  6000.             if(($etap171 && $this->checkDocNotArchive($etap171->getFileDocEtap171Multiple())) || ($etap3 && $this->checkDocNotArchive($etap3->getFileDocDrocMultiple()))){
  6001.                 $str = 'DOC OK';
  6002.             }elseif ($etap4 && $etap4->getDateDaact()){
  6003.                 $str = 'DAACT signée Ã  recup. ('.$etap4->getDateDaact()->format('d/m').')';
  6004.             }else{
  6005.                 $str = 'DAACT Ã  déposer';
  6006.             }
  6007.         }elseif ($etap2 && $this->checkDocNotArchive($etap2->getFileCertificatNonRecoursMultiple()) && $this->checkDocNotArchive($etap2->getFileCertificatNonRetraitMultiple())){
  6008.             $str = 'ANR OK';
  6009.         }elseif ($etap2 && $this->checkDocNotArchive($etap2->getFilePVPassageHuissierMultiple())){
  6010.             if ($etap2 && $this->checkDocNotArchive($etap2->getFileCertificatNonRecoursMultiple())){
  6011.                 $str = 'Certif. non-retrait Ã  récup.';
  6012.             }else{
  6013.                 if ($etap2 && $this->checkDocNotArchive($etap2->getFileCertificatNonRetraitMultiple())){
  6014.                     $str = 'Certif. non-recours Ã  récup.';
  6015.                 }else{
  6016.                     $str = 'ANR Ã  demander';
  6017.                 }
  6018.             }
  6019.         }elseif ($etap2 && ($date1PassageHuissierModif2mois && $date1PassageHuissierModif2mois < new \DateTime('now'))){
  6020.             $str = 'PVA Ã  récup. ('.$date1PassageHuissierModif2mois->format('d/m').')';
  6021.         }elseif ($etap2 && $etap2->getDate1PassageHuissier() ){
  6022.             $str = 'Att.PVA ('.$date1PassageHuissierModif2mois->format('d/m').')';
  6023.         }elseif ($etap1 && $this->checkDocNotArchive($etap1->getFileArretePcDpMultiple()) ){
  6024.             $str = 'Huissier NOK';
  6025.         }elseif ($project->getTypologieProject() && ($project->getTypologieProject()->getId() == 1)){
  6026.             if($etap1 && $etap1->getDateDepotComplement()){
  6027.                 $dateDepotComplementModifModif =  new \DateTime($etap1->getDateDepotComplement()->format('d-m-Y'));
  6028.                 $delaiInstruction = $etap1->getDelaiInstruction()? (int)$etap1->getDelaiInstruction() : 3 ;
  6029.                 $dateDepotComplementModifPlus =  $dateDepotComplementModifModif->modify('+'.$delaiInstruction.' months');
  6030.                 $str = 'DP comp. en instruction -> '.$dateDepotComplementModifPlus->format('d/m');
  6031.             }elseif($etap1 && $etap1->getDateDemandeComplement()){
  6032.                 $str = 'Dem. Pièces comp. ('.$etap1->getDateDemandeComplement()->format('d/m').')';
  6033.             }elseif($etap1 && $etap1->getDateDepotPc() && $this->checkDocNotArchive($etap1->getFileRecepisseDepotPcMultiple())){
  6034. //                $dateDepotModif =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6035. //                $dateDepotModifPlus =  $dateDepotModif->modify('+42 days');
  6036. //                if($dateDepotModifPlus < new \DateTime('now')){
  6037. //                    $dateDepotModif2 =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6038. //                    $delaiInstruction = $etap1->getDelaiInstruction()? (int)$etap1->getDelaiInstruction() : 3 ;
  6039. //                    $dateDepotModif2Plus =  $dateDepotModif2->modify('+'.$delaiInstruction.' months');
  6040. //                    $str = 'DP en instruction -> '.$dateDepotModif2Plus->format('d/m');
  6041. //                }else{
  6042. //                    $dateDepotModif2 =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6043. //                    $dateDepotModif2Plus =  $dateDepotModif2->modify('+1 months');
  6044. //                    $str = 'DP déposée - check comp. -> '.$dateDepotModif2Plus->format('d/m');
  6045. //                }
  6046.                 if($etap1->getIsNotDateDemandeComplement()){
  6047.                     $dateDepotModif2 =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6048.                     $delaiInstruction = $etap1->getDelaiInstruction()? (int)$etap1->getDelaiInstruction() : 3 ;
  6049.                     $dateDepotModif2Plus =  $dateDepotModif2->modify('+'.$delaiInstruction.' months');
  6050.                     $str = 'DP en instruction -> '.$dateDepotModif2Plus->format('d/m');
  6051.                 }else{
  6052.                     $dateDepotModif2 =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6053.                     $dateDepotModif2Plus =  $dateDepotModif2->modify('+1 months');
  6054.                     $str = 'DP déposée - check comp. -> '.$dateDepotModif2Plus->format('d/m');
  6055.                 }
  6056.             }elseif($etap1 && $etap1->getDateDepotPc()){
  6057.                 $str = 'DP déposée - récup. récépissé';
  6058.             }elseif($etap1 && $this->checkDocNotArchive($etap1->getFileDossierPcDpMultiple())){
  6059.                 $str = 'DP Ã  déposer';
  6060.             }else{
  6061.                 $str = 'DP Ã  faire';
  6062.             }
  6063.         }else{
  6064.             if($project->getTypologieProject() && ($project->getTypologieProject()->getId() == 2)){
  6065.                 if($etap1 && count($etap1->getEtap1Pcm()) > 0){
  6066.                     $pcm = $etap1->getEtap1Pcm()[0];
  6067.                     if($pcm && $pcm->getDateDepotComplement()){
  6068.                         $dateDepotComplementPcmModif =  new \DateTime($pcm->getDateDepotComplement()->format('d-m-Y'));
  6069.                         $delaiInstruction = $pcm->getDelaiInstruction()? (int)$pcm->getDelaiInstruction() : 3 ;
  6070.                         $dateDepotComplementPcmModifPlus =  $dateDepotComplementPcmModif->modify('+'.$delaiInstruction.' months');
  6071.                         $str = 'PCM comp. en instruction -> '.$dateDepotComplementPcmModifPlus->format('d/m');
  6072.                     }elseif ($pcm && $pcm->getDateDemandeComplement()){
  6073.                         $str = 'Dem. Pièces comp. PCM ('.$pcm->getDateDemandeComplement()->format('d/m').')';
  6074.                     }elseif($pcm && $pcm->getDateDepotPCM() && $this->checkDocNotArchive($pcm->getFileRecepisseDepotPcmMultiple())){
  6075. //                        $dateDepotPCMModif =  new \DateTime($pcm->getDateDepotPCM()->format('d-m-Y'));
  6076. //                        $dateDepotPCMModifPlus =  $dateDepotPCMModif->modify('+42 days');
  6077. //                        if($dateDepotPCMModifPlus < new \DateTime('now')){
  6078. //                            $dateDepotPCMModif2 =  new \DateTime($pcm->getDateDepotPCM()->format('d-m-Y'));
  6079. //                            $delaiInstruction = $pcm->getDelaiInstruction()? (int)$pcm->getDelaiInstruction() : 3 ;
  6080. //                            $dateDepotPCMModif2Plus =  $dateDepotPCMModif2->modify('+'.$delaiInstruction.' months');
  6081. //                            $str = 'PCM en instruction -> '.$dateDepotPCMModif2Plus->format('d/m');
  6082. //                        }else{
  6083. //                            $dateDepotPCMModif2 =  new \DateTime($pcm->getDateDepotPCM()->format('d-m-Y'));
  6084. //                            $dateDepotPCMModif2Plus =  $dateDepotPCMModif2->modify('+1 months');
  6085. //                            $str = 'PCM déposée - check comp. -> '.$dateDepotPCMModif2Plus->format('d/m');
  6086. //                        }
  6087.                         if($pcm->getIsNotDateDemandeComplementPcm()){
  6088.                             $dateDepotPCMModif2 =  new \DateTime($pcm->getDateDepotPCM()->format('d-m-Y'));
  6089.                             $delaiInstruction = $pcm->getDelaiInstruction()? (int)$pcm->getDelaiInstruction() : 3 ;
  6090.                             $dateDepotPCMModif2Plus =  $dateDepotPCMModif2->modify('+'.$delaiInstruction.' months');
  6091.                             $str = 'PCM en instruction -> '.$dateDepotPCMModif2Plus->format('d/m');
  6092.                         }else{
  6093.                             $dateDepotPCMModif2 =  new \DateTime($pcm->getDateDepotPCM()->format('d-m-Y'));
  6094.                             $dateDepotPCMModif2Plus =  $dateDepotPCMModif2->modify('+1 months');
  6095.                             $str = 'PCM déposée - check comp. -> '.$dateDepotPCMModif2Plus->format('d/m');
  6096.                         }
  6097.                     }elseif($pcm && $pcm->getDateDepotPCM()){
  6098.                         $str = 'PCM déposée - récup. récépissé';
  6099.                     }elseif($pcm && $this->checkDocNotArchive($pcm->getFileDossierPcmpMultiple())){
  6100.                         $str = 'PCM Ã  déposer';
  6101.                     }else{
  6102.                         $str = 'PCM Ã  faire';
  6103.                     }
  6104.                 }else{
  6105.                     if($etap1 && $etap1->getDateDepotComplement()){
  6106.                         $dateDepotComplementModifModif =  new \DateTime($etap1->getDateDepotComplement()->format('d-m-Y'));
  6107.                         $delaiInstruction = $etap1->getDelaiInstruction()? (int)$etap1->getDelaiInstruction() : 3 ;
  6108.                         $dateDepotComplementModifPlus =  $dateDepotComplementModifModif->modify('+'.$delaiInstruction.' months');
  6109.                         $str = 'PC comp. en instruction -> '.$dateDepotComplementModifPlus->format('d/m');
  6110.                     }elseif($etap1 && $etap1->getDateDemandeComplement()){
  6111.                         $str = 'Dem. Pièces comp. ('.$etap1->getDateDemandeComplement()->format('d/m').')';
  6112.                     }elseif($etap1 && $etap1->getDateDepotPc() && $this->checkDocNotArchive($etap1->getFileRecepisseDepotPcMultiple())){
  6113. //                        $dateDepotModif =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6114. //                        $dateDepotModifPlus =  $dateDepotModif->modify('+42 days');
  6115. //                        if($dateDepotModifPlus < new \DateTime('now')){
  6116. //                            $dateDepotModif2 =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6117. //                            $delaiInstruction = $etap1->getDelaiInstruction()? (int)$etap1->getDelaiInstruction() : 3 ;
  6118. //                            $dateDepotModif2Plus =  $dateDepotModif2->modify('+'.$delaiInstruction.' months');
  6119. //                            $str = 'PC en instruction -> '.$dateDepotModif2Plus->format('d/m');
  6120. //                        }else{
  6121. //                            $dateDepotModif2 =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6122. //                            $dateDepotModif2Plus =  $dateDepotModif2->modify('+1 months');
  6123. //                            $str = 'PC déposé - check comp. -> '.$dateDepotModif2Plus->format('d/m');
  6124. //                        }
  6125.                         if($etap1->getIsNotDateDemandeComplement()){
  6126.                             $dateDepotModif2 =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6127.                             $delaiInstruction = $etap1->getDelaiInstruction()? (int)$etap1->getDelaiInstruction() : 3 ;
  6128.                             $dateDepotModif2Plus =  $dateDepotModif2->modify('+'.$delaiInstruction.' months');
  6129.                             $str = 'PC en instruction -> '.$dateDepotModif2Plus->format('d/m');
  6130.                         }else{
  6131.                             $dateDepotModif2 =  new \DateTime($etap1->getDateDepotPc()->format('d-m-Y'));
  6132.                             $dateDepotModif2Plus =  $dateDepotModif2->modify('+1 months');
  6133.                             $str = 'PC déposé - check comp. -> '.$dateDepotModif2Plus->format('d/m');
  6134.                         }
  6135.                     }elseif($etap1 && $etap1->getDateDepotPc()){
  6136.                         $str = 'PC déposé - récup. récépissé';
  6137.                     }elseif($etap1 && $this->checkDocNotArchive($etap1->getFileDossierPcDpMultiple())){
  6138.                         $str = 'PC Ã  déposer';
  6139.                     }else{
  6140.                         $str = 'PC Ã  faire';
  6141.                     }
  6142.                 }
  6143.             }else{
  6144.                 $str = '';
  6145.             }
  6146.         }
  6147.         $statusOld = $this->em->getRepository(StatusUrbanisme::class)->findOneBy(['project'=>$project->getId()]);
  6148.         if($statusOld){
  6149.             if($statusOld && $statusOld->getStatusStr() == $str){
  6150.             }else{
  6151.                 $statusOld->setStatusStr($str);
  6152.                 $statusOld->setUpdatedAt(new \DateTime());
  6153.                 $statusOld->setProject($project);
  6154.                 $this->em->persist($statusOld);
  6155.                 $this->em->flush();
  6156.             }
  6157.             return $statusOld;
  6158.         }else{
  6159.             $status = new StatusUrbanisme();
  6160.             $status->setStatusStr($str);
  6161.             $status->setUpdatedAt(new \DateTime());
  6162.             $status->setProject($project);
  6163.             $this->em->persist($status);
  6164.             $this->em->flush();
  6165.             return $status;
  6166.         }
  6167.     }
  6168.     public function updateStatusFoncier($project){
  6169.         $str1 = '';
  6170.         $str2 = '';
  6171.         $str3 = '';
  6172.         $etap1 = $this->em->getRepository(Etap1::class)->findOneBy(['project'=>$project->getId()]);
  6173.         $etap6 = $this->em->getRepository(Etap6::class)->findOneBy(['project'=>$project->getId()]);
  6174.         $etap7 = $this->em->getRepository(Etap7::class)->findOneBy(['project'=>$project->getId()]);
  6175.         $etap601 = $this->em->getRepository(Etap601::class)->findOneBy(['project'=>$project->getId()]);
  6176.         $etap602 = $this->em->getRepository(Etap602::class)->findOneBy(['project'=>$project->getId()]);
  6177.         // status 1
  6178.         if($etap6 && $etap6->getSituationFonciere() == 'NOK' ){
  6179.             $str1 = 'Foncier NOK';
  6180.         }elseif($etap6 && $etap6->getStatutMainlevee() && $etap6->getStatutMainlevee() != 'n.a.' && $etap6->getStatutMainlevee() != 'ML OK'){
  6181.             $str1 = $etap6->getStatutMainlevee();
  6182.         }else{
  6183.             $str1 = '';
  6184.         }
  6185.         // status 2
  6186.         if($etap7 && $this->checkDocNotArchive($etap7->getFileBailSigneMultiple())) {
  6187.             $str2 = '';
  6188.             $str1 = '';
  6189.         }else{
  6190.             if($etap601 && $this->checkDocNotArchive($etap601->getFileEtatDecriptifMultiple())) {
  6191.                 if($project->getTypologieProject() && $project->getTypologieProject()->getId() == 1){
  6192.                     $str2 = 'EDDV OK';
  6193.                 }elseif($project->getTypologieProject() && $project->getTypologieProject()->getId() == 2){
  6194.                     $str2 = 'DA OK';
  6195.                 }else{
  6196.                     $str2 = '';
  6197.                 }
  6198.             }elseif ($etap601 && $etap601->getDateIntervention()){
  6199.                 if($project->getTypologieProject() && $project->getTypologieProject()->getId() == 1){
  6200.                     $str2 = 'Att. EDDV (interv. '.$etap601->getDateIntervention()->format('d/m').' )';
  6201.                 }elseif($project->getTypologieProject() && $project->getTypologieProject()->getId() == 2){
  6202.                     $str2 = 'Att. DA (interv. '.$etap601->getDateIntervention()->format('d/m').' )';
  6203.                 }else{
  6204.                     $str2 = '';
  6205.                 }
  6206.             }elseif ($etap601 && $etap601->getDateLancement()){
  6207.                 if($project->getTypologieProject() && $project->getTypologieProject()->getId() == 1){
  6208.                     $str2 = 'Att. EDDV ('.$etap601->getDateLancement()->format('d/m').')';
  6209.                 }elseif($project->getTypologieProject() && $project->getTypologieProject()->getId() == 2){
  6210.                     $str2 = 'Att. DA ('.$etap601->getDateLancement()->format('d/m').')';
  6211.                 }else{
  6212.                     $str2 = '';
  6213.                 }
  6214.             }elseif ($etap601 && $etap601->getFournisseur()){
  6215.                 if($project->getTypologieProject() && $project->getTypologieProject()->getId() == 1){
  6216.                     $str2 = 'Att. EDDV';
  6217.                 }elseif($project->getTypologieProject() && $project->getTypologieProject()->getId() == 2){
  6218.                     $str2 = 'Att. DA';
  6219.                 }else{
  6220.                     $str2 = '';
  6221.                 }
  6222.             }else{
  6223.                 if(($etap1 && $etap1->getDateArretePcDp() ) || ($etap1 && $etap1->getDateArretePcDpMixte())){
  6224.                     $str2 = 'Géom. NOK';
  6225.                 }else{
  6226.                     $str2 = '';
  6227.                 }
  6228.             }
  6229.         }
  6230.         // status 3
  6231.         if($etap7 && $this->checkDocNotArchive($etap7->getFileBailSigneMultiple())) {
  6232.             $str3 = 'Bail signé';
  6233.         }elseif ($etap602 && $etap602->getDateSignatureProcuration()){
  6234.             $str3 = 'Procs signées ('.$etap602->getDateSignatureProcuration()->format('d/m').')';
  6235.         }elseif ($etap602 && $etap602->getDateEnvoiPocuration()){
  6236.             $str3 = 'Procs envoyées ('.$etap602->getDateEnvoiPocuration()->format('d/m').')';
  6237.         }elseif ($etap602 && $etap602->getFournisseur()){
  6238.             $str3 = 'Bail EC';
  6239.         }else{
  6240.             $str3 = 'Notaire NOK';
  6241.         }
  6242.         $statusOld = $this->em->getRepository(StatusFoncier::class)->findOneBy(['project'=>$project->getId()]);
  6243.         $str = '';
  6244.         if($str1 == ''){
  6245.             $str = $str1." ";
  6246.         }else{
  6247.             $str = $str1." | ";
  6248.         }
  6249.         if($str2 == ''){
  6250.             $str = $str.$str2." ".$str3;
  6251.         }else{
  6252.             $str =  $str.$str2." | ".$str3;
  6253.         }
  6254.         if($statusOld){
  6255.             if($statusOld && $statusOld->getStatusStr() == $str){
  6256.             }else {
  6257.                 $statusOld->setStatusStr($str);
  6258.                 $statusOld->setStatusStr1($str1);
  6259.                 $statusOld->setStatusStr2($str2);
  6260.                 $statusOld->setStatusStr3($str3);
  6261.                 $statusOld->setUpdatedAt(new \DateTime());
  6262.                 $statusOld->setProject($project);
  6263.                 $this->em->persist($statusOld);
  6264.                 $this->em->flush();
  6265.             }
  6266.             return $statusOld;
  6267.         }else{
  6268.             $status = new StatusFoncier();
  6269.             $status->setStatusStr($str);
  6270.             $status->setStatusStr1($str1);
  6271.             $status->setStatusStr2($str2);
  6272.             $status->setStatusStr3($str3);
  6273.             $status->setUpdatedAt(new \DateTime());
  6274.             $status->setProject($project);
  6275.             $this->em->persist($status);
  6276.             $this->em->flush();
  6277.             return $status;
  6278.         }
  6279.     }
  6280.     public function updateStatusRaccordement($project){
  6281.         $statusOld = $this->em->getRepository(StatusRaccordement::class)->findOneBy(['project'=>$project->getId()]);
  6282.         $str = '';
  6283.         if($statusOld){
  6284.             if($statusOld && $statusOld->getStatusStr() == $str){
  6285.             }else {
  6286.                 $statusOld->setStatusStr($str);
  6287.                 $statusOld->setUpdatedAt(new \DateTime());
  6288.                 $statusOld->setProject($project);
  6289.                 $this->em->persist($statusOld);
  6290.                 $this->em->flush();
  6291.             }
  6292.             return $statusOld;
  6293.         }else{
  6294.             $status = new StatusRaccordement();
  6295.             $status->setStatusStr($str);
  6296.             $status->setUpdatedAt(new \DateTime());
  6297.             $status->setProject($project);
  6298.             $this->em->persist($status);
  6299.             $this->em->flush();
  6300.             return $status;
  6301.         }
  6302.     }
  6303.     public function updateStatusConstruction($project){
  6304.         $statusOld = $this->em->getRepository(StatusConsruction::class)->findOneBy(['project'=>$project->getId()]);
  6305.         $str = '';
  6306.         if($statusOld){
  6307.             if($statusOld && $statusOld->getStatusStr() == $str){
  6308.             }else {
  6309.                 $statusOld->setStatusStr($str);
  6310.                 $statusOld->setUpdatedAt(new \DateTime());
  6311.                 $statusOld->setProject($project);
  6312.                 $this->em->persist($statusOld);
  6313.                 $this->em->flush();
  6314.             }
  6315.             return $statusOld;
  6316.         }else{
  6317.             $status = new StatusConsruction();
  6318.             $status->setStatusStr($str);
  6319.             $status->setUpdatedAt(new \DateTime());
  6320.             $status->setProject($project);
  6321.             $this->em->persist($status);
  6322.             $this->em->flush();
  6323.             return $status;
  6324.         }
  6325.     }
  6326.     public function removeUpdateManuelStatus($status){
  6327.         if($status){
  6328.             $status->setIsModif(false);
  6329.             $this->em->persist($status);
  6330.             $this->em->flush();
  6331.         }
  6332.     }
  6333.     public function getStatusDetailStr($project,$cat){
  6334.         if($cat == 1){
  6335.             $status = $this->em->getRepository(StatusUrbanisme::class)->findOneBy(['project'=>$project->getId()]);
  6336.         }elseif ($cat == 2){
  6337.             $status = $this->em->getRepository(StatusFoncier::class)->findOneBy(['project'=>$project->getId()]);
  6338.         }elseif ($cat == 3){
  6339.             $status = $this->em->getRepository(StatusRaccordement::class)->findOneBy(['project'=>$project->getId()]);
  6340.         }elseif ($cat == 4){
  6341.             $status = $this->em->getRepository(StatusConsruction::class)->findOneBy(['project'=>$project->getId()]);
  6342.         }else{
  6343.             $status = null;
  6344.         }
  6345.         if($status){
  6346.             if($status->getIsModif()){
  6347.                 return $status->getStatusStrModif();
  6348.             }else{
  6349.                 return $status->getStatusStr();
  6350.             }
  6351.         }else{
  6352.             return '';
  6353.         }
  6354.     }
  6355.     public function updateStatusDetailStrManuel($project,$cat,$str){
  6356.         if($cat == 1){
  6357.             $status = $this->em->getRepository(StatusUrbanisme::class)->findOneBy(['project'=>$project->getId()]);
  6358.         }elseif ($cat == 2){
  6359.             $status = $this->em->getRepository(StatusFoncier::class)->findOneBy(['project'=>$project->getId()]);
  6360.         }elseif ($cat == 3){
  6361.             $status = $this->em->getRepository(StatusRaccordement::class)->findOneBy(['project'=>$project->getId()]);
  6362.         }elseif ($cat == 4){
  6363.             $status = $this->em->getRepository(StatusConsruction::class)->findOneBy(['project'=>$project->getId()]);
  6364.         }else{
  6365.             $status = null;
  6366.         }
  6367.         if($status){
  6368.             $status->setStatusStrModif($str);
  6369.             $status->setIsModif(true);
  6370.             $this->em->persist($status);
  6371.             $this->em->flush();
  6372.         }else{
  6373.             if($cat == 3 || $cat == 4){
  6374.                 if($cat == 3){
  6375.                     $status = new StatusRaccordement();
  6376.                 }elseif ($cat == 4){
  6377.                     $status = new StatusConsruction();
  6378.                 }
  6379.                 $status->setProject($project);
  6380.                 $status->setStatusStrModif($str);
  6381.                 $status->setIsModif(true);
  6382.                 $this->em->persist($status);
  6383.                 $this->em->flush();
  6384.             }
  6385.         }
  6386.     }
  6387.     public function updateCodeProject(){
  6388.         $fileName = 'Codes projets.xlsx';
  6389.         $filePath =  $this->params->get('images_directory'). '/' . $fileName;
  6390.         if (!file_exists($filePath)) {
  6391.             throw new \Exception("Le fichier n'existe pas : " . $filePath);
  6392.         }
  6393.         $spreadsheet = IOFactory::load($filePath);
  6394.         $worksheet = $spreadsheet->getActiveSheet();
  6395.         $data = [];
  6396.         $i = 1;
  6397.         foreach ($worksheet->getRowIterator() as $row) {
  6398.             $rowData = [];
  6399.             if($i > 2){
  6400.                 foreach ($row->getCellIterator() as $cell) {
  6401.                     if($cell->getColumn() == 'A'){
  6402.                         $rowData[] = $cell->getValue();
  6403.                     }
  6404.                     if($cell->getColumn() == 'E'){
  6405.                         $rowData[] = $cell->getOldCalculatedValue();
  6406.                     }
  6407.                     if($cell->getColumn() == 'D'){
  6408.                         $rowData[] = $cell->getValue();
  6409.                     }
  6410.                 }
  6411.                 if($rowData && isset($rowData[0]) && isset($rowData[1])){
  6412.                     $data[$rowData[0]]['num'] = $rowData[1];
  6413.                     $data[$rowData[0]]['code'] = $rowData[2];
  6414.                 }
  6415.             }
  6416.             $i++;
  6417.         }
  6418.         $projects = $this->em->getRepository(Project::class)->findAll();
  6419.         foreach ($projects as $project){
  6420.             $name = $project->getName();
  6421.             if(isset($data[$name])){
  6422.                 $project->setIsImportCode(true);
  6423.                 $project->setCodeProject($data[$name]['code']);
  6424.                 $project->setCompteurErpiNbr((int)$data[$name]['num']);
  6425.                 $project->setCompteurErpiAnnee($project->getCreatedAt()->format('y'));
  6426.                 $this->em->persist($project);
  6427.             }
  6428.         }
  6429.         $this->em->flush();
  6430.         $worksheet2 = $spreadsheet->setActiveSheetIndex(1);
  6431.         $data = [];
  6432.         $i = 1;
  6433.         foreach ($worksheet2->getRowIterator() as $row) {
  6434.             $rowData = [];
  6435.             if($i > 5){
  6436.                 foreach ($row->getCellIterator() as $cell) {
  6437.                     if($cell->getColumn() == 'B'){
  6438.                         $rowData[] = $cell->getValue();
  6439.                     }
  6440.                     if($cell->getColumn() == 'C'){
  6441.                         $rowData[] = $cell->getValue();
  6442.                     }
  6443.                 }
  6444.                 if($rowData && isset($rowData[0]) && isset($rowData[1])){
  6445.                     $data[$rowData[0]]['name'] = $rowData[0];
  6446.                     $data[$rowData[0]]['code'] = $rowData[1];
  6447.                 }
  6448.             }
  6449.             $i++;
  6450.         }
  6451.         $devs = $this->em->getRepository(User::class)->getUserByRole('ROLE_DEV');
  6452.         foreach ($devs as $dev){
  6453.             $name = $dev->getFirstName().' '.$dev->getLastname();
  6454.             if(isset($data[$name])){
  6455.                 $dev->setCodeDev($data[$name]['code']);
  6456.                 $this->em->persist($dev);
  6457.             }
  6458.         }
  6459.         $this->em->flush();
  6460.         $this->setAllCodeProject();
  6461.     }
  6462.     public function setCodeProject($project){
  6463.         if(!$project->getIsImportCode()){
  6464.             if($project && $project->getDeveloppeur() && $project->getChoixDev() != Project::dev_intern){
  6465.                 if($project->getDeveloppeur()->getCodeDev()){
  6466.                     $devCode = $project->getDeveloppeur()->getCodeDev();
  6467.                 }else{
  6468.                     $devCode = strtoupper(substr($project->getDeveloppeur()->getFirstname(), 0, 3));
  6469.                 }
  6470.                 $annee = $project->getCreatedAt()->format('y');
  6471.                 if(!$project->getCodeProject()){
  6472.                     $compteurErpi= $this->em->getRepository(Project::class)->findCodeProjectByYearAndDev($annee,$project->getDeveloppeur()->getId());
  6473.                     $compteurNbr = 1;
  6474.                     if($compteurErpi){
  6475.                         $compteurNbr = $compteurErpi->getCompteurErpiNbr() ? $compteurErpi->getCompteurErpiNbr() + 1 : 1;
  6476.                     }
  6477.                     $codeGenerate = $annee.''.$devCode.''.$this->generateCodeCompteurErpi($compteurNbr);
  6478.                     $project->setCodeProject($codeGenerate);
  6479.                     $project->setCompteurErpiNbr($compteurNbr);
  6480.                     $project->setCompteurErpiAnnee($annee);
  6481.                     $this->em->persist($project);
  6482.                     $this->em->flush();
  6483.                 }else{
  6484.                     $pos =  strpos($project->getCodeProject(),$devCode) ;
  6485.                     if ($pos === false) {
  6486.                         $codeGenerate = $annee.''.$devCode.''.$this->generateCodeCompteurErpi($project->getCompteurErpiNbr());
  6487.                         $project->setCodeProject($codeGenerate);
  6488.                         $this->em->persist($project);
  6489.                         $this->em->flush();
  6490.                     }
  6491.                 }
  6492.             }
  6493.         }
  6494.     }
  6495.     function generateCodeCompteurErpi($number) {
  6496.         $numberFormatted = str_pad($number, 4, '0', STR_PAD_LEFT);
  6497.         return $numberFormatted;
  6498.     }
  6499.     public function setAllCodeProject(){
  6500.         $projects = $this->em->getRepository(Project::class)->findAll();
  6501.         foreach ($projects as $project){
  6502.             $this->setCodeProject($project);
  6503.         }
  6504.     }
  6505.     public function addAlertEtap1AndEtap2($project) : void
  6506.     {
  6507.         $dateNow = new \DateTime();
  6508.         $dateCreationProject = $project->getCreatedAt();
  6509.         if($dateCreationProject){
  6510.             $dateCreationProject->modify('+6 month');
  6511.         }
  6512.         $alert = false;
  6513.         if( $dateNow >= $dateCreationProject ) {
  6514.             $etap1 = $this->em->getRepository(Etap1::class)->findOneBy(['project' => $project->getId()]);
  6515.             $etap2 = $this->em->getRepository(Etap2::class)->findOneBy(['project' => $project->getId()]);
  6516.             if ($etap1 && $etap2) {
  6517.                 $color = $this->checkEtapStatusColorByDoc($etap1);
  6518.                 $color2 = $this->checkEtapStatusColorByDoc($etap2);
  6519.                 if (($color == '#86D687' or $color == '#ff9f43') and ($color2 == '#86D687' or $color2 == '#ff9f43')) {
  6520.                     $alert =  false;
  6521.                 } else {
  6522.                     $alert =  true;
  6523.                 }
  6524.             }
  6525.         }
  6526.         $alertEntity = $this->em->getRepository(Alert::class)->findOneBy(['project'=>$project->getId(),'typeAlert'=>Alert::ALERT_Etap1And2]);
  6527.         if($alertEntity){
  6528.             if($alert){
  6529.                 $alertEntity->setIsArchived(false);
  6530.             }else{
  6531.                 $alertEntity->setIsArchived(true);
  6532.             }
  6533.             $this->em->persist($alertEntity);
  6534.             $this->em->flush();
  6535.         }
  6536.         else{
  6537.             $alertEntity = new Alert();
  6538.             $alertEntity->setDateLimit($dateCreationProject);
  6539.             $alertEntity->setProject($project);
  6540.             $alertEntity->setTypeAlert(Alert::ALERT_Etap1And2);
  6541.             if($alert){
  6542.                 $alertEntity->setIsArchived(false);
  6543.             }else{
  6544.                 $alertEntity->setIsArchived(true);
  6545.             }
  6546.             $this->em->persist($alertEntity);
  6547.             $this->em->flush();
  6548.         }
  6549.     }
  6550.     public function addAlertsEtap1AndEtap2(){
  6551.         $projects = $this->em->getRepository(Project::class)->findAllProjectActive();
  6552.         if($projects){
  6553.             foreach ($projects as $project){
  6554.                 $this->addAlertEtap1AndEtap2($project);
  6555.             }
  6556.         }
  6557.     }
  6558.     public function getAlertsEtap1AndEtap2($project){
  6559.         $dateNow = new \DateTime();
  6560.         $dateCreationProject = $project->getCreatedAt();
  6561.         if($dateCreationProject){
  6562.             $dateCreationProject->modify('+6 month');
  6563.         }
  6564.         $alert = false;
  6565.         if(  $dateNow >= $dateCreationProject ) {
  6566.             $etap1 = $this->em->getRepository(Etap1::class)->findOneBy(['project' => $project->getId()]);
  6567.             $etap2 = $this->em->getRepository(Etap2::class)->findOneBy(['project' => $project->getId()]);
  6568.             if ($etap1 && $etap2) {
  6569.                 $color = $this->checkEtapStatusColorByDoc($etap1);
  6570.                 $color2 = $this->checkEtapStatusColorByDoc($etap2);
  6571.                 if (($color == '#86D687' or $color == '#ff9f43') and ($color2 == '#86D687' or $color2 == '#ff9f43')) {
  6572.                     $alert =  false;
  6573.                 } else {
  6574.                     $alert =  true;
  6575.                 }
  6576.             }
  6577.         }
  6578.         $str = false;
  6579.         if($alert){
  6580.             $str = 'il n’y a pas d\'avancement de l\'étape 1 Ã  l\'étape 2 de timeline urbanisme ';
  6581.         }
  6582.         return $str;
  6583.     }
  6584.     public function sendMailMESprevisionnelle($date){
  6585.         $etaps14 = $this->em->getRepository(Etap14::class)->findByDateMESprevisionnelle($date);
  6586.         if($etaps14){
  6587.             $userCourant = $this->security->getUser();
  6588.             foreach ($etaps14 as $etap){
  6589.                 if(!$etap->getProject()->getIsNotifDateMESPrevisionnelle()) {
  6590.                     $isNotif = $this->notification->notifProjectDateMESPrevisionnelle($etap,$userCourant);
  6591.                     if ($isNotif) {
  6592.                         $etap->getProject()->setIsNotifDateMESPrevisionnelle(true);
  6593.                         $this->em->persist($etap->getProject());
  6594.                         $this->em->flush();
  6595.                     }
  6596.                 }
  6597.             }
  6598.         }
  6599.     }
  6600.     public function changeDev4($date){
  6601.         $etaps173 = $this->em->getRepository(Etap173::class)->getDateCahrpentier($date);
  6602.         if($etaps173){
  6603.             foreach ($etaps173 as $etap173){
  6604.                 if ($etap173 && is_object($etap173->getDateDebutCharpente())  && ($date >= $etap173->getDateDebutCharpente()) ){
  6605.                     $this->updateStatusTracker($etap173->getProject());
  6606.                 }
  6607.             }
  6608.         }
  6609.     }
  6610.     public function updateStatusTrackerConstruction($project){
  6611.         if($project){
  6612.             $isGoConsultation = false;
  6613.             $isAttenteDevis = false;
  6614.             $isArbitrageDevis = false;
  6615.             $isBudgetCapex = false;
  6616.             $isContratConstruction = false;
  6617.             $isConstructionDemarree = false;
  6618.             $isConstructionAcheveeNonRaccordable = false;
  6619.             $isConstructionAcheveeARaccorder = false;
  6620.             $isConstructionAcheveeRaccordee = false;
  6621.             $isPassagedre = false;
  6622.             $isConsuelobtenu = false;
  6623.             $isOperating = false;
  6624.             $isBillable = false;
  6625.             $isInvoiced = false;
  6626.             $isOrderDemarrageEnvoye = false;
  6627.             if($project->getStadeConstruction() == 'Go consultation'){
  6628.                 $isGoConsultation = true;
  6629.             }
  6630.             if($project->getStadeConstruction() == 'Attente devis' or $project->getStadeConstruction() == 'Devis reçus' or $project->getStadeConstruction() == 'Attente validation budget/Capex' ){
  6631.                 $isAttenteDevis = true;
  6632.             }
  6633.             if($project->getStadeConstruction() == 'Arbitrage Devis'){
  6634.                 $isArbitrageDevis = true;
  6635.             }
  6636.             if($project->getStadeConstruction() == 'Devis signé' or$project->getStadeConstruction() == 'Budget/Capex validé' or $project->getStadeConstruction() == 'Contrat de construction signé' or $project->getStadeConstruction() == 'Ordre de démarrage envoyé' or $project->getStadeConstruction() == 'Travaux réceptionnés'){
  6637.                 $isBudgetCapex = true;
  6638.             }
  6639.             $etap16 = $this->em->getRepository(Etap16::class)->findOneBy(['project'=>$project->getId()]);
  6640.             if(count($etap16->getContratConstruction()) > 0){
  6641.                 foreach ($etap16->getContratConstruction() as $item){
  6642.                     if(count($item->getFileContratEpcMultiple())>0){
  6643.                         foreach ($item->getFileContratEpcMultiple() as $value){
  6644.                             if(!$value->getIsArchived()){
  6645.                                 $isContratConstruction = true;
  6646.                             }
  6647.                         }
  6648.                     }
  6649.                 }
  6650.             }
  6651.             $dateJour = new \DateTime();
  6652.             $dateNow1 = new \DateTime($dateJour->format('Y-m-d').' 23:59:59');
  6653.             $etap172 = $this->em->getRepository(Etap172::class)->findOneBy(['project'=>$project->getId()]);
  6654.             $etap173 = $this->em->getRepository(Etap173::class)->findOneBy(['project'=>$project->getId()]);
  6655.             $etap174 = $this->em->getRepository(Etap174::class)->findOneBy(['project'=>$project->getId()]);
  6656.             $etap175 = $this->em->getRepository(Etap175::class)->findOneBy(['project'=>$project->getId()]);
  6657.             $etap121 = $this->em->getRepository(Etap121::class)->findOneBy(['project'=>$project->getId()]);
  6658.             if($etap172 && $etap172->getDateDebutFondation() && ($etap172->getDateDebutFondation() <= $dateNow1) ){
  6659.                 $isConstructionDemarree = true;
  6660.             }
  6661.             if($etap173 && $etap173->getDateDebutCharpente() && ($etap173->getDateDebutCharpente() <= $dateNow1) ){
  6662.                 $isConstructionDemarree = true;
  6663.             }
  6664.             if($etap173 && $etap173->getDateDebutCouverture() && ($etap173->getDateDebutCouverture() <= $dateNow1) ){
  6665.                 $isConstructionDemarree = true;
  6666.             }
  6667.             if($etap174 && $etap174->getDateDebutPosePv() && ($etap174->getDateDebutPosePv() <= $dateNow1) ){
  6668.                 $isConstructionDemarree = true;
  6669.             }
  6670.             if($etap174 && $etap174->getDateFinPosePv() && ($etap174->getDateFinPosePv() <= $dateNow1)){
  6671.                 if($etap175 && !$etap175->getDateAchevementTraveaux()){
  6672.                     if($etap121 && !$etap121->getDateInstallationPDL()){
  6673.                         $isConstructionAcheveeNonRaccordable = true;
  6674.                     }
  6675.                     if($etap121 && (!$etap121->getDatePrevisionnelleInstallationPDL() || ($etap121->getDatePrevisionnelleInstallationPDL() < $dateNow1))){
  6676.                         $isConstructionAcheveeNonRaccordable = true;
  6677.                     }
  6678.                     if($etap121 && !$etap121->getDateMiseSousTensionEnedis()){
  6679.                         $isConstructionAcheveeNonRaccordable = true;
  6680.                     }
  6681.                 }
  6682.             }
  6683.             if($etap174 && $etap174->getDateFinPosePv() && ($etap174->getDateFinPosePv() <= $dateNow1)){
  6684.                 if($etap175 && !$etap175->getDateAchevementTraveaux()){
  6685.                     if($etap121 && $etap121->getDateInstallationPDL() && $etap121->getDateInstallationPDL() <= $dateNow1){
  6686.                         $isConstructionAcheveeARaccorder = true;
  6687.                     }
  6688.                     if($etap121 && $etap121->getDatePrevisionnelleInstallationPDL()  && $etap121->getDatePrevisionnelleInstallationPDL() <= $dateNow1){
  6689.                         $isConstructionAcheveeARaccorder = true;
  6690.                     }
  6691.                     if($etap121 && $etap121->getDateMiseSousTensionEnedis()  && $etap121->getDateMiseSousTensionEnedis() <= $dateNow1){
  6692.                         $isConstructionAcheveeARaccorder = true;
  6693.                     }
  6694.                 }
  6695.             }
  6696.             $etap175 = $this->em->getRepository(Etap175::class)->findOneBy(['project'=>$project->getId()]);
  6697.             if($etap175 && $etap175->getDateAchevementTraveaux()){
  6698.                 $isConstructionAcheveeRaccordee = true;
  6699.             }
  6700.             $etap13 = $this->em->getRepository(Etap13::class)->findOneBy(['project'=>$project->getId()]);
  6701.             $etap20 = $this->em->getRepository(Etap20::class)->findOneBy(['project'=>$project->getId()]);
  6702.             if($etap13 || $etap20){
  6703.                 if($this->checkArchiveFile($project, Etaps::ETAP_13, 'getFileDREMultiple')){
  6704.                     $isPassagedre = true;
  6705.                 }
  6706.                 if($etap13->getDateConsuel() or $this->checkArchiveFile($project, Etaps::ETAP_13, 'getFileConsuelMultiple')){
  6707.                     $isConsuelobtenu = true;
  6708.                 }
  6709.                 if($etap20->getDateConsuelEtap20() or $this->checkArchiveFile($project, Etaps::ETAP_20, 'getFileConsuelEtap20Multiple')){
  6710.                     $isConsuelobtenu = true;
  6711.                 }
  6712.             }
  6713.             if($project->getDateMiseEnService()){
  6714.                 $isOperating = true;
  6715.             }
  6716.             $etap14 = $this->em->getRepository(Etap14::class)->findOneBy(['project'=>$project->getId()]);
  6717.             if($etap13 || $etap14){
  6718.                 if((int)$project->getCapacite() > 100 && ($this->checkArchiveFile($project, Etaps::ETAP_13, 'getFileAttestationBureauControleMultiple') or $this->checkArchiveFile($project, Etaps::ETAP_14, 'getFileAttestationS21Multiple'))){
  6719.                     $isBillable = true;
  6720.                 }
  6721.             }
  6722. //            $etap15 = $this->em->getRepository(Etap15::class)->findOneBy(['project'=>$project->getId()]);
  6723. //            if($etap15 && $this->checkArchiveFile($project, Etaps::ETAP_15, 'getFileContratAchatSigneMultiple')){
  6724. //                $isInvoiced = true;
  6725. //            }
  6726.             $etap24 = $this->em->getRepository(Etap24::class)->findOneBy(['project'=>$project->getId()]);
  6727.             if($etap24 && count($etap24->getEtap24Champs()) > 0){
  6728.                 $notEmpty = false  ;
  6729.                 foreach ($etap24->getEtap24Champs() as $champ){
  6730.                     if(count($champ->getEtap26Champs()) > 0){
  6731.                         foreach ($champ->getEtap26Champs() as $champ26){
  6732.                             if(count($champ26->getFileContratAchatSigneEtap25Multiple()) > 0){
  6733.                                 foreach ($champ26->getFileContratAchatSigneEtap25Multiple() as $doc){
  6734.                                     if(!$doc->getIsArchived()){
  6735.                                         $notEmpty = true  ;
  6736.                                     }
  6737.                                 }
  6738.                             }
  6739.                         }
  6740.                     }
  6741.                 }
  6742.                 if($notEmpty){
  6743.                     $isInvoiced = true;
  6744.                 }
  6745.             }
  6746.             $etap171 = $this->em->getRepository(Etap171::class)->findOneBy(['project'=>$project->getId()]);
  6747.             if($etap171 && $this->checkArchiveFile($project, Etaps::ETAP_171, 'getFileOrderServiceMultiple')){
  6748.                 $isOrderDemarrageEnvoye = true;
  6749.             }
  6750.             $status = 0;
  6751.             if($isInvoiced){
  6752.                 $status = StatusTrackerConstruction::Invoiced;
  6753.             }elseif ($isBillable) {
  6754.                 $status = StatusTrackerConstruction::Billable;
  6755.             }elseif ($isOperating) {
  6756.                 $status = StatusTrackerConstruction::Operating;
  6757.             }elseif ($isConsuelobtenu) {
  6758.                 $status = StatusTrackerConstruction::Consuel_obtenu;
  6759.             }elseif ($isPassagedre) {
  6760.                 $status = StatusTrackerConstruction::Passage_dre;
  6761.             }elseif ($isConstructionAcheveeRaccordee) {
  6762.                 $status = StatusTrackerConstruction::Construction_Achevee_Raccordee;
  6763.             }elseif ($isConstructionAcheveeARaccorder) {
  6764.                 $status = StatusTrackerConstruction::Construction_Achevee_A_Raccorder;
  6765.             }elseif ($isConstructionAcheveeNonRaccordable) {
  6766.                 $status = StatusTrackerConstruction::Construction_Achevee_Non_Raccordable;
  6767.             }elseif ($isConstructionDemarree) {
  6768.                 $status = StatusTrackerConstruction::Construction_Demarree;
  6769.             }elseif ($isOrderDemarrageEnvoye) {
  6770.                 $status = StatusTrackerConstruction::Order_demarrage_envoye;
  6771.             }elseif ($isContratConstruction) {
  6772.                 $status = StatusTrackerConstruction::Contrat_Construction;
  6773.             }elseif ($isBudgetCapex) {
  6774.                 $status = StatusTrackerConstruction::Budget_Capex;
  6775.             }elseif ($isArbitrageDevis) {
  6776.                 $status = StatusTrackerConstruction::Arbitrage_Devis;
  6777.             }elseif ($isAttenteDevis) {
  6778.                 $status = StatusTrackerConstruction::Attente_Devis;
  6779.             }elseif ($isGoConsultation) {
  6780.                 $status = StatusTrackerConstruction::Go_Consultation;
  6781.             }
  6782.             $statusTracker = $project->getStatusTrackerActuel();
  6783.             if($statusTracker == StatusTracker::STATUS_dev_4){
  6784.                 if(in_array($status ,[StatusTrackerConstruction::Construction_Achevee_Non_Raccordable,StatusTrackerConstruction::Construction_Achevee_A_Raccorder,StatusTrackerConstruction::Construction_Achevee_Raccordee,StatusTrackerConstruction::Passage_dre])){
  6785.                 }else{
  6786.                     $status = StatusTrackerConstruction::Construction_Demarree;
  6787.                 }
  6788.             }elseif ($statusTracker == StatusTracker::STATUS_dev_5){
  6789. //                if(in_array($status ,[StatusTrackerConstruction::Construction_Achevee_Non_Raccordable,StatusTrackerConstruction::Construction_Achevee_A_Raccorder,StatusTrackerConstruction::Construction_Achevee_Raccordee,StatusTrackerConstruction::Passage_dre])){
  6790. //
  6791. //                }else{
  6792. //                    $status = StatusTrackerConstruction::Construction_Achevee_Non_Raccordable;
  6793. //                }
  6794.             }
  6795.             elseif ($statusTracker == StatusTracker::STATUS_dev_6){
  6796.                 $status = StatusTrackerConstruction::Consuel_obtenu;
  6797.             }
  6798.             elseif ($statusTracker == StatusTracker::STATUS_operating){
  6799.                 if(in_array($status ,[StatusTrackerConstruction::Operating,StatusTrackerConstruction::Billable,StatusTrackerConstruction::Invoiced])){
  6800.                 }else{
  6801.                     $status = StatusTrackerConstruction::Operating;
  6802.                 }
  6803.             }
  6804.             $statusTrackerProjectConstruction = $this->em->getRepository(StatusTrackerConstruction::class)->findOneBy(['project'=>$project->getId()],['createdAt'=>'desc']);
  6805.             if($statusTrackerProjectConstruction){
  6806.                 if($statusTrackerProjectConstruction->getStatus() != $status){
  6807.                     $entity = new StatusTrackerConstruction();
  6808.                     $entity->setProject($project);
  6809.                     $entity->setStatus($status);
  6810.                     $this->em->persist($entity);
  6811.                     $project->setStatusTrackerActuelConstruction($status);
  6812.                     $this->em->persist($project);
  6813.                     $this->em->flush();
  6814.                 }
  6815.             }else{
  6816.                 $entity = new StatusTrackerConstruction();
  6817.                 $entity->setProject($project);
  6818.                 $entity->setStatus($status);
  6819.                 $this->em->persist($entity);
  6820.                 $project->setStatusTrackerActuelConstruction($status);
  6821.                 $this->em->persist($project);
  6822.                 $this->em->flush();
  6823.             }
  6824.         }
  6825.     }
  6826.     private function checkArchiveFile($project,$numEtap,$attribute){
  6827.         $class = 'App\Entity\Etap'.$numEtap;
  6828.         $etap = $this->em->getRepository($class)->findOneBy(['project'=>$project->getId()]);
  6829.         $docs = $etap->{$attribute}();
  6830.         if($docs && count($docs) > 0){
  6831.             $empty =false;
  6832.             foreach ($docs as $doc){
  6833.                 if(!$doc->getIsArchived()){
  6834.                     $empty = true  ;
  6835.                 }
  6836.             }
  6837.             if($empty){
  6838.                 return true;
  6839.             }else{
  6840.                 return false;
  6841.             }
  6842.         }else{
  6843.             return false;
  6844.         }
  6845.     }
  6846.     public function addEtap71()
  6847.     {
  6848.         $projects = $this->em->getRepository(Project::class)->findAll();
  6849.         foreach ($projects as $project){
  6850.             $etap71 = $this->em->getRepository(Etap71::class)->findOneBy(['project'=>$project->getId()]);
  6851.             $etap = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_71]);
  6852.             if(!$etap71){
  6853.                 $etap71 = new Etap71();
  6854.                 $etap71->setProject($project);
  6855.                 $etap71->setEtap($etap);
  6856.                 $etap71->setStatus(Etaps::STATUS_EN_COURS);
  6857.                 $this->em->persist($etap71);
  6858.                 $this->em->flush();
  6859.             }
  6860.         }
  6861.     }
  6862.     public function migrateImageProject()
  6863.     {
  6864.         $projects = $this->em->getRepository(Project::class)->findAll();
  6865.         foreach ($projects as $project){
  6866.             if($project->getImageProject()){
  6867.                 $project->addImagesProject($project->getImageProject());
  6868.                 $this->em->persist($project);
  6869.                 $this->em->flush();
  6870.             }
  6871.         }
  6872.     }
  6873.     public function addCategoryValorisation()
  6874.     {
  6875.         $typeValorisations = $this->em->getRepository(TypeValorisation::class)->findAll();
  6876.         if(!$typeValorisations){
  6877.             $typeValorisation = new TypeValorisation();$typeValorisation->setName('Guichet ouvert');$typeValorisation->setCategory(TypeValorisation::type_guichet_ouvert);$this->em->persist($typeValorisation);
  6878.             $typeValorisation = new TypeValorisation();$typeValorisation->setName('AO CRE');$typeValorisation->setCategory(TypeValorisation::type_ao_cre);$this->em->persist($typeValorisation);
  6879.             $typeValorisation = new TypeValorisation();$typeValorisation->setName('ACC');$typeValorisation->setCategory(TypeValorisation::type_acc);$this->em->persist($typeValorisation);
  6880.             $typeValorisation = new TypeValorisation();$typeValorisation->setName('ACI');$typeValorisation->setCategory(TypeValorisation::type_aci);$this->em->persist($typeValorisation);
  6881.             $typeValorisation = new TypeValorisation();$typeValorisation->setName('PPA');$typeValorisation->setCategory(TypeValorisation::type_ppa);$this->em->persist($typeValorisation);
  6882.             $typeValorisation = new TypeValorisation();$typeValorisation->setName('Spot');$typeValorisation->setCategory(TypeValorisation::type_spot);$this->em->persist($typeValorisation);
  6883.             $typeValorisation = new TypeValorisation();$typeValorisation->setName('FER');$typeValorisation->setCategory(TypeValorisation::type_fer);$this->em->persist($typeValorisation);
  6884.             $this->em->flush();
  6885.         }
  6886.         $projects = $this->em->getRepository(Project::class)->findAll();
  6887.         $catValorisation = $this->em->getRepository(EtapsCategory::class)->findOneBy(['name'=>'Valorisation']);
  6888.         if(!$catValorisation){
  6889.             $catValorisation = new EtapsCategory();
  6890.             $catValorisation->setName('Valorisation');
  6891.             $catValorisation->setNum(5);
  6892.             $this->em->persist($catValorisation);
  6893.             $this->em->flush();
  6894.         }
  6895.         $catRaccordement = $this->em->getRepository(EtapsCategory::class)->findOneBy(['name'=>'Raccordement']);
  6896.         if(!$catRaccordement){
  6897.             $catRaccordement = new EtapsCategory();
  6898.             $catRaccordement->setName('Raccordement');
  6899.             $catRaccordement->setNum(3);
  6900.             $this->em->persist($catRaccordement);
  6901.             $this->em->flush();
  6902.         }
  6903.         $etapCat24 = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_24]);
  6904.         if(!$etapCat24){
  6905.             $etapCat24 = new Etaps();
  6906.             $etapCat24->setName('Méthode de valorisation');
  6907.             $etapCat24->setCategory($catValorisation);
  6908.             $etapCat24->setNum(24);
  6909.             $etapCat24->setEtapsNum(1);
  6910.             $etapCat24->setIsDelete(false);
  6911.             $etapCat24->setIsDeleteNewConstruction(false);
  6912.             $etapCat24->setIsNeedCondition(false);
  6913.             $etapCat24->setIsNeedValide(false);
  6914.             $this->em->persist($etapCat24);
  6915.             $this->em->flush();
  6916.         }
  6917.         $etapCat25 = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_25]);
  6918.         if(!$etapCat25){
  6919.             $etapCat25 = new Etaps();
  6920.             $etapCat25->setName('Avancée de la valorisation');
  6921.             $etapCat25->setCategory($catValorisation);
  6922.             $etapCat25->setNum(25);
  6923.             $etapCat25->setEtapsNum(2);
  6924.             $etapCat25->setIsDelete(false);
  6925.             $etapCat25->setIsDeleteNewConstruction(false);
  6926.             $etapCat25->setIsNeedCondition(false);
  6927.             $etapCat25->setIsNeedValide(false);
  6928.             $this->em->persist($etapCat25);
  6929.             $this->em->flush();
  6930.         }
  6931.         $etapCat26 = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_26]);
  6932.         if(!$etapCat26){
  6933.             $etapCat26 = new Etaps();
  6934.             $etapCat26->setName('Contrat d’achat');
  6935.             $etapCat26->setCategory($catValorisation);
  6936.             $etapCat26->setNum(26);
  6937.             $etapCat26->setEtapsNum(3);
  6938.             $etapCat26->setIsDelete(false);
  6939.             $etapCat26->setIsDeleteNewConstruction(false);
  6940.             $etapCat26->setIsNeedCondition(false);
  6941.             $etapCat26->setIsNeedValide(false);
  6942.             $this->em->persist($etapCat26);
  6943.             $this->em->flush();
  6944.         }
  6945.         $etapCat80 = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>Etaps::ETAP_80]);
  6946.         if(!$etapCat80){
  6947.             $etapCat80 = new Etaps();
  6948.             $etapCat80->setName('Faisabilité du raccordement');
  6949.             $etapCat80->setCategory($catRaccordement);
  6950.             $etapCat80->setNum(80);
  6951.             $etapCat80->setEtapsNum(0);
  6952.             $etapCat80->setIsDelete(false);
  6953.             $etapCat80->setIsDeleteNewConstruction(false);
  6954.             $etapCat80->setIsNeedCondition(false);
  6955.             $etapCat80->setIsNeedValide(false);
  6956.             $this->em->persist($etapCat80);
  6957.             $this->em->flush();
  6958.         }
  6959.         foreach ($projects as $project){
  6960.             $etap24 = $this->em->getRepository(Etap24::class)->findOneBy(['project'=>$project->getId()]);
  6961.             if(!$etap24){
  6962.                 $etap24 = new Etap24();
  6963.                 $etap24->setProject($project);
  6964.                 $etap24->setEtap($etapCat24);
  6965.                 $etap24->setStatus(Etaps::STATUS_EN_COURS);
  6966.                 $this->em->persist($etap24);
  6967.                 $this->em->flush();
  6968.             }
  6969.             $etap25 = $this->em->getRepository(Etap25::class)->findOneBy(['project'=>$project->getId()]);
  6970.             if(!$etap25){
  6971.                 $etap25 = new Etap25();
  6972.                 $etap25->setProject($project);
  6973.                 $etap25->setEtap($etapCat25);
  6974.                 $etap25->setStatus(Etaps::STATUS_EN_COURS);
  6975.                 $this->em->persist($etap25);
  6976.                 $this->em->flush();
  6977.             }
  6978.             $etap26 = $this->em->getRepository(Etap26::class)->findOneBy(['project'=>$project->getId()]);
  6979.             if(!$etap26 ){
  6980.                 $etap26 = new Etap26();
  6981.                 $etap26->setProject($project);
  6982.                 $etap26->setEtap($etapCat26);
  6983.                 $etap26->setStatus(Etaps::STATUS_EN_COURS);
  6984.                 $this->em->persist($etap26);
  6985.                 $this->em->flush();
  6986.             }
  6987.             // deplacer les champs
  6988.             $etap9 = $this->em->getRepository(Etap9::class)->findOneBy(['project'=>$project->getId()]);
  6989.             if($etap9){
  6990.                 if($etap24 && $etap25 && $etap26){
  6991.                     if(count($etap24->getEtap24Champs()) > 0){
  6992.                     }else{
  6993.                         $etap15 = $this->em->getRepository(Etap15::class)->findOneBy(['project'=>$project->getId()]);
  6994.                         if($etap15) {
  6995.                             if (count($etap15->getInformationMultiple()) > 0) {
  6996.                                 foreach ($etap15->getInformationMultiple() as $contrat) {
  6997.                                     $typeValorisation = $this->em->getRepository(TypeValorisation::class)->findOneBy(['category' => TypeValorisation::type_guichet_ouvert]);
  6998.                                     if($typeValorisation){
  6999.                                         $etap24Cahmps = new Etap24Champs();
  7000.                                         $etap24Cahmps->setEtap24($etap24);
  7001.                                         $etap24Cahmps->setEtap25($etap25);
  7002.                                         $etap24Cahmps->setEtap26($etap26);
  7003.                                         $etap24Cahmps->setTypeValorisation($typeValorisation);
  7004.                                         if($contrat->getTypeContrat()){
  7005.                                             $etap24Cahmps->setSousChoixValorisation($contrat->getTypeContrat());
  7006.                                         }
  7007.                                         if($etap9->getTarifFit()){
  7008.                                             $etap24Cahmps->setTarifFit($etap9->getTarifFit());
  7009.                                         }
  7010.                                         if($etap9->getDateConsignation()){
  7011.                                             $etap24Cahmps->setDateConsignation($etap9->getDateConsignation());
  7012.                                         }
  7013.                                         if($etap9->getDateMaximaleAchevement()){
  7014.                                             $etap24Cahmps->setDateConsignation($etap9->getDateMaximaleAchevement());
  7015.                                         }
  7016.                                         if($etap9->getDateT0()){
  7017.                                             $etap24Cahmps->setDateT0($etap9->getDateT0());
  7018.                                         }
  7019.                                         if(count($etap9->getFileGarantieBancaireMultiple()) > 0){
  7020.                                             foreach ($etap9->getFileGarantieBancaireMultiple() as $value){
  7021.                                                 $etap24Cahmps->addFileGarantieBancaireEtap25Multiple($value);
  7022.                                             }
  7023.                                         }
  7024.                                         if(count($etap9->getFileMailEnedisConfirmationMultiple()) > 0){
  7025.                                             foreach ($etap9->getFileMailEnedisConfirmationMultiple() as $value){
  7026.                                                 $etap24Cahmps->addFileMailEnedisConfirmationEtap25Multiple($value);
  7027.                                             }
  7028.                                         }
  7029.                                         if(count($etap9->getFileDemandeRaccordementMultiple()) > 0){
  7030.                                             foreach ($etap9->getFileDemandeRaccordementMultiple() as $value){
  7031.                                                 $etap24Cahmps->addFileDemandeRaccordementEtap25Multiple($value);
  7032.                                             }
  7033.                                         }
  7034.                                         $this->em->persist($etap24Cahmps);
  7035.                                         $this->em->flush();
  7036.                                         // add contrat
  7037.                                         if($etap24Cahmps){
  7038.                                             $etap26Cahmps = new Etap26Champs();
  7039.                                             $etap26Cahmps->setEtap24Champs($etap24Cahmps);
  7040.                                             if($contrat->getDateDebutContratAchat()){$etap26Cahmps->setDateDebutContratAchat1($contrat->getDateDebutContratAchat());}
  7041.                                             if($contrat->getDateFinContratAchat()){$etap26Cahmps->setDateFinContratAchat1($contrat->getDateFinContratAchat());}
  7042.                                             if($contrat->getNumeroContratAchat()){$etap26Cahmps->setNumeroContratAchat1($contrat->getNumeroContratAchat());}
  7043.                                             if($contrat->getPeridiciteFacturation()){$etap26Cahmps->setPeridiciteFacturation1($contrat->getPeridiciteFacturation());}
  7044.                                             if($contrat->getTarifContratAchat()){$etap26Cahmps->setTarifContratAchat1($contrat->getTarifContratAchat());}
  7045.                                             if($contrat->getTypeContrat()){$etap26Cahmps->setTypeContrat1($contrat->getTypeContrat());}
  7046.                                             if(count($etap15->getFileContratAchatSigneMultiple()) > 0){
  7047.                                                 foreach ($etap15->getFileContratAchatSigneMultiple() as $item){
  7048.                                                     $val = clone $item;
  7049.                                                     $etap26Cahmps->addFileContratAchatSigneEtap25Multiple($val);
  7050.                                                 }
  7051.                                             }
  7052.                                             if(count($etap15->getFileAttestionProducteurMultiple()) > 0){
  7053.                                                 foreach ($etap15->getFileAttestionProducteurMultiple() as $item){
  7054.                                                     $val = clone $item;
  7055.                                                     $etap26Cahmps->addFileAttestionProducteurEtap25Multiple($val);
  7056.                                                 }
  7057.                                             }
  7058.                                             if(count($etap15->getFileAttestionInstallateurMultiple()) > 0){
  7059.                                                 foreach ($etap15->getFileAttestionInstallateurMultiple() as $item){
  7060.                                                     $val = clone $item;
  7061.                                                     $etap26Cahmps->addFileAttestionInstallateurEtap25Multiple($val);
  7062.                                                 }
  7063.                                             }
  7064.                                             if(count($etap15->getFileArContratAchatMultiple()) > 0){
  7065.                                                 foreach ($etap15->getFileArContratAchatMultiple() as $item){
  7066.                                                     $val = clone $item;
  7067.                                                     $etap26Cahmps->addFileArContratAchatEtap25Multiple($val);
  7068.                                                 }
  7069.                                             }
  7070.                                             $this->em->persist($etap26Cahmps);
  7071.                                             $this->em->flush();
  7072.                                         }
  7073.                                     }
  7074.                                 }
  7075.                             }
  7076.                         }
  7077.                     }
  7078.                 }
  7079.             }
  7080.             $etap80 = $this->em->getRepository(Etap80::class)->findOneBy(['project'=>$project->getId()]);
  7081.             if(!$etap80 ){
  7082.                 $etap80 = new Etap80();
  7083.                 $etap80->setProject($project);
  7084.                 $etap80->setEtap($etapCat80);
  7085.                 $etap80->setStatus(Etaps::STATUS_EN_COURS);
  7086.                 $this->em->persist($etap80);
  7087.                 $this->em->flush();
  7088.             }
  7089.         }
  7090.     }
  7091.     public function submitEtap24($request,$user)
  7092.     {
  7093.         $etapToken = $request->get('etapToken');
  7094.         $tokenProject = $request->get('tokenProject');
  7095.         $etap24Champs = $request->get('etap24Champs');
  7096.         if($etapToken and $tokenProject){
  7097.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  7098.             $etap = $this->em->getRepository(Etap24::class)->findOneBy(['token'=>$etapToken]);
  7099.             $etap25 = $this->em->getRepository(Etap25::class)->findOneBy(['project'=>$project->getId()]);
  7100.             $etap26 = $this->em->getRepository(Etap26::class)->findOneBy(['project'=>$project->getId()]);
  7101.             if($project && $etap){
  7102.                 if(!$this->checkUserAction($user,$project,$etap)){
  7103.                     return [
  7104.                         'success' => false
  7105.                     ];
  7106.                 }
  7107.                 if($etap24Champs) {
  7108.                     foreach ($etap24Champs as $item) {
  7109.                         if (isset($item['id']) and $item['id'] != '') {
  7110.                             $etap24ChampsEntity = $this->em->getRepository(Etap24Champs::class)->findOneBy(['token' => $item['id']]);
  7111.                         } else {
  7112.                             $etap24ChampsEntity = new Etap24Champs();
  7113.                         }
  7114.                         if (isset($item['typeValorisation']) and $item['typeValorisation'] != '') {
  7115.                            $typeValorisation = $this->em->getRepository(TypeValorisation::class)->find($item['typeValorisation']);
  7116.                            $etap24ChampsEntity->setTypeValorisation($typeValorisation);
  7117.                         }else{
  7118.                             $etap24ChampsEntity->setTypeValorisation(null);
  7119.                         }
  7120.                         if(isset($item['sousChoixValorisation']) and $item['sousChoixValorisation'] != ''){
  7121.                             $etap24ChampsEntity->setSousChoixValorisation($item['sousChoixValorisation']);
  7122.                         }else{
  7123.                             $etap24ChampsEntity->setSousChoixValorisation(null);
  7124.                         }
  7125.                         if(isset($item['sousChoixValorisationLibre']) and $item['sousChoixValorisationLibre'] != ''){
  7126.                             $etap24ChampsEntity->setSousChoixValorisationLibre($item['sousChoixValorisationLibre']);
  7127.                         }else{
  7128.                             $etap24ChampsEntity->setSousChoixValorisationLibre(null);
  7129.                         }
  7130.                         if(isset($item['dureeContrat']) and $item['dureeContrat'] != ''){
  7131.                             $etap24ChampsEntity->setDureeContrat($item['dureeContrat']);
  7132.                         }else{
  7133.                             $etap24ChampsEntity->setDureeContrat(null);
  7134.                         }
  7135.                         if(isset($item['prixVenteElectricite']) and $item['prixVenteElectricite'] != ''){
  7136.                             $etap24ChampsEntity->setPrixVenteElectricite($item['prixVenteElectricite']);
  7137.                         }else{
  7138.                             $etap24ChampsEntity->setPrixVenteElectricite(null);
  7139.                         }
  7140.                         if(isset($item['tauxIndexationTarif']) and $item['tauxIndexationTarif'] != ''){
  7141.                             $etap24ChampsEntity->setTauxIndexationTarif($item['tauxIndexationTarif']);
  7142.                         }else{
  7143.                             $etap24ChampsEntity->setTauxIndexationTarif(null);
  7144.                         }
  7145.                         $etap9 = $this->em->getRepository(Etap9::class)->findOneBy(['project'=>$project->getId()]);
  7146.                         if(count($etap9->getFileMailEnedisConfirmationMultiple()) > 0) {
  7147.                             foreach ($etap9->getFileMailEnedisConfirmationMultiple() as $itemEtap9Doc){
  7148.                                 if($etap24ChampsEntity->getTypeValorisation() && ($etap24ChampsEntity->getTypeValorisation()->getCategory() == TypeValorisation::type_ao_cre or $etap24ChampsEntity->getTypeValorisation()->getCategory() == TypeValorisation::type_guichet_ouvert)){
  7149.                                     $etap24ChampsEntity->addFileMailEnedisConfirmationEtap25Multiple($itemEtap9Doc);
  7150.                                 }
  7151.                             }
  7152.                         }
  7153.                         if(count($etap9->getFileDemandeRaccordementMultiple()) > 0) {
  7154.                             foreach ($etap9->getFileDemandeRaccordementMultiple() as $itemEtap9Doc){
  7155.                                 if($etap24ChampsEntity->getTypeValorisation() && ($etap24ChampsEntity->getTypeValorisation()->getCategory() == TypeValorisation::type_ao_cre or $etap24ChampsEntity->getTypeValorisation()->getCategory() == TypeValorisation::type_guichet_ouvert)){
  7156.                                     $etap24ChampsEntity->addFileDemandeRaccordementEtap25Multiple($itemEtap9Doc);
  7157.                                 }
  7158.                             }
  7159.                         }
  7160.                         if(count($etap9->getFileGarantieBancaireMultiple()) > 0) {
  7161.                             foreach ($etap9->getFileGarantieBancaireMultiple() as $itemEtap9Doc){
  7162.                                 if($etap24ChampsEntity->getTypeValorisation() && ($etap24ChampsEntity->getTypeValorisation()->getCategory() == TypeValorisation::type_ao_cre )){
  7163.                                     $etap24ChampsEntity->addFileDemandeRaccordementEtap25Multiple($itemEtap9Doc);
  7164.                                 }
  7165.                             }
  7166.                         }
  7167.                         if($etap9->getDateT0()){
  7168.                             $etap24ChampsEntity->setDateT0($etap9->getDateT0());
  7169.                         }
  7170.                         $etap24ChampsEntity->setEtap24($etap);
  7171.                         $etap24ChampsEntity->setEtap25($etap25);
  7172.                         $etap24ChampsEntity->setEtap26($etap26);
  7173.                         $this->em->persist($etap24ChampsEntity);
  7174.                         $this->em->flush();
  7175.                     }
  7176.                 }
  7177.                 $this->em->persist($etap);
  7178.                 $this->em->flush();
  7179.                 $this->updateStatusTracker($project); // set status tracker
  7180.                 $this->flashBag->add(
  7181.                     'success',
  7182.                     'L\'opération a Ã©té effectuée avec succès.'
  7183.                 );
  7184.                 return [
  7185.                     'etap' => $etap,
  7186.                     'success' => true
  7187.                 ];
  7188.             }
  7189.         }
  7190.         return [
  7191.             'success' => false
  7192.         ];
  7193.     }
  7194.     public function submitEtap25($request,$user)
  7195.     {
  7196.         $etapToken = $request->get('etapToken');
  7197.         $tokenProject = $request->get('tokenProject');
  7198.         $etap25Champs = $request->get('etap25Champs');
  7199.         if($etapToken and $tokenProject){
  7200.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  7201.             $etap = $this->em->getRepository(Etap25::class)->findOneBy(['token'=>$etapToken]);
  7202.             $etap9 = $this->em->getRepository(Etap9::class)->findOneBy(['project'=>$project->getId()]);
  7203.             if($project && $etap){
  7204.                 if(!$this->checkUserAction($user,$project,$etap)){
  7205.                     return [
  7206.                         'success' => false
  7207.                     ];
  7208.                 }
  7209.                 if($etap25Champs) {
  7210.                     foreach ($etap25Champs as $item) {
  7211.                         if (isset($item['id']) and $item['id'] != '') {
  7212.                             $etap24ChampsEntity = $this->em->getRepository(Etap24Champs::class)->findOneBy(['token' => $item['id']]);
  7213.                         } else {
  7214.                             $etap24ChampsEntity = new Etap24Champs();
  7215.                         }
  7216.                         if(isset($item['fileDemandeRaccordementEtap25Multiple']) and $item['fileDemandeRaccordementEtap25Multiple'] != ''){
  7217.                             $array = explode(',',$item['fileDemandeRaccordementEtap25Multiple']);
  7218.                             foreach ($array as $item1){
  7219.                                 $fileMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  7220.                                 $nomenclature = $this->getNomenclature($etap,$fileMultipleEntity,'Demande de raccordement');
  7221.                                 $etap24ChampsEntity->addFileDemandeRaccordementEtap25Multiple($fileMultipleEntity);
  7222.                                 $etap9->addFileDemandeRaccordementMultiple($fileMultipleEntity);
  7223.                             }
  7224.                         }
  7225.                         if(isset($item['fileMailEnedisConfirmationEtap25Multiple']) and $item['fileMailEnedisConfirmationEtap25Multiple'] != ''){
  7226.                             $array = explode(',',$item['fileMailEnedisConfirmationEtap25Multiple']);
  7227.                             foreach ($array as $item1){
  7228.                                 $fileMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  7229.                                 $nomenclature = $this->getNomenclature($etap,$fileMultipleEntity,'Mail d’ENEDIS de confirmation');
  7230.                                 $etap24ChampsEntity->addFileMailEnedisConfirmationEtap25Multiple($fileMultipleEntity);
  7231.                                 $etap9->addFileMailEnedisConfirmationMultiple($fileMultipleEntity);
  7232.                             }
  7233.                         }
  7234.                         if(isset($item['fileGarantieBancaireEtap25Multiple']) and $item['fileGarantieBancaireEtap25Multiple'] != ''){
  7235.                             $array = explode(',',$item['fileGarantieBancaireEtap25Multiple']);
  7236.                             foreach ($array as $item1){
  7237.                                 $fileMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  7238.                                 $nomenclature = $this->getNomenclature($etap,$fileMultipleEntity,'Garantie Bancaire ');
  7239.                                 $etap24ChampsEntity->addFileGarantieBancaireEtap25Multiple($fileMultipleEntity);
  7240.                                 $etap9->addFileGarantieBancaireMultiple($fileMultipleEntity);
  7241.                             }
  7242.                         }
  7243.                         if(isset($item['fileRecepisseDemandeAoMultiple']) and $item['fileRecepisseDemandeAoMultiple'] != ''){
  7244.                             $array = explode(',',$item['fileRecepisseDemandeAoMultiple']);
  7245.                             foreach ($array as $item1){
  7246.                                 $fileMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  7247.                                 $nomenclature = $this->getNomenclature($etap,$fileMultipleEntity,'Récépissé demande AO');
  7248.                                 $etap24ChampsEntity->addFileRecepisseDemandeAoMultiple($fileMultipleEntity);
  7249.                             }
  7250.                         }
  7251.                         if(isset($item['fileLettreLaureaMultiple']) and $item['fileLettreLaureaMultiple'] != ''){
  7252.                             $array = explode(',',$item['fileLettreLaureaMultiple']);
  7253.                             foreach ($array as $item1){
  7254.                                 $fileMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  7255.                                 $nomenclature = $this->getNomenclature($etap,$fileMultipleEntity,'Lettre de lauréat ');
  7256.                                 $etap24ChampsEntity->addFileLettreLaureaMultiple($fileMultipleEntity);
  7257.                             }
  7258.                         }
  7259.                         if(isset($item['dateT0']) and $item['dateT0'] != ''){
  7260.                             $etap24ChampsEntity->setDateT0(new \DateTime($item['dateT0']));
  7261.                             $etap9->setDateT0(new \DateTime($item['dateT0']));
  7262.                         }else{
  7263.                             $etap24ChampsEntity->setDateT0(null);
  7264.                             $etap9->setDateT0(null);
  7265.                         }
  7266.                         if(isset($item['tarifFit']) and $item['tarifFit'] != ''){
  7267.                             $etap24ChampsEntity->setTarifFit($item['tarifFit']);
  7268.                         }else{
  7269.                             $etap24ChampsEntity->setTarifFit(null);
  7270.                         }
  7271.                         if(isset($item['dateMaximaleAchevement']) and $item['dateMaximaleAchevement'] != ''){
  7272.                             $etap24ChampsEntity->setDateMaximaleAchevement(new \DateTime($item['dateMaximaleAchevement']));
  7273.                         }else{
  7274.                             $etap24ChampsEntity->setDateMaximaleAchevement(null);
  7275.                         }
  7276.                         if(isset($item['dateConsignation']) and $item['dateConsignation'] != ''){
  7277.                             $etap24ChampsEntity->setDateConsignation(new \DateTime($item['dateConsignation']));
  7278.                         }else{
  7279.                             $etap24ChampsEntity->setDateConsignation(null);
  7280.                         }
  7281.                         if(isset($item['dateDepotAo']) and $item['dateDepotAo'] != ''){
  7282.                             $etap24ChampsEntity->setDateDepotAo(new \DateTime($item['dateDepotAo']));
  7283.                         }else{
  7284.                             $etap24ChampsEntity->setDateDepotAo(null);
  7285.                         }
  7286.                         if(isset($item['dateNotificationLaureatAo']) and $item['dateNotificationLaureatAo'] != ''){
  7287.                             $etap24ChampsEntity->setDateNotificationLaureatAo(new \DateTime($item['dateNotificationLaureatAo']));
  7288.                         }else{
  7289.                             $etap24ChampsEntity->setDateNotificationLaureatAo(null);
  7290.                         }
  7291.                         if(isset($item['typeAoPeriodeCandidature']) and $item['typeAoPeriodeCandidature'] != ''){
  7292.                             $etap24ChampsEntity->setTypeAoPeriodeCandidature($item['typeAoPeriodeCandidature']);
  7293.                         }else{
  7294.                             $etap24ChampsEntity->setTypeAoPeriodeCandidature(null);
  7295.                         }
  7296.                         if(isset($item['agregateur']) and $item['agregateur'] != ''){
  7297.                             $etap24ChampsEntity->setAgregateur($item['agregateur']);
  7298.                         }else{
  7299.                             $etap24ChampsEntity->setAgregateur(null);
  7300.                         }
  7301.                         if(isset($item['fraisGestion']) and $item['fraisGestion'] != ''){
  7302.                             $etap24ChampsEntity->setFraisGestion($item['fraisGestion']);
  7303.                         }else{
  7304.                             $etap24ChampsEntity->setFraisGestion(null);
  7305.                         }
  7306.                         if(isset($item['uniteFraisGestion']) and $item['uniteFraisGestion'] != ''){
  7307.                             $etap24ChampsEntity->setUniteFraisGestion($item['uniteFraisGestion']);
  7308.                         }else{
  7309.                             $etap24ChampsEntity->setUniteFraisGestion(null);
  7310.                         }
  7311.                         if(isset($item['contrepartie']) and $item['contrepartie'] != ''){
  7312.                             $etap24ChampsEntity->setContrepartie($item['contrepartie']);
  7313.                         }else{
  7314.                             $etap24ChampsEntity->setContrepartie(null);
  7315.                         }
  7316.                         $etap24ChampsEntity->setEtap25($etap);
  7317.                         $this->em->persist($etap24ChampsEntity);
  7318.                         $this->em->persist($etap9);
  7319.                         $this->em->flush();
  7320.                     }
  7321.                 }
  7322.                 $this->em->persist($etap);
  7323.                 $this->em->flush();
  7324.                 $this->updateStatusTracker($project); // set status tracker
  7325.                 $this->flashBag->add(
  7326.                     'success',
  7327.                     'L\'opération a Ã©té effectuée avec succès.'
  7328.                 );
  7329.                 return [
  7330.                     'etap' => $etap,
  7331.                     'success' => true
  7332.                 ];
  7333.             }
  7334.         }
  7335.         return [
  7336.             'success' => false
  7337.         ];
  7338.     }
  7339.     public function submitEtap26($request,$user)
  7340.     {
  7341.         $etapToken = $request->get('etapToken');
  7342.         $tokenProject = $request->get('tokenProject');
  7343.         $etap26Champs = $request->get('etap26Champs');
  7344.         if($etapToken and $tokenProject){
  7345.             $project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$tokenProject]);
  7346.             $etap = $this->em->getRepository(Etap26::class)->findOneBy(['token'=>$etapToken]);
  7347.             if($project && $etap){
  7348.                 if(!$this->checkUserAction($user,$project,$etap)){
  7349.                     return [
  7350.                         'success' => false
  7351.                     ];
  7352.                 }
  7353.                 if($etap26Champs) {
  7354.                     foreach ($etap26Champs as $item) {
  7355.                         if (isset($item['id']) and $item['id'] != '') {
  7356.                             $etap24ChampsEntity = $this->em->getRepository(Etap24Champs::class)->findOneBy(['token' => $item['id']]);
  7357.                             if($etap24ChampsEntity){
  7358.                                 if (isset($item['vlalorisation']) and $item['vlalorisation'] != '') {
  7359.                                     foreach ($item['vlalorisation'] as $valorisation) {
  7360.                                         if (isset($valorisation['id']) and $valorisation['id'] != '') {
  7361.                                             $etap26ChampsEntity = $this->em->getRepository(Etap26Champs::class)->findOneBy(['token' => $valorisation['id']]);
  7362.                                         }else{
  7363.                                             $etap26ChampsEntity = new Etap26Champs();
  7364.                                         }
  7365.                                         if(isset($valorisation['fileContratAchatSigneEtap25Multiple']) and $valorisation['fileContratAchatSigneEtap25Multiple'] != ''){
  7366.                                             $array = explode(',',$valorisation['fileContratAchatSigneEtap25Multiple']);
  7367.                                             foreach ($array as $item1){
  7368.                                                 $fileMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  7369.                                                 if($fileMultipleEntity){
  7370.                                                     $nomenclature = $this->getNomenclature($etap,$fileMultipleEntity,'Contrat d’achat signé');
  7371.                                                     $etap26ChampsEntity->addFileContratAchatSigneEtap25Multiple($fileMultipleEntity);
  7372.                                                 }
  7373.                                             }
  7374.                                         }
  7375.                                         if(isset($valorisation['fileAttestionProducteurEtap25Multiple']) and $valorisation['fileAttestionProducteurEtap25Multiple'] != ''){
  7376.                                             $array = explode(',',$valorisation['fileAttestionProducteurEtap25Multiple']);
  7377.                                             foreach ($array as $item1){
  7378.                                                 $fileMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  7379.                                                 if($fileMultipleEntity) {
  7380.                                                     $nomenclature = $this->getNomenclature($etap, $fileMultipleEntity, 'Attestation de producteur');
  7381.                                                     $etap26ChampsEntity->addFileAttestionProducteurEtap25Multiple($fileMultipleEntity);
  7382.                                                 }
  7383.                                             }
  7384.                                         }
  7385.                                         if(isset($valorisation['fileAttestionInstallateurEtap25Multiple']) and $valorisation['fileAttestionInstallateurEtap25Multiple'] != ''){
  7386.                                             $array = explode(',',$valorisation['fileAttestionInstallateurEtap25Multiple']);
  7387.                                             foreach ($array as $item1){
  7388.                                                 $fileMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  7389.                                                 if($fileMultipleEntity) {
  7390.                                                     $nomenclature = $this->getNomenclature($etap, $fileMultipleEntity, 'Attestation de l’installateur');
  7391.                                                     $etap26ChampsEntity->addFileAttestionInstallateurEtap25Multiple($fileMultipleEntity);
  7392.                                                 }
  7393.                                             }
  7394.                                         }
  7395.                                         if(isset($valorisation['fileArContratAchatEtap25Multiple']) and $valorisation['fileArContratAchatEtap25Multiple'] != ''){
  7396.                                             $array = explode(',',$valorisation['fileArContratAchatEtap25Multiple']);
  7397.                                             foreach ($array as $item1){
  7398.                                                 $fileMultipleEntity = $this->em->getRepository(DocUpload::class)->findOneBy(['token'=>$item1]);
  7399.                                                 if($fileMultipleEntity) {
  7400.                                                     $nomenclature = $this->getNomenclature($etap, $fileMultipleEntity, 'AR Contrat d’achat');
  7401.                                                     $etap26ChampsEntity->addFileArContratAchatEtap25Multiple($fileMultipleEntity);
  7402.                                                 }
  7403.                                             }
  7404.                                         }
  7405.                                         if(isset($valorisation['dateDebutContratAchat1']) and $valorisation['dateDebutContratAchat1'] != ''){
  7406.                                             $etap26ChampsEntity->setDateDebutContratAchat1(new \DateTime($valorisation['dateDebutContratAchat1']));
  7407.                                         }else{
  7408.                                             $etap26ChampsEntity->setDateDebutContratAchat1(null);
  7409.                                         }
  7410.                                         if(isset($valorisation['dateDebutContratAchat2']) and $valorisation['dateDebutContratAchat2'] != ''){
  7411.                                             $etap26ChampsEntity->setDateDebutContratAchat2(new \DateTime($valorisation['dateDebutContratAchat2']));
  7412.                                         }else{
  7413.                                             $etap26ChampsEntity->setDateDebutContratAchat2(null);
  7414.                                         }
  7415.                                         if(isset($valorisation['dateFinContratAchat1']) and $valorisation['dateFinContratAchat1'] != ''){
  7416.                                             $etap26ChampsEntity->setDateFinContratAchat1(new \DateTime($valorisation['dateFinContratAchat1']));
  7417.                                         }else{
  7418.                                             $etap26ChampsEntity->setDateFinContratAchat1(null);
  7419.                                         }
  7420.                                         if(isset($valorisation['dateFinContratAchat2']) and $valorisation['dateFinContratAchat2'] != ''){
  7421.                                             $etap26ChampsEntity->setDateFinContratAchat2(new \DateTime($valorisation['dateFinContratAchat2']));
  7422.                                         }else{
  7423.                                             $etap26ChampsEntity->setDateFinContratAchat2(null);
  7424.                                         }
  7425.                                         if(isset($valorisation['tarifContratAchat1']) and $valorisation['tarifContratAchat1'] != ''){
  7426.                                             $etap26ChampsEntity->setTarifContratAchat1($valorisation['tarifContratAchat1']);
  7427.                                         }else{
  7428.                                             $etap26ChampsEntity->setTarifContratAchat1(null);
  7429.                                         }
  7430.                                         if(isset($valorisation['tarifContratAchat2']) and $valorisation['tarifContratAchat2'] != ''){
  7431.                                             $etap26ChampsEntity->setTarifContratAchat2($valorisation['tarifContratAchat2']);
  7432.                                         }else{
  7433.                                             $etap26ChampsEntity->setTarifContratAchat2(null);
  7434.                                         }
  7435.                                         if(isset($valorisation['peridiciteFacturation1']) and $valorisation['peridiciteFacturation1'] != ''){
  7436.                                             $etap26ChampsEntity->setPeridiciteFacturation1($valorisation['peridiciteFacturation1']);
  7437.                                         }else{
  7438.                                             $etap26ChampsEntity->setPeridiciteFacturation1(null);
  7439.                                         }
  7440.                                         if(isset($valorisation['peridiciteFacturation2']) and $valorisation['peridiciteFacturation2'] != ''){
  7441.                                             $etap26ChampsEntity->setPeridiciteFacturation2($valorisation['peridiciteFacturation2']);
  7442.                                         }else{
  7443.                                             $etap26ChampsEntity->setPeridiciteFacturation2(null);
  7444.                                         }
  7445.                                         if(isset($valorisation['numeroContratAchat1']) and $valorisation['numeroContratAchat1'] != ''){
  7446.                                             $etap26ChampsEntity->setNumeroContratAchat1($valorisation['numeroContratAchat1']);
  7447.                                         }else{
  7448.                                             $etap26ChampsEntity->setNumeroContratAchat1(null);
  7449.                                         }
  7450.                                         if(isset($valorisation['numeroContratAchat2']) and $valorisation['numeroContratAchat2'] != ''){
  7451.                                             $etap26ChampsEntity->setNumeroContratAchat2($valorisation['numeroContratAchat2']);
  7452.                                         }else{
  7453.                                             $etap26ChampsEntity->setNumeroContratAchat2(null);
  7454.                                         }
  7455.                                         if(isset($valorisation['typeContrat1']) and $valorisation['typeContrat1'] != ''){
  7456.                                             $etap26ChampsEntity->setTypeContrat1($valorisation['typeContrat1']);
  7457.                                         }else{
  7458.                                             $etap26ChampsEntity->setTypeContrat1(null);
  7459.                                         }
  7460.                                         if(isset($valorisation['typeContrat2']) and $valorisation['typeContrat2'] != ''){
  7461.                                             $etap26ChampsEntity->setTypeContrat2($valorisation['typeContrat2']);
  7462.                                         }else{
  7463.                                             $etap26ChampsEntity->setTypeContrat2(null);
  7464.                                         }
  7465.                                         if(isset($valorisation['agregateurEtap25']) and $valorisation['agregateurEtap25'] != ''){
  7466.                                             $etap26ChampsEntity->setAgregateurEtap25($valorisation['agregateurEtap25']);
  7467.                                         }else{
  7468.                                             $etap26ChampsEntity->setAgregateurEtap25(null);
  7469.                                         }
  7470.                                         if(isset($valorisation['contrepartieEtap25']) and $valorisation['contrepartieEtap25'] != ''){
  7471.                                             $etap26ChampsEntity->setContrepartieEtap25($valorisation['contrepartieEtap25']);
  7472.                                         }else{
  7473.                                             $etap26ChampsEntity->setContrepartieEtap25(null);
  7474.                                         }
  7475.                                         $etap26ChampsEntity->setEtap24Champs($etap24ChampsEntity);
  7476.                                         $this->em->persist($etap26ChampsEntity);
  7477.                                         $this->em->flush();
  7478.                                     }
  7479.                                 }
  7480.                             }
  7481.                         }
  7482.                     }
  7483.                 }
  7484.                 $this->em->persist($etap);
  7485.                 $this->em->flush();
  7486.                 $this->updateStatusTracker($project); // set status tracker
  7487.                 $this->flashBag->add(
  7488.                     'success',
  7489.                     'L\'opération a Ã©té effectuée avec succès.'
  7490.                 );
  7491.                 return [
  7492.                     'etap' => $etap,
  7493.                     'success' => true
  7494.                 ];
  7495.             }
  7496.         }
  7497.         return [
  7498.             'success' => false
  7499.         ];
  7500.     }
  7501.     public function addUserFournisseurInProject($fournisseur){
  7502.         $name = $fournisseur->getName();
  7503.         $email = $fournisseur->getEmail();
  7504.         if(!$fournisseur->getUser()){
  7505.             if($email) {
  7506.                 $user = new User();
  7507.                 // encode the plain password
  7508.                 $password = $this->randomPassword();
  7509.                 $user->setPassword(
  7510.                     $this->passwordEncoder->encodePassword(
  7511.                         $user,
  7512.                         $password
  7513.                     )
  7514.                 );
  7515.                 $user->setRoles(array('ROLE_FOURNISSEUR'));
  7516.                 $user->setFirstname($name);
  7517.                 $user->setLastname($name);
  7518.                 $user->setEmail($email);
  7519.                 $user->setAcces(User::ACCES_ECRETURE);
  7520.                 if ($fournisseur->getId()) {
  7521.                     $user->setIsEnabled($fournisseur->getIsEnabled());
  7522.                 } else {
  7523.                     $user->setIsEnabled(true);
  7524.                 }
  7525.                 $errors = $this->validator->validate($user);
  7526.                 if (count($errors) > 0) {
  7527.                     foreach ($errors as $error) {
  7528.                         $erreurs[] = $error->getMessage();
  7529.                     }
  7530.                     return array(
  7531.                         'erreurs' => $erreurs,
  7532.                         'success' => false
  7533.                     );
  7534.                 }
  7535.                 $this->em->persist($user);
  7536.                 $this->em->flush();
  7537.                 $this->notification->createUser($user, $password);
  7538.             }else{
  7539.                 return array(
  7540.                     'success' => false,
  7541.                     'erreurs' => 'Erreur email !',
  7542.                 );
  7543.             }
  7544.         }
  7545.         return array(
  7546.             'success' => true,
  7547.             'user' => $user
  7548.         );
  7549.     }
  7550.     public function updateStatusAdministratifEngagment($project){
  7551.         if($project){
  7552.             $isGoConsultation = false;
  7553.             $isAttenteDevis = false;
  7554.             $isArbitrageDevis = false;
  7555.             $isBudgetCapex = false;
  7556.             $isContratConstruction = false;
  7557.             $isConstructionDemarree = false;
  7558.             $isConstructionAcheveeNonRaccordable = false;
  7559.             $isConstructionAcheveeARaccorder = false;
  7560.             $isConstructionAcheveeRaccordee = false;
  7561.             $isPassagedre = false;
  7562.             $isConsuelobtenu = false;
  7563.             $isOperating = false;
  7564.             $isBillable = false;
  7565.             $isInvoiced = false;
  7566.             $isOrderDemarrageEnvoye = false;
  7567.             if($project->getStadeConstruction() == 'Go consultation'){
  7568.                 $isGoConsultation = true;
  7569.             }
  7570.             if($project->getStadeConstruction() == 'Attente devis' or $project->getStadeConstruction() == 'Devis reçus' or $project->getStadeConstruction() == 'Attente validation budget/Capex' ){
  7571.                 $isAttenteDevis = true;
  7572.             }
  7573.             if($project->getStadeConstruction() == 'Arbitrage Devis'){
  7574.                 $isArbitrageDevis = true;
  7575.             }
  7576.             if($project->getStadeConstruction() == 'Devis signé' or$project->getStadeConstruction() == 'Budget/Capex validé' or $project->getStadeConstruction() == 'Contrat de construction signé' or $project->getStadeConstruction() == 'Ordre de démarrage envoyé' or $project->getStadeConstruction() == 'Travaux réceptionnés'){
  7577.                 $isBudgetCapex = true;
  7578.             }
  7579.             $etap16 = $this->em->getRepository(Etap16::class)->findOneBy(['project'=>$project->getId()]);
  7580.             if(count($etap16->getContratConstruction()) > 0){
  7581.                 foreach ($etap16->getContratConstruction() as $item){
  7582.                     if(count($item->getFileContratEpcMultiple())>0){
  7583.                         foreach ($item->getFileContratEpcMultiple() as $value){
  7584.                             if(!$value->getIsArchived()){
  7585.                                 $isContratConstruction = true;
  7586.                             }
  7587.                         }
  7588.                     }
  7589.                 }
  7590.             }
  7591.             $dateJour = new \DateTime();
  7592.             $dateNow1 = new \DateTime($dateJour->format('Y-m-d').' 23:59:59');
  7593.             $etap172 = $this->em->getRepository(Etap172::class)->findOneBy(['project'=>$project->getId()]);
  7594.             $etap173 = $this->em->getRepository(Etap173::class)->findOneBy(['project'=>$project->getId()]);
  7595.             $etap174 = $this->em->getRepository(Etap174::class)->findOneBy(['project'=>$project->getId()]);
  7596.             $etap175 = $this->em->getRepository(Etap175::class)->findOneBy(['project'=>$project->getId()]);
  7597.             $etap121 = $this->em->getRepository(Etap121::class)->findOneBy(['project'=>$project->getId()]);
  7598.             if($etap172 && $etap172->getDateDebutFondation() && ($etap172->getDateDebutFondation() <= $dateNow1) ){
  7599.                 $isConstructionDemarree = true;
  7600.             }
  7601.             if($etap173 && $etap173->getDateDebutCharpente() && ($etap173->getDateDebutCharpente() <= $dateNow1) ){
  7602.                 $isConstructionDemarree = true;
  7603.             }
  7604.             if($etap173 && $etap173->getDateDebutCouverture() && ($etap173->getDateDebutCouverture() <= $dateNow1) ){
  7605.                 $isConstructionDemarree = true;
  7606.             }
  7607.             if($etap174 && $etap174->getDateDebutPosePv() && ($etap174->getDateDebutPosePv() <= $dateNow1) ){
  7608.                 $isConstructionDemarree = true;
  7609.             }
  7610.             if($etap174 && $etap174->getDateFinPosePv() && ($etap174->getDateFinPosePv() <= $dateNow1)){
  7611.                 if($etap175 && !$etap175->getDateAchevementTraveaux()){
  7612.                     if($etap121 && !$etap121->getDateInstallationPDL()){
  7613.                         $isConstructionAcheveeNonRaccordable = true;
  7614.                     }
  7615.                     if($etap121 && (!$etap121->getDatePrevisionnelleInstallationPDL() || ($etap121->getDatePrevisionnelleInstallationPDL() < $dateNow1))){
  7616.                         $isConstructionAcheveeNonRaccordable = true;
  7617.                     }
  7618.                     if($etap121 && !$etap121->getDateMiseSousTensionEnedis()){
  7619.                         $isConstructionAcheveeNonRaccordable = true;
  7620.                     }
  7621.                 }
  7622.             }
  7623.             if($etap174 && $etap174->getDateFinPosePv() && ($etap174->getDateFinPosePv() <= $dateNow1)){
  7624.                 if($etap175 && !$etap175->getDateAchevementTraveaux()){
  7625.                     if($etap121 && $etap121->getDateInstallationPDL() && $etap121->getDateInstallationPDL() <= $dateNow1){
  7626.                         $isConstructionAcheveeARaccorder = true;
  7627.                     }
  7628.                     if($etap121 && $etap121->getDatePrevisionnelleInstallationPDL()  && $etap121->getDatePrevisionnelleInstallationPDL() <= $dateNow1){
  7629.                         $isConstructionAcheveeARaccorder = true;
  7630.                     }
  7631.                     if($etap121 && $etap121->getDateMiseSousTensionEnedis()  && $etap121->getDateMiseSousTensionEnedis() <= $dateNow1){
  7632.                         $isConstructionAcheveeARaccorder = true;
  7633.                     }
  7634.                 }
  7635.             }
  7636.             $etap175 = $this->em->getRepository(Etap175::class)->findOneBy(['project'=>$project->getId()]);
  7637.             if($etap175 && $etap175->getDateAchevementTraveaux()){
  7638.                 $isConstructionAcheveeRaccordee = true;
  7639.             }
  7640.             $etap13 = $this->em->getRepository(Etap13::class)->findOneBy(['project'=>$project->getId()]);
  7641.             $etap20 = $this->em->getRepository(Etap20::class)->findOneBy(['project'=>$project->getId()]);
  7642.             if($etap13 || $etap20){
  7643.                 if($this->checkArchiveFile($project, Etaps::ETAP_13, 'getFileDREMultiple')){
  7644.                     $isPassagedre = true;
  7645.                 }
  7646.                 if($etap13->getDateConsuel() or $this->checkArchiveFile($project, Etaps::ETAP_13, 'getFileConsuelMultiple')){
  7647.                     $isConsuelobtenu = true;
  7648.                 }
  7649.                 if($etap20->getDateConsuelEtap20() or $this->checkArchiveFile($project, Etaps::ETAP_20, 'getFileConsuelEtap20Multiple')){
  7650.                     $isConsuelobtenu = true;
  7651.                 }
  7652.             }
  7653.             if($project->getDateMiseEnService()){
  7654.                 $isOperating = true;
  7655.             }
  7656.             $etap14 = $this->em->getRepository(Etap14::class)->findOneBy(['project'=>$project->getId()]);
  7657.             if($etap13 || $etap14){
  7658.                 if((int)$project->getCapacite() > 100 && ($this->checkArchiveFile($project, Etaps::ETAP_13, 'getFileAttestationBureauControleMultiple') or $this->checkArchiveFile($project, Etaps::ETAP_14, 'getFileAttestationS21Multiple'))){
  7659.                     $isBillable = true;
  7660.                 }
  7661.             }
  7662. //            $etap15 = $this->em->getRepository(Etap15::class)->findOneBy(['project'=>$project->getId()]);
  7663. //            if($etap15 && $this->checkArchiveFile($project, Etaps::ETAP_15, 'getFileContratAchatSigneMultiple')){
  7664. //                $isInvoiced = true;
  7665. //            }
  7666.             $etap24 = $this->em->getRepository(Etap24::class)->findOneBy(['project'=>$project->getId()]);
  7667.             if($etap24 && count($etap24->getEtap24Champs()) > 0){
  7668.                 $notEmpty = false  ;
  7669.                 foreach ($etap24->getEtap24Champs() as $champ){
  7670.                     if(count($champ->getEtap26Champs()) > 0){
  7671.                         foreach ($champ->getEtap26Champs() as $champ26){
  7672.                             if(count($champ26->getFileContratAchatSigneEtap25Multiple()) > 0){
  7673.                                 foreach ($champ26->getFileContratAchatSigneEtap25Multiple() as $doc){
  7674.                                     if(!$doc->getIsArchived()){
  7675.                                         $notEmpty = true  ;
  7676.                                     }
  7677.                                 }
  7678.                             }
  7679.                         }
  7680.                     }
  7681.                 }
  7682.                 if($notEmpty){
  7683.                     $isInvoiced = true;
  7684.                 }
  7685.             }
  7686.             $etap171 = $this->em->getRepository(Etap171::class)->findOneBy(['project'=>$project->getId()]);
  7687.             if($etap171 && $this->checkArchiveFile($project, Etaps::ETAP_171, 'getFileOrderServiceMultiple')){
  7688.                 $isOrderDemarrageEnvoye = true;
  7689.             }
  7690.             $status = 0;
  7691.             if($isInvoiced){
  7692.                 $status = StatusTrackerConstruction::Invoiced;
  7693.             }elseif ($isBillable) {
  7694.                 $status = StatusTrackerConstruction::Billable;
  7695.             }elseif ($isOperating) {
  7696.                 $status = StatusTrackerConstruction::Operating;
  7697.             }elseif ($isConsuelobtenu) {
  7698.                 $status = StatusTrackerConstruction::Consuel_obtenu;
  7699.             }elseif ($isPassagedre) {
  7700.                 $status = StatusTrackerConstruction::Passage_dre;
  7701.             }elseif ($isConstructionAcheveeRaccordee) {
  7702.                 $status = StatusTrackerConstruction::Construction_Achevee_Raccordee;
  7703.             }elseif ($isConstructionAcheveeARaccorder) {
  7704.                 $status = StatusTrackerConstruction::Construction_Achevee_A_Raccorder;
  7705.             }elseif ($isConstructionAcheveeNonRaccordable) {
  7706.                 $status = StatusTrackerConstruction::Construction_Achevee_Non_Raccordable;
  7707.             }elseif ($isConstructionDemarree) {
  7708.                 $status = StatusTrackerConstruction::Construction_Demarree;
  7709.             }elseif ($isOrderDemarrageEnvoye) {
  7710.                 $status = StatusTrackerConstruction::Order_demarrage_envoye;
  7711.             }elseif ($isContratConstruction) {
  7712.                 $status = StatusTrackerConstruction::Contrat_Construction;
  7713.             }elseif ($isBudgetCapex) {
  7714.                 $status = StatusTrackerConstruction::Budget_Capex;
  7715.             }elseif ($isArbitrageDevis) {
  7716.                 $status = StatusTrackerConstruction::Arbitrage_Devis;
  7717.             }elseif ($isAttenteDevis) {
  7718.                 $status = StatusTrackerConstruction::Attente_Devis;
  7719.             }elseif ($isGoConsultation) {
  7720.                 $status = StatusTrackerConstruction::Go_Consultation;
  7721.             }
  7722.             $statusTracker = $project->getStatusTrackerActuel();
  7723.             if($statusTracker == StatusTracker::STATUS_dev_4){
  7724.                 if(in_array($status ,[StatusTrackerConstruction::Construction_Achevee_Non_Raccordable,StatusTrackerConstruction::Construction_Achevee_A_Raccorder,StatusTrackerConstruction::Construction_Achevee_Raccordee,StatusTrackerConstruction::Passage_dre])){
  7725.                 }else{
  7726.                     $status = StatusTrackerConstruction::Construction_Demarree;
  7727.                 }
  7728.             }elseif ($statusTracker == StatusTracker::STATUS_dev_5){
  7729.                 if(in_array($status ,[StatusTrackerConstruction::Construction_Achevee_Non_Raccordable,StatusTrackerConstruction::Construction_Achevee_A_Raccorder,StatusTrackerConstruction::Construction_Achevee_Raccordee,StatusTrackerConstruction::Passage_dre])){
  7730.                 }else{
  7731.                     $status = StatusTrackerConstruction::Construction_Achevee_Non_Raccordable;
  7732.                 }
  7733.             }
  7734.             elseif ($statusTracker == StatusTracker::STATUS_dev_6){
  7735.                 $status = StatusTrackerConstruction::Consuel_obtenu;
  7736.             }
  7737.             elseif ($statusTracker == StatusTracker::STATUS_operating){
  7738.                 if(in_array($status ,[StatusTrackerConstruction::Operating,StatusTrackerConstruction::Billable,StatusTrackerConstruction::Invoiced])){
  7739.                 }else{
  7740.                     $status = StatusTrackerConstruction::Operating;
  7741.                 }
  7742.             }
  7743.             $statusTrackerProjectConstruction = $this->em->getRepository(StatusTrackerConstruction::class)->findOneBy(['project'=>$project->getId()],['createdAt'=>'desc']);
  7744.             if($statusTrackerProjectConstruction){
  7745.                 if($statusTrackerProjectConstruction->getStatus() != $status){
  7746.                     $entity = new StatusTrackerConstruction();
  7747.                     $entity->setProject($project);
  7748.                     $entity->setStatus($status);
  7749.                     $this->em->persist($entity);
  7750.                     $project->setStatusTrackerActuelConstruction($status);
  7751.                     $this->em->persist($project);
  7752.                     $this->em->flush();
  7753.                 }
  7754.             }else{
  7755.                 $entity = new StatusTrackerConstruction();
  7756.                 $entity->setProject($project);
  7757.                 $entity->setStatus($status);
  7758.                 $this->em->persist($entity);
  7759.                 $project->setStatusTrackerActuelConstruction($status);
  7760.                 $this->em->persist($project);
  7761.                 $this->em->flush();
  7762.             }
  7763.         }
  7764.     }
  7765. }