Meilleur gestion des dates

This commit is contained in:
Michael RICOIS 2017-01-11 12:20:12 +01:00
parent e8903e3a3b
commit 25db7c39a3

View File

@ -1835,30 +1835,30 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
$etab = array(
'id' => $etabG['id'],
'siret' => $etabG['Siret'],
'siege' => $etabG['Siege'],
'raisonSociale' => $etabG['Nom'],
'sigle' => $etabG['Sigle'],
'enseigne' => $etabG['Enseigne'],
'Adresse' => $etabG['Adresse'],
'adr_comp' => $etabG['Adresse2'],
'adr_num' => $adr['num'],
'adr_btq' => $adr['adr_btq'],
'adr_typeVoie' => $adr['typeVoie'],
'adr_libVoie' => $adr['libVoie'],
'adr_dep' => substr($etabG['CP'], 0, 2),
'siret' => $etabG['Siret'],
'siege' => $etabG['Siege'],
'raisonSociale' => $etabG['Nom'],
'sigle' => $etabG['Sigle'],
'enseigne' => $etabG['Enseigne'],
'Adresse' => $etabG['Adresse'],
'adr_comp' => $etabG['Adresse2'],
'adr_num' => $adr['num'],
'adr_btq' => $adr['adr_btq'],
'adr_typeVoie' => $adr['typeVoie'],
'adr_libVoie' => $adr['libVoie'],
'adr_dep' => substr($etabG['CP'], 0, 2),
'adr_cp' => $etabG['CP'],
'adr_ville' => $etabG['Ville'],
'tel' => $etabG['Tel'],
'fax' => $etabG['Fax'],
'adr_ville' => $etabG['Ville'],
'tel' => $etabG['Tel'],
'fax' => $etabG['Fax'],
'cj' => $etabG['FJ'],
'siren' => $etabG['Siren'],
'nic' => $etabG['Nic'],
'actif' => $etabG['Actif'],
'ape_etab' => $etabG['NafEtab'],
'siren' => $etabG['Siren'],
'nic' => $etabG['Nic'],
'actif' => $etabG['Actif'],
'ape_etab' => $etabG['NafEtab'],
'ape_entrep' => $etabG['NafEnt'],
'autre_id' => $etabG['NumRC'],
'dateMAJ' => Metier_Util_Date::dateT('Ymd', 'Y-m-d', $lastMaj),
'autre_id' => $etabG['NumRC'],
'dateMAJ' => Metier_Util_Date::dateT('Ymd', 'Y-m-d', $lastMaj),
);
}
$timer['accesInfogreffeCarInconnu'] = microtime(true);
@ -2659,25 +2659,38 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
if ($identite['SituationJuridique'] == '') {
$tabAnn = $this->getAnnoncesLegales($siren, 0, 'A', false);
$nbAnn = count($tabAnn);
if (count($tabAnn) > 0) {
if ($nbAnn > 0) {
if ($this->debug) {
file_put_contents('procol.log', "DETECTION ABSORPTION\n", FILE_APPEND);
}
$dateAnn = $tabAnn[$nbAnn-1]['dateInsertionSD'];
$dateAnnCompare = DateTime::createFromFormat('Y-m-d H:i:s', $dateAnn);
$dateAnnCompare->add(new DateInterval('P364D'));
if ($dateAnnCompare >= $dateAnnLastCompare) {
if ($dateAnnCompare > $dateAnnLastCompare) {
$tabRet['SituationJuridique'] = 'A';
if ($this->debug) {
file_put_contents('procol.log', "Entreprise absorbée\n", FILE_APPEND);
}
}
}
}
// Dissolution
if ($identite['SituationJuridique'] == '') {
$tabAnn = $this->getAnnoncesLegales($siren, 0, 'D', false);
$nbAnn = count($tabAnn);
if (count($tabAnn) > 0) {
if ($nbAnn > 0) {
if ($this->debug) {
file_put_contents('procol.log', "DETECTION DISSOLUTION\n", FILE_APPEND);
}
$dateAnn = $tabAnn[$nbAnn-1]['dateInsertionSD'];
$dateAnnCompare = DateTime::createFromFormat('Y-m-d H:i:s', $dateAnn);
$dateAnnCompare->add(new DateInterval('P364D'));
if ($dateAnnCompare >= $dateAnnLastCompare) {
if ($dateAnnCompare > $dateAnnLastCompare) {
$tabRet['SituationJuridique'] = 'D';
if ($this->debug) {
file_put_contents('procol.log', "Entreprise dissolue\n", FILE_APPEND);
}
}
}
}
@ -2686,10 +2699,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
if ($this->debug) {
file_put_contents('procol.log', "SituationJuridique = ".$tabRet['SituationJuridique']."\n", FILE_APPEND);
}
// Fin Situation Juridique
$timer['getAnnoncesLegales'] = microtime(true);
}
} // Fin Situation Juridique
if (($tabInsee['CJ'] > 0 && $tabInsee['CJ'] < 20
|| $tabInsee['CJ'] > 999 && $tabInsee['CJ'] < 2000) && $tabInsee['DIR_FCT']=='') {
@ -2881,10 +2892,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
$tabRet['Mail'] = trim($annCap['Assoc_Mail']);
}
if ($annCap['typeAsso'] == 'ASL' && $tabRet['FJ'] != 9150) {
$tabRet['FJ2'] = $tabRet['FJ'];
$tabRet['FJ2_Lib'] = $tabRet['FJ_lib'];
$tabRet['FJ'] = 9150;
$tabRet['FJ_lib'] = $this->getLibelleFJ(9150);
$tabRet['FJ2'] = $tabRet['FJ'];
$tabRet['FJ2_Lib'] = $tabRet['FJ_lib'];
$tabRet['FJ'] = 9150;
$tabRet['FJ_lib'] = $this->getLibelleFJ(9150);
} elseif ($annCap['typeAsso'] == 'FOD') {
$tabRet['FJ_lib'].= ' (Fonds de dotation)';
}
@ -3072,25 +3083,26 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
}
$tabRet['dir1NomPrenom']=implode(' ', $tabNom);
}
$tabRet['FJ_lib'] = $etabG['FJLib'];
$tabRet['AutreId'] = $etabG['NumRC'];
$tabRet['NafEtab'] = $etabG['NafEtab'];
$tabRet['NafEnt'] = $etabG['NafEnt'];
$tabRet['FJ_lib'] = $etabG['FJLib'];
$tabRet['AutreId'] = $etabG['NumRC'];
$tabRet['NafEtab'] = $etabG['NafEtab'];
$tabRet['NafEnt'] = $etabG['NafEnt'];
$tabRet['NafEntLib'] = $etabG['NafEntLib'];
$tabRet['NafEtabLib'] = $etabG['NafEtabLib'];
$tabRet['SiretSiege'] = $etabG['Siret'];
$tabRet['DateMajRCS'] = $etab['dateMAJ'];
$tabRet['NafEtabLib'] = $etabG['NafEtabLib'];
$tabRet['SiretSiege'] = $etabG['Siret'];
$tabRet['DateMajRCS'] = $etab['dateMAJ'];
$tabRet['numGreffe'] = $etabG['NumGreffe'];
$tabRet['numRC'] = $etabG['NumRC2'];
$tabRet['Enseigne'] = $etabG['Enseigne'];
$tabRet['Enseigne'] = $etabG['Enseigne'];
$iRncs = new Metier_Partenaires_MRncs($this->iDb);
$tabRet['Tribunal'] = $iRncs->getCodeBodaccTribunal($etabG['NumGreffe']);
$tabRet['Tribunal'] = $iRncs->getCodeBodaccTribunal($etabG['NumGreffe']);
}
if ($tabRet['Siege']==1 && $tabRet['Actif'] && $tabRet['Tribunal']=='') {
$tabRet['Tribunal'] = $tabCodeTri;
}
// RNCS Entrep et Etab, RM
if (intval($siren) > 0) {
$stmt = $this->conn->executeQuery("SELECT siren, sirenValide, actif, numGreffe, triCode,
triId, numRC, numRC2, raisonSociale, nom, prenom, nomUsage, sigle, dateNaiss,
@ -4586,8 +4598,19 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
// --- Liste des jugements principaux - Tri chronologique par date de jugement
foreach ($tabRet as $i => $ann) {
$item = new stdClass();
$item->date = str_replace('-', '', $ann['dateJugement']);
$item->dateISO8601 = $ann['dateJugement'];
$dateEff = str_replace('-', '', $ann['dateEffet'])*1;
$dateJug = str_replace('-', '', $ann['dateJugement'])*1;
$datePar = str_replace('-', '', $ann['DateParution'])*1;
if ($dateEff > 0) {
$item->date = $dateEff;
$item->dateISO8601 = $ann['dateEffet'];
} elseif ($dateJug > 0) {
$item->date = $dateJug;
$item->dateISO8601 = $ann['dateJugement'];
} elseif ($datePar > 0) {
$item->date = $datePar;
$item->dateISO8601 = $ann['DateParution'];
}
$item->code = $ann['evenements'][0]['CodeEven'];
$tabJugements[] = $item;
// Detection TopDepart Cloture
@ -4755,10 +4778,14 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
$derExercice = $bilan['dateExercice'];
}
}
if ($derExercice > $evenProcolDateLast) {
if ($derExercice > $evenProcolLastDate) {
$derEx = Metier_Util_Date::dateT('Ymd', 'd/m/Y', $derExercice);
$derPr = Metier_Util_Date::dateT('Ymd', 'd/m/Y', $evenProcolDateLast);
$derPr = Metier_Util_Date::dateT('Ymd', 'd/m/Y', $evenProcolLastDate);
$effacement = true;
if ($this->debug) {
file_put_contents('procol.log', "Effacement dissolution : $derExercice > $evenProcolLastDate\n", FILE_APPEND);
}
}
}
}
@ -5190,6 +5217,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
$sql.= " ORDER BY unionDate ASC, FIELD(SourceTable, 'histo', 'annonce', 'bodacc')";
}
}
if ($this->debug && $rubrique == 'D') {
file_put_contents('procol.log', $sql."\n", FILE_APPEND);
}
$stmt = $this->conn->executeQuery($sql);
// --- Traitement des resultats