Merge from 2.7
This commit is contained in:
commit
8860fa194a
@ -1657,21 +1657,21 @@ class MInsee
|
||||
*/
|
||||
public function getEtablissements($siren, $nic='', $deb=0, $nbRep=20, $maxRep=200, $dep=0, $actif=-1, $siege=null)
|
||||
{
|
||||
$this->setTabCodesNaf();
|
||||
$deb=$deb*1;
|
||||
$dep=$dep*1;
|
||||
$nbRep=$nbRep*1;
|
||||
$this->setTabCodesNaf();
|
||||
$deb = $deb*1;
|
||||
$dep = $dep*1;
|
||||
$nbRep = $nbRep*1;
|
||||
|
||||
$strInfo='';
|
||||
$strInfo = '';
|
||||
|
||||
$limit="LIMIT $deb, $nbRep";
|
||||
|
||||
$sqlInfo="e.id, e.source, e.source_id, e.triCode, e.autre_id, LPAD(e.siren, 9, 0) AS siren, LPAD(e.nic, 5, 0) AS nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, e.adr_dep, LPAD(e.adr_com,3,0) AS adr_com, LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, ".
|
||||
"CONCAT(siren, nic) as siret, e.actif, e.identite_pre, IF(e.siege=2,0.5,e.siege) AS triSiege";
|
||||
"CONCAT(siren, nic) AS siret, e.actif, e.identite_pre, IF(e.siege=2,0.5,e.siege) AS triSiege";
|
||||
|
||||
$strActif='';
|
||||
$strActif = $strDep = '';
|
||||
if (intval($actif)==1) $strActif=' AND e.actif=1 ';
|
||||
elseif (intval($actif)==0) $strActif=' AND e.actif=0 ';
|
||||
|
||||
@ -1680,43 +1680,37 @@ class MInsee
|
||||
elseif ($siege==1) $strSiege='AND e.siege=1 ';
|
||||
elseif ($siege==0) $strSiege='AND e.siege IN(0,2) ';
|
||||
|
||||
//Search with "departement"
|
||||
$listeEtab = array();
|
||||
|
||||
// --- Search with "departement"
|
||||
if ($dep>0 && $dep<99999) {
|
||||
|
||||
if ($dep<96) $strDep='AND adr_cp BETWEEN '.$dep.'000 AND '.$dep.'999';
|
||||
elseif ($dep>9999) $strDep="AND adr_cp BETWEEN $dep AND $dep";
|
||||
else $strDep='AND adr_cp BETWEEN '.$dep.'00 AND '.$dep.'99';
|
||||
|
||||
$tabTmp=$this->iDb->select('jo.etablissements e', 'count(*)', "siren=$siren $strDep $strActif $strSiege");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
|
||||
$listeEtab=$this->iDb->select('jo.etablissements e', $sqlInfo,
|
||||
"siren=$siren $strDep $strActif $strSiege ORDER BY triSiege DESC, e.actif DESC, e.nic DESC $limit", false, MYSQL_ASSOC);
|
||||
|
||||
$whereCount = "siren=$siren $strDep $strActif $strSiege";
|
||||
$whereSelect = "siren=$siren $strDep $strActif $strSiege ORDER BY triSiege DESC, e.actif DESC, e.nic DESC $limit";
|
||||
}
|
||||
//Search without NIC
|
||||
// --- Search without NIC
|
||||
elseif ($nic=='') {
|
||||
|
||||
$tabTmp=$this->iDb->select('jo.etablissements e', 'count(*)', "siren=$siren $strActif $strSiege");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
|
||||
$listeEtab=$this->iDb->select('jo.etablissements e', $sqlInfo,
|
||||
"e.siren=$siren $strActif $strSiege ORDER BY triSiege DESC, e.actif DESC, e.nic DESC $limit", false, MYSQL_ASSOC);
|
||||
|
||||
$whereCount = "siren=$siren $strActif $strSiege";
|
||||
$whereSelect = "e.siren=$siren $strActif $strSiege ORDER BY triSiege DESC, e.actif DESC, e.nic DESC $limit";
|
||||
}
|
||||
//Search with NIC
|
||||
// --- Search with NIC
|
||||
else {
|
||||
|
||||
$tabTmp=$this->iDb->select('jo.etablissements e', 'count(*)', "siren=$siren AND (nic=$nic OR siege=1) $strActif $strSiege");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
$listeEtab=$this->iDb->select('jo.etablissements e', $sqlInfo,
|
||||
"siren=$siren AND (nic=$nic OR siege=1) $strActif $strSiege ORDER BY triSiege DESC, e.actif DESC, e.nic DESC $limit", false, MYSQL_ASSOC);
|
||||
|
||||
$whereCount = "siren=$siren AND (nic=$nic OR siege=1) $strActif $strSiege";
|
||||
$whereSelect = "siren=$siren AND (nic=$nic OR siege=1) $strActif $strSiege ORDER BY triSiege DESC, e.actif DESC, e.nic DESC $limit";
|
||||
}
|
||||
|
||||
$tabTmp = $this->iDb->select('jo.etablissements e', 'count(*)', $whereCount);
|
||||
if (count($tabTmp)>0) {
|
||||
$nbTot = $tabTmp[0][0];
|
||||
if ($nbTot>0) {
|
||||
$listeEtab = $this->iDb->select('jo.etablissements e', $sqlInfo, $whereSelect, false, MYSQL_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
//Vérification du SIREN
|
||||
// --- Vérification du SIREN
|
||||
if ($nbTot==0 && $actif==-1) {
|
||||
|
||||
require_once 'Metier/sphinx/rechercheFonc.php';
|
||||
$liste = verificationDuSiret($siren);
|
||||
if ($liste != false) {
|
||||
@ -1729,16 +1723,20 @@ class MInsee
|
||||
$listeSiren[]=$s;
|
||||
}
|
||||
}
|
||||
$strSiren=implode(',',$listeSiren);
|
||||
$tabTmp=$this->iDb->select('jo.etablissements', 'count(*)', "siren IN ($strSiren) AND siege=1");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
$listeEtab=$this->iDb->select('jo.etablissements e', $sqlInfo,
|
||||
"siren IN ($strSiren) AND siege=1 ORDER BY e.rang DESC, e.actif DESC, e.nic ASC $limit", true, MYSQL_ASSOC);
|
||||
$strSiren = implode(',',$listeSiren);
|
||||
$tabTmp = $this->iDb->select('jo.etablissements', 'count(*)', "siren IN ($strSiren) AND siege=1");
|
||||
if (count($tabTmp)>0) {
|
||||
$nbTot = $tabTmp[0];
|
||||
$listeEtab = $this->iDb->select(
|
||||
'jo.etablissements e', $sqlInfo,
|
||||
"siren IN ($strSiren) AND siege=1 ORDER BY e.rang DESC, e.actif DESC, e.nic ASC $limit",
|
||||
true, MYSQL_ASSOC);
|
||||
}
|
||||
$strInfo='Siren saisi invalide';
|
||||
}
|
||||
}
|
||||
|
||||
//Affichage de la liste des établissements
|
||||
// --- Affichage de la liste des établissements
|
||||
if ( count($listeEtab)>0 ) {
|
||||
foreach ($listeEtab as $etab) {
|
||||
$tel=sprintf('%010d', strtr($etab['tel'],array('-'=>'', '/'=>'','.'=>'',','=>'')));
|
||||
@ -1749,9 +1747,9 @@ class MInsee
|
||||
if ($fax<>'0000000000') $fax=implode('.', str_split($fax,2));
|
||||
else $fax='';
|
||||
|
||||
$nom=trim($etab['raisonSociale']);
|
||||
$nom = trim($etab['raisonSociale']);
|
||||
// Cas des noms vides à l'INSEE (une centaine)
|
||||
if ($nom=='') $nom=@preg_replace('/,.*$/','',$etab['identite_pre']);
|
||||
if ($nom=='') $nom = preg_replace('/,.*$/','',$etab['identite_pre']);
|
||||
|
||||
$pays = 'France';
|
||||
if ( $etab['adr_dep']==99 ) {
|
||||
|
@ -2247,8 +2247,10 @@ class MGreffes
|
||||
*/
|
||||
function getIdentite($siren, $refresh=false)
|
||||
{
|
||||
$res=$this->iDb->select('jo.greffes_identite', 'id, siren, nom, nomCommercial, adresse, adresse2, cp, ville, enseigne, siege, fj, fjLib, naf, nafLib, numRC, numRC2, typeRCS, numGreffe, libGreffe, dateCreation, dateRadiation, dateCloture, ca, res, eff, dateInsert', "siren=$siren");
|
||||
if (count($res)>0 && !$refresh) {
|
||||
$id = false;
|
||||
|
||||
$res = $this->iDb->select('jo.greffes_identite', 'id, siren, nom, nomCommercial, adresse, adresse2, cp, ville, enseigne, siege, fj, fjLib, naf, nafLib, numRC, numRC2, typeRCS, numGreffe, libGreffe, dateCreation, dateRadiation, dateCloture, ca, res, eff, dateInsert', "siren=$siren");
|
||||
if (count($res) > 0 && !$refresh) {
|
||||
$ent=$res[0];
|
||||
$id=$ent['id'];
|
||||
$siren=$ent['siren'];
|
||||
@ -2781,44 +2783,46 @@ class MGreffes
|
||||
'eff' => $eff,
|
||||
);
|
||||
$dateInsert=date('Y-m-d H:i:s');
|
||||
$id=$this->iDb->insert('jo.greffes_identite', $tabInsert, true);
|
||||
//sendMail('debug@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMGreffes.php : Debug identite $siren", $this->body);
|
||||
// 997536917
|
||||
$id = $this->iDb->insert('jo.greffes_identite', $tabInsert, true);
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$tabRet = array(
|
||||
'id' => $id,// A calculer après insert
|
||||
'Pertinence' => 100,
|
||||
'Siret' => $siren.'00000',
|
||||
'Siege' => $siege,
|
||||
'Nom' => $nom,
|
||||
'Nom2' => $nomCom,
|
||||
'Sigle' => '',//prepareString($etab['Sigle']),
|
||||
'Enseigne' => $ens,
|
||||
'Adresse' => $adr,
|
||||
'Adresse2' => $adr2,//prepareString($etab['Adresse2']),
|
||||
'CP' => $cp,
|
||||
'Ville' => $ville,
|
||||
'Tel' => '',//$etab['Tel'],
|
||||
'Fax' => '',//$etab['Fax'],
|
||||
'FJ' => $cj,
|
||||
'FJLib' => $cjLib,
|
||||
'Siren' => $siren,
|
||||
'Nic' => '00000',
|
||||
'Actif' => 0,
|
||||
'NafEtab' => $naf,
|
||||
'NafEtabLib' => $nafLib,
|
||||
'NafEnt' => $naf,
|
||||
'NafEntLib' => $nafLib,
|
||||
'NumRC' => $numRC,
|
||||
'NumRC2' => $numRC2,
|
||||
'NumGreffe' => $greffe_num,
|
||||
'DateCreation' => $dateCre,
|
||||
'DateRadiation' => $dateRad,
|
||||
'DateCloture' => $dateCloture,
|
||||
'DateUpdate' => substr($dateInsert,0,10),
|
||||
);
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
$tabRet=array( 'id' => $id,// A calculer après insert
|
||||
'Pertinence' => 100,
|
||||
'Siret' => $siren.'00000',
|
||||
'Siege' => $siege,
|
||||
'Nom' => $nom,
|
||||
'Nom2' => $nomCom,
|
||||
'Sigle' => '',//prepareString($etab['Sigle']),
|
||||
'Enseigne' => $ens,
|
||||
'Adresse' => $adr,
|
||||
'Adresse2' => $adr2,//prepareString($etab['Adresse2']),
|
||||
'CP' => $cp,
|
||||
'Ville' => $ville,
|
||||
'Tel' => '',//$etab['Tel'],
|
||||
'Fax' => '',//$etab['Fax'],
|
||||
'FJ' => $cj,
|
||||
'FJLib' => $cjLib,
|
||||
'Siren' => $siren,
|
||||
'Nic' => '00000',
|
||||
'Actif' => 0,
|
||||
'NafEtab' => $naf,
|
||||
'NafEtabLib' => $nafLib,
|
||||
'NafEnt' => $naf,
|
||||
'NafEntLib' => $nafLib,
|
||||
'NumRC' => $numRC,
|
||||
'NumRC2' => $numRC2,
|
||||
'NumGreffe' => $greffe_num,
|
||||
'DateCreation' => $dateCre,
|
||||
'DateRadiation' => $dateRad,
|
||||
'DateCloture' => $dateCloture,
|
||||
'DateUpdate' => substr($dateInsert,0,10),
|
||||
);
|
||||
return $tabRet;
|
||||
return false;
|
||||
}
|
||||
|
||||
function getListeEtab($siren) {
|
||||
|
@ -3088,9 +3088,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
$orderBy = $orderBy.' '.$triMode;
|
||||
|
||||
if ($filtre->detail) {
|
||||
$strSelect = 'source, email, siren, nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi';
|
||||
$strSelect = 'source, email, LPAD(siren,9,0) AS siren, LPAD(nic,5,0) AS nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi';
|
||||
} else {
|
||||
$strSelect = 'source, email, siren, nic, ref, dateAjout, dateDerEnvoi';
|
||||
|
||||
$strSelect = 'source, email, LPAD(siren,9,0) AS siren, LPAD(nic,5,0) AS nic, ref, dateAjout, dateDerEnvoi';
|
||||
}
|
||||
if ($filtre->source!='') $strSource = " AND source='$filtre->source' ";
|
||||
else $strSource = '';
|
||||
|
@ -3088,9 +3088,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
$orderBy = $orderBy.' '.$triMode;
|
||||
|
||||
if ($filtre->detail) {
|
||||
$strSelect = 'source, email, siren, nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi';
|
||||
$strSelect = 'source, email, LPAD(siren,9,0) AS siren, LPAD(nic,5,0) AS nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi';
|
||||
} else {
|
||||
$strSelect = 'source, email, siren, nic, ref, dateAjout, dateDerEnvoi';
|
||||
|
||||
$strSelect = 'source, email, LPAD(siren,9,0) AS siren, LPAD(nic,5,0) AS nic, ref, dateAjout, dateDerEnvoi';
|
||||
}
|
||||
if ($filtre->source!='') $strSource = " AND source='$filtre->source' ";
|
||||
else $strSource = '';
|
||||
|
@ -3459,11 +3459,16 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
debugLog('I',"Recherche par Siret de $siret (dep=$dep) avec un maximum de $maxRep réponses pour la tranche $deb à $nbRep",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
// --- Supprimer les éléments autres que chiffres dans le siret
|
||||
$siret = preg_replace('/[^0-9]/', '', $siret);
|
||||
|
||||
// --- Controle de la taille du siret/siren
|
||||
if ( strlen($siret)!=14 && strlen($siret)!=9 ){
|
||||
debugLog('W', "Siren/Siret $siret incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->sendError('1010');
|
||||
}
|
||||
|
||||
// --- Initialisation des variables
|
||||
if (empty($deb)) $deb = 0;
|
||||
if (empty($nbRep)) $nbRep = 20;
|
||||
if (empty($maxRep)) $maxRep = 200;
|
||||
@ -3476,8 +3481,8 @@ class Entreprise extends Scores_Ws_Server
|
||||
$nbReponsesTotal = $nbReponses = 0;
|
||||
|
||||
$siren = substr($siret,0,9);
|
||||
if (strlen($siret)==14) $nic = substr($siret,9,5);
|
||||
elseif (strlen($siret)== 9) $nic = '';
|
||||
if (strlen($siret) == 14) $nic = substr($siret,9,5);
|
||||
elseif (strlen($siret) == 9) $nic = '';
|
||||
|
||||
$iInsee = new MInsee();
|
||||
|
||||
@ -3522,53 +3527,55 @@ class Entreprise extends Scores_Ws_Server
|
||||
$nbReponsesTotal = $rep['nbReponsesTotal'];
|
||||
$nbReponses = $rep['nbReponses'];
|
||||
|
||||
/** Si le siren est valide, on part chez Infogreffe **/
|
||||
if (count($tabRet)==0 && $iInsee->valideSiren($siren)) {
|
||||
$iGeffes = new MGreffes();
|
||||
$etab = $iGeffes->getIdentite($siren);
|
||||
if ($etab) {
|
||||
$reponse = new EntrepriseItem();
|
||||
$reponse->id = $etab['id'];
|
||||
$reponse->Pertinence = $etab['Pertinence'];
|
||||
$reponse->Siret = $etab['Siret'];
|
||||
$reponse->Siege = $etab['Siege'];
|
||||
$reponse->Nom = prepareString($etab['Nom']);
|
||||
$reponse->Nom2 = prepareString($etab['Nom2']);
|
||||
$reponse->Sigle = prepareString($etab['Sigle']);
|
||||
$reponse->Enseigne = prepareString($etab['Enseigne']);
|
||||
$reponse->Adresse = prepareString($etab['Adresse']);
|
||||
$reponse->Adresse2 = prepareString($etab['Adresse2']);
|
||||
$reponse->CP = $etab['CP'];
|
||||
$reponse->Ville = prepareString($etab['Ville']);
|
||||
$reponse->Pays = 'France';
|
||||
$reponse->Tel = $etab['Tel'];
|
||||
$reponse->Fax = $etab['Fax'];
|
||||
$reponse->FJ = $etab['FJ'];
|
||||
$reponse->FJLib = $etab['FJLib'];
|
||||
$reponse->Siren = $etab['Siren'];
|
||||
$reponse->Nic = $etab['Nic'];
|
||||
$reponse->Actif = $etab['Actif'];
|
||||
$reponse->NafEtab = $etab['NafEtab'];
|
||||
$reponse->NafEtabLib = $etab['NafEtabLib'];
|
||||
$reponse->NafEnt = $etab['NafEnt'];
|
||||
$reponse->NafEntLib = $etab['NafEntLib'];
|
||||
|
||||
$tabRet[] = $reponse;
|
||||
$nbReponses = 1;
|
||||
$nbReponsesTotal = 1;
|
||||
|
||||
} else {
|
||||
$iDb = new WDB();
|
||||
$iDb->insert('jo.siren_inexistants',
|
||||
array( 'siren'=>$siren,
|
||||
'nic'=>$nic,
|
||||
'dep'=>$dep,
|
||||
'login'=>$this->User->login,
|
||||
'client'=>$this->User->idClient,
|
||||
'dateInsert'=>date('YmdHis')));
|
||||
$nbReponses = 0;
|
||||
$nbReponsesTotal = 0;
|
||||
}
|
||||
// --- Si le siren est valide et pas de résultats
|
||||
if ( count($tabRet)==0 && $iInsee->valideSiren($siren) ) {
|
||||
// --- Vérification dans la table des greffes
|
||||
$iGeffes = new MGreffes();
|
||||
$etab = $iGeffes->getIdentite($siren);
|
||||
if ($etab) {
|
||||
$reponse = new EntrepriseItem();
|
||||
$reponse->id = $etab['id'];
|
||||
$reponse->Pertinence = $etab['Pertinence'];
|
||||
$reponse->Siret = $etab['Siret'];
|
||||
$reponse->Siege = $etab['Siege'];
|
||||
$reponse->Nom = prepareString($etab['Nom']);
|
||||
$reponse->Nom2 = prepareString($etab['Nom2']);
|
||||
$reponse->Sigle = prepareString($etab['Sigle']);
|
||||
$reponse->Enseigne = prepareString($etab['Enseigne']);
|
||||
$reponse->Adresse = prepareString($etab['Adresse']);
|
||||
$reponse->Adresse2 = prepareString($etab['Adresse2']);
|
||||
$reponse->CP = $etab['CP'];
|
||||
$reponse->Ville = prepareString($etab['Ville']);
|
||||
$reponse->Pays = 'France';
|
||||
$reponse->Tel = $etab['Tel'];
|
||||
$reponse->Fax = $etab['Fax'];
|
||||
$reponse->FJ = $etab['FJ'];
|
||||
$reponse->FJLib = $etab['FJLib'];
|
||||
$reponse->Siren = $etab['Siren'];
|
||||
$reponse->Nic = $etab['Nic'];
|
||||
$reponse->Actif = $etab['Actif'];
|
||||
$reponse->NafEtab = $etab['NafEtab'];
|
||||
$reponse->NafEtabLib = $etab['NafEtabLib'];
|
||||
$reponse->NafEnt = $etab['NafEnt'];
|
||||
$reponse->NafEntLib = $etab['NafEntLib'];
|
||||
$tabRet[] = $reponse;
|
||||
$nbReponses = 1;
|
||||
$nbReponsesTotal = 1;
|
||||
}
|
||||
|
||||
else {
|
||||
$iDb = new WDB();
|
||||
$iDb->insert('jo.siren_inexistants', array(
|
||||
'siren' => $siren,
|
||||
'nic' => $nic,
|
||||
'dep' => $dep,
|
||||
'login' => $this->User->login,
|
||||
'client' => $this->User->idClient,
|
||||
'dateInsert' => date('YmdHis'))
|
||||
);
|
||||
$nbReponses = 0;
|
||||
$nbReponsesTotal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$output = new SearchReturn();
|
||||
@ -3990,9 +3997,9 @@ class Entreprise extends Scores_Ws_Server
|
||||
$orderBy = $orderBy.' '.$triMode;
|
||||
|
||||
if ($filtre->detail) {
|
||||
$strSelect = 'source, email, siren, nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi';
|
||||
$strSelect = 'source, email, LPAD(siren,9,0) AS siren, LPAD(nic,5,0) AS nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi';
|
||||
} else {
|
||||
$strSelect = 'source, email, siren, nic, ref, dateAjout, dateDerEnvoi';
|
||||
$strSelect = 'source, email, LPAD(siren,9,0) AS siren, LPAD(nic,5,0) AS nic, ref, dateAjout, dateDerEnvoi';
|
||||
}
|
||||
if ($filtre->source!='') $strSource = " AND source='$filtre->source' ";
|
||||
else $strSource = '';
|
||||
|
@ -3459,11 +3459,16 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
debugLog('I',"Recherche par Siret de $siret (dep=$dep) avec un maximum de $maxRep réponses pour la tranche $deb à $nbRep",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
// --- Supprimer les éléments autres que chiffres dans le siret
|
||||
$siret = preg_replace('/[^0-9]/', '', $siret);
|
||||
|
||||
// --- Controle de la taille du siret/siren
|
||||
if ( strlen($siret)!=14 && strlen($siret)!=9 ){
|
||||
debugLog('W', "Siren/Siret $siret incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->sendError('1010');
|
||||
}
|
||||
|
||||
// --- Initialisation des variables
|
||||
if (empty($deb)) $deb = 0;
|
||||
if (empty($nbRep)) $nbRep = 20;
|
||||
if (empty($maxRep)) $maxRep = 200;
|
||||
@ -3476,8 +3481,8 @@ class Entreprise extends Scores_Ws_Server
|
||||
$nbReponsesTotal = $nbReponses = 0;
|
||||
|
||||
$siren = substr($siret,0,9);
|
||||
if (strlen($siret)==14) $nic = substr($siret,9,5);
|
||||
elseif (strlen($siret)== 9) $nic = '';
|
||||
if (strlen($siret) == 14) $nic = substr($siret,9,5);
|
||||
elseif (strlen($siret) == 9) $nic = '';
|
||||
|
||||
$iInsee = new MInsee();
|
||||
|
||||
@ -3522,53 +3527,55 @@ class Entreprise extends Scores_Ws_Server
|
||||
$nbReponsesTotal = $rep['nbReponsesTotal'];
|
||||
$nbReponses = $rep['nbReponses'];
|
||||
|
||||
/** Si le siren est valide, on part chez Infogreffe **/
|
||||
if (count($tabRet)==0 && $iInsee->valideSiren($siren)) {
|
||||
$iGeffes = new MGreffes();
|
||||
$etab = $iGeffes->getIdentite($siren);
|
||||
if ($etab) {
|
||||
$reponse = new EntrepriseItem();
|
||||
$reponse->id = $etab['id'];
|
||||
$reponse->Pertinence = $etab['Pertinence'];
|
||||
$reponse->Siret = $etab['Siret'];
|
||||
$reponse->Siege = $etab['Siege'];
|
||||
$reponse->Nom = prepareString($etab['Nom']);
|
||||
$reponse->Nom2 = prepareString($etab['Nom2']);
|
||||
$reponse->Sigle = prepareString($etab['Sigle']);
|
||||
$reponse->Enseigne = prepareString($etab['Enseigne']);
|
||||
$reponse->Adresse = prepareString($etab['Adresse']);
|
||||
$reponse->Adresse2 = prepareString($etab['Adresse2']);
|
||||
$reponse->CP = $etab['CP'];
|
||||
$reponse->Ville = prepareString($etab['Ville']);
|
||||
$reponse->Pays = 'France';
|
||||
$reponse->Tel = $etab['Tel'];
|
||||
$reponse->Fax = $etab['Fax'];
|
||||
$reponse->FJ = $etab['FJ'];
|
||||
$reponse->FJLib = $etab['FJLib'];
|
||||
$reponse->Siren = $etab['Siren'];
|
||||
$reponse->Nic = $etab['Nic'];
|
||||
$reponse->Actif = $etab['Actif'];
|
||||
$reponse->NafEtab = $etab['NafEtab'];
|
||||
$reponse->NafEtabLib = $etab['NafEtabLib'];
|
||||
$reponse->NafEnt = $etab['NafEnt'];
|
||||
$reponse->NafEntLib = $etab['NafEntLib'];
|
||||
|
||||
$tabRet[] = $reponse;
|
||||
$nbReponses = 1;
|
||||
$nbReponsesTotal = 1;
|
||||
|
||||
} else {
|
||||
$iDb = new WDB();
|
||||
$iDb->insert('jo.siren_inexistants',
|
||||
array( 'siren'=>$siren,
|
||||
'nic'=>$nic,
|
||||
'dep'=>$dep,
|
||||
'login'=>$this->User->login,
|
||||
'client'=>$this->User->idClient,
|
||||
'dateInsert'=>date('YmdHis')));
|
||||
$nbReponses = 0;
|
||||
$nbReponsesTotal = 0;
|
||||
}
|
||||
// --- Si le siren est valide et pas de résultats
|
||||
if ( count($tabRet)==0 && $iInsee->valideSiren($siren) ) {
|
||||
// --- Vérification dans la table des greffes
|
||||
$iGeffes = new MGreffes();
|
||||
$etab = $iGeffes->getIdentite($siren);
|
||||
if ($etab) {
|
||||
$reponse = new EntrepriseItem();
|
||||
$reponse->id = $etab['id'];
|
||||
$reponse->Pertinence = $etab['Pertinence'];
|
||||
$reponse->Siret = $etab['Siret'];
|
||||
$reponse->Siege = $etab['Siege'];
|
||||
$reponse->Nom = prepareString($etab['Nom']);
|
||||
$reponse->Nom2 = prepareString($etab['Nom2']);
|
||||
$reponse->Sigle = prepareString($etab['Sigle']);
|
||||
$reponse->Enseigne = prepareString($etab['Enseigne']);
|
||||
$reponse->Adresse = prepareString($etab['Adresse']);
|
||||
$reponse->Adresse2 = prepareString($etab['Adresse2']);
|
||||
$reponse->CP = $etab['CP'];
|
||||
$reponse->Ville = prepareString($etab['Ville']);
|
||||
$reponse->Pays = 'France';
|
||||
$reponse->Tel = $etab['Tel'];
|
||||
$reponse->Fax = $etab['Fax'];
|
||||
$reponse->FJ = $etab['FJ'];
|
||||
$reponse->FJLib = $etab['FJLib'];
|
||||
$reponse->Siren = $etab['Siren'];
|
||||
$reponse->Nic = $etab['Nic'];
|
||||
$reponse->Actif = $etab['Actif'];
|
||||
$reponse->NafEtab = $etab['NafEtab'];
|
||||
$reponse->NafEtabLib = $etab['NafEtabLib'];
|
||||
$reponse->NafEnt = $etab['NafEnt'];
|
||||
$reponse->NafEntLib = $etab['NafEntLib'];
|
||||
$tabRet[] = $reponse;
|
||||
$nbReponses = 1;
|
||||
$nbReponsesTotal = 1;
|
||||
}
|
||||
|
||||
else {
|
||||
$iDb = new WDB();
|
||||
$iDb->insert('jo.siren_inexistants', array(
|
||||
'siren' => $siren,
|
||||
'nic' => $nic,
|
||||
'dep' => $dep,
|
||||
'login' => $this->User->login,
|
||||
'client' => $this->User->idClient,
|
||||
'dateInsert' => date('YmdHis'))
|
||||
);
|
||||
$nbReponses = 0;
|
||||
$nbReponsesTotal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$output = new SearchReturn();
|
||||
@ -3990,9 +3997,9 @@ class Entreprise extends Scores_Ws_Server
|
||||
$orderBy = $orderBy.' '.$triMode;
|
||||
|
||||
if ($filtre->detail) {
|
||||
$strSelect = 'source, email, siren, nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi';
|
||||
$strSelect = 'source, email, LPAD(siren,9,0) AS siren, LPAD(nic,5,0) AS nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi';
|
||||
} else {
|
||||
$strSelect = 'source, email, siren, nic, ref, dateAjout, dateDerEnvoi';
|
||||
$strSelect = 'source, email, LPAD(siren,9,0) AS siren, LPAD(nic,5,0) AS nic, ref, dateAjout, dateDerEnvoi';
|
||||
}
|
||||
if ($filtre->source!='') $strSource = " AND source='$filtre->source' ";
|
||||
else $strSource = '';
|
||||
|
Loading…
Reference in New Issue
Block a user