issue #0001467 : Nouveaux paramètres et correction pour les filtres SIEGE et ACTIF
This commit is contained in:
parent
8d63f63448
commit
39059dadf1
@ -1488,59 +1488,60 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
* @param int $maxRep
|
||||
* @param int $dep
|
||||
* @param int $actif
|
||||
* @param int $siege
|
||||
*/
|
||||
public function getEtablissements($siren, $nic='', $deb=0, $nbRep=20, $maxRep=200, $dep=0, $actif=-1)
|
||||
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;
|
||||
|
||||
$strInfo = '';
|
||||
|
||||
$limit="LIMIT $deb, $nbRep";
|
||||
$strInfo='';
|
||||
|
||||
$sqlInfo="'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif, e.identite_pre";
|
||||
|
||||
$strActif='';
|
||||
if (intval($actif)==1) $strActif=' AND e.actif=1 ';
|
||||
elseif (intval($actif)==0) $strActif=' AND e.actif=0 ';
|
||||
|
||||
$strSiege='';
|
||||
if ($siege===null) $strSiege='';
|
||||
elseif ($siege==1) $strSiege=' AND e.siege=1 ';
|
||||
elseif ($siege==0) $strSiege=' AND e.siege=0 ';
|
||||
|
||||
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('etablissements e', 'count(*)', "siren=$siren $strDep $strActif");
|
||||
$tabTmp=$this->iDb->select('etablissements e', 'count(*)', "siren=$siren $strDep $strActif $strSiege");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
|
||||
$listeEtab=$this->iDb->select('etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif, e.identite_pre",
|
||||
"siren=$siren $strDep $strActif ORDER BY e.siege , e.actif DESC $limit", false, MYSQL_ASSOC);
|
||||
$listeEtab=$this->iDb->select('etablissements e', $sqlInfo,
|
||||
"siren=$siren $strDep $strActif $strSiege ORDER BY e.siege , e.actif DESC $limit", false, MYSQL_ASSOC);
|
||||
|
||||
} elseif ($nic=='') {
|
||||
|
||||
$tabTmp=$this->iDb->select('etablissements e', 'count(*)', "siren=$siren $strActif");
|
||||
$tabTmp=$this->iDb->select('etablissements e', 'count(*)', "siren=$siren $strActif $strSiege");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
|
||||
$listeEtab=$this->iDb->select('etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif, e.identite_pre",
|
||||
"e.siren=$siren $strActif ORDER BY e.siege DESC, e.actif DESC $limit", false, MYSQL_ASSOC);
|
||||
$listeEtab=$this->iDb->select('etablissements e', $sqlInfo,
|
||||
"e.siren=$siren $strActif $strSiege ORDER BY e.siege DESC, e.actif DESC $limit", false, MYSQL_ASSOC);
|
||||
|
||||
} else {
|
||||
|
||||
$tabTmp=$this->iDb->select('etablissements e', 'count(*)', "siren=$siren AND (nic=$nic OR siege=1) $strActif");
|
||||
$tabTmp=$this->iDb->select('etablissements e', 'count(*)', "siren=$siren AND (nic=$nic OR siege=1) $strActif $strSiege");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
|
||||
$listeEtab=$this->iDb->select('etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif, e.identite_pre",
|
||||
"siren=$siren AND (nic=$nic OR siege=1) $strActif ORDER BY e.siege , e.actif DESC $limit", false, MYSQL_ASSOC);
|
||||
$listeEtab=$this->iDb->select('etablissements e', $sqlInfo,
|
||||
"siren=$siren AND (nic=$nic OR siege=1) $strActif $strSiege ORDER BY e.siege , e.actif DESC $limit", false, MYSQL_ASSOC);
|
||||
|
||||
}
|
||||
|
||||
@ -1552,8 +1553,7 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
$listeSiren=array();
|
||||
foreach ($liste as $s) {
|
||||
if (sommeDeControle($s) != 0) {
|
||||
print 'erreur somme de controle sur '.$s.
|
||||
' ('.sommeDeControle($s).')<br/>';
|
||||
//print 'erreur somme de controle sur '.$s.' ('.sommeDeControle($s).')<br/>';
|
||||
} else {
|
||||
$listeSiren[]=$s;
|
||||
}
|
||||
@ -1561,12 +1561,8 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
$strSiren=implode(',',$listeSiren);
|
||||
$tabTmp=$this->iDb->select('etablissements', 'count(*)', "siren IN ($strSiren) AND siege=1");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
$listeEtab=$this->iDb->select('etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif, e.identite_pre",
|
||||
"siren IN ($strSiren) AND siege=1 ORDER BY e.rang DESC, e.actif DESC, e.nic ASC $limit", true, MYSQL_ASSOC);
|
||||
$listeEtab=$this->iDb->select('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';
|
||||
}
|
||||
|
||||
@ -1619,11 +1615,11 @@ public function rechercheDirOld($nom, $prenom='', $fonction='', $dateNaiss='', $
|
||||
if ($dep==0) $dep=''; // Evite l'affichage d'un 0 inutile sur l'Extranet
|
||||
|
||||
return array(
|
||||
'criteres'=>array('siren'=>$siren, 'nic'=>$nic, 'dep'=>$dep),
|
||||
'info'=>$strInfo,
|
||||
'nbReponses'=>count($tabRet),
|
||||
'nbReponsesTotal'=>$nbTot,
|
||||
'reponses'=>$tabRet);
|
||||
'criteres' => array('siren'=>$siren, 'nic'=>$nic, 'dep'=>$dep),
|
||||
'info' => $strInfo,
|
||||
'nbReponses' => count($tabRet),
|
||||
'nbReponsesTotal' => $nbTot,
|
||||
'reponses' => $tabRet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,14 +4,7 @@ require_once realpath(dirname(__FILE__)).'/Types.php';
|
||||
|
||||
class Entreprise extends WsScore
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->serviceClient = true;
|
||||
$this->serviceClientName = 'Vwbank';
|
||||
$this->serviceName = 'Entreprise';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne les informations identitaires de l'entreprise ou de l'établissement demandé
|
||||
* @param string $siret Siren de l'entreprise ou siret de l'établissement
|
||||
@ -576,53 +569,73 @@ class Entreprise extends WsScore
|
||||
$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->Tel = $etab['Tel'];
|
||||
$reponse->Fax = $etab['Fax'];
|
||||
$reponse->FJ = $etab['FJ'];
|
||||
$reponse->FJLib = utf8_encode(prepareString(utf8_decode($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('siren_inexistants', array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>$nic,
|
||||
'dep'=>$dep,
|
||||
'login'=>$this->tabInfoUser['login'],
|
||||
'client'=>$this->tabInfoUser['idClient'],
|
||||
'dateInsert'=>date('YmdHis')));
|
||||
$nbReponses = 0;
|
||||
$nbReponsesTotal = 0;
|
||||
$rep['info'] = 'Siren inexistant';
|
||||
}
|
||||
if (count($tabRet)==0)
|
||||
{
|
||||
if ($siege===null || $actif==2)
|
||||
{
|
||||
/** Si le siren est valide, on part chez Infogreffe **/
|
||||
if ($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->Tel = $etab['Tel'];
|
||||
$reponse->Fax = $etab['Fax'];
|
||||
$reponse->FJ = $etab['FJ'];
|
||||
$reponse->FJLib = prepareString($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('siren_inexistants', array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>$nic,
|
||||
'dep'=>$dep,
|
||||
'login'=>$this->tabInfoUser['login'],
|
||||
'client'=>$this->tabInfoUser['idClient'],
|
||||
'dateInsert'=>date('YmdHis')));
|
||||
$nbReponses = 0;
|
||||
$nbReponsesTotal = 0;
|
||||
$rep['info'] = 'Siren inexistant';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($iInsee->sirenExiste($siren) ) {
|
||||
$info = 'Aucun ';
|
||||
if ( $siege == 1 ) $info.= 'siege';
|
||||
else $info.= 'etablissement';
|
||||
|
||||
if ( $actif == 0 ) $info.= ' inactif';
|
||||
elseif ( $actif == 1) $info.= ' actif';
|
||||
|
||||
$rep['info'] = $info;
|
||||
|
||||
} else {
|
||||
$rep['info'] = 'Siren inexistant';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output = new SearchReturn();
|
||||
|
Loading…
x
Reference in New Issue
Block a user