4218 lines
162 KiB
PHP
4218 lines
162 KiB
PHP
<?php
|
|
require_once 'WsScore/WsScore.php';
|
|
require_once realpath(dirname(__FILE__)).'/Types.php';
|
|
|
|
class Entreprise extends WsScore
|
|
{
|
|
|
|
/**
|
|
* Retourne les informations identitaires de l'entreprise ou de l'établissement demandé
|
|
* @param string $siret Siren de l'entreprise ou siret de l'établissement
|
|
* @param int $id Identifiant interne
|
|
* @return Identite
|
|
*/
|
|
public function getIdentite($siret, $id = 0)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('identite');
|
|
|
|
//Initialisation
|
|
if (empty($id)) { $id = 0; }
|
|
$forceVerif = false;
|
|
|
|
$tdeb = microtime(1);
|
|
$ligne = date('YmdHis').";$siret;Ws->getIdentite Avant ...";
|
|
$fp = fopen(LOG_PATH.'/accesDistant.log', 'a');
|
|
fwrite($fp,$ligne.EOL);
|
|
fclose($fp);
|
|
debugLog('I',"Identités demandée pour siret $siret (id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$tabRet = array();
|
|
$siret = trim($siret);
|
|
$len = strlen($siret);
|
|
$siren = substr($siret,0,9);
|
|
if ($len == 14) {
|
|
$nic = substr($siret,9,5)*1;
|
|
} elseif ($len == 9) {
|
|
$nic = 0;
|
|
}
|
|
|
|
if ($siren*1==0 && $id==0) {
|
|
$this->sendError('1010');
|
|
} elseif ($len!=14 && $len!=9) {
|
|
$this->sendError('1020');
|
|
}
|
|
|
|
debugLog('I', "Avant getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$iInsee = new MInsee();
|
|
$entrep = $iInsee->getIdentiteEntreprise($siren, $nic, $id, $forceVerif);
|
|
debugLog('I', "Après getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$duree = round(microtime(1)-$tdeb,3);
|
|
$ligne = date('YmdHis').";$siret;Ws->getIdentite juste apres iInsee->... ($duree s)";
|
|
$fp = fopen(LOG_PATH.'/accesDistant.log', 'a');
|
|
fwrite($fp,$ligne.EOL);
|
|
fclose($fp);
|
|
if (empty($entrep) || empty($entrep['id']) ) {
|
|
debugLog('W', "Siren $siren non présent en base", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1020');
|
|
}
|
|
|
|
$iBourse = new MBourse($siren);
|
|
$bourse = $iBourse->getInfosBourse($siren);
|
|
|
|
$identite = new Identite();
|
|
$identite->id = $entrep['id'];
|
|
$identite->Siret = $entrep['Siret'];
|
|
$identite->SiretSiege = $entrep['SiretSiege'];
|
|
$identite->Siege = $entrep['Siege'];
|
|
$identite->AncienSiege = $entrep['AncienSiege'];
|
|
$identite->AncienSiegeDateFin = $entrep['AncienSiegeDateFin'];
|
|
$identite->TribunalCode = prepareString($entrep['Tribunal']);
|
|
$identite->TribunalLib = prepareString($entrep['TribunalLib']);
|
|
//'NumGreffe' = $entrep['numGreffe'], // Ajouté le 4 08 2009
|
|
$identite->NumRC = $entrep['numRC']; // Ajouté le 4 08 2009
|
|
$identite->Actif = $entrep['Actif'];
|
|
$identite->ActifEco = $entrep['ActifEco']; // Etab éco actif, ajout le 28/04/2011
|
|
$identite->ActifEcoDate = $entrep['ActifEcoDate']; // Date si éco inactif et jur actif
|
|
$identite->ActifEcoType = $entrep['ActifEcoType']; // vide ou NPAI ou PFER ou ECOF
|
|
$identite->EntActiveRCS = $entrep['EntActiveRCS'];
|
|
$identite->AutreId = $entrep['AutreId'];
|
|
$identite->Source = $entrep['Source'];
|
|
$identite->SourceId = $entrep['SourceId'];
|
|
$identite->Isin = $entrep['Isin'];
|
|
$identite->Nom = prepareString(strtr($entrep['Nom'],'/*',' '));
|
|
$identite->Nom2 = prepareString($entrep['Nom2']);
|
|
$identite->NomLong = prepareString($entrep['nomLong']); // Ajouté le 4 08 2009
|
|
$identite->NomCommercial = prepareString($entrep['NomCommercial']); // Ajouté le 16 11 2010
|
|
$identite->Siret = $entrep['Siret'];
|
|
$identite->Sigle = prepareString($entrep['Sigle']);
|
|
$identite->SigleLong = prepareString($entrep['sigleLong']); // Ajouté le 4 08 2009
|
|
$identite->Enseigne = prepareString($entrep['Enseigne']);
|
|
$identite->EnseigneLong = prepareString($entrep['enseigneLong']); // Ajouté le 16 11 2010
|
|
$identite->Adresse = prepareString($entrep['Adresse']);
|
|
$identite->Adresse2 = prepareString($entrep['Adresse2']);
|
|
$identite->AdresseNum = prepareString($entrep['AdresseNum']);
|
|
$identite->AdresseBtq = prepareString($entrep['AdresseBtq']);
|
|
$identite->AdresseVoie = prepareString($entrep['AdresseVoie']);
|
|
$identite->AdresseRue = prepareString($entrep['AdresseRue']);
|
|
$identite->CP = $entrep['CP'];
|
|
$identite->Ville = prepareString($entrep['Ville']);
|
|
$identite->Pays = prepareString($entrep['Pays']); // Ajouté le 18 02 2008
|
|
$identite->PaysIso2 = $entrep['PaysIso2'];
|
|
$identite->AdresseDom = $entrep['AdresseDom'];
|
|
|
|
$tabAdresseDomEnt = array();
|
|
if (isset($entrep['AdresseDomEnt']) && count($entrep['AdresseDomEnt'])>0){
|
|
foreach ($entrep['AdresseDomEnt'] as $element){
|
|
$adresseDomEnt = new AdresseDomEnt();
|
|
$adresseDomEnt->siren = $element['siren'];
|
|
$adresseDomEnt->nom = $element['nom'];
|
|
$tabAdresseDomEnt[] = $adresseDomEnt;
|
|
}
|
|
}
|
|
$identite->AdresseDomEnt = $tabAdresseDomEnt;
|
|
|
|
$identite->AdresseDomNb = $entrep['AdresseDomNb'];
|
|
$identite->Civilite = $entrep['Civilite'];
|
|
$identite->NbEtab = $entrep['NbEtab'];
|
|
$identite->Tel = prepareString($entrep['Tel']);
|
|
$identite->Fax = prepareString($entrep['Fax']);
|
|
$identite->Web = prepareString($entrep['Web']);
|
|
$identite->Mail = prepareString($entrep['Mail']);
|
|
$identite->GeoLat = $entrep['GeoLat'];
|
|
$identite->GeoLon = $entrep['GeoLon'];
|
|
$identite->GeoPrecis = $entrep['GeoPrecis'];
|
|
|
|
$geoInfos = new GeoInfos();
|
|
$geoInfos->CUCS = $entrep['GeoInfos']['CUCS'];
|
|
$geoInfos->NCUCS = $entrep['GeoInfos']['NCUCS'];
|
|
$geoInfos->ZRU = $entrep['GeoInfos']['ZRU'];
|
|
$geoInfos->NZRU = $entrep['GeoInfos']['NZRU'];
|
|
$geoInfos->ZFU = $entrep['GeoInfos']['ZFU'];
|
|
$geoInfos->NZFU = $entrep['GeoInfos']['NZFU'];
|
|
$geoInfos->ZUS = $entrep['GeoInfos']['ZUS'];
|
|
$geoInfos->NZUS = $entrep['GeoInfos']['NZUS'];
|
|
$geoInfos->AFR = $entrep['GeoInfos']['AFR'];
|
|
$geoInfos->NAFR = $entrep['GeoInfos']['NAFR'];
|
|
$geoInfos->ZRR = $entrep['GeoInfos']['ZRR'];
|
|
$geoInfos->NZRR = $entrep['GeoInfos']['NZRR'];
|
|
$identite->GeoInfos = $geoInfos;
|
|
|
|
$identite->TvaNumero = $entrep['TvaNumero'];
|
|
$identite->TvaAttribue = $entrep['TvaAttribue'];
|
|
$identite->FJ = $entrep['FJ'];
|
|
$identite->FJ_Lib = $entrep['FJ_lib'];
|
|
$identite->FJ2 = $entrep['FJ2']; // Ajouté le 4 08 2009
|
|
$identite->FJ2_Lib = $entrep['FJ2_Lib']; // Ajouté le 4 08 2009
|
|
$identite->Siren = $entrep['Siren'];
|
|
$identite->Nic = $entrep['Nic'];
|
|
$identite->NafEnt = $entrep['NafEnt'];
|
|
$identite->NafEntLib = $entrep['NafEntLib'];
|
|
$identite->NafEtab = $entrep['NafEtab'];
|
|
$identite->NafEtabLib = $entrep['NafEtabLib'];
|
|
$identite->NaceEtab = $entrep['NaceEtab'];
|
|
$identite->NaceEnt = $entrep['NaceEnt'];
|
|
$identite->Nafa = $entrep['APRM'];
|
|
$identite->NafaLib = prepareString($entrep['APRM_Lib']);
|
|
$identite->NumRM = $entrep['NumRM'];
|
|
$identite->Activite = $entrep['Activite'];
|
|
$identite->Capital = $entrep['Capital'];
|
|
$identite->CapitalDev = $entrep['CapitalDev'];
|
|
$identite->CapitalLib = $entrep['CapitalLib']; // Ajouté le 18 02 2008
|
|
$identite->CapitalType = prepareString($entrep['CapitalType']); // Ajouté le 4 08 2009
|
|
$identite->DateCreaEt = WDate::dateT('Ymd','Y-m-d',$entrep['DateCreaEt']);
|
|
$identite->DateCreaEn = WDate::dateT('Ymd','Y-m-d',$entrep['DateCreaEn']);
|
|
$identite->DateClotEt = $entrep['DateClotEt']; //@todo : date
|
|
$identite->DateImmat = $entrep['dateImmat']; // Ajouté le 4 08 2009
|
|
$identite->DateRadiation = $entrep['dateRad']; // Ajouté le 4 08 2009
|
|
//'DateMajRCS' = $entrep['DateMajRCS'], // Ajouté le 4 08 2009
|
|
$identite->EffEnTr = $entrep['EffEnTr'];
|
|
$identite->EffEnTrLib = $entrep['EffEnTrLib'];
|
|
$identite->Effectif = $entrep['Effectif'];
|
|
$identite->EffEtTr = $entrep['EffEtTr']; // Ajout le 11 08 2010
|
|
$identite->EffEtTrLib = $entrep['EffEtTrLib']; // Ajout le 11 08 2010
|
|
$identite->EffectifEtab = $entrep['EffectifEtab']; // Ajout le 11 08 2010
|
|
$identite->Dept = $entrep['Dept'];
|
|
$identite->codeCommune = prepareString($entrep['codeCommune']);
|
|
$identite->AnneeEffEn = $entrep['AnneeEffEn'];
|
|
$identite->AnneeEffEt = $entrep['AnneeEffEt'];
|
|
$identite->AnneeTCA = $entrep['AnneeTCA'];
|
|
$identite->TrancheCA = $entrep['TrancheCA'];
|
|
$identite->TrancheCALib = $entrep['TrancheCALib'];
|
|
$identite->TrancheCAType = $entrep['TrancheCAType'];
|
|
$identite->dir1Code = $entrep['dir1Code'];
|
|
$identite->dir1Titre = prepareString($entrep['dir1Titre']);
|
|
$identite->dir1NomPrenom = prepareString($entrep['dir1NomPrenom']);
|
|
$identite->dir1DateFct = prepareString($entrep['dir1DateFct']); //@todo : date
|
|
$identite->dir1DateNaiss = $entrep['dir1DateNaiss']; //@todo : date // Ajouté le 4 08 2009
|
|
$identite->dir1LieuNaiss = prepareString($entrep['dir1LieuNaiss']); // Ajouté le 4 08 2009
|
|
$identite->dir2Code = $entrep['dir2Code'];
|
|
$identite->dir2Titre = prepareString($entrep['dir2Titre']);
|
|
$identite->dir2NomPrenom = prepareString($entrep['dir2NomPrenom']);
|
|
$identite->dir2DateFct = $entrep['dir2DateFct']; //@todo : date
|
|
$identite->dir2DateNaiss = prepareString($entrep['dir2DateNaiss']); //@todo : date // Ajouté le 4 08 2009
|
|
$identite->dir2LieuNaiss = prepareString($entrep['dir2LieuNaiss']); // Ajouté le 4 08 2009
|
|
$identite->Rivoli = $entrep['Rivoli'];
|
|
|
|
$identite->InfosIris->codIris = $entrep['InfosIris']['codIris'];
|
|
$identite->InfosIris->codComIris = $entrep['InfosIris']['codComIris'];
|
|
$identite->InfosIris->libIris = prepareString($entrep['InfosIris']['libIris']);
|
|
$identite->InfosIris->typIris = prepareString($entrep['InfosIris']['typIris']);
|
|
$identite->InfosIris->evoIris = $entrep['InfosIris']['evoIris'];
|
|
$identite->InfosIris->trIris = $entrep['InfosIris']['trIris'];
|
|
$identite->InfosIris->grdQuartier = $entrep['InfosIris']['grdQuartier'];
|
|
$identite->NatureActivite = $entrep['NatureActivite']; // Nature de l'activité
|
|
$identite->OrigineCreation = $entrep['OrigineCreation']; // Origine de la création
|
|
$identite->TypeExploitation = $entrep['TypeExploitation'];
|
|
$identite->Auxiliaire = $entrep['Auxiliaire']; // 1=Auxiliaire / 0=Non auxiliaire
|
|
$identite->Saisonnalite = $entrep['Saisonnalite']; // P=Activité permanente / S=Activité saisonnière
|
|
$identite->SurfaceMagasin = $entrep['ACTISURF']*1; // 0=N/D, 1=inf. à 300m2,2=300 à 400m2, 3=400 à 2500m2, 4=sup. à 2500m2
|
|
$identite->SituationJuridique = $entrep['SituationJuridique'];
|
|
$identite->Bilan->Millesime = $entrep['bilanAnnee'];
|
|
$identite->Bilan->Cloture = $entrep['bilanDate']; //@todo : date
|
|
$identite->Bilan->Duree = $entrep['bilanMois'];
|
|
$identite->Bilan->Devise = $entrep['bilanDevise'];
|
|
$identite->Bilan->Capital = $entrep['bilanDA'];
|
|
$identite->Bilan->CA = $entrep['bilanFL'];
|
|
$identite->Bilan->CAestime = $entrep['bilanFLestime'];
|
|
$identite->Bilan->Resultat = prepareString($entrep['bilanHN']);
|
|
$identite->Bilan->Effectif = $entrep['bilanYP'];
|
|
$identite->Bourse->placeCotation = $bourse['placeCotation'];
|
|
$identite->Bourse->nombreTitres = $bourse['nombreTitres'];
|
|
$identite->Bourse->capitalisation = $bourse['close']*$bourse['nombreTitres'];
|
|
$identite->Bourse->derCoursDate = $bourse['date']; //@todo : date
|
|
$identite->Bourse->derCoursCloture = $bourse['close']; //@todo : date
|
|
|
|
$tabAutreSiren = array();
|
|
if (isset($entrep['AutreSiren'])) {
|
|
$autreSiren = new AutreSiren();
|
|
$autreSiren->siren = $entrep['AutreSiren']['listeSiren']['siren'];
|
|
$autreSiren->type = $entrep['AutreSiren']['listeSiren']['type'];
|
|
$tabAutreSiren[] = $autreSiren;
|
|
}
|
|
$identite->AutreSiren = $tabAutreSiren;
|
|
|
|
$tabAutreSiret = array();
|
|
if (count($entrep['AutreSiret'])) {
|
|
foreach($entrep['AutreSiret'] as $type => $item) {
|
|
$autreSiret = new AutreSiret();
|
|
$autreSiret->type = $type;
|
|
$autreSiret->siren = $item['siren'];
|
|
$autreSiret->nic = $item['nic'];
|
|
$autreSiret->apeEtab = $item['apeEtab'];
|
|
$autreSiret->codeEve = $item['codeEve'];
|
|
$autreSiret->dateEve = $item['dateEve'];
|
|
$autreSiret->adrL1 = $item['adrL1'];
|
|
$autreSiret->adrL2 = $item['adrL2'];
|
|
$autreSiret->adrL3 = $item['adrL3'];
|
|
$autreSiret->adrL4 = $item['adrL4'];
|
|
$autreSiret->adrL5 = $item['adrL5'];
|
|
$autreSiret->adrL6 = $item['adrL6'];
|
|
$autreSiret->adrL7 = $item['adrL7'];
|
|
$autreSiret->depCom = $item['depCom'];
|
|
$autreSiret->rivoli = $item['rivoli'];
|
|
$autreSiret->siege = $item['siege'];
|
|
$autreSiret->destinat = $item['destinat'];
|
|
$autreSiret->typEtab = $item['typeEtab'];
|
|
$autreSiret->origine = $item['origine'];
|
|
$tabAutreSiret[] = $autreSiret;
|
|
}
|
|
}
|
|
$identite->AutreSiret = $tabAutreSiret;
|
|
|
|
$identite->DateMajINSEE = $entrep['DateMajINSEE']; //@todo : date
|
|
$identite->DateMajRCS = $entrep['DateMajRCS']; //@todo : date
|
|
$identite->DateMajBILAN = $entrep['bilanDateMaj']; //@todo : date
|
|
$identite->DateMajANN = $entrep['dateMajANN']; //@todo : date
|
|
$identite->DateMajID = $entrep['dateMajIdentite']; //@todo : date
|
|
//'importExport' = $entrep['importExport'],
|
|
|
|
if (preg_match('/NAF4/i', $this->tabInfoUser['pref']))
|
|
{
|
|
$entrep2 = $iInsee->getNaf4($siren, $nic, $id);
|
|
if ( $entrep2 !== false ) {
|
|
$identite->Naf4Ent = $entrep2['apen4'];
|
|
$identite->Naf4Etab = $entrep2['apet4'];
|
|
$identite->Naf4EntLib = prepareString($entrep2['apen4_lib']);
|
|
$identite->Naf4EtabLib = prepareString($entrep2['apet4_lib']);
|
|
}
|
|
}
|
|
|
|
debugLog('I', 'Etablissement retourné = '. $entrep['Nom'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('identite',$siret,$id);
|
|
$duree=round(microtime(1)-$tdeb,3);
|
|
$ligne=date('YmdHis').";$siret;Ws->getIdentite APRES ($duree s) !!!";
|
|
$fp=fopen(LOG_PATH.'/accesDistant.log', 'a');
|
|
fwrite($fp,$ligne.EOL);
|
|
fclose($fp);
|
|
|
|
return $identite;
|
|
}
|
|
|
|
/**
|
|
* Retourne les informations identitaires de l'entreprise ou de l'établissement demandé
|
|
* @param string $siret Siren de l'entreprise ou siret de l'établissement
|
|
* @param integer $id Identifiant S&D de l'établissement
|
|
* @return IdentiteProcol Fiche d'identité de l'établissement
|
|
*/
|
|
public function getIdentiteProcol($siret, $id=0, $forceVerif=false)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('idprocol');
|
|
|
|
debugLog('I',"Identité AGS demandée pour siret $siret (id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$tabRet = array();
|
|
$siret = trim($siret);
|
|
$len = strlen($siret);
|
|
$siren = substr($siret,0,9);
|
|
if ($len == 14) {
|
|
$nic = substr($siret,9,5)*1;
|
|
} elseif ($len == 9) {
|
|
$nic = 0;
|
|
}
|
|
|
|
if (intval($siren)==0 && $id==0) {
|
|
$this->sendError('1010');
|
|
} elseif ($len!=14 && $len!=9) {
|
|
$this->sendError('1020');
|
|
}
|
|
|
|
debugLog('I', "Avant getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$iInsee = new MInsee();
|
|
$entrep = $iInsee->getIdentiteEntreprise($siren, $nic, $id, $forceVerif);
|
|
debugLog('I', "Après getIdentiteEntreprise($siren, $nic, $id)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$duree = round(microtime(1)-$tdeb,3);
|
|
$ligne = date('YmdHis').";$siret;Ws->getIdentite juste apres iInsee->... ($duree s)";
|
|
$fp = fopen(LOG_PATH.'/accesDistant.log', 'a');
|
|
fwrite($fp,$ligne.EOL);
|
|
fclose($fp);
|
|
if (empty($entrep)) {
|
|
debugLog('W', "Siren $siren non présent en base", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1020');
|
|
}
|
|
|
|
$iBourse = new MBourse($siren);
|
|
$bourse = $iBourse->getInfosBourse($siren);
|
|
|
|
$identiteProcol = new IdentiteProcol();
|
|
|
|
//Element identite
|
|
$identite = new Identite();
|
|
$identite->id = $entrep['id'];
|
|
$identite->Siret = $entrep['Siret'];
|
|
$identite->SiretSiege = $entrep['SiretSiege'];
|
|
$identite->Siege = $entrep['Siege'];
|
|
$identite->TribunalCode = $entrep['Tribunal'];
|
|
$identite->TribunalLib = $entrep['TribunalLib'];
|
|
$identite->NumRC = $entrep['numRC']; // Ajouté le 4 08 2009
|
|
$identite->Actif = $entrep['Actif'];
|
|
$identite->EntActiveRCS = $entrep['EntActiveRCS'];
|
|
$identite->AutreId = $entrep['AutreId'];
|
|
$identite->Source = $entrep['Source'];
|
|
$identite->SourceId = $entrep['SourceId'];
|
|
$identite->Isin = $entrep['Isin'];
|
|
$identite->Nom = strtr($entrep['Nom'],'/*',' ');
|
|
$identite->Nom2 = $entrep['Nom2'];
|
|
$identite->NomLong = $entrep['nomLong']; // Ajouté le 4 08 2009
|
|
$identite->NomCommercial = $entrep['NomCommercial']; // Ajouté le 16 11 2010
|
|
$identite->Siret = $entrep['Siret'];
|
|
$identite->Sigle = $entrep['Sigle'];
|
|
$identite->SigleLong = $entrep['sigleLong']; // Ajouté le 4 08 2009
|
|
$identite->Enseigne = $entrep['Enseigne'];
|
|
$identite->EnseigneLong = $entrep['enseigneLong']; // Ajouté le 16 11 2010
|
|
$identite->Adresse = $entrep['Adresse'];
|
|
$identite->Adresse2 = $entrep['Adresse2'];
|
|
$identite->AdresseNum = $entrep['AdresseNum'];
|
|
$identite->AdresseBtq = $entrep['AdresseBtq'];
|
|
$identite->AdresseVoie = $entrep['AdresseVoie'];
|
|
$identite->AdresseRue = $entrep['AdresseRue'];
|
|
$identite->CP = $entrep['CP'];
|
|
$identite->Ville = $entrep['Ville'];
|
|
$identite->Pays = $entrep['Pays']; // Ajouté le 18 02 2008
|
|
$identite->PaysIso2 = $entrep['PaysIso2'];
|
|
$identite->AdresseDom = $entrep['AdresseDom'];
|
|
|
|
$tabAdresseDomEnt = array();
|
|
if (isset($entrep['AdresseDomEnt']) && count($entrep['AdresseDomEnt'])>0){
|
|
foreach ($entrep['AdresseDomEnt'] as $element){
|
|
$adresseDomEnt = new AdresseDomEnt();
|
|
$adresseDomEnt->siren = $element['siren'];
|
|
$adresseDomEnt->nom = $element['nom'];
|
|
$tabAdresseDomEnt[] = $adresseDomEnt;
|
|
}
|
|
}
|
|
$identite->AdresseDomEnt = $tabAdresseDomEnt;
|
|
|
|
$identite->AdresseDomNb = $entrep['AdresseDomNb'];
|
|
$identite->Civilite = $entrep['Civilite'];
|
|
$identite->NbEtab = $entrep['NbEtab'];
|
|
$identite->Tel = $entrep['Tel'];
|
|
$identite->Fax = $entrep['Fax'];
|
|
$identite->Web = $entrep['Web'];
|
|
$identite->Mail = $entrep['Mail'];
|
|
$identite->GeoLat = $entrep['GeoLat'];
|
|
$identite->GeoLon = $entrep['GeoLon'];
|
|
$identite->GeoPrecis = $entrep['GeoPrecis'];
|
|
$identite->GeoInfos = $entrep['GeoInfos'];
|
|
$identite->TvaNumero = $entrep['TvaNumero'];
|
|
$identite->TvaAttribue = $entrep['TvaAttribue'];
|
|
$identite->FJ = $entrep['FJ'];
|
|
$identite->FJ_Lib = $entrep['FJ_lib'];
|
|
$identite->FJ2 = $entrep['FJ2']; // Ajouté le 4 08 2009
|
|
$identite->FJ2_Lib = $entrep['FJ2_Lib']; // Ajouté le 4 08 2009
|
|
$identite->Siren = $entrep['Siren'];
|
|
$identite->Nic = $entrep['Nic'];
|
|
$identite->NafEnt = $entrep['NafEnt'];
|
|
$identite->NafEntLib = $entrep['NafEntLib'];
|
|
$identite->NafEtab = $entrep['NafEtab'];
|
|
$identite->NafEtabLib = $entrep['NafEtabLib'];
|
|
$identite->NaceEtab = $entrep['NaceEtab'];
|
|
$identite->NaceEnt = $entrep['NaceEnt'];
|
|
$identite->Nafa = $entrep['APRM'];
|
|
$identite->NafaLib = $entrep['APRM_Lib'];
|
|
$identite->NumRM = $entrep['NumRM'];
|
|
$identite->Activite = $entrep['Activite'];
|
|
$identite->Capital = $entrep['Capital'];
|
|
$identite->CapitalDev = $entrep['CapitalDev'];
|
|
$identite->CapitalLib = $entrep['CapitalLib']; // Ajouté le 18 02 2008
|
|
$identite->CapitalType = $entrep['CapitalType']; // Ajouté le 4 08 2009
|
|
$identite->DateCreaEt = WDate::dateT('Ymd','Y-m-d',$entrep['DateCreaEt']);
|
|
$identite->DateCreaEn = WDate::dateT('Ymd','Y-m-d',$entrep['DateCreaEn']);
|
|
$identite->DateClotEt = $entrep['DateClotEt']; //@todo : date
|
|
$identite->DateImmat = $entrep['dateImmat']; // Ajouté le 4 08 2009
|
|
$identite->DateRadiation = $entrep['dateRad']; // Ajouté le 4 08 2009
|
|
$identite->EffEnTr = $entrep['EffEnTr'];
|
|
$identite->EffEnTrLib = $entrep['EffEnTrLib'];
|
|
$identite->Effectif = $entrep['Effectif'];
|
|
$identite->EffEtTr = $entrep['EffEtTr']; // Ajout le 11 08 2010
|
|
$identite->EffEtTrLib = $entrep['EffEtTrLib']; // Ajout le 11 08 2010
|
|
$identite->EffectifEtab = $entrep['EffectifEtab']; // Ajout le 11 08 2010
|
|
$identite->Dept = $entrep['Dept'];
|
|
$identite->codeCommune = $entrep['codeCommune'];
|
|
$identite->AnneeEffEn = $entrep['AnneeEffEn'];
|
|
$identite->AnneeEffEt = $entrep['AnneeEffEt'];
|
|
$identite->AnneeTCA = $entrep['AnneeTCA'];
|
|
$identite->TrancheCA = $entrep['TrancheCA'];
|
|
$identite->TrancheCALib = $entrep['TrancheCALib'];
|
|
$identite->dir1Code = $entrep['dir1Code'];
|
|
$identite->dir1Titre = $entrep['dir1Titre'];
|
|
$identite->dir1NomPrenom = $entrep['dir1NomPrenom'];
|
|
$identite->dir1DateFct = $entrep['dir1DateFct']; //@todo : date
|
|
$identite->dir1DateNaiss = $entrep['dir1DateNaiss']; //@todo : date // Ajouté le 4 08 2009
|
|
$identite->dir1LieuNaiss = $entrep['dir1LieuNaiss']; // Ajouté le 4 08 2009
|
|
$identite->dir2Code = $entrep['dir2Code'];
|
|
$identite->dir2Titre = $entrep['dir2Titre'];
|
|
$identite->dir2NomPrenom = $entrep['dir2NomPrenom'];
|
|
$identite->dir2DateFct = $entrep['dir2DateFct']; //@todo : date
|
|
$identite->dir2DateNaiss = $entrep['dir2DateNaiss']; //@todo : date // Ajouté le 4 08 2009
|
|
$identite->dir2LieuNaiss = $entrep['dir2LieuNaiss']; // Ajouté le 4 08 2009
|
|
$identite->Rivoli = $entrep['Rivoli'];
|
|
$identite->InfosIris->codIris = $entrep['InfosIris']['codIris'];
|
|
$identite->InfosIris->codComIris = $entrep['InfosIris']['codComIris'];
|
|
$identite->InfosIris->libIris = $entrep['InfosIris']['libIris'];
|
|
$identite->InfosIris->typIris = $entrep['InfosIris']['typIris'];
|
|
$identite->InfosIris->evoIris = $entrep['InfosIris']['evoIris'];
|
|
$identite->InfosIris->trIris = $entrep['InfosIris']['trIris'];
|
|
$identite->InfosIris->grdQuartier = $entrep['InfosIris']['grdQuartier'];
|
|
$identite->NatureActivite = $entrep['NatureActivite']; // Nature de l'activité
|
|
$identite->OrigineCreation = $entrep['OrigineCreation']; // Origine de la création
|
|
$identite->TypeExploitation = $entrep['TypeExploitation'];
|
|
$identite->Auxiliaire = $entrep['Auxiliaire']; // 1=Auxiliaire / 0=Non auxiliaire
|
|
$identite->Saisonnalite = $entrep['Saisonnalite']; // P=Activité permanente / S=Activité saisonnière
|
|
$identite->SituationJuridique = $entrep['SituationJuridique'];
|
|
$identite->Bilan->Cloture = $entrep['bilanDate']; //@todo : date
|
|
$identite->Bilan->Duree = $entrep['bilanMois'];
|
|
$identite->Bilan->Devise = $entrep['bilanDevise'];
|
|
$identite->Bilan->Capital = $entrep['bilanDA'];
|
|
$identite->Bilan->CA = $entrep['bilanFL'];
|
|
$identite->Bilan->Resultat = $entrep['bilanHN'];
|
|
$identite->Bilan->Effectif = $entrep['bilanYP'];
|
|
$identite->Bourse->placeCotation = $bourse['placeCotation'];
|
|
$identite->Bourse->nombreTitres = $bourse['nombreTitres'];
|
|
$identite->Bourse->capitalisation = $bourse['close']*$bourse['nombreTitres'];
|
|
$identite->Bourse->derCoursDate = $bourse['date']; //@todo : date
|
|
$identite->Bourse->derCoursCloture = $bourse['close']; //@todo : date
|
|
|
|
$tabAutreSiren = array();
|
|
if (isset($entrep['AutreSiren'])) {
|
|
$autreSiren = new AutreSiren();
|
|
$autreSiren->siren = $entrep['AutreSiren']['listeSiren']['siren'];
|
|
$autreSiren->type = $entrep['AutreSiren']['listeSiren']['type'];
|
|
$tabAutreSiren[] = $autreSiren;
|
|
}
|
|
$identite->AutreSiren = $tabAutreSiren;
|
|
|
|
$identite->DateMajINSEE = $entrep['DateMajINSEE']; //@todo : date
|
|
$identite->DateMajRCS = $entrep['DateMajRCS']; //@todo : date
|
|
$identite->DateMajBILAN = $entrep['bilanDateMaj']; //@todo : date
|
|
$identite->DateMajANN = $entrep['dateMajANN']; //@todo : date
|
|
$identite->DateMajID = $entrep['dateMajIdentite']; //@todo : date
|
|
|
|
if (preg_match('/NAF4/i', $this->tabInfoUser['pref']))
|
|
{
|
|
$entrep2 = $iInsee->getNaf4($siren, $nic, $id);
|
|
if ( $entrep2 !== false ) {
|
|
$identite->Naf4Ent = $entrep2['apen4'];
|
|
$identite->Naf4Etab = $entrep2['apet4'];
|
|
$identite->Naf4EntLib = prepareString($entrep2['apen4_lib']);
|
|
$identite->Naf4EtabLib = prepareString($entrep2['apet4_lib']);
|
|
}
|
|
}
|
|
|
|
$identiteProcol->Identite = $identite;
|
|
|
|
//Eléments annonces légales
|
|
$tabRetAnn = $tabLastEven = array();
|
|
if (intval($siren)!=0) {
|
|
$anns = $this->getAnnonces($siren, 1);
|
|
$anns = $anns->result;
|
|
$tribunalProcol = false;
|
|
foreach ($anns as $nb=>$ann)
|
|
{
|
|
$tabRetEven = array();
|
|
foreach ($ann->evenements as $tabEven) {
|
|
// On ignore les éléments suivants
|
|
if ($tabEven->CodeEven>=7000) continue;
|
|
if ($tabEven->CodeEven>=4000 && $tabEven->CodeEven<=4999) continue;
|
|
|
|
// Par défaut, on force le tribunal à celui présent dans la dernière annonce de Procol
|
|
if ($tribunalProcol==false && $tabEven->CodeEven>=1000 && $tabEven->CodeEven<2000 && $ann->BodaccCode=='BODA') {
|
|
$identiteProcol->TribunalCode = $ann->TribunalCode;
|
|
$identiteProcol->TribunalLib = prepareString($ann->Tribunal);
|
|
$tribunalProcol=true;
|
|
}
|
|
|
|
// On ne prend que le dernier élément de chaque type
|
|
if (in_array($tabEven->CodeEven, $tabLastEven)) continue;
|
|
|
|
$tabLastEven[] = $tabEven->CodeEven;
|
|
$tabRetEven[] = $tabEven;
|
|
}
|
|
|
|
if (count($tabRetEven)>0) {
|
|
$annonce = new Annonce();
|
|
$annonce->id = $ann->id;
|
|
$annonce->BodaccCode = $ann->BodaccCode;
|
|
$annonce->BodaccNum = $ann->BodaccNum;
|
|
$annonce->NumAnnonce = $ann->NumAnnonce;
|
|
$annonce->DateParution = $ann->DateParution; //@todo : date
|
|
$annonce->Departement = $ann->Departement;
|
|
$annonce->Tribunal = $ann->Tribunal;
|
|
$annonce->TribunalCode = $ann->TribunalCode;
|
|
$annonce->TribunalSiret = $ann->TribunalSiret;
|
|
$annonce->Rubrique = $ann->Rubrique;
|
|
$annonce->typeAnnonce = $ann->typeAnnonce;
|
|
$annonce->texteRectificatif = $ann->texteRectificatif;
|
|
$annonce->texteAnnonce = utf8_encode($ann->texteAnnonce);
|
|
$annonce->dateEffet = $ann->dateEffet; //@todo : date
|
|
$annonce->dateJugement = $ann->dateJugement; //@todo : date
|
|
$annonce->dateInsertionSD = $ann->dateInsertionSD; //@todo : date
|
|
$annonce->evenements = $tabRetEven;
|
|
$annonce->Lien_Annonce_Pdf = $ann->Lien_Annonce_Pdf;
|
|
$tabRetAnn[] = $annonce;
|
|
}
|
|
}
|
|
$identiteProcol->Annonces = $tabRetAnn;
|
|
|
|
$iRncs = new MRncs();
|
|
if ($entrep['Siege']==1 || $entrep['Siege']==11) {
|
|
$identiteProcol->LibTypeEtab = 'Etablissement Siege';
|
|
} else {
|
|
$tabEtabRncs = $iRncs->getIdentiteEtab($siren, $entrep['Nic']);
|
|
if ($tabEtabRncs['Siege']==2) $identiteProcol->LibTypeEtab = 'Etablissement Principal';
|
|
elseif ($tabEtabRncs['Siege']==1) $identiteProcol->LibTypeEtab = 'Etablissement Complementaire';
|
|
elseif ($tabEtabRncs['Siege']==0) $identiteProcol->LibTypeEtab = 'Etablissement Secondaire';
|
|
}
|
|
|
|
//@todo
|
|
$tabJuge = $iRncs->getIntervenants($siren);
|
|
$tabDepots=array();
|
|
foreach ($tabJuge as $iDepot=>$depot) {
|
|
$organe = new Organe();
|
|
$organe->codEven = $depot['codEven'];
|
|
$organe->libEven = prepareString($depot['libEven']);
|
|
$organe->dateEffet = $depot['dateEffet'];
|
|
$organe->admcode = $depot['admcode'];
|
|
$organe->admfonction = prepareString($depot['admfonction']);
|
|
$organe->admnom = prepareString($depot['admnom']);
|
|
$organe->admadrNum = $depot['admadrNum'];
|
|
$organe->admadrInd = $depot['admadrInd'];
|
|
$organe->admadrVoie = $depot['admadrVoie']; // @todo : adm1adr1, adm1adr2, adm1adr3,
|
|
$organe->admadrCP = $depot['admadrCP'];
|
|
$organe->admadrVille = $depot['admadrVille'];
|
|
$tabDepots[] = $organe;
|
|
}
|
|
$identiteProcol->Organes = $tabDepots;
|
|
|
|
|
|
$mLiens = new MLiens($siren);
|
|
$tabA = $mLiens->getActionnaires($siren, 1);
|
|
$nbA = count($tabA);
|
|
$tabAct = array();
|
|
foreach ($tabA as $i=>$lien) {
|
|
$liens = new Actionnaire();
|
|
$liens->Pmin = $lien['Pmin'];
|
|
$liens->MajMin = $lien['MajMin'];
|
|
$liens->RaisonSociale = $lien['RaisonSociale'];
|
|
$liens->Pays = $lien['Pays'];
|
|
$liens->Siren = $lien['Siren'];
|
|
$liens->Actif = $lien['Actif'];
|
|
$tabAct[] = $liens;
|
|
}
|
|
$identiteProcol->Actionnaires = $tabAct;
|
|
|
|
$iGreffes = new MGreffes();
|
|
$tabActes = $iGreffes->getListeActes($siren);
|
|
|
|
$identiteProcol->StatutsModifDepot = $identiteProcol->StatutsModif = '0000-00-00';
|
|
foreach ($tabActes as $i=>$acte) {
|
|
if ('_'.$acte['acte_type']=='_04') { // STATUTS CONSTITUTIFS
|
|
$identiteProcol->StatutsConstDepot = $acte['depot_date']; // => 1997-12-18
|
|
$identiteProcol->StatutsConst = $acte['acte_date']; // => 1997-11-13
|
|
break;
|
|
} elseif (in_array('_'.$acte['acte_type'], array(
|
|
//'_04', // STATUTS CONSTITUTIFS
|
|
'_06', // STATUTS A JOUR 9 0000-00-00 2009-09-02 17:05:55
|
|
'_07', // STATUTS A JOUR 9 0000-00-00 2009-09-02 17:05:55
|
|
'_08', // STATUTS A JOUR ET DECLARATION DE CONFORMITE 9 0000-00-00 2009-09-02 17:05:55
|
|
'_09', // STATUTS APRES TRANSFERT DE SIEGE 9 0000-00-00 2009-09-02 17:05:55
|
|
'_A1', // STATUTS 9 0000-00-00 2009-09-02 17:05:55
|
|
'_AH', // AVENANT AUX STATUTS
|
|
))) {
|
|
// On ne prend que la dernière modif
|
|
if ($identiteProcol->StatutsModifDepot=='0000-00-00' && $identiteProcol->StatutsModif=='0000-00-00') {
|
|
$identiteProcol->StatutsModifDepot = $acte['depot_date'];// => 1997-12-18
|
|
$identiteProcol->StatutsModif = $acte['acte_date']; // => 1997-11-13
|
|
}
|
|
}
|
|
}
|
|
|
|
/** Y a t il eu des informations relatives à une cession ? **/
|
|
$tabCes = $iGreffes->getInfosCessions($siren);
|
|
if ($tabCes) {
|
|
$identiteProcol->CessionJugeLib = $tabCes['cessJuge'];
|
|
$identiteProcol->CessionJugeDate = $tabCes['cessDateJuge'];
|
|
$identiteProcol->CessionAvisBodac = $tabCes['cessDateBod'];
|
|
$identiteProcol->CessionInvenDate = $tabCes['cessDateInv'];
|
|
$identiteProcol->CessionCAdeclare = $tabCes['cessCAdec'];
|
|
$identiteProcol->CessionEffectif = $tabCes['cessEffectif'];
|
|
$identiteProcol->CessionDesc = $tabCes['cessDesc'];
|
|
$identiteProcol->CessionDescDate = $tabCes['cessDateDesc'];
|
|
$identiteProcol->CessionOffreDate = $tabCes['cessDateLim'];
|
|
$identiteProcol->CessionMandataire = $tabCes['cessMand'];
|
|
}
|
|
}
|
|
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug $siren", print_r($tabRet,true)) ;
|
|
debugLog('I', 'Etablissement retourné = '. $entrep['Nom'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('identite',$siret,$id);
|
|
|
|
return $identiteProcol;
|
|
}
|
|
|
|
/**
|
|
* Retourne les liens financiers pour une entreprise.
|
|
*
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param boolean $actifsUniquement Uniquement les liens Actifs
|
|
* @return LiensReturn
|
|
*/
|
|
public function getLiens($siren, $actifsUniquement = true)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('liens');
|
|
|
|
//Initialisation
|
|
if (empty($actifsUniquement)) { $actifsUniquement = true; }
|
|
$tabAct = $tabPar = array();
|
|
|
|
debugLog('I',"Liens entreprises demandés pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
if (strlen($siren)<>9){
|
|
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$mLiens = new MLiens($siren);
|
|
$tabA = $mLiens->getActionnaires($siren, $actifsUniquement);
|
|
$nbA = count($tabA);
|
|
$tabAct = array();
|
|
if ($nbA > 0) {
|
|
foreach ($tabA as $i => $lien) {
|
|
$actionnaire = new Actionnaire();
|
|
$actionnaire->Pmin = $lien['Pmin'];
|
|
$actionnaire->MajMin = $lien['MajMin'];
|
|
$actionnaire->RaisonSociale = $lien['RaisonSociale'];
|
|
$actionnaire->TypeEntrep = $lien['TypeEntrep'];
|
|
$actionnaire->Pays = $lien['Pays'];
|
|
$actionnaire->Siren = $lien['Siren'];
|
|
$actionnaire->Actif = $lien['Actif'];
|
|
$actionnaire->Source = $lien['Source'];
|
|
$actionnaire->DateLien = $lien['DateLien']; //@todo : date
|
|
$actionnaire->DateMaj = $lien['DateMaj']; //@todo : date
|
|
$tabAct[] = $actionnaire;
|
|
}
|
|
}
|
|
debugLog('W', "$nbA actionnaires pour le siren $siren", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$tabP = $mLiens->getParticipations($siren, $actifsUniquement);
|
|
$nbP = count($tabP);
|
|
$tabPar = array();
|
|
if ($nbP > 0) {
|
|
foreach ($tabP as $i => $lien) {
|
|
$participation = new Participation();
|
|
$participation->Pmin = $lien['Pmin'];
|
|
$participation->MajMin = $lien['MajMin'];
|
|
$participation->RaisonSociale = $lien['RaisonSociale'];
|
|
$participation->TypeEntrep = $lien['TypeEntrep'];
|
|
$participation->Pays = $lien['Pays'];
|
|
$participation->Siren = $lien['Siren'];
|
|
$participation->Actif = $lien['Actif'];
|
|
$participation->Source = $lien['Source'];
|
|
$participation->DateLien = $lien['DateLien']; //@todo : date
|
|
$participation->DateMaj = $lien['DateMaj']; //@todo : date
|
|
$tabPar[] = $participation;
|
|
}
|
|
}
|
|
debugLog('W', "$nbP participations pour le siren $siren", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('liens',$siren);
|
|
|
|
$output = new LiensReturn();
|
|
$output->actionnaires = $tabAct;
|
|
$output->participations = $tabPar;
|
|
return $output;
|
|
}
|
|
|
|
|
|
/**
|
|
* Liste des établissements d'une entreprise
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param integer $departement Limiter aux établissements du departement
|
|
* @param integer $actif Otpionnel 1=Uniquements les actifs, 0=inactifs, Néant=Tous
|
|
* @param integer $position
|
|
* @param integer $nbRep
|
|
*
|
|
* @return ListeEtablissementsReturn
|
|
*/
|
|
public function getListeEtablissements($siren, $dep = 0, $actif = -1, $position = 0, $nbRep = 20)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('etablissements');
|
|
|
|
//Initialisation
|
|
if (empty($dep)) { $dep = 0; }
|
|
if (!in_array($actif, array(0,1))) { $actif = -1; }
|
|
if (empty($position)) { $position = 0; }
|
|
if (empty($nbRep)) { $nbRep = 20; }
|
|
|
|
//Valeur max
|
|
if($nbRep > 200) { $nbRep = 200; }
|
|
$departement = $dep;
|
|
|
|
debugLog('I',"Liste des établissements demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
if (strlen($siren)<>9) {
|
|
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
$rep = $iInsee->getEtablissements($siren, '', $position, $nbRep, 200, $departement, $actif);
|
|
$etabs = $rep['reponses'];
|
|
$nbReponses = $rep['nbReponsesTotal'];
|
|
$result = array();
|
|
if (count($etabs)>0)
|
|
{
|
|
foreach ($etabs as $nb => $etab)
|
|
{
|
|
$etablissement = new Etablissement();
|
|
$etablissement->id = $etab['id'];
|
|
$etablissement->Siege = $etab['Siege'];
|
|
$etablissement->Enseigne = $etab['Enseigne'];
|
|
$etablissement->Adresse = $etab['Adresse'];
|
|
$etablissement->Adresse2 = $etab['Adresse2'];
|
|
$etablissement->CP = $etab['CP'];
|
|
$etablissement->Ville = $etab['Ville'];
|
|
$etablissement->Tel = $etab['Tel'];
|
|
$etablissement->Fax = $etab['Fax'];
|
|
$etablissement->Nic = $etab['Nic'];
|
|
$etablissement->Actif = $etab['Actif'];
|
|
$etablissement->NafEtab = $etab['NafEtab'];
|
|
$etablissement->NafEtabLib = $etab['NafEtabLib'];
|
|
$etablissement->EffEtTr = $etab['EffEtTr'];
|
|
$etablissement->EffEtTrLib = $etab['EffEtTrLib'];
|
|
|
|
$result[] = $etablissement;
|
|
}
|
|
}
|
|
debugLog('I', "Nb Etablissements retournés ($departement, $actif) = ". count($result), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('etablissements',$siren);
|
|
$output = new ListeEtablissementsReturn();
|
|
$output->nbReponses = $nbReponses;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne l'ensemble des informations identitaires des dirigeants de l'entreprise
|
|
*
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param bool $histo Afficher l'historique des dirigeants
|
|
* @return DirigeantsReturn Liste des dirigeants actifs de l'entreprise
|
|
*/
|
|
public function getDirigeants( $siren , $histo = false)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('dirigeants');
|
|
|
|
//Initialisation
|
|
if (empty($histo)) { $histo = false; }
|
|
|
|
//Zend_Registry::get('WsLogger')->info('HISTO : '.$histo);
|
|
|
|
debugLog('I',"Dirigeants demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$tabRet = array();
|
|
if (strlen($siren)<>9) {
|
|
debugLog('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
$dirs = $iInsee->getDirigeants($siren, $histo);
|
|
//debugLog('W', print_r($dirs, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$liste = array();
|
|
foreach ($dirs as $nb => $dir)
|
|
{
|
|
//debugLog('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$dirigeant = new Dirigeant();
|
|
$dirigeant->Code = $dir['Fonction'];
|
|
$dirigeant->Titre = $dir['Titre'];
|
|
$dirigeant->Societe = $dir['Societe'];
|
|
$dirigeant->Civilite = $dir['Civilite'];
|
|
$dirigeant->Nom = $dir['Nom'];
|
|
$dirigeant->Prenom = $dir['Prenom'];
|
|
$dirigeant->NomUsage = $dir['NomUsage'];
|
|
$dirigeant->NaissDate = $dir['NaissDate']; //@todo : date
|
|
$dirigeant->NaissVille = $dir['NaissVille'];
|
|
$dirigeant->NaissDepPays = $dir['NaissDepPays'];
|
|
$dirigeant->Ancien = $dir['Ancien'];
|
|
$dirigeant->DateFct = $dir['DateFct']; //@todo : date
|
|
$liste[] = $dirigeant;
|
|
}
|
|
$this->wsLog('dirigeants',$siren,$option);
|
|
debugLog('I', 'Nb Dirigeants retournés = '. count($dirs), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$output = new DirigeantsReturn();
|
|
$output->result = $liste;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne la liste des annonces légales relative à une entreprise
|
|
*
|
|
* @todo Revoir cette fonction pour la faire marcher avec les associations
|
|
*
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param integer $filtre 1=BODACC, 2=B.A.L.O, 3=JO Association, 4=Boamp
|
|
* @param string $idAnn Identifiant de l'annonce
|
|
* @param integer $position
|
|
* @param integer $nbRep
|
|
* @return AnnoncesReturn
|
|
*/
|
|
public function getAnnonces($siren, $filtre = 1, $idAnn = '', $position = 0, $nbRep = 100)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('annonces');
|
|
|
|
//Initialisation
|
|
if (empty($filtre)) { $filtre = 1; }
|
|
if (empty($idAnn)) { $idAnn = ''; }
|
|
if (empty($position)) { $position = 0; }
|
|
if (empty($nbRep)) { $nbRep = 100; }
|
|
|
|
//Valeur max
|
|
if($nbRep > 200) { $nbRep = 200; }
|
|
|
|
debugLog('I',"Annonces demandées pour $siren ($filtre, $idAnn)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$liste = array();
|
|
|
|
if (strlen($siren)!=9) {
|
|
debugLog('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif (intval($siren)==0 && $idAnn=='') {
|
|
debugLog('W', "Siren $siren ou annonce $idAnn inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
/*
|
|
if ($siren>100 && $filtre==3) $asso=true;
|
|
else {
|
|
$asso=false;
|
|
$tabIdentite=$this->iInsee->getIdentiteLight($siren);
|
|
if ($tabIdentite['FJ']>90 && $tabIdentite['FJ']<94 ||
|
|
$tabIdentite['FJ']>9000 && $tabIdentite['FJ']<9400) $asso=true;
|
|
}*/
|
|
|
|
//@todo : Connaitre le nombre d'annonce
|
|
|
|
/*
|
|
getAnnoncesBoamp => Avis de marché, Avis d'attribution
|
|
getAnnoncesAsso => Rien de particulier
|
|
getAnnoncesBalo => Rien de particulier
|
|
getAnnoncesLegales => Plusieurs requetes SQL suivant la situation
|
|
*/
|
|
|
|
if ($idAnn=='') {
|
|
$anns=$iInsee->getAnnoncesLegales($siren);
|
|
$annsB=$iInsee->getAnnoncesBalo($siren);
|
|
$annsA=$iInsee->getAnnoncesAsso($siren);
|
|
$annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn);
|
|
} elseif ($filtre==1)
|
|
$anns=$iInsee->getAnnoncesLegales($siren, $idAnn);
|
|
elseif ($filtre==2)
|
|
$annsB=$iInsee->getAnnoncesBalo($siren, $idAnn);
|
|
elseif ($filtre==3)
|
|
$annsA=$iInsee->getAnnoncesAsso($siren, $idAnn);
|
|
elseif ($filtre==4)
|
|
$annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn);
|
|
|
|
//debugLog('W', print_r($entrep, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
if (empty($anns) && empty($annsB) && empty($annsA) && empty($annsM))
|
|
{
|
|
debugLog('W', "Aucune annonce pour le siren $siren (source=$filtre, id=$idAnn)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$error->errnum = 102;
|
|
$error->errmsg = 'Siren inexistant B '.$siren.' '.$idAnn;
|
|
}
|
|
else
|
|
{
|
|
foreach ($anns as $nb=>$ann)
|
|
{
|
|
//debugLog('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$evens = array();
|
|
foreach ($ann['evenements'] as $tabEven)
|
|
{
|
|
$even = new AnnonceEvenement();
|
|
$even->CodeEven = $tabEven['CodeEven'];
|
|
$even->LibEven = $tabEven['LibEven'];
|
|
$evens[] = $even;
|
|
}
|
|
$annonce = new Annonce();
|
|
$annonce->id = $ann['id'];
|
|
$annonce->BodaccCode = $ann['BodaccCode'];
|
|
$annonce->BodaccNum = $ann['BodaccNum'];
|
|
$annonce->NumAnnonce = $ann['NumAnnonce'];
|
|
$annonce->DateParution = $ann['DateParution']; //@todo : date
|
|
$annonce->Departement = $ann['Departement'];
|
|
$annonce->Tribunal = $ann['Tribunal'];
|
|
$annonce->TribunalCode = $ann['TribunalCode'];
|
|
$annonce->TribunalSiret = $ann['TribunalSiret'];
|
|
$annonce->Rubrique = $ann['Rubrique'];
|
|
$annonce->typeAnnonce = $ann['typeAnnonce'];
|
|
$annonce->texteRectificatif = prepareString($ann['texteRectificatif']);
|
|
$annonce->texteAnnonce = prepareString($ann['texteAnnonce']);
|
|
$annonce->libFJ = $ann['libFJ'];
|
|
$annonce->codFJ = $ann['codFJ'];
|
|
$annonce->capital = $ann['capital'];
|
|
$annonce->capitalDev = $ann['capitalDev'];
|
|
|
|
$annonce->raisonSociale = $ann['raisonSociale'];
|
|
$annonce->nomCommercial = $ann['nomCommercial'];
|
|
$annonce->sigle = $ann['sigle'];
|
|
$annonce->adresse = $ann['adresse'];
|
|
$annonce->dateEffet = $ann['dateEffet']; //@todo : date
|
|
$annonce->dateJugement = $ann['dateJugement']; //@todo : date
|
|
$annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$annonce->evenements = $evens;
|
|
$annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf'];
|
|
|
|
$liste[] = $annonce;
|
|
}
|
|
|
|
if (is_array($annsB))
|
|
{
|
|
foreach ($annsB as $nb=>$ann)
|
|
{
|
|
//debugLog('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$evens = array();
|
|
foreach ($ann['evenements'] as $tabEven)
|
|
{
|
|
$even = new AnnonceEvenement();
|
|
$even->CodeEven = $tabEven['CodeEven'];
|
|
$even->LibEven = $tabEven['LibEven'];
|
|
$evens[] = $even;
|
|
}
|
|
$annonce = new Annonce();
|
|
$annonce->id = $ann['id'];
|
|
$annonce->BodaccCode = $ann['BodaccCode'];
|
|
$annonce->BodaccNum = $ann['BodaccNum'];
|
|
$annonce->NumAnnonce = $ann['NumAnnonce'];
|
|
$annonce->DateParution = $ann['DateParution']; //@todo : date
|
|
$annonce->Departement = $ann['Departement'];
|
|
$annonce->Tribunal = $ann['Tribunal'];
|
|
//$annonce->TribunalCode = $ann['TribunalCode'];
|
|
$annonce->TribunalSiret = $ann['TribunalSiret'];
|
|
$annonce->Rubrique = $ann['Rubrique'];
|
|
$annonce->typeAnnonce = $ann['typeAnnonce'];
|
|
$annonce->texteRectificatif = prepareString($ann['texteRectificatif']);
|
|
$annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']);
|
|
//$annonce->libFJ = $ann['libFJ'];
|
|
//$annonce->codFJ = $ann['codFJ'];
|
|
//$annonce->capital = $ann['capital'];
|
|
//$annonce->capitalDev = $ann['capitalDev'];
|
|
$annonce->dateEffet = $ann['dateEffet']; //@todo : date
|
|
$annonce->dateJugement = $ann['dateJugement']; //@todo : date
|
|
$annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$annonce->evenements = $evens;
|
|
$annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf'];
|
|
|
|
$liste[] = $annonce;
|
|
}
|
|
}
|
|
|
|
if (is_array($annsA))
|
|
{
|
|
foreach ($annsA as $nb=>$ann)
|
|
{
|
|
//debugLog('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$evens = array();
|
|
foreach ($ann['evenements'] as $tabEven)
|
|
{
|
|
$even = new AnnonceEvenement();
|
|
$even->CodeEven = $tabEven['CodeEven'];
|
|
$even->LibEven = $tabEven['LibEven'];
|
|
$evens[] = $even;
|
|
}
|
|
|
|
$annonce = new Annonce();
|
|
$annonce->id = $ann['id'];
|
|
$annonce->BodaccCode = $ann['BodaccCode'];
|
|
$annonce->BodaccNum = $ann['BodaccNum'];
|
|
$annonce->NumAnnonce = $ann['NumAnnonce'];
|
|
$annonce->DateParution = $ann['DateParution']; //@todo : date
|
|
$annonce->Departement = $ann['Departement'];
|
|
$annonce->Tribunal = $ann['Tribunal'];
|
|
//$annonce->TribunalCode = $ann['TribunalCode'];
|
|
$annonce->TribunalSiret = $ann['TribunalSiret'];
|
|
$annonce->Rubrique = $ann['Rubrique'];
|
|
$annonce->typeAnnonce = $ann['typeAnnonce'];
|
|
$annonce->texteRectificatif = prepareString($ann['texteRectificatif']);
|
|
$annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']);
|
|
//$annonce->libFJ = $ann['libFJ'];
|
|
//$annonce->codFJ = $ann['codFJ'];
|
|
//$annonce->capital = $ann['capital'];
|
|
//$annonce->capitalDev = $ann['capitalDev'];
|
|
//@todo : date
|
|
$annonce->dateEffet = $ann['dateEffet']; //@todo : date
|
|
$annonce->dateJugement = $ann['dateJugement']; //@todo : date
|
|
$annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$annonce->evenements = $evens;
|
|
$annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf'];
|
|
|
|
$liste[] = $annonce;
|
|
}
|
|
}
|
|
|
|
if (is_array($annsM))
|
|
{
|
|
foreach ($annsM as $nb=>$ann)
|
|
{
|
|
$evens = array();
|
|
foreach ($ann['evenements'] as $tabEven)
|
|
{
|
|
$even = new AnnonceEvenement();
|
|
$even->CodeEven = $tabEven['CodeEven'];
|
|
$even->LibEven = $tabEven['LibEven'];
|
|
$evens[] = $even;
|
|
}
|
|
|
|
$annonce = new Annonce();
|
|
$annonce->id = $ann['id'];
|
|
$annonce->BodaccCode = $ann['BodaccCode'];
|
|
$annonce->BodaccNum = $ann['BodaccNum'];
|
|
$annonce->NumAnnonce = $ann['NumAnnonce'];
|
|
$annonce->DateParution = $ann['DateParution']; //@todo : date
|
|
$annonce->Departement = $ann['Departement'];
|
|
$annonce->Tribunal = $ann['Tribunal'];
|
|
//$annonce->TribunalCode = $ann['TribunalCode'];
|
|
$annonce->TribunalSiret = $ann['TribunalSiret'];
|
|
$annonce->Rubrique = $ann['Rubrique'];
|
|
$annonce->typeAnnonce = $ann['typeAnnonce'];
|
|
$annonce->texteRectificatif = prepareString($ann['texteRectificatif']);
|
|
$annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']);
|
|
//$annonce->libFJ = $ann['libFJ'];
|
|
//$annonce->codFJ = $ann['codFJ'];
|
|
//$annonce->capital = $ann['capital'];
|
|
//$annonce->capitalDev = $ann['capitalDev'];
|
|
$annonce->dateEffet = $ann['dateEffet']; //@todo : date
|
|
$annonce->dateJugement = $ann['dateJugement']; //@todo : date
|
|
$annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$annonce->evenements = $evens;
|
|
$annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf'];
|
|
|
|
$liste[] = $annonce;
|
|
}
|
|
}
|
|
}
|
|
|
|
$nbReponses = count($liste);
|
|
if ($nbReponses>0){
|
|
//$liste = array_slice($liste, $position, $nbRep);
|
|
}
|
|
debugLog('I', "Nb Annonces $filtre retournées pour $siren (source=$filtre, id=$idAnn) = ". count($liste), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('annonces',$siren,$filtre.'/'.$idAnn);
|
|
|
|
$output = new AnnoncesReturn();
|
|
$output->nbReponses = $nbReponses;
|
|
$output->result = $liste;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne le nombre d'élément pour chaque type
|
|
* @param string $siren
|
|
* @return AnnonceNum[]
|
|
*/
|
|
public function getAnnoncesNum($siren)
|
|
{
|
|
$this->authenticate();
|
|
|
|
$output = array();
|
|
|
|
if ( substr($siren,0,1)=='W' ) {
|
|
$iInsee = new MInsee();
|
|
$nb = new AnnonceNum();
|
|
$nb->type = 'asso';
|
|
$nb->num = $iInsee->getAnnoncesAssoCount($siren);
|
|
$output[] = $nb;
|
|
} elseif (intval($siren)!=0) {
|
|
$types = array('bodacc', 'balo', 'boamp', 'asso');
|
|
$iInsee = new MInsee();
|
|
foreach ($types as $type) {
|
|
switch($type) {
|
|
case 'bodacc':
|
|
$anns = $iInsee->getAnnoncesLegales($siren);
|
|
$total = count($anns);
|
|
break;
|
|
case 'balo':
|
|
$total = $iInsee->getAnnoncesBaloCount($siren);
|
|
break;
|
|
case 'boamp':
|
|
$total = $iInsee->getAnnoncesBoampCount($siren);
|
|
break;
|
|
case 'asso':
|
|
$total = $iInsee->getAnnoncesAssoCount($siren);
|
|
break;
|
|
}
|
|
$nb = new AnnonceNum();
|
|
$nb->type = $type;
|
|
$nb->num = $total;
|
|
$output[] = $nb;
|
|
}
|
|
}
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne les annonces légales
|
|
* @param string $siren
|
|
* @param string $idAnn
|
|
* @param AnnonceFilter[] $filtre
|
|
* @param int $position
|
|
* @param int $nbRep
|
|
* @return AnnoncesReturn
|
|
*/
|
|
public function getAnnoncesLegales($siren, $idAnn = null, $filtre = null, $position = 0, $nbRep = 20)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('annonces');
|
|
|
|
//Initialisation
|
|
if (empty($idAnn)) { $idAnn = null; }
|
|
if (empty($position)) { $position = 0; }
|
|
if (empty($nbRep)) { $nbRep = 100; }
|
|
|
|
//Valeur max
|
|
if($nbRep > 200) { $nbRep = 200; }
|
|
|
|
debugLog('I',"Annonces demandées pour $siren ($idAnn)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if (strlen($siren)!=9) {
|
|
debugLog('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif (intval($siren)==0 && $idAnn=='') {
|
|
debugLog('W', "Siren $siren ou annonce $idAnn inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
$isList = false;
|
|
|
|
if ( is_null($idAnn) ) {
|
|
$anns = $iInsee->getAnnoncesLegales($siren);
|
|
$nbReponses = count($anns);
|
|
$isList = true;
|
|
} else {
|
|
$anns = $iInsee->getAnnoncesLegales($siren, $idAnn);
|
|
$nbReponses = count($anns);
|
|
}
|
|
|
|
$liste = array();
|
|
$cpt = 0;
|
|
|
|
if (is_array($anns))
|
|
{
|
|
foreach ($anns as $nb => $ann)
|
|
{
|
|
if ($isList===true && $nb<$position) { continue; }
|
|
$cpt++;
|
|
if ($isList===true && $cpt>$nbRep) { break; }
|
|
|
|
$evens = array();
|
|
foreach ($ann['evenements'] as $tabEven)
|
|
{
|
|
$even = new AnnonceEvenement();
|
|
$even->CodeEven = $tabEven['CodeEven'];
|
|
$even->LibEven = $tabEven['LibEven'];
|
|
$evens[] = $even;
|
|
}
|
|
$annonce = new Annonce();
|
|
$annonce->id = $ann['id'];
|
|
$annonce->BodaccCode = $ann['BodaccCode'];
|
|
$annonce->BodaccNum = $ann['BodaccNum'];
|
|
$annonce->NumAnnonce = $ann['NumAnnonce'];
|
|
$annonce->DateParution = $ann['DateParution']; //@todo : date
|
|
$annonce->Departement = $ann['Departement'];
|
|
$annonce->Tribunal = $ann['Tribunal'];
|
|
$annonce->TribunalCode = $ann['TribunalCode'];
|
|
$annonce->TribunalSiret = $ann['TribunalSiret'];
|
|
$annonce->Rubrique = $ann['Rubrique'];
|
|
$annonce->typeAnnonce = $ann['typeAnnonce'];
|
|
$annonce->texteRectificatif = prepareString($ann['texteRectificatif']);
|
|
$annonce->texteAnnonce = prepareString($ann['texteAnnonce']);
|
|
$annonce->libFJ = $ann['libFJ'];
|
|
$annonce->codFJ = $ann['codFJ'];
|
|
$annonce->capital = $ann['capital'];
|
|
$annonce->capitalDev = $ann['capitalDev'];
|
|
|
|
$annonce->raisonSociale = $ann['raisonSociale'];
|
|
$annonce->nomCommercial = $ann['nomCommercial'];
|
|
$annonce->sigle = $ann['sigle'];
|
|
$annonce->adresse = $ann['adresse'];
|
|
$annonce->dateEffet = $ann['dateEffet']; //@todo : date
|
|
$annonce->dateJugement = $ann['dateJugement']; //@todo : date
|
|
$annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$annonce->evenements = $evens;
|
|
$annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf'];
|
|
|
|
$liste[] = $annonce;
|
|
}
|
|
}
|
|
|
|
$this->wsLog('annonces',$siren,$idAnn);
|
|
|
|
$output = new AnnoncesReturn();
|
|
$output->nbReponses = $nbReponses;
|
|
$output->result = $liste;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne les annonces du journal officiel des associations
|
|
* @param string $siren
|
|
* @param string $idAnn
|
|
* @param AnnonceFilter[] $filtre
|
|
* @param int $position
|
|
* @param int $nbRep
|
|
* @return AnnoncesReturn
|
|
*/
|
|
public function getAnnoncesAsso($siren, $idAnn = null, $filtre = null, $position = 0, $nbRep = 20)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('annonces');
|
|
|
|
//Initialisation
|
|
if (empty($idAnn)) { $idAnn = 0; }
|
|
if (empty($position)) { $position = 0; }
|
|
if (empty($nbRep)) { $nbRep = 20; }
|
|
|
|
//Valeur max
|
|
if($nbRep > 200) { $nbRep = 200; }
|
|
|
|
debugLog('I',"Annonces demandées pour $siren ($filtre, $idAnn)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if (strlen($siren)!=9 && substr($siren,0,1)!='W') {
|
|
debugLog('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif (intval($siren)==0 && is_null($idAnn)) {
|
|
debugLog('W', "Siren $siren ou annonce $idAnn inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
$nbReponses = $iInsee->getAnnoncesAssoCount($siren, $idAnn);
|
|
$anns = $iInsee->getAnnoncesAsso($siren, $idAnn, $position, $nbRep);
|
|
|
|
$liste = array();
|
|
|
|
if (is_array($anns))
|
|
{
|
|
foreach ($anns as $nb=>$ann)
|
|
{
|
|
$evens = array();
|
|
foreach ($ann['evenements'] as $tabEven)
|
|
{
|
|
$even = new AnnonceEvenement();
|
|
$even->CodeEven = $tabEven['CodeEven'];
|
|
$even->LibEven = $tabEven['LibEven'];
|
|
$evens[] = $even;
|
|
}
|
|
|
|
$annonce = new Annonce();
|
|
$annonce->id = $ann['id'];
|
|
$annonce->BodaccCode = $ann['BodaccCode'];
|
|
$annonce->BodaccNum = $ann['BodaccNum'];
|
|
$annonce->NumAnnonce = $ann['NumAnnonce'];
|
|
$annonce->DateParution = $ann['DateParution']; //@todo : date
|
|
$annonce->Departement = $ann['Departement'];
|
|
$annonce->Tribunal = $ann['Tribunal'];
|
|
//$annonce->TribunalCode = $ann['TribunalCode'];
|
|
$annonce->TribunalSiret = $ann['TribunalSiret'];
|
|
$annonce->Rubrique = $ann['Rubrique'];
|
|
$annonce->typeAnnonce = $ann['typeAnnonce'];
|
|
$annonce->texteRectificatif = prepareString($ann['texteRectificatif']);
|
|
$annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']);
|
|
//$annonce->libFJ = $ann['libFJ'];
|
|
//$annonce->codFJ = $ann['codFJ'];
|
|
//$annonce->capital = $ann['capital'];
|
|
//$annonce->capitalDev = $ann['capitalDev'];
|
|
//@todo : date
|
|
$annonce->dateEffet = $ann['dateEffet']; //@todo : date
|
|
$annonce->dateJugement = $ann['dateJugement']; //@todo : date
|
|
$annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$annonce->evenements = $evens;
|
|
$annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf'];
|
|
|
|
$liste[] = $annonce;
|
|
}
|
|
}
|
|
|
|
$this->wsLog('annonces',$siren,$idAnn);
|
|
|
|
$output = new AnnoncesReturn();
|
|
$output->nbReponses = $nbReponses;
|
|
$output->result = $liste;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne les annonces de marché public
|
|
* @param string $siren
|
|
* @param string $idAnn
|
|
* @param AnnonceFilter[] $filtre
|
|
* @param int $position
|
|
* @param int $nbRep
|
|
* @return AnnoncesReturn
|
|
*/
|
|
public function getAnnoncesBoamp($siren, $idAnn = null, $filtre = null, $position = 0, $nbRep = 20)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('annonces');
|
|
|
|
//Initialisation
|
|
if (empty($idAnn)) { $idAnn = ''; }
|
|
if (empty($position)) { $position = 0; }
|
|
if (empty($nbRep)) { $nbRep = 20; }
|
|
|
|
//Valeur max
|
|
if($nbRep > 200) { $nbRep = 200; }
|
|
|
|
$type = array('A', 'M');
|
|
|
|
if (is_array($filtre->item) && count($filtre->item)>0) {
|
|
foreach($filtre->item as $item) {
|
|
if ( $item->key == 'type' ) {
|
|
$type = $item->value;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (strlen($siren)<>9) {
|
|
debugLog('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif (intval($siren)==0 && is_null($idAnn)) {
|
|
debugLog('W', "Siren $siren ou annonce $idAnn inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
if ( empty($idAnn) ) {
|
|
$nbReponses = $iInsee->getAnnoncesBoampCount($siren, $type);
|
|
$anns = $iInsee->getAnnoncesBoamp($siren, $idAnn, $type, $position, $nbRep);
|
|
} else {
|
|
$anns = $iInsee->getAnnoncesBoamp($siren, $idAnn, $type, 0, 1);
|
|
$nbReponses = count($anns);
|
|
}
|
|
|
|
$liste = array();
|
|
if (is_array($anns) && count($anns)>0)
|
|
{
|
|
foreach ($anns as $nb=>$ann)
|
|
{
|
|
$evens = array();
|
|
foreach ($ann['evenements'] as $tabEven)
|
|
{
|
|
$even = new AnnonceEvenement();
|
|
$even->CodeEven = $tabEven['CodeEven'];
|
|
$even->LibEven = $tabEven['LibEven'];
|
|
$evens[] = $even;
|
|
}
|
|
|
|
$annonce = new Annonce();
|
|
$annonce->id = $ann['id'];
|
|
$annonce->BodaccCode = $ann['BodaccCode'];
|
|
$annonce->BodaccNum = $ann['BodaccNum'];
|
|
$annonce->NumAnnonce = $ann['NumAnnonce'];
|
|
$annonce->DateParution = $ann['DateParution']; //@todo : date
|
|
$annonce->Departement = $ann['Departement'];
|
|
$annonce->Tribunal = $ann['Tribunal'];
|
|
//$annonce->TribunalCode = $ann['TribunalCode'];
|
|
$annonce->TribunalSiret = $ann['TribunalSiret'];
|
|
$annonce->Rubrique = $ann['Rubrique'];
|
|
$annonce->typeAnnonce = $ann['typeAnnonce'];
|
|
$annonce->texteRectificatif = prepareString($ann['texteRectificatif']);
|
|
$annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']);
|
|
//$annonce->libFJ = $ann['libFJ'];
|
|
//$annonce->codFJ = $ann['codFJ'];
|
|
//$annonce->capital = $ann['capital'];
|
|
//$annonce->capitalDev = $ann['capitalDev'];
|
|
$annonce->dateEffet = $ann['dateEffet']; //@todo : date
|
|
$annonce->dateJugement = $ann['dateJugement']; //@todo : date
|
|
$annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$annonce->evenements = $evens;
|
|
$annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf'];
|
|
|
|
$liste[] = $annonce;
|
|
}
|
|
}
|
|
|
|
$this->wsLog('annonces',$siren,$idAnn);
|
|
|
|
$output = new AnnoncesReturn();
|
|
$output->nbReponses = $nbReponses;
|
|
$output->result = $liste;
|
|
return $output;
|
|
|
|
}
|
|
|
|
/**
|
|
* Retourne les annonces du bulletins des annonces légales obligatoires
|
|
* @param string $siren
|
|
* @param string $idAnn
|
|
* @param AnnonceFilter[] $filtre
|
|
* @param int $position
|
|
* @param int $nbRep
|
|
* @return AnnoncesReturn
|
|
*/
|
|
public function getAnnoncesBalo($siren, $idAnn = null, $filtre = null, $position = 0, $nbRep = 20)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('annonces');
|
|
|
|
//Initialisation
|
|
if (empty($idAnn)) { $idAnn = null; }
|
|
if (empty($position)) { $position = 0; }
|
|
if (empty($nbRep)) { $nbRep = 20; }
|
|
|
|
//Valeur max
|
|
if($nbRep > 200) { $nbRep = 200; }
|
|
|
|
debugLog('I',"Annonces demandées pour $siren ($filtre, $idAnn)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if (strlen($siren)<>9) {
|
|
debugLog('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif (intval($siren)==0 && is_null($idAnn)) {
|
|
debugLog('W', "Siren $siren ou annonce $idAnn inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
if ( is_null($idAnn) ) {
|
|
$nbReponses = $iInsee->getAnnoncesBaloCount($siren);
|
|
$anns = $iInsee->getAnnoncesBalo($siren, $idAnn, $position, $nbRep);
|
|
} else {
|
|
$anns = $iInsee->getAnnoncesBalo($siren, $idAnn, 0, 1);
|
|
$nbReponses = count($anns);
|
|
}
|
|
|
|
$liste = array();
|
|
if (is_array($anns) && count($anns)>0)
|
|
{
|
|
foreach ($anns as $nb=>$ann)
|
|
{
|
|
$evens = array();
|
|
foreach ($ann['evenements'] as $tabEven)
|
|
{
|
|
$even = new AnnonceEvenement();
|
|
$even->CodeEven = $tabEven['CodeEven'];
|
|
$even->LibEven = $tabEven['LibEven'];
|
|
$evens[] = $even;
|
|
}
|
|
$annonce = new Annonce();
|
|
$annonce->id = $ann['id'];
|
|
$annonce->BodaccCode = $ann['BodaccCode'];
|
|
$annonce->BodaccNum = $ann['BodaccNum'];
|
|
$annonce->NumAnnonce = $ann['NumAnnonce'];
|
|
$annonce->DateParution = $ann['DateParution']; //@todo : date
|
|
$annonce->Departement = $ann['Departement'];
|
|
$annonce->Tribunal = $ann['Tribunal'];
|
|
$annonce->TribunalSiret = $ann['TribunalSiret'];
|
|
$annonce->Rubrique = $ann['Rubrique'];
|
|
$annonce->typeAnnonce = $ann['typeAnnonce'];
|
|
$annonce->texteRectificatif = prepareString($ann['texteRectificatif']);
|
|
$annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']);
|
|
$annonce->dateEffet = $ann['dateEffet']; //@todo : date
|
|
$annonce->dateJugement = $ann['dateJugement']; //@todo : date
|
|
$annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$annonce->evenements = $evens;
|
|
$annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf'];
|
|
|
|
$liste[] = $annonce;
|
|
}
|
|
}
|
|
|
|
$this->wsLog('annonces',$siren,$idAnn);
|
|
|
|
$output = new AnnoncesReturn();
|
|
$output->nbReponses = $nbReponses;
|
|
$output->result = $liste;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Evaluation indiScore d'une entreprise
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param string $nic Nic de l'établissement
|
|
* @param integer $niveau Niveau des commentaires
|
|
* @param bool $plus Si true, mise en surveillance privilèges
|
|
* @param string $ref Si $plus=true, référence de la mise en Surveillance
|
|
* @param integer $encours Si $plus=true, encours client demandé lors de la mise en Surveillance
|
|
* @param string $email Si $plus=true, email client pour la mise en surveillance
|
|
* @return Indiscore
|
|
*/
|
|
public function getIndiScore($siren, $nic=0, $niveau=2, $plus=false, $ref='', $encours=0, $email='')
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$accesDist = true;
|
|
if (empty($nic)) { $nic = 0; }
|
|
if (empty($niveau)) { $niveau = 2; }
|
|
if (empty($plus)) { $plus = false; }
|
|
if ( !in_array($niveau, array(0,1,2,3,4,5)) ) { $niveau = 2; }
|
|
$perm = false;
|
|
//@todo : Gestion des droits
|
|
switch($niveau){
|
|
case 3: $perms = array('indiscore3', 'indiscore3p'); break;
|
|
case 2: $perms = array('indiscore2', 'indiscore2p', 'indiscore3', 'indiscore3p'); break;
|
|
case 1: $perms = array('indiscore', 'indiscorep'); break;
|
|
}
|
|
foreach($perms as $item){
|
|
if ( $this->checkPerm($item) ){
|
|
$perm = true;
|
|
break;
|
|
}
|
|
}
|
|
if ($perm === false) {
|
|
$this->sendError('0902');
|
|
}
|
|
|
|
$tabRet = array();
|
|
debugLog('I',"IndiScore demandée pour $siren en niveau $niveau",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
if (strlen($siren)>9 || (substr($siren,0,9)*1)<100 ){
|
|
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$tDeb = microtime(true);
|
|
require_once 'Metier/scores/classMScores.php';
|
|
$tabRet = calculIndiScore($siren, $nic, $accesDist, $niveau, false, 'scores');
|
|
$duree = round(microtime(true)-$tDeb,3);
|
|
debugLog('W', "indiscore DUREE = $duree s", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$output = new Indiscore();
|
|
foreach($tabRet as $key => $value){
|
|
if ($key=='paiements'){
|
|
$parMont = $value['parMont'];
|
|
$parTrim = $value['parTrim'];
|
|
$tabMont = array();
|
|
foreach($parMont as $parMontK => $parMontV){
|
|
$paiementMont = new IndiscorePaiementDetail();
|
|
$paiementMont->id = $parMontK;
|
|
$paiementMont->nb = $parMontV['nb'];
|
|
if (array_key_exists('d=180', $parMontV)){
|
|
$paiementMont->d180 = $parMontV['d=180'];
|
|
}
|
|
if (array_key_exists('d=150', $parMontV)){
|
|
$paiementMont->d150 = $parMontV['d=150'];
|
|
}
|
|
if (array_key_exists('d=120', $parMontV)){
|
|
$paiementMont->d120 = $parMontV['d=120'];
|
|
}
|
|
if (array_key_exists('d=90', $parMontV)){
|
|
$paiementMont->d90 = $parMontV['d=90'];
|
|
}
|
|
if (array_key_exists('d=60', $parMontV)){
|
|
$paiementMont->d60 = $parMontV['d=60'];
|
|
}
|
|
if (array_key_exists('d=30', $parMontV)){
|
|
$paiementMont->d30 = $parMontV['d=30'];
|
|
}
|
|
$tabMont[] = $paiementMont;
|
|
}
|
|
$tabTrim = array();
|
|
foreach($parTrim as $parTrimK => $parTrimV){
|
|
$paiementTrim = new IndiscorePaiementDetail();
|
|
$paiementTrim->id = $parTrimK;
|
|
$paiementTrim->nb = $parTrimV['nb'];
|
|
if (array_key_exists('d=180', $parTrimV)){
|
|
$paiementTrim->d180 = $parTrimV['d=180'];
|
|
}
|
|
if (array_key_exists('d=150', $parTrimV)){
|
|
$paiementTrim->d150 = $parTrimV['d=150'];
|
|
}
|
|
if (array_key_exists('d=120', $parTrimV)){
|
|
$paiementTrim->d120 = $parTrimV['d=120'];
|
|
}
|
|
if (array_key_exists('d=90', $parTrimV)){
|
|
$paiementTrim->d90 = $parTrimV['d=90'];
|
|
}
|
|
if (array_key_exists('d=60', $parTrimV)){
|
|
$paiementTrim->d60 = $parTrimV['d=60'];
|
|
}
|
|
if (array_key_exists('d=30', $parTrimV)){
|
|
$paiementTrim->d30 = $parTrimV['d=30'];
|
|
}
|
|
$tabTrim[] = $paiementTrim;
|
|
}
|
|
$paiement = new IndiscorePaiement();
|
|
$paiement->parMont = $tabMont;
|
|
$paiement->parTrim = $tabTrim;
|
|
$output->paiements = $paiement;
|
|
|
|
} elseif ($key=='Notes_Structure') {
|
|
|
|
$notesStructure = new IndiscoreNotesStructure();
|
|
$notesStructure->activite = $value['activite'];
|
|
$notesStructure->naf4 = $value['naf4'];
|
|
$notesStructure->age = $value['age'];
|
|
$notesStructure->capital = $value['capital'];
|
|
$notesStructure->effectif = $value['effectif'];
|
|
$notesStructure->fj = $value['fj'];
|
|
$notesStructure->localite = $value['localite'];
|
|
$notesStructure->singulier = $value['singulier'];
|
|
$output->Notes_Structure = $notesStructure;
|
|
|
|
} elseif ($key=='tabBilans') {
|
|
|
|
$tabRet = array();
|
|
foreach($value as $bilan)
|
|
{
|
|
$element = new ListeBilans();
|
|
$element->dateProvPartenaire = $bilan['dateProvPartenaire']; //@todo : date
|
|
$element->dateInsert = $bilan['dateInsert']; //@todo : date
|
|
$element->typeBilan = $bilan['typeBilan'];
|
|
$element->dureeExercice = $bilan['dureeExercice'];
|
|
$element->dateExercice = $bilan['dateExercice']; //@todo : date
|
|
$element->millesime = $bilan['millesime'];
|
|
$element->dateExercicePre = $bilan['dateExercicePre']; //@todo : date
|
|
$element->dureeExercicePre = $bilan['dureeExercicePre'];
|
|
$element->monnaie = $bilan['monnaie'];
|
|
$element->source = $bilan['source'];
|
|
$tabRet[] = $element;
|
|
}
|
|
$output->tabBilans = $tabRet;
|
|
|
|
} elseif ($key=='tabBilan') {
|
|
|
|
$tabRet = array();
|
|
foreach($value as $bilan){
|
|
$resultBilan = new Bilan();
|
|
$tabPoste = array();
|
|
foreach($bilan as $bilan_key => $bilan_value){
|
|
if(!in_array($bilan_key, array('SIREN', 'DATE_FRAICHE_BILAN',
|
|
'DATE_CLOTURE', 'DATE_CLOTURE_PRE', 'DUREE_MOIS',
|
|
'DUREE_MOIS_PRE', 'MONNAIE', 'CONSOLIDE', 'MONNAIE_ORI',
|
|
'MONNAIE_LIV_UNITE', 'SOURCE', 'devise'))){
|
|
$resultPoste = new BilanPoste();
|
|
$resultPoste->id = $bilan_key;
|
|
$resultPoste->val = $bilan_value;
|
|
$tabPoste[] = $resultPoste;
|
|
} else {
|
|
$resultBilan->$bilan_key = $bilan_value;
|
|
}
|
|
}
|
|
$resultBilan->POSTES = $tabPoste;
|
|
$tabRet[] = $resultBilan;
|
|
}
|
|
$output->tabBilan = $tabRet;
|
|
|
|
} elseif ($key=='tabInfosNotations') {
|
|
|
|
$infosNotation = new IndiscoreInfosNotations();
|
|
$infosNotation->SituationFinanciere = $value['SituationFinanciere'];
|
|
$infosNotation->Notation = $value['Notation'];
|
|
$infosNotation->ProbabiliteDefaut = $value['ProbabiliteDefaut'];
|
|
$output->tabInfosNotations = $infosNotation;
|
|
|
|
} elseif ($key=='tabImportExport') {
|
|
|
|
$tabRet = array();
|
|
foreach($value as $element){
|
|
$importExport = new IndiscoreImportExport();
|
|
$importExport->importExport = $element['importExport'];
|
|
$importExport->annee = $element['annee'];
|
|
$importExport->rangNational = $element['rangNational'];
|
|
$importExport->deptSiege = $element['deptSiege'];
|
|
$tabRet[] = $importExport;
|
|
}
|
|
$output->tabImportExport = $tabRet;
|
|
|
|
} elseif ($key=='tabCommentaires') {
|
|
|
|
$tab = array();
|
|
foreach($value as $comment) {
|
|
require_once 'i18n/cleanchar.php';
|
|
$tab[] = fixEncoding($comment);
|
|
}
|
|
$output->tabCommentaires = $tab;
|
|
|
|
} elseif ($key=='tabVariables') {
|
|
|
|
$tab = $value['CA_Y'];
|
|
$tabVar = array();
|
|
if (count($tab)>0) {
|
|
foreach($tab as $varName => $varVal){
|
|
$var = new CA_Y();
|
|
$var->id = $varName;
|
|
$var->val = $varVal;
|
|
$tabVar[] = $var;
|
|
}
|
|
}
|
|
$variables = new IndiscoreVariables();
|
|
$variables->CA_Y = $tabVar;
|
|
$output->tabVariables = $variables;
|
|
|
|
} elseif ($key=='Bilans') {
|
|
|
|
$tab = array();
|
|
foreach($value as $item)
|
|
{
|
|
$objet = new IndiscoreBilans();
|
|
$objet->Millesime = $item['Millesime'];
|
|
$objet->FraisPerso = $item['FraisPerso'];
|
|
$objet->CA = $item['CA'];
|
|
$objet->EBE = $item['EBE'];
|
|
$objet->TxInvest = $item['TxInvest'];
|
|
$objet->TxEndett = $item['TxEndett'];
|
|
$objet->DettesCT = $item['DettesCT'];
|
|
$objet->FraisFi = $item['FraisFi'];
|
|
$objet->BFR = $item['BFR'];
|
|
$objet->FR = $item['FR'];
|
|
$objet->FondsPr = $item['FondsPr'];
|
|
$objet->DelaiCli = $item['DelaiCli'];
|
|
$objet->DelaiFour = $item['DelaiFour'];
|
|
$tab[] = $objet;
|
|
}
|
|
$output->$key = $tab;
|
|
} else {
|
|
$output->$key = $value;
|
|
}
|
|
}
|
|
|
|
if ($plus) {
|
|
if (empty($ref)) $ref='Indiscore+';
|
|
if (empty($email)) $email=$this->tabInfoUser['email'];
|
|
$this->setSurveillance($siren, $email, $ref, 'privileges');
|
|
$this->setSurveillance($siren, $email, $ref, 'score', false, $encours);
|
|
if ($this->tabInfoUser['idClient']==89)
|
|
$this->setSurveillance($siren, $email, $ref, 'annonces');
|
|
$this->wsLog('indiscore+',$siren);
|
|
} else
|
|
$this->wsLog('indiscore',$siren);
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Evaluation valorsation d'une entreprise
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param string $nic Nic de l'établissement
|
|
* @param integer $niveau Niveau des commentaires
|
|
* @return Indiscore
|
|
*/
|
|
public function getValo($siren, $nic=0, $niveau=2)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('indiscore');
|
|
|
|
//Initialisation
|
|
$accesDist = true;
|
|
if (empty($nic)) {
|
|
$nic = 0;
|
|
}
|
|
if (empty($niveau)) {
|
|
$niveau = 2;
|
|
}
|
|
if (empty($plus)) {
|
|
$plus = false;
|
|
}
|
|
if ( !in_array($niveau, array(0,1,2,3,4,5)) ) {
|
|
$niveau = 2;
|
|
}
|
|
$perm = false;
|
|
//@todo : Gestion des droits
|
|
/*switch($niveau){
|
|
case 1: $perms = array('indiscore', 'indiscorep'); break;
|
|
case 2: $perms = array('indiscore2', 'indiscore2p'); break;
|
|
case 3: $perms = array('indiscore3', 'indiscore3p'); break;
|
|
}
|
|
foreach($perms as $item){
|
|
if ( $this->checkPerm($item) ){
|
|
$perm = true;
|
|
break;
|
|
}
|
|
}
|
|
if ($perm === false) {
|
|
$this->sendError('0902');
|
|
}*/
|
|
|
|
$tabRet = array();
|
|
debugLog('I',"IndiScore demandée pour $siren en niveau $niveau",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
if (strlen($siren)>9 || (substr($siren,0,9)*1)<100 ){
|
|
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$tDeb = microtime(true);
|
|
require_once 'Metier/scores/classMScores.php';
|
|
$tabRet = calculIndiScore($siren, $nic, $accesDist, $niveau, false, 'valo');
|
|
$duree = round(microtime(true)-$tDeb,3);
|
|
debugLog('W', "indiscore DUREE = $duree s", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$output = new Indiscore();
|
|
foreach($tabRet as $key => $value){
|
|
if ($key=='paiements'){
|
|
$parMont = $value['parMont'];
|
|
$parTrim = $value['parTrim'];
|
|
$tabMont = array();
|
|
foreach($parMont as $parMontK => $parMontV){
|
|
$paiementMont = new IndiscorePaiementDetail();
|
|
$paiementMont->id = $parMontK;
|
|
$paiementMont->nb = $parMontV['nb'];
|
|
if (array_key_exists('d=180', $parMontV)){
|
|
$paiementMont->d180 = $parMontV['d=180'];
|
|
}
|
|
if (array_key_exists('d=150', $parMontV)){
|
|
$paiementMont->d150 = $parMontV['d=150'];
|
|
}
|
|
if (array_key_exists('d=120', $parMontV)){
|
|
$paiementMont->d120 = $parMontV['d=120'];
|
|
}
|
|
if (array_key_exists('d=90', $parMontV)){
|
|
$paiementMont->d90 = $parMontV['d=90'];
|
|
}
|
|
if (array_key_exists('d=60', $parMontV)){
|
|
$paiementMont->d60 = $parMontV['d=60'];
|
|
}
|
|
if (array_key_exists('d=30', $parMontV)){
|
|
$paiementMont->d30 = $parMontV['d=30'];
|
|
}
|
|
$tabMont[] = $paiementMont;
|
|
}
|
|
$tabTrim = array();
|
|
foreach($parTrim as $parTrimK => $parTrimV){
|
|
$paiementTrim = new IndiscorePaiementDetail();
|
|
$paiementTrim->id = $parTrimK;
|
|
$paiementTrim->nb = $parTrimV['nb'];
|
|
if (array_key_exists('d=180', $parTrimV)){
|
|
$paiementTrim->d180 = $parTrimV['d=180'];
|
|
}
|
|
if (array_key_exists('d=150', $parTrimV)){
|
|
$paiementTrim->d150 = $parTrimV['d=150'];
|
|
}
|
|
if (array_key_exists('d=120', $parTrimV)){
|
|
$paiementTrim->d120 = $parTrimV['d=120'];
|
|
}
|
|
if (array_key_exists('d=90', $parTrimV)){
|
|
$paiementTrim->d90 = $parTrimV['d=90'];
|
|
}
|
|
if (array_key_exists('d=60', $parTrimV)){
|
|
$paiementTrim->d60 = $parTrimV['d=60'];
|
|
}
|
|
if (array_key_exists('d=30', $parTrimV)){
|
|
$paiementTrim->d30 = $parTrimV['d=30'];
|
|
}
|
|
$tabTrim[] = $paiementTrim;
|
|
}
|
|
$paiement = new IndiscorePaiement();
|
|
$paiement->parMont = $tabMont;
|
|
$paiement->parTrim = $tabTrim;
|
|
$output->paiements = $paiement;
|
|
|
|
} elseif ($key=='Notes_Structure') {
|
|
|
|
$notesStructure = new IndiscoreNotesStructure();
|
|
$notesStructure->activite = $value['activite'];
|
|
$notesStructure->naf4 = $value['naf4'];
|
|
$notesStructure->age = $value['age'];
|
|
$notesStructure->capital = $value['capital'];
|
|
$notesStructure->effectif = $value['effectif'];
|
|
$notesStructure->fj = $value['fj'];
|
|
$notesStructure->localite = $value['localite'];
|
|
$notesStructure->singulier = $value['singulier'];
|
|
$output->Notes_Structure = $notesStructure;
|
|
|
|
} elseif ($key=='tabBilans') {
|
|
|
|
$tabRet = array();
|
|
foreach($value as $bilan)
|
|
{
|
|
$element = new ListeBilans();
|
|
$element->dateProvPartenaire = $bilan['dateProvPartenaire']; //@todo : date
|
|
$element->dateInsert = $bilan['dateInsert']; //@todo : date
|
|
$element->typeBilan = $bilan['typeBilan'];
|
|
$element->dureeExercice = $bilan['dureeExercice'];
|
|
$element->dateExercice = $bilan['dateExercice']; //@todo : date
|
|
$element->millesime = $bilan['millesime'];
|
|
$element->dateExercicePre = $bilan['dateExercicePre']; //@todo : date
|
|
$element->dureeExercicePre = $bilan['dureeExercicePre'];
|
|
$element->monnaie = $bilan['monnaie'];
|
|
$element->source = $bilan['source'];
|
|
$tabRet[] = $element;
|
|
}
|
|
$output->tabBilans = $tabRet;
|
|
|
|
} elseif ($key=='tabBilan') {
|
|
|
|
$tabRet = array();
|
|
foreach($value as $bilan){
|
|
$resultBilan = new Bilan();
|
|
$tabPoste = array();
|
|
foreach($bilan as $bilan_key => $bilan_value){
|
|
if(!in_array($bilan_key, array('SIREN', 'DATE_FRAICHE_BILAN',
|
|
'DATE_CLOTURE', 'DATE_CLOTURE_PRE', 'DUREE_MOIS',
|
|
'DUREE_MOIS_PRE', 'MONNAIE', 'CONSOLIDE', 'MONNAIE_ORI',
|
|
'MONNAIE_LIV_UNITE', 'SOURCE', 'devise'))){
|
|
$resultPoste = new BilanPoste();
|
|
$resultPoste->id = $bilan_key;
|
|
$resultPoste->val = $bilan_value;
|
|
$tabPoste[] = $resultPoste;
|
|
} else {
|
|
$resultBilan->$bilan_key = $bilan_value;
|
|
}
|
|
}
|
|
$resultBilan->POSTES = $tabPoste;
|
|
$tabRet[] = $resultBilan;
|
|
}
|
|
$output->tabBilan = $tabRet;
|
|
|
|
} elseif ($key=='tabInfosNotations') {
|
|
|
|
$infosNotation = new IndiscoreInfosNotations();
|
|
$infosNotation->SituationFinanciere = $value['SituationFinanciere'];
|
|
$infosNotation->Notation = $value['Notation'];
|
|
$infosNotation->ProbabiliteDefaut = $value['ProbabiliteDefaut'];
|
|
$output->tabInfosNotations = $infosNotation;
|
|
|
|
} elseif ($key=='tabImportExport') {
|
|
|
|
$tabRet = array();
|
|
foreach($value as $element){
|
|
$importExport = new IndiscoreImportExport();
|
|
$importExport->importExport = $element['importExport'];
|
|
$importExport->annee = $element['annee'];
|
|
$importExport->rangNational = $element['rangNational'];
|
|
$importExport->deptSiege = $element['deptSiege'];
|
|
$tabRet[] = $importExport;
|
|
}
|
|
$output->tabImportExport = $tabRet;
|
|
|
|
} elseif ($key=='tabCommentaires') {
|
|
|
|
$tab = array();
|
|
foreach($value as $comment) {
|
|
require_once 'i18n/cleanchar.php';
|
|
$tab[] = fixEncoding($comment);
|
|
}
|
|
$output->tabCommentaires = $tab;
|
|
|
|
} elseif ($key=='tabVariables') {
|
|
|
|
$tab = $value['CA_Y'];
|
|
$tabVar = array();
|
|
if (count($tab)>0) {
|
|
foreach($tab as $varName => $varVal){
|
|
$var = new CA_Y();
|
|
$var->id = $varName;
|
|
$var->val = $varVal;
|
|
$tabVar[] = $var;
|
|
}
|
|
}
|
|
$variables = new IndiscoreVariables();
|
|
$variables->CA_Y = $tabVar;
|
|
$output->tabVariables = $variables;
|
|
|
|
} elseif ($key=='Bilans') {
|
|
|
|
$tab = array();
|
|
foreach($value as $item)
|
|
{
|
|
$objet = new IndiscoreBilans();
|
|
$objet->Millesime = $item['Millesime'];
|
|
$objet->FraisPerso = $item['FraisPerso'];
|
|
$objet->CA = $item['CA'];
|
|
$objet->EBE = $item['EBE'];
|
|
$objet->TxInvest = $item['TxInvest'];
|
|
$objet->TxEndett = $item['TxEndett'];
|
|
$objet->DettesCT = $item['DettesCT'];
|
|
$objet->FraisFi = $item['FraisFi'];
|
|
$objet->BFR = $item['BFR'];
|
|
$objet->FR = $item['FR'];
|
|
$objet->FondsPr = $item['FondsPr'];
|
|
$objet->DelaiCli = $item['DelaiCli'];
|
|
$objet->DelaiFour = $item['DelaiFour'];
|
|
$tab[] = $objet;
|
|
}
|
|
$output->$key = $tab;
|
|
} else {
|
|
$output->$key = $value;
|
|
}
|
|
}
|
|
|
|
$this->wsLog('indiscore',$siren);
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Liste de tous les évènements enregistrés à l'INSEE pour une entreprise
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param string $nic
|
|
* @param integer $position
|
|
* @param integer $nbRep
|
|
* @return InseeReturn
|
|
**/
|
|
public function getListeEvenements($siren, $nic=0, $position=0, $nbRep=1000)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('eveninsee');
|
|
|
|
//Initialisation
|
|
if (empty($nic)) { $nic = 0; }
|
|
if (empty($position)) { $position = 0; }
|
|
if (empty($nbRep) || $nbRep>1000) { $nbRep = 1000; }
|
|
|
|
debugLog('I',"Liste des évènements pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$tabRet = array();
|
|
if (strlen($siren)<>9) {
|
|
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
//@todo : compter la liste des événéments pour pouvoir faire la pagination
|
|
|
|
$evens = $iInsee->getEvenements($siren, $nic, $position, $nbRep);
|
|
$tabRet = array();
|
|
if (count($evens)>0) {
|
|
foreach ($evens as $key => $row) {
|
|
$date[$key] = $row['dateMAJ'];
|
|
}
|
|
array_multisort($date, SORT_DESC, $evens);
|
|
foreach ($evens as $nb=>$even) {
|
|
$iEven = new InseeEven();
|
|
$iEven->Nic = $even['nic'];
|
|
$iEven->Siege = $even['siege'];
|
|
$iEven->SiretAss = $even['siretAssocie'];
|
|
$iEven->TypeSiretAss = $even['typeSiretAss'];
|
|
$iEven->EvenCode = $even['codeEven'];
|
|
$iEven->EvenLib = $even['libEven'];
|
|
$iEven->EvenLibDet = $even['libEvenDet'];
|
|
$iEven->EvenDate = $even['dateEven']; //@todo : date
|
|
$iEven->DateInfo = $even['dateMAJ']; //@todo : date
|
|
$tabRet[] = $iEven;
|
|
}
|
|
}
|
|
|
|
debugLog('I', 'Nb évènements retournés = '. count($tabRet), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('evenements',$siren);
|
|
$output = new InseeReturn();
|
|
$output->nbReponses = count($tabRet); // @todo : retrouver le nombre total d'évenements
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
|
|
/**
|
|
* Recherche
|
|
* @param EntrepriseCriteres $criteres
|
|
* @param integer $position Position de parcours des résultats retournées (0 par défaut)
|
|
* @param integer $nbRep Nombre de réponses retournées lors d'une requête (20 par défaut)
|
|
* @param integer $maxRep Nombre de réponses maximum pouvant être retournées lors d'une requête (200 par défaut)
|
|
* @param boolean $pertinence Recherche orthographique stricte sur le nom, l'adresse et la ville (false par défaut)
|
|
* @param boolean $avecSiren Seulement les entités sirénées (false par défaut)
|
|
* @return SearchEntrepriseReturn
|
|
*/
|
|
public function searchEntreprise($criteres, $position = 0, $nbRep = 20, $maxRep = 200, $pertinence = false, $avecSiren = false)
|
|
{
|
|
$this->authenticate();
|
|
|
|
if (empty($position)) { $position = 0;}
|
|
if (empty($nbRep)) { $nbRep = 20; }
|
|
if (empty($maxRep)) { $maxRep = 200; }
|
|
|
|
require_once 'i18n/cleanchar.php';
|
|
|
|
$entCriteres = new EntrepriseCriteres();
|
|
$entCriteres = $criteres;
|
|
$identifiant = $entCriteres->identifiant;
|
|
$typeId = '';
|
|
|
|
//Detection autour de l'identifiant
|
|
if ($identifiant!='') {
|
|
$len = strlen($identifiant);
|
|
//Numéro WALDEC
|
|
if (strtoupper(substr($identifiant,0,1))=='W') {
|
|
$typeId = 'W';
|
|
//Code ISIN
|
|
} elseif ($len==12){
|
|
$typeId = 'I';
|
|
//TVA Intracommunautaire
|
|
} elseif (in_array(substr($identifiant,0,2),
|
|
array('AT','BE','BG','CY','CZ','DE','DK','EE','EL','ES',
|
|
'FI','GB','HU','IE','IT','LT','LU','LV','MT','NL','PL',
|
|
'PT','RO','SE','SI','SK'))){
|
|
//"La recherche par numéro de TVA n'est pas encore possible sur ce pays !";
|
|
//Pour la france
|
|
} elseif (substr($identifiant,0,2)=='FR') {
|
|
$typeId = 'S';
|
|
if ($len==13) $identifiant = substr($identifiant,4,9);
|
|
else $identifiant = '';
|
|
//Numéro RC
|
|
} elseif (preg_match('/A|B|C|D/i', $identifiant)) {
|
|
$typeId = 'R';
|
|
//Siren normal on enleve tout ce qui n'est pas un chiffre
|
|
} else {
|
|
$typeId = 'S';
|
|
}
|
|
}
|
|
|
|
$adresse = trim($entCriteres->adresse);
|
|
|
|
//Détection Tel/Fax uniquement
|
|
if ( empty($typeId)
|
|
&& empty($entCriteres->raisonSociale)
|
|
&& empty($adresse)
|
|
&& empty($entCriteres->codePostal)
|
|
&& empty($entCriteres->ville)
|
|
&& empty($entCriteres->naf) ){
|
|
$typeId = 'TEL';
|
|
}
|
|
|
|
if (in_array($typeId, array('R', 'W', 'I'))){
|
|
|
|
$O = $this->searchAutreId(
|
|
$typeId,
|
|
$identifiant,
|
|
$entCriteres->codePostal,
|
|
$entCriteres->actif,
|
|
empty($position) ? 0 : $position,
|
|
empty($nbRep) ? 20 : $nbRep,
|
|
empty($maxRep) ? 200 : $maxRep
|
|
);
|
|
$output = new SearchEntrepriseReturn();
|
|
$output->nbReponses = $O->nbReponses;
|
|
$output->nbReponsesTotal = $O->nbReponsesTotal;
|
|
$output->result = $O->result;
|
|
return $output;
|
|
|
|
} elseif ($typeId == 'S'){
|
|
|
|
$O = $this->searchSiren(
|
|
$identifiant,
|
|
$entCriteres->codePostal,
|
|
$entCriteres->actif,
|
|
empty($position) ? 0 : $position,
|
|
empty($nbRep) ? 20 : $nbRep,
|
|
empty($maxRep) ? 200 : $maxRep
|
|
);
|
|
|
|
$output = new SearchEntrepriseReturn();
|
|
$output->nbReponses = $O->nbReponses;
|
|
$output->nbReponsesTotal = $O->nbReponsesTotal;
|
|
$output->result = $O->result;
|
|
$output->info = $O->info;
|
|
return $output;
|
|
|
|
} elseif ($typeId == 'TEL'){
|
|
|
|
$O = $this->searchTelFax(
|
|
$entCriteres->telFax,
|
|
$entCriteres->actif,
|
|
empty($position) ? 0 : $position,
|
|
empty($nbRep) ? 20 : $nbRep,
|
|
empty($maxRep) ? 200 : $maxRep
|
|
);
|
|
|
|
$output = new SearchEntrepriseReturn();
|
|
$output->nbReponses = $O->nbReponses;
|
|
$output->nbReponsesTotal = $O->nbReponsesTotal;
|
|
$output->result = $O->result;
|
|
return $output;
|
|
|
|
} else {
|
|
|
|
$O = $this->searchNomAdr(
|
|
cleanstring($entCriteres->raisonSociale),
|
|
cleanstring($entCriteres->adresse),
|
|
$entCriteres->codePostal,
|
|
cleanstring($entCriteres->ville),
|
|
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
|
$entCriteres->actif,
|
|
empty($position) ? 0 : $position,
|
|
empty($nbRep) ? 20 : $nbRep,
|
|
empty($maxRep) ? 200 : $maxRep,
|
|
empty($pertinence) ? false : $pertinence,
|
|
empty($avecSiren) ? false : $avecSiren,
|
|
$entCriteres->naf
|
|
);
|
|
|
|
$output = new SearchEntrepriseReturn();
|
|
$output->nbReponses = $O->nbReponses;
|
|
$output->nbReponsesTotal = $O->nbReponsesTotal;
|
|
$output->result = $O->result;
|
|
return $output;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Recherche d'entreprise par dirigeants
|
|
* @param DirigeantCriteres $criteres
|
|
* @param integer $deb Position du curseur dans la liste des réponses (0 par défaut)
|
|
* @param integer $nbRep Nombre de réponses retournées au maximum par cette requete (20 par défaut)
|
|
* @param integer $maxRep Nombre de réponses recherchées au maximum (200 par défaut)
|
|
* @return SearchDirReturn
|
|
*/
|
|
public function searchDir($criteres, $deb=0, $nbRep=20, $maxRep=200)
|
|
{
|
|
$this->authenticate();
|
|
|
|
$nom = $criteres->nom;
|
|
$prenom = $criteres->prenom;
|
|
$dateNaiss = $criteres->dateNaiss;
|
|
$lieuNaiss = $criteres->lieuNaiss;
|
|
$pertinence = $criteres->pertinence;
|
|
|
|
debugLog('I',"Recherche Dirigeant de $nom, $prenom, $dateNaiss, $lieuNaiss (Max Rep=$nbRep)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if (empty($prenom)) $prenom = '';
|
|
if (empty($dateNaiss)) $dateNaiss = '';
|
|
if (empty($lieuNaiss)) $lieuNaiss = '';
|
|
if (empty($pertinence)) $pertinence = false;
|
|
if (empty($deb)) $deb = 0;
|
|
if (empty($nbRep)) $nbRep = 20;
|
|
if (empty($maxRep)) $maxRep = 200;
|
|
|
|
$iInsee = new MInsee();
|
|
$etabs = $iInsee->rechercheDir($nom, $prenom, '', $dateNaiss, $lieuNaiss, $deb, $nbRep, $maxRep, $pertinence);
|
|
|
|
$tabRet = array();
|
|
foreach ($etabs['reponses'] as $etab) {
|
|
$item = new EntrepriseDirItem();
|
|
$item->id = $etab['id'];
|
|
$item->Pertinence = $etab['Pertinence'];
|
|
$item->Siret = $etab['Siret'];
|
|
$item->Siege = $etab['Siege'];
|
|
$item->Nom = prepareString(strtr($etab['Nom'],'/*',' '));
|
|
$item->Nom2 = prepareString($etab['Nom2']);
|
|
$item->Sigle = prepareString($etab['Sigle']);
|
|
$item->Enseigne = prepareString($etab['Enseigne']);
|
|
$item->Adresse = prepareString($etab['Adresse']);
|
|
$item->Adresse2 = prepareString($etab['Adresse2']);
|
|
$item->CP = $etab['CP'];
|
|
$item->Ville = prepareString($etab['Ville']);
|
|
$item->Tel = $etab['Tel'];
|
|
$item->Fax = $etab['Fax'];
|
|
$item->FJ = $etab['FJ'];
|
|
$item->FJLib = $iInsee->getLibelleFJ($etab['FJ']);
|
|
$item->Siren = $etab['Siren'];
|
|
$item->Nic = $etab['Nic'];
|
|
$item->Actif = $etab['Actif'];
|
|
$item->NafEtab = $etab['NafEtab']; // Etablissement
|
|
$item->NafEtabLib = prepareString($iInsee->getLibelleNaf($etab['NafEtab'])); // Etablissement
|
|
$item->NafEnt = $etab['NafEnt']; // Entreprise
|
|
$item->NafEntLib = prepareString($iInsee->getLibelleNaf($etab['NafEnt']));
|
|
|
|
// Dirigeant
|
|
$item->DirRs = prepareString($etab['DirRs']);
|
|
$item->DirNom = prepareString($etab['DirNom']);
|
|
$item->DirPrenom = prepareString($etab['DirPrenom']);
|
|
$item->DirNomUsage = prepareString($etab['DirNomUsage']);
|
|
$item->DirDateEffet = $etab['DirDateEffet'];
|
|
$item->DirFonction = prepareString($etab['DirFonction']);
|
|
$item->DirDepart = $etab['DirDepart'];
|
|
$tabRet[] = $item;
|
|
}
|
|
|
|
if ($etabs['nbReponses']==0){
|
|
debugLog('W', "Aucun résultat pour cette recherche !", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
}
|
|
|
|
$search = new SearchDirReturn();
|
|
$search->nbReponses = $etabs['nbReponses'];
|
|
$search->nbReponsesTotal = $etabs['nbReponsesTotal'];
|
|
$search->result = $tabRet;
|
|
return $search;
|
|
}
|
|
|
|
/**
|
|
* Recherche d'entreprise ou d'établissement par un autre Identifiant
|
|
*
|
|
* @param string $typeId I=Code Isin, W=N°Waldec (Associations) ou R=N°RC (Registre Greffe)
|
|
* @param string $identifiant Identifiant recherché
|
|
* @param integer $dep Département
|
|
* @param integer $actif 0 : Filtre sur les inactfis, 1: Filtre sur les actifs, 2 : Tous (defaut)
|
|
* @param integer $deb Position du curseur dans la liste des réponses (0 par défaut)
|
|
* @param integer $nbRep Nombre de réponses retournées au maximum par cette requete (20 par défaut)
|
|
* @param integer $maxRep Nombre de réponses recherchées au maximum (200 par défaut)
|
|
* @return SearchReturn
|
|
*/
|
|
public function searchAutreId($typeId, $identifiant, $dep=0, $actif=2, $deb=0, $nbRep=20, $maxRep=200)
|
|
{
|
|
$this->authenticate();
|
|
|
|
if (empty($deb)) $deb = 0;
|
|
if (empty($nbRep)) $nbRep = 0;
|
|
if (empty($maxRep)) $maxRep = 0;
|
|
if (empty($dep)) $dep = 0;
|
|
if (!in_array($actif, array(0,1,2))) $actif = 2;
|
|
|
|
$typeId = substr(trim(strtoupper($typeId)),0,1);
|
|
|
|
if ($typeId!='I' && $typeId!='W' && $typeId!='R') {
|
|
debugLog('I',"Type d'identifiant $typeId inexistant",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1021');
|
|
}
|
|
$tabRet = array();
|
|
debugLog('I',"Recherche par identifiant $typeId de $identifiantavec un maximum de $nbRep réponses",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
if ($typeId=='W' || $typeId=='R')
|
|
{
|
|
$iInsee = new MInsee();
|
|
$rep = $iInsee->getEtablissementsParId('AUTRE', $identifiant, $deb, $nbRep, $maxRep, $dep, $actif);
|
|
$etabs = $rep['reponses'];
|
|
foreach ($etabs as $nb=>$etab)
|
|
{
|
|
$item = new EntrepriseItem();
|
|
$item->id = $etab['id'];
|
|
$item->Pertinence = $etab['Pertinence'];
|
|
$item->Siret = $etab['Siret'];
|
|
$item->Siege = $etab['Siege'];
|
|
$item->Nom = prepareString(strtr($etab['Nom'],'/*',' '));
|
|
$item->Nom2 = prepareString($etab['Nom2']);
|
|
$item->Sigle = prepareString($etab['Sigle']);
|
|
$item->Enseigne = prepareString($etab['Enseigne']);
|
|
$item->Adresse = prepareString($etab['Adresse']);
|
|
$item->Adresse2 = prepareString($etab['Adresse2']);
|
|
$item->CP = $etab['CP'];
|
|
$item->Ville = prepareString($etab['Ville']);
|
|
$item->Tel = $etab['Tel'];
|
|
$item->Fax = $etab['Fax'];
|
|
$item->FJ = $etab['FJ'];
|
|
$item->FJLib = prepareString($etab['FJLib']);
|
|
$item->Siren = $etab['Siren'];
|
|
$item->Nic = $etab['Nic'];
|
|
$item->Actif = $etab['Actif'];
|
|
$item->NafEtab = $etab['NafEtab']; // Etablissement
|
|
$item->NafEtabLib = prepareString($etab['NafEtabLib']); // Etablissement
|
|
$item->NafEnt = $etab['NafEnt']; // Entreprise
|
|
$item->NafEntLib = prepareString($etab['NafEntLib']);
|
|
$tabRet[] = $item;
|
|
}
|
|
$output = new SearchReturn();
|
|
$output->nbReponses = $rep['nbReponses'];
|
|
$output->nbReponsesTotal = $rep['nbReponsesTotal'];
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
} else {
|
|
$iBourse = new MBourse($siren);
|
|
$siren = $iBourse->getCodeSiren($identifiant);
|
|
return $this->searchSiren($siren, $dep, $actif, $deb, $nbRep, $maxRep);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Recherche d'entreprise ou d'établissement par leur TEL FAX
|
|
*
|
|
* @param string $telFax Téléphone ou fax de l'établissement (ex: 0175438010)
|
|
* @param integer $actif 0 : Filtre sur les inactfis, 1: Filtre sur les actifs, 2 : Tous (defaut)
|
|
* @param integer $deb Position du curseur dans la liste des réponses (0 par défaut)
|
|
* @param integer $nbRep Nombre de réponses retournées au maximum par cette requete (20 par défaut)
|
|
* @param integer $maxRep Nombre de réponses recherchées au maximum (200 par défaut)
|
|
* @return SearchReturn
|
|
*/
|
|
public function searchTelFax($telFax, $actif=2, $deb=0, $nbRep=20, $maxRep=200)
|
|
{
|
|
$this->authenticate();
|
|
|
|
if (empty($deb)) $deb = 0;
|
|
if (empty($nbRep)) $nbRep = 0;
|
|
if (empty($maxRep)) $maxRep = 0;
|
|
if (!in_array($actif, array(0,1,2))) $actif = 2;
|
|
|
|
$tabRet = array();
|
|
debugLog('I',"Recherche par Tel/Fax de $telFax avec un maximum de $nbRep réponses",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
//$assocs=$this->iInsee->rechercheEtab($raisonSociale, $adresse, $codePostal, $ville, $siege, $nbRep, $pertinence);
|
|
/** @todo A FAIRE **/
|
|
if (strlen($telFax)<10 || strlen($telFax)>14) {
|
|
debugLog('W', "Tel/Fax $telFax incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1011');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
$rep = $iInsee->getEtablissementsParId('TEL', $telFax, $deb, $nbRep, $maxRep, 0, $actif);
|
|
$etabs = $rep['reponses'];
|
|
foreach ($etabs as $nb=>$etab)
|
|
{
|
|
$item = new EntrepriseItem();
|
|
$item->id = $etab['id'];
|
|
$item->Pertinence = $etab['Pertinence'];
|
|
$item->Siret = $etab['Siret'];
|
|
$item->Siege = $etab['Siege'];
|
|
$item->Nom = prepareString(strtr($etab['Nom'],'/*',' '));
|
|
$item->Nom2 = prepareString($etab['Nom2']);
|
|
$item->Sigle = prepareString($etab['Sigle']);
|
|
$item->Enseigne = prepareString($etab['Enseigne']);
|
|
$item->Adresse = prepareString($etab['Adresse']);
|
|
$item->Adresse2 = prepareString($etab['Adresse2']);
|
|
$item->CP = $etab['CP'];
|
|
$item->Ville = prepareString($etab['Ville']);
|
|
$item->Tel = $etab['Tel'];
|
|
$item->Fax = $etab['Fax'];
|
|
$item->FJ = $etab['FJ'];
|
|
$item->FJLib = prepareString($etab['FJLib']);
|
|
$item->Siren = $etab['Siren'];
|
|
$item->Nic = $etab['Nic'];
|
|
$item->Actif = $etab['Actif'];
|
|
$item->NafEtab = $etab['NafEtab']; // Etablissement
|
|
$item->NafEtabLib = prepareString($etab['NafEtabLib']); // Etablissement
|
|
$item->NafEnt = $etab['NafEnt']; // Entreprise
|
|
$item->NafEntLib = prepareString($etab['NafEntLib']);
|
|
$tabRet[] = $item;
|
|
}
|
|
|
|
$output = new SearchReturn();
|
|
$output->nbReponses = $rep['nbReponses'];
|
|
$output->nbReponsesTotal = $rep['nbReponsesTotal'];
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
|
|
/**
|
|
* Recherche entreprise par nom et adresse
|
|
* @param string $raisonSociale Raison Sociale ou Enseigne ou Sigle
|
|
* @param string $adresse Adresse de l'entreprise, du type : 3 rue des Plantes
|
|
* @param string $codePostal Code postal (ex: 75014)
|
|
* @param string $ville Ville
|
|
* @param boolean $siege Limitation de la recherche aux sièges (si true)
|
|
* @param integer $actif 0 : Filtre sur les inactfis, 1: Filtre sur les actifs, 2 : Tous (defaut)
|
|
* @param integer $deb Position du curseur dans la liste des réponses (0 par défaut)
|
|
* @param integer $nbRep Nombre de réponses retournées au maximum par cette requete (20 par défaut)
|
|
* @param integer $maxRep Nombre de réponses recherchées au maximum (200 par défaut)
|
|
* @param boolean $pertinence Recherche orthographique stricte sur le nom, l'adresse et la ville (si true)
|
|
* @param boolean $avecSiren Ne proposer que les entités sirénées
|
|
* @param string $ape_etab
|
|
* @return SearchReturn
|
|
*/
|
|
public function searchNomAdr($raisonSociale, $adresse='', $codePostal='', $ville='', $siege=false, $actif=2, $deb=0, $nbRep=20, $maxRep=200, $pertinence=false, $avecSiren=false, $ape_etab='')
|
|
{
|
|
$this->authenticate();
|
|
|
|
debugLog('I',"Recherche Entreprise de $raisonSociale, $adresse, $codePostal $ville (Siège=$siege / Max Rep=$nbRep)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if (empty($adresse)) $adresse = '';
|
|
if (empty($codePostal)) $codePostal = '';
|
|
if (empty($ville)) $ville = '';
|
|
if (empty($siege)) $siege = false;
|
|
if (!in_array($actif, array(0,1,2))) $actif = 2;
|
|
if (empty($deb)) $deb = 0;
|
|
if (empty($nbRep)) $nbRep = 20;
|
|
if (empty($maxRep)) $maxRep = 200;
|
|
if (empty($pertinence)) $pertinence = false;
|
|
if (empty($avecSiren)) $avecSiren = false;
|
|
if (empty($ape_etab)) $ape_etab = '';
|
|
|
|
$iInsee = new MInsee();
|
|
$etabs = $iInsee->rechercheEtab($raisonSociale, $adresse, $codePostal, $ville, $siege, $actif, $deb, $nbRep, $maxRep, $pertinence, $avecSiren, $ape_etab);
|
|
|
|
$result = new SearchReturn();
|
|
$tabRet = array();
|
|
if (count($etabs['reponses'])) {
|
|
foreach ($etabs['reponses'] as $etab) {
|
|
$reponse = new EntrepriseItem();
|
|
$reponse->id = $etab['id'];
|
|
$reponse->Pertinence = $etab['Pertinence'];
|
|
$reponse->Siret = $etab['Siret'];
|
|
$reponse->Siege = $etab['Siege'];
|
|
$reponse->Nom = strtr($etab['Nom'],'/*',' ');
|
|
$reponse->Nom2 = $etab['Nom2'];
|
|
$reponse->Sigle = $etab['Sigle'];
|
|
$reponse->Enseigne = $etab['Enseigne'];
|
|
$reponse->Adresse = $etab['Adresse'];
|
|
$reponse->Adresse2 = $etab['Adresse2'];
|
|
$reponse->CP = $etab['CP'];
|
|
$reponse->Ville = $etab['Ville'];
|
|
$reponse->Tel = $etab['Tel'];
|
|
$reponse->Fax = $etab['Fax'];
|
|
$reponse->FJ = $etab['FJ'];
|
|
$reponse->FJLib = $iInsee->getLibelleFJ($etab['FJ']);
|
|
$reponse->Siren = $etab['Siren'];
|
|
$reponse->Nic = $etab['Nic'];
|
|
$reponse->Actif = $etab['Actif'];
|
|
$reponse->NafEtab = $etab['NafEtab']; // Etablissement
|
|
$reponse->NafEtabLib = $iInsee->getLibelleNaf($etab['NafEtab']); // Etablissement
|
|
$reponse->NafEnt = $etab['NafEnt']; // Entreprise
|
|
$reponse->NafEntLib = $iInsee->getLibelleNaf($etab['NafEnt']);
|
|
|
|
$tabRet[] = $reponse;
|
|
}
|
|
}
|
|
|
|
$fp=fopen(LOG_PATH.'/recherches.log','a');
|
|
|
|
$siretTrouve = 0;
|
|
if ($etabs['nbReponses']==0) {
|
|
|
|
$str="NbRep=0, S=$raisonSociale, R=$adresse, L=$codePostal, V=$ville, A=$ape_etab, ($deb, $nbRep, $maxRep, $siege, $actif, $pertinence, $avecSiren), SiretTrouve=$siretTrouve";
|
|
fwrite($fp, $str.EOL);
|
|
fclose($fp);
|
|
debugLog('I', "rechercheEtab : AUCUN RESULTAT, S=$raisonSociale, R=$adresse, L=$codePostal, V=$ville, A=$ape_etab ($siege, $actif, $deb, $nbRep, $maxRep, $pertinence, $avecSiren)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$result->nbReponses = count($tabRet);
|
|
$result->nbReponsesTotal = $etabs['nbReponsesTotal'];
|
|
$result->result = $tabRet;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
if ($etabs['nbReponses']==1) $siretTrouve=$etabs['reponses'][0]['Siret'];
|
|
$str="NbRep=".$etabs['nbReponses'].", S=$raisonSociale, R=$adresse, L=$codePostal, V=$ville, A=$ape_etab, ($deb, $nbRep, $maxRep, $siege, $actif, $pertinence, $avecSiren), SiretTrouve=$siretTrouve";
|
|
fwrite($fp, $str.EOL);
|
|
fclose($fp);
|
|
debugLog('I', "rechercheEtab : ".$etabs['nbReponses']." RESULTATS, S=$raisonSociale, R=$adresse, L=$codePostal, V=$ville, A=$ape_etab ($siege, $actif, $deb, $nbRep, $maxRep, $pertinence, $avecSiren)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$result->nbReponses = $etabs['nbReponses'];
|
|
$result->nbReponsesTotal = $etabs['nbReponsesTotal'];
|
|
$result->result = $tabRet;
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Recherche d'entreprise ou d'établissement par leur identifiant SIREN ou SIRET
|
|
* @param string $siret Siren ou Siret de l'entreprise ou de l'établissement sur 9 ou 14 chiffres significatifs
|
|
* @param integer $dep Département
|
|
* @param integer $actif 0 : Filtre sur les inactfis, 1: Filtre sur les actifs, 2 : Tous (defaut)
|
|
* @param integer $deb Position du curseur dans la liste des réponses (0 par défaut)
|
|
* @param integer $nbRep Nombre de réponses retournées au maximum par cette requete (20 par défaut)
|
|
* @param integer $maxRep Nombre de réponses recherchées au maximum (200 par défaut)
|
|
* @return SearchReturn
|
|
*/
|
|
public function searchSiren($siret, $dep=0, $actif=2, $deb=0, $nbRep=20, $maxRep=200)
|
|
{
|
|
$this->authenticate();
|
|
|
|
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__);
|
|
|
|
if ( strlen($siret)!=14 && strlen($siret)!=9 ){
|
|
debugLog('W', "Siren/Siret $siret incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
if (empty($deb)) $deb = 0;
|
|
if (empty($nbRep)) $nbRep = 20;
|
|
if (empty($maxRep)) $maxRep = 200;
|
|
if (empty($dep)) $dep = 0;
|
|
|
|
if (!in_array($actif, array(0,1,2))) $actif = 2;
|
|
if ( $actif==2 ) $actif = -1;
|
|
|
|
$nbReponsesTotal = $nbReponses = 0;
|
|
|
|
$siren = substr($siret,0,9);
|
|
if (strlen($siret)==14) $nic = substr($siret,9,5);
|
|
elseif (strlen($siret)== 9) $nic = '';
|
|
|
|
$iInsee = new MInsee();
|
|
|
|
$rep = $iInsee->getEtablissements($siren, $nic, $deb, $nbRep, $maxRep, $dep, $actif);
|
|
if ( count($rep['reponses'])==0 && $dep>0 ) {
|
|
$rep = $iInsee->getEtablissements($siren, $nic, $deb, $nbRep, $maxRep, 0, $actif);
|
|
}
|
|
$etabs = $rep['reponses'];
|
|
$tabRet = array();
|
|
if (count($etabs)>0){
|
|
foreach ($etabs as $nb=>$etab) {
|
|
$reponse = new EntrepriseItem();
|
|
$reponse->id = $etab['id'];
|
|
$reponse->Pertinence = $etab['Pertinence'];
|
|
$reponse->Siret = $etab['Siret'];
|
|
$reponse->Siege = $etab['Siege'];
|
|
$reponse->Nom = prepareString(strtr($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']; // Etablissement
|
|
$reponse->NafEtabLib = $etab['NafEtabLib']; // Etablissement
|
|
$reponse->NafEnt = $etab['NafEnt']; // Entreprise
|
|
$reponse->NafEntLib = $etab['NafEntLib'];
|
|
$tabRet[] = $reponse;
|
|
}
|
|
}
|
|
$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;
|
|
}
|
|
}
|
|
|
|
$output = new SearchReturn();
|
|
$output->nbReponses = $nbReponses;
|
|
$output->nbReponsesTotal = $nbReponsesTotal;
|
|
$output->result = $tabRet;
|
|
$output->info = $rep['info'];
|
|
return $output;
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Retourne la fiche d'identité simplifié d'une entreprise avec son numéro de TVA.
|
|
*
|
|
* @param string $siren Identifiant Siren de l'entreprise
|
|
* @return TvaReturn
|
|
*/
|
|
public function getTVA($siren)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$siren = trim($siren);
|
|
debugLog('I',"TVA demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$tabRet = array();
|
|
if (strlen($siren)<>9) {
|
|
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
debugLog('I', "Avant getIdentiteEntreprise($siren)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$iInsee = new MInsee();
|
|
$entrep = $iInsee->getIdentiteEntreprise($siren);
|
|
debugLog('I', "Après getIdentiteEntreprise($siren)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
if (empty($entrep))
|
|
{
|
|
debugLog('W', "Siren $siren non présent en base", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1020');
|
|
}
|
|
|
|
debugLog('I', "Avant MTva($siren)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$iTva = new MTva($siren);
|
|
if ($iTva->vatDefined) $tva=$iTva->vatNumber;
|
|
else $tva='N/A';
|
|
debugLog('I', "Après MTva($siren)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$output = new TvaReturn();
|
|
$output->id = $entrep['id'];
|
|
$output->AutreId = $entrep['AutreId'];
|
|
$output->Nom = $entrep['Nom'];
|
|
$output->Sigle = $entrep['Sigle'];
|
|
$output->Enseigne = $entrep['Enseigne'];
|
|
$output->Adresse = $entrep['Adresse'];
|
|
$output->Adresse2 = $entrep['Adresse2'];
|
|
$output->CP = $entrep['CP'];
|
|
$output->Ville = $entrep['Ville'];
|
|
$output->Siren = $entrep['Siren'];
|
|
$output->Tva = $tva;
|
|
|
|
debugLog('I', "TVA retournée = $tva (".$entrep['Nom'].')', __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('tva',$siren);
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne tout ou patie des informations règlementées sur l'entreprise
|
|
*
|
|
* @param string $siren SIREN de l'entreprise
|
|
* @param mixed $id Id du communiqué
|
|
* @return InfosRegReturn
|
|
*/
|
|
public function getInfosReg( $siren, $id = false )
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('infosreg');
|
|
|
|
//Initialisation
|
|
if (empty($id)) $id = false;
|
|
$tabRet = array();
|
|
$siren = substr($siren,0,9);
|
|
|
|
debugLog('I',"Infos règlementées demandées pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
$iBourse = new MBourse($siren);
|
|
$anns = $iBourse->getInfosReg($siren, $id);
|
|
//debugLog('W', print_r($entrep, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
if ( empty($anns) ){
|
|
debugLog('W', "Aucune info règlementée pour le siren $siren", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1030');
|
|
}
|
|
|
|
foreach ($anns as $nb=>$ann)
|
|
{
|
|
//debugLog('I', "Siren/Siret $siren trouvé : ".$etab['Siren'].' '.$etab['Nic'].', '.$etab['Nom'] .', '.$etab['CP'].', '.$etab['Ville'], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
if ($id == false) {
|
|
$infos = new InfosReg();
|
|
$infos->id = $ann['id'];
|
|
$infos->source = $ann['source'];
|
|
$infos->DateParution = $ann['DateParution']; //@todo : date
|
|
$infos->raisonSociale = $ann['raisonSociale'];
|
|
$infos->titre = $ann['titre'];
|
|
$infos->pj = $ann['pj'];
|
|
$infos->url = $ann['url'];
|
|
$infos->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$tabRet[] = $infos;
|
|
} else {
|
|
$infos = new InfosReg();
|
|
$infos->id = $ann['id'];
|
|
$infos->source = $ann['source'];
|
|
$infos->DateParution = $ann['DateParution']; //@todo : date
|
|
$infos->raisonSociale = $ann['raisonSociale'];
|
|
$infos->titre = $ann['titre'];
|
|
$infos->communique = $ann['communique'];
|
|
$infos->communiqueHtml = $ann['communiqueHtml'];
|
|
$infos->pj = $ann['pj'];
|
|
$infos->url = $ann['url'];
|
|
$infos->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
|
$tabRet[] = $infos;
|
|
}
|
|
}
|
|
debugLog('I', 'Nb infos retournés = '. count($anns), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('infosreg',$siren,$id);
|
|
$output = new InfosRegReturn();
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne les informations boursières de l'entreprise
|
|
* @param string $siren SIREN de l'entreprise
|
|
* @return InfosBourse
|
|
*/
|
|
public function getInfosBourse($siren)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('bourse');
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
debugLog('I',"Infos bourse demandées pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$siren = substr($siren,0,9);
|
|
|
|
if ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iBourse = new MBourse($siren);
|
|
$bourse = $iBourse->getInfosBourse($siren);
|
|
//debugLog('W', print_r($entrep, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
if (empty($bourse)) {
|
|
debugLog('W', "Aucune info bourse pour le siren $siren", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1030');
|
|
}
|
|
|
|
$result = new InfosBourse();
|
|
$result->Siren = $bourse['siren'];
|
|
$result->RaisonSociale = $bourse['raisonSociale'];
|
|
$result->Adresse = $bourse['adresse'];
|
|
$result->Effectif = $bourse['effectif'];
|
|
$result->CodeSicovam = $bourse['code_sicovam'];
|
|
$result->CodeMnemo = $bourse['code_mnemo'];
|
|
$result->CodeBloomberg = $bourse['code_bloomberg'];
|
|
$result->CodeDatastream = $bourse['code_datastream'];
|
|
$result->Isin = $bourse['code_isin'];
|
|
$result->CodeRic = $bourse['code_ric'];
|
|
$result->DateIntroduction = $bourse['dateIntroduction']; //@todo : date
|
|
$result->DateDerAG = $bourse['dateDerAG']; //@todo : date
|
|
$result->DateRadiation = $bourse['dateRadiation']; //@todo : date
|
|
$result->AutreIsin = $bourse['autre_isin'];
|
|
$result->EligibleSRD = $bourse['eligibleSRD'];
|
|
$result->EligiblePEA = $bourse['eligiblePEA'];
|
|
$result->Tel = $bourse['tel1'];
|
|
$result->Tel2 = $bourse['tel2'];
|
|
$result->Fax = $bourse['fax1'];
|
|
$result->Fax2 = $bourse['fax2'];
|
|
$result->Web = $bourse['web'];
|
|
$result->Mail = $bourse['mail'];
|
|
|
|
$result->Marche = $bourse['marche'];
|
|
$result->Description = $bourse['description'];
|
|
$result->Secteur = $bourse['secteur'];
|
|
$result->Activite = $bourse['activite'];
|
|
$result->ActiviteDet = $bourse['activiteDet'];
|
|
|
|
$result->placeCotation = $bourse['placeCotation'];
|
|
$result->nombreTitres = $bourse['nombreTitres'];
|
|
$result->capitalisation = $bourse['close']*$bourse['nombreTitres'];
|
|
$result->derCoursDate = $bourse['date']; //@todo : date
|
|
$result->derCoursCloture = $bourse['close'];
|
|
$result->derCoursOuverture = $bourse['open'];
|
|
$result->derCoursPlusHaut = $bourse['high'];
|
|
$result->derCoursPlusBas = $bourse['low'];
|
|
|
|
$result->derCoursVolume = $bourse['volume'];
|
|
$result->coursMin = $bourse['coursMin'];
|
|
$result->coursMoy = $bourse['coursMoy'];
|
|
$result->coursMax = $bourse['coursMax'];
|
|
|
|
$this->wsLog('bourse',$siren,$id);
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Ajout d'une surveillance
|
|
*
|
|
* @param string $siret Siret/Siren
|
|
* @param string $email Adresse email du client
|
|
* @param string $ref Référence de la surveillance
|
|
* @param string $source Type de source en surveillance (insee, annonces, bilans, actes, privileges, score, dirigeants, paiements, liens)
|
|
* @param boolean $delete Suppression de la ligne
|
|
* @param integer $encoursClient Encours demandé par le client
|
|
* @return SetSurveillanceReturn
|
|
*/
|
|
public function setSurveillance($siret, $email, $ref='', $source='annonces', $delete=false, $encoursClient=0)
|
|
{
|
|
$this->authenticate();
|
|
$source = strtolower($source);
|
|
switch ($source) {
|
|
case 'insee':
|
|
$this->permission('survinsee');
|
|
break;
|
|
case 'bilans':
|
|
$this->permission('survbilan');
|
|
break;
|
|
case 'actes':
|
|
$this->permission('survactes');
|
|
break;
|
|
case 'privileges':
|
|
$this->permission('survpriv');
|
|
break;
|
|
case 'dirigeants':
|
|
$this->permission('survdirigeants');
|
|
break;
|
|
case 'score':
|
|
$this->permission('survscore');
|
|
break;
|
|
case 'paiements':
|
|
$this->permission('survpaiements');
|
|
break;
|
|
case 'liens':
|
|
$this->permission('survliens');
|
|
break;
|
|
case 'annonces':
|
|
default:
|
|
$this->permission('survannonce');
|
|
break;
|
|
}
|
|
|
|
//Initialisation
|
|
if (empty($ref)) $ref = '';
|
|
if (empty($delete)) $delete = false;
|
|
if (empty($encoursClient)) $encoursClient = false;
|
|
$result = false;
|
|
$siren = substr($siret,0,9);
|
|
$nic = substr($siret,9,5);
|
|
if (empty($nic)) {
|
|
$nic = '00000';
|
|
}
|
|
|
|
debugLog('I',"setSurveillances(siret=$siret, email=$email, ref=$ref, source=$source, delete=$delete)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$iDb = new WDB();
|
|
$login = $this->tabInfoUser['login'];
|
|
switch ($source) {
|
|
case 'insee':
|
|
case 'annonces':
|
|
case 'bilans':
|
|
case 'actes':
|
|
case 'privileges':
|
|
case 'paiements':
|
|
case 'liens':
|
|
case 'dirigeants': $encoursClient=0; break;
|
|
case 'score': $encoursClient=$encoursClient*1; break;
|
|
default: $source='annonces'; break;
|
|
}
|
|
|
|
if ($delete) {
|
|
|
|
$tabUpdate = array('dateSuppr'=>date('Y-m-d'));
|
|
$result = $iDb->update('surveillances_site',
|
|
$tabUpdate,
|
|
"source='$source' AND login='$login' AND email='$email' AND siren=$siren AND nic=$nic AND ref='$ref'"
|
|
);
|
|
|
|
} else {
|
|
|
|
$where = "source='$source' AND login='$login' AND email='$email' AND siren=$siren AND nic=$nic AND ref='$ref'";
|
|
|
|
//Si la donnée existe déjà alors il faut mettre à jour l'encours client
|
|
$detect = $iDb->select('surveillances_site', 'siren', $where, false, MYSQL_ASSOC);
|
|
if ( count($detect)>0 ) {
|
|
|
|
$data = array(
|
|
'encoursClient' => $encoursClient,
|
|
);
|
|
$result = $iDb->update('surveillances_site', $data, $where);
|
|
|
|
} else {
|
|
|
|
$iInsee = new MInsee();
|
|
$tabIdentite = $iInsee->getIdentiteLight($siren, $nic);
|
|
|
|
$data = array(
|
|
'source' => $source,
|
|
'login' => $login,
|
|
'email' => $email,
|
|
'siren' => $siren,
|
|
'nic' => $nic,
|
|
'ref' => $ref,
|
|
'encoursClient' => $encoursClient,
|
|
'rs' => $tabIdentite['Nom'],
|
|
'cp' => $tabIdentite['CP'],
|
|
'ville' => $tabIdentite['Ville'],
|
|
'dateAjout'=>date('Y-m-d'),
|
|
'dateSuppr'=>0,
|
|
);
|
|
$result = $iDb->insert('surveillances_site', $data);
|
|
}
|
|
}
|
|
$output = new SetSurveillanceReturn();
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* getSurveillances
|
|
* @param SurveillancesFiltre $filtre
|
|
* @param integer $deb
|
|
* @param integer $nbRep
|
|
* @return SurveillancesReturn
|
|
*/
|
|
public function getSurveillances($filtre, $position=0, $nbRep=100)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('survliste');
|
|
|
|
//Initialisation
|
|
if (empty($position)) $position = 0;
|
|
if (empty($nbRep)) $nbRep = 100;
|
|
|
|
$error = new ErrorType();
|
|
$tabRet = array();
|
|
$siren = 0;
|
|
$login = $this->tabInfoUser['login'];
|
|
|
|
$strSiren = "";
|
|
if (!empty($filtre->item) && $filtre->itemMode == 'siren'){
|
|
$siren = substr($filtre->item,0,9);
|
|
$nic = substr($filtre->item,9,5);
|
|
$strSiren = " AND siren='$siren'";
|
|
} elseif (!empty($filtre->item) && $filtre->itemMode == 'search') {
|
|
$strSiren = " AND ( siren='$filtre->item' OR ref='$filtre->item' OR rs='$filtre->item' )";
|
|
}
|
|
|
|
//Ordre pour le tri
|
|
$triMode = strtoupper(trim($filtre->triMode));
|
|
if ($triMode == 'DESC') {
|
|
$triMode = 'DESC';
|
|
} else {
|
|
$triMode = 'ASC';
|
|
}
|
|
|
|
//Option de tri
|
|
$tri = strtolower(trim($filtre->tri));
|
|
switch ($tri) {
|
|
case 'ref': $orderBy='ORDER BY ref'; break;
|
|
case 'dateAjout': $orderBy='ORDER BY dateAjout'; break;
|
|
case 'dateDerEnvoi': $orderBy='ORDER BY dateDerEnvoi'; break;
|
|
case 'rs': $orderBy='ORDER BY rs'; break;
|
|
case 'cp': $orderBy='ORDER BY cp'; break;
|
|
case 'ville': $orderBy='ORDER BY ville'; break;
|
|
default: $orderBy='ORDER BY siren'; break; // siren ou vide ou autre
|
|
}
|
|
$orderBy = $orderBy.' '.$triMode;
|
|
|
|
if ($filtre->detail) {
|
|
$strSelect = 'source, email, siren, nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi';
|
|
} else {
|
|
$strSelect = 'source, email, siren, nic, ref, dateAjout, dateDerEnvoi';
|
|
}
|
|
if ($filtre->source!='') $strSource = " AND source='$filtre->source' ";
|
|
else $strSource = '';
|
|
|
|
$iDb = new WDB();
|
|
|
|
if ($filtre->source!='') {
|
|
|
|
// Il faut compter le nombre de siren au total
|
|
$tabTmp = $iDb->select(
|
|
'surveillances_site',
|
|
'count(*) as nb', "login='$login' AND dateSuppr=0 $strSiren $strSource",
|
|
false, MYSQL_ASSOC
|
|
);
|
|
$nbRepTot = $tabTmp[0]['nb'];
|
|
|
|
// Récupération des résultats
|
|
$tabTmp = $iDb->select(
|
|
'surveillances_site', $strSelect,
|
|
"login='$login' AND dateSuppr=0 $strSiren $strSource $orderBy LIMIT $position,$nbRep",
|
|
false, MYSQL_ASSOC
|
|
);
|
|
|
|
} else {
|
|
|
|
// Il faut compter le nombre de siren au total
|
|
$tabTmp = $iDb->select(
|
|
'surveillances_site',
|
|
'siren', "login='$login' AND dateSuppr=0 $strSiren GROUP BY siren",
|
|
false, MYSQL_ASSOC
|
|
);
|
|
$nbRepTot = count($tabTmp);
|
|
|
|
// Récupération des résultats
|
|
if ($nbRepTot>0){
|
|
$tabTmp = $iDb->select(
|
|
'surveillances_site',
|
|
'siren', "login='$login' AND dateSuppr=0 $strSiren GROUP BY siren ORDER BY siren LIMIT $position,$nbRep",
|
|
false, MYSQL_ASSOC
|
|
);
|
|
$listeSiren = array();
|
|
foreach($tabTmp as $i => $v) {
|
|
$listeSiren[] = $v['siren'];
|
|
}
|
|
$tabTmp = $iDb->select(
|
|
'surveillances_site', $strSelect,
|
|
"login='$login' AND dateSuppr=0 AND siren IN (".join(',',$listeSiren).") $strSiren ORDER BY siren",
|
|
false, MYSQL_ASSOC
|
|
);
|
|
}
|
|
}
|
|
|
|
if (count($tabTmp)>0)
|
|
{
|
|
//Tri pour avoir le nombre de réponse correct suivant la structure
|
|
$listeRetour = array();
|
|
foreach ($tabTmp as $i => $tabSurv)
|
|
{
|
|
$rs = '';
|
|
$cp = '';
|
|
$ville = '';
|
|
if ($filtre->detail) {
|
|
if (trim($tabSurv['rs'])<>'') {
|
|
$rs = $tabSurv['rs'];
|
|
$cp = $tabSurv['cp'];
|
|
$ville = $tabSurv['ville'];
|
|
} else {
|
|
$iInsee = new MInsee();
|
|
$tabIdentite = $iInsee->getIdentiteLight($tabSurv['siren'], $tabSurv['nic']);
|
|
$rs = $tabIdentite['Nom'];
|
|
$cp = $tabIdentite['CP'];
|
|
$ville = $tabIdentite['Ville'];
|
|
$iDb->update('surveillances_site', array(
|
|
'rs' => $rs,
|
|
'cp' => $cp,
|
|
'ville' => $ville),
|
|
"login='$login' AND dateSuppr=0 AND siren=".$tabSurv['siren']." AND nic=".$tabSurv['nic']." $strSource",
|
|
false
|
|
);
|
|
}
|
|
}
|
|
|
|
$listeRetour[$tabSurv['siren']][] = array(
|
|
'rs' => $rs,
|
|
'cp' => $cp,
|
|
'ville' => $ville,
|
|
'source' => $tabSurv['source'],
|
|
'email' => $tabSurv['email'],
|
|
'nic' => $tabSurv['nic'],
|
|
'ref' => $tabSurv['ref'],
|
|
'dateAjout' => $tabSurv['dateAjout'],
|
|
'dateDerEnvoi' => $tabSurv['dateDerEnvoi'],
|
|
);
|
|
}
|
|
|
|
foreach ($listeRetour as $siren => $item)
|
|
{
|
|
$liste = new Surveillance();
|
|
$liste->siren = $siren;
|
|
foreach($item as $s) {
|
|
$source = new stdClass();
|
|
$source->rs = $s['rs'];
|
|
$source->cp = $s['cp'];
|
|
$source->ville = $s['ville'];
|
|
$source->source = $s['source'];
|
|
$source->email = $s['email'];
|
|
$source->nic = $s['nic'];
|
|
$source->ref = $s['ref'];
|
|
$source->encoursClient = $s['encoursClient'];
|
|
$source->dateAjout = $s['dateAjout']; //@todo : date
|
|
$source->dateDerEnvoi = $s['dateDerEnvoi']; //@todo : date
|
|
$liste->sources[] = $source;
|
|
}
|
|
$tabRet[] = $liste;
|
|
}
|
|
}
|
|
$output = new SurveillancesReturn();
|
|
$output->nbReponses = count($tabRet);
|
|
$output->nbReponsesTotal = $nbRepTot;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Recherche par référence client
|
|
* @param string $search
|
|
* @param integer $position
|
|
* @param integer $nbRep
|
|
* @return SearchRefClientReturn
|
|
*/
|
|
public function searchRefClient($search, $position=0, $nbRep=20)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
if (empty($position)) $position = 0;
|
|
if (empty($nbRep)) $nbRep = 20;
|
|
|
|
$iDb = new WDB();
|
|
$login = $this->tabInfoUser['login'];
|
|
$orderBy = " ORDER BY dateAjout ASC";
|
|
|
|
if ($this->tabInfoUser['rechRefType']=='CLI'){
|
|
//On cherche les logins actifs pour le client
|
|
$idClient = $this->tabInfoUser['idClient'];
|
|
|
|
$where = "u.idClient='$idClient' AND u.actif=1 AND s.dateSuppr=0 AND ( s.siren='$search' OR s.ref='$search' OR s.rs='$search' )";
|
|
// Il faut compter le nombre au total
|
|
$tabTmp = $iDb->select('surveillances_site s, utilisateurs u', 'count(*) as nb', $where.$orderBy, false, MYSQL_ASSOC);
|
|
$nbRepTot = $tabTmp[0]['nb'];
|
|
|
|
// Execution de la requete
|
|
$tabTmp = $iDb->select('surveillances_site s, utilisateurs u',
|
|
"siren, nic, ref, source, login, email, DATE_FORMAT(dateAjout, '%Y-%m-%d') as dateAjout, DATE_FORMAT(dateDerEnvoi, '%Y-%m-%d') as dateEnvoi",
|
|
$where.$orderBy." LIMIT $position,$nbRep", false, MYSQL_ASSOC);
|
|
} else {
|
|
$where = "login='$login' AND dateSuppr=0 AND ( siren='$search' OR ref='$search' OR rs='$search' )";
|
|
// Il faut compter le nombre au total
|
|
$tabTmp = $iDb->select('surveillances_site', 'count(*) as nb', $where.$orderBy, false, MYSQL_ASSOC);
|
|
$nbRepTot = $tabTmp[0]['nb'];
|
|
|
|
// Execution de la requete
|
|
$tabTmp = $iDb->select('surveillances_site',
|
|
"siren, nic, ref, source, login, email, DATE_FORMAT(dateAjout, '%Y-%m-%d') as dateAjout, DATE_FORMAT(dateDerEnvoi, '%Y-%m-%d') as dateEnvoi",
|
|
$where.$orderBy." LIMIT $position,$nbRep", false, MYSQL_ASSOC);
|
|
}
|
|
|
|
$tabRet = array();
|
|
if (count($tabTmp)>0)
|
|
{
|
|
foreach ($tabTmp as $i => $item)
|
|
{
|
|
$info = new SearchRefClientInfo();
|
|
$info->ref = $item['ref'];
|
|
$info->source = $item['source'];
|
|
$info->login = $item['login'];
|
|
$info->email = $item['email'];
|
|
$info->dateAjout = $item['dateAjout'];
|
|
$info->dateEnvoi = $item['dateEnvoi'];
|
|
|
|
$iInsee = new MInsee();
|
|
$tabIdentite = $iInsee->getIdentiteLight($item['siren'], $item['nic']);
|
|
|
|
$reponse = new SearchRefClient();
|
|
$reponse->id = $tabIdentite['id'];
|
|
$reponse->Siret = $tabIdentite['Siret'];
|
|
$reponse->Siege = $tabIdentite['Siege'];
|
|
$reponse->Nom = prepareString(strtr($tabIdentite['Nom'],'/*',' '));
|
|
$reponse->Nom2 = prepareString($tabIdentite['Nom2']);
|
|
$reponse->Sigle = prepareString($tabIdentite['Sigle']);
|
|
$reponse->Enseigne = prepareString($tabIdentite['Enseigne']);
|
|
$reponse->Adresse = prepareString($tabIdentite['Adresse']);
|
|
$reponse->Adresse2 = prepareString($tabIdentite['Adresse2']);
|
|
$reponse->CP = $tabIdentite['CP'];
|
|
$reponse->Ville = prepareString($tabIdentite['Ville']);
|
|
$reponse->Tel = $tabIdentite['Tel'];
|
|
$reponse->Fax = $tabIdentite['Fax'];
|
|
$reponse->FJ = $tabIdentite['FJ'];
|
|
$reponse->FJLib = prepareString($tabIdentite['FJ_lib']);
|
|
$reponse->Siren = $tabIdentite['Siren'];
|
|
$reponse->Nic = $tabIdentite['Nic'];
|
|
$reponse->Actif = $tabIdentite['Actif'];
|
|
$reponse->NafEtab = $tabIdentite['NafEtab'];
|
|
$reponse->NafEtabLib = $tabIdentite['NafEtabLib'];
|
|
$reponse->NafEnt = $tabIdentite['NafEnt'];
|
|
$reponse->NafEntLib = $tabIdentite['NafEntLib'];
|
|
$reponse->Infos = $info;
|
|
$tabRet[] = $reponse;
|
|
}
|
|
}
|
|
$output = new SearchRefClientReturn();
|
|
$output->nbReponses = count($tabRet);
|
|
$output->nbReponsesTotal = $nbRepTot;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne le bilan correspondant au siren, à l'exercice et au formalisme demandé
|
|
*
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param string $millesime Date du bilan au format AAAAMMJJ
|
|
* @param string $typeBilan N:Réel Normal, S:Réel Simplifié, C:Consolidé
|
|
* @param string $ref Référence S&D obligatoire
|
|
* @return Bilan
|
|
*/
|
|
public function getBilan($siren, $millesime, $typeBilan='N', $ref='')
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('liasse');
|
|
|
|
//Initialisation
|
|
if (empty($typeBilan)) { $typeBilan = 'N'; }
|
|
if (empty($ref)) { $ref = ''; }
|
|
|
|
debugLog('I',"Bilan $millesime $typeBilan demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$tabRet = array();
|
|
if (strlen($siren)<>9){
|
|
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$millesime = WDate::dateT('Ymd','d/m/Y',$millesime);
|
|
$mBil = new MBilans($siren);
|
|
$tabBilan = $mBil->getBilan($millesime, $typeBilan, $ref, true);
|
|
|
|
$resultBilan = new Bilan();
|
|
$tabPoste = array();
|
|
foreach($tabBilan as $key => $value){
|
|
if(!in_array($key, array('SIREN', 'DATE_FRAICHE_BILAN',
|
|
'DATE_CLOTURE', 'DATE_CLOTURE_PRE', 'DUREE_MOIS',
|
|
'DUREE_MOIS_PRE', 'MONNAIE', 'CONSOLIDE', 'MONNAIE_ORI',
|
|
'MONNAIE_LIV_UNITE', 'SOURCE', 'devise'))){
|
|
$resultPoste = new BilanPoste();
|
|
$resultPoste->id = $key;
|
|
$resultPoste->val = $value;
|
|
$tabPoste[] = $resultPoste;
|
|
} else {
|
|
$resultBilan->$key = $value;
|
|
}
|
|
}
|
|
$this->wsLog('bilan',$siren, $millesime.':'.$typeBilan.':'.$ref);
|
|
$resultBilan->POSTES = $tabPoste;
|
|
return $resultBilan;
|
|
}
|
|
|
|
/**
|
|
* Retourne la liste des bilans disponible pour une entreprise
|
|
*
|
|
* @param string $siren Siren de l'entreprise
|
|
* @return ListeBilansReturn
|
|
*/
|
|
public function getListeBilans($siren)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('liasse');
|
|
|
|
//Initialisation
|
|
$tabRet = array();
|
|
debugLog('I',"Liste des Bilans demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
if (strlen($siren)<>9) {
|
|
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$mBil = new MBilans($siren);
|
|
$tabBilans = $mBil->listeBilans(true);
|
|
foreach($tabBilans as $bilan)
|
|
{
|
|
$element = new ListeBilans();
|
|
$element->dateProvPartenaire = $bilan['dateProvPartenaire']; //@todo : date
|
|
$element->dateInsert = $bilan['dateInsert']; //@todo : date
|
|
$element->typeBilan = $bilan['typeBilan'];
|
|
$element->dureeExercice = $bilan['dureeExercice'];
|
|
$element->dateExercice = $bilan['dateExercice']; //@todo : date
|
|
$element->millesime = $bilan['millesime'];
|
|
$element->dateExercicePre = $bilan['dateExercicePre']; //@todo : date
|
|
$element->dureeExercicePre = $bilan['dureeExercicePre'];
|
|
$element->monnaie = $bilan['monnaie'];
|
|
$element->source = $bilan['source'];
|
|
$tabRet[] = $element;
|
|
}
|
|
|
|
debugLog('I', 'Nb Bilans retournés = '. count($tabBilans), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('listebilans', $siren);
|
|
$output = new ListeBilansReturn();
|
|
$output->nbReponses = count($tabRet);
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Vérifie si un siren existe en base Scores & Décisions
|
|
* @param string $siren Siren de l'entité
|
|
* @return boolean
|
|
*/
|
|
public function isSirenExistant($siren)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$tabRet = array();
|
|
$siren = trim(substr($siren,0,9));
|
|
$result = false;
|
|
debugLog('I',"Siren existant demandée pour siren $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$iInsee = new MInsee();
|
|
$entrep = $iInsee->sirenExiste($siren);
|
|
if (empty($entrep)) {
|
|
debugLog('W', "Siren $siren non présent en base", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$result = false;
|
|
} else {
|
|
debugLog('I', "Siren $siren présent en base", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$result = true;
|
|
}
|
|
$this->wsLog('sirenExiste',$siren);
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Retourne une annonce en fonction de sa référence
|
|
*
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param string $dateAnnee
|
|
* @param integer $numParution
|
|
* @param integer $numAnnonce
|
|
* @return RechercheAnnonceReturn
|
|
*/
|
|
public function rechercheAnnonce($source, $dateAnnee, $numParution, $numAnnonce)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('histobodacc');
|
|
|
|
//Initialisation
|
|
$tabRet = array();
|
|
|
|
debugLog('I',"Annonce précise demandée pour $source, $dateAnnee, $numParution, $numAnnonce",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if (strlen($dateAnnee)==4) $annee = $dateAnnee;
|
|
else $annee = substr($dateAnnee,0,4);
|
|
|
|
$iDb = new WDB('jo');
|
|
|
|
switch (strtoupper($source))
|
|
{
|
|
case 'BODA':
|
|
case 'BODB':
|
|
case 'BODC':
|
|
$lettre = substr(strtoupper($source),3,1);
|
|
if ($annee<2005) {
|
|
if ($lettre=='A'){ $numJAL=1; }
|
|
elseif ($lettre=='B'){ $numJAL=200; }
|
|
else{ break; }
|
|
$anneeDeb = $annee.'0101';
|
|
$anneeFin = $annee.'1231';
|
|
$res = $iDb->select('historiques.entrep e, texte t',
|
|
"$annee AS Annee_Parution, e.NOBOD AS Num_Parution, e.NOANN AS Num_Annonce, e.NOPAGE AS Num_Page, e.`DATE` AS Date_Parution, e.DEPT AS Departement, e.CODTRI AS Tribunal_Code, 'I' AS typeAnnonce, CONCAT(e.NOANN,' - ',t.annonceTxt) AS annonce",
|
|
"e.JAL=$numJAL AND e.NOBOD=$numParution AND e.`DATE` BETWEEN $anneeDeb AND $anneeFin AND e.NOANN=$numAnnonce AND e.ANBASE=t.annonceNum", false, MYSQL_ASSOC);
|
|
} else {
|
|
$res = $iDb->select('bodacc',
|
|
'Bodacc_Annee_Parution AS Annee_Parution, Bodacc_Num AS Num_Parution, Num_Annonce, Bodacc_Page AS Num_Page, Bodacc_Date_Parution AS Date_Parution, Tribunal_Dept AS Departement, Tribunal_Code, typeAnnonce, annonce',
|
|
"Bodacc_Code='$lettre' AND Bodacc_Annee_Parution=$annee AND Bodacc_Num=$numParution AND Num_Annonce=$numAnnonce", false, MYSQL_ASSOC);
|
|
}
|
|
break;
|
|
case 'ASSO':
|
|
$res = $iDb->select('asso',
|
|
'YEAR(Date_Parution) AS Annee_Parution, Num_Parution, Num_Annonce, pageDeb AS Num_Page, Date_Parution, Departement, codTribunal AS Tribunal_Code, typeAnnonce, Annonce_Html AS annonce', "Date_Parution BETWEEN '$annee-01-01' AND '$annee-12-31' AND Num_Parution=$annee".sprintf('%04d', $numParution)." AND Num_Annonce=$numAnnonce",
|
|
false, MYSQL_ASSOC);
|
|
break;
|
|
case 'BALO':
|
|
$res = $iDb->select('balo',
|
|
"YEAR(Date_Parution) AS Annee_Parution, Num_Parution, Num_Affaire AS Num_Annonce, '' AS Num_Page, Date_Parution, '' AS Departement, '' AS Tribunal_Code, 'Insertion' AS typeAnnonce, Annonce_Html AS annonce", "Date_Parution BETWEEN '$annee-01-01' AND '$annee-12-31' AND Num_Parution=$numParution AND Num_Affaire=$numAnnonce",
|
|
false, MYSQL_ASSOC);
|
|
break;
|
|
}
|
|
|
|
if (count($res)>0)
|
|
{
|
|
$iBodacc = new MBodacc();
|
|
foreach ($res as $i => $etab)
|
|
{
|
|
$annonces = new AnnonceItem();
|
|
$annonces->Annee_Parution = $etab['Annee_Parution'];
|
|
$annonces->Num_Parution = $etab['Num_Parution'];
|
|
$annonces->Num_Annonce = $etab['Num_Annonce'];
|
|
$annonces->Num_Page = $etab['Num_Page'];
|
|
$annonces->Date_Parution = $etab['Date_Parution']; //@todo : date
|
|
$annonces->Departement = $etab['Departement'];
|
|
$annonces->Tribunal_Code = $etab['Tribunal_Code'];
|
|
$annonces->Tribunal = $iBodacc->getTribunalNom($etab['Tribunal_Code']);
|
|
$annonces->Type_Annonce = $etab['typeAnnonce'];
|
|
$annonces->Annonce = strip_tags(strtr(
|
|
html_entity_decode($etab['annonce']),
|
|
array('>'=>'>','&'=>'&','<'=>'<','’'=>"'")
|
|
));
|
|
|
|
$tabRet[] = $annonces;
|
|
}
|
|
}
|
|
$nbTot = count($tabRet);
|
|
$output = new RechercheAnnonceReturn();
|
|
$output->criteres = $criteres;
|
|
$output->nbReponses = $nbTot;
|
|
$output->nbReponsesTotal = $nbTot;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* getRatios
|
|
* @param string $siren
|
|
* @param string $page
|
|
* @return RatiosReturn
|
|
*/
|
|
public function getRatios($siren, $page='ratios')
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('ratios');
|
|
|
|
global $tva, $tabFormules, $mBil, $tabBilan, $efftr, $tabInfla;
|
|
$tabFormules = include APPLICATION_PATH . '/../library/Metier/scores/Variables/CacheTabFormules.php';
|
|
require_once 'Metier/scores/Variables/configMRatios.php';
|
|
|
|
//Initialisation
|
|
if (empty($page)) $page = 'ratios';
|
|
$tabRatiosInfos = $tabRatiosSecteurs = $tabBilansR = array();
|
|
$tabRatios2 = $tabRatiosEvol = array();
|
|
$tabRet = array();
|
|
debugLog('I',"Liste des Ratios demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
if (strlen($siren)<>9){
|
|
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
} elseif ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
debugLog('I',"Liste des Ratios demandée pour $siren avant getIdentiteEntreprise",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$iInsee = new MInsee();
|
|
$tabIdentite = $iInsee->getIdentiteEntreprise($siren,0,0,false,false);
|
|
debugLog('I',"Liste des Ratios demandée pour $siren après getIdentiteEntreprise",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$naf = $tabIdentite['NafEnt'];
|
|
$nafLib = $tabIdentite['NafEntLib'];
|
|
$efftr = $tabIdentite['Effectif']*1;
|
|
$fj = $tabIdentite['FJ'];
|
|
|
|
$mBil = new MBilans($siren);
|
|
$tabBilans = $mBil->listeBilans(true);
|
|
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getRatios sur $siren", print_r($tabBilans, true));
|
|
$nbBilans = count($tabBilans);
|
|
$tabBilan = $tabBil = array();
|
|
if ($nbBilans>0){
|
|
$tabRatios = calculRatios($tabBilans, $tabIdentite, true);
|
|
}
|
|
$nbRatios = count($tabRatios);
|
|
debugLog('I',"Liste des Ratios demandée pour $siren après calculRatios ($nbRatios)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
/** Tableau d'infos sur les formules **/
|
|
$tabBorneMin = $tabBorneMax = array();
|
|
foreach ($tabFormules as $formule) {
|
|
$id = $formule['id']*1;
|
|
$libelle = $formule['libelle'];
|
|
$unite = $formule['unite'];
|
|
$commentaires = $formule['commentaires'];
|
|
$tabFormulesInfos[$id] = $formule; //Pour la gestion des unités des ratios secteur
|
|
$ratiosInfos = new RatiosInfos();
|
|
$ratiosInfos->id = 'r'.$id;
|
|
$ratiosInfos->libelle = $formule['libelle'];
|
|
$ratiosInfos->unite = $formule['unite'];
|
|
$ratiosInfos->commentaires = $formule['commentaires'];
|
|
$tabRatiosInfos[] = $ratiosInfos;
|
|
$tabBorneMin[$id] = $formule['borneMin'];
|
|
$tabBorneMax[$id] = $formule['borneMax'];
|
|
}
|
|
|
|
$tabAnnees = array();
|
|
foreach ($tabRatios as $i=>$R) {
|
|
|
|
//Informations sur le bilan
|
|
$bilansInfos = new RatiosBilansInfos();
|
|
$bilansInfos->dateCloture = $tabBilan[$i]['DATE_CLOTURE']; //@todo : date
|
|
$bilansInfos->duree = $tabBilan[$i]['DUREE_MOIS'];
|
|
$bilansInfos->devise = $tabBilan[$i]['MONNAIE'];
|
|
$bilansInfos->typeBilan = $tabBilan[$i]['CONSOLIDE'];
|
|
$bilansInfos->unite = 'U';
|
|
if ( substr($tabBilan[$i]['DATE_CLOTURE'],0,4)>1900 ){
|
|
$tabAnnees[$i]=substr($tabBilan[$i]['DATE_CLOTURE'],0,4);
|
|
}
|
|
|
|
$tabRatiosEntrep = array();
|
|
$tabRatiosEntrepEvol = array();
|
|
foreach ( $R as $Ridx=>$Rmont ){
|
|
|
|
if ($Rmont<>'NS') {
|
|
if ( $tabBorneMin[$Ridx]<>'' && $Rmont<$tabBorneMin[$Ridx] ){
|
|
$Rmont='<'.$tabBorneMin[$Ridx];
|
|
} elseif ( $tabBorneMax[$Ridx]<>'' && $Rmont>$tabBorneMax[$Ridx] ){
|
|
$Rmont='>'.$tabBorneMax[$Ridx];
|
|
}
|
|
}
|
|
|
|
// RatiosEntrep
|
|
$ratiosEntrep = new Ratios();
|
|
if (substr($Rmont,0,1)=='N' || substr($Rmont,0,1)=='<' || substr($Rmont,0,1)=='>'){
|
|
$ratiosEntrep->id = 'r'.$Ridx;
|
|
$ratiosEntrep->val = $Rmont;
|
|
} else {
|
|
$ratiosEntrep->id = 'r'.$Ridx;
|
|
$ratiosEntrep->val = round($Rmont,2);
|
|
}
|
|
$tabRatiosEntrep[] = $ratiosEntrep;
|
|
|
|
if (($tabBilan[$i]['CONSOLIDE']=='S' && isset($tabRatios[$i+1])&&($tabBilan[$i+1]['CONSOLIDE']=='S'||($tabBilan[$i+1]['CONSOLIDE']=='N'&&$tabBilan[$i+1]['DATE_CLOTURE']<>$tabBilan[$i]['DATE_CLOTURE']))) ||
|
|
($tabBilan[$i]['CONSOLIDE']=='N'&&isset($tabRatios[$i+1])&&($tabBilan[$i+1]['CONSOLIDE']=='N'||($tabBilan[$i+1]['CONSOLIDE']=='S'&&$tabBilan[$i+1]['DATE_CLOTURE']<>$tabBilan[$i]['DATE_CLOTURE'])))
|
|
)
|
|
$Rmont=(($R[$Ridx]-$tabRatios[$i+1][$Ridx])*100)/abs($tabRatios[$i+1][$Ridx]);
|
|
elseif ( ($tabBilan[$i]['CONSOLIDE']=='S'&&isset($tabRatios[$i+1])&&($tabBilan[$i+2]['CONSOLIDE']=='S'||($tabBilan[$i+2]['CONSOLIDE']=='N'&&$tabBilan[$i+2]['DATE_CLOTURE']<>$tabBilan[$i]['DATE_CLOTURE'])))
|
|
|| ($tabBilan[$i]['CONSOLIDE']=='N'&&isset($tabRatios[$i+1])&&($tabBilan[$i+2]['CONSOLIDE']=='N'||($tabBilan[$i+2]['CONSOLIDE']=='S'&&$tabBilan[$i+2]['DATE_CLOTURE']<>$tabBilan[$i]['DATE_CLOTURE'])))
|
|
)
|
|
$Rmont=(($R[$Ridx]-$tabRatios[$i+2][$Ridx])*100)/abs($tabRatios[$i+2][$Ridx]);
|
|
else
|
|
$Rmont='NS';
|
|
|
|
// RatiosEntrepEvol
|
|
$ratiosEntrepEvol = new Ratios();
|
|
if ($Rmont=='NS' || $Rmont<-800 || $Rmont>800){
|
|
$ratiosEntrepEvol->id = 'r'.$Ridx;
|
|
$ratiosEntrepEvol->val = 'NS';
|
|
} else {
|
|
$ratiosEntrepEvol->id = 'r'.$Ridx;
|
|
$ratiosEntrepEvol->val = number_format($Rmont,2,',',' ');
|
|
}
|
|
$tabRatiosEntrepEvol[] = $ratiosEntrepEvol;
|
|
}
|
|
$bilansInfos->RatiosEntrep = $tabRatiosEntrep;
|
|
$bilansInfos->RatiosEntrepEvol = $tabRatiosEntrepEvol;
|
|
$tabBilansR[] = $bilansInfos;
|
|
}
|
|
|
|
debugLog('I',"Liste des Ratios demandée pour $siren après EVOLUTION",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
// Tableau des ratios secteurs
|
|
|
|
if (strlen($naf)>4) $strNaf = " AND naf5='$naf' ";
|
|
else $strNaf = " AND naf4='$naf' ";
|
|
$strAnnees = implode(',', $tabAnnees);
|
|
|
|
$tabRatiosSecteurs = array();
|
|
|
|
$tabAnnees = array_unique($tabAnnees);
|
|
|
|
if ( count($tabAnnees)>0 )
|
|
{
|
|
$iDb = new WDB('jo');
|
|
$tabTmp = $iDb->select('ratios_secteurs',
|
|
'annee, naf5, naf4, id, (montant/nombre) AS ratio, nombre',
|
|
"1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC",
|
|
false, MYSQL_ASSOC);
|
|
|
|
$nbRatiosSec = 0;
|
|
foreach($tabAnnees as $annee)
|
|
{
|
|
$ratiosSecteur = new RatiosSecteur();
|
|
$ratiosSecteur->annee = $annee;
|
|
foreach ($tabTmp as $tmp)
|
|
{
|
|
if ($tmp['annee']== $annee)
|
|
{
|
|
$Ridx = $tmp['id'];
|
|
if ($tmp['nombre']>$nbRatiosSec){
|
|
$nbRatiosSec = $tmp['nombre'];
|
|
}
|
|
|
|
$unite = $tabFormulesInfos[$Ridx]['unite'];
|
|
if ($unite=='EUR'){
|
|
$montant = round($tmp['ratio']*1000);
|
|
} else {
|
|
$montant = round($tmp['ratio']);
|
|
}
|
|
if ($tabBorneMin[$Ridx]<>'' && $montant<$tabBorneMin[$Ridx]){
|
|
$montant='<'.$tabBorneMin[$Ridx];
|
|
} elseif ($tabBorneMax[$Ridx]<>'' && $montant>$tabBorneMax[$Ridx]){
|
|
$montant='>'.$tabBorneMax[$Ridx];
|
|
}
|
|
|
|
$ratiosSecteurListe = new Ratios();
|
|
if (substr($montant,0,1)=='N' || substr($montant,0,1)=='<' || substr($montant,0,1)=='>'){
|
|
$ratiosSecteurListe->id = 'r'.$Ridx;
|
|
$ratiosSecteurListe->val = $montant;
|
|
} else {
|
|
$ratiosSecteurListe->id = 'r'.$Ridx;
|
|
$ratiosSecteurListe->val = round($montant,2);
|
|
}
|
|
$ratiosSecteur->liste[] = $ratiosSecteurListe;
|
|
}
|
|
}
|
|
$tabRatiosSecteurs[] = $ratiosSecteur;
|
|
}
|
|
}
|
|
|
|
//$tabRatiosSecteurs=array(count($tabTmp), "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC");
|
|
|
|
$output = new RatiosReturn();
|
|
$output->Nom = $tabIdentite['Nom'];
|
|
$output->NafEnt = $tabIdentite['NafEnt'];
|
|
$output->NafEntLib = $tabIdentite['NafEntLib'];
|
|
$output->FJ = $fj;
|
|
$output->FJ_lib = $tabIdentite['FJ_lib'];
|
|
$output->Siren = $siren;
|
|
$output->NbEntNaf = $nbRatiosSec;
|
|
$output->BilansInfos = $tabBilansR;
|
|
$output->RatiosInfos = $tabRatiosInfos;
|
|
$output->RatiosSecteur = $tabRatiosSecteurs;
|
|
|
|
debugLog('I',"Liste des Ratios demandée pour $siren RETURN",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog($page, $siren);
|
|
return $output;
|
|
|
|
}
|
|
|
|
/**
|
|
* getRapport
|
|
* @param string $siren Siren de l'entreprise
|
|
* @param integer $niveau Niveau du rapport 1, 2 ou 3
|
|
* @param integer $id Identifiant interne S&D de l'entreprise
|
|
* @param boolean $plus Si true, mise en surveillance privilèges
|
|
* @param string $ref Si $plus=true, référence facultative de la mise en Surveillance
|
|
* @param integer $encours Si $plus=true, encours facultatif Demandé par le client lors de la mise en Surveillance
|
|
* @param string $email Si $plus=true, email facultatif pour le suivi
|
|
* @return Rapport
|
|
*/
|
|
public function getRapport($siren, $niveau=3, $id=0, $plus=false, $ref='', $encours=0, $email='')
|
|
{
|
|
$this->authenticate();
|
|
if (empty($niveau)) $niveau = 3;
|
|
if (empty($id)) $id = 0;
|
|
$result = new Rapport();
|
|
$filtre = 0;
|
|
$idAnn = 0;
|
|
|
|
//@todo : Gestion des droits
|
|
$perm = false;
|
|
switch($niveau){
|
|
case 1: $perms = array('indiscore', 'indiscorep'); break;
|
|
case 2: $perms = array('indiscore2', 'indiscore2p'); break;
|
|
case 3: $perms = array('indiscore3', 'indiscore3p'); break;
|
|
}
|
|
foreach($perms as $item){
|
|
if ( $this->checkPerm($item) ){
|
|
$perm = true;
|
|
break;
|
|
}
|
|
}
|
|
if ($perm === false) {
|
|
$this->sendError('0902');
|
|
}
|
|
|
|
$accesDist=true;
|
|
$nivComment=2;
|
|
if ($niveau==1){
|
|
$result->Indiscore = $this->getIndiScore($siren, 0, $nivComment, $plus, $ref, $encours, $email);
|
|
} elseif ($niveau==2) {
|
|
$result->Identite = $this->getIdentite($siren, $id=0);
|
|
$result->Indiscore = $this->getIndiScore($siren, 0, $nivComment, $plus, $ref, $encours, $email);
|
|
$result->Dirigeants = $this->getDirigeants($siren, false);
|
|
$result->Liens = $this->getLiens($siren, true);
|
|
$result->Ratios = $this->getRatios($siren, $page="rapport$niveau");
|
|
} elseif ($niveau==3) {
|
|
$result->Identite = $this->getIdentite($siren, $id=0);
|
|
$result->Indiscore = $this->getIndiScore($siren, 0, $nivComment, $plus, $ref, $encours, $email);
|
|
$result->Dirigeants = $this->getDirigeants($siren, false);
|
|
$result->Liens = $this->getLiens($siren, true);
|
|
$result->Ratios = $this->getRatios($siren, $page="rapport$niveau");
|
|
$result->Annonces = $this->getAnnonces($siren, $filtre, $idAnn);
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Retourne la liste des banques connues pour une entreprise
|
|
* @param string $siren Siren de l'entreprise
|
|
* @return BanquesReturn
|
|
**/
|
|
public function getBanques($siren)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
$iDb = new WDB('sdv1');
|
|
$tabRet = array();
|
|
debugLog('I',"Liste des banques demandée pour siren $siren",
|
|
__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if (intval($siren)<=1000) {
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$res=$iDb->select('banques', 'codeBanque, codeGuichet, libBanqueGuichet, precis, dateSource*1 AS dateSource', "siren=$siren", false, MYSQL_ASSOC);
|
|
$tmp=$iDb->select('fedRib', "codeBanque, codeGuichet, CONCAT(libBanque,' ',libGuichet) AS libBanqueGuichet, 0 AS precis, IF (dateInfo='0000-00-00', dateDispo*1, dateInfo*1) AS dateSource", "siren=$siren", false, MYSQL_ASSOC);
|
|
$res=array_merge($res, $tmp);
|
|
foreach ($res as $tabBanque){
|
|
$dateSource=$tabBanque['dateSource'];
|
|
$codBanque=$tabBanque['codeBanque'];
|
|
$codGuichet=$tabBanque['codeGuichet'];
|
|
$libBanque=trim($tabBanque['libBanqueGuichet']);
|
|
$found=false;
|
|
$adrBanque1=$adrBanque2=$adrBanqueCP=$adrBanqueVille='';
|
|
|
|
if ($codBanque>0 && $codGuichet>0 &&
|
|
$dateSource>(date('Y')-4)*10000+101 &&
|
|
$dateSource<date('Ymd')){
|
|
$tmp = $iDb->select('insee.BDF_Etabs b, insee.BDF_Guichets g',
|
|
'g.bdfFibCodeEtab AS banque, g.bdfFibCodeGuichet AS guichet, b.bdfFibDenom40 AS nomBanque, b.bdfFibDenom10 AS sigleBanque, g.bdfFibDenom20 AS nomGuichet, g.bdfFibAdresse1 AS adresse1, g.bdfFibAdresse2 AS adresse2, g.bdfFibAdresse3 AS adresse3, g.CP, g.Ville', "g.bdfFibCodeEtab=$codBanque AND g.bdfFibCodeGuichet=$codGuichet AND b.bdfFibCodeEtab=g.bdfFibCodeEtab",
|
|
false, MYSQL_ASSOC);
|
|
if (isset($tmp[0])){
|
|
$libBanque=trim($tmp[0]['nomBanque'].' '.$tmp[0]['nomGuichet']);
|
|
$adrBanque1=$tmp[0]['adresse1'];
|
|
$adrBanque2=trim($tmp[0]['adresse2'].' '.$tmp[0]['adresse3']);
|
|
$adrBanqueCP=$tmp[0]['CP'];
|
|
$adrBanqueVille=$tmp[0]['Ville'];
|
|
$found=true;
|
|
};
|
|
}
|
|
if (!$found && $codBanque>0 &&
|
|
$dateSource>(date('Y')-4)*10000+101 &&
|
|
$dateSource<date('Ymd')){
|
|
$tmp = $iDb->select('insee.BDF_Etabs', "bdfFibCodeEtab AS banque, '' AS guichet, bdfFibDenom40 AS nomBanque, '' AS nomGuichet, '' AS adresse1, '' AS adresse2, '' AS adresse3, '' AS CP, '' AS Ville", "bdfFibCodeEtab=$codBanque", false, MYSQL_ASSOC);
|
|
if (isset($tmp[0])){
|
|
$libBanque=trim($tmp[0]['nomBanque'].' '.$tmp[0]['nomGuichet']);
|
|
$adrBanque1=$tmp[0]['adresse1'];
|
|
$adrBanque2=trim($tmp[0]['adresse2'].' '.$tmp[0]['adresse3']);
|
|
$adrBanqueCP=$tmp[0]['CP'];
|
|
$adrBanqueVille=$tmp[0]['Ville'];
|
|
} else continue;
|
|
} else continue;
|
|
|
|
$banque = new Banque();
|
|
$banque->codeBanque = $codBanque;
|
|
$banque->codeGuichet = $codGuichet;
|
|
$banque->libBanque = $libBanque;
|
|
$banque->adresse1 = $adrBanque1;
|
|
$banque->adresse2 = $adrBanque2;
|
|
$banque->cp = $adrBanqueCP;
|
|
$banque->ville = $adrBanqueVille;
|
|
$tabRet[] = $banque;
|
|
}
|
|
debugLog('I',"Liste des banques pour siren $siren : ".count($tabRet).' banques',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$this->wsLog('banque', $siren);
|
|
$output = new BanquesReturn();
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne la liste des compétences territoriales pour un établissement à une adresse donnée.
|
|
* @param string $siret Siret de l'établissement
|
|
* @param string $type Type de compétence (pre:prefectures et s/prefectures, jal;journaux d'annonces légales, tri:tribunaux, adm:administrateurs et mandataires judiciaires, hui:huissiers, cfe:centres de formalités des entreprises)
|
|
* @param string $codeInsee Code Insee de la commune de l'établissement
|
|
* @return ListeCompetencesReturn
|
|
*/
|
|
public function getListeCompetences($siret, $type, $codeInsee)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('competences');
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
$type = strtolower($type);
|
|
|
|
debugLog('I',"Liste des compétences $type demandée pour la commune $codeInsee",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$tabRet = array();
|
|
$iBodacc = new MBodacc();
|
|
$cp=$codeInsee*1;
|
|
$dep=false;
|
|
if (substr($codeInsee,0,2)=='2A' || substr($codeInsee,0,2)=='2B')
|
|
{
|
|
$dep=20; $cp=20000+(substr($codeInsee,2,3))*1;
|
|
}
|
|
elseif ($cp>0 && $cp<100) $dep=$cp;
|
|
elseif ($cp>970 && $cp<977) $dep=$cp;
|
|
elseif ($cp>999 && $cp<10000) $dep='0'.substr($cp,0,1);
|
|
elseif ($cp>=10000 && $cp<96000) $dep=substr($cp,0,2);
|
|
elseif ($cp>=99000) $dep=substr($cp,0,2);
|
|
elseif ($cp>=98000) $dep=substr($cp,0,3);
|
|
elseif ($cp>=97100 && $cp<97700) $dep=substr($cp,0,3);
|
|
|
|
require_once 'i18n/cleanchar.php';
|
|
|
|
if ($type=='pre'){
|
|
|
|
$iDb = new WDB('jo');
|
|
$tabTmp2 = $iDb->select('villes', 'DEP, COM, AR, CT', 'codeInsee='.$codeInsee, false, MYSQL_ASSOC);
|
|
$arrond = $tabTmp2[0]['AR'];
|
|
unset($iDb);
|
|
$iDb = new WDB('insee');
|
|
$tabTmp2 = $iDb->select('insee_tabArrond', 'CHEFLIEU, ARTMAJ, NCC', "DEP='$dep' AND AR='$arrond'", false, MYSQL_ASSOC);
|
|
$nomSousPref = trim(strtr($tabTmp2[0]['ARTMAJ'],array('('=>'',')'=>'',' '=>'', "'"=>'')).' '.$tabTmp2[0]['NCC']);
|
|
unset($iDb);
|
|
$tabTmp = $iBodacc->getTribunauxParDep($dep);
|
|
foreach ($tabTmp as $i=>$tribunal)
|
|
{
|
|
if ($tribunal['triType']=='A' || $tribunal['triType']=='B')
|
|
{
|
|
$pref = levenshtein($tribunal['triNom'], 'PREFECTURE DE '.$nomSousPref);
|
|
$spref = levenshtein($tribunal['triNom'], 'SOUS PREFECTURE DE '.$nomSousPref);
|
|
|
|
if ($tribunal['triType']=='B' && ($pref>7 || $spref>5)) continue;
|
|
|
|
$competence = new Competence();
|
|
$competence->Id = $tribunal['triId'];
|
|
$competence->IdSup = $tribunal['triIdSup'];
|
|
$competence->Code = $tribunal['triCode'];
|
|
$competence->Type = $tribunal['triType'].$typeP;
|
|
$competence->Nom = strtoupper($tribunal['triNom']);
|
|
$competence->Siret = $tribunal['triSiret'];
|
|
$competence->Adr = strtoupper(
|
|
preg_replace('/ +/',' ',$tribunal['triAdrNum'].' '.
|
|
$tribunal['triAdrIndRep'].' '.
|
|
$tribunal['triAdrTypeVoie'].' '.
|
|
$tribunal['triAdrVoie']));
|
|
$competence->AdrComp = strtoupper($tribunal['triAdrComp']);
|
|
$competence->CP = $tribunal['triCP'];
|
|
$competence->Ville = strtoupper($tribunal['triVille']);
|
|
$competence->CodeInsee = $tribunal['CodeInsee'];
|
|
$competence->Tel = $tribunal['triTel'];
|
|
$competence->Fax = $tribunal['triFax'];
|
|
$competence->Web = $tribunal['triWeb'];
|
|
$competence->Mail = $tribunal['triMail'];
|
|
$competence->Statut = $tribunal['triStatut'];
|
|
$competence->DateCessation = $tribunal['triDateCessation']; //@todo : date
|
|
$competence->Remarque = $tribunal['triCommentaire'];
|
|
$tabRet[] = $competence;
|
|
|
|
}
|
|
}
|
|
|
|
} elseif ($type=='jal') {
|
|
|
|
$tabTmp = $iBodacc->getJALparDep($dep);
|
|
foreach ($tabTmp as $i=>$comp)
|
|
{
|
|
$infos='';
|
|
if (trim($comp['parution'])<>'') $infos.='Parution '.$comp['parution'].'. ';
|
|
if (trim($comp['aboAnnuel'])>0) $infos.='Abonnement Annuel : '.$comp['aboAnnuel'].' euros. ';
|
|
if (trim($comp['infos'])<>'') $infos.=$comp['infos'];
|
|
|
|
$competence = new Competence();
|
|
$competence->Id = 9000+$comp['id']*1;
|
|
$competence->IdSup = 0;
|
|
$competence->Code = '';
|
|
$competence->Type = '';
|
|
$competence->Nom = strtoupper($comp['nomJal']);
|
|
$competence->Siret = '';
|
|
$competence->Adr = strtoupper($comp['adresse']);
|
|
$competence->AdrComp = '';
|
|
$competence->CP = $comp['cp'];
|
|
$competence->Ville = strtoupper($comp['ville']);
|
|
$competence->CodeInsee = '';
|
|
$competence->Tel = $comp['tel'];
|
|
$competence->Fax = $comp['fax'];
|
|
$competence->Web = $comp['siteWeb'];
|
|
$competence->Mail = $comp['email'];
|
|
$competence->Statut = 'Actif';
|
|
$competence->DateCessation = '';
|
|
$competence->Remarque = trim($infos);
|
|
$tabRet[] = $competence;
|
|
}
|
|
|
|
} elseif ($type=='tri' || $type=='adm' || $type=='hui') {
|
|
|
|
$tabTmp = $iBodacc->getTribunauxParCommune($codeInsee);
|
|
foreach ($tabTmp as $i=>$tribunal)
|
|
{
|
|
if (//$tribunal['triType']=='C' ||
|
|
$tribunal['triType']=='G'// ||
|
|
/*$tribunal['triType']=='I'*/) {
|
|
$idCA = $tribunal['triIdSup'];
|
|
$codeTGI = $tribunal['triCode'];
|
|
$code = strtoupper(substr($tribunal['triCode'],0,3));
|
|
}
|
|
debugLog('D',"Liste des compétences $type demandée pour la commune $codeInsee ($dep) : ".
|
|
"Type=".$tribunal['triType'].', '.
|
|
"Code=".$tribunal[$codeTGI],__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
if ($tribunal['triType']<>'E' && $tribunal['triType']<>'O' &&
|
|
$tribunal['triType']<>'T' && $tribunal['triType']<>'R' &&
|
|
$tribunal['triType']<>'N' && $tribunal['triType']<>'U' &&
|
|
$tribunal['triType']<>'Z')
|
|
{
|
|
$competence = new Competence();
|
|
$competence->Id = $tribunal['triId'];
|
|
$competence->IdSup = $tribunal['triIdSup'];
|
|
$competence->Code = $tribunal['triCode'];
|
|
$competence->Type = $tribunal['triType'];
|
|
$competence->Nom = strtoupper(cleanstring($tribunal['triNom']));
|
|
$competence->Siret = $tribunal['triSiret'];
|
|
$competence->Adr = strtoupper(cleanstring(preg_replace('/ +/',' ',
|
|
$tribunal['triAdrNum'].' '.
|
|
$tribunal['triAdrIndRep'].' '.
|
|
$tribunal['triAdrTypeVoie'].' '.
|
|
$tribunal['triAdrVoie'])));
|
|
$competence->AdrComp = strtoupper($tribunal['triAdrComp']);
|
|
$competence->CP = $tribunal['triCP'];
|
|
$competence->Ville = strtoupper($tribunal['triVille']);
|
|
$competence->CodeInsee = $tribunal['CodeInsee'];
|
|
$competence->Tel = $tribunal['triTel'];
|
|
$competence->Fax = $tribunal['triFax'];
|
|
$competence->Web = $tribunal['triWeb'];
|
|
$competence->Mail = $tribunal['triMail'];
|
|
$competence->Statut = $tribunal['triStatut'];
|
|
$competence->DateCessation = $tribunal['triDateCessation']; //@todo : date
|
|
$competence->Remarque = $tribunal['triCommentaire'];
|
|
if ($tribunal['triNumGreffe']*1>0)
|
|
{
|
|
$competence->IdentifiantGreffe = $tribunal['triNumGreffe'];
|
|
}
|
|
$tabRet[] = $competence;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($type=='adm')
|
|
{
|
|
$iInsee = new MInsee();
|
|
$tabTmp = $iInsee->getMandataires(array($idCA), false);
|
|
$tabRet = array();
|
|
$nbAff=0;
|
|
foreach ($tabTmp as $i=>$tribunal)
|
|
{ /** @todo A revoir Debut **/
|
|
if (stripos($tribunal['tribunal'], $code)!==false ||
|
|
stripos($tribunal['tribunal'], 'SAINT')!==false)
|
|
{
|
|
$competence = new Competence();
|
|
$competence->Id = $tribunal['id'];
|
|
$competence->IdSup = $tribunal['sirenGrp'];
|
|
$competence->Code = $tribunal['tribunal'].'/'.$code;
|
|
$competence->Type = $tribunal['type'];
|
|
$competence->Nom = $tribunal['Nom'].' '.$tribunal['Prenom'];
|
|
$competence->Siret = $tribunal['sirenMand'];
|
|
$competence->Adr = strtoupper($tribunal['adresse']);
|
|
$competence->AdrComp = strtoupper($tribunal['adresseComp']);
|
|
$competence->CP = $tribunal['cp'];
|
|
$competence->Ville = strtoupper($tribunal['ville']);
|
|
//'CodeInsee'=>$tribunal['CodeInsee'],
|
|
$competence->Tel = $tribunal['tel'];
|
|
$competence->Fax = $tribunal['fax'];
|
|
$competence->Web = $tribunal['web'];
|
|
$competence->Mail = $tribunal['email'];
|
|
$competence->Statut = $tribunal['Statut'];
|
|
//'DateCessation'=>$tribunal['triDateCessation'],
|
|
$competence->Remarque = $tribunal['contact'];
|
|
//,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact
|
|
$tabRet[] = $competence;
|
|
$nbAff++;
|
|
}
|
|
}
|
|
if ($nbAff==0)
|
|
{
|
|
foreach ($tabTmp as $i=>$tribunal)
|
|
{
|
|
$competence = new Competence();
|
|
$competence->Id = $tribunal['id'];
|
|
$competence->IdSup = $tribunal['sirenGrp'];
|
|
$competence->Code = $tribunal['tribunal'].'/'.$code;
|
|
$competence->Type = $tribunal['type'];
|
|
$competence->Nom = $tribunal['Nom'].' '.$tribunal['Prenom'];
|
|
$competence->Siret = $tribunal['sirenMand'];
|
|
$competence->Adr = strtoupper($tribunal['adresse']);
|
|
$competence->AdrComp = strtoupper($tribunal['adresseComp']);
|
|
$competence->CP = $tribunal['cp'];
|
|
$competence->Ville = strtoupper($tribunal['ville']);
|
|
//'CodeInsee'=>$tribunal['CodeInsee'],
|
|
$competence->Tel = $tribunal['tel'];
|
|
$competence->Fax = $tribunal['fax'];
|
|
$competence->Web = $tribunal['web'];
|
|
$competence->Mail = $tribunal['email'];
|
|
$competence->Statut = $tribunal['Statut'];
|
|
//'DateCessation'=>$tribunal['triDateCessation'],
|
|
$competence->Remarque = $tribunal['contact'];
|
|
//,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact
|
|
$tabRet[] = $competence;
|
|
}
|
|
}/** @todo A revoir Fin : Lier correctement les mandataires à un TI principal **/
|
|
}
|
|
elseif ($type=='hui')
|
|
{
|
|
$iInsee = new MInsee();
|
|
$tabTmp = $iInsee->getHuissiers(array($codeTGI), false);
|
|
|
|
$tabRet = array();
|
|
$nbAff = 0;
|
|
foreach ($tabTmp as $i=>$tribunal)
|
|
{
|
|
$adr = $iInsee->structureVoie($tribunal['adresse']);
|
|
$competence = new Competence();
|
|
$competence->Id = $tribunal['id'];
|
|
$competence->IdSup = $tribunal['sirenGrp'];
|
|
$competence->Code = $tribunal['tribunal'].'/'.$code;
|
|
$competence->Type = $tribunal['type'];
|
|
$competence->Nom = $tribunal['Nom'].' '.$tribunal['Prenom'];
|
|
$competence->Siret = $tribunal['sirenMand'];
|
|
$competence->Adr = strtoupper($adr['num'].' '.$adr['adr_btq'].' '.
|
|
$adr['typeVoie'].' '.$adr['libVoie']);
|
|
$competence->AdrComp = strtoupper($tribunal['adresseComp']);
|
|
$competence->CP = $adr['cp'];
|
|
$competence->Ville = strtoupper($tribunal['ville']);
|
|
//'CodeInsee'=>$tribunal['CodeInsee'],
|
|
$competence->Tel = $tribunal['tel'];
|
|
$competence->Fax = $tribunal['fax'];
|
|
$competence->Web = $tribunal['web'];
|
|
$competence->Mail = $tribunal['email'];
|
|
$competence->Statut = $tribunal['Statut'];
|
|
//'DateCessation'=>$tribunal['triDateCessation'];
|
|
$competence->Remarque = strtr($tribunal['contact'],
|
|
array( '<br/>'=>', ', '<br>'=>', ',
|
|
'<br />'=>', ',
|
|
));
|
|
$tabRet[] = $competence;
|
|
}
|
|
$nbComp = count($tabTmp);
|
|
debugLog('I',"$nbComp compétences $type trouvées pour le tribunal $codeTGI",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
}
|
|
elseif ($type=='cfe')
|
|
{
|
|
$tabTmp = $iBodacc->getTribunauxParCommune($codeInsee);
|
|
foreach ($tabTmp as $i=>$tribunal)
|
|
{
|
|
if ($tribunal['triType']=='C' || $tribunal['triType']=='O' ||
|
|
$tribunal['triType']=='T' || $tribunal['triType']=='R' ||
|
|
$tribunal['triType']=='N' || $tribunal['triType']=='U' ||
|
|
$tribunal['triType']=='Z')
|
|
{
|
|
if (strlen($tribunal['triCommentaire'])==32 &&
|
|
strpos($tribunal['triCommentaire'], ' ')===false)
|
|
$remarque='';
|
|
else $remarque=$tribunal['triCommentaire'];
|
|
|
|
$competence = new Competence();
|
|
$competence->Id = $tribunal['triId'];
|
|
$competence->IdSup = $tribunal['triIdSup'];
|
|
$competence->Code = $tribunal['triCode'];
|
|
$competence->Type = $tribunal['triType'];
|
|
$competence->Nom = strtoupper($tribunal['triNom']);
|
|
$competence->Siret = $tribunal['triSiret'];
|
|
$competence->Adr = strtoupper(preg_replace('/ +/',' ',$tribunal['triAdrNum'].' '.$tribunal['triAdrIndRep'].' '.
|
|
$tribunal['triAdrTypeVoie'].' '.$tribunal['triAdrVoie']));
|
|
$competence->AdrComp = strtoupper($tribunal['triAdrComp']);
|
|
$competence->CP = $tribunal['triCP'];
|
|
$competence->Ville = strtoupper($tribunal['triVille']);
|
|
$competence->CodeInsee = $tribunal['CodeInsee'];
|
|
$competence->Tel = $tribunal['triTel'];
|
|
$competence->Fax = $tribunal['triFax'];
|
|
$competence->Web = $tribunal['triWeb'];
|
|
$competence->Mail = $tribunal['triMail'];
|
|
$competence->Statut = $tribunal['triStatut'];
|
|
$competence->DateCessation = $tribunal['triDateCessation']; //@todo : date
|
|
$competence->Remarque = $remarque;
|
|
$tabRet[] = $competence;
|
|
}
|
|
}
|
|
}
|
|
$this->wsLog('competences',$siret,$type.'/'.$codeInsee);
|
|
$output = new ListeCompetencesReturn();
|
|
$output->result = $tabRet;
|
|
$output->nbReponses = count($tabRet);
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne le statut du webservice
|
|
* @return StatusReturn
|
|
*/
|
|
public function status()
|
|
{
|
|
/* @todo tester les différents éléments qui peuvent conduire
|
|
* à un problème dans les services tel que la connexion à la
|
|
* base de données, l'accès FTP, l'accès HTTP, l'accès système de fichier
|
|
*/
|
|
|
|
//Enregistrement des accès à la requête getIdentite
|
|
Zend_Registry::get('WsLogger')->info("status - ip:".
|
|
$_SERVER['REMOTE_ADDR'].", login:".$_SERVER['PHP_AUTH_USER'].
|
|
", hash:".$_SERVER['PHP_AUTH_PW']);
|
|
|
|
$error = new StatusReturn();
|
|
//Test connexion à la base de données
|
|
$db = new WDB('jo');
|
|
if (!$db) {
|
|
$error->statusCode = 9000;
|
|
$error->statusMsg = $this->listError['9000'];
|
|
} else {
|
|
$error->statusCode = 3000;
|
|
$error->statusMsg = $this->listError['3000'];
|
|
}
|
|
return $error;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|