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;
}
function getAdresse($siren, $nic) {
/* 'Nom'=>$etab['raisonSociale'],
'Tribunal'=>$etab['triCode'],
'Sigle'=>$etab['sigle'],
''=>$etab['enseigne'],
'Adresse'=>trim(preg_replace('/ +/', ' ', trim( $etab['adr_num'] .' '. $etab['adr_btq'] .' '.
$etab['adr_typeVoie'] .' '. $etab['adr_libVoie']))),
'Adresse2'=>trim(preg_replace('/ +/', ' ', $etab['adr_comp'])),
'AdresseNum'=>$etab['adr_num'],
'AdresseBtq'=>$etab['adr_btq'],
'AdresseVoie'=>$etab['adr_typeVoie'],
'AdresseRue'=>$etab['adr_libVoie'],
'CP'=>$etab['adr_cp'],
'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;
/**
* Retourne l'adresse normalisé
* @param string $siren
* @param string $nic
* @param string $cedexa (1=>On, 0=>Off)
* @return array
* L1_NOM, L2_NOM2, L3_ADRCOMP, L4_VOIE, L5_DISTSP, L6_POST, L7_PAYS
*/
function getAdresse($siren, $nic, $cedexa=1)
{
// Table etablissements
$tabIdentite = $this->getIdentiteLight($siren, $nic);
$codeVoie = strtoupper($this->getCodeVoie($tabIdentite['AdresseVoie']));
if ($codeVoie=='') $codeVoie=$tabIdentite['AdresseVoie'];
$tabRet=array('L1_NOM' => $tabIdentite['Nom'],
'L2_NOM2' => $tabIdentite['Enseigne'],
'L3_ADRCOMP' => '',
'L4_VOIE' => trim(preg_replace('/ +/',' ',preg_replace('/^0+/','',$tabIdentite['AdresseNum'].' '.
$tabIdentite['AdresseBtq'].' '.
$codeVoie.' '.
$tabIdentite['AdresseRue']))),
'L5_DISTSP' => $tabIdentite['Adresse2'],
'L6_POST' => $tabIdentite['CP'].' '.$tabIdentite['Ville'],
'L7_PAYS' => '',
);
if (strlen($tabRet['L4_VOIE'])>38)
$tabRet = array(
'L1_NOM' => $tabIdentite['Nom'],
'L2_NOM2' => $tabIdentite['Enseigne'],
'L3_ADRCOMP' => '',
'L4_VOIE' => trim(preg_replace('/ +/',' ',preg_replace('/^0+/','',$tabIdentite['AdresseNum'].' '.
$tabIdentite['AdresseBtq'].' '. $codeVoie.' '. $tabIdentite['AdresseRue']))),
'L5_DISTSP' => $tabIdentite['Adresse2'],
'L6_POST' => $tabIdentite['CP'].' '.$tabIdentite['Ville'],
'L7_PAYS' => '',
);
if (strlen($tabRet['L4_VOIE'])>38) {
$tabRet['L4_VOIE']=trim(preg_replace('/ +/',' ',preg_replace('/^0+/','',
$tabIdentite['AdresseNum'].' '.
$tabIdentite['AdresseBtq'].' '.
$tabIdentite['AdresseVoie'].' '.
$tabIdentite['AdresseRue'])));
}
$tabNotice=$this->getInfosNotice($siren, $nic);
//if ($tabNotice['insL4_VOIE']<>'' && $tabNotice['insL4_VOIE']<>$tabRet['L4_VOIE'])
// $tabRet['L4_VOIE']=$tabNotice['insL4_VOIE'];
if ($tabNotice['L6_POST']<>'' && $tabNotice['L6_POST']<>$tabRet['L6_POST'])
$tabRet['L6_POST']=$tabNotice['L6_POST'];
//Notice 80 - Override $tabRet
$tabNotice = $this->getInfosNotice($siren, $nic);
if ($tabNotice['L6_POST']<>'' && $tabNotice['L6_POST']<>$tabRet['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);
$tabIdentite=$tabTmp[0];
if ($tabIdentite['NOM2']<>'' && $tabIdentite['NOM2']<>$tabRet['L2_NOM2'])
$tabIdentite = $tabTmp[0];
if ($tabIdentite['NOM2']<>'' && $tabIdentite['NOM2']<>$tabRet['L2_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'];
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'];
if ($tabIdentite['PAYS']<>'' && $tabIdentite['PAYS']<>$tabRet['L7_PAYS'])
}
if ($tabIdentite['PAYS']<>'' && $tabIdentite['PAYS']<>$tabRet['L7_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);
$tabCedex=$tabTmp[0];
//Cedexa
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'])
$tabRet['L2_NOM2']=$tabCedex['l2_nomComp'];
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'])
$tabRet['L4_VOIE']=$l4;
$l5=trim(preg_replace('/ +/',' ', $tabCedex['l5_distrib'].' '.$tabCedex['l5_numMS'].' '.$tabCedex['l5_libCom']));
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'])
$tabRet['L6_POST']=$l6;
if ($tabCedex['l2_nomComp']<>'' && $tabCedex['l2_nomComp']<>$tabRet['L2_NOM2']) {
$tabRet['L2_NOM2']=$tabCedex['l2_nomComp'];
}
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']) {
$tabRet['L4_VOIE']=$l4;
}
$l5=trim(preg_replace('/ +/',' ', $tabCedex['l5_distrib'].' '.$tabCedex['l5_numMS'].' '.$tabCedex['l5_libCom']));
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']) {
$tabRet['L6_POST']=$l6;
}
}
}
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);
// F.Jur
$fj=$tabIdentite['FJ'];