This commit is contained in:
Michael RICOIS 2017-01-11 16:41:44 +01:00
parent 715bc738bb
commit 33dd6ce019

View File

@ -132,19 +132,23 @@ class Entreprise extends Scores_Ws_Server
$codePaysIso2='FR'; $codePaysIso2='FR';
if ($entrep['Dept'] > 98) { if ($entrep['Dept'] > 98) {
$codePaysInsee = $entrep['codeCommune']; $codePaysInsee = $entrep['codeCommune'];
$iDb=new Metier_Util_Db();
$tabTmp=$iDb->select('jo.tabPays j, insee.insee_tabPays i', $sql = "SELECT j.codPays, j.numPays, j.codPays3, j.codePaysInpi, j.libPays, i.LIBCOG, i.ACTUAL
'j.codPays, j.numPays, j.codPays3, j.codePaysInpi, j.libPays, i.LIBCOG, i.ACTUAL', FROM jo.tabPays j, insee.insee_tabPays i
"j.codePaysInsee=$codePaysInsee AND j.codePaysInsee=substring( i.COG, 3, 3 ) AND i.ACTUAL IN (1,4) AND j.numPays is NOT NULL", true, MYSQL_ASSOC); WHERE j.codePaysInsee=:codePays AND j.codePaysInsee=substring(i.COG, 3, 3) AND i.ACTUAL IN (1,4) AND j.numPays is NOT NULL";
if (count($tabTmp)==1) { $stmt = $this->conn->prepare($sql);
$codePaysIso2=$tabTmp[0]['codPays']; $stmt->bindValue('codePays', $codePaysInsee);
$stmt->execute();
if ($stmt->rowCount() == 1) {
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
$codePaysIso2 = $result['codPays'];
} else { } else {
$codePaysIso2 = ''; $codePaysIso2 = '';
foreach ($tabTmp as $tabTmp2) { while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
if (trim(strtoupper(strtr($tabTmp2['libPays'], if (trim(strtoupper(strtr($result['libPays'],
'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝ', 'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝ',
"aaaaaaaceeeeiiiionooooouuuuyyAAAAAAACEEEEIIIIONOOOOOUUUUY")))==trim(strtoupper($tabTmp2['LIBCOG']))) { "aaaaaaaceeeeiiiionooooouuuuyyAAAAAAACEEEEIIIIONOOOOOUUUUY")))==trim(strtoupper($result['LIBCOG']))) {
$codePaysIso2=$tabTmp2['codPays']; $codePaysIso2 = $result['codPays'];
break; break;
} }
} }
@ -152,8 +156,9 @@ class Entreprise extends Scores_Ws_Server
} }
$autreId = $entrep['AutreId']; $autreId = $entrep['AutreId'];
if ($params->siret>0 && $waldec<>'') if ($params->siret > 0 && $waldec != '') {
$autreId = $waldec; $autreId = $waldec;
}
// Source RNCS prioritaire pour les infos entreprises // Source RNCS prioritaire pour les infos entreprises
$nom=$entrep['nomLong']; $nom=$entrep['nomLong'];