2011-02-04 11:37:58 +00:00
< ? php
require_once 'WsScore/WsScore.php' ;
require_once 'WsScore/functions.php' ;
require_once realpath ( dirname ( __FILE__ )) . '/Types.php' ;
class Entreprise extends WsScore
{
protected $wsdl = null ;
protected $wsdlOptions = array ();
public function __construct ()
{
parent :: __construct ();
2011-08-04 09:38:08 +00:00
$config = new Zend_Config_Ini ( APPLICATION_PATH . '/configs/webservices.ini' , APPLICATION_ENV );
$webservicesConfig = $config -> webservice -> scores ;
2011-02-04 11:37:58 +00:00
$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
2011-02-07 09:39:30 +00:00
* @ return Identite
2011-02-04 11:37:58 +00:00
*/
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 ) {
2011-06-08 12:36:18 +00:00
$this -> sendError ( '1020' );
2011-02-04 11:37:58 +00:00
}
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 );
2011-02-07 09:39:30 +00:00
$identite = new Identite ();
2011-02-04 11:37:58 +00:00
$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' ];
2011-04-21 13:25:56 +00:00
$identite -> FJ_Lib = $entrep [ 'FJ_lib' ];
2011-02-04 11:37:58 +00:00
$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 ;
}
2011-06-08 12:36:18 +00:00
/**
* Retourne les informations identitaires de l 'entreprise ou de l' établissement demandé
* @ param string $siret Siren de l 'entreprise ou siret de l' établissement
* @ param integer $id Identifiant S & D de l ' établissement
* @ return IdentiteProcol Fiche d 'identité de l' établissement
*/
public function getIdentiteProcol ( $siret , $id = 0 , $forceVerif = false )
{
debugLog ( 'I' , " Identité AGS demandée pour siret $siret (id= $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$siret = trim ( $siret );
$len = strlen ( $siret );
$siren = substr ( $siret , 0 , 9 );
if ( $len == 14 ) {
$nic = substr ( $siret , 9 , 5 ) * 1 ;
} elseif ( $len == 9 ) {
$nic = 0 ;
}
if ( intval ( $siren ) == 0 && $id == 0 ) {
$this -> sendError ( '1010' );
} elseif ( $len != 14 && $len != 9 ) {
$this -> sendError ( '1020' );
}
debugLog ( 'I' , " Avant getIdentiteEntreprise( $siren , $nic , $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iInsee = new MInsee ();
$entrep = $iInsee -> getIdentiteEntreprise ( $siren , $nic , $id , $forceVerif );
debugLog ( 'I' , " Après getIdentiteEntreprise( $siren , $nic , $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$duree = round ( microtime ( 1 ) - $tdeb , 3 );
$ligne = date ( 'YmdHis' ) . " ; $siret ;Ws->getIdentite juste apres iInsee->... ( $duree s) " ;
$fp = fopen ( LOG_PATH . '/accesDistant.log' , 'a' );
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
if ( empty ( $entrep )) {
debugLog ( 'W' , " Siren $siren non présent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1020' );
}
$iBourse = new MBourse ( $siren );
$bourse = $iBourse -> getInfosBourse ( $siren );
$identiteProcol = new IdentiteProcol ();
//Element identite
$identite = new Identite ();
$identite -> id = $entrep [ 'id' ];
$identite -> Siret = $entrep [ 'Siret' ];
$identite -> SiretSiege = $entrep [ 'SiretSiege' ];
$identite -> Siege = $entrep [ 'Siege' ];
$identite -> TribunalCode = $entrep [ 'Tribunal' ];
$identite -> TribunalLib = $entrep [ 'TribunalLib' ];
$identite -> NumRC = $entrep [ 'numRC' ]; // Ajouté le 4 08 2009
$identite -> Actif = $entrep [ 'Actif' ];
$identite -> EntActiveRCS = $entrep [ 'EntActiveRCS' ];
$identite -> AutreId = $entrep [ 'AutreId' ];
$identite -> Source = $entrep [ 'Source' ];
$identite -> SourceId = $entrep [ 'SourceId' ];
$identite -> Isin = $entrep [ 'Isin' ];
$identite -> Nom = strtr ( $entrep [ 'Nom' ], '/*' , ' ' );
$identite -> Nom2 = $entrep [ 'Nom2' ];
$identite -> NomLong = $entrep [ 'nomLong' ]; // Ajouté le 4 08 2009
$identite -> NomCommercial = $entrep [ 'NomCommercial' ]; // Ajouté le 16 11 2010
$identite -> Siret = $entrep [ 'Siret' ];
$identite -> Sigle = $entrep [ 'Sigle' ];
$identite -> SigleLong = $entrep [ 'sigleLong' ]; // Ajouté le 4 08 2009
$identite -> Enseigne = $entrep [ 'Enseigne' ];
$identite -> EnseigneLong = $entrep [ 'enseigneLong' ]; // Ajouté le 16 11 2010
$identite -> Adresse = $entrep [ 'Adresse' ];
$identite -> Adresse2 = $entrep [ 'Adresse2' ];
$identite -> AdresseNum = $entrep [ 'AdresseNum' ];
$identite -> AdresseBtq = $entrep [ 'AdresseBtq' ];
$identite -> AdresseVoie = $entrep [ 'AdresseVoie' ];
$identite -> AdresseRue = $entrep [ 'AdresseRue' ];
$identite -> CP = $entrep [ 'CP' ];
$identite -> Ville = $entrep [ 'Ville' ];
$identite -> Pays = $entrep [ 'Pays' ]; // Ajouté le 18 02 2008
$identite -> PaysIso2 = $entrep [ 'PaysIso2' ];
$identite -> AdresseDom = $entrep [ 'AdresseDom' ];
$tabAdresseDomEnt = array ();
if ( isset ( $entrep [ 'AdresseDomEnt' ]) && count ( $entrep [ 'AdresseDomEnt' ]) > 0 ){
foreach ( $entrep [ 'AdresseDomEnt' ] as $element ){
$adresseDomEnt = new AdresseDomEnt ();
$adresseDomEnt -> siren = $element [ 'siren' ];
$adresseDomEnt -> nom = $element [ 'nom' ];
$tabAdresseDomEnt [] = $adresseDomEnt ;
}
}
$identite -> AdresseDomEnt = $tabAdresseDomEnt ;
$identite -> AdresseDomNb = $entrep [ 'AdresseDomNb' ];
$identite -> Civilite = $entrep [ 'Civilite' ];
$identite -> NbEtab = $entrep [ 'NbEtab' ];
$identite -> Tel = $entrep [ 'Tel' ];
$identite -> Fax = $entrep [ 'Fax' ];
$identite -> Web = $entrep [ 'Web' ];
$identite -> Mail = $entrep [ 'Mail' ];
$identite -> GeoLat = $entrep [ 'GeoLat' ];
$identite -> GeoLon = $entrep [ 'GeoLon' ];
$identite -> GeoPrecis = $entrep [ 'GeoPrecis' ];
$identite -> GeoInfos = $entrep [ 'GeoInfos' ];
$identite -> TvaNumero = $entrep [ 'TvaNumero' ];
$identite -> TvaAttribue = $entrep [ 'TvaAttribue' ];
$identite -> FJ = $entrep [ 'FJ' ];
$identite -> FJ_Lib = $entrep [ 'FJ_lib' ];
$identite -> FJ2 = $entrep [ 'FJ2' ]; // Ajouté le 4 08 2009
$identite -> FJ2_Lib = $entrep [ 'FJ2_Lib' ]; // Ajouté le 4 08 2009
$identite -> Siren = $entrep [ 'Siren' ];
$identite -> Nic = $entrep [ 'Nic' ];
$identite -> NafEnt = $entrep [ 'NafEnt' ];
$identite -> NafEntLib = $entrep [ 'NafEntLib' ];
$identite -> NafEtab = $entrep [ 'NafEtab' ];
$identite -> NafEtabLib = $entrep [ 'NafEtabLib' ];
$identite -> NaceEtab = $entrep [ 'NaceEtab' ];
$identite -> NaceEnt = $entrep [ 'NaceEnt' ];
$identite -> Nafa = $entrep [ 'APRM' ];
$identite -> NafaLib = $entrep [ 'APRM_Lib' ];
$identite -> NumRM = $entrep [ 'NumRM' ];
$identite -> Activite = $entrep [ 'Activite' ];
$identite -> Capital = $entrep [ 'Capital' ];
$identite -> CapitalDev = $entrep [ 'CapitalDev' ];
$identite -> CapitalLib = $entrep [ 'CapitalLib' ]; // Ajouté le 18 02 2008
$identite -> CapitalType = $entrep [ 'CapitalType' ]; // Ajouté le 4 08 2009
$identite -> DateCreaEt = WDate :: dateT ( 'Ymd' , 'Y-m-d' , $entrep [ 'DateCreaEt' ]);
$identite -> DateCreaEn = WDate :: dateT ( 'Ymd' , 'Y-m-d' , $entrep [ 'DateCreaEn' ]);
$identite -> DateClotEt = $entrep [ 'DateClotEt' ]; //@todo : date
$identite -> DateImmat = $entrep [ 'dateImmat' ]; // Ajouté le 4 08 2009
$identite -> DateRadiation = $entrep [ 'dateRad' ]; // Ajouté le 4 08 2009
$identite -> EffEnTr = $entrep [ 'EffEnTr' ];
$identite -> EffEnTrLib = $entrep [ 'EffEnTrLib' ];
$identite -> Effectif = $entrep [ 'Effectif' ];
$identite -> EffEtTr = $entrep [ 'EffEtTr' ]; // Ajout le 11 08 2010
$identite -> EffEtTrLib = $entrep [ 'EffEtTrLib' ]; // Ajout le 11 08 2010
$identite -> EffectifEtab = $entrep [ 'EffectifEtab' ]; // Ajout le 11 08 2010
$identite -> Dept = $entrep [ 'Dept' ];
$identite -> codeCommune = $entrep [ 'codeCommune' ];
$identite -> AnneeEffEn = $entrep [ 'AnneeEffEn' ];
$identite -> AnneeEffEt = $entrep [ 'AnneeEffEt' ];
$identite -> AnneeTCA = $entrep [ 'AnneeTCA' ];
$identite -> TrancheCA = $entrep [ 'TrancheCA' ];
$identite -> TrancheCALib = $entrep [ 'TrancheCALib' ];
$identite -> dir1Code = $entrep [ 'dir1Code' ];
$identite -> dir1Titre = $entrep [ 'dir1Titre' ];
$identite -> dir1NomPrenom = $entrep [ 'dir1NomPrenom' ];
$identite -> dir1DateFct = $entrep [ 'dir1DateFct' ]; //@todo : date
$identite -> dir1DateNaiss = $entrep [ 'dir1DateNaiss' ]; //@todo : date // Ajouté le 4 08 2009
$identite -> dir1LieuNaiss = $entrep [ 'dir1LieuNaiss' ]; // Ajouté le 4 08 2009
$identite -> dir2Code = $entrep [ 'dir2Code' ];
$identite -> dir2Titre = $entrep [ 'dir2Titre' ];
$identite -> dir2NomPrenom = $entrep [ 'dir2NomPrenom' ];
$identite -> dir2DateFct = $entrep [ 'dir2DateFct' ]; //@todo : date
$identite -> dir2DateNaiss = $entrep [ 'dir2DateNaiss' ]; //@todo : date // Ajouté le 4 08 2009
$identite -> dir2LieuNaiss = $entrep [ 'dir2LieuNaiss' ]; // Ajouté le 4 08 2009
$identite -> Rivoli = $entrep [ 'Rivoli' ];
$identite -> InfosIris -> codIris = $entrep [ 'InfosIris' ][ 'codIris' ];
$identite -> InfosIris -> codComIris = $entrep [ 'InfosIris' ][ 'codComIris' ];
$identite -> InfosIris -> libIris = $entrep [ 'InfosIris' ][ 'libIris' ];
$identite -> InfosIris -> typIris = $entrep [ 'InfosIris' ][ 'typIris' ];
$identite -> InfosIris -> evoIris = $entrep [ 'InfosIris' ][ 'evoIris' ];
$identite -> InfosIris -> trIris = $entrep [ 'InfosIris' ][ 'trIris' ];
$identite -> InfosIris -> grdQuartier = $entrep [ 'InfosIris' ][ 'grdQuartier' ];
$identite -> NatureActivite = $entrep [ 'NatureActivite' ]; // Nature de l'activité
$identite -> OrigineCreation = $entrep [ 'OrigineCreation' ]; // Origine de la création
$identite -> TypeExploitation = $entrep [ 'TypeExploitation' ];
$identite -> Auxiliaire = $entrep [ 'Auxiliaire' ]; // 1=Auxiliaire / 0=Non auxiliaire
$identite -> Saisonnalite = $entrep [ 'Saisonnalite' ]; // P=Activité permanente / S=Activité saisonnière
$identite -> SituationJuridique = $entrep [ 'SituationJuridique' ];
$identite -> Bilan -> Cloture = $entrep [ 'bilanDate' ]; //@todo : date
$identite -> Bilan -> Duree = $entrep [ 'bilanMois' ];
$identite -> Bilan -> Devise = $entrep [ 'bilanDevise' ];
$identite -> Bilan -> Capital = $entrep [ 'bilanDA' ];
$identite -> Bilan -> CA = $entrep [ 'bilanFL' ];
$identite -> Bilan -> Resultat = $entrep [ 'bilanHN' ];
$identite -> Bilan -> Effectif = $entrep [ 'bilanYP' ];
$identite -> Bourse -> placeCotation = $bourse [ 'placeCotation' ];
$identite -> Bourse -> nombreTitres = $bourse [ 'nombreTitres' ];
$identite -> Bourse -> capitalisation = $bourse [ 'close' ] * $bourse [ 'nombreTitres' ];
$identite -> Bourse -> derCoursDate = $bourse [ 'date' ]; //@todo : date
$identite -> Bourse -> derCoursCloture = $bourse [ 'close' ]; //@todo : date
$tabAutreSiren = array ();
if ( isset ( $entrep [ 'AutreSiren' ])) {
$autreSiren = new AutreSiren ();
$autreSiren -> siren = $entrep [ 'AutreSiren' ][ 'listeSiren' ][ 'siren' ];
$autreSiren -> type = $entrep [ 'AutreSiren' ][ 'listeSiren' ][ 'type' ];
$tabAutreSiren [] = $autreSiren ;
}
$identite -> AutreSiren = $tabAutreSiren ;
$identite -> DateMajINSEE = $entrep [ 'DateMajINSEE' ]; //@todo : date
$identite -> DateMajRCS = $entrep [ 'DateMajRCS' ]; //@todo : date
$identite -> DateMajBILAN = $entrep [ 'bilanDateMaj' ]; //@todo : date
$identite -> DateMajANN = $entrep [ 'dateMajANN' ]; //@todo : date
$identite -> DateMajID = $entrep [ 'dateMajIdentite' ]; //@todo : date
if ( preg_match ( '/NAF4/i' , $this -> tabInfoUser [ 'pref' ]))
{
$entrep2 = $iInsee -> getNaf4 ( $siren , $nic , $id );
$identite -> Naf4Ent = $entrep2 [ 'apen4' ];
$identite -> Naf4Etab = $entrep2 [ 'apet4' ];
$identite -> Naf4EntLib = $entrep2 [ 'apen4_lib' ];
$identite -> Naf4EtabLib = $entrep2 [ 'apet4_lib' ];
}
$identiteProcol -> Identite = $identite ;
//Eléments annonces légales
$anns = $this -> getAnnonces ( $siren , 1 );
$tabRetAnn = $tabLastEven = array ();
$anns = $anns -> result ;
$tribunalProcol = false ;
foreach ( $anns as $nb => $ann ) {
$tabRetEven = array ();
foreach ( $ann -> evenements as $tabEven ) {
// On ignore les éléments suivants
if ( $tabEven -> CodeEven >= 7000 ) continue ;
if ( $tabEven -> CodeEven >= 4000 && $tabEven -> CodeEven <= 4999 ) continue ;
// Par défaut, on force le tribunal à celui présent dans la dernière annonce de Procol
if ( $tribunalProcol == false && $tabEven -> CodeEven >= 1000 && $tabEven -> CodeEven < 2000 && $ann -> BodaccCode == 'BODA' ) {
$identiteProcol -> TribunalCode = $ann -> TribunalCode ;
$identiteProcol -> TribunalLib = prepareString ( $ann -> Tribunal );
$tribunalProcol = true ;
}
// On ne prend que le dernier élément de chaque type
if ( in_array ( $tabEven -> CodeEven , $tabLastEven )) continue ;
$tabLastEven [] = $tabEven -> CodeEven ;
$tabRetEven [] = $tabEven ;
}
if ( count ( $tabRetEven ) > 0 ) {
$annonce = new Annonce ();
$annonce -> id = $ann -> id ;
$annonce -> BodaccCode = $ann -> BodaccCode ;
$annonce -> BodaccNum = $ann -> BodaccNum ;
$annonce -> NumAnnonce = $ann -> NumAnnonce ;
$annonce -> DateParution = $ann -> DateParution ; //@todo : date
$annonce -> Departement = $ann -> Departement ;
$annonce -> Tribunal = $ann -> Tribunal ;
$annonce -> TribunalCode = $ann -> TribunalCode ;
$annonce -> TribunalSiret = $ann -> TribunalSiret ;
$annonce -> Rubrique = $ann -> Rubrique ;
$annonce -> typeAnnonce = $ann -> typeAnnonce ;
$annonce -> texteRectificatif = $ann -> texteRectificatif ;
$annonce -> texteAnnonce = utf8_encode ( $ann -> texteAnnonce );
$annonce -> dateEffet = $ann -> dateEffet ; //@todo : date
$annonce -> dateJugement = $ann -> dateJugement ; //@todo : date
$annonce -> dateInsertionSD = $ann -> dateInsertionSD ; //@todo : date
$annonce -> evenements = $tabRetEven ;
$annonce -> Lien_Annonce_Pdf = $ann -> Lien_Annonce_Pdf ;
$tabRetAnn [] = $annonce ;
}
}
$identiteProcol -> Annonces = $tabRetAnn ;
$iRncs = new MRncs ();
if ( $entrep [ 'Siege' ] == 1 || $entrep [ 'Siege' ] == 11 ) {
$identiteProcol -> LibTypeEtab = 'Etablissement Siege' ;
} else {
$tabEtabRncs = $iRncs -> getIdentiteEtab ( $siren , $entrep [ 'Nic' ]);
if ( $tabEtabRncs [ 'Siege' ] == 2 ) $identiteProcol -> LibTypeEtab = 'Etablissement Principal' ;
elseif ( $tabEtabRncs [ 'Siege' ] == 1 ) $identiteProcol -> LibTypeEtab = 'Etablissement Complementaire' ;
elseif ( $tabEtabRncs [ 'Siege' ] == 0 ) $identiteProcol -> LibTypeEtab = 'Etablissement Secondaire' ;
}
//@todo
$tabJuge = $iRncs -> getIntervenants ( $siren );
$tabDepots = array ();
foreach ( $tabJuge as $iDepot => $depot ) {
$organe = new Organe ();
$organe -> codEven = $depot [ 'codEven' ];
$organe -> libEven = prepareString ( $depot [ 'libEven' ]);
$organe -> dateEffet = $depot [ 'dateEffet' ];
$organe -> admcode = $depot [ 'admcode' ];
$organe -> admfonction = prepareString ( $depot [ 'admfonction' ]);
$organe -> admnom = prepareString ( $depot [ 'admnom' ]);
$organe -> admadrNum = $depot [ 'admadrNum' ];
$organe -> admadrInd = $depot [ 'admadrInd' ];
$organe -> admadrVoie = $depot [ 'admadrVoie' ]; // @todo : adm1adr1, adm1adr2, adm1adr3,
$organe -> admadrCP = $depot [ 'admadrCP' ];
$organe -> admadrVille = $depot [ 'admadrVille' ];
$tabDepots [] = $organe ;
}
$identiteProcol -> Organes = $tabDepots ;
$mLiens = new MLiens ( $siren );
$tabA = $mLiens -> getActionnaires ( $siren , 1 );
$nbA = count ( $tabA );
$tabAct = array ();
foreach ( $tabA as $i => $lien ) {
$liens = new Actionnaire ();
$liens -> Pmin = $lien [ 'Pmin' ];
$liens -> MajMin = $lien [ 'MajMin' ];
$liens -> RaisonSociale = $lien [ 'RaisonSociale' ];
$liens -> Pays = $lien [ 'Pays' ];
$liens -> Siren = $lien [ 'Siren' ];
$liens -> Actif = $lien [ 'Actif' ];
$tabAct [] = $liens ;
}
$identiteProcol -> Actionnaires = $tabAct ;
$iGreffes = new MGreffes ();
$tabActes = $iGreffes -> getListeActes ( $siren );
$identiteProcol -> StatutsModifDepot = $identiteProcol -> StatutsModif = '0000-00-00' ;
foreach ( $tabActes as $i => $acte ) {
if ( '_' . $acte [ 'acte_type' ] == '_04' ) { // STATUTS CONSTITUTIFS
$identiteProcol -> StatutsConstDepot = $acte [ 'depot_date' ]; // => 1997-12-18
$identiteProcol -> StatutsConst = $acte [ 'acte_date' ]; // => 1997-11-13
break ;
} elseif ( in_array ( '_' . $acte [ 'acte_type' ], array (
//'_04', // STATUTS CONSTITUTIFS
'_06' , // STATUTS A JOUR 9 0000-00-00 2009-09-02 17:05:55
'_07' , // STATUTS A JOUR 9 0000-00-00 2009-09-02 17:05:55
'_08' , // STATUTS A JOUR ET DECLARATION DE CONFORMITE 9 0000-00-00 2009-09-02 17:05:55
'_09' , // STATUTS APRES TRANSFERT DE SIEGE 9 0000-00-00 2009-09-02 17:05:55
'_A1' , // STATUTS 9 0000-00-00 2009-09-02 17:05:55
'_AH' , // AVENANT AUX STATUTS
))) {
// On ne prend que la dernière modif
if ( $identiteProcol -> StatutsModifDepot == '0000-00-00' && $identiteProcol -> StatutsModif == '0000-00-00' ) {
$identiteProcol -> StatutsModifDepot = $acte [ 'depot_date' ]; // => 1997-12-18
$identiteProcol -> StatutsModif = $acte [ 'acte_date' ]; // => 1997-11-13
}
}
}
/** Y a t il eu des informations relatives à une cession ? **/
$tabCes = $iGreffes -> getInfosCessions ( $siren );
if ( $tabCes ) {
$identiteProcol -> CessionJugeLib = $tabCes [ 'cessJuge' ];
$identiteProcol -> CessionJugeDate = $tabCes [ 'cessDateJuge' ];
$identiteProcol -> CessionAvisBodac = $tabCes [ 'cessDateBod' ];
$identiteProcol -> CessionInvenDate = $tabCes [ 'cessDateInv' ];
$identiteProcol -> CessionCAdeclare = $tabCes [ 'cessCAdec' ];
$identiteProcol -> CessionEffectif = $tabCes [ 'cessEffectif' ];
$identiteProcol -> CessionDesc = $tabCes [ 'cessDesc' ];
$identiteProcol -> CessionDescDate = $tabCes [ 'cessDateDesc' ];
$identiteProcol -> CessionOffreDate = $tabCes [ 'cessDateLim' ];
$identiteProcol -> CessionMandataire = $tabCes [ 'cessMand' ];
}
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug $siren", print_r($tabRet,true)) ;
debugLog ( 'I' , 'Etablissement retourné = ' . $entrep [ 'Nom' ], __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> wsLog ( 'identite' , $siret , $id );
Zend_Registry :: get ( 'WsLogger' ) -> info ( " getIdentiteProcol : " . print_r ( $identiteProcol , 1 ));
return $identiteProcol ;
}
2011-02-04 11:37:58 +00:00
/**
* 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__ );
2011-02-04 15:28:45 +00:00
if ( strlen ( $siren ) <> 9 ) {
2011-02-04 11:37:58 +00:00
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1010' );
2011-02-04 15:28:45 +00:00
} elseif ( $siren * 1 == 0 ) {
2011-02-04 11:37:58 +00:00
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 ;
2011-02-04 15:28:45 +00:00
$output -> result = $result ;
2011-02-04 11:37:58 +00:00
return $output ;
}
/**
* Retourne l 'ensemble des informations identitaires des dirigeants de l' entreprise
*
2011-04-19 06:22:14 +00:00
* @ param string $siren Siren de l ' entreprise
2011-02-04 11:37:58 +00:00
* @ 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 ();
2011-02-04 15:28:45 +00:00
if ( strlen ( $siren ) <> 9 ) {
2011-02-04 11:37:58 +00:00
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1010' );
2011-02-04 15:28:45 +00:00
} elseif ( $siren * 1 == 0 ) {
2011-02-04 11:37:58 +00:00
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1010' );
}
2011-02-04 15:28:45 +00:00
if ( $histo ) $option = 'histo' ;
else $option = '' ;
2011-02-04 11:37:58 +00:00
$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 -> 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
2011-05-02 07:32:19 +00:00
* @ param string $idAnn Identifiant de l ' annonce
2011-02-04 11:37:58 +00:00
* @ param integer $position
* @ param integer $nbRep
* @ return AnnoncesReturn
*/
2011-05-02 07:32:19 +00:00
public function getAnnonces ( $siren , $filtre = 0 , $idAnn = '' , $position = 0 , $nbRep = 100 )
2011-02-04 11:37:58 +00:00
{
$this -> authenticate ();
//Initialisation
if ( empty ( $filtre )) { $filtre = 0 ; }
2011-05-09 08:27:03 +00:00
if ( empty ( $idAnn )) { $idAnn = '' ; }
2011-02-04 11:37:58 +00:00
if ( empty ( $position )) { $position = 0 ; }
2011-02-10 16:34:16 +00:00
if ( empty ( $nbRep )) { $nbRep = 100 ; }
2011-02-04 11:37:58 +00:00
//Valeur max
if ( $nbRep > 200 ) { $nbRep = 200 ; }
debugLog ( 'I' , " Annonces demandées pour $siren ( $filtre , $idAnn ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$liste = array ();
2011-06-08 12:36:18 +00:00
if ( strlen ( $siren ) <> 9 ) {
2011-02-04 11:37:58 +00:00
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1010' );
2011-06-08 12:36:18 +00:00
} elseif ( $siren * 1 == 0 && $idAnn == '' ) {
2011-02-04 11:37:58 +00:00
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 ;
} */
2011-05-09 08:27:03 +00:00
if ( $idAnn == '' ) {
2011-02-04 11:37:58 +00:00
$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
2011-02-07 09:39:30 +00:00
* @ return Indiscore
2011-02-04 11:37:58 +00:00
*/
public function getIndiScore ( $siren , $nic = 0 , $niveau = 2 , $plus = false )
{
$this -> authenticate ();
$perm = false ;
switch ( $niveau ){
case 1 :
2011-05-23 15:05:49 +00:00
if ( ! $this -> checkPerm ( 'indiscore' ) || ! $this -> checkPerm ( 'indiscorep' ) ){
2011-02-04 11:37:58 +00:00
$this -> permission ( 'indiscore' );
}
break ;
case 2 :
2011-05-23 15:05:49 +00:00
if ( ! $this -> checkPerm ( 'indiscore2' ) || ! $this -> checkPerm ( 'indiscore2p' ) ){
2011-02-04 11:37:58 +00:00
$this -> permission ( 'indiscore2' );
}
break ;
case 3 :
2011-05-23 15:05:49 +00:00
if ( ! $this -> checkPerm ( 'indiscore3' ) || ! $this -> checkPerm ( 'indiscore3p' ) ){
2011-02-04 11:37:58 +00:00
$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 ; }
$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__ );
2011-02-04 14:34:18 +00:00
$this -> sendError ( '1010' );
2011-02-04 11:37:58 +00:00
}
2011-02-04 14:34:18 +00:00
$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__ );
2011-05-23 15:46:06 +00:00
/*
2011-02-04 11:37:58 +00:00
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' );
2011-05-23 15:46:06 +00:00
} */
2011-02-04 14:34:18 +00:00
2011-02-07 11:14:37 +00:00
Zend_Registry :: get ( 'WsLogger' ) -> info ( " INDISCORE : " . print_r ( $tabRet , 1 ));
2011-02-07 09:39:30 +00:00
$output = new Indiscore ();
2011-02-04 11:37:58 +00:00
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 ;
2011-02-07 09:39:30 +00:00
$output -> paiements = $paiement ;
2011-02-04 11:37:58 +00:00
} elseif ( $key == 'Notes_Structure' ) {
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
$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' ];
2011-02-07 09:39:30 +00:00
$output -> Notes_Structure = $notesStructure ;
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
} elseif ( $key == 'tabBilans' ) {
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
$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 ;
}
2011-02-07 09:39:30 +00:00
$output -> tabBilans = $tabRet ;
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
} elseif ( $key == 'tabBilan' ) {
2011-02-07 09:39:30 +00:00
2011-02-07 11:14:37 +00:00
$tabRet = array ();
foreach ( $value as $bilan ){
$resultBilan = new Bilan ();
$tabPoste = array ();
foreach ( $bilan as $bilan_key => $bilan_value ){
if ( ! in_array ( $bilan_key , array ( 'SIREN' , 'DATE_FRAICHE_BILAN' ,
'DATE_CLOTURE' , 'DATE_CLOTURE_PRE' , 'DUREE_MOIS' ,
'DUREE_MOIS_PRE' , 'MONNAIE' , 'CONSOLIDE' , 'MONNAIE_ORI' ,
'MONNAIE_LIV_UNITE' , 'SOURCE' , 'devise' ))){
$resultPoste = new BilanPoste ();
$resultPoste -> id = $bilan_key ;
$resultPoste -> val = $bilan_value ;
$tabPoste [] = $resultPoste ;
} else {
$resultBilan -> $bilan_key = $bilan_value ;
}
}
$resultBilan -> POSTES = $tabPoste ;
$tabRet [] = $resultBilan ;
}
$output -> tabBilan = $tabRet ;
2011-02-07 09:39:30 +00:00
2011-02-04 11:37:58 +00:00
} elseif ( $key == 'tabInfosNotations' ) {
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
$infosNotation = new IndiscoreInfosNotations ();
$infosNotation -> SituationFinanciere = $value [ 'SituationFinanciere' ];
$infosNotation -> Notation = $value [ 'Notation' ];
$infosNotation -> ProbabiliteDefaut = $value [ 'ProbabiliteDefaut' ];
2011-02-07 09:39:30 +00:00
$output -> tabInfosNotations = $infosNotation ;
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
} elseif ( $key == 'tabImportExport' ) {
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
$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 ;
}
2011-02-07 09:39:30 +00:00
$output -> tabImportExport = $tabRet ;
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
} elseif ( $key == 'tabCommentaires' ) {
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
$tab = array ();
foreach ( $value as $comment ) {
$tab [] = $comment ;
}
2011-02-07 09:39:30 +00:00
$output -> tabCommentaires = $tab ;
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
} elseif ( $key == 'tabVariables' ) {
2011-02-07 11:14:37 +00:00
2011-02-04 11:37:58 +00:00
$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 ;
2011-02-07 09:39:30 +00:00
$output -> tabVariables = $variables ;
2011-02-04 11:37:58 +00:00
} else {
2011-02-07 09:39:30 +00:00
$output -> $key = $value ;
2011-02-04 11:37:58 +00:00
}
}
2011-02-04 14:34:18 +00:00
$this -> wsLog ( 'indiscore' , $siren );
2011-02-04 11:37:58 +00:00
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
2011-02-04 15:28:45 +00:00
* @ param integer $position
* @ param integer $nbRep
2011-02-04 11:37:58 +00:00
* @ return InseeReturn
**/
2011-02-04 15:28:45 +00:00
public function getListeEvenements ( $siren , $nic = 0 , $position = 0 , $nbRep = 1000 )
2011-02-04 11:37:58 +00:00
{
$this -> authenticate ();
$this -> permission ( 'eveninsee' );
//Initialisation
if ( empty ( $nic )) { $nic = 0 ; }
2011-02-04 15:28:45 +00:00
if ( empty ( $position )) { $position = 0 ; }
if ( empty ( $nbRep ) || $nbRep > 1000 ) { $nbRep = 1000 ; }
2011-02-04 11:37:58 +00:00
debugLog ( 'I' , " Liste des évènements pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
2011-02-04 15:28:45 +00:00
if ( strlen ( $siren ) <> 9 ) {
2011-02-04 11:37:58 +00:00
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1010' );
2011-02-04 15:28:45 +00:00
} elseif ( $siren * 1 == 0 ) {
2011-02-04 11:37:58 +00:00
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1010' );
}
$iInsee = new MInsee ();
2011-02-04 15:28:45 +00:00
$evens = $iInsee -> getEvenements ( $siren , $nic , $position , $nbRep );
2011-02-04 11:37:58 +00:00
$tabRet = array ();
2011-02-04 15:28:45 +00:00
if ( count ( $evens ) > 0 ) {
foreach ( $evens as $nb => $even ) {
2011-02-04 11:37:58 +00:00
$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 ;
}
}
2011-02-04 15:28:45 +00:00
2011-02-04 11:37:58 +00:00
debugLog ( 'I' , 'Nb évènements retournés = ' . count ( $tabRet ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-02-04 14:34:18 +00:00
$this -> wsLog ( 'evenements' , $siren );
2011-02-04 11:37:58 +00:00
$output = new InseeReturn ();
2011-02-04 15:28:45 +00:00
$output -> nbReponses = count ( $tabRet ); // @todo : retrouver le nombre total d'évenements
2011-02-04 11:37:58 +00:00
$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' ]);
2011-05-09 12:38:06 +00:00
2011-02-04 11:37:58 +00:00
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 ) {
2011-06-15 10:21:24 +00:00
Zend_Registry :: get ( 'WsLogger' ) -> info ( " rechercheEntreprise - " . serialize ( $criteres ));
2011-02-04 11:37:58 +00:00
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 ) {
2011-06-15 10:21:24 +00:00
Zend_Registry :: get ( 'WsLogger' ) -> info ( " rechercheEntreprise - " . serialize ( $criteres ));
2011-02-04 11:37:58 +00:00
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 ) {
2011-06-15 10:21:24 +00:00
Zend_Registry :: get ( 'WsLogger' ) -> info ( " rechercheEntreprise - " . serialize ( $criteres ));
2011-02-04 11:37:58 +00:00
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 (
2011-05-09 12:38:06 +00:00
cleanstring ( $dirCriteres -> nom ),
cleanstring ( $dirCriteres -> prenom ),
$dirCriteres -> dateNaiss ,
cleanstring ( $dirCriteres -> lieuNaiss ),
2011-02-04 11:37:58 +00:00
empty ( $position ) ? 0 : $position ,
empty ( $nbRep ) ? 20 : $nbRep ,
empty ( $maxRep ) ? 200 : $maxRep ,
empty ( $pertinence ) ? false : $pertinence
);
} catch ( SoapFault $fault ) {
2011-06-15 10:21:24 +00:00
Zend_Registry :: get ( 'WsLogger' ) -> info ( " rechercheEntreprise - " . serialize ( $criteres ));
2011-02-04 11:37:58 +00:00
throw new SoapFault ( $fault -> faultcode , $fault -> faultstring );
exit ;
}
break ;
}
$error = new ErrorType ();
$error = arrayToClass ( $O [ 'error' ], 'ErrorType' );
2011-04-11 12:31:16 +00:00
2011-02-04 11:37:58 +00:00
$results = new RechercheEntrepriseResult ();
2011-04-11 12:31:16 +00:00
switch ( $type ){
case 'ent' :
$results -> criteres = $entCriteres ;
break ;
case 'dir' :
$results -> criteres = $dirCriteres ;
break ;
}
$results -> info = $O [ 'results' ][ 'info' ];
$results -> nbReponses = $O [ 'results' ][ 'nbReponses' ];
$results -> nbReponsesTotal = $O [ 'results' ][ 'nbReponsesTotal' ];
$results -> duree = $O [ 'results' ][ 'duree' ];
$results -> erreur = $O [ 'results' ][ 'erreur' ];
$results -> pass = $O [ 'results' ][ 'pass' ];
$reponse = array ();
if ( count ( $O [ 'results' ][ 'reponses' ]) > 0 ){
foreach ( $O [ 'results' ][ 'reponses' ] as $item ) {
$reponse [] = arrayToClass ( $item , 'RechercheEntrepriseReponses' );
}
}
$results -> reponses = $reponse ;
2011-02-04 11:37:58 +00:00
$outputParams = new RechercheEntrepriseReturn ();
$outputParams -> error = $error ;
$outputParams -> results = $results ;
return $outputParams ;
}
2011-05-26 12:39:17 +00:00
/**
* Recherche entreprise par nom et adresse
* @ param unknown_type $raisonSociale
* @ param unknown_type $adresse
* @ param unknown_type $codePostal
* @ param unknown_type $ville
* @ param unknown_type $siege
* @ param unknown_type $actif
* @ param integer $deb
* @ param integer $nbRep
* @ param integer $maxRep
* @ param boolean $pertinence
* @ param boolean $avecSiren
* @ param string $ape_etab
*/
protected function searchNomAdr ( $raisonSociale , $adresse = '' , $codePostal = '' , $ville = '' , $siege = '' , $actif = '' , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false , $avecSiren = false , $ape_etab = '' )
{
debugLog ( 'I' , " Recherche Entreprise de $raisonSociale , $adresse , $codePostal $ville (Siège= $siege / Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iInsee = new MInsee ();
$etabs = $iInsee -> rechercheEtab ( $raisonSociale , $adresse , $codePostal , $ville , $siege , $actif , $deb , $nbRep , $maxRep , $pertinence , $avecSiren , $ape_etab );
$recherche = new RechercheEntrepriseResult ();
$tabRet = array ();
foreach ( $etabs [ 'reponses' ] as $etab ) {
$reponse = new RechercheEntrepriseReponses ();
$reponse -> id = $etab [ 'id' ];
$reponse -> Pertinence = $etab [ 'Pertinence' ];
$reponse -> Siret = $etab [ 'Siret' ];
$reponse -> Siege = $etab [ 'Siege' ];
$reponse -> Nom = strtr ( $etab [ 'Nom' ], '/*' , ' ' );
$reponse -> Nom2 = $etab [ 'Nom2' ];
$reponse -> Sigle = $etab [ 'Sigle' ];
$reponse -> Enseigne = $etab [ 'Enseigne' ];
$reponse -> Adresse = $etab [ 'Adresse' ];
$reponse -> Adresse2 = $etab [ 'Adresse2' ];
$reponse -> CP = $etab [ 'CP' ];
$reponse -> Ville = $etab [ 'Ville' ];
$reponse -> Tel = $etab [ 'Tel' ];
$reponse -> Fax = $etab [ 'Fax' ];
$reponse -> FJ = $etab [ 'FJ' ];
$reponse -> FJLib = $this -> iInsee -> getLibelleFJ ( $etab [ 'FJ' ]);
$reponse -> Siren = $etab [ 'Siren' ];
$reponse -> Nic = $etab [ 'Nic' ];
$reponse -> Actif = $etab [ 'Actif' ];
$reponse -> NafEtab = $etab [ 'NafEtab' ]; // Etablissement
$reponse -> NafEtabLib = $iInsee -> getLibelleNaf ( $etab [ 'NafEtab' ]); // Etablissement
$reponse -> NafEnt = $etab [ 'NafEnt' ]; // Entreprise
$reponse -> NafEntLib = $iInsee -> getLibelleNaf ( $etab [ 'NafEnt' ]);
$tabRet [] = $reponse ;
}
2011-02-04 11:37:58 +00:00
2011-05-26 12:39:17 +00:00
2011-09-07 16:03:34 +00:00
$fp =@ fopen ( LOG_PATH . '/recherches.log' , 'a' );
2011-05-26 12:39:17 +00:00
$siretTrouve = 0 ;
if ( $etabs [ 'nbReponses' ] == 0 ) {
$str = " NbRep=0, S= $raisonSociale , R= $adresse , L= $codePostal , V= $ville , A= $ape_etab , ( $deb , $nbRep , $maxRep , $siege , $actif , $pertinence , $avecSiren ), SiretTrouve= $siretTrouve " ;
@ fwrite ( $fp , $str . EOL );
@ fclose ( $fp );
debugLog ( 'I' , " rechercheEtab : AUCUN RESULTAT, S= $raisonSociale , R= $adresse , L= $codePostal , V= $ville , A= $ape_etab ( $siege , $actif , $deb , $nbRep , $maxRep , $pertinence , $avecSiren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 100 , 'errmsg' => 'Pas de reponse' ), 'results' => $tabRet );
}
else
{
if ( $etabs [ 'nbReponses' ] == 1 ) $siretTrouve = $etabs [ 'reponses' ][ 0 ][ 'Siret' ];
$str = " NbRep= " . $etabs [ 'nbReponses' ] . " , S= $raisonSociale , R= $adresse , L= $codePostal , V= $ville , A= $ape_etab , ( $deb , $nbRep , $maxRep , $siege , $actif , $pertinence , $avecSiren ), SiretTrouve= $siretTrouve " ;
@ fwrite ( $fp , $str . EOL );
@ fclose ( $fp );
debugLog ( 'I' , " rechercheEtab : " . $tabRet [ 'nbReponses' ] . " RESULTATS, S= $raisonSociale , R= $adresse , L= $codePostal , V= $ville , A= $ape_etab ( $siege , $actif , $deb , $nbRep , $maxRep , $pertinence , $avecSiren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
$results = new RechercheEntrepriseResult ();
$error = new ErrorType ();
$searchNomAdr = new RechercheEntrepriseReturn ();
$searchNomAdr -> error = $error ;
$searchNomAdr -> results = $results ;
}
protected function searchSiren (){}
protected function searchDir (){}
protected function searchTelFax (){}
2011-02-04 11:37:58 +00:00
/**
* 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 ();
2011-02-04 15:28:45 +00:00
if ( strlen ( $siren ) <> 9 ) {
2011-02-04 11:37:58 +00:00
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1010' );
2011-02-04 15:28:45 +00:00
} elseif ( $siren * 1 == 0 ) {
2011-02-04 11:37:58 +00:00
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1010' );
}
debugLog ( 'I' , " Avant getIdentiteEntreprise( $siren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iInsee = new MInsee ();
$entrep = $iInsee -> getIdentiteEntreprise ( $siren );
debugLog ( 'I' , " Après getIdentiteEntreprise( $siren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( empty ( $entrep ))
{
debugLog ( 'W' , " Siren $siren non présent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> sendError ( '1020' );
}
debugLog ( 'I' , " Avant MTva( $siren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iTva = new MTva ( $siren );
if ( $iTva -> vatDefined ) $tva = $iTva -> vatNumber ;
else $tva = 'N/A' ;
debugLog ( 'I' , " Après MTva( $siren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$output = new TvaReturn ();
$output -> id = $entrep [ 'id' ];
$output -> AutreId = $entrep [ 'AutreId' ];
$output -> Nom = $entrep [ 'Nom' ];
$output -> Sigle = $entrep [ 'Sigle' ];
$output -> Enseigne = $entrep [ 'Enseigne' ];
$output -> Adresse = $entrep [ 'Adresse' ];
$output -> Adresse2 = $entrep [ 'Adresse2' ];
$output -> CP = $entrep [ 'CP' ];
$output -> Ville = $entrep [ 'Ville' ];
$output -> Siren = $entrep [ 'Siren' ];
$output -> Tva = $tva ;
debugLog ( 'I' , " TVA retournée = $tva ( " . $entrep [ 'Nom' ] . ')' , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$this -> wsLog ( 'tva' , $siren );
return $output ;
}
/**
* Retourne tout ou patie des informations règlementées sur l ' entreprise
*
* @ param string $siren SIREN de l ' entreprise
* @ param mixed $id Id du communiqué
* @ return InfosRegReturn
*/
public function getInfosReg ( $siren , $id = false )
{
$this -> authenticate ();
//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
2011-02-07 09:39:30 +00:00
* @ return InfosBourse
2011-02-04 11:37:58 +00:00
*/
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' ];
2011-05-20 14:38:01 +00:00
$result -> RaisonSociale = $bourse [ 'raisonSociale' ];
$result -> Adresse = $bourse [ 'adresse' ];
2011-02-04 11:37:58 +00:00
$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' ];
2011-05-20 14:38:01 +00:00
$result -> DateIntroduction = $bourse [ 'dateIntroduction' ]; //@todo : date
$result -> DateDerAG = $bourse [ 'dateDerAG' ]; //@todo : date
$result -> DateRadiation = $bourse [ 'dateRadiation' ]; //@todo : date
2011-02-04 11:37:58 +00:00
$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 );
2011-02-07 09:39:30 +00:00
return $result ;
2011-02-04 11:37:58 +00:00
}
/**
* 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
2011-02-04 15:28:45 +00:00
* @ param integer $nbRep
2011-02-04 11:37:58 +00:00
* @ 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 ;
}
/**
* 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
2011-02-07 09:39:30 +00:00
* @ return Bilan
2011-02-04 11:37:58 +00:00
*/
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 ;
}
}
2011-02-04 14:34:18 +00:00
$this -> wsLog ( 'bilan' , $siren , $millesime . ':' . $typeBilan . ':' . $ref );
2011-02-04 11:37:58 +00:00
$resultBilan -> POSTES = $tabPoste ;
2011-02-07 09:39:30 +00:00
return $resultBilan ;
2011-02-04 11:37:58 +00:00
}
/**
* 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__ );
2011-02-04 14:34:18 +00:00
$this -> wsLog ( 'listebilans' , $siren );
2011-02-04 11:37:58 +00:00
$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__ );
2011-03-08 10:05:05 +00:00
if ( strlen ( $dateAnnee ) == 4 ) $annee = $dateAnnee ;
else $annee = substr ( $dateAnnee , 0 , 4 );
2011-02-04 11:37:58 +00:00
$iDb = new WDB ( 'jo' );
switch ( strtoupper ( $source ))
{
case 'BODA' :
case 'BODB' :
case 'BODC' :
$lettre = substr ( strtoupper ( $source ), 3 , 1 );
2011-03-08 10:05:05 +00:00
if ( $annee < 2005 ) {
2011-02-04 11:37:58 +00:00
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 " ,
2011-03-08 10:05:05 +00:00
" e.JAL= $numJAL AND e.NOBOD= $numParution AND e.`DATE` BETWEEN $anneeDeb AND $anneeFin AND e.NOANN= $numAnnonce AND e.ANBASE=t.annonceNum " , false , MYSQL_ASSOC );
2011-02-04 11:37:58 +00:00
} 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' ,
2011-03-08 10:05:05 +00:00
" Bodacc_Code=' $lettre ' AND Bodacc_Annee_Parution= $annee AND Bodacc_Num= $numParution AND Num_Annonce= $numAnnonce " , false , MYSQL_ASSOC );
2011-02-04 11:37:58 +00:00
}
break ;
case 'ASSO' :
2011-03-08 10:05:05 +00:00
$res = $iDb -> select ( 'asso' ,
'YEAR(Date_Parution) AS Annee_Parution, Num_Parution, Num_Annonce, pageDeb AS Num_Page, Date_Parution, Departement, codTribunal AS Tribunal_Code, typeAnnonce, Annonce_Html AS annonce' , " Date_Parution BETWEEN ' $annee -01-01' AND ' $annee -12-31' AND Num_Parution= $annee " . sprintf ( '%04d' , $numParution ) . " AND Num_Annonce= $numAnnonce " ,
false , MYSQL_ASSOC );
2011-02-04 11:37:58 +00:00
break ;
case 'BALO' :
2011-03-08 10:05:05 +00:00
$res = $iDb -> select ( 'balo' ,
" YEAR(Date_Parution) AS Annee_Parution, Num_Parution, Num_Affaire AS Num_Annonce, '' AS Num_Page, Date_Parution, '' AS Departement, '' AS Tribunal_Code, 'Insertion' AS typeAnnonce, Annonce_Html AS annonce " , " Date_Parution BETWEEN ' $annee -01-01' AND ' $annee -12-31' AND Num_Parution= $numParution AND Num_Affaire= $numAnnonce " ,
false , MYSQL_ASSOC );
2011-02-04 11:37:58 +00:00
break ;
}
2011-03-08 10:05:05 +00:00
2011-02-04 11:37:58 +00:00
if ( count ( $res ) > 0 )
{
$iBodacc = new MBodacc ();
2011-03-08 10:05:05 +00:00
foreach ( $res as $i => $etab )
2011-02-04 11:37:58 +00:00
{
2011-03-08 10:05:05 +00:00
$annonces = new RechercheAnnonce ();
2011-02-04 11:37:58 +00:00
$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
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__ );
2011-02-04 15:28:45 +00:00
$this -> sendError ( '1010' );
2011-02-04 11:37:58 +00:00
} elseif ( $siren * 1 == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-02-04 15:28:45 +00:00
$this -> sendError ( '1010' );
}
debugLog ( 'I' , " Liste des Ratios demandée pour $siren avant getIdentiteEntreprise " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iInsee = new MInsee ();
$tabIdentite = $iInsee -> getIdentiteEntreprise ( $siren , 0 , 0 , false , false );
debugLog ( 'I' , " Liste des Ratios demandée pour $siren après getIdentiteEntreprise " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$naf = $tabIdentite [ 'NafEnt' ];
$nafLib = $tabIdentite [ 'NafEntLib' ];
$efftr = $tabIdentite [ 'Effectif' ] * 1 ;
$fj = $tabIdentite [ 'FJ' ];
2011-02-04 11:37:58 +00:00
2011-02-04 15:28:45 +00:00
$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 ) {
2011-02-04 11:37:58 +00:00
2011-02-04 15:28:45 +00:00
//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 ];
2011-02-04 11:37:58 +00:00
}
2011-02-04 15:28:45 +00:00
}
2011-02-04 11:37:58 +00:00
2011-02-04 15:28:45 +00:00
// 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 );
2011-02-04 11:37:58 +00:00
}
2011-02-04 15:28:45 +00:00
$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 ;
2011-02-04 11:37:58 +00:00
}
2011-02-04 15:28:45 +00:00
$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' ];
2011-02-04 11:37:58 +00:00
}
2011-02-04 15:28:45 +00:00
$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' ];
2011-02-04 11:37:58 +00:00
}
}
2011-02-04 15:28:45 +00:00
//$tabRatiosSecteurs=array(count($tabTmp), "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC");
2011-02-07 09:39:30 +00:00
$output = new RatiosReturn ();
$output -> Nom = $tabIdentite [ 'Nom' ];
$output -> NafEnt = $tabIdentite [ 'NafEnt' ];
$output -> NafEntLib = $tabIdentite [ 'NafEntLib' ];
$output -> FJ = $fj ;
$output -> FJ_lib = $tabIdentite [ 'FJ_lib' ];
$output -> Siren = $siren ;
$output -> NbEntNaf = $nbRatiosSec ;
$output -> BilansInfos = $tabBilansR ;
$output -> RatiosInfos = $tabRatiosInfos ;
$output -> RatiosSecteur = $tabRatiosSecteurs ;
2011-02-04 15:28:45 +00:00
//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 );
return $output ;
2011-02-04 11:37:58 +00:00
}
/**
* getRapport
* @ param string $siren
* @ param integer $niveau
* @ param integer $id
2011-02-07 09:39:30 +00:00
* @ return Rapport
2011-02-04 11:37:58 +00:00
*/
public function getRapport ( $siren , $niveau = 3 , $id = 0 )
{
$this -> authenticate ();
if ( empty ( $niveau )) $niveau = 3 ;
if ( empty ( $id )) $id = 0 ;
$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 );
}
2011-02-07 09:39:30 +00:00
return $result ;
2011-02-04 11:37:58 +00:00
}
/**
* 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__ );
2011-02-04 15:28:45 +00:00
if ( intval ( $siren ) <= 1000 ) {
$this -> sendError ( '1010' );
}
$res = $iDb -> select ( 'banques' , 'codeBanque, codeGuichet, libBanqueGuichet, precis, dateSource*1 AS dateSource' , " siren= $siren " , false , MYSQL_ASSOC );
$tmp = $iDb -> select ( 'fedRib' , " codeBanque, codeGuichet, CONCAT(libBanque,' ',libGuichet) AS libBanqueGuichet, 0 AS precis, IF (dateInfo='0000-00-00', dateDispo*1, dateInfo*1) AS dateSource " , " siren= $siren " , false , MYSQL_ASSOC );
$res = array_merge ( $res , $tmp );
foreach ( $res as $tabBanque ){
$dateSource = $tabBanque [ 'dateSource' ];
$codBanque = $tabBanque [ 'codeBanque' ];
$codGuichet = $tabBanque [ 'codeGuichet' ];
$libBanque = trim ( $tabBanque [ 'libBanqueGuichet' ]);
$found = false ;
$adrBanque1 = $adrBanque2 = $adrBanqueCP = $adrBanqueVille = '' ;
if ( $codBanque > 0 && $codGuichet > 0 &&
$dateSource > ( date ( 'Y' ) - 4 ) * 10000 + 101 &&
$dateSource < date ( 'Ymd' )){
$tmp = $iDb -> select ( 'insee.BDF_Etabs b, insee.BDF_Guichets g' ,
'g.bdfFibCodeEtab AS banque, g.bdfFibCodeGuichet AS guichet, b.bdfFibDenom40 AS nomBanque, b.bdfFibDenom10 AS sigleBanque, g.bdfFibDenom20 AS nomGuichet, g.bdfFibAdresse1 AS adresse1, g.bdfFibAdresse2 AS adresse2, g.bdfFibAdresse3 AS adresse3, g.CP, g.Ville' , " g.bdfFibCodeEtab= $codBanque AND g.bdfFibCodeGuichet= $codGuichet AND b.bdfFibCodeEtab=g.bdfFibCodeEtab " ,
false , MYSQL_ASSOC );
2011-02-04 11:37:58 +00:00
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' ];
2011-02-04 15:28:45 +00:00
$found = true ;
};
2011-02-04 11:37:58 +00:00
}
2011-02-04 15:28:45 +00:00
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 ;
2011-02-04 11:37:58 +00:00
}
debugLog ( 'I' , " Liste des banques pour siren $siren : " . count ( $tabRet ) . ' banques' , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-02-04 15:28:45 +00:00
2011-02-04 14:34:18 +00:00
$this -> wsLog ( 'banque' , $siren );
2011-02-04 11:37:58 +00:00
$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' );
2011-05-26 12:39:17 +00:00
if ( ! $db ) {
2011-02-15 10:04:53 +00:00
$error -> statusCode = 9000 ;
$error -> statusMsg = $this -> listError [ '9000' ];
2011-05-26 12:39:17 +00:00
} else {
$error -> statusCode = 3000 ;
$error -> statusMsg = $this -> listError [ '3000' ];
2011-02-04 11:37:58 +00:00
}
return $error ;
}
}
?>