2568 lines
97 KiB
PHP
2568 lines
97 KiB
PHP
<?php
|
|
require_once realpath(dirname(__FILE__)).'/WsScore.php';
|
|
require_once realpath(dirname(__FILE__)).'/functions.php';
|
|
require_once realpath(dirname(__FILE__)).'/Types/EntrepriseTypes.php';
|
|
|
|
class WsEntreprise extends WsScore
|
|
{
|
|
protected $wsdl = null;
|
|
protected $wsdlOptions = array();
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$webservicesConfig = Zend_Registry::get('webservicesConfig')->webservice->scores;
|
|
$wsdl = !empty($webservicesConfig->wsdl) ? $webservicesConfig->wsdl : null ;
|
|
$options = array();
|
|
foreach ($webservicesConfig->options as $optionName => $optionValue){
|
|
$options[$optionName] = $optionValue;
|
|
}
|
|
$options['login'] = $_SERVER['PHP_AUTH_USER'];
|
|
$options['password'] = $_SERVER['PHP_AUTH_PW'];
|
|
$this->wsdl = $wsdl;
|
|
$this->wsdlOptions = $options;
|
|
}
|
|
|
|
/**
|
|
* 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 IdentiteReturn
|
|
*/
|
|
public function getIdentite($siret, $id = 0)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//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('1010');
|
|
}
|
|
|
|
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);
|
|
|
|
$identite = new IdentiteReturn();
|
|
$identite->id = $entrep['id'];
|
|
$identite->Siret = $entrep['Siret'];
|
|
$identite->SiretSiege = $entrep['SiretSiege'];
|
|
$identite->Siege = $entrep['Siege'];
|
|
$identite->TribunalCode = $entrep['Tribunal'];
|
|
$identite->TribunalLib = $entrep['TribunalLib'];
|
|
//'NumGreffe' = $entrep['numGreffe'], // Ajouté le 4 08 2009
|
|
$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
|
|
//'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 = $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
|
|
//'importExport' = $entrep['importExport'],
|
|
|
|
if (preg_match('/NAF4/i', $this->tabInfoUser['pref']))
|
|
{
|
|
$entrep2 = $iInsee->getNaf4($siren, $nic, $id);
|
|
$identite->Naf4Ent = $entrep2['apen4'];
|
|
$identite->Naf4Etab = $entrep2['apet4'];
|
|
$identite->Naf4EntLib = $entrep2['apen4_lib'];
|
|
$identite->Naf4EtabLib = $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 liens financiers pour une entreprise.
|
|
*
|
|
* @param integer $siren Siren de l'entreprise
|
|
* @param boolean $actifsUniquement Uniquement les liens Actifs
|
|
* @return LiensReturn
|
|
*/
|
|
public function getLiens($siren, $actifsUniquement = true)
|
|
{
|
|
$this->authenticate();
|
|
//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();
|
|
|
|
//Initialisation
|
|
if (empty($dep)) { $dep = 0; }
|
|
if (empty($actif)) { $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->liste = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne l'ensemble des informations identitaires des dirigeants de l'entreprise
|
|
*
|
|
* @param integer $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();
|
|
|
|
//Initialisation
|
|
if (empty($histo)) { $histo = false; }
|
|
|
|
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');
|
|
}
|
|
|
|
if ($histo) $option='histo';
|
|
else $option='';
|
|
$iInsee = new MInsee();
|
|
$dirs = $iInsee->getDirigeants($siren, $histo);
|
|
//debugLog('W', print_r($entrep, 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->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->nbReponses = count($liste);
|
|
$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 0=Pas de Filtre, 1=BODACC, 2=B.A.L.O, 3=JO Association, 4=Boamp
|
|
* @param integer $idAnn Identifiant de l'annonce
|
|
* @param integer $position
|
|
* @param integer $nbRep
|
|
* @return AnnoncesReturn
|
|
*/
|
|
public function getAnnonces($siren, $filtre = 0, $idAnn = 0, $position = 0, $nbRep = 20)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
if (empty($filtre)) { $filtre = 0; }
|
|
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__);
|
|
|
|
$liste = array();
|
|
|
|
if (strlen($siren)<>9)
|
|
{
|
|
debugLog('W', "Siren/Siret $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->sendError('1010');
|
|
}
|
|
elseif ($siren*1==0 && $idAnn==0)
|
|
{
|
|
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;
|
|
}*/
|
|
if ($idAnn==0) {
|
|
$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 = $ann['texteRectificatif'];
|
|
$annonce->texteAnnonce = $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 = $ann['texteRectificatif'];
|
|
$annonce->texteAnnonce = $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 = $ann['texteRectificatif'];
|
|
$annonce->texteAnnonce = $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 = $ann['texteRectificatif'];
|
|
$annonce->texteAnnonce = $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);
|
|
file_put_contents(LOG_PATH.'/annonces.log', print_r($liste,1));
|
|
|
|
$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
|
|
* @param int $niveau
|
|
* @return IndiscoreReturn
|
|
*/
|
|
public function getIndiScore($siren, $nic=0, $niveau=2, $plus=false)
|
|
{
|
|
$this->authenticate();
|
|
$perm = false;
|
|
switch($niveau){
|
|
case 1:
|
|
if ( !$this->checkPerm('indiscore') || !checkPerm('indiscorep') ){
|
|
$this->permission('indiscore');
|
|
}
|
|
break;
|
|
case 2:
|
|
if (!$this->checkPerm('indiscore2') || !checkPerm('indiscore2p') ){
|
|
$this->permission('indiscore2');
|
|
}
|
|
break;
|
|
case 3:
|
|
if (!$this->checkPerm('indiscore3') || !checkPerm('indiscore3p') ){
|
|
$this->permission('indiscore3');
|
|
}
|
|
break;
|
|
}
|
|
|
|
//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; }
|
|
$error = new ErrorType();
|
|
$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__);
|
|
$error->errnum = 102;
|
|
$error->errmsg = 'Siren incorrect';
|
|
} else {
|
|
$tDeb = microtime(true);
|
|
require_once 'Metier/scores/classMScores.php';
|
|
$tabRet = calculIndiScore($siren, $nic, $accesDist, $niveau);
|
|
$duree = round(microtime(true)-$tDeb,3);
|
|
debugLog('W', "indiscore DUREE = $duree s", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog('indiscore',$siren);
|
|
}
|
|
if ($plus) {
|
|
$this->setSurveillance($siren, $this->tabInfoUser['email'], 'Indiscore+', 'privileges', false, 0);
|
|
$this->setSurveillance($siren, $this->tabInfoUser['email'], 'Indiscore+', 'score');
|
|
if ($this->tabInfoUser['idClient']==89)
|
|
$this->setSurveillance($siren, $this->tabInfoUser['email'], 'Indiscore+', 'annonces');
|
|
}
|
|
Zend_Registry::get('WsLogger')->info("INDISCORE : ".print_r($tabRet,1));
|
|
$result = 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;
|
|
$result->paiements = $paiement;
|
|
} elseif ($key=='Bilans') {
|
|
|
|
} 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'];
|
|
$result->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;
|
|
}
|
|
$result->tabBilans = $tabRet;
|
|
} elseif ($key=='tabBilan') {
|
|
|
|
} elseif ($key=='tabInfosNotations') {
|
|
$infosNotation = new IndiscoreInfosNotations();
|
|
$infosNotation->SituationFinanciere = $value['SituationFinanciere'];
|
|
$infosNotation->Notation = $value['Notation'];
|
|
$infosNotation->ProbabiliteDefaut = $value['ProbabiliteDefaut'];
|
|
$result->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;
|
|
}
|
|
$result->tabImportExport = $tabRet;
|
|
} elseif ($key=='tabCommentaires') {
|
|
$tab = array();
|
|
foreach($value as $comment) {
|
|
$tab[] = $comment;
|
|
}
|
|
$result->tabCommentaires = $tab;
|
|
} elseif ($key=='tabVariables') {
|
|
$tab = $value['CA_Y'];
|
|
$tabVar = array();
|
|
foreach($tab as $varName => $varVal){
|
|
$var = new CA_Y();
|
|
$var->id = $varName;
|
|
$var->val = $varVal;
|
|
$tabVar[] = $var;
|
|
}
|
|
$variables = new IndiscoreVariables();
|
|
$variables->CA_Y = $tabVar;
|
|
$result->tabVariables = $variables;
|
|
|
|
|
|
} else {
|
|
$result->$key = $value;
|
|
}
|
|
}
|
|
$output = new IndiscoreReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
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 $deb
|
|
* @param integer $max
|
|
* @return InseeReturn
|
|
**/
|
|
public function getListeEvenements($siren, $nic=0, $deb=0, $max=1000)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('eveninsee');
|
|
|
|
//Initialisation
|
|
if (empty($nic)) { $nic = 0; }
|
|
if (empty($deb)) { $deb = 0; }
|
|
if (empty($max) || $max>1000) { $max = 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();
|
|
$evens = $iInsee->getEvenements($siren, $nic, $deb, $max);
|
|
$tabRet = array();
|
|
if (count($evens)>0)
|
|
{
|
|
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('etablissements',$siren);
|
|
|
|
$output = new InseeReturn();
|
|
$output->nbReponses = count($tabRet);
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
|
|
/**
|
|
* Recherche
|
|
* @param string $type Type de la recherche (recherche entreprise : 'ent', recherche dirigeant : 'dir')
|
|
* @param RechercheEntrepriseCriteres $criteres
|
|
* @param int $position Position de parcours des résultats retournées (0 par défaut)
|
|
* @param int $nbRep Nombre de réponses retournées lors d'une requête (20 par défaut)
|
|
* @param int $maxRep Nombre de réponses maximum pouvant être retournées lors d'une requête (200 par défaut)
|
|
* @param bool $pertinence Recherche orthographique stricte sur le nom, l'adresse et la ville (false par défaut)
|
|
* @param bool $avecSiren Seulement les entités sirénées (false par défaut)
|
|
* @return RechercheEntrepriseReturn
|
|
*/
|
|
public function rechercheEntreprise($type, $criteres, $position = 0, $nbRep = 20, $maxRep = 200, $pertinence = false, $avecSiren = false)
|
|
{
|
|
//Enregistrement des accès à la requête getIdentite
|
|
Zend_Registry::get('WsLogger')->info("rechercheEntreprise - ip : ".
|
|
$_SERVER['REMOTE_ADDR'].", login:".$_SERVER['PHP_AUTH_USER']);
|
|
|
|
require_once 'i18n/cleanchar.php';
|
|
switch ($type)
|
|
{
|
|
case 'ent':
|
|
$entCriteres = new CriteresEntreprise();
|
|
$entCriteres = $criteres->elementEntreprise;
|
|
$client = new SoapClient($this->wsdl, $this->wsdlOptions);
|
|
$identifiant = $entCriteres->identifiant;
|
|
$typeId = '';
|
|
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';
|
|
}
|
|
}
|
|
|
|
if (in_array($typeId, array('R', 'W', 'I'))){
|
|
try {
|
|
$O = $client->searchAutreId(
|
|
$typeId,
|
|
$identifiant,
|
|
empty($position) ? 0 : $position,
|
|
empty($nbRep) ? 20 : $nbRep,
|
|
empty($maxRep) ? 200 : $maxRep,
|
|
$entCriteres->codePostal
|
|
);
|
|
} catch (SoapFault $fault) {
|
|
Zend_Registry::get('WsLogger')->err("rechercheEntreprise - ".serialize($criteres));
|
|
throw new SoapFault($fault->faultcode, $fault->faultstring);
|
|
exit;
|
|
}
|
|
} elseif ($typeId == 'S'){
|
|
try {
|
|
$O = $client->searchSiren(
|
|
$identifiant,
|
|
empty($position) ? 0 : $position,
|
|
empty($nbRep) ? 20 : $nbRep,
|
|
empty($maxRep) ? 200 : $maxRep,
|
|
$entCriteres->codePostal
|
|
);
|
|
} catch (SoapFault $fault) {
|
|
Zend_Registry::get('WsLogger')->err("rechercheEntreprise - ".serialize($criteres));
|
|
throw new SoapFault($fault->faultcode, $fault->faultstring);
|
|
exit;
|
|
}
|
|
} else {
|
|
|
|
try {
|
|
$O = $client->searchNomAdr(
|
|
cleanstring($entCriteres->raisonSociale),
|
|
cleanstring($entCriteres->adresse),
|
|
$entCriteres->codePostal,
|
|
cleanstring($entCriteres->ville),
|
|
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
|
empty($entCriteres->actif) ? false : $entCriteres->actif,
|
|
empty($position) ? 0 : $position,
|
|
empty($nbRep) ? 20 : $nbRep,
|
|
empty($maxRep) ? 200 : $maxRep,
|
|
empty($pertinence) ? false : $pertinence,
|
|
empty($avecSiren) ? false : $avecSiren,
|
|
$entCriteres->naf
|
|
);
|
|
} catch (SoapFault $fault) {
|
|
Zend_Registry::get('WsLogger')->err("rechercheEntreprise - ".serialize($criteres));
|
|
throw new SoapFault($fault->faultcode, $fault->faultstring);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
break;
|
|
case 'dir':
|
|
$dirCriteres = new CriteresDirigeant();
|
|
$dirCriteres = $criteres->elementDirigeant;
|
|
$client = new SoapClient($this->wsdl, $this->wsdlOptions);
|
|
try {
|
|
$O = $client->searchDir(
|
|
cleanstring($dirCriteres->dirNom),
|
|
cleanstring($dirCriteres->dirPrenom),
|
|
$dirCriteres->dirDateNaiss,
|
|
cleanstring($dirCriteres->dirVille),
|
|
empty($position) ? 0 : $position,
|
|
empty($nbRep) ? 20 : $nbRep,
|
|
empty($maxRep) ? 200 : $maxRep,
|
|
empty($pertinence) ? false : $pertinence
|
|
);
|
|
} catch (SoapFault $fault) {
|
|
Zend_Registry::get('WsLogger')->err("rechercheEntreprise - ".serialize($criteres));
|
|
throw new SoapFault($fault->faultcode, $fault->faultstring);
|
|
exit;
|
|
}
|
|
break;
|
|
}
|
|
|
|
$error = new ErrorType();
|
|
$error = arrayToClass($O['error'], 'ErrorType');
|
|
$results = new RechercheEntrepriseResult();
|
|
$results = arrayToClass($O['results'], 'RechercheEntrepriseResult');
|
|
$outputParams = new RechercheEntrepriseReturn();
|
|
$outputParams->error = $error;
|
|
$outputParams->results = $results;
|
|
return $outputParams;
|
|
}
|
|
|
|
/**
|
|
* 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 la liste des tribunaux ou Compétences demandées
|
|
* @param array|string $tabTypes Tableau des types de Compétences demandés 'C':Commerce, 'I':Instance, 'G':TGI, 'A':Préfectures, 'B':Sous-préf, 'D':Tribunal Administratif, 'H':Prud'hommes, 'L': Cour d'Appel, 'M': Tribunal Mixte, 'O':CCI, 'V': Cour Administrative d'Appel
|
|
* @return TribunauxReturn
|
|
**/
|
|
public function getTribunaux($tabTypes)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
if (empty($tabTypes)) $tabTypes = array();
|
|
if (is_string($tabTypes)) $tabTypes = (array)$tabTypes;
|
|
|
|
$iBodacc = new MBodacc();
|
|
debugLog('I',"Liste des tribunaux demandées",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$tabTmp = $iBodacc->getListeTribunaux();
|
|
//@todo : Retourner liste en ordre alphabétique
|
|
$tabRet = array();
|
|
if (count($tabTypes)==0) {
|
|
foreach ($tabTmp as $i => $tribunal){
|
|
$tri = new Tribunal();
|
|
$tri->code = $i;
|
|
$tri->nom = $tribunal['nom'];
|
|
$tabRet[] = $tri;
|
|
}
|
|
} else {
|
|
foreach ($tabTmp as $i=>$tribunal){
|
|
$type = substr($i,-1);
|
|
if ( in_array($type, $tabTypes) ){
|
|
$tri = new Tribunal();
|
|
$tri->code = $i;
|
|
$tri->nom = $tribunal['nom'];
|
|
$tabRet[] = $tri;
|
|
}
|
|
}
|
|
}
|
|
$output = new TribunauxReturn();
|
|
$output->tribunaux = $tabRet;
|
|
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();
|
|
|
|
//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 InfosBourseReturn
|
|
*/
|
|
public function getInfosBourse($siren)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//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('1010');
|
|
}
|
|
|
|
$result = new InfosBourse();
|
|
$result->Siren = $bourse['siren'];
|
|
$result->RaisonSociale = prepareString($bourse['raisonSociale']);
|
|
$result->Adresse = prepareString($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 = prepareString($bourse['dateIntroduction']); //@todo : date
|
|
$result->DateDerAG = prepareString($bourse['dateDerAG']); //@todo : date
|
|
$result->DateRadiation = prepareString($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);
|
|
$output = new InfosBourseReturn();
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* Enter description here ...
|
|
* @param string $siren
|
|
* @param array $tabTypes
|
|
* @return PrivilegesDetailReturn
|
|
*/
|
|
public function getPrivilegesDetail($siren, $tabTypes=array('03','04'))
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
if (empty($tabTypes)) $tabTypes = array('03','04');
|
|
debugLog('I',"Liste des privilèges detail sur $siren ".print_r($tabTypes, true),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$iPriv = new MPrivileges();
|
|
$ret = $iPriv->getPrivilegesDetail($siren, $tabTypes); //@todo : date
|
|
// @todo : faire les détails privileges
|
|
$output = new PrivilegesDetailReturn();
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* Enter description here ...
|
|
* @param string $siren
|
|
* @param array $tabTypes
|
|
* @return PrivilegesCumulReturn
|
|
*/
|
|
public function getPrivilegesCumul($siren, $tabTypes=array('03','04'))
|
|
{
|
|
$this->authenticate();
|
|
//Initialisation
|
|
if (empty($tabTypes)) $tabTypes = array('03','04');
|
|
debugLog('I',"Liste des privilèges cumul sur $siren ".print_r($tabTypes, true),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$iPriv = new MPrivileges();
|
|
$ret = $iPriv->getPrivilegesCumul($siren, $tabTypes);
|
|
$tabRet = array();
|
|
|
|
if (isset($ret['03']) && count($ret['03']>0)){
|
|
$value = $ret['03'];
|
|
$priv = new PrivilegesCumul();
|
|
$priv->insType = '03';
|
|
$priv->nb = $value['nb'];
|
|
$priv->insTypeLib = $value['insTypeLib'];
|
|
$priv->dateFraiche = $value['dateFraiche']; //@todo : date
|
|
$priv->dateDerInsc = $value['dateDerInsc']; //@todo : date
|
|
$priv->nomDerCre = $value['nomDerCre'];
|
|
$priv->numDebiteur = $value['numDebiteur'];
|
|
$priv->greffeLib = $value['greffeLib'];
|
|
$priv->dateMajSD = $value['dateMajSD']; //@todo : date
|
|
$priv->insCumul = $value['insCumul'];
|
|
$tabRet[] = $priv;
|
|
}
|
|
|
|
if (isset($ret['04']) && count($ret['04']>0)){
|
|
$value = $ret['04'];
|
|
$priv = new PrivilegesCumul();
|
|
$priv->insType = '04';
|
|
$priv->nb = $value['nb'];
|
|
$priv->insTypeLib = $value['insTypeLib'];
|
|
$priv->dateFraiche = $value['dateFraiche']; //@todo : date
|
|
$priv->dateDerInsc = $value['dateDerInsc']; //@todo : date
|
|
$priv->nomDerCre = $value['nomDerCre'];
|
|
$priv->numDebiteur = $value['numDebiteur'];
|
|
$priv->greffeLib = $value['greffeLib'];
|
|
$priv->dateMajSD = $value['dateMajSD']; //@todo : date
|
|
$priv->insCumul = $value['insCumul'];
|
|
$tabRet[] = $priv;
|
|
}
|
|
|
|
$output = new PrivilegesCumulReturn();
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
|
|
/**
|
|
* 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)
|
|
* @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 'annonces':
|
|
default:
|
|
$this->permission('survannonce');
|
|
break;
|
|
}
|
|
|
|
//Initialisation
|
|
if (empty($ref)) $ref = '';
|
|
if (empty($delete)) $delete = false;
|
|
if (empty($encoursClient)) $encoursClient = false;
|
|
$tabRet = array();
|
|
$siren = substr($siret,0,9);
|
|
$nic = substr($siret,9,5);
|
|
|
|
debugLog('I',"setSurveillances(siret=$siret, email=$email, ref=$ref, source=$source, delete=$delete)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$iInsee = new MInsee();
|
|
$tabIdentite = $iInsee->getIdentiteLight($siren, $nic);
|
|
$iDb = new WDB();
|
|
$login = $this->tabInfoUser['login'];
|
|
switch ($source) {
|
|
case 'insee':
|
|
case 'annonces':
|
|
case 'bilans':
|
|
case 'actes':
|
|
case 'privileges':
|
|
case 'dirigeants': $encoursClient=0; break;
|
|
case 'score': $encoursClient=$encoursClient*1; break;
|
|
default: $source='annonces'; break;
|
|
}
|
|
$tabUpdate = array(
|
|
'source' => $source,
|
|
'login' => $login,
|
|
'email' => $email,
|
|
'siren' => $siren,
|
|
'nic' => $nic,
|
|
'ref' => $ref,
|
|
'encoursClient' => $encoursClient,
|
|
'rs' => $tabIdentite['Nom'],
|
|
'cp' => $tabIdentite['CP'],
|
|
'ville' => $tabIdentite['Ville'],
|
|
);
|
|
if ($delete) {
|
|
$tabUpdate = array_merge(
|
|
$tabUpdate,
|
|
array('dateSuppr'=>date('Y-m-d'))
|
|
);
|
|
} else {
|
|
$tabUpdate = array_merge(
|
|
$tabUpdate,
|
|
array('dateAjout'=>date('Y-m-d'), 'dateSuppr'=>0)
|
|
);
|
|
}
|
|
if ( $delete || !$iDb->insert('surveillances_site', $tabUpdate)) {
|
|
/*@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "debugSurv pour $login",
|
|
"source='$source' AND login='$login' AND email='$email' AND siren=$siren AND nic=$nic AND ref='$ref'".EOL.
|
|
print_r($tabUpdate,true).EOL
|
|
);*/
|
|
if (!$iDb->update('surveillances_site', $tabUpdate, "source='$source' AND login='$login' AND email='$email' AND siren=$siren AND nic=$nic AND ref='$ref'"))
|
|
{
|
|
$this->sendError('1030');
|
|
}
|
|
}
|
|
$output = new SetSurveillanceReturn();
|
|
$output->result = true;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* getSurveillances
|
|
* @param SurveillancesFiltre $filtre
|
|
* @param integer $deb
|
|
* @param integer $nbRet
|
|
* @return SurveillancesReturn
|
|
*/
|
|
public function getSurveillances($filtre, $position=0, $nbRep=100)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
if (empty($position)) $position = 0;
|
|
if (empty($nbRep)) $nbRep = 100;
|
|
|
|
$error = new ErrorType();
|
|
$tabRet = array();
|
|
$siren = substr($filtre->siret,0,9);
|
|
$nic = substr($filtre->siret,9,5);
|
|
|
|
$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
|
|
}
|
|
$iDb = new WDB();
|
|
$login = $this->tabInfoUser['login'];
|
|
|
|
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 = '';
|
|
|
|
if ($siren>0) $strSiren = " AND siren=$siren ";
|
|
else $strSiren = '';
|
|
|
|
// 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'];
|
|
|
|
$tabTmp = $iDb->select('surveillances_site', $strSelect, "login='$login' AND dateSuppr=0 $strSiren $strSource $orderBy LIMIT $position,$nbRep", false, MYSQL_ASSOC);
|
|
foreach ($tabTmp as $i=>$tabSurv){
|
|
if (!$filtre->detail){
|
|
$liste = new Surveillance();
|
|
$liste->source = $tabSurv['source'];
|
|
$liste->email = $tabSurv['email'];
|
|
$liste->siren = $tabSurv['siren'];
|
|
$liste->nic = $tabSurv['nic'];
|
|
$liste->ref = $tabSurv['ref'];
|
|
$liste->dateAjout = $tabSurv['dateAjout']; //@todo : date
|
|
$liste->dateDerEnvoi = $tabSurv['dateDerEnvoi']; //@todo : date
|
|
$tabRet[] = $liste;
|
|
} else {
|
|
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
|
|
);
|
|
}
|
|
$liste = new Surveillance();
|
|
$liste->source = $tabSurv['source'];
|
|
$liste->email = $tabSurv['email'];
|
|
$liste->siren = $tabSurv['siren'];
|
|
$liste->nic = $tabSurv['nic'];
|
|
$liste->ref = $tabSurv['ref'];
|
|
$liste->dateAjout = $tabSurv['dateAjout']; //@todo : date
|
|
$liste->encoursClient = $tabSurv['encoursClient'];
|
|
$liste->rs = $rs;
|
|
$liste->cp = $cp;
|
|
$liste->ville = $ville;
|
|
$liste->dateDerEnvoi = $tabSurv['dateDerEnvoi']; //@todo : date
|
|
$tabRet[] = $liste;
|
|
}
|
|
}
|
|
$output = new SurveillancesReturn();
|
|
$output->nbReponses = count($tabRet);
|
|
$output->nbReponsesTotal = $nbRepTot;
|
|
$output->result = $tabRet;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Liste les mandataires correspondant à un nom donné
|
|
*
|
|
* @param mixed $codeTribunal Identifiants BODACC du tribunal ou tableau d'Identifiants numériques des cours d'appel
|
|
* @param array $type Type de mandataire (A)dministrateur, (M)andataire, (O)ppositions, (N)otaires, a(V)ocat
|
|
* @param int $cpDep Code postal ou département du mandataire
|
|
* @return MandatairesReturn
|
|
*/
|
|
public function searchMandataires($nom, $type=array('A','M'), $cpDep=0)
|
|
{
|
|
$this->authenticate();
|
|
|
|
//Initialisation
|
|
if (empty($type)) $type = array('A','M');
|
|
if (empty($cpDep)) $cpDep = 0;
|
|
$tabRet = array();
|
|
|
|
debugLog('I',"Recherche de Mandataires '$nom' (Dep=$cpDep)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
$iInsee = new MInsee();
|
|
$tabTmp = $iInsee->searchMandataires($nom, true, $type, $cpDep);
|
|
|
|
foreach ($tabTmp as $i=>$mand)
|
|
{
|
|
$mandataire = new Mandataire();
|
|
$mandataire->id = 'm'.$i;
|
|
$mandataire->mand = $mand;
|
|
$tabRet[] = $mandataire;
|
|
|
|
}
|
|
$output = new MandatairesReturn();
|
|
$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 BilanReturn
|
|
*/
|
|
public function getBilan($siren, $millesime, $typeBilan='N', $ref='')
|
|
{
|
|
$this->authenticate();
|
|
|
|
//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;
|
|
}
|
|
}
|
|
$resultBilan->POSTES = $tabPoste;
|
|
$output = new BilanReturn();
|
|
$output->result = $resultBilan;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Retourne la liste des bilans disponible pour une entreprise
|
|
*
|
|
* @param string $siren Siren de l'entreprise
|
|
* @return ListeBilansReturn
|
|
*/
|
|
public function getListeBilans($siren)
|
|
{
|
|
$this->authenticate();
|
|
//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(false);
|
|
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__);
|
|
$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();
|
|
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
$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");
|
|
} 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");
|
|
}
|
|
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");
|
|
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");
|
|
break;
|
|
}
|
|
|
|
if (count($res)>0)
|
|
{
|
|
$iBodacc = new MBodacc();
|
|
foreach ($res as $i=>$etab)
|
|
{
|
|
$annonces = RechercheAnnonce();
|
|
$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);
|
|
$result = new RechercheAnnonceResult();
|
|
$result->criteres = $criteres;
|
|
$result->nbReponses = $nbTot;
|
|
$result->nbReponsesTotal = $nbTot;
|
|
$result->liste = $tabRet;
|
|
$output = new RechercheAnnonceReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* getRatios
|
|
* @param string $siren
|
|
* @param string $page
|
|
* @return RatiosReturn
|
|
*/
|
|
public function getRatios($siren, $page='ratios')
|
|
{
|
|
global $tva, $tabFormules, $mBil, $tabBilan, $efftr, $tabInfla;
|
|
require_once 'Metier/tmp/configMRatios.php';
|
|
$this->authenticate();
|
|
//Initialisation
|
|
$error = new ErrorType();
|
|
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__);
|
|
$error->errnum =102;
|
|
$error->errmsg = 'Siren inexistant';
|
|
} elseif ($siren*1==0) {
|
|
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
$error->errnum =102;
|
|
$error->errmsg = 'Siren inexistant';
|
|
} else {
|
|
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
|
|
$tabRatiosSecteurs = array();
|
|
if (strlen($naf)>4) $strNaf = " AND naf5='$naf' ";
|
|
else $strNaf = " AND naf4='$naf' ";
|
|
$strAnnees = implode(',', $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);
|
|
$ratiosSecteur = new RatiosSecteur();
|
|
$ratiosSecteur->annee = $tabTmp[0]['annee'];
|
|
$nbRatiosSec = 0;
|
|
$anneePre = $tabTmp[0]['annee'];
|
|
foreach ($tabTmp as $tabTmp2) {
|
|
if ($anneePre<>$tabTmp2['annee']) {
|
|
$tabRatiosSecteurs[] = $ratiosSecteur;
|
|
//On réinitialise tout
|
|
$ratiosSecteur = new RatiosSecteur();
|
|
$ratiosSecteur->annee = $tabTmp2['annee'];
|
|
}
|
|
$Ridx = $tabTmp2['id'];
|
|
if ($tabTmp2['nombre']>$nbRatiosSec){
|
|
$nbRatiosSec = $tabTmp2['nombre'];
|
|
}
|
|
|
|
$unite = $tabFormulesInfos[$Ridx]['unite'];
|
|
if ($unite=='EUR'){
|
|
$montant = round($tabTmp2['ratio']*1000);
|
|
} else {
|
|
$montant = round($tabTmp2['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;
|
|
$anneePre = $tabTmp2['annee'];
|
|
}
|
|
}
|
|
|
|
//$tabRatiosSecteurs=array(count($tabTmp), "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC");
|
|
|
|
$result = new RatiosResult();
|
|
$result->Nom = $tabIdentite['Nom'];
|
|
$result->NafEnt = $tabIdentite['NafEnt'];
|
|
$result->NafEntLib = $tabIdentite['NafEntLib'];
|
|
$result->FJ = $fj;
|
|
$result->FJ_lib = $tabIdentite['FJ_lib'];
|
|
$result->Siren = $siren;
|
|
$result->NbEntNaf = $nbRatiosSec;
|
|
$result->BilansInfos = $tabBilansR;
|
|
$result->RatiosInfos = $tabRatiosInfos;
|
|
$result->RatiosSecteur = $tabRatiosSecteurs;
|
|
|
|
//Zend_Registry::get('WsLogger')->info(__FUNCTION__." : ".print_r($result,1));
|
|
|
|
debugLog('I',"Liste des Ratios demandée pour $siren RETURN",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
$this->wsLog($page, $siren);
|
|
$output = new RatiosReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* getRapport
|
|
* @param string $siren
|
|
* @param integer $niveau
|
|
* @param integer $id
|
|
* @return RapportReturn
|
|
*/
|
|
public function getRapport($siren, $niveau=3, $id=0)
|
|
{
|
|
$this->authenticate();
|
|
if (empty($niveau)) $niveau = 3;
|
|
if (empty($id)) $id = 0;
|
|
$error = new ErrorType();
|
|
$result = new Rapport();
|
|
$filtre = 0;
|
|
$idAnn = 0;
|
|
if ($niveau==1){
|
|
$result->Indiscore = $this->getIndiScore($siren, 0);
|
|
} elseif ($niveau==2) {
|
|
$result->Identite = $this->getIdentite($siren, $id=0);
|
|
$result->Indiscore = $this->getIndiScore($siren, 0);
|
|
$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);
|
|
$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);
|
|
}
|
|
$output = new RapportReturn();
|
|
$output->error = $error;
|
|
$output->result = $result;
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* 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 ($siren*1>1000){
|
|
|
|
$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;
|
|
}
|
|
} else {
|
|
$error->errnum = 102;
|
|
$error->errmsg = 'Siren invalide';
|
|
}
|
|
debugLog('I',"Liste des banques pour siren $siren : ".count($tabRet).' banques',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
|
if (count($tabRet)==0) {
|
|
$error->errnum = 256454;
|
|
$error->errmsg = 'Aucune relation bancaire en base';
|
|
}
|
|
$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();
|
|
|
|
//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 === false)
|
|
{
|
|
$error->statusCode = 1;
|
|
$error->statusMsg = 'Erreur critique';
|
|
}
|
|
else
|
|
{
|
|
$error->statusCode = 0;
|
|
$error->statusMsg = 'Services disponible (beta)';
|
|
}
|
|
return $error;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|