<?php
namespace App\Twig;
use App\Entity\Avoir;
use App\Entity\AvoirFactureFinance;
use App\Entity\AvoirMontantTvaProject;
use App\Entity\CommentEtap;
use App\Entity\EfacData;
use App\Entity\Entreprise;
use App\Entity\EquipementCommandeProduitPrix;
use App\Entity\EquipementCommandeProduitPrixDetail;
use App\Entity\EquipementFournisseur;
use App\Entity\Etap14;
use App\Entity\Etap171;
use App\Entity\Etap172;
use App\Entity\Etap173;
use App\Entity\Etap174;
use App\Entity\Etap175;
use App\Entity\Etaps;
use App\Entity\EtapsCategory;
use App\Entity\FactureFinance;
use App\Entity\FactureFinanceMontantTvaProject;
use App\Entity\FactureFinancePaiementDetail;
use App\Entity\Fournisseur;
use App\Entity\FournisseurProject;
use App\Entity\HistoryFactureAvoir;
use App\Entity\MeltdChamps;
use App\Entity\ParametrageXlsProject;
use App\Entity\Project;
use App\Entity\Spv;
use App\Entity\StatusTracker;
use App\Entity\StatusTrackerConstruction;
use App\Entity\TypologieProject;
use App\Entity\User;
use App\Entity\UserDroit;
use App\Entity\UserDroitGlobal;
use App\Entity\TypeValorisation;
use App\Services\CompteRenduService;
use App\Services\EquipementCommandeService;
use App\Services\EtapsService;
use App\Services\FactureFinanceService;
use App\Services\FactureService;
use App\Services\FournisseurService;
use App\Services\Notifications;
use App\Services\ProjectService;
use App\Services\UploadService;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
use Twig\Environment;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class AppExtension extends AbstractExtension
{
private $twig;
private $params;
public function __construct(
Environment $twig,
EntityManagerInterface $em,
ParameterBagInterface $params,
EtapsService $etapsService,
Notifications $notifications,
ProjectService $projectService,
FactureFinanceService $factureFinanceService,
UploadService $uploadService,
FournisseurService $fournisseurService,
EquipementCommandeService $equipementCommandeService,
CompteRenduService $compteRenduService
) {
$this->twig = $twig;
$this->em = $em;
$this->params = $params;
$this->etapsService = $etapsService;
$this->uploadService = $uploadService;
$this->notifications = $notifications;
$this->projectService = $projectService;
$this->factureFinanceService = $factureFinanceService;
$this->fournisseurService = $fournisseurService;
$this->equipementCommandeService = $equipementCommandeService;
$this->compteRenduService = $compteRenduService;
}
public function getFunctions()
{
return [
new TwigFunction('getEtapNameByNum', [$this, 'getEtapNameByNum']),
new TwigFunction('getReferencePrice', [$this, 'getReferencePrice']),
new TwigFunction('getTimelinePointEtapByNum', [$this, 'getTimelinePointEtapByNum']),
new TwigFunction('getCommentEtapByNum', [$this, 'getCommentEtapByNum']),
new TwigFunction('checkCommentEtapByNum', [$this, 'checkCommentEtapByNum']),
new TwigFunction('getEtapByNumAndProject', [$this, 'getEtapByNumAndProject']),
new TwigFunction('getNotisNotLu', [$this, 'getNotisNotLu']),
new TwigFunction('getSpvs', [$this, 'getSpvs']),
new TwigFunction('getEpcs', [$this, 'getEpcs']),
new TwigFunction('getUserByRoles', [$this, 'getUserByRoles']),
new TwigFunction('checkOpenEtap', [$this, 'checkOpenEtap']),
new TwigFunction('getDocsPartage', [$this, 'getDocsPartage']),
new TwigFunction('getAbreviation', [$this, 'getAbreviation']),
new TwigFunction('checkInformationProprietaireEtap6Raccordement', [$this, 'checkInformationProprietaireEtap6Raccordement']),
new TwigFunction('completudeCategory', [$this, 'completudeCategory']),
new TwigFunction('completudeDocsCategory', [$this, 'completudeDocsCategory']),
new TwigFunction('espaceNumber', [$this, 'espaceNumber']),
new TwigFunction('getDocUploadMultipleNotArchive', [$this, 'getDocUploadMultipleNotArchive']),
new TwigFunction('getDocUploadMultipleNotArchiveString', [$this, 'getDocUploadMultipleNotArchiveString']),
new TwigFunction('getDocUploadMultipleNotArchiveEntity', [$this, 'getDocUploadMultipleNotArchiveEntity']),
new TwigFunction('getDocUploadMultipleNotArchiveEntityImage', [$this, 'getDocUploadMultipleNotArchiveEntityImage']),
new TwigFunction('checkEtap3StatusFermee', [$this, 'checkEtap3StatusFermee']),
new TwigFunction('checkEtap3StatusName', [$this, 'checkEtap3StatusName']),
new TwigFunction('checkEtap3Status', [$this, 'checkEtap3Status']),
new TwigFunction('getDocsName', [$this, 'getDocsName']),
new TwigFunction('disabledOptionFileName', [$this, 'disabledOptionFileName']),
new TwigFunction('getAllFileNameTimeLine', [$this, 'getAllFileNameTimeLine']),
new TwigFunction('getAllFileNameTimeLineCategory', [$this, 'getAllFileNameTimeLineCategory']),
new TwigFunction('getAllFileNameTimeLineManyToMany', [$this, 'getAllFileNameTimeLineManyToMany']),
new TwigFunction('getAllFileNameTimeLineManyToMany2', [$this, 'getAllFileNameTimeLineManyToMany2']),
new TwigFunction('getAllFileNameFactureProject', [$this, 'getAllFileNameFactureProject']),
new TwigFunction('getAllFileNameAvoirProject', [$this, 'getAllFileNameAvoirProject']),
new TwigFunction('getHistoriqueAvoirFacture', [$this, 'getHistoriqueAvoirFacture']),
new TwigFunction('sommeValue', [$this, 'sommeValue']),
new TwigFunction('getAvoirByFacture', [$this, 'getAvoirByFacture']),
new TwigFunction('getfacturesByAvoir', [$this, 'getfacturesByAvoir']),
new TwigFunction('getMontantAvoirRestantByFacture', [$this, 'getMontantAvoirRestantByFacture']),
new TwigFunction('checkBailExpiree', [$this, 'checkBailExpiree']),
new TwigFunction('checkPCDPExpiree', [$this, 'checkPCDPExpiree']),
new TwigFunction('getEtapByProject', [$this, 'getEtapByProject']),
new TwigFunction('checkT0Expiree', [$this, 'checkT0Expiree']),
new TwigFunction('checkBailExpireeTimeline', [$this, 'checkBailExpireeTimeline']),
new TwigFunction('checkAlertPcExpireeTimeline', [$this, 'checkAlertPcExpireeTimeline']),
new TwigFunction('checkAlertT0ExpireeTimeline', [$this, 'checkAlertT0ExpireeTimeline']),
new TwigFunction('getDevsRapport', [$this, 'getDevsRapport']),
new TwigFunction('getDevsRapportSortant', [$this, 'getDevsRapportSortant']),
new TwigFunction('getDevsRapportConstructionSortant', [$this, 'getDevsRapportConstructionSortant']),
new TwigFunction('getDevsRapportConstruction', [$this, 'getDevsRapportConstruction']),
new TwigFunction('getAncientStatut', [$this, 'getAncientStatut']),
new TwigFunction('getStatutDate', [$this, 'getStatutDate']),
new TwigFunction('getAncientStatutConstruction', [$this, 'getAncientStatutConstruction']),
new TwigFunction('getStatutDateConstruction', [$this, 'getStatutDateConstruction']),
new TwigFunction('getFournisseursActive', [$this, 'getFournisseursActive']),
new TwigFunction('getChampsUpdates', [$this, 'getChampsUpdates']),
new TwigFunction('getTimeComment', [$this, 'getTimeComment']),
new TwigFunction('getCommentsProject', [$this, 'getCommentsProject']),
new TwigFunction('getChampsExport', [$this, 'getChampsExport']),
new TwigFunction('getTypologie', [$this, 'getTypologie']),
new TwigFunction('getEtapsByCategory', [$this, 'getEtapsByCategory']),
new TwigFunction('getAllIntervenant', [$this, 'getAllIntervenant']),
new TwigFunction('getAllParentAndActiveColonneXls', [$this, 'getAllParentAndActiveColonneXls']),
new TwigFunction('checkEtapIntervenant', [$this, 'checkEtapIntervenant']),
new TwigFunction('checkResponsableInProject', [$this, 'checkResponsableInProject']),
new TwigFunction('checkResponsableFoncierInProject', [$this, 'checkResponsableFoncierInProject']),
new TwigFunction('checkResponsableDeveloppementInProject', [$this, 'checkResponsableDeveloppementInProject']),
new TwigFunction('checkConstructeurInProject', [$this, 'checkConstructeurInProject']),
new TwigFunction('getSuiviBudget', [$this, 'getSuiviBudget']),
new TwigFunction('checkEtapStatusColorByDoc', [$this, 'checkEtapStatusColorByDoc']),
new TwigFunction('checkEtapStatusColorByDocEtap4Construction', [$this, 'checkEtapStatusColorByDocEtap4Construction']),
new TwigFunction('checkEtapStatusColorByDocEtap3Construction', [$this, 'checkEtapStatusColorByDocEtap3Construction']),
new TwigFunction('getDoeListFile', [$this, 'getDoeListFile']),
new TwigFunction('getBailListFile', [$this, 'getBailListFile']),
new TwigFunction('getStatusDetailStr', [$this, 'getStatusDetailStr']),
new TwigFunction('getTemplateMeltdChampsUpdate', [$this, 'getTemplateMeltdChampsUpdate']),
new TwigFunction('getTemplateMeltdChampsUpdateForm', [$this, 'getTemplateMeltdChampsUpdateForm']),
new TwigFunction('getNameChampGlobale', [$this, 'getNameChampGlobale']),
new TwigFunction('checkCalvuisUpdate', [$this, 'checkCalvuisUpdate']),
new TwigFunction('getConstructeurProject', [$this, 'getConstructeurProject']),
new TwigFunction('getMontantFinalTtcFacture', [$this, 'getMontantFinalTtcFacture']),
new TwigFunction('getFournisseurIsNotaire', [$this, 'getFournisseurIsNotaire']),
new TwigFunction('checkFournisseurRibActive', [$this, 'checkFournisseurRibActive']),
new TwigFunction('checkAltareaFacture', [$this, 'checkAltareaFacture']),
new TwigFunction('checkCodeProjectFacture', [$this, 'checkCodeProjectFacture']),
new TwigFunction('checkAlertEtap1And2', [$this, 'checkAlertEtap1And2']),
new TwigFunction('getDateFichierFactureFinancePaiement', [$this, 'getDateFichierFactureFinancePaiement']),
new TwigFunction('checkDroitProfileExtern', [$this, 'checkDroitProfileExtern']),
new TwigFunction('getUserNotaire', [$this, 'getUserNotaire']),
new TwigFunction('getUserByTitreIntervenant', [$this, 'getUserByTitreIntervenant']),
new TwigFunction('getVisitesQuestionByQuestion', [$this, 'getVisitesQuestionByQuestion']),
new TwigFunction('getQuestionColor', [$this, 'getQuestionColor']),
new TwigFunction('checkNextQuestionVisiteCompteRendu', [$this, 'checkNextQuestionVisiteCompteRendu']),
new TwigFunction('checkPrevQuestionVisiteCompteRendu', [$this, 'checkPrevQuestionVisiteCompteRendu']),
new TwigFunction('findAllProjectActive', [$this, 'findAllProjectActive']),
new TwigFunction('getAllPhotosForCompteRendu', [$this, 'getAllPhotosForCompteRendu']),
new TwigFunction('getAllEtapsPhotosMultiple', [$this, 'getAllEtapsPhotosMultiple']),
new TwigFunction('getTypeValorisation', [$this, 'getTypeValorisation']),
new TwigFunction('getEntrepriseActive', [$this, 'getEntrepriseActive']),
new TwigFunction('getfournisseurEquipement', [$this, 'getfournisseurEquipement']),
new TwigFunction('getEquipementPalettesWithCommande', [$this, 'getEquipementPalettesWithCommande']),
new TwigFunction('getEquipementProduitCommande', [$this, 'getEquipementProduitCommande']),
new TwigFunction('getEquipementProduitSousCommande', [$this, 'getEquipementProduitSousCommande']),
new TwigFunction('getEquipementCommandeFile', [$this, 'getEquipementCommandeFile']),
new TwigFunction('getEquipementProduitTabSousCommande', [$this, 'getEquipementProduitTabSousCommande']),
new TwigFunction('getTabEquipementBylogisticionReferenceAndStatus', [$this, 'getTabEquipementBylogisticionReferenceAndStatus']),
new TwigFunction('getTabEquipementLogisticienByReference', [$this, 'getTabEquipementLogisticienByReference']),
new TwigFunction('getTabEquipementTotalByReference', [$this, 'getTabEquipementTotalByReference']),
new TwigFunction('getTabEquipementCommandesBylogisticionReferenceAndStatus', [$this, 'getTabEquipementCommandesBylogisticionReferenceAndStatus']),
new TwigFunction('getTabEquipementBonDeLivraisonBylogisticionReferenceAndStatus', [$this, 'getTabEquipementBonDeLivraisonBylogisticionReferenceAndStatus']),
new TwigFunction('getFournisseurByReference', [$this, 'getFournisseurByReference']),
new TwigFunction('document_types', [EfacData::class, 'getDocumentTypes']),
new TwigFunction('getProjectPriceService', [$this, 'getProjectPriceService'])
];
}
public function getFilters()
{
return array(
);
}
public function getFournisseurByReference($referenceId){
$tab = $this->equipementCommandeService->getFournisseurByReference($referenceId);
return $tab ;
}
public function getTabEquipementTotalByReference($referenceId){
$tab = $this->equipementCommandeService->getTabEquipementTotalByReference($referenceId);
return $tab ;
}
public function getTabEquipementLogisticienByReference($referenceId){
$tab = $this->equipementCommandeService->getTabEquipementLogisticienByReference($referenceId);
return $tab ;
}
public function getTabEquipementBylogisticionReferenceAndStatus($logisticienReference,$status){
$tab = $this->equipementCommandeService->getTabEquipementBylogisticionReferenceAndStatus($logisticienReference,$status);
return $tab ;
}
public function getTabEquipementCommandesBylogisticionReferenceAndStatus($logisticienReference,$status){
$tab = $this->equipementCommandeService->getTabEquipementCommandesBylogisticionReferenceAndStatus($logisticienReference,$status);
return $tab ;
}
public function getTabEquipementBonDeLivraisonBylogisticionReferenceAndStatus($logisticienReference,$status){
$tab = $this->equipementCommandeService->getTabEquipementBonDeLivraisonBylogisticionReferenceAndStatus($logisticienReference,$status);
return $tab ;
}
public function getEquipementProduitTabSousCommande($commande){
$tab = $this->equipementCommandeService->getEquipementProduitTabSousCommande($commande);
return $tab ;
}
public function getEquipementCommandeFile($commande){
$tab = $this->equipementCommandeService->getEquipementCommandeFile($commande);
return $tab ;
}
public function getEquipementProduitSousCommande($sousCommande){
$tab = $this->equipementCommandeService->getEquipementProduitSousCommande($sousCommande);
return $tab ;
}
public function getEquipementProduitCommande($commande){
$tab = $this->equipementCommandeService->getEquipementProduitCommande($commande);
return $tab ;
}
public function getEquipementPalettesWithCommande($commande){
$tab = $this->equipementCommandeService->getEquipementPalettesWithCommande($commande);
return $tab ;
}
public function getfournisseurEquipement(){
$fournisseurs = $this->em->getRepository(EquipementFournisseur::class)->findAll();
return $fournisseurs ;
}
public function getProjectPriceService($tvaFactureFinanceId,$projectId,$isAvoir = false){
if($isAvoir){
$factureFinanceMontantTvaProject = $this->em->getRepository(AvoirMontantTvaProject::class)->getMontantTvaProjectByIdTvaAndPorjectId($tvaFactureFinanceId,$projectId);
}else{
$factureFinanceMontantTvaProject = $this->em->getRepository(FactureFinanceMontantTvaProject::class)->getMontantTvaProjectByIdTvaAndPorjectId($tvaFactureFinanceId,$projectId);
}
return $factureFinanceMontantTvaProject;
}
public function getEntrepriseActive(){
$entreprises = $this->em->getRepository(Entreprise::class)->getAllActive();
return $entreprises ;
}
public function getAllPhotosForCompteRendu($project){
return $this->compteRenduService->getAllPhotosForCompteRendu($project);
}
public function findAllProjectActive(){
return $this->em->getRepository(Project::class)->findAllProjectActive();
}
public function checkNextQuestionVisiteCompteRendu($token){
return $this->compteRenduService->checkIsNext($token);
}
public function checkPrevQuestionVisiteCompteRendu($token){
return $this->compteRenduService->checkIsPrev($token);
}
public function getQuestionColor($question){
$vistesByQuestion = $this->compteRenduService->getQuestionColor($question);
return $vistesByQuestion;
}
public function getVisitesQuestionByQuestion($question){
$vistesByQuestion = $this->compteRenduService->getQuestionsByVisite($question);
return $vistesByQuestion;
}
public function getUserByTitreIntervenant($titre){
$fournisseurs = $this->fournisseurService->getUserByTitreIntervenant($titre);
return $fournisseurs ;
}
public function getUserNotaire(){
$users = $this->fournisseurService->getUserNotaire();
return $users ;
}
public function checkFournisseurRibActive($fournisseur){
$montant = $this->fournisseurService->checkFournisseurRibActive($fournisseur);
return $montant ;
}
public function checkAltareaFacture($facture){
$montant = $this->factureFinanceService->checkAltareaFacture($facture);
return $montant ;
}
public function checkCodeProjectFacture($facture){
$data = $this->factureFinanceService->checkFactureFinanceCodeProject($facture);
return $data ;
}
public function getMontantFinalTtcFacture($facture){
$montant = $this->factureFinanceService->getMontantFinalTtcFacture($facture);
return $montant ;
}
public function getFournisseurIsNotaire($user){
$fournissueur = $this->em->getRepository(Fournisseur::class)->findOneBy(['user'=>$user->getId()]);
return $fournissueur ? $fournissueur->getIsNotaire() :false;
}
public function getConstructeurProject(){
$constructeurProject = $this->em->getRepository(FournisseurProject::class)->getConstructeurProject();
return $constructeurProject ;
}
public function checkCalvuisUpdate($project){
$champs = $this->em->getRepository(MeltdChamps::class)->getNotValideByProject($project);
return $champs ;
}
public function getNameChampGlobale($meltedId){
$name = $this->projectService->getNameChampGlobale($meltedId);
return $name ;
}
public function getTemplateMeltdChampsUpdate($project,$etap,$champName,$user,$isEtap = 1){
if(in_array($user->getTypeAcces(),[User::ACCES_intervenant,User::ACCES_visiteur,User::ACCES_comptable])){
$arrays = $this->em->getRepository(UserDroitGlobal::class)->getByUserAndChamp($user->getId(),'isUploadDoc');
if(!$arrays){
return 'disabled';
}
}
if($isEtap){
$melted = $this->em->getRepository(MeltdChamps::class)->findOneBy(['project'=>$project->getId(),'numEtap'=>$etap->getEtap()->getNum(),'champName'=>$champName]);
}else{
$melted = $this->em->getRepository(MeltdChamps::class)->findOneBy(['project'=>$project->getId(),'champName'=>$champName,'isProject'=>true]);
}
if($melted && (in_array('ROLE_SUPER_ADMINISTRATOR',$user->getRoles()) || in_array('ROLE_ADMIN',$user->getRoles()) || in_array('ROLE_ADMINISTRATEUR_FINANCIER',$user->getRoles()))){
return $this->twig->render('user/etaps/tooltip-champs-border.html.twig', [
'melted' => $melted
]);
}else {
return '';
}
}
public function getTemplateMeltdChampsUpdateForm($project,$etap,$champName,$user,$isEtap = 1){
if($isEtap){
$melted = $this->em->getRepository(MeltdChamps::class)->findOneBy(['project'=>$project->getId(),'numEtap'=>$etap->getEtap()->getNum(),'champName'=>$champName]);
}else{
$melted = $this->em->getRepository(MeltdChamps::class)->findOneBy(['project'=>$project->getId(),'champName'=>$champName,'isProject'=>true]);
}
if($melted && (in_array('ROLE_SUPER_ADMINISTRATOR',$user->getRoles()) || in_array('ROLE_ADMIN',$user->getRoles()) || in_array('ROLE_ADMINISTRATEUR_FINANCIER',$user->getRoles()))){
return $this->twig->render('user/etaps/tooltip-champs-form.html.twig', [
'melted' => $melted
]);
}else {
return '';
}
}
public function getStatusDetailStr($project,$cat){
return $this->etapsService->getStatusDetailStr($project,$cat);
}
public function getDoeListFile($project){
return $this->projectService->getDoeListFile($project);
}
public function getBailListFile($project){
return $this->projectService->getBailListFile($project);
}
public function checkEtapStatusColorByDocEtap4Construction($project){
return $this->etapsService->checkEtapStatusColorByDocEtap4Construction($project);
}
public function checkEtapStatusColorByDocEtap3Construction($project){
return $this->etapsService->checkEtapStatusColorByDocEtap3Construction($project);
}
public function checkEtapStatusColorByDoc($etap){
return $this->etapsService->checkEtapStatusColorByDoc($etap);
}
public function getSuiviBudget($project){
$tab = $this->projectService->getTabFacturationParProject($project);
return $tab;
}
public function checkResponsableFoncierInProject($responsableUser,$project){
$arrays = $project->getResponsableFoncierUser();
foreach ($arrays as $item){
$responsable = $item->getResponsable();
if($responsable == $responsableUser){
return true;
break;
}
}
return false;
}
public function checkResponsableInProject($responsableUser,$project){
$arrays = $project->getResponsableUser();
foreach ($arrays as $item){
$responsable = $item->getResponsable();
if($responsable == $responsableUser){
return true;
break;
}
}
return false;
}
public function checkResponsableDeveloppementInProject($responsableUser,$project){
$arrays = $project->getResponsableDeveloppement();
foreach ($arrays as $item){
$responsable = $item->getResponsable();
if($responsable == $responsableUser){
return true;
break;
}
}
return false;
}
public function checkConstructeurInProject($constructeurUser,$project){
$arrays = $project->getConstructeurUser();
foreach ($arrays as $item){
$constructeur = $item->getConstructeur();
if($constructeur == $constructeurUser){
return true;
break;
}
}
return false;
}
public function checkEtapIntervenant($etapNum,$user){
$arrays = $this->em->getRepository(UserDroit::class)->getByEtapNumUser($etapNum,$user->getId());
return $arrays;
}
public function checkDroitProfileExtern($user,$champ){
if(in_array($user->getTypeAcces(),[User::ACCES_intervenant,User::ACCES_visiteur,User::ACCES_comptable])){
$arrays = $this->em->getRepository(UserDroitGlobal::class)->getByUserAndChamp($user->getId(),$champ);
return $arrays;
}else{
return true;
}
}
public function getAllParentAndActiveColonneXls($parentId){
$arrays = $this->em->getRepository(ParametrageXlsProject::class)->getAllParentAndActive($parentId);
return $arrays;
}
public function getAllIntervenant(){
$arrays = $this->em->getRepository(User::class)->getIntervenants();
return $arrays;
}
public function getEtapsByCategory($categoryNum,$isNewConstruction){
$arrays = $this->em->getRepository(Etaps::class)->getEtapsByCategory($categoryNum,$isNewConstruction);
return $arrays;
}
public function getTypologie(){
$arrays = $this->em->getRepository(TypologieProject::class)->findAll();
return $arrays;
}
public function getCommentsProject($project){
$arrays = $this->projectService->getCommentsProject($project);
return $arrays;
}
public function getTimeComment($dateTime){
$str = $this->projectService->getTimeComment($dateTime);
return $str;
}
public function getChampsUpdates(){
$array = $this->etapsService->getChampsUpdates();
return $array;
}
public function getChampsExport(){
$array = $this->etapsService->getChampsExport();
return $array;
}
public function getFournisseursActive(){
$fournisseurs = $this->em->getRepository(Fournisseur::class)->findAllActive();
return $fournisseurs;
}
public function getAncientStatut($project,$date,$date2,$isNew=1){
if($isNew == 1){
$statusTrackers = $this->em->getRepository(StatusTracker::class)->getNewStatut($date,$date2,$project->getId());
if($statusTrackers){
if(count($statusTrackers)>=1){
return isset($statusTrackers[0]) ? $this->projectService->getStatusTrackerStr($statusTrackers[0]->getStatus()): '-';
}
}
}else{
$statusTrackers = $this->em->getRepository(StatusTracker::class)->getAncientStatut($date,$project->getId());
if($statusTrackers){
if(count($statusTrackers)>0){
return isset($statusTrackers[0]) ? $this->projectService->getStatusTrackerStr($statusTrackers[0]->getStatus()): '-';
}
}
}
return '-';
}
public function getStatutDate($project,$date){
$statusTrackers = $this->em->getRepository(StatusTracker::class)->getAncientStatut($date,$project->getId());
if($statusTrackers){
if(count($statusTrackers)>0){
return $statusTrackers[0];
}
}
return false;
}
public function getDevsRapportSortant($projects,$status){
$array = [];
if($projects){
foreach ($projects as $statusTracker){
if($statusTracker->getProject()->getDeveloppeur()){
if($status >= $statusTracker->getStatus() ){
$array[$statusTracker->getProject()->getDeveloppeur()->getId()]['projects']['moins'][] = $statusTracker->getProject() ;
}else {
$array[$statusTracker->getProject()->getDeveloppeur()->getId()]['projects']['plus'][] = $statusTracker->getProject() ;
}
$array[$statusTracker->getProject()->getDeveloppeur()->getId()]['developeur'] = $statusTracker->getProject()->getDeveloppeur()? $statusTracker->getProject()->getDeveloppeur()->getFirstname().' '.$statusTracker->getProject()->getDeveloppeur()->getLastname(): null ;
$array[$statusTracker->getProject()->getDeveloppeur()->getId()]['coulour'] = $statusTracker->getProject()->getDeveloppeur()? $statusTracker->getProject()->getDeveloppeur()->getCouleurRapport(): null ;
}else{
$array['notDev']['notDev'][] = $statusTracker->getProject() ;
$array['notDev']['coulour'] = null ;
}
}
}
return $array ;
}
public function getDevsRapport($projects){
$array = [];
if($projects){
foreach ($projects as $project){
if($project->getDeveloppeur()){
$array[$project->getDeveloppeur()->getId()]['projects'][] = $project ;
$array[$project->getDeveloppeur()->getId()]['developeur'] = $project->getDeveloppeur()? $project->getDeveloppeur()->getFirstname().' '.$project->getDeveloppeur()->getLastname(): null ;
$array[$project->getDeveloppeur()->getId()]['coulour'] = $project->getDeveloppeur()? $project->getDeveloppeur()->getCouleurRapport(): null ;
}else{
$array['notDev']['notDev'][] = $project ;
$array['notDev']['coulour'] = null ;
}
}
}
if($array) {
foreach ($array as &$item) {
if (isset($item['projects'])) {
$item['pourcentage'] = count($item['projects'])/count($projects) * 100;
}elseif(isset($item['notDev'])){
$item['pourcentage'] = count($item['notDev'])/count($projects) * 100;
}
}
}
$pourcentage = array_column($array, 'pourcentage');
array_multisort($pourcentage, SORT_DESC, $array);
return $array ;
}
public function getDevsRapportConstructionSortant($projects,$status){
$array = [];
if($projects){
foreach ($projects as $statusTracker){
if($statusTracker->getProject()->getResponsableUser() && count($statusTracker->getProject()->getResponsableUser())){
$responsable0 = $statusTracker->getProject()->getResponsableUser()[0];
if($status >= $statusTracker->getStatus() ){
$array[$responsable0->getResponsable()->getId()]['projects']['moins'][] = $statusTracker->getProject() ;
}else {
$array[$responsable0->getResponsable()->getId()]['projects']['plus'][] = $statusTracker->getProject() ;
}
foreach ($statusTracker->getProject()->getResponsableUser() as $responsable){
$array[$responsable0->getResponsable()->getId()]['responsableConstruction'][] = $responsable->getResponsable()->getFirstname().' '.$responsable->getResponsable()->getLastname() ;
}
$array[$responsable0->getResponsable()->getId()]['coulour'] = $responsable0 ? $responsable0->getResponsable()->getCouleurRapport(): null ;
}else{
$array['notDev']['notDev'][] = $statusTracker->getProject() ;
$array['notDev']['coulour'] = null ;
}
}
}
return $array ;
}
public function getDevsRapportConstruction($projects){
$array = [];
if($projects){
foreach ($projects as $project){
if($project->getResponsableUser() && count($project->getResponsableUser())>0){
$responsable0 = $project->getResponsableUser()[0];
$array[$responsable0->getResponsable()->getId()]['projects'][] = $project ;
foreach ($project->getResponsableUser() as $responsable){
$array[$responsable0->getResponsable()->getId()]['responsableConstruction'][] = $responsable->getResponsable()->getFirstname().' '.$responsable->getResponsable()->getLastname() ;
}
$array[$responsable0->getResponsable()->getId()]['coulour'] = $responsable0 ? $responsable0->getResponsable()->getCouleurRapport(): null ;
}else{
$array['notDev']['notDev'][] = $project ;
$array['notDev']['coulour'] = null ;
}
}
}
if($array) {
foreach ($array as &$item) {
if (isset($item['projects'])) {
$item['pourcentage'] = count($item['projects'])/count($projects) * 100;
}elseif(isset($item['notDev'])){
$item['pourcentage'] = count($item['notDev'])/count($projects) * 100;
}
}
}
$pourcentage = array_column($array, 'pourcentage');
array_multisort($pourcentage, SORT_DESC, $array);
return $array ;
}
public function getAncientStatutConstruction($project,$date,$date2,$isNew=1){
if($isNew == 1){
$statusTrackers = $this->em->getRepository(StatusTrackerConstruction::class)->getNewStatut($date,$date2,$project->getId());
if($statusTrackers){
if(count($statusTrackers)>=1){
return isset($statusTrackers[0]) ? $this->projectService->getStatusTrackerConstructionStr($statusTrackers[0]->getStatus()): '-';
}
}
}else{
$statusTrackers = $this->em->getRepository(StatusTrackerConstruction::class)->getAncientStatut($date,$project->getId());
if($statusTrackers){
if(count($statusTrackers)>0){
return isset($statusTrackers[0]) ? $this->projectService->getStatusTrackerConstructionStr($statusTrackers[0]->getStatus()): '-';
}
}
}
return '-';
}
public function getStatutDateConstruction($project,$date){
$statusTrackers = $this->em->getRepository(StatusTrackerConstruction::class)->getAncientStatut($date,$project->getId());
if($statusTrackers){
if(count($statusTrackers)>0){
return $statusTrackers[0];
}
}
return false;
}
public function getEtapByProject($project,$etapNum){
$etapEntityClass = 'App\\Entity\\Etap' . $etapNum;
$etapEntity = $this->em->getRepository($etapEntityClass)->findOneBy(['project' => $project->getId()]);
return $etapEntity ;
}
public function getAllEtapsPhotosMultiple($project){
$photos = [];
$etapsDone = [];
$etaps = $this->em->getRepository(Etaps::class)->findAll();
foreach ($etaps as $etapDef){
$num = $etapDef->getNum();
if(isset($etapsDone[$num])){
continue;
}
$etapsDone[$num] = true;
$etapEntityClass = 'App\\Entity\\Etap' . $num;
if(!class_exists($etapEntityClass)){
continue;
}
$etapEntity = $this->em->getRepository($etapEntityClass)->findOneBy(['project' => $project->getId()]);
if($etapEntity && method_exists($etapEntity, 'getFilePhotosMultiple')){
foreach ($etapEntity->getFilePhotosMultiple() as $doc){
if(!$doc->getIsArchived() && $this->checkIfInArrayString(['.png', '.jpg', '.jpeg', 'heic'], strtolower($doc->getPath()))){
$photos[] = $doc;
}
}
}
}
return $photos;
}
public function getMontantAvoirRestantByFacture($facture){
$mantantTotalAvoir = 0;
$mantantTotalAvoirRestant = 0;
if($facture){
$avoirs = $this->em->getRepository(AvoirFactureFinance::class)->findBy(['financeFacture'=>$facture->getId()]);
$mantantFacture = (float)(str_replace(',','.',$facture->getMonatantTtc()));
if($avoirs){
foreach ($avoirs as $avoir){
if($avoir->getMonatantAvoirTtc()){
$mantantTotalAvoir += (float)(str_replace(',','.',$avoir->getMonatantAvoirTtc()));
}else{
$mantantTotalAvoir += 0;
}
}
}
if($mantantFacture >= $mantantTotalAvoir){
$mantantTotalAvoirRestant = 0;
}else{
$mantantTotalAvoirRestant = $mantantTotalAvoir - $mantantFacture;
}
}
return $mantantTotalAvoirRestant;
}
public function getAvoirByFacture($facture){
$avoirs = $this->em->getRepository(AvoirFactureFinance::class)->findBy(['financeFacture'=>$facture->getId()]);
return $avoirs;
}
public function getfacturesByAvoir($avoir){
$avoirs = $this->em->getRepository(AvoirFactureFinance::class)->findBy(['avoir'=>$avoir->getId()]);
return $avoirs;
}
public function sommeValue($val1,$val2){
$val1 = (float)(str_replace(',','.',$val1));
$val2 = (float)(str_replace(',','.',$val2));
return $val1 + $val2;
}
public function getHistoriqueAvoirFacture($avoir=null,$facture=null){
$array = null;
if($avoir){
$array = $this->em->getRepository(HistoryFactureAvoir::class)->findBy(['avoir'=>$avoir->getId()],['id'=>'desc']);
}elseif($facture){
$array = $this->em->getRepository(HistoryFactureAvoir::class)->findBy(['factureFinance'=>$facture->getId()],['id'=>'desc']);
}
return $array;
}
public function checkBailExpireeTimeline($project){
$rep = $this->notifications->getAlertBailTimeline($project);
return $rep;
}
public function checkAlertPcExpireeTimeline($project){
$rep = $this->notifications->getAlertPcTimeline($project);
return $rep;
}
public function checkAlertT0ExpireeTimeline($project){
$rep = $this->notifications->getAlertT0Timeline($project);
return $rep;
}
public function checkBailExpiree($project){
$rep = $this->notifications->getAlertBail($project);
return $rep;
}
public function checkPCDPExpiree($project){
$rep = $this->notifications->getAlertPc($project);
return $rep;
}
public function checkAlertEtap1And2($project){
$rep = $this->etapsService->getAlertsEtap1AndEtap2($project);
return $rep;
}
public function checkT0Expiree($project){
$rep = $this->notifications->getAlertT0($project);
return $rep;
}
public function disabledOptionFileName($project,$fileNameInput,$etapNum){
$etapNum = $etapNum;
$fileName = $fileNameInput;
$etapClass = 'App\\Entity\\Etap'.$etapNum;
$etap = $this->em->getRepository($etapClass)->findOneBy(['project'=>$project->getId()]);
$isNotEmpty = false;
if($etap){
$classMetadata = $this->em->getClassMetadata($etapClass);
$associationMappings = $classMetadata->getAssociationMapping($fileName);
if ($associationMappings['type'] === \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_MANY){
$nameGeteurFiled = 'get'.ucfirst($fileName);
$filedValue = $etap->{$nameGeteurFiled}();
if(!$filedValue->isEmpty()){
if($fileName == 'fileCrdSigneeMultiple'){
foreach ($filedValue as $item){
if($item->getIsArchived()){
}else{
$isNotEmpty = true;
}
}
$filedValue2 = $etap->getFileCrdSigneeSansPtfMultiple();
if(!$filedValue2->isEmpty()) {
foreach ($filedValue2 as $item) {
if ($item->getIsArchived()) {
} else {
$isNotEmpty = true;
}
}
}
}elseif ($fileName == 'fileCrdSigneeSansPtfMultiple'){
foreach ($filedValue as $item){
if($item->getIsArchived()){
}else{
$isNotEmpty = true;
}
}
$filedValue2 = $etap->getFileCrdSigneeMultiple();
if(!$filedValue2->isEmpty()){
foreach ($filedValue2 as $item){
if($item->getIsArchived()){
}else{
$isNotEmpty = true;
}
}
}
}
else{
foreach ($filedValue as $item){
if($item->getIsArchived()){
}else{
$isNotEmpty = true;
}
}
}
}
}else{
$nameGeteurFiled = 'get'.ucfirst($fileName);
$filedValue = $etap->{$nameGeteurFiled}();
if($filedValue){
$isNotEmpty = true;
}
}
}
return $isNotEmpty;
}
public function getAllFileNameTimeLine($project,$fileNameInput,$etapNum){
$etapNum = $etapNum;
$fileName = $fileNameInput;
$etapClass = 'App\\Entity\\Etap'.$etapNum;
$etap = $this->em->getRepository($etapClass)->findOneBy(['project'=>$project->getId()]);
$targetEntity = 'App\Entity\DocUpload';
$file = [];
if($etap){
$classMetadata = $this->em->getClassMetadata($etapClass);
$associationMappings = $classMetadata->getAssociationMapping($fileName);
if($associationMappings['targetEntity'] === $targetEntity){
if ($associationMappings['type'] === \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_MANY){
$nameGeteurFiled = 'get'.ucfirst($fileName);
// if($etapNum == 10){
// $condition = false;
// if($etap->getIsPtf()){
// if(in_array($fileName,['filePtfMultiple','fileCrdSigneeMultiple','filePreuveVirementMultiple'])){
// $condition = true;
// }
// }else{
// if(in_array($fileName,['fileCrdSigneeSansPtfMultiple','filePreuveVirementSansPtfMultiple'])){
// $condition = true;
// }
// }
// if($condition){
// $filedValue = $etap->{$nameGeteurFiled}();
// if(!$filedValue->isEmpty()){
// foreach ($filedValue as $item){
// if($item->getIsArchived()){
//
// }else{
// $file[] = $item;
// }
// }
// }
// }
// }else{
$filedValue = $etap->{$nameGeteurFiled}();
if(!$filedValue->isEmpty()){
foreach ($filedValue as $item){
if($item->getIsArchived()){
}else{
$file[] = $item;
}
}
}
// }
}else{
$nameGeteurFiled = 'get'.ucfirst($fileName);
$filedValue = $etap->{$nameGeteurFiled}();
if($filedValue){
$file[] = $filedValue;
}
}
}
}
return $file;
}
public function getAllFileNameTimeLineCategory($project,$etapNum){
$etapNum = $etapNum;
$etapClass = 'App\\Entity\\Etap'.$etapNum;
$etap = $this->em->getRepository($etapClass)->findOneBy(['project'=>$project->getId()]);
$file = [];
$fileName = 'categorys';
if($etap){
$classMetadata = $this->em->getClassMetadata($etapClass);
$ssociationMappings = $classMetadata->getAssociationMappings();
if(array_key_exists('categorys',$ssociationMappings)){
$associationMappings = $classMetadata->getAssociationMapping($fileName);
if(isset($associationMappings['targetEntity']) && $associationMappings['targetEntity'] == 'App\Entity\CategoryDocument'){
if ($associationMappings['type'] === \Doctrine\ORM\Mapping\ClassMetadata::ONE_TO_MANY){
$nameGeteurFiled = 'get'.ucfirst($fileName);
$filedValueCat = $etap->{$nameGeteurFiled}();
if(!$filedValueCat->isEmpty()){
foreach ($filedValueCat as $item){
if(!$item->getDocuments()->isEmpty()){
foreach ($item->getDocuments() as $document){
$doc = $document->getDocUpload() ;
if($doc){
$file[] = $doc;
}
}
}
}
}
}
}
}
}
return $file;
}
public function getAllFileNameTimeLineManyToMany($project,$etapNum,$etapsFilesManyToManyName,$fileNameInput,$class){
$etapNum = $etapNum;
$etapClass = 'App\\Entity\\Etap'.$etapNum;
$etap = $this->em->getRepository($etapClass)->findOneBy(['project'=>$project->getId()]);
$file = [];
$fileName = $fileNameInput;
$targetEntity = 'App\Entity\DocUpload';
if($etap){
$classMetadata = $this->em->getClassMetadata($etapClass);
$ssociationMappings = $classMetadata->getAssociationMappings();
if(array_key_exists($etapsFilesManyToManyName,$ssociationMappings)){
$associationMappings = $classMetadata->getAssociationMapping($etapsFilesManyToManyName);
if(isset($associationMappings['targetEntity'])){
if ($associationMappings['type'] === \Doctrine\ORM\Mapping\ClassMetadata::ONE_TO_MANY){
$nameGeteurFiled = 'get'.ucfirst($etapsFilesManyToManyName);
$filedValueCat = $etap->{$nameGeteurFiled}();
if(!$filedValueCat->isEmpty()){
$etapClassDetail = 'App\\Entity\\'.$class;
$classMetadataDetail = $this->em->getClassMetadata($etapClassDetail);
$ssociationMappingsDetail = $classMetadataDetail->getAssociationMappings();
if(array_key_exists($fileNameInput,$ssociationMappingsDetail)){
foreach ($filedValueCat as $item){
$associationMappingsDetail = $classMetadataDetail->getAssociationMapping($fileNameInput);
if($associationMappingsDetail['targetEntity'] === $targetEntity){
if ($associationMappingsDetail['type'] === \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_MANY){
$nameGeteurFiledDetail = 'get'.ucfirst($fileName);
$filedValueDetail = $item->{$nameGeteurFiledDetail}();
if(!$filedValueDetail->isEmpty()){
foreach ($filedValueDetail as $item2){
if($item2->getIsArchived()){
}else{
$file[] = $item2;
}
}
}
}else{
$nameGeteurFiledDetail = 'get'.ucfirst($fileName);
$filedValueDetail = $item->{$nameGeteurFiledDetail}();
if($filedValueDetail){
$file[] = $filedValueDetail;
}
}
}
}
}
}
}
}
}
}
return $file;
}
public function getAllFileNameTimeLineManyToMany2($project,$etapNum,$etapsFilesManyToManyName,$fileNameInput,$class,$etapsFilesManyToManyName2,$class2){
$etapNum = $etapNum;
$etapClass = 'App\\Entity\\Etap'.$etapNum;
$etap = $this->em->getRepository($etapClass)->findOneBy(['project'=>$project->getId()]);
$file = [];
$fileName = $fileNameInput;
$targetEntity = 'App\Entity\DocUpload';
if($etap){
$classMetadata = $this->em->getClassMetadata($etapClass);
$ssociationMappings = $classMetadata->getAssociationMappings();
if(array_key_exists($etapsFilesManyToManyName,$ssociationMappings)){
$associationMappings = $classMetadata->getAssociationMapping($etapsFilesManyToManyName);
if(isset($associationMappings['targetEntity'])){
if ($associationMappings['type'] === \Doctrine\ORM\Mapping\ClassMetadata::ONE_TO_MANY){
$nameGeteurFiled = 'get'.ucfirst($etapsFilesManyToManyName);
$filedValueCat = $etap->{$nameGeteurFiled}();
if(!$filedValueCat->isEmpty()){
$etapClassDetail = 'App\\Entity\\'.$class;
$classMetadataDetail = $this->em->getClassMetadata($etapClassDetail);
$ssociationMappingsDetail = $classMetadataDetail->getAssociationMappings();
if(array_key_exists($etapsFilesManyToManyName2,$ssociationMappingsDetail)) {
foreach ($filedValueCat as $item1) {
$associationMappings2 = $classMetadataDetail->getAssociationMapping($etapsFilesManyToManyName2);
if (isset($associationMappings2['targetEntity'])) {
if ($associationMappings2['type'] === \Doctrine\ORM\Mapping\ClassMetadata::ONE_TO_MANY) {
$nameGeteurFiled2 = 'get' . ucfirst($etapsFilesManyToManyName2);
$filedValueCat2 = $item1->{$nameGeteurFiled2}();
if (!$filedValueCat2->isEmpty()) {
$etapClassDetail2 = 'App\\Entity\\' . $class2;
$classMetadataDetail2 = $this->em->getClassMetadata($etapClassDetail2);
$ssociationMappingsDetail2 = $classMetadataDetail2->getAssociationMappings();
if(array_key_exists($fileNameInput,$ssociationMappingsDetail2)){
foreach ($filedValueCat2 as $item){
$associationMappingsDetail2 = $classMetadataDetail2->getAssociationMapping($fileNameInput);
if($associationMappingsDetail2['targetEntity'] === $targetEntity){
if ($associationMappingsDetail2['type'] === \Doctrine\ORM\Mapping\ClassMetadata::MANY_TO_MANY){
$nameGeteurFiledDetail = 'get'.ucfirst($fileName);
$filedValueDetail = $item->{$nameGeteurFiledDetail}();
if(!$filedValueDetail->isEmpty()){
foreach ($filedValueDetail as $item2){
if($item2->getIsArchived()){
}else{
$file[] = $item2;
}
}
}
}else{
$nameGeteurFiledDetail = 'get'.ucfirst($fileName);
$filedValueDetail = $item->{$nameGeteurFiledDetail}();
if($filedValueDetail){
$file[] = $filedValueDetail;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return $file;
}
public function getAllFileNameFactureProject($project){
$factures = $this->em->getRepository(FactureFinance::class)->getFacturesProject([$project->getId()]);
$file = [];
foreach ($factures as $facture){
if($facture->getFileFacture()){
$file[] = $facture->getFileFacture();
}
}
return $file;
}
public function getAllFileNameAvoirProject($project){
$factures = $this->em->getRepository(Avoir::class)->getAvoirsProject([$project->getId()]);
$file = [];
foreach ($factures as $facture){
if($facture->getFileAvoir()){
$file[] = $facture->getFileAvoir();
}
}
return $file;
}
public function getDocsName($project = null){
$docsName = $this->projectService->getDocsName($project);
return $docsName;
}
public function checkEtap3StatusFermee($project){
$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()]);
if(($etap171 && $etap171->getStatus() == Etaps::STATUS_FERMEE)
&& ($etap172 && $etap172->getStatus() == Etaps::STATUS_FERMEE)
&& ($etap173 && $etap173->getStatus() == Etaps::STATUS_FERMEE)
&& ($etap174 && $etap174->getStatus() == Etaps::STATUS_FERMEE)
&& ($etap175 && $etap175->getStatus() == Etaps::STATUS_FERMEE)
){
return true;
}else{
return false;
}
}
public function checkEtap3Status($project){
$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()]);
if(($etap171 && $etap171->getStatus() == Etaps::STATUS_FERMEE)
&& ($etap172 && $etap172->getStatus() == Etaps::STATUS_FERMEE)
&& ($etap173 && $etap173->getStatus() == Etaps::STATUS_FERMEE)
&& ($etap174 && $etap174->getStatus() == Etaps::STATUS_FERMEE)
&& ($etap175 && $etap175->getStatus() == Etaps::STATUS_FERMEE)
){
return Etaps::STATUS_FERMEE;
}elseif(($etap171 && $etap171->getStatus() == Etaps::STATUS_VALIDE)
&& ($etap172 && $etap172->getStatus() == Etaps::STATUS_VALIDE)
&& ($etap173 && $etap173->getStatus() == Etaps::STATUS_VALIDE)
&& ($etap174 && $etap174->getStatus() == Etaps::STATUS_VALIDE)
&& ($etap175 && $etap175->getStatus() == Etaps::STATUS_VALIDE)
){
return Etaps::STATUS_VALIDE;
}elseif(($etap171 && in_array($etap171->getStatus() , [Etaps::STATUS_DEMANDE]))
|| ($etap172 && in_array($etap172->getStatus() , [Etaps::STATUS_DEMANDE]))
|| ($etap173 && in_array($etap173->getStatus() , [Etaps::STATUS_DEMANDE]))
|| ($etap174 && in_array($etap174->getStatus() , [Etaps::STATUS_DEMANDE]))
|| ($etap175 && in_array($etap175->getStatus() , [Etaps::STATUS_DEMANDE]))
){
return Etaps::STATUS_DEMANDE;
}elseif(($etap171 && in_array($etap171->getStatus() , [Etaps::STATUS_EN_ATTENT]))
|| ($etap172 && in_array($etap172->getStatus() , [Etaps::STATUS_EN_ATTENT]))
|| ($etap173 && in_array($etap173->getStatus() , [Etaps::STATUS_EN_ATTENT]))
|| ($etap174 && in_array($etap174->getStatus() , [Etaps::STATUS_EN_ATTENT]))
|| ($etap175 && in_array($etap175->getStatus() , [Etaps::STATUS_EN_ATTENT]))
){
return Etaps::STATUS_EN_ATTENT;
}elseif(($etap171 && in_array($etap171->getStatus() , [Etaps::STATUS_REFUSE]))
|| ($etap172 && in_array($etap172->getStatus() , [Etaps::STATUS_REFUSE]))
|| ($etap173 && in_array($etap173->getStatus() , [Etaps::STATUS_REFUSE]))
|| ($etap174 && in_array($etap174->getStatus() , [Etaps::STATUS_REFUSE]))
|| ($etap175 && in_array($etap175->getStatus() , [Etaps::STATUS_REFUSE]))
){
return Etaps::STATUS_REFUSE;
}
elseif(($etap171 && in_array($etap171->getStatus() , [Etaps::STATUS_EN_COURS]))
|| ($etap172 && in_array($etap172->getStatus() , [Etaps::STATUS_EN_COURS]))
|| ($etap173 && in_array($etap173->getStatus() , [Etaps::STATUS_EN_COURS]))
|| ($etap174 && in_array($etap174->getStatus() , [Etaps::STATUS_EN_COURS]))
|| ($etap175 && in_array($etap175->getStatus() , [Etaps::STATUS_EN_COURS]))
){
return Etaps::STATUS_EN_COURS;
}else{
return false;
}
}
public function checkEtap3StatusName($project){
$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()]);
if(($etap171 && $etap171->getStatus() == Etaps::STATUS_EN_ATTENT)
|| ($etap172 && $etap172->getStatus() == Etaps::STATUS_EN_ATTENT)
|| ($etap173 && $etap173->getStatus() == Etaps::STATUS_EN_ATTENT)
|| ($etap174 && $etap174->getStatus() == Etaps::STATUS_EN_ATTENT)
|| ($etap175 && $etap175->getStatus() == Etaps::STATUS_EN_ATTENT)
){
return 'En attente de validation';
}elseif (($etap171 && $etap171->getStatus() == Etaps::STATUS_REFUSE)
|| ($etap172 && $etap172->getStatus() == Etaps::STATUS_REFUSE)
|| ($etap173 && $etap173->getStatus() == Etaps::STATUS_REFUSE)
|| ($etap174 && $etap174->getStatus() == Etaps::STATUS_REFUSE)
|| ($etap175 && $etap175->getStatus() == Etaps::STATUS_REFUSE)
){
return 'L\'etape a été refusé';
}elseif (($etap171 && $etap171->getStatus() == Etaps::STATUS_DEMANDE)
|| ($etap172 && $etap172->getStatus() == Etaps::STATUS_DEMANDE)
|| ($etap173 && $etap173->getStatus() == Etaps::STATUS_DEMANDE)
|| ($etap174 && $etap174->getStatus() == Etaps::STATUS_DEMANDE)
|| ($etap175 && $etap175->getStatus() == Etaps::STATUS_DEMANDE)
){
return 'Demande de complément';
}else{
return false;
}
}
public function getDocUploadMultipleNotArchiveEntity($array){
$val = null;
if(count($array)>0){
foreach ($array as $value){
if(!$value->getIsArchived()){
$val = $value;
}
}
}
return $val;
}
public function getDocUploadMultipleNotArchiveEntityImage($array){
$val = null;
if(count($array)>0){
foreach ($array as $value){
if(!$value->getIsArchived() and ($this->checkIfInArrayString(['.png', '.jpg','.jpeg','heic'],$value->getPath()))){
$val = $value;
}
}
}
return $val;
}
private function checkIfInArrayString($array, $searchingFor) {
foreach ($array as $element) {
if (strpos($searchingFor, $element) !== false) {
return true;
}
}
return false;
}
public function getDocUploadMultipleNotArchive($array){
$token = null;
if(count($array)>0){
foreach ($array as $value){
if(!$value->getIsArchived()){
$token = $value->getToken();
}
}
}
return $token;
}
public function getDocUploadMultipleNotArchiveString($array){
$strTokens = '';
if(count($array)>0){
$lastArray = $array[count($array)-1];
foreach ($array as $value){
if(!$value->getIsArchived()){
$strTokens .= $value->getToken();
if($value->getId() != $lastArray->getId()){
$strTokens .= ',';
}
}
}
}
return $strTokens;
}
public function espaceNumber($str,$chiffreApresVergule = 3){
$formattedNumber = str_replace(',','.',$str);
if($formattedNumber and is_numeric($formattedNumber)){
if(strpos($formattedNumber,'.') or strpos($formattedNumber,',')){
if(strpos($formattedNumber,'.')){
$formattedNumber = number_format($formattedNumber, $chiffreApresVergule, '.', ' ');
}else{
$formattedNumber = number_format($formattedNumber, $chiffreApresVergule, ',', ' ');
}
}else{
$formattedNumber = number_format($formattedNumber, 0, '0', ' ');
}
}
return $formattedNumber;
}
public function checkInformationProprietaireEtap6Raccordement($project){
$etap = $this->em->getRepository(Etap14::class)->findOneBy(['project'=>$project->getId()]);
if($etap){
if(!empty($etap->getAdresseMiseEnService()) or !empty($etap->getCityMiseEnService()) or !empty($etap->getCodePostalMiseEnService()) or !empty($etap->getFirstnameProprietaire()) or !empty($etap->getLastnameProprietaire()) or !empty($etap->getPhoneProprietaire()) ){
return true;
}
}
return false;
}
public function getAbreviation($user=null){
$name = '';
$nameAB = 'X';
$role = '';
$entreprise = null;
if($user){
$name = ucwords((string)$user->getFirstname()).' '.ucwords((string)$user->getLastname());
$role = $user->getRoleStringComplet();
$entreprise = $user->getEntreprise() ? ucfirst($user->getEntreprise()->getName()) : null;
$nameAB = substr((string)$user->getFirstname(), 0, 1) .substr((string)$user->getLastname(), 0, 1);
}
return ['entreprise'=>$entreprise,'role'=>$role,'name' => $name,'nameAB' => strtoupper($nameAB)];
}
public function getDocsPartage($project){
$docs = $this->uploadService->getFilesPorjectPartage($project);
return $docs ;
}
public function getEpcs($role){
$users = $this->em->getRepository(User::class)->getUserByRole($role);
return $users ;
}
public function getUserByRoles($roles){
$users = $this->em->getRepository(User::class)->getUserByRoles($roles);
return $users ;
}
public function checkOpenEtap($etap){
if($etap) {
if ($etap->getEtap()->getCategory()->getNum() == 1) {
if($etap->getProject()->getIsOpenCat1()){
return true;
}
} elseif ($etap->getEtap()->getCategory()->getNum() == 2) {
if($etap->getProject()->getIsOpenCat2()){
return true;
}
} elseif ($etap->getEtap()->getCategory()->getNum() == 3) {
if($etap->getProject()->getIsOpenCat3()){
return true;
}
} elseif ($etap->getEtap()->getCategory()->getNum() == 4) {
if($etap->getProject()->getIsOpenCat4()){
return true;
}
}
}
return false;
}
public function completudeCategory($project){
$array = $this->etapsService->completudeValideEtapProject($project);
$cats = $this->em->getRepository(EtapsCategory::class)->findAll();
if(isset($array['category'])){
return $this->twig->render('user/etaps/completude.html.twig', [
'completude' => $array,
'cats' => $cats,
]);
}else{
return [];
}
}
public function completudeDocsCategory($project){
$array = $this->etapsService->completudeValideDocumentEtapProject($project);
$cats = $this->em->getRepository(EtapsCategory::class)->findAll();
if(isset($array['category'])){
return $this->twig->render('user/etaps/completudeDocs.html.twig', [
'completude' => $array,
'cats' => $cats,
'project' => $project,
]);
}else{
return [];
}
}
public function getNotisNotLu($user){
$notifs = $this->notifications->getNotifictionNotLu($user);
return $notifs;
}
public function getSpvs(){
$spvs = $this->em->getRepository(Spv::class)->getSpvEnabled();
return $spvs;
}
public function getEtapNameByNum($num){
$etap = $this->em->getRepository(Etaps::class)->findOneBy(['num'=>$num]);
return $etap ? $etap->getName():' ';
}
public function getReferencePrice($referenceId){
$equipementPrice = $this->em->getRepository(EquipementCommandeProduitPrix::class)->findOneBy(['equipementReference'=>$referenceId]);
return $equipementPrice ? $equipementPrice->getPrixUnitaire() : 0;
}
public function getEtapByNumAndProject($num,$project){
$etapEntity = 'App\\Entity\\Etap'.$num;
if($project){
$etap = $this->em->getRepository($etapEntity)->findOneBy(['project'=>$project->getId()]);
return $etap ;
}else{
return null;
}
}
public function getTimelinePointEtapByNum($project,$num,$etapCurrent){
if(is_object($project)){
$etapEntity = 'App\\Entity\\Etap'.$num;
$etap = $this->em->getRepository($etapEntity)->findOneBy(['project'=>$project->getId()]);
return $this->twig->render('user/etaps/timeline-point.html.twig', [
'etap' => $etap,
'etapCurrent' => $etapCurrent
]);
}
return ' ';
}
public function getCommentEtapByNum($project,$num){
if(is_object($project)){
$comments = $this->em->getRepository(CommentEtap::class)->findBy(['project'=>$project->getId(),'etapNum'=>$num]);
$response = $this->twig->render('user/etaps/etapComment.html.twig',['comments'=>$comments,'multiple'=>true]);
return $response;
}
return ' ';
}
public function checkCommentEtapByNum($project,$num){
if(is_object($project)){
$comments = $this->em->getRepository(CommentEtap::class)->findBy(['project'=>$project->getId(),'etapNum'=>$num]);
if($comments){
return true;
}
}
return false;
}
public function getDateFichierFactureFinancePaiement($factureFinancePaiment){
if(is_object($factureFinancePaiment)){
$details = $this->em->getRepository(FactureFinancePaiementDetail::class)->findBy(['factureFinancePaiement'=>$factureFinancePaiment->getId()]);
if($details){
$detail = $details[0];
if($detail->getFactureFinance() && $detail->getFactureFinance()->getDatePaiementGenerateFichier()){
return $detail->getFactureFinance()->getDatePaiementGenerateFichier();
}
}
}
return null;
}
public function getTypeValorisation(){
$typeValorisations = $this->em->getRepository(TypeValorisation::class)->findAll();
return $typeValorisations;
}
}