<?php
/**
* Created by PhpStorm.
*/
namespace App\Services;
use App\Entity\DocUpload;
use App\Entity\DocUploadPartageProject;
use App\Entity\Etap1;
use App\Entity\Etap10;
use App\Entity\Etap11;
use App\Entity\Etap12;
use App\Entity\Etap13;
use App\Entity\Etap14;
use App\Entity\Etap15;
use App\Entity\Etap159;
use App\Entity\Etap16;
use App\Entity\Etap160;
use App\Entity\Etap161;
use App\Entity\Etap17;
use App\Entity\Etap171;
use App\Entity\Etap172;
use App\Entity\Etap173;
use App\Entity\Etap174;
use App\Entity\Etap175;
use App\Entity\Etap18;
use App\Entity\Etap19;
use App\Entity\Etap2;
use App\Entity\Etap20;
use App\Entity\Etap201;
use App\Entity\Etap21;
use App\Entity\Etap22;
use App\Entity\Etap23;
use App\Entity\Etap3;
use App\Entity\Etap4;
use App\Entity\Etap5;
use App\Entity\Etap6;
use App\Entity\Etap7;
use App\Entity\Etap8;
use App\Entity\Etap9;
use App\Entity\ImfomationContratAchat;
use App\Entity\Project;
use App\Entity\User;
use App\Form\UserType;
use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxApp;
use Kunnu\Dropbox\Exceptions\DropboxClientException;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Twig\Environment;
use App\Entity\Centrale;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class UploadService
{
private $em;
private $trans;
private $params;
private $security;
private $session;
private $twig;
private $notification;
public function __construct(
Environment $twig,
SessionInterface $session,
Security $security,
ParameterBagInterface $params,
EntityManagerInterface $em,
TranslatorInterface $trans,
ValidatorInterface $validator,
FlashBagInterface $flashBag,
UserPasswordEncoderInterface $passwordEncoder,
Notifications $notifications,
FormFactoryInterface $form
) {
$this->em = $em;
$this->trans = $trans;
$this->params = $params;
$this->security = $security;
$this->session = $session;
$this->twig = $twig;
$this->validator = $validator;
$this->form = $form;
$this->flashBag = $flashBag;
$this->passwordEncoder = $passwordEncoder;
$this->notification = $notifications;
}
public function upload(UploadedFile $file)
{
set_time_limit(0);
if (is_object($file)) {
$filenameGenerate = $this->generateUniqueFileName();
$fileName = $filenameGenerate . '.' . $file->guessExtension();
if($file->guessExtension() == 'bin'){
$fileName = $filenameGenerate . '.' . $file->getClientOriginalName();
}
$file->move($this->params->get('uploads_directory'), $fileName);
$docUpload = new DocUpload();
$docUpload->setName($file->getClientOriginalName());
$docUpload->setPath($fileName);
$docUpload->setUserCreated($this->security->getUser());
$this->em->persist($docUpload);
$this->em->flush();
return array('token' => $docUpload->getToken(), 'filename' => $docUpload->getName());
}
return false;
}
public function removeFile($file){
if(is_object($file)) {
if ($file->getPath() and trim($file->getPath()) != '') {
$this->deleteFileToDropbox($file);
$filePath = $this->params->get('uploads_directory') . '/' . $file->getPath();
if (file_exists($filePath)) unlink($filePath);
}
$this->em->remove($file);
$this->em->flush();
}
}
public function archiveFile($file){
if(is_object($file)) {
$file->setIsArchived(true);
$this->em->persist($file);
$this->em->flush();
}
}
public function removeFilePartage($file){
if(is_object($file)) {
if ($file->getDoc()->getPath() and trim($file->getDoc()->getPath()) != '') {
$filePath = $this->params->get('uploads_directory') . '/' . $file->getDoc()->getPath();
if (file_exists($filePath)) unlink($filePath);
}
$this->em->remove($file->getDoc());
$this->em->remove($file);
$this->em->flush();
}
}
public function getFilesPorjectPartage($project){
if(is_object($project)) {
$docs = $this->em->getRepository(DocUploadPartageProject::class)->findBy(['project'=>$project->getId()]);
return $docs;
}
return false;
}
public function generateUniqueFileName() {
return md5(uniqid());
}
public function exportZip($token){
$project = $this->em->getRepository(Project::class)->findOneBy(['token'=>$token]);
if($project){
$etap1 = $this->em->getRepository(Etap1::class)->findOneBy(['project'=>$project->getId()]);
$etap2 = $this->em->getRepository(Etap2::class)->findOneBy(['project'=>$project->getId()]);
$etap3 = $this->em->getRepository(Etap3::class)->findOneBy(['project'=>$project->getId()]);
$etap4 = $this->em->getRepository(Etap4::class)->findOneBy(['project'=>$project->getId()]);
$etap5 = $this->em->getRepository(Etap5::class)->findOneBy(['project'=>$project->getId()]);
$etap6 = $this->em->getRepository(Etap6::class)->findOneBy(['project'=>$project->getId()]);
$etap7 = $this->em->getRepository(Etap7::class)->findOneBy(['project'=>$project->getId()]);
$etap8 = $this->em->getRepository(Etap8::class)->findOneBy(['project'=>$project->getId()]);
$etap9 = $this->em->getRepository(Etap9::class)->findOneBy(['project'=>$project->getId()]);
$etap10 = $this->em->getRepository(Etap10::class)->findOneBy(['project'=>$project->getId()]);
$etap11 = $this->em->getRepository(Etap11::class)->findOneBy(['project'=>$project->getId()]);
$etap12 = $this->em->getRepository(Etap12::class)->findOneBy(['project'=>$project->getId()]);
$etap13 = $this->em->getRepository(Etap13::class)->findOneBy(['project'=>$project->getId()]);
$etap14 = $this->em->getRepository(Etap14::class)->findOneBy(['project'=>$project->getId()]);
$etap15 = $this->em->getRepository(Etap15::class)->findOneBy(['project'=>$project->getId()]);
$etap16 = $this->em->getRepository(Etap16::class)->findOneBy(['project'=>$project->getId()]);
$etap17 = $this->em->getRepository(Etap17::class)->findOneBy(['project'=>$project->getId()]);
$etap18 = $this->em->getRepository(Etap18::class)->findOneBy(['project'=>$project->getId()]);
$etap19 = $this->em->getRepository(Etap19::class)->findOneBy(['project'=>$project->getId()]);
$etap20 = $this->em->getRepository(Etap20::class)->findOneBy(['project'=>$project->getId()]);
$etap201 = $this->em->getRepository(Etap201::class)->findOneBy(['project'=>$project->getId()]);
$etap21 = $this->em->getRepository(Etap21::class)->findOneBy(['project'=>$project->getId()]);
$etap22 = $this->em->getRepository(Etap22::class)->findOneBy(['project'=>$project->getId()]);
$etap160 = $this->em->getRepository(Etap160::class)->findOneBy(['project'=>$project->getId()]);
$etap161 = $this->em->getRepository(Etap161::class)->findOneBy(['project'=>$project->getId()]);
$etap171 = $this->em->getRepository(Etap171::class)->findOneBy(['project'=>$project->getId()]);
$etap172 = $this->em->getRepository(Etap172::class)->findOneBy(['project'=>$project->getId()]);
$etap173 = $this->em->getRepository(Etap173::class)->findOneBy(['project'=>$project->getId()]);
$etap174 = $this->em->getRepository(Etap174::class)->findOneBy(['project'=>$project->getId()]);
$etap175 = $this->em->getRepository(Etap175::class)->findOneBy(['project'=>$project->getId()]);
//Présentation générale
$fileEtudeProductibleName = 'Présentation générale/Étude de productible/';
$fileEtudeProductiblePath = null;
if($project->getFileEtudeProductible()){
$extension = substr($project->getFileEtudeProductible()->getPath(), strrpos($project->getFileEtudeProductible()->getPath(), ".",-1) + 1);
$fileEtudeProductibleName = 'Présentation générale/Étude de productible/'.$project->getName().' - '.$project->getSpv().' - Étude de productible.'.$extension;
$fileEtudeProductiblePath = $this->params->get('uploads_directory').'/'.$project->getFileEtudeProductible()->getPath();
}
$filePromessebailProjectName = 'Présentation générale/Promesse de bail/';
$filePromessebailProjectPath = null;
if($project->getFilePromessebail()){
$extension = substr($project->getFilePromessebail()->getPath(), strrpos($project->getFilePromessebail()->getPath(), ".",-1) + 1);
$filePromessebailProjectName = 'Présentation générale/Promesse de bail/'.$project->getName().' - '.$project->getSpv().' - Promesse de bail.'.$extension;
$filePromessebailProjectPath = $this->params->get('uploads_directory').'/'.$project->getFilePromessebail()->getPath();
}
$fileDocCompementaireName = 'Présentation générale/Visite Technique devéloppeur/';
$arrayDocCompementairePath = [];
if(count($project->getFileDocCompementaire())>0){
foreach ($project->getFileDocCompementaire() as $key => $item){
$extension = substr($item->getPath(), strrpos($item->getPath(), ".",-1) + 1);
$arrayDocCompementairePath[$item->getId()]['name'] = 'Présentation générale/Visite Technique devéloppeur/'.$key.' - '.$project->getName().' - '.$project->getSpv().' - Visite Technique devéloppeur.'.$extension;
$arrayDocCompementairePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
//Urbanisme
$fileDossierPcDpName = 'Urbanisme/Dossier PC/';
$fileDossierPcDpPath = [];
if(count($etap1->getFileDossierPcDpMultiple()) > 0){
foreach ($etap1->getFileDossierPcDpMultiple() as $key => $item){
$fileDossierPcDpPath[$item->getId()]['name'] = 'Urbanisme/Dossier PC/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileDossierPcDpPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileArretePcDpName = 'Urbanisme/Arrêté PC/';
$fileArretePcDpPath = [];
if(count($etap1->getFileArretePcDpMultiple()) > 0){
foreach ($etap1->getFileArretePcDpMultiple() as $key => $item){
$fileArretePcDpPath[$item->getId()]['name'] = 'Urbanisme/Arrêté PC/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileArretePcDpPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$filePVPassageHuissierName = 'Urbanisme/PV passage huissier/';
$filePVPassageHuissierPath = [];
if(count($etap2->getFilePVPassageHuissierMultiple()) > 0){
foreach ($etap2->getFilePVPassageHuissierMultiple() as $key => $item){
$filePVPassageHuissierPath[$item->getId()]['name'] = 'Urbanisme/PV passage huissier/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$filePVPassageHuissierPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileCertificatNonRecoursName = 'Urbanisme/Certificat de non-recours (Tribunal Administratif)/';
$fileCertificatNonRecoursPath = [];
if(count($etap2->getFileCertificatNonRecoursMultiple()) > 0){
foreach ($etap2->getFileCertificatNonRecoursMultiple() as $key => $item){
$fileCertificatNonRecoursPath[$item->getId()]['name'] = 'Urbanisme/Certificat de non-recours (Tribunal Administratif)/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileCertificatNonRecoursPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileCertificatNonOppositionName = 'Urbanisme/Certificat de non opposition/';
$fileCertificatNonOppositionPath = [];
if(count($etap1->getFileCertificatNonOppositionEtap1Multiple()) > 0){
foreach ($etap1->getFileCertificatNonOppositionEtap1Multiple() as $key => $item){
$fileCertificatNonOppositionPath[$item->getId()]['name'] = 'Urbanisme/Certificat de non opposition/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileCertificatNonOppositionPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileCertificatNonRetraitName = 'Urbanisme/Certificat de non retrait/';
$fileCertificatNonRetraitPath = [];
if(count($etap2->getFileCertificatNonRetraitMultiple()) > 0){
foreach ($etap2->getFileCertificatNonRetraitMultiple() as $key => $item){
$fileCertificatNonRetraitPath[$item->getId()]['name'] = 'Urbanisme/Certificat de non opposition/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileCertificatNonRetraitPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileDocDrocName = 'Urbanisme/DROC - DOC/';
$fileDocDrocPath = [];
if(count($etap3->getFileDocDrocMultiple()) > 0){
foreach ($etap3->getFileDocDrocMultiple() as $key => $item){
$fileDocDrocPath[$item->getId()]['name'] = 'Urbanisme/DROC - DOC/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileDocDrocPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileDaactName = 'Urbanisme/DAACT/';
$fileDaactPath = [];
if(count($etap4->getFileDaactMultiple()) > 0){
foreach ($etap4->getFileDaactMultiple() as $key => $item){
$fileDaactPath[$item->getId()]['name'] = 'Urbanisme/DAACT/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileDaactPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
//foncier
$filePromessebailName = 'Maitrise foncière/Promesse de bail/';
$filePromessebailPath = [];
if(count($etap5->getFilePromessebailMultiple()) > 0){
foreach ($etap5->getFilePromessebailMultiple() as $key => $item){
$filePromessebailPath[$item->getId()]['name'] = 'Maitrise foncière/Promesse de bail/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$filePromessebailPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileEtatDecriptifName = 'Maitrise foncière/Etat Descriptif de Division volumétrique/';
$fileEtatDecriptifPath = [];
if(count($etap6->getFileEtatDecriptifMultiple()) > 0){
foreach ($etap6->getFileEtatDecriptifMultiple() as $key => $item){
$fileEtatDecriptifPath[$item->getId()]['name'] = 'Maitrise foncière/Etat Descriptif de Division volumétrique/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileEtatDecriptifPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileEtatHypothecaireName = 'Maitrise foncière/Etat hypothécaire/';
$fileEtatHypothecairePath = [];
if(count($etap6->getFileEtatHypothecaireMultiple()) > 0){
foreach ($etap6->getFileEtatHypothecaireMultiple() as $key => $item){
$fileEtatHypothecairePath[$item->getId()]['name'] = 'Maitrise foncière/Etat hypothécaire/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileEtatHypothecairePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$filePublicationSPRName = 'Maitrise foncière/Publication SPF/';
$filePublicationSPRPath = [];
if(count($etap6->getFilePublicationSPRMultiple()) > 0){
foreach ($etap6->getFilePublicationSPRMultiple() as $key => $item){
$filePublicationSPRPath[$item->getId()]['name'] = 'Maitrise foncière/Publication SPF/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$filePublicationSPRPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileTitreProprieteName = 'Maitrise foncière/Titre de propriété/';
$fileTitreProprietePath = [];
if(count($etap6->getFileTitreProprieteMultiple()) > 0){
foreach ($etap6->getFileTitreProprieteMultiple() as $key => $item){
$fileTitreProprietePath[$item->getId()]['name'] = 'Maitrise foncière/Titre de propriété/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileTitreProprietePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileAutreEtap6Name = 'Maitrise foncière/Autres (Cession de bail, projet de bail…)/';
$arrayAutreEtap6Path = [];
if(count($etap6->getFileAutreEtap6())>0){
foreach ($etap6->getFileAutreEtap6() as $key => $item){
$arrayAutreEtap6Path[$item->getId()]['name'] = 'Maitrise foncière/Autres (Cession de bail, projet de bail…)/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$arrayAutreEtap6Path[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileProcurationBailleurName = 'Maitrise foncière/Procuration Bailleur/';
$arrayProcurationBailleurPath = [];
if(count($etap6->getFileProcurationBailleur())>0){
foreach ($etap6->getFileProcurationBailleur() as $key => $item){
$arrayProcurationBailleurPath[$item->getId()]['name'] = 'Maitrise foncière/Procuration Bailleur/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$arrayProcurationBailleurPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileBailSigneName = 'Maitrise foncière/Bail signé/';
$fileBailSignePath = [];
if(count($etap7->getFileBailSigneMultiple()) > 0){
foreach ($etap7->getFileBailSigneMultiple() as $key => $item){
$fileBailSignePath[$item->getId()]['name'] = 'Maitrise foncière/Bail signé/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileBailSignePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileAvenantBailName = 'Maitrise foncière/Avenant au Bail/';
$fileAvenantBailPath = [];
if(count($etap7->getFileAvenantBailMultiple()) > 0){
foreach ($etap7->getFileAvenantBailMultiple() as $key => $item){
$fileAvenantBailPath[$item->getId()]['name'] = 'Maitrise foncière/Avenant au Bail/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileAvenantBailPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
//Raccordement ENEDIS
$fileKbisEtsName = 'Raccordement ENEDIS/Kibis/';
$fileKbisEtsPath = [];
if(count($etap8->getFileKbisEtsMultiple()) > 0){
foreach ($etap8->getFileKbisEtsMultiple() as $key => $item){
$fileKbisEtsPath[$item->getId()]['name'] = 'Raccordement ENEDIS/Kibis/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileKbisEtsPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
};
}
$fileMailEnedisConfirmationName = 'Raccordement ENEDIS/Mail d’ENEDIS de confirmation/';
$fileMailEnedisConfirmationPath = [];
if(count($etap9->getFileMailEnedisConfirmationMultiple()) > 0){
foreach ($etap9->getFileMailEnedisConfirmationMultiple() as $key => $item){
$fileMailEnedisConfirmationPath[$item->getId()]['name'] = 'Raccordement ENEDIS/Mail d’ENEDIS de confirmation/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileMailEnedisConfirmationPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$filePtfName = 'Raccordement ENEDIS/PTF/';
$filePtfPath = [];
if(count($etap10->getFilePtfMultiple()) > 0){
foreach ($etap10->getFilePtfMultiple() as $key => $item){
$filePtfPath[$item->getId()]['name'] = 'Raccordement ENEDIS/PTF/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$filePtfPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileCrdSigneeName = 'Raccordement ENEDIS/CRD signée/';
$fileCrdSigneePath = [];
if(count($etap10->getFileCrdSigneeMultiple()) > 0){
foreach ($etap10->getFileCrdSigneeMultiple() as $key => $item){
$fileCrdSigneePath[$item->getId()]['name'] = 'Raccordement ENEDIS/CRD signée/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileCrdSigneePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}elseif(count($etap10->getFileCrdSigneeSansPtfMultiple()) > 0){
foreach ($etap10->getFileCrdSigneeSansPtfMultiple() as $key => $item){
$fileCrdSigneePath[$item->getId()]['name'] = 'Raccordement ENEDIS/CRD signée/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileCrdSigneePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$filePreuveVirementName = 'Raccordement ENEDIS/Preuve de virement/';
$filePreuveVirementPath = [];
if(count($etap10->getFilePreuveVirementMultiple()) > 0){
foreach ($etap10->getFilePreuveVirementMultiple() as $key => $item){
$filePreuveVirementPath[$item->getId()]['name'] = 'Raccordement ENEDIS/Preuve de virement/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$filePreuveVirementPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}elseif(count($etap10->getFilePreuveVirementSansPtfMultiple()) > 0){
foreach ($etap10->getFilePreuveVirementSansPtfMultiple() as $key => $item){
$filePreuveVirementPath[$item->getId()]['name'] = 'Raccordement ENEDIS/Preuve de virement/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$filePreuveVirementPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileCexSigneName = 'Raccordement ENEDIS/CEX signé/';
$fileCexSignePath = [];
if(count($etap12->getFileCexSigneMultiple()) > 0){
foreach ($etap12->getFileCexSigneMultiple() as $key => $item){
$fileCexSignePath[$item->getId()]['name'] = 'Raccordement ENEDIS/CEX signé/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileCexSignePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileCardiSigneName = 'Raccordement ENEDIS/CARDi signé/';
$fileCardiSignePath = [];
if(count($etap12->getFileCardiSigneMultiple()) > 0){
foreach ($etap12->getFileCardiSigneMultiple() as $key => $item){
$fileCardiSignePath[$item->getId()]['name'] = 'Raccordement ENEDIS/CARDi signé/'.($item->getNomenclature()? $key.' - '. $item->getNomenclature(): $item->getPath());
$fileCardiSignePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileConsuelName = 'Raccordement ENEDIS/Consuel/';
$fileConsuelPath = [];
if(count($etap13->getFileConsuelMultiple()) > 0){
foreach ($etap13->getFileConsuelMultiple() as $key => $item){
$fileConsuelPath[$item->getId()]['name'] = 'Raccordement ENEDIS/Consuel/'.($item->getNomenclature()? $key.' - '. $item->getNomenclature(): $item->getPath());
$fileConsuelPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileDREName = 'Raccordement ENEDIS/DRE/';
$fileDREPath = [];
if(count($etap13->getFileDREMultiple()) > 0){
foreach ($etap13->getFileDREMultiple() as $key => $item){
$fileDREPath[$item->getId()]['name'] = 'Raccordement ENEDIS/DRE/'.($item->getNomenclature()? $key.' - '. $item->getNomenclature(): $item->getPath());
$fileDREPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileAttestationBureauControleMultipleName = 'Raccordement ENEDIS/Attestation bureau de contrôle S21/';
$fileAttestationBureauControleMultiplePath = [];
if(count($etap13->getFileAttestationBureauControleMultiple()) > 0){
foreach ($etap13->getFileAttestationBureauControleMultiple() as $key => $item){
$fileAttestationBureauControleMultiplePath[$item->getId()]['name'] = 'Raccordement ENEDIS/Attestation bureau de contrôle S21/'.($item->getNomenclature()? $key.' - '. $item->getNomenclature(): $item->getPath());
$fileAttestationBureauControleMultiplePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileDoeName = 'Raccordement ENEDIS/DOE/';
$fileDoePath = [];
if(count($etap14->getFileDoeMultiple()) > 0){
foreach ($etap14->getFileDoeMultiple() as $key => $item){
$fileDoePath[$item->getId()]['name'] = 'Raccordement ENEDIS/Attestation de mise en service /'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileDoePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileContratAchatSigneName = 'Raccordement ENEDIS/Contrat d’achat signé/';
$fileContratAchatSignePath = [];
if(count($etap15->getFileContratAchatSigneMultiple()) > 0){
foreach ($etap15->getFileContratAchatSigneMultiple() as $key => $item){
$fileContratAchatSignePath[$item->getId()]['name'] = 'Raccordement ENEDIS/Contrat d’achat signé/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileContratAchatSignePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileAttestionProducteurName = 'Raccordement ENEDIS/Attestation de producteur/';
$fileAttestionProducteurPath = [];
if(count($etap15->getFileAttestionProducteurMultiple()) > 0){
foreach ($etap15->getFileAttestionProducteurMultiple() as $key => $item){
$fileAttestionProducteurPath[$item->getId()]['name'] = 'Raccordement ENEDIS/Attestation de producteur/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileAttestionProducteurPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileAttestionInstallateurName = 'Raccordement ENEDIS/Attestation de l’installateur/';
$fileAttestionInstallateurPath = [];
if(count($etap15->getFileAttestionInstallateurMultiple()) > 0){
foreach ($etap15->getFileAttestionInstallateurMultiple() as $key => $item){
$fileAttestionInstallateurPath[$item->getId()]['name'] = 'Raccordement ENEDIS/Attestation de l’installateur/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileAttestionInstallateurPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$user = $this->security->getUser();
//Contrats de development et construction
$fileContratEpcName = 'Contrats de development et construction/Contrat de construction/';
$fileContratEpcPath = [];
if($user and (!in_array('ROLE_DEV',$user->getRoles()) or !in_array('ROLE_EPC',$user->getRoles()))) {
if(count($etap16->getFileContratEpcMultiple()) > 0){
foreach ($etap16->getFileContratEpcMultiple() as $key => $item){
$fileContratEpcPath[$item->getId()]['name'] = 'Contrats de development et construction/Contrat de construction/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileContratEpcPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
}
$fileAnnexesName = 'Contrats de development et construction/Annexes (fiches techniques…)/';
$fileAnnexesPath =[];
if($user and (!in_array('ROLE_DEV',$user->getRoles()) or !in_array('ROLE_EPC',$user->getRoles()))) {
if(count($etap16->getFileAnnexesMultiple()) > 0){
foreach ($etap16->getFileAnnexesMultiple() as $key => $item){
$fileAnnexesPath[$item->getId()]['name'] = 'Contrats de development et construction/Annexes/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$fileAnnexesPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
}
$fileDocumentGeometreName = 'Contrats de development et construction/Documents de géomètre/';
$arrayDocumentGeometrePath = [];
if(count($etap17->getFileDocumentGeometre())>0){
foreach ($etap17->getFileDocumentGeometre() as $key => $item){
$arrayDocumentGeometrePath[$item->getId()]['name'] = 'Contrats de development et construction/Documents de géomètre/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$arrayDocumentGeometrePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$filePlanExecutionName = 'Contrats de development et construction/Plan exécution et étude de structure/';
$arrayPlanExecutionPath = [];
if(count($etap17->getFilePlanExecution())>0){
foreach ($etap17->getFilePlanExecution() as $key => $item){
$arrayPlanExecutionPath[$item->getId()]['name'] = 'Contrats de development et construction/Plan exécution et étude de structure/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$arrayPlanExecutionPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$filePhotosFondationName = 'Contrats de development et construction/Photos des fondations/';
$arrayPhotosFondationPath = [];
if(count($etap18->getFilePhotosFondation())>0){
foreach ($etap18->getFilePhotosFondation() as $key => $item){
$arrayPhotosFondationPath[$item->getId()]['name'] = 'Contrats de development et construction/Photos des fondations/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$arrayPhotosFondationPath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$filePhotosBatimentName = 'Contrats de development et construction/Photos du bâtiment/';
$filePhotosBatimentPath = null;
if($etap19->getFilePhotosBatiment()){
$filePhotosBatimentName = 'Contrats de development et construction/Photos du bâtiment/'.($etap19->getFilePhotosBatiment()->getNomenclature()? $etap19->getFilePhotosBatiment()->getNomenclature(): $etap19->getFilePhotosBatiment()->getPath());
$filePhotosBatimentPath = $this->params->get('uploads_directory').'/'.$etap19->getFilePhotosBatiment()->getPath();
}
// $fileConsuelEtap20Name = 'Contrats de development et construction/Consuel Etap 5/';
// $fileConsuelEtap20Path = null;
// if($etap20->getFileConsuelEtap20()){
// $fileConsuelEtap20Name = 'Contrats de development et construction/Consuel Etap 5/'.($etap20->getFileConsuelEtap20()->getNomenclature()? $etap20->getFileConsuelEtap20()->getNomenclature(): $etap20->getFileConsuelEtap20()->getPath());
// $fileConsuelEtap20Path = $this->params->get('uploads_directory').'/'.$etap20->getFileConsuelEtap20()->getPath();
// }
$fileTestReceptionName = 'Contrats de development et construction/Tests de réception/';
$fileTestReceptionPath = [];
if(count($etap21->getFileTestReceptionMultiple())>0){
foreach ($etap21->getFileTestReceptionMultiple() as $key => $item){
$arrayTestReceptionMultiplePath[$item->getId()]['name'] = 'Contrats de development et construction/Tests de réception/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$arrayTestReceptionMultiplePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$fileTestPrName = 'Contrats de development et construction/Tests de PR/';
$fileTestPrPath = [];
if(count($etap22->getFileTestPrMultiple())>0){
foreach ($etap22->getFileTestPrMultiple() as $key => $item){
$arrayTestPrMultiplePath[$item->getId()]['name'] = 'Contrats de development et construction/Tests de PR/'.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$arrayTestPrMultiplePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
$zip = new \ZipArchive();
$zipfile = $this->params->get('zips_directory') . '/project-' . $project->getName() .'.zip';
if (file_exists($zipfile)) unlink($zipfile);
if ($zip->open($zipfile, \ZipArchive::CREATE) === TRUE) {
//project
$fileEtudeProductiblePath ? $zip->addFile($fileEtudeProductiblePath,$fileEtudeProductibleName):$zip->addEmptyDir($fileEtudeProductibleName);
$filePromessebailProjectPath ? $zip->addFile($filePromessebailProjectPath,$filePromessebailProjectName):$zip->addEmptyDir($filePromessebailProjectName);
if(count($arrayDocCompementairePath)>0){
foreach ($arrayDocCompementairePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileDocCompementaireName);
}
//urbanisme
if(count($fileDossierPcDpPath)>0){
foreach ($fileDossierPcDpPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileDossierPcDpName);
}
if(count($fileArretePcDpPath)>0){
foreach ($fileArretePcDpPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileArretePcDpName);
}
if(count($fileCertificatNonRecoursPath)>0){
foreach ($fileCertificatNonRecoursPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileCertificatNonRecoursName);
}
if(count($fileCertificatNonOppositionPath)>0){
foreach ($fileCertificatNonOppositionPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileCertificatNonOppositionName);
}
if(count($fileCertificatNonRetraitPath)>0){
foreach ($fileCertificatNonRetraitPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileCertificatNonRetraitName);
}
if(count($fileDocDrocPath)>0){
foreach ($fileDocDrocPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileDocDrocName);
}
if(count($filePVPassageHuissierPath)>0){
foreach ($filePVPassageHuissierPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($filePVPassageHuissierName);
}
if(count($fileDaactPath)>0){
foreach ($fileDaactPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileDaactName);
}
//foncier
if(count($filePromessebailPath)>0){
foreach ($filePromessebailPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($filePromessebailName);
}
if(count($fileBailSignePath)>0){
foreach ($fileBailSignePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileBailSigneName);
}
if(count($fileAvenantBailPath)>0){
foreach ($fileAvenantBailPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileAvenantBailName);
}
if(count($fileEtatDecriptifPath)>0){
foreach ($fileEtatDecriptifPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileEtatDecriptifName);
}
if(count($fileEtatHypothecairePath)>0){
foreach ($fileEtatHypothecairePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileEtatHypothecaireName);
}
if(count($filePublicationSPRPath)>0){
foreach ($filePublicationSPRPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($filePublicationSPRName);
}
if(count($fileTitreProprietePath)>0){
foreach ($fileTitreProprietePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileTitreProprieteName);
}
if(count($arrayAutreEtap6Path)>0){
foreach ($arrayAutreEtap6Path as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileAutreEtap6Name);
}
if(count($arrayProcurationBailleurPath)>0){
foreach ($arrayProcurationBailleurPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileProcurationBailleurName);
}
// Raccordement
if(count($fileKbisEtsPath)>0){
foreach ($fileKbisEtsPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileKbisEtsName);
}
if(count($fileMailEnedisConfirmationPath)>0){
foreach ($fileMailEnedisConfirmationPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileMailEnedisConfirmationName);
}
if(count($filePtfPath)>0){
foreach ($filePtfPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($filePtfName);
}
if(count($filePreuveVirementPath)>0){
foreach ($filePreuveVirementPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($filePreuveVirementName);
}
if(count($fileCrdSigneePath)>0){
foreach ($fileCrdSigneePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileCrdSigneeName);
}
if(count($fileCexSignePath)>0){
foreach ($fileCexSignePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileCexSigneName);
}
if(count($fileCardiSignePath)>0){
foreach ($fileCardiSignePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileCardiSigneName);
}
if(count($fileCardiSignePath)>0){
foreach ($fileCardiSignePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileCardiSigneName);
}
if(count($fileConsuelPath)>0){
foreach ($fileConsuelPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileConsuelName);
}
if(count($fileDREPath)>0){
foreach ($fileDREPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileDREName);
}
if(count($fileAttestationBureauControleMultiplePath)>0){
foreach ($fileAttestationBureauControleMultiplePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileAttestationBureauControleMultipleName);
}
if(count($fileContratAchatSignePath)>0){
foreach ($fileContratAchatSignePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileContratAchatSigneName);
}
if(count($fileDoePath)>0){
foreach ($fileDoePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileDoeName);
}
if(count($fileAttestionProducteurPath)>0){
foreach ($fileAttestionProducteurPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileAttestionProducteurName);
}
if(count($fileAttestionInstallateurPath)>0){
foreach ($fileAttestionInstallateurPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileAttestionInstallateurName);
}
//construction
if(count($fileContratEpcPath)>0){
foreach ($fileContratEpcPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileContratEpcName);
}
if(count($fileAnnexesPath)>0){
foreach ($fileAnnexesPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileAnnexesName);
}
if(count($arrayDocumentGeometrePath)>0){
foreach ($arrayDocumentGeometrePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($fileDocumentGeometreName);
}
if(count($arrayPlanExecutionPath)>0){
foreach ($arrayPlanExecutionPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($filePlanExecutionName);
}
if(count($arrayPhotosFondationPath)>0){
foreach ($arrayPhotosFondationPath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($filePhotosFondationName);
}
$filePhotosBatimentPath ? $zip->addFile($filePhotosBatimentPath,$filePhotosBatimentName):$zip->addEmptyDir($filePhotosBatimentName);
// $fileConsuelEtap20Path ? $zip->addFile($fileConsuelEtap20Path,$fileConsuelEtap20Name):$zip->addEmptyDir($fileConsuelEtap20Name);
$fileTestReceptionPath ? $zip->addFile($fileTestReceptionPath,$fileTestReceptionName):$zip->addEmptyDir($fileTestReceptionName);
$fileTestPrPath ? $zip->addFile($fileTestPrPath,$fileTestPrName):$zip->addEmptyDir($fileTestPrName);
if($user and (!in_array('ROLE_DEV',$user->getRoles()) or !in_array('ROLE_EPC',$user->getRoles()))) {
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap171,'getFilePVDemarrageMultiple','Contrats de development et construction/Pré-requis avant démarage de la construction/PV de démarrage/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap171,'getFileDocEtap171Multiple','Contrats de development et construction/Pré-requis avant démarage de la construction/DOC/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap171,'getFileOrderServiceMultiple','Contrats de development et construction/Pré-requis avant démarage de la construction/Ordre de service/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap171,'getFilePlanningPrevisionnelMultiple','Contrats de development et construction/Pré-requis avant démarage de la construction/Planning prévisionnel/');
$zip = $this->getNameAndPathCategoryAndAddToZip($zip,$etap171,'Contrats de development et construction/Pré-requis avant démarage de la construction/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap172,'getFileNoteCalculBetonFeraillageMultiple','Contrats de development et construction/LOT Génie civil et fondations/Note de calcul béton et féraillage/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap172,'getFilePlanImplantationBatimentAvecDalleBetonMultiple','Contrats de development et construction/LOT Génie civil et fondations/Plan implantation bâtiment avec dalle béton du local onduleur/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap172,'getFilePVReceptionMultiple','Contrats de development et construction/LOT Génie civil et fondations/PV de réception/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap172,'getFileFondationTermineesMultiple','Contrats de development et construction/LOT Génie civil et fondations/Fondations terminées/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap172,'getFileDalleBetonShelterMultiple','Contrats de development et construction/LOT Génie civil et fondations/Dalle béton shelter/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap172,'getFileCheminAccesMultiple','Contrats de development et construction/LOT Génie civil et fondations/Chemin d’accès/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap172,'getFilePhotosPlateformeMultiple','Contrats de development et construction/LOT Génie civil et fondations/Photos de la plateforme/');
$zip = $this->getNameAndPathCategoryAndAddToZip($zip,$etap172,'Contrats de development et construction/LOT Génie civil et fondations/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFileNoteCalculCharpente173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Notes de calcul charpente/');
// $zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFilePhotoRenforcementcharpente173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Photos de renforcement charpente/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFileOssatureSecondaireBardage173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Plan de bardage/');
// $zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFilePhotoRenforcementBardage173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Photos de renforcement des bardages/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFilePVreception173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/PV de réception/');
// $zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFilePhotoRenforcementCouvertureTermine173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Photos de renforcement de la couverture terminée/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFilePlansCharpente173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Plans de charpente/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFilePlansCharpente173SigneMultiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Plans de charpente signé par le bailleur/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFileVues3d173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Vues 3D/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFilePlanCouverture173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Plan de couverture/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFilePlanDescriptionTravauxRenforcementCharpente173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Plan et descriptifs des travaux de renforcement de charpente/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap173,'getFilePlanDescriptionTravauxDeposeCouverture173Multiple','Contrats de development et construction/LOT Charpente et couverture - bardage/Plan et descriptifs des travaux de dépose , repose de couverture/');
$zip = $this->getNameAndPathCategoryAndAddToZip($zip,$etap173,'Contrats de development et construction/LOT Charpente et couverture - bardage/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFilePlanCalepinageModule174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Plan de calepinage & câblage/');
// $zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFilePlanCaplageStrings174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Plan de câblage des strings/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFileNoteCalculSousLisePV174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Note de calcul sous Lise PV/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFileSchemaUnifilaireInstallation174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Schéma Unifilaire de l’installation/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFileShemaAgencementShelterPhotos174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Schéma d’agencement du shelter ou photos/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFileTestPrMiseService174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Test de PR à la mise en service/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFileShemaUnifilaireSystemeMonitoring174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Schéma unifilaire du système de monitoring/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFileTestVerificationTravauxElectriqueFiche174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Tests et vérifications des travaux électriques, fiche d’auto-contrôle de l’installateur/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFilePVReception174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/PV de réception lot photovoltaïque & élec & AMO/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFilePhotosGenerateur174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Photos de la centrale solaire/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFilePvTerminees174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Pv terminées/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFileDescentesCables174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Descentes de câbles/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap174,'getFileRaccordementLocalOnduleur174Multiple','Contrats de development et construction/LOT photovoltaïque et élec/Raccordement du local onduleur/');
$zip = $this->getNameAndPathCategoryAndAddToZip($zip,$etap174,'Contrats de development et construction/LOT photovoltaïque et élec/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap175,'getFileNoteCalculCableAcLiaison175Multiple','Contrats de development et construction/LOT Raccordement, liaison PDL/Notes de calcul des câbles AC de la liaison/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap175,'getFilePlanTranchee175Multiple','Contrats de development et construction/LOT Raccordement, liaison PDL/Plans de la tranchée (coupe et plan de localisation)/');
// $zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap175,'getFileDaact175Multiple','Contrats de development et construction/LOT Raccordement, liaison PDL/DAACT : cerfa signé tamponné mairie/');
// $zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap175,'getFilePVReception175Multiple','Contrats de development et construction/LOT Raccordement, liaison PDL/PV de réception/');
// $zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap175,'getFilePhotosLiaisonTerminee175Multiple','Contrats de development et construction/LOT Raccordement, liaison PDL/Photos de la liaison terminée/');
$zip = $this->getNameAndPathCategoryAndAddToZip($zip,$etap175,'Contrats de development et construction/LOT Raccordement, liaison PDL/');
$zip = $this->getNameAndPathCategoryAndAddToZip($zip,$etap161,'Contrats de development et construction/Devis fournisseurs et sous-traitants/');
}
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap201,'getFileDoeEtap201Multiple','Contrats de development et construction/Dossier des Ouvrages Exécutés/DOE/');
$zip = $this->getNameAndPathCategoryAndAddToZip($zip,$etap160,'Contrats de development et construction/Informations Techniques/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap2,'getFileDemandeAnrMarieMultiple','Urbanisme/Demande d’ANR Mairie/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap2,'getFileDemandeAnrTaMultiple','Urbanisme/Demande d’ANR TA/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap2,'getFileAttestationHonneurAnrMairieTaMultiple','Urbanisme/Attestation sur l’honneur ANR Mairie / TA/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap10,'getFileAvenantCrdMultiple','Raccordement ENEDIS/Avenant CRD/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap10,'getFileAvenantCrdMesMultiple','Raccordement ENEDIS/Avenant CRD pour MES/');
$zip = $this->getMultipleNameAndPathAndAddToZip($zip,$etap12,'getFileAvenantCardiMultiple','Raccordement ENEDIS/Avenant CARDI/');
$zip->close();
return $zipfile;
}else{
return false;
}
}
return false;
}
public function exportZips($zips,$request = null){
if($zips){
$zip = new \ZipArchive();
$zipName = time().'project-exported.zip';
$zipfile = $this->params->get('zips_directory') . '/'.$zipName;
if (file_exists($zipfile)) unlink($zipfile);
if ($zip->open($zipfile, \ZipArchive::CREATE) === TRUE) {
foreach ($zips as $item){
$zip->addFile($item['zip'],$item['name'].'.zip');
}
$zip->close();
if($request){
$baseurl = $request->getScheme() . '://' . $request->getHttpHost();
return $baseurl.'/zips/'.$zipName;
}else{
return $zipfile;
}
}else{
return 0;
}
}
return 0;
}
public function getMultipleNameAndPathAndAddToZip($zip,$etap,$file,$name){
$filePath =[];
if(count($etap->{$file}()) > 0){
foreach ($etap->{$file}() as $key => $item){
$filePath[$item->getId()]['name'] = $name.($item->getNomenclature()? $key.' - '.$item->getNomenclature(): $item->getPath());
$filePath[$item->getId()]['path'] = $this->params->get('uploads_directory').'/'.$item->getPath();
}
}
if(count($filePath)>0){
foreach ($filePath as $item){
$zip->addFile($item['path'],$item['name']);
}
}else{
$zip->addEmptyDir($name);
}
return $zip;
}
public function getNameAndPathAndAddToZip($zip,$etap,$file,$name){
$fileName = $name;
$filePath = null;
if($etap->{$file}()){
$fileName = $name.($etap->{$file}()->getNomenclature()? $etap->{$file}()->getNomenclature(): $etap->{$file}()->getPath());
$filePath = $this->params->get('uploads_directory').'/'.$etap->{$file}()->getPath();
}
$filePath ? $zip->addFile($filePath,$fileName):$zip->addEmptyDir($fileName);
return $zip;
}
public function getNameAndPathCategoryAndAddToZip($zip,$etap,$name){
if(count($etap->getCategorys()) > 0){
foreach ($etap->getCategorys() as $category){
if(count($category->getDocuments())>0){
foreach ($category->getDocuments() as $document){
$nameDoc = $document->getName();
$fileName = $name.$nameDoc."/";
$filePath = null;
$doc = $document->getDocUpload();
if($doc){
$fileName = $name.$nameDoc."/".($doc->getNomenclature()? $doc->getNomenclature(): $doc->getPath());
$filePath = $this->params->get('uploads_directory').'/'.$doc->getPath();
}
$filePath ? $zip->addFile($filePath,$fileName):$zip->addEmptyDir($fileName);
}
}
}
}
return $zip;
}
public function deleteFileToDropbox($doc){
$dropboxKey = $this->params->get('dropbox_key');
$dropboxSecret = $this->params->get('dropbox_secret');
$dropboxToken= $this->params->get('dropbox_token');
$app = new DropboxApp($dropboxKey,$dropboxSecret,$dropboxToken);
$dropbox = new Dropbox($app);
if(is_object($doc) && $doc->getPathDropbox() ) {
try {
$file = $dropbox->delete($doc->getPathDropbox());
return true;
} catch (DropboxClientException $e) {
return false;
}
}
return true;
}
public function switchDocInProsess(){
$etap1 = $this->em->getRepository(Etap1::class)->findAll();
$etap9 = $this->em->getRepository(Etap9::class)->findAll();
$etap10 = $this->em->getRepository(Etap10::class)->findAll();
$etap12 = $this->em->getRepository(Etap12::class)->findAll();
$etap14 = $this->em->getRepository(Etap14::class)->findAll();
$etap15 = $this->em->getRepository(Etap15::class)->findAll();
foreach ($etap1 as $item){
if($item->getFileArretePcDp()){
$item->addFileArretePcDpMultiple($item->getFileArretePcDp());
}
if($item->getFileDossierPcDp()){
$item->addFileDossierPcDpMultiple($item->getFileDossierPcDp());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap9 as $item){
if($item->getFileMailEnedisConfirmation()){
$item->addFileMailEnedisConfirmationMultiple($item->getFileMailEnedisConfirmation());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap10 as $item){
if($item->getFileCrdSignee()){
$item->addFileCrdSigneeMultiple($item->getFileCrdSignee());
}
if($item->getFileCrdSigneeSansPtf()){
$item->addFileCrdSigneeSansPtfMultiple($item->getFileCrdSigneeSansPtf());
}
if($item->getFilePreuveVirement()){
$item->addFilePreuveVirementMultiple($item->getFilePreuveVirement());
}
if($item->getFilePreuveVirementSansPtf()){
$item->addFilePreuveVirementSansPtfMultiple($item->getFilePreuveVirementSansPtf());
}
if($item->getFilePtf()){
$item->addFilePtfMultiple($item->getFilePtf());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap12 as $item){
if($item->getFileCardiSigne()){
$item->addFileCardiSigneMultiple($item->getFileCardiSigne());
}
if($item->getFileCexSigne()){
$item->addFileCexSigneMultiple($item->getFileCexSigne());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap14 as $item){
if($item->getFileDoe()){
$item->addFileDoeMultiple($item->getFileDoe());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap15 as $item){
if($item->getFileAttestionInstallateur()){
$item->addFileAttestionInstallateurMultiple($item->getFileAttestionInstallateur());
}
if($item->getFileAttestionProducteur()){
$item->addFileAttestionProducteurMultiple($item->getFileAttestionProducteur());
}
if($item->getFileContratAchatSigne()){
$item->addFileContratAchatSigneMultiple($item->getFileContratAchatSigne());
}
$this->em->persist($item);
$this->em->flush();
}
}
public function switchDocFileDiagnostiqueCharpente(){
$projects = $this->em->getRepository(Project::class)->findAll();
foreach ($projects as $project){
$etap160 = $this->em->getRepository(Etap160::class)->findOneBy(['project'=>$project->getId()]);
$etap159 = $this->em->getRepository(Etap159::class)->findOneBy(['project'=>$project->getId()]);
if($etap160 && $etap159){
if(count($etap160->getFileDiagnostiqueCharpenteMultiple())>0){
foreach ($etap160->getFileDiagnostiqueCharpenteMultiple() as $item){
$etap159->addFileDiagnostiqueCharpente159Multiple($item);
}
}
if(count($etap159->getFileDiagnostiqueCharpente159Multiple())>0){
foreach ($etap159->getFileDiagnostiqueCharpente159Multiple() as $item){
$etap160->addFileDiagnostiqueCharpenteMultiple($item);
}
}
}
$this->em->persist($etap159);
$this->em->persist($etap160);
}
$this->em->flush();
}
public function switchDocInProsess2(){
// urbanisme
$etap2 = $this->em->getRepository(Etap2::class)->findAll();
$etap3 = $this->em->getRepository(Etap3::class)->findAll();
$etap4 = $this->em->getRepository(Etap4::class)->findAll();
foreach ($etap2 as $item){
if($item->getFilePVPassageHuissier()){
$item->addFilePVPassageHuissierMultiple($item->getFilePVPassageHuissier());
}
if($item->getFileCertificatNonRecours()){
$item->addFileCertificatNonRecoursMultiple($item->getFileCertificatNonRecours());
}
if($item->getFileCertificatNonRetrait()){
$item->addFileCertificatNonRetraitMultiple($item->getFileCertificatNonRetrait());
}
if($item->getFileCertificatNonOpposition()){
$item->addFileCertificatNonOppositionMultiple($item->getFileCertificatNonOpposition());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap3 as $item){
if($item->getFileDocDroc()){
$item->addFileDocDrocMultiple($item->getFileDocDroc());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap4 as $item){
if($item->getFileDaact()){
$item->addFileDaactMultiple($item->getFileDaact());
}
$this->em->persist($item);
$this->em->flush();
}
// foncier
$etap5 = $this->em->getRepository(Etap5::class)->findAll();
$etap6 = $this->em->getRepository(Etap6::class)->findAll();
$etap7 = $this->em->getRepository(Etap7::class)->findAll();
foreach ($etap5 as $item){
if($item->getFilePromessebail()){
$item->addFilePromessebailMultiple($item->getFilePromessebail());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap6 as $item){
if($item->getFileEtatDecriptif()){
$item->addFileEtatDecriptifMultiple($item->getFileEtatDecriptif());
}
if($item->getFileEtatHypothecaire()){
$item->addFileEtatHypothecaireMultiple($item->getFileEtatHypothecaire());
}
if($item->getFilePublicationSPR()){
$item->addFilePublicationSPRMultiple($item->getFilePublicationSPR());
}
if($item->getFileTitrePropriete()){
$item->addFileTitreProprieteMultiple($item->getFileTitrePropriete());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap7 as $item){
if($item->getFileBailSigne()){
$item->addFileBailSigneMultiple($item->getFileBailSigne());
}
if($item->getFileAvenantBail()){
$item->addFileAvenantBailMultiple($item->getFileAvenantBail());
}
$this->em->persist($item);
$this->em->flush();
}
// Raccordement
$etap8 = $this->em->getRepository(Etap8::class)->findAll();
$etap13 = $this->em->getRepository(Etap13::class)->findAll();
foreach ($etap8 as $item){
if($item->getFileKbisEts()){
$item->addFileKbisEtsMultiple($item->getFileKbisEts());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap13 as $item){
if($item->getFileConsuel()){
$item->addFileConsuelMultiple($item->getFileConsuel());
}
$this->em->persist($item);
$this->em->flush();
}
// Construction
$etap16 = $this->em->getRepository(Etap16::class)->findAll();
$etap20 = $this->em->getRepository(Etap20::class)->findAll();
$etap21 = $this->em->getRepository(Etap21::class)->findAll();
$etap22 = $this->em->getRepository(Etap22::class)->findAll();
$etap160 = $this->em->getRepository(Etap160::class)->findAll();
$etap201 = $this->em->getRepository(Etap201::class)->findAll();
$etap171 = $this->em->getRepository(Etap171::class)->findAll();
$etap172 = $this->em->getRepository(Etap172::class)->findAll();
$etap173 = $this->em->getRepository(Etap173::class)->findAll();
$etap174 = $this->em->getRepository(Etap174::class)->findAll();
$etap175 = $this->em->getRepository(Etap175::class)->findAll();
foreach ($etap16 as $item){
if($item->getFileContratEpc()){
$item->addFileContratEpcMultiple($item->getFileContratEpc());
}
if($item->getFileAnnexes()){
$item->addFileAnnexesMultiple($item->getFileAnnexes());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap20 as $item){
if($item->getFileConsuelEtap20()){
$item->addFileConsuelEtap20Multiple($item->getFileConsuelEtap20());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap21 as $item){
if($item->getFileTestReception()){
$item->addFileTestReceptionMultiple($item->getFileTestReception());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap22 as $item){
if($item->getFileTestPr()){
$item->addFileTestPrMultiple($item->getFileTestPr());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap160 as $item){
if($item->getFileDiagnostiqueCharpente()){
$item->addFileDiagnostiqueCharpenteMultiple($item->getFileDiagnostiqueCharpente());
}
if($item->getFileEtudeSole()){
$item->addFileEtudeSoleMultiple($item->getFileEtudeSole());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap201 as $item){
if($item->getFileDoeEtap201()){
$item->addFileDoeEtap201Multiple($item->getFileDoeEtap201());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap171 as $item){
if($item->getFileDocEtap171()){
$item->addFileDocEtap171Multiple($item->getFileDocEtap171());
}
if($item->getFileOrderService()){
$item->addFileOrderServiceMultiple($item->getFileOrderService());
}
if($item->getFilePlanningPrevisionnel()){
$item->addFilePlanningPrevisionnelMultiple($item->getFilePlanningPrevisionnel());
}
if($item->getFilePVDemarrage()){
$item->addFilePVDemarrageMultiple($item->getFilePVDemarrage());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap172 as $item){
if($item->getFilePVReception()){
$item->addFilePVReceptionMultiple($item->getFilePVReception());
}
if($item->getFilePlanImplantationBatimentAvecDalleBeton()){
$item->addFilePlanImplantationBatimentAvecDalleBetonMultiple($item->getFilePlanImplantationBatimentAvecDalleBeton());
}
if($item->getFilePhotosPlateforme()){
$item->addFilePhotosPlateformeMultiple($item->getFilePhotosPlateforme());
}
if($item->getFileNoteCalculBetonFeraillage()){
$item->addFileNoteCalculBetonFeraillageMultiple($item->getFileNoteCalculBetonFeraillage());
}
if($item->getFileFondationTerminees()){
$item->addFileFondationTermineesMultiple($item->getFileFondationTerminees());
}
if($item->getFileDalleBetonShelter()){
$item->addFileDalleBetonShelterMultiple($item->getFileDalleBetonShelter());
}
if($item->getFileCheminAcces()){
$item->addFileCheminAccesMultiple($item->getFileCheminAcces());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap173 as $item){
if($item->getFileNoteCalculCharpente173()){
$item->addFileNoteCalculCharpente173Multiple($item->getFileNoteCalculCharpente173());
}
if($item->getFileOssatureSecondaireBardage173()){
$item->addFileOssatureSecondaireBardage173Multiple($item->getFileOssatureSecondaireBardage173());
}
if($item->getFilePhotoRenforcementBardage173()){
$item->addFilePhotoRenforcementBardage173Multiple($item->getFilePhotoRenforcementBardage173());
}
if($item->getFilePhotoRenforcementcharpente173()){
$item->addFilePhotoRenforcementcharpente173Multiple($item->getFilePhotoRenforcementcharpente173());
}
if($item->getFilePhotoRenforcementCouvertureTermine173()){
$item->addFilePhotoRenforcementCouvertureTermine173Multiple($item->getFilePhotoRenforcementCouvertureTermine173());
}
if($item->getFilePlanCouverture173()){
$item->addFilePlanCouverture173Multiple($item->getFilePlanCouverture173());
}
if($item->getFilePlanDescriptionTravauxDeposeCouverture173()){
$item->addFilePlanDescriptionTravauxDeposeCouverture173Multiple($item->getFilePlanDescriptionTravauxDeposeCouverture173());
}
if($item->getFilePlanDescriptionTravauxRenforcementCharpente173()){
$item->addFilePlanDescriptionTravauxRenforcementCharpente173Multiple($item->getFilePlanDescriptionTravauxRenforcementCharpente173());
}
if($item->getFilePlansCharpente173()){
$item->addFilePlansCharpente173Multiple($item->getFilePlansCharpente173());
}
if($item->getFilePVreception173()){
$item->addFilePVreception173Multiple($item->getFilePVreception173());
}
if($item->getFileVues3d173()){
$item->addFileVues3d173Multiple($item->getFileVues3d173());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap174 as $item) {
if ($item->getFileTestVerificationTravauxElectriqueFiche174()) {
$item->addFileTestVerificationTravauxElectriqueFiche174Multiple($item->getFileTestVerificationTravauxElectriqueFiche174());
}
if ($item->getFileTestPrMiseService174()) {
$item->addFileTestPrMiseService174Multiple($item->getFileTestPrMiseService174());
}
if ($item->getFileShemaUnifilaireSystemeMonitoring174()) {
$item->addFileShemaUnifilaireSystemeMonitoring174Multiple($item->getFileShemaUnifilaireSystemeMonitoring174());
}
if ($item->getFileShemaAgencementShelterPhotos174()) {
$item->addFileShemaAgencementShelterPhotos174Multiple($item->getFileShemaAgencementShelterPhotos174());
}
if ($item->getFileSchemaUnifilaireInstallation174()) {
$item->addFileSchemaUnifilaireInstallation174Multiple($item->getFileSchemaUnifilaireInstallation174());
}
if ($item->getFileRaccordementLocalOnduleur174()) {
$item->addFileRaccordementLocalOnduleur174Multiple($item->getFileRaccordementLocalOnduleur174());
}
if ($item->getFilePvTerminees174()) {
$item->addFilePvTerminees174Multiple($item->getFilePvTerminees174());
}
if ($item->getFilePVReception174()) {
$item->addFilePVReception174Multiple($item->getFilePVReception174());
}
if ($item->getFilePlanCaplageStrings174()) {
$item->addFilePlanCaplageStrings174Multiple($item->getFilePlanCaplageStrings174());
}
if ($item->getFilePlanCalepinageModule174()) {
$item->addFilePlanCalepinageModule174Multiple($item->getFilePlanCalepinageModule174());
}
if ($item->getFilePhotosGenerateur174()) {
$item->addFilePhotosGenerateur174Multiple($item->getFilePhotosGenerateur174());
}
if ($item->getFileNoteCalculSousLisePV174()) {
$item->addFileNoteCalculSousLisePV174Multiple($item->getFileNoteCalculSousLisePV174());
}
if ($item->getFileDescentesCables174()) {
$item->addFileDescentesCables174Multiple($item->getFileDescentesCables174());
}
$this->em->persist($item);
$this->em->flush();
}
foreach ($etap175 as $item) {
if ($item->getFileDaact175()) {
$item->addFileDaact175Multiple($item->getFileDaact175());
}
if ($item->getFileNoteCalculCableAcLiaison175()) {
$item->addFileNoteCalculCableAcLiaison175Multiple($item->getFileNoteCalculCableAcLiaison175());
}
if ($item->getFilePhotosLiaisonTerminee175()) {
$item->addFilePhotosLiaisonTerminee175Multiple($item->getFilePhotosLiaisonTerminee175());
}
if ($item->getFilePlanTranchee175()) {
$item->addFilePlanTranchee175Multiple($item->getFilePlanTranchee175());
}
if ($item->getFilePVReception175()) {
$item->addFilePVReception175Multiple($item->getFilePVReception175());
}
$this->em->persist($item);
$this->em->flush();
}
}
public function switchDocInProsess3(){
$etap15 = $this->em->getRepository(Etap15::class)->findAll();
foreach ($etap15 as $item){
if($item->getTarifContratAchat() or $item->getDateDebutContratAchat() or $item->getDateFinContratAchat() or $item->getPeridiciteFacturation() or $item->getNumeroContratAchat()){
$imformationContratAchat = new ImfomationContratAchat();
$imformationContratAchat->setDateDebutContratAchat($item->getDateDebutContratAchat());
$imformationContratAchat->setDateFinContratAchat($item->getDateFinContratAchat());
$imformationContratAchat->setNumeroContratAchat($item->getNumeroContratAchat());
$imformationContratAchat->setPeridiciteFacturation($item->getPeridiciteFacturation());
$imformationContratAchat->setTarifContratAchat($item->getTarifContratAchat());
$imformationContratAchat->setEtap15($item);
$this->em->persist($imformationContratAchat);
$this->em->flush();
}
}
}
public function switchDocEnterTowEtaps(){
$projects = $this->em->getRepository(Project::class)->findAll();
foreach ($projects as $project){
$etap171 = $this->em->getRepository(Etap171::class)->findOneBy(['project'=>$project->getId()]);
$etap172 = $this->em->getRepository(Etap172::class)->findOneBy(['project'=>$project->getId()]);
if($etap171 && $etap172){
if(count($etap172->getFileCheminAccesMultiple())>0){
foreach ($etap172->getFileCheminAccesMultiple() as $item){
$etap171->addFileCheminAccesMultiple($item);
}
}
if(count($etap172->getFilePhotosPlateformeMultiple())>0){
foreach ($etap172->getFilePhotosPlateformeMultiple() as $item){
$etap171->addFilePhotosPlateformeMultiple($item);
}
}
}
$this->em->persist($etap171);
}
$this->em->flush();
}
public function uploadFileImport(UploadedFile $file)
{
set_time_limit(0);
if (is_object($file)) {
$filenameGenerate = $this->generateUniqueFileName();
$fileName = $filenameGenerate . '_' . $file->getClientOriginalName();
$file->move($this->params->get('uploads_directory'), $fileName);
return array('filename' => $fileName,'filenameOrigine'=>$file->getClientOriginalName());
}
return false;
}
public function addEtap15Information(){
$etaps15 = $this->em->getRepository(Etap15::class)->findAll();
foreach ($etaps15 as $etap15){
$information = new ImfomationContratAchat();
if($etap15->getNumeroContratAchat()){
$information->setNumeroContratAchat($etap15->getNumeroContratAchat());
}
if($etap15->getPeridiciteFacturation()){
$information->setPeridiciteFacturation($etap15->getPeridiciteFacturation());
}
if($etap15->getDateFinContratAchat()){
$information->setDateFinContratAchat($etap15->getDateFinContratAchat());
}
if($etap15->getDateDebutContratAchat()){
$information->setDateDebutContratAchat($etap15->getDateDebutContratAchat());
}
if($etap15->getTarifContratAchat()){
$information->setTarifContratAchat($etap15->getTarifContratAchat());
}
$information->setEtap15($etap15);
$this->em->persist($information);
$this->em->flush();
}
}
public function addVisiteTerrainOld(){
$etaps23 = $this->em->getRepository(Etap23::class)->findAll();
foreach ($etaps23 as $etap23){
$visiteOld = $etap23->getVisiteTerrain();
if(count($visiteOld)>0){
foreach ($visiteOld as $item){
$photosOld = $item->getFilePhotosVisiteTerainMultiple();
if(count($photosOld)>0){
foreach ($photosOld as $value){
$etap23->addFilePhotosVisiteTerainEtap23Multiple($value);
$this->em->persist($etap23);
}
}
}
}
$this->em->flush();
}
}
}