classMInsee - getAdresse : Add comments and conditional for cedexa

This commit is contained in:
Michael RICOIS 2013-04-25 08:21:21 +00:00
parent 1e6bce4d80
commit 47457aa835

View File

@ -5479,91 +5479,94 @@ ORDER BY a.dateJugement DESC".EOL.EOL.print_r($collecte,true));*/
return false; return false;
} }
function getAdresse($siren, $nic) { /**
/* 'Nom'=>$etab['raisonSociale'], * Retourne l'adresse normalisé
'Tribunal'=>$etab['triCode'], * @param string $siren
'Sigle'=>$etab['sigle'], * @param string $nic
''=>$etab['enseigne'], * @param string $cedexa (1=>On, 0=>Off)
'Adresse'=>trim(preg_replace('/ +/', ' ', trim( $etab['adr_num'] .' '. $etab['adr_btq'] .' '. * @return array
$etab['adr_typeVoie'] .' '. $etab['adr_libVoie']))), * L1_NOM, L2_NOM2, L3_ADRCOMP, L4_VOIE, L5_DISTSP, L6_POST, L7_PAYS
'Adresse2'=>trim(preg_replace('/ +/', ' ', $etab['adr_comp'])), */
'AdresseNum'=>$etab['adr_num'], function getAdresse($siren, $nic, $cedexa=1)
'AdresseBtq'=>$etab['adr_btq'], {
'AdresseVoie'=>$etab['adr_typeVoie'], // Table etablissements
'AdresseRue'=>$etab['adr_libVoie'], $tabIdentite = $this->getIdentiteLight($siren, $nic);
'CP'=>$etab['adr_cp'], $codeVoie = strtoupper($this->getCodeVoie($tabIdentite['AdresseVoie']));
'Ville'=>$etab['adr_ville'],
*/
/** On prend l'information dans la table etablissements **/
$tabIdentite=$this->getIdentiteLight($siren, $nic);
$codeVoie=@strtoupper($this->getCodeVoie($tabIdentite['AdresseVoie']));
//echo $codeVoie.EOL;
if ($codeVoie=='') $codeVoie=$tabIdentite['AdresseVoie']; if ($codeVoie=='') $codeVoie=$tabIdentite['AdresseVoie'];
$tabRet=array('L1_NOM' => $tabIdentite['Nom'], $tabRet = array(
'L2_NOM2' => $tabIdentite['Enseigne'], 'L1_NOM' => $tabIdentite['Nom'],
'L3_ADRCOMP' => '', 'L2_NOM2' => $tabIdentite['Enseigne'],
'L4_VOIE' => trim(preg_replace('/ +/',' ',preg_replace('/^0+/','',$tabIdentite['AdresseNum'].' '. 'L3_ADRCOMP' => '',
$tabIdentite['AdresseBtq'].' '. 'L4_VOIE' => trim(preg_replace('/ +/',' ',preg_replace('/^0+/','',$tabIdentite['AdresseNum'].' '.
$codeVoie.' '. $tabIdentite['AdresseBtq'].' '. $codeVoie.' '. $tabIdentite['AdresseRue']))),
$tabIdentite['AdresseRue']))), 'L5_DISTSP' => $tabIdentite['Adresse2'],
'L5_DISTSP' => $tabIdentite['Adresse2'], 'L6_POST' => $tabIdentite['CP'].' '.$tabIdentite['Ville'],
'L6_POST' => $tabIdentite['CP'].' '.$tabIdentite['Ville'], 'L7_PAYS' => '',
'L7_PAYS' => '', );
);
if (strlen($tabRet['L4_VOIE'])>38) if (strlen($tabRet['L4_VOIE'])>38) {
$tabRet['L4_VOIE']=trim(preg_replace('/ +/',' ',preg_replace('/^0+/','', $tabRet['L4_VOIE']=trim(preg_replace('/ +/',' ',preg_replace('/^0+/','',
$tabIdentite['AdresseNum'].' '. $tabIdentite['AdresseNum'].' '.
$tabIdentite['AdresseBtq'].' '. $tabIdentite['AdresseBtq'].' '.
$tabIdentite['AdresseVoie'].' '. $tabIdentite['AdresseVoie'].' '.
$tabIdentite['AdresseRue']))); $tabIdentite['AdresseRue'])));
}
$tabNotice=$this->getInfosNotice($siren, $nic); //Notice 80 - Override $tabRet
//if ($tabNotice['insL4_VOIE']<>'' && $tabNotice['insL4_VOIE']<>$tabRet['L4_VOIE']) $tabNotice = $this->getInfosNotice($siren, $nic);
// $tabRet['L4_VOIE']=$tabNotice['insL4_VOIE']; if ($tabNotice['L6_POST']<>'' && $tabNotice['L6_POST']<>$tabRet['L6_POST']) {
if ($tabNotice['L6_POST']<>'' && $tabNotice['L6_POST']<>$tabRet['L6_POST']) $tabRet['L6_POST'] = $tabNotice['L6_POST'];
$tabRet['L6_POST']=$tabNotice['L6_POST']; }
$tabTmp=$this->iDbInsee->select('identite','NOM2, ADR_COMP, ADR_DISTSP, PAYS', $tabTmp = $this->iDbInsee->select('identite','NOM2, ADR_COMP, ADR_DISTSP, PAYS',
"SIREN=$siren AND NIC=$nic", false, MYSQL_ASSOC); "SIREN=$siren AND NIC=$nic", false, MYSQL_ASSOC);
$tabIdentite=$tabTmp[0]; $tabIdentite = $tabTmp[0];
if ($tabIdentite['NOM2']<>'' && $tabIdentite['NOM2']<>$tabRet['L2_NOM2']) if ($tabIdentite['NOM2']<>'' && $tabIdentite['NOM2']<>$tabRet['L2_NOM2']) {
$tabRet['L2_NOM2']=$tabIdentite['NOM2']; $tabRet['L2_NOM2']=$tabIdentite['NOM2'];
if ($tabIdentite['ADR_COMP']<>'' && $tabIdentite['ADR_COMP']<>$tabRet['L3_ADRCOMP']) }
if ($tabIdentite['ADR_COMP']<>'' && $tabIdentite['ADR_COMP']<>$tabRet['L3_ADRCOMP']) {
$tabRet['L3_ADRCOMP']=$tabIdentite['ADR_COMP']; $tabRet['L3_ADRCOMP']=$tabIdentite['ADR_COMP'];
if ($tabIdentite['ADR_DISTSP']<>'' && $tabIdentite['ADR_DISTSP']<>$tabRet['L5_DISTSP']) }
if ($tabIdentite['ADR_DISTSP']<>'' && $tabIdentite['ADR_DISTSP']<>$tabRet['L5_DISTSP']) {
$tabRet['L5_DISTSP']=$tabIdentite['ADR_DISTSP']; $tabRet['L5_DISTSP']=$tabIdentite['ADR_DISTSP'];
if ($tabIdentite['PAYS']<>'' && $tabIdentite['PAYS']<>$tabRet['L7_PAYS']) }
if ($tabIdentite['PAYS']<>'' && $tabIdentite['PAYS']<>$tabRet['L7_PAYS']) {
$tabRet['L7_PAYS']=$tabIdentite['PAYS']; $tabRet['L7_PAYS']=$tabIdentite['PAYS'];
}
$tabTmp=$this->iDbInsee->select('cedexa','contrat, hexavia, codePostal, l1_nom, l2_nomComp, l3_compGeo, l4_numVoie, l4_indRep, l4_libVoie, l5_distrib, l5_numMS, l5_libCom, l6_codCedex, l6_achCedex, codeInsee, actif, dateFlux, dateInsert, dateUpdate', "siren=$siren AND nic=$nic", false, MYSQL_ASSOC); //Cedexa
$tabCedex=$tabTmp[0]; if ($cedexa = 1) {
$tabTmp = $this->iDbInsee->select('cedexa','contrat, hexavia, codePostal, l1_nom, l2_nomComp, l3_compGeo, l4_numVoie, l4_indRep, l4_libVoie, l5_distrib, l5_numMS, l5_libCom, l6_codCedex, l6_achCedex, codeInsee, actif, dateFlux, dateInsert, dateUpdate', "siren=$siren AND nic=$nic", false, MYSQL_ASSOC);
if ( count($tabTmp)>0 ) {
$tabCedex = $tabTmp[0];
if ($tabCedex['l2_nomComp']<>'' && $tabCedex['l2_nomComp']<>$tabRet['L2_NOM2']) if ($tabCedex['l2_nomComp']<>'' && $tabCedex['l2_nomComp']<>$tabRet['L2_NOM2']) {
$tabRet['L2_NOM2']=$tabCedex['l2_nomComp']; $tabRet['L2_NOM2']=$tabCedex['l2_nomComp'];
if ($tabCedex['l3_compGeo']<>'' && $tabCedex['l3_compGeo']<>$tabRet['L3_ADRCOMP']) }
$tabRet['L3_ADRCOMP']=$tabCedex['l3_compGeo']; if ($tabCedex['l3_compGeo']<>'' && $tabCedex['l3_compGeo']<>$tabRet['L3_ADRCOMP']) {
$tabRet['L3_ADRCOMP']=$tabCedex['l3_compGeo'];
$l4=trim(preg_replace('/ +/',' ',preg_replace('/^0+/','', $tabCedex['l4_numVoie'].' '.$tabCedex['l4_indRep'].' '.$tabCedex['l4_libVoie']))); }
if ($l4<>'' && $l4<>$tabRet['L4_VOIE']) $l4=trim(preg_replace('/ +/',' ',preg_replace('/^0+/','', $tabCedex['l4_numVoie'].' '.$tabCedex['l4_indRep'].' '.$tabCedex['l4_libVoie'])));
$tabRet['L4_VOIE']=$l4; if ($l4<>'' && $l4<>$tabRet['L4_VOIE']) {
$tabRet['L4_VOIE']=$l4;
$l5=trim(preg_replace('/ +/',' ', $tabCedex['l5_distrib'].' '.$tabCedex['l5_numMS'].' '.$tabCedex['l5_libCom'])); }
if ($l5<>'' && $l5<>$tabRet['L5_DISTSP']) $l5=trim(preg_replace('/ +/',' ', $tabCedex['l5_distrib'].' '.$tabCedex['l5_numMS'].' '.$tabCedex['l5_libCom']));
$tabRet['L5_DISTSP']=$l5; if ($l5<>'' && $l5<>$tabRet['L5_DISTSP']) {
$tabRet['L5_DISTSP']=$l5;
$l6=trim(preg_replace('/ +/',' ', $tabCedex['l6_codCedex'].' '.$tabCedex['l6_achCedex'])); }
if ($l6<>'' && $l6<>$tabRet['L6_POST']) $l6=trim(preg_replace('/ +/',' ', $tabCedex['l6_codCedex'].' '.$tabCedex['l6_achCedex']));
$tabRet['L6_POST']=$l6; if ($l6<>'' && $l6<>$tabRet['L6_POST']) {
$tabRet['L6_POST']=$l6;
}
}
}
return $tabRet; return $tabRet;
/** RNCS ? **/
/*$tabTmp=$this->iDb->select('rncs_etab','enseigne, nomCommercial, adrNumVoie, adrIndRep, adrLibVoie, adrTypeVoie,
adrVoie, cp, commune, adrComp, adresse1, adresse2, adresse3',
"siren=$siren AND nic=$nic", false, MYSQL_ASSOC);
$tabIdentite=$tabTmp[0];*/
} }
function getActivite($siren, $nic=0) {
function getActivite($siren, $nic=0)
{
$tabIdentite=$this->getIdentiteLight($siren, $nic); $tabIdentite=$this->getIdentiteLight($siren, $nic);
// F.Jur // F.Jur
$fj=$tabIdentite['FJ']; $fj=$tabIdentite['FJ'];