CS
This commit is contained in:
parent
be0044abb2
commit
76a6fe2729
@ -21,45 +21,45 @@ class Entreprise extends Scores_Ws_Server
|
||||
*/
|
||||
public function getIdentite($siret, $id, $dept, $waldec)
|
||||
{
|
||||
$forceVerif=false;
|
||||
$forceVerif = false;
|
||||
Metier_Util_Log::write('W',"Recherche par identifiant Siren=$siret, Dept=$dep, Id=$id, Waldec=$waldec",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
$iInsee = new Metier_Insee_MInsee();
|
||||
$result = new EntrepResult();
|
||||
|
||||
|
||||
if ($waldec<>'' && substr($waldec,0,1)=='W' && $siret*1==0) {
|
||||
if ($waldec != '' && substr($waldec,0,1) == 'W' && $siret*1 == 0) {
|
||||
Metier_Util_Log::write('I',"AFNIC Recherche par identifiant Waldec $waldec (Siren=$siret, Dept=$dep, Id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
$rep=$iInsee->getEtablissementsParId('AUTRE', $waldec, 0, 20, 20);
|
||||
|
||||
$etabs=$rep['reponses'];
|
||||
if ($rep['nbReponses']>0) {
|
||||
foreach ($etabs as $nb=>$etab) {
|
||||
$siret=$etab['Siret'];
|
||||
$id=$etab['id'];
|
||||
$rep = $iInsee->getEtablissementsParId('AUTRE', $waldec, 0, 20, 20);
|
||||
$etabs = $rep['reponses'];
|
||||
if ($rep['nbReponses'] > 0) {
|
||||
foreach ($etabs as $nb => $etab) {
|
||||
$siret = $etab['Siret'];
|
||||
$id = $etab['id'];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Metier_Util_Log::write('W', "Waldec $waldec non présent en base", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
$error = new ErrorElement();
|
||||
$error->errnum = 108;
|
||||
$error->errmsg = 'Waldec inconnu';
|
||||
$result->error = $error;
|
||||
return $result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$tabRet=array();
|
||||
$siret=trim($siret);
|
||||
$len=strlen($siret);
|
||||
$id=trim($id)*1;
|
||||
if ($len==14) $nic=substr(''.$siret,9,5)*1;
|
||||
elseif ($len== 9) $nic='';
|
||||
$tabRet = array();
|
||||
$siret = trim($siret);
|
||||
$len = strlen($siret);
|
||||
$id = trim($id)*1;
|
||||
if ($len == 14) {
|
||||
$nic = substr(''.$siret,9,5)*1;
|
||||
}
|
||||
elseif ($len == 9) {
|
||||
$nic='';
|
||||
}
|
||||
elseif ($len== 0) {
|
||||
$siren=0; $nic='';
|
||||
$siren = 0;
|
||||
$nic = '';
|
||||
}
|
||||
else {
|
||||
Metier_Util_Log::write('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
@ -71,7 +71,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
return $result;
|
||||
}
|
||||
$siren=substr(''.$siret,0,9)*1;
|
||||
if ($siren==0 && $id==0) {
|
||||
if ($siren == 0 && $id == 0) {
|
||||
Metier_Util_Log::write('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$error = new ErrorElement();
|
||||
$error->errnum = 102;
|
||||
@ -81,7 +81,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($id==0 && !$iInsee->valideSiren($siren, $nic)) {
|
||||
if ($id == 0 && !$iInsee->valideSiren($siren, $nic)) {
|
||||
Metier_Util_Log::write('W', "Siren $siren/$nic invalide (105)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$error = new ErrorElement();
|
||||
$error->errnum = 105;
|
||||
@ -91,15 +91,15 @@ class Entreprise extends Scores_Ws_Server
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($dep==974) {
|
||||
if ($dep == 974) {
|
||||
Metier_Util_Log::write('I',"AFNIC Recherche par Siren/Dept (Waldec=$waldec, Siren=$siret, Dept=$dep, Id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$rep=$iInsee->getEtablissements($siren, $nic, 0, 20, 20, $dep);
|
||||
$etabs=$rep['reponses'];
|
||||
$rep = $iInsee->getEtablissements($siren, $nic, 0, 20, 20, $dep);
|
||||
$etabs = $rep['reponses'];
|
||||
if ($rep['nbReponses']>0) {
|
||||
foreach ($etabs as $nb=>$etab) {
|
||||
$siren=$etab['siren'];
|
||||
$nic=$etab['nic'];
|
||||
$id=$etab['id'];
|
||||
$siren = $etab['siren'];
|
||||
$nic = $etab['nic'];
|
||||
$id = $etab['id'];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@ -116,7 +116,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
Metier_Util_Log::write('I',"AFNIC Identités demandée pour siret ".strtr(print_r($siret, true),array("\r"=>'',"\n"=>'')). " (id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
Metier_Util_Log::write('I', "Avant getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$entrep=$iInsee->getIdentiteEntreprise($siren, $nic, $id, $forceVerif);
|
||||
$entrep = $iInsee->getIdentiteEntreprise($siren, $nic, $id, $forceVerif);
|
||||
Metier_Util_Log::write('I', "Après getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
if (empty($entrep)) {
|
||||
@ -132,7 +132,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
$codePaysIso2='FR';
|
||||
if ($entrep['Dept'] > 98) {
|
||||
$codePaysInsee = $entrep['codeCommune'];
|
||||
|
||||
$sql = "SELECT j.codPays, j.numPays, j.codPays3, j.codePaysInpi, j.libPays, i.LIBCOG, i.ACTUAL
|
||||
FROM jo.tabPays j, insee.insee_tabPays i
|
||||
WHERE j.codePaysInsee=:codePays AND j.codePaysInsee=substring(i.COG, 3, 3) AND i.ACTUAL IN (1,4) AND j.numPays is NOT NULL";
|
||||
@ -175,10 +174,12 @@ class Entreprise extends Scores_Ws_Server
|
||||
else $actif=0;
|
||||
|
||||
// Source INSEE prioritaire sur l'établissement
|
||||
$enseigne=$entrep['Enseigne'];
|
||||
if ($enseigne=='') $enseigne=$entrep['enseigneLong'];
|
||||
$tabCarInvalides=array('/'=>' ','*'=>' ', '&'=>' ET ', '&'=>' ET ', '&'=>' ET ',
|
||||
'"'=>' ', "'"=>' ');
|
||||
$enseigne = $entrep['Enseigne'];
|
||||
if ($enseigne == '') {
|
||||
$enseigne = $entrep['enseigneLong'];
|
||||
}
|
||||
$tabCarInvalides = array('/'=>' ','*'=>' ', '&'=>' ET ', '&'=>' ET ', '&'=>' ET ',
|
||||
'"'=>' ', "'"=>' ');
|
||||
|
||||
$item = new EntrepElement();
|
||||
$item->id = $entrep['id'];
|
||||
@ -241,7 +242,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
$item->Naf4EtabLib = $entrep2['apet4_lib'];
|
||||
}
|
||||
Metier_Util_Log::write('I', 'Etablissement retourné = '. $entrep['Nom'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->wsLog('identite',$siret,$id);
|
||||
$this->wsLog('identite', $siret, $id);
|
||||
|
||||
$error = new ErrorElement();
|
||||
$error->errmsg = '';
|
||||
|
Loading…
Reference in New Issue
Block a user