2010-08-30 07:49:44 +00:00
< ? php
2010-11-25 10:40:35 +00:00
require_once realpath ( dirname ( __FILE__ )) . '/WsScore.php' ;
2010-08-30 07:49:44 +00:00
require_once realpath ( dirname ( __FILE__ )) . '/functions.php' ;
2010-11-18 16:53:20 +00:00
require_once realpath ( dirname ( __FILE__ )) . '/Types/EntrepriseTypes.php' ;
2010-08-30 07:49:44 +00:00
2010-11-25 10:40:35 +00:00
class WsEntreprise extends WsScore
2010-09-13 09:54:49 +00:00
{
2010-09-21 15:19:32 +00:00
protected $wsdl = null ;
protected $wsdlOptions = array ();
2010-11-25 10:34:00 +00:00
public function __construct ()
2010-09-21 15:19:32 +00:00
{
2010-12-02 16:26:07 +00:00
parent :: __construct ();
2010-09-21 15:19:32 +00:00
$webservicesConfig = Zend_Registry :: get ( 'webservicesConfig' ) -> webservice -> scores ;
$wsdl = ! empty ( $webservicesConfig -> wsdl ) ? $webservicesConfig -> wsdl : null ;
$options = array ();
foreach ( $webservicesConfig -> options as $optionName => $optionValue ){
$options [ $optionName ] = $optionValue ;
}
$options [ 'login' ] = $_SERVER [ 'PHP_AUTH_USER' ];
$options [ 'password' ] = $_SERVER [ 'PHP_AUTH_PW' ];
$this -> wsdl = $wsdl ;
$this -> wsdlOptions = $options ;
}
2010-08-30 07:49:44 +00:00
/**
* Retourne les informations identitaires de l 'entreprise ou de l' établissement demandé
2010-11-10 13:37:07 +00:00
* @ param string $siret Siren de l 'entreprise ou siret de l' établissement
* @ param int $id Identifiant interne
* @ param boolean $forceVerif
2010-11-08 17:25:06 +00:00
* @ return IdentiteReturn
2010-08-30 07:49:44 +00:00
*/
2010-11-08 17:25:06 +00:00
public function getIdentite ( $siret , $id = 0 , $forceVerif = false )
2010-09-13 09:54:49 +00:00
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-10 13:37:07 +00:00
//Initialisation
2010-11-10 15:22:15 +00:00
if ( empty ( $id )) { $id = 0 ; }
2010-11-24 13:05:09 +00:00
if ( empty ( $forceVerif )) { $forceVerif = false ; }
2010-11-10 13:37:07 +00:00
2010-11-08 17:25:06 +00:00
$outputParams = new IdentiteReturn ();
2010-11-05 09:54:50 +00:00
$error = new ErrorType ();
2010-11-08 17:25:06 +00:00
$result = new IdentiteResult ();
2010-11-05 09:54:50 +00:00
$tdeb = microtime ( 1 );
$ligne = date ( 'YmdHis' ) . " ; $siret ;Ws->getIdentite Avant ... " ;
$fp = fopen ( LOG_PATH . '/accesDistant.log' , 'a' );
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
2010-09-13 09:54:49 +00:00
2010-11-05 09:54:50 +00:00
debugLog ( 'I' , " Identités demandée pour siret $siret (id= $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$siret = trim ( $siret );
$len = strlen ( $siret );
2010-11-10 13:37:07 +00:00
$siren = substr ( $siret , 0 , 9 );
if ( $len == 14 )
{
$nic = substr ( $siret , 9 , 5 ) * 1 ;
}
elseif ( $len == 9 )
{
$nic = 0 ;
}
2010-11-24 13:05:09 +00:00
if ( $siren * 1 == 0 && $id == 0 )
2010-11-10 13:37:07 +00:00
{
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
2010-11-24 13:05:09 +00:00
elseif ( $len != 14 && $len != 9 )
2010-11-10 13:37:07 +00:00
{
2010-11-05 09:54:50 +00:00
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
2010-11-24 13:05:09 +00:00
$error -> errmsg = 'Siren/Siret incorrect' ;
2010-11-10 13:37:07 +00:00
}
else
{
debugLog ( 'I' , " Avant getIdentiteEntreprise( $siren , $nic , $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
$entrep = $iInsee -> getIdentiteEntreprise ( $siren , $nic , $id , $forceVerif );
2010-11-10 13:37:07 +00:00
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__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
$iBourse = new MBourse ( $siren );
$bourse = $iBourse -> getInfosBourse ( $siren );
$tabRet = array (
'id' => $entrep [ 'id' ],
'Siret' => $entrep [ 'Siret' ],
'SiretSiege' => $entrep [ 'SiretSiege' ],
'Siege' => $entrep [ 'Siege' ],
'TribunalCode' => $entrep [ 'Tribunal' ],
'TribunalLib' => $entrep [ 'TribunalLib' ],
2010-11-25 09:11:42 +00:00
//'NumGreffe' =>$entrep['numGreffe'], // Ajouté le 4 08 2009
'NumRC' => $entrep [ 'numRC' ], // Ajouté le 4 08 2009
2010-11-10 13:37:07 +00:00
'Actif' => $entrep [ 'Actif' ],
'EntActiveRCS' => $entrep [ 'EntActiveRCS' ],
'AutreId' => $entrep [ 'AutreId' ],
'Source' => $entrep [ 'Source' ],
'SourceId' => $entrep [ 'SourceId' ],
'Isin' => $entrep [ 'Isin' ],
'Nom' => strtr ( $entrep [ 'Nom' ], '/*' , ' ' ),
'Nom2' => $entrep [ 'Nom2' ],
'NomLong' => $entrep [ 'nomLong' ], // Ajouté le 4 08 2009
2010-11-29 16:12:32 +00:00
'NomCommercial' => $entrep [ 'NomCommercial' ], // Ajouté le 16 11 2010
2010-11-10 13:37:07 +00:00
'Siret' => $entrep [ 'Siret' ],
'Sigle' => $entrep [ 'Sigle' ],
'SigleLong' => $entrep [ 'sigleLong' ], // Ajouté le 4 08 2009
'Enseigne' => $entrep [ 'Enseigne' ],
2010-11-29 16:12:32 +00:00
'EnseigneLong' => $entrep [ 'enseigneLong' ], // Ajouté le 16 11 2010
2010-11-10 13:37:07 +00:00
'Adresse' => $entrep [ 'Adresse' ],
'Adresse2' => $entrep [ 'Adresse2' ],
'AdresseNum' => $entrep [ 'AdresseNum' ],
'AdresseBtq' => $entrep [ 'AdresseBtq' ],
'AdresseVoie' => $entrep [ 'AdresseVoie' ],
'AdresseRue' => $entrep [ 'AdresseRue' ],
'CP' => $entrep [ 'CP' ],
'Ville' => $entrep [ 'Ville' ],
2010-11-25 09:11:42 +00:00
'Pays' => $entrep [ 'Pays' ], // Ajouté le 18 02 2008
2010-11-10 13:37:07 +00:00
'PaysIso2' => $entrep [ 'PaysIso2' ],
'AdresseDom' => $entrep [ 'AdresseDom' ],
'AdresseDomEnt' => $entrep [ 'AdresseDomEnt' ],
'AdresseDomNb' => $entrep [ 'AdresseDomNb' ],
'Civilite' => $entrep [ 'Civilite' ],
'NbEtab' => $entrep [ 'NbEtab' ],
'Tel' => $entrep [ 'Tel' ],
'Fax' => $entrep [ 'Fax' ],
'Web' => $entrep [ 'Web' ],
'Mail' => $entrep [ 'Mail' ],
'GeoLat' => $entrep [ 'GeoLat' ],
'GeoLon' => $entrep [ 'GeoLon' ],
'GeoPrecis' => $entrep [ 'GeoPrecis' ],
'GeoInfos' => $entrep [ 'GeoInfos' ],
'TvaNumero' => $entrep [ 'TvaNumero' ],
'TvaAttribue' => $entrep [ 'TvaAttribue' ],
'FJ' => $entrep [ 'FJ' ],
'FJ_lib' => $entrep [ 'FJ_lib' ],
2010-11-25 09:11:42 +00:00
'FJ2' => $entrep [ 'FJ2' ], // Ajouté le 4 08 2009
2010-11-10 13:37:07 +00:00
'FJ2_Lib' => $entrep [ 'FJ2_Lib' ], // Ajouté le 4 08 2009
'Siren' => $entrep [ 'Siren' ],
'Nic' => $entrep [ 'Nic' ],
'NafEnt' => $entrep [ 'NafEnt' ],
'NafEntLib' => $entrep [ 'NafEntLib' ],
'NafEtab' => $entrep [ 'NafEtab' ],
'NafEtabLib' => $entrep [ 'NafEtabLib' ],
'NaceEtab' => $entrep [ 'NaceEtab' ],
'NaceEnt' => $entrep [ 'NaceEnt' ],
'Nafa' => $entrep [ 'APRM' ],
'NafaLib' => $entrep [ 'APRM_Lib' ],
'NumRM' => $entrep [ 'NumRM' ],
'Activite' => $entrep [ 'Activite' ],
'Capital' => $entrep [ 'Capital' ],
'CapitalDev' => $entrep [ 'CapitalDev' ],
'CapitalLib' => $entrep [ 'CapitalLib' ], // Ajouté le 18 02 2008
2010-11-25 09:11:42 +00:00
'CapitalType' => $entrep [ 'CapitalType' ], // Ajouté le 4 08 2009
2010-11-10 13:37:07 +00:00
'DateCreaEt' => $entrep [ 'DateCreaEt' ],
'DateCreaEn' => $entrep [ 'DateCreaEn' ],
'DateClotEt' => $entrep [ 'DateClotEt' ],
2010-11-25 09:11:42 +00:00
'DateImmat' => $entrep [ 'dateImmat' ], // Ajouté le 4 08 2009
'DateRadiation' => $entrep [ 'dateRad' ], // Ajouté le 4 08 2009
// 'DateMajRCS' =>$entrep['DateMajRCS'], // Ajouté le 4 08 2009
2010-11-10 13:37:07 +00:00
'EffEnTr' => $entrep [ 'EffEnTr' ],
'EffEnTrLib' => $entrep [ 'EffEnTrLib' ],
'Effectif' => $entrep [ 'Effectif' ],
'EffEtTr' => $entrep [ 'EffEtTr' ], // Ajout le 11 08 2010
2010-11-25 09:11:42 +00:00
'EffEtTrLib' => $entrep [ 'EffEtTrLib' ], // Ajout le 11 08 2010
'EffectifEtab' => $entrep [ 'EffectifEtab' ], // Ajout le 11 08 2010
2010-11-10 13:37:07 +00:00
'Dept' => $entrep [ 'Dept' ],
'codeCommune' => $entrep [ 'codeCommune' ],
'AnneeEffEn' => $entrep [ 'AnneeEffEn' ],
'AnneeEffEt' => $entrep [ 'AnneeEffEt' ],
'AnneeTCA' => $entrep [ 'AnneeTCA' ],
'TrancheCA' => $entrep [ 'TrancheCA' ],
'TrancheCALib' => $entrep [ 'TrancheCALib' ],
'dir1Code' => $entrep [ 'dir1Code' ],
'dir1Titre' => $entrep [ 'dir1Titre' ], //utf8
'dir1NomPrenom' => $entrep [ 'dir1NomPrenom' ],
'dir1DateFct' => $entrep [ 'dir1DateFct' ],
'dir1DateNaiss' => $entrep [ 'dir1DateNaiss' ], // Ajouté le 4 08 2009
'dir1LieuNaiss' => $entrep [ 'dir1LieuNaiss' ], // Ajouté le 4 08 2009
'dir2Code' => $entrep [ 'dir2Code' ],
'dir2Titre' => $entrep [ 'dir2Titre' ], //utf8
'dir2NomPrenom' => $entrep [ 'dir2NomPrenom' ],
'dir2DateFct' => $entrep [ 'dir2DateFct' ],
'dir2DateNaiss' => $entrep [ 'dir2DateNaiss' ], // Ajouté le 4 08 2009
'dir2LieuNaiss' => $entrep [ 'dir2LieuNaiss' ], // Ajouté le 4 08 2009
'Rivoli' => $entrep [ 'Rivoli' ],
'NatureActivite' => $entrep [ 'NatureActivite' ], // Nature de l'activité
'OrigineCreation' => $entrep [ 'OrigineCreation' ], // Origine de la création
'TypeExploitation' => $entrep [ 'TypeExploitation' ],
'Auxiliaire' => $entrep [ 'Auxiliaire' ], // 1=Auxiliaire / 0=Non auxiliaire
'Saisonnalite' => $entrep [ 'Saisonnalite' ], // P=Activité permanente / S=Activité saisonnière
'SituationJuridique' => $entrep [ 'SituationJuridique' ],
'Bilan' => array (
'Cloture' => $entrep [ 'bilanDate' ],
'Duree' => $entrep [ 'bilanMois' ],
'Devise' => $entrep [ 'bilanDevise' ],
'Capital' => $entrep [ 'bilanDA' ],
'CA' => $entrep [ 'bilanFL' ],
'Resultat' => $entrep [ 'bilanHN' ],
'Effectif' => $entrep [ 'bilanYP' ],
),
'Bourse' => array (
'placeCotation' => $bourse [ 'placeCotation' ],
'nombreTitres' => $bourse [ 'nombreTitres' ],
'capitalisation' => $bourse [ 'close' ] * $bourse [ 'nombreTitres' ],
'derCoursDate' => $bourse [ 'date' ],
'derCoursCloture' => $bourse [ 'close' ]
),
'AutreSiren' => $entrep [ 'AutreSiren' ],
'DateMajINSEE' => $entrep [ 'DateMajINSEE' ],
'DateMajRCS' => $entrep [ 'DateMajRCS' ],
'DateMajBILAN' => $entrep [ 'bilanDateMaj' ],
'DateMajANN' => $entrep [ 'dateMajANN' ],
'DateMajID' => $entrep [ 'dateMajIdentite' ],
//'importExport' =>$entrep['importExport'],
);
if ( preg_match ( '/NAF4/i' , $this -> tabInfoUser [ 'pref' ]))
{
2010-11-25 10:34:00 +00:00
$entrep2 = $iInsee -> getNaf4 ( $siren , $nic , $id );
2010-11-10 13:37:07 +00:00
$tabRet [ 'Naf4Ent' ] = $entrep2 [ 'apen4' ];
$tabRet [ 'Naf4Etab' ] = $entrep2 [ 'apet4' ];
$tabRet [ 'Naf4EntLib' ] = $entrep2 [ 'apen4_lib' ];
$tabRet [ 'Naf4EtabLib' ] = $entrep2 [ 'apet4_lib' ];
}
debugLog ( 'I' , 'Etablissement retourné = ' . $entrep [ 'Nom' ], __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
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 );
$result = arrayToClass ( $tabRet , 'IdentiteResult' );
$error -> errnum = 0 ;
$error -> errmsg = '' ;
}
}
$outputParams -> error = $error ;
$outputParams -> result = $result ;
return $outputParams ;
}
/**
* Retourne les liens financiers pour une entreprise .
*
* @ param integer $siren Siren de l ' entreprise
* @ param boolean $actifsUniquement Uniquement les liens Actifs
* @ return LiensReturn
*/
2010-11-10 13:42:16 +00:00
public function getLiens ( $siren , $actifsUniquement = true )
2010-11-10 13:37:07 +00:00
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-10 13:37:07 +00:00
//Initialisation
2010-12-03 13:24:15 +00:00
if ( empty ( $actifsUniquement )) { $actifsUniquement = true ; }
2010-11-10 13:37:07 +00:00
$error = new ErrorType ();
$tabAct = $tabPar = array ();
2010-11-05 09:54:50 +00:00
2010-11-10 13:37:07 +00:00
debugLog ( 'I' , " Liens entreprises demandés pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-12-03 13:24:15 +00:00
if ( strlen ( $siren ) <> 9 ){
2010-11-10 13:37:07 +00:00
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
2010-12-03 13:24:15 +00:00
} elseif ( $siren * 1 == 0 ) {
2010-11-10 13:37:07 +00:00
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
2010-12-03 13:24:15 +00:00
} else {
2010-11-10 13:37:07 +00:00
$mLiens = new MLiens ( $siren );
$tabA = $mLiens -> getActionnaires ( $siren , $actifsUniquement );
$nbA = count ( $tabA );
2010-11-10 15:22:15 +00:00
$tabAct = array ();
2010-12-03 13:24:15 +00:00
if ( $nbA > 0 ) {
foreach ( $tabA as $i => $lien ) {
2010-11-10 13:37:07 +00:00
$actionnaire = new Actionnaire ();
$actionnaire -> Pmin = $lien [ 'Pmin' ];
$actionnaire -> MajMin = $lien [ 'MajMin' ];
$actionnaire -> RaisonSociale = $lien [ 'RaisonSociale' ];
2010-12-13 15:28:22 +00:00
$actionnaire -> TypeEntrep = $lien [ 'TypeEntrep' ];
2010-11-10 13:37:07 +00:00
$actionnaire -> Pays = $lien [ 'Pays' ];
$actionnaire -> Siren = $lien [ 'Siren' ];
$actionnaire -> Actif = $lien [ 'Actif' ];
$actionnaire -> Source = $lien [ 'Source' ];
$actionnaire -> DateLien = $lien [ 'DateLien' ];
$actionnaire -> DateMaj = $lien [ 'DateMaj' ];
$tabAct [] = $actionnaire ;
}
}
debugLog ( 'W' , " $nbA actionnaires pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabP = $mLiens -> getParticipations ( $siren , $actifsUniquement );
$nbP = count ( $tabP );
2010-11-10 15:22:15 +00:00
$tabPar [] = array ();
2010-12-03 13:24:15 +00:00
if ( $nbP > 0 ) {
foreach ( $tabP as $i => $lien ) {
2010-11-10 13:37:07 +00:00
$participation = new Participation ();
$participation -> Pmin = $lien [ 'Pmin' ];
$participation -> MajMin = $lien [ 'MajMin' ];
$participation -> RaisonSociale = $lien [ 'RaisonSociale' ];
2010-12-13 15:28:22 +00:00
$participation -> TypeEntrep = $lien [ 'TypeEntrep' ];
2010-11-10 13:37:07 +00:00
$participation -> Pays = $lien [ 'Pays' ];
$participation -> Siren = $lien [ 'Siren' ];
$participation -> Actif = $lien [ 'Actif' ];
$participation -> Source = $lien [ 'Source' ];
$participation -> DateLien = $lien [ 'DateLien' ];
$participation -> DateMaj = $lien [ 'DateMaj' ];
$tabPar [] = $participation ;
}
}
debugLog ( 'W' , " $nbP participations pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'liens' , $siren );
}
$result = new LiensResult ();
$result -> actionnaires = $tabAct ;
$result -> participations = $tabPar ;
$output = new LiensReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-08-30 07:49:44 +00:00
}
2010-09-08 13:40:57 +00:00
2010-11-10 13:37:07 +00:00
2010-11-08 17:25:06 +00:00
/**
* 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 )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-08 17:25:06 +00:00
2010-11-09 08:21:01 +00:00
//Initialisation
2010-11-10 15:22:15 +00:00
if ( empty ( $dep )) { $dep = 0 ; }
if ( empty ( $actif )) { $actif = - 1 ; }
if ( empty ( $position )) { $position = 0 ; }
if ( empty ( $nbRep )) { $nbRep = 20 ; }
2010-11-09 08:21:01 +00:00
//Valeur max
if ( $nbRep > 200 ) { $nbRep = 200 ; }
2010-11-08 17:25:06 +00:00
$departement = $dep ;
$error = new ErrorType ();
debugLog ( 'I' , " Liste des établissements demandée pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( strlen ( $siren ) <> 9 )
{
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
elseif ( $siren * 1 == 0 )
{
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
$rep = $iInsee -> getEtablissements ( $siren , '' , $position , $nbRep , 200 , $departement , $actif );
2010-11-08 17:25:06 +00:00
$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__ );
wsLog ( 'etablissements' , $siren );
}
$reponse = new ListeEtablissementsResult ();
$reponse -> nbReponses = $nbReponses ;
$reponse -> liste = $result ;
$output = new ListeEtablissementsReturn ();
$output -> error = $error ;
$output -> result = $reponse ;
return $output ;
}
/**
* Retourne l 'ensemble des informations identitaires des dirigeants de l' entreprise
*
* @ param integer $siren Siren de l ' entreprise
* @ param bool $histo Afficher l ' historique des dirigeants
* @ return DirigeantsReturn Liste des dirigeants actifs de l ' entreprise
*/
public function getDirigeants ( $siren , $histo = false )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-10 13:37:07 +00:00
//Initialisation
2010-11-10 15:22:15 +00:00
if ( empty ( $histo )) { $histo = false ; }
2010-11-08 17:25:06 +00:00
debugLog ( 'I' , " Dirigeants demandée pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 )
{
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren Siret inexistant' ;
}
elseif ( $siren * 1 == 0 )
{
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
if ( $histo ) $option = 'histo' ;
else $option = '' ;
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
$dirs = $iInsee -> getDirigeants ( $siren , $histo );
2010-11-08 17:25:06 +00:00
//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' ];
$dirigeant -> NaissVille = $dir [ 'NaissVille' ];
$dirigeant -> NaissDepPays = $dir [ 'NaissDepPays' ];
$dirigeant -> Ancien = $dir [ 'Ancien' ];
$dirigeant -> DateFct = $dir [ 'DateFct' ];
$liste [] = $dirigeant ;
}
wsLog ( 'dirigeants' , $siren , $option );
debugLog ( 'I' , 'Nb Dirigeants retournés = ' . count ( $dirs ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
$output = new DirigeantsReturn ();
$output -> error = $error ;
$output -> result = $liste ;
return $output ;
}
2010-11-10 13:37:07 +00:00
/**
* Retourne la liste des annonces légales relative à une entreprise
*
* @ todo Revoir cette fonction pour la faire marcher avec les associations
*
* @ param string $siren Siren de l ' entreprise
* @ param integer $filtre 0 = Pas de Filtre , 1 = BODACC , 2 = B . A . L . O , 3 = JO Association , 4 = Boamp
* @ param integer $idAnn Identifiant de l ' annonce
* @ param integer $position
* @ param integer $nbRep
* @ return AnnoncesReturn
*/
public function getAnnonces ( $siren , $filtre = 0 , $idAnn = 0 , $position = 0 , $nbRep = 20 )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-10 13:37:07 +00:00
//Initialisation
2010-11-10 15:22:15 +00:00
if ( empty ( $filtre )) { $filtre = 0 ; }
if ( empty ( $idAnn )) { $idAnn = 0 ; }
if ( empty ( $position )) { $position = 0 ; }
if ( empty ( $nbRep )) { $nbRep = 20 ; }
2010-11-10 13:37:07 +00:00
//Valeur max
if ( $nbRep > 200 ) { $nbRep = 200 ; }
debugLog ( 'I' , " Annonces demandées pour $siren ( $filtre , $idAnn ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$liste = array ();
if ( strlen ( $siren ) <> 9 )
{
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren Siret inexistant' ;
}
elseif ( $siren * 1 == 0 && $idAnn == 0 )
{
debugLog ( 'W' , " Siren $siren ou annonce $idAnn inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant A' ;
}
else
{
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
2010-11-10 13:37:07 +00:00
/*
if ( $siren > 100 && $filtre == 3 ) $asso = true ;
else {
$asso = false ;
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $siren );
if ( $tabIdentite [ 'FJ' ] > 90 && $tabIdentite [ 'FJ' ] < 94 ||
$tabIdentite [ 'FJ' ] > 9000 && $tabIdentite [ 'FJ' ] < 9400 ) $asso = true ;
} */
if ( $idAnn == 0 ) {
2010-11-25 10:34:00 +00:00
$anns = $iInsee -> getAnnoncesLegales ( $siren );
$annsB = $iInsee -> getAnnoncesBalo ( $siren );
$annsA = $iInsee -> getAnnoncesAsso ( $siren );
$annsM = $iInsee -> getAnnoncesBoamp ( $siren , $idAnn );
2010-11-10 13:37:07 +00:00
} elseif ( $filtre == 1 )
2010-11-25 10:34:00 +00:00
$anns = $iInsee -> getAnnoncesLegales ( $siren , $idAnn );
2010-11-10 13:37:07 +00:00
elseif ( $filtre == 2 )
2010-11-25 10:34:00 +00:00
$annsB = $iInsee -> getAnnoncesBalo ( $siren , $idAnn );
2010-11-10 13:37:07 +00:00
elseif ( $filtre == 3 )
2010-11-25 10:34:00 +00:00
$annsA = $iInsee -> getAnnoncesAsso ( $siren , $idAnn );
2010-11-10 13:37:07 +00:00
elseif ( $filtre == 4 )
2010-11-25 10:34:00 +00:00
$annsM = $iInsee -> getAnnoncesBoamp ( $siren , $idAnn );
2010-11-08 17:25:06 +00:00
2010-11-10 13:37:07 +00:00
//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' ];
$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' ];
2010-11-29 16:12:32 +00:00
$annonce -> raisonSociale = $ann [ 'raisonSociale' ];
$annonce -> nomCommercial = $ann [ 'nomCommercial' ];
$annonce -> sigle = $ann [ 'sigle' ];
$annonce -> adresse = $ann [ 'adresse' ];
2010-11-10 13:37:07 +00:00
$annonce -> dateEffet = $ann [ 'dateEffet' ];
$annonce -> dateJugement = $ann [ 'dateJugement' ];
$annonce -> dateInsertionSD = $ann [ 'dateInsertionSD' ];
$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' ];
$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' ];
$annonce -> dateJugement = $ann [ 'dateJugement' ];
$annonce -> dateInsertionSD = $ann [ 'dateInsertionSD' ];
$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' ];
$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' ];
$annonce -> dateJugement = $ann [ 'dateJugement' ];
$annonce -> dateInsertionSD = $ann [ 'dateInsertionSD' ];
$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' ];
$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' ];
$annonce -> dateJugement = $ann [ 'dateJugement' ];
$annonce -> dateInsertionSD = $ann [ 'dateInsertionSD' ];
$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__ );
wsLog ( 'annonces' , $siren , $filtre . '/' . $idAnn );
file_put_contents ( PATH_LOG . '/annonces.log' , print_r ( $liste , 1 ));
$output = new AnnoncesReturn ();
$output -> error = $error ;
$result = new AnnoncesResult ();
$result -> nbReponses = $nbReponses ;
$result -> liste = $liste ;
$output -> result = $result ;
return $output ;
}
2010-11-08 17:25:06 +00:00
2010-11-10 15:22:15 +00:00
/**
* Evaluation indiScore d ' une entreprise
*
* @ param string $siren Siren de l ' entreprise
* @ param string $nic
* @ param bool $accesDist
* @ param int $niveau
2010-11-22 17:43:19 +00:00
* @ return IndiscoreReturn
2010-11-10 15:22:15 +00:00
*/
2010-11-22 17:43:19 +00:00
public function getIndiScore ( $siren , $nic = 0 , $accesDist = true , $niveau = 2 )
2010-11-10 15:22:15 +00:00
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-10 15:22:15 +00:00
//Initialisation
if ( empty ( $nic )) { $nic = 0 ; }
if ( empty ( $accesDist )) { $accesDist = true ; }
if ( empty ( $niveau )) { $niveau = 2 ; }
if ( ! in_array ( $niveau , array ( 0 , 1 , 2 , 3 , 4 , 5 )) ) { $niveau = 2 ; }
$error = new ErrorType ();
2010-11-22 17:41:28 +00:00
$tabRet = array ();
2010-11-10 15:22:15 +00:00
debugLog ( 'I' , " IndiScore demandée pour $siren en niveau $niveau " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-12-03 13:24:15 +00:00
if ( strlen ( $siren ) > 9 || ( substr ( $siren , 0 , 9 ) * 1 ) < 100 ){
2010-11-10 15:22:15 +00:00
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren incorrect' ;
2010-12-03 13:24:15 +00:00
} else {
2010-11-22 17:41:28 +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__ );
wsLog ( 'indiscore' , $siren );
}
2010-12-03 17:12:59 +00:00
$result = new Indiscore ();
foreach ( $tabRet as $key => $value ){
if ( $key == 'paiements' ){
$parMont = $tabRet [ $key ][ 'parMont' ];
$parTrim = $tabRet [ $key ][ 'parTrim' ];
$tabMont = array ();
foreach ( $parMont as $parMontK => $parMontV ){
$paiementMont = new IndiscorePaiementMont ();
$paiementMont -> id = $parMontK ;
$paiementMont -> val = $parMontV ;
$tabMont [] = $paiementMont ;
}
$tabTrim = array ();
foreach ( $parTrim as $parTrimK => $parTrimV ){
$paiementTrim = new IndiscorePaiementTrim ();
$paiementTrim -> id = $parTrimK ;
$paiementTrim -> val = $parTrimV ;
$tabTrim [] = $paiementTrim ;
}
$paiement = new IndiscorePaiement ();
$paiement -> parMont = $tabMont ;
$paiement -> parTrim = $tabTrim ;
$result -> paiements = $paiement ;
} elseif ( $key == 'tabInfosNotation' ) {
$tab = $tabRet [ $key ];
$infosNotation = new IndiscoreInfosNotation ();
$infosNotation -> SituationFinanciere = $tabRet [ $key ][ 'SituationFinanciere' ];
$infosNotation -> Notation = $tabRet [ $key ][ 'Notation' ];
$infosNotation -> ProbabiliteDefaut = $tabRet [ $key ][ 'ProbabiliteDefaut' ];
$result -> tabInfosNotations = $infosNotation ;
} elseif ( $key == 'tabImportExport' ) {
$importExport = new IndiscoreImportExport ();
$importExport -> importExport = $tabRet [ $key ][ 'importExport' ];
$importExport -> annee = $tabRet [ $key ][ 'annee' ];
$importExport -> rangNational = $tabRet [ $key ][ 'rangNational' ];
$importExport -> deptSiege = $tabRet [ $key ][ 'deptSiege' ];
$result -> tabImportExport = $importExport ;
} elseif ( $key == 'tabCommentaires' ) {
$tab = array ();
foreach ( $tabRet [ $key ] as $comment ) {
$tab [] = $comment ;
}
$result -> tabCommentaires = $tab ;
} elseif ( $key == 'tabVariables' ) {
$tab = $tabRet [ $key ][ 'CA_Y' ];
$tabVar = array ();
foreach ( $tab as $key => $value ){
$var = new CA_Y ();
$var -> id = $key ;
$var -> val = $value ;
$tabVar [] = $var ;
}
$variables = new IndiscoreVariables ();
$variables -> CA_Y = $tabVar ;
$result -> tabVariables = $variables ;
} else {
2010-12-14 10:23:40 +00:00
$result -> ${$key} = $value ;
2010-12-03 17:12:59 +00:00
}
}
2010-11-22 17:41:28 +00:00
$output = new IndiscoreReturn ();
$output -> error = $error ;
2010-12-03 17:12:59 +00:00
$output -> result = $result ;
return $output ;
2010-11-10 15:22:15 +00:00
}
/**
* Liste de tous les évènements enregistrés à l ' INSEE pour une entreprise
* @ param string $siren Siren de l ' entreprise
* @ param string $nic
* @ param integer $deb
* @ param integer $max
* @ return InseeReturn
**/
public function getListeEvenements ( $siren , $nic = 0 , $deb = 0 , $max = 1000 )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-10 15:22:15 +00:00
//Initialisation
if ( empty ( $nic )) { $nic = 0 ; }
2010-12-01 13:42:30 +00:00
if ( empty ( $deb )) { $deb = 0 ; }
2010-11-10 15:22:15 +00:00
if ( empty ( $max ) || $max > 1000 ) { $max = 1000 ; }
$error = new ErrorType ();
debugLog ( 'I' , " Liste des évènements pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 )
{
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
elseif ( $siren * 1 == 0 )
{
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
$evens = $iInsee -> getEvenements ( $siren , $nic , $deb , $max );
2010-11-10 15:22:15 +00:00
$tabRet = array ();
if ( count ( $evens ) > 0 )
{
foreach ( $evens as $nb => $even )
{
$iEven = new InseeEven ();
$iEven -> Nic = $even [ 'nic' ];
$iEven -> Siege = $even [ 'siege' ];
$iEven -> SiretAss = $even [ 'siretAssocie' ];
$iEven -> TypeSiretAss = $even [ 'typeSiretAss' ];
$iEven -> EvenCode = $even [ 'codeEven' ];
$iEven -> EvenLib = $even [ 'libEven' ];
$iEven -> EvenLibDet = $even [ 'libEvenDet' ];
$iEven -> EvenDate = $even [ 'dateEven' ];
$iEven -> DateInfo = $even [ 'dateMAJ' ];
$tabRet [] = $iEven ;
}
}
}
debugLog ( 'I' , 'Nb évènements retournés = ' . count ( $tabRet ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
//wsLog('etablissements',$siren);
$result = new InseeResult ();
$result -> nbReponses = count ( $tabRet );
2010-12-01 13:39:01 +00:00
$result -> evenements = $tabRet ;
2010-11-10 15:22:15 +00:00
$output = new InseeReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
}
2010-11-08 17:25:06 +00:00
2010-09-08 13:40:57 +00:00
/**
* Recherche
2010-09-21 15:19:32 +00:00
* @ 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 )
2010-11-08 17:25:06 +00:00
* @ return RechercheEntrepriseReturn
2010-09-08 13:40:57 +00:00
*/
2010-11-08 17:25:06 +00:00
public function rechercheEntreprise ( $type , $criteres , $position = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false , $avecSiren = false )
2010-09-15 16:18:38 +00:00
{
2010-09-21 15:19:32 +00:00
//Enregistrement des accès à la requête getIdentite
Zend_Registry :: get ( 'WsLogger' ) -> info ( " rechercheEntreprise - ip: " .
2010-09-22 07:22:40 +00:00
$_SERVER [ 'REMOTE_ADDR' ] . " , login: " . $_SERVER [ 'PHP_AUTH_USER' ]);
2010-09-21 15:19:32 +00:00
switch ( $type )
{
case 'ent' :
$entCriteres = new CriteresEntreprise ();
$entCriteres = $criteres -> elementEntreprise ;
$client = new SoapClient ( $this -> wsdl , $this -> wsdlOptions );
2010-09-23 16:20:08 +00:00
$identifiant = $entCriteres -> identifiant ;
$typeId = '' ;
if ( $identifiant != '' ) {
$len = strlen ( $identifiant );
//Numéro WALDEC
if ( strtoupper ( substr ( $identifiant , 0 , 1 )) == 'W' ) {
$typeId = 'W' ;
//Code ISIN
} elseif ( $len == 12 ){
$typeId = 'I' ;
//TVA Intracommunautaire
} elseif ( in_array ( substr ( $identifiant , 0 , 2 ),
array ( 'AT' , 'BE' , 'BG' , 'CY' , 'CZ' , 'DE' , 'DK' , 'EE' , 'EL' , 'ES' ,
'FI' , 'GB' , 'HU' , 'IE' , 'IT' , 'LT' , 'LU' , 'LV' , 'MT' , 'NL' , 'PL' ,
'PT' , 'RO' , 'SE' , 'SI' , 'SK' ))){
//"La recherche par numéro de TVA n'est pas encore possible sur ce pays !";
//Pour la france
} elseif ( substr ( $identifiant , 0 , 2 ) == 'FR' ) {
$typeId = 'S' ;
if ( $len == 13 ) $identifiant = substr ( $identifiant , 4 , 9 );
else $identifiant = '' ;
//Numéro RC
} elseif ( preg_match ( '/A|B|C|D/i' , $identifiant )) {
$typeId = 'R' ;
//Siren normal on enleve tout ce qui n'est pas un chiffre
} else {
$typeId = 'S' ;
}
}
if ( in_array ( $typeId , array ( 'R' , 'W' , 'I' ))){
try {
$O = $client -> searchAutreId (
$typeId ,
$identifiant ,
empty ( $position ) ? 0 : $position ,
empty ( $nbRep ) ? 20 : $nbRep ,
empty ( $maxRep ) ? 200 : $maxRep ,
$entCriteres -> codePostal
);
} catch ( SoapFault $fault ) {
Zend_Registry :: get ( 'WsLogger' ) -> err ( " rechercheEntreprise - " . serialize ( $criteres ));
2010-10-18 10:04:21 +00:00
throw new SoapFault ( $fault -> faultcode , $fault -> faultstring );
exit ;
2010-09-23 16:20:08 +00:00
}
} elseif ( $typeId == 'S' ){
try {
$O = $client -> searchSiren (
$identifiant ,
empty ( $position ) ? 0 : $position ,
empty ( $nbRep ) ? 20 : $nbRep ,
empty ( $maxRep ) ? 200 : $maxRep ,
$entCriteres -> codePostal
);
} catch ( SoapFault $fault ) {
Zend_Registry :: get ( 'WsLogger' ) -> err ( " rechercheEntreprise - " . serialize ( $criteres ));
2010-10-18 10:04:21 +00:00
throw new SoapFault ( $fault -> faultcode , $fault -> faultstring );
exit ;
2010-09-23 16:20:08 +00:00
}
} else {
try {
$O = $client -> searchNomAdr (
$entCriteres -> raisonSociale ,
$entCriteres -> adresse ,
$entCriteres -> codePostal ,
$entCriteres -> ville ,
empty ( $entCriteres -> siege ) ? false : $entCriteres -> siege ,
empty ( $entCriteres -> actif ) ? false : $entCriteres -> actif ,
empty ( $position ) ? 0 : $position ,
empty ( $nbRep ) ? 20 : $nbRep ,
empty ( $maxRep ) ? 200 : $maxRep ,
empty ( $pertinence ) ? false : $pertinence ,
empty ( $avecSiren ) ? false : $avecSiren ,
$entCriteres -> naf
);
} catch ( SoapFault $fault ) {
Zend_Registry :: get ( 'WsLogger' ) -> err ( " rechercheEntreprise - " . serialize ( $criteres ));
2010-10-18 10:04:21 +00:00
throw new SoapFault ( $fault -> faultcode , $fault -> faultstring );
exit ;
2010-09-23 16:20:08 +00:00
}
2010-09-21 15:19:32 +00:00
}
break ;
case 'dir' :
$dirCriteres = new CriteresDirigeant ();
$dirCriteres = $criteres -> elementDirigeant ;
$client = new SoapClient ( $this -> wsdl , $this -> wsdlOptions );
try {
$O = $client -> searchDir (
$dirCriteres -> dirNom ,
$dirCriteres -> dirPrenom ,
$dirCriteres -> dirDateNaiss ,
$dirCriteres -> dirVille ,
2010-09-23 16:20:08 +00:00
empty ( $position ) ? 0 : $position ,
2010-09-21 15:19:32 +00:00
empty ( $nbRep ) ? 20 : $nbRep ,
empty ( $maxRep ) ? 200 : $maxRep ,
empty ( $pertinence ) ? false : $pertinence
);
} catch ( SoapFault $fault ) {
Zend_Registry :: get ( 'WsLogger' ) -> err ( " rechercheEntreprise - " . serialize ( $criteres ));
2010-10-18 10:04:21 +00:00
throw new SoapFault ( $fault -> faultcode , $fault -> faultstring );
exit ;
2010-09-21 15:19:32 +00:00
}
break ;
}
2010-09-15 16:18:38 +00:00
$error = new ErrorType ();
2010-09-21 15:19:32 +00:00
$error = arrayToClass ( $O [ 'error' ], 'ErrorType' );
$results = new RechercheEntrepriseResult ();
$results = arrayToClass ( $O [ 'results' ], 'RechercheEntrepriseResult' );
2010-11-08 17:25:06 +00:00
$outputParams = new RechercheEntrepriseReturn ();
2010-09-15 16:18:38 +00:00
$outputParams -> error = $error ;
$outputParams -> results = $results ;
return $outputParams ;
2010-09-08 13:40:57 +00:00
}
2010-11-15 14:51:46 +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
2010-11-15 14:58:54 +00:00
* @ return TvaReturn
2010-11-15 14:51:46 +00:00
*/
2010-11-15 14:58:54 +00:00
public function getTVA ( $siren )
2010-11-15 14:51:46 +00:00
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-15 14:51:46 +00:00
//Initialisation
$error = new ErrorType ();
$result = new TvaResult ();
$siren = trim ( $siren );
debugLog ( 'I' , " TVA demandée pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
if ( strlen ( $siren ) <> 9 )
{
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
elseif ( $siren * 1 == 0 )
{
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
debugLog ( 'I' , " Avant getIdentiteEntreprise( $siren ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
$entrep = $iInsee -> getIdentiteEntreprise ( $siren );
2010-11-15 14:51:46 +00:00
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__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
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__ );
$result -> id = $entrep [ 'id' ];
$result -> AutreId = $entrep [ 'AutreId' ];
$result -> Nom = $entrep [ 'Nom' ];
$result -> Sigle = $entrep [ 'Sigle' ];
$result -> Enseigne = $entrep [ 'Enseigne' ];
$result -> Adresse = $entrep [ 'Adresse' ];
$result -> Adresse2 = $entrep [ 'Adresse2' ];
$result -> CP = $entrep [ 'CP' ];
$result -> Ville = $entrep [ 'Ville' ];
$result -> Siren = $entrep [ 'Siren' ];
$result -> Tva = $tva ;
debugLog ( 'I' , " TVA retournée = $tva ( " . $entrep [ 'Nom' ] . ')' , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'tva' , $siren );
}
}
$output = new TvaReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
}
2010-11-15 15:40:01 +00:00
/**
* Retourne la liste des tribunaux ou Compétences demandées
* @ param array | string $tabTypes Tableau des types de Compétences demandés 'C' : Commerce , 'I' : Instance , 'G' : TGI , 'A' : Préfectures , 'B' : Sous - préf , 'D' : Tribunal Administratif , 'H' : Prud 'hommes, ' L ': Cour d' Appel , 'M' : Tribunal Mixte , 'O' : CCI , 'V' : Cour Administrative d ' Appel
* @ return TribunauxReturn
**/
public function getTribunaux ( $tabTypes )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-15 15:40:01 +00:00
//Initialisation
if ( empty ( $tabTypes )) $tabTypes = array ();
if ( is_string ( $tabTypes )) $tabTypes = ( array ) $tabTypes ;
$error = new ErrorType ();
$iBodacc = new MBodacc ();
debugLog ( 'I' , " Liste des tribunaux demandées " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabTmp = $iBodacc -> getListeTribunaux ();
$tabRet = array ();
if ( count ( $tabTypes ) == 0 )
{
foreach ( $tabTmp as $i => $tribunal )
{
$tri = new TribunalNom ();
$tri -> nom = $tribunal [ 'nom' ];
$tabRet [ $i ] = $tri ;
}
}
else
{
foreach ( $tabTmp as $i => $tribunal )
{
$type = substr ( $i , - 1 );
if ( in_array ( $type , $tabTypes ))
{
$tri = new TribunalNom ();
$tri -> nom = $tribunal [ 'nom' ];
$tabRet [ $i ] = $tri ;
}
}
}
$output = new TribunauxReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
}
2010-09-08 13:40:57 +00:00
2010-11-17 16:45:20 +00:00
/**
* Retourne tout ou patie des informations règlementées sur l ' entreprise
*
* @ param int $siren SIREN de l ' entreprise
* @ param mixed $id Id du communiqué
* @ return InfosRegReturn
*/
public function getInfosReg ( $siren , $id = false )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-17 16:45:20 +00:00
//Initialisation
if ( empty ( $id )) $id = false ;
$tabRet = array ();
$error = new ErrorType ();
$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__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
$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__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Aucune info réglementé pour le siren' ;
}
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__);
if ( $id == false )
{
$infos = new InfosReg ();
$infos -> id = $ann [ 'id' ];
$infos -> source = $ann [ 'source' ];
$infos -> DateParution = $ann [ 'DateParution' ];
$infos -> raisonSociale = $ann [ 'raisonSociale' ];
$infos -> titre = $ann [ 'titre' ];
$infos -> pj = $ann [ 'pj' ];
$infos -> url = $ann [ 'url' ];
$infos -> dateInsertionSD = $ann [ 'dateInsertionSD' ];
$tabRet [] = $infos ;
}
else
{
$infos = new InfosReg ();
$infos -> id = $ann [ 'id' ];
$infos -> source = $ann [ 'source' ];
$infos -> DateParution = $ann [ 'DateParution' ];
$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' ];
$tabRet [] = $infos ;
}
}
}
debugLog ( 'I' , 'Nb infos retournés = ' . count ( $anns ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'infosreg' , $siren , $id );
}
$output = new InfosRegReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
}
2010-11-18 16:53:20 +00:00
/**
* Retourne les informations boursières de l ' entreprise
* @ param string $siren SIREN de l ' entreprise
* @ return InfosBourseReturn
*/
public function getInfosBourse ( $siren )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-18 16:53:20 +00:00
//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__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
$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__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
$result = new InfosBourse ();
$result -> Siren = $bourse [ 'siren' ];
$result -> RaisonSociale = prepareString ( $bourse [ 'raisonSociale' ]);
$result -> Adresse = prepareString ( $bourse [ 'adresse' ]);
$result -> Effectif = $bourse [ 'effectif' ];
$result -> CodeSicovam = $bourse [ 'code_sicovam' ];
$result -> CodeMnemo = $bourse [ 'code_mnemo' ];
$result -> CodeBloomberg = $bourse [ 'code_bloomberg' ];
$result -> CodeDatastream = $bourse [ 'code_datastream' ];
$result -> Isin = $bourse [ 'code_isin' ];
$result -> CodeRic = $bourse [ 'code_ric' ];
$result -> DateIntroduction = prepareString ( $bourse [ 'dateIntroduction' ]);
$result -> DateDerAG = prepareString ( $bourse [ 'dateDerAG' ]);
$result -> DateRadiation = prepareString ( $bourse [ 'dateRadiation' ]);
$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 = prepareString ( $bourse [ 'marche' ]);
$result -> Description = prepareString ( $bourse [ 'description' ]);
$result -> Secteur = prepareString ( $bourse [ 'secteur' ]);
$result -> Activite = prepareString ( $bourse [ 'activite' ]);
$result -> ActiviteDet = prepareString ( $bourse [ 'activiteDet' ]);
$result -> placeCotation = prepareString ( $bourse [ 'placeCotation' ]);
$result -> nombreTitres = $bourse [ 'nombreTitres' ];
$result -> capitalisation = $bourse [ 'close' ] * $bourse [ 'nombreTitres' ];
$result -> derCoursDate = $bourse [ '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' ];
wsLog ( 'bourse' , $siren , $id );
}
}
$output = new InfosBourseReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
}
2010-11-19 13:27:30 +00:00
/**
2010-12-06 14:05:50 +00:00
*
* Enter description here ...
* @ param string $siren
* @ param array $tabTypes
* @ return PrivilegesDetailReturn
*/
public function getPrivilegesDetail ( $siren , $tabTypes = array ( '03' , '04' ))
2010-11-19 13:27:30 +00:00
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-19 13:27:30 +00:00
//Initialisation
2010-11-22 17:41:28 +00:00
if ( empty ( $tabTypes )) $tabTypes = array ( '03' , '04' );
2010-11-19 13:27:30 +00:00
$error = new ErrorType ();
2010-12-06 14:05:50 +00:00
debugLog ( 'I' , " Liste des privilèges detail sur $siren " . print_r ( $tabTypes , true ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iPriv = new MPrivileges ();
$ret = $iPriv -> getPrivilegesDetail ( $siren , $tabTypes );
2010-11-19 13:27:30 +00:00
2010-12-06 14:05:50 +00:00
$output = new PrivilegesDetailReturn ();
$output -> error = new ErrorType ();
$output -> result = $tabRet ;
return $output ;
}
/**
*
* Enter description here ...
* @ param string $siren
* @ param array $tabTypes
* @ return PrivilegesCumulReturn
*/
public function getPrivilegesCumul ( $siren , $tabTypes = array ( '03' , '04' ))
{
$this -> authenticate ();
//Initialisation
if ( empty ( $tabTypes )) $tabTypes = array ( '03' , '04' );
$error = new ErrorType ();
debugLog ( 'I' , " Liste des privilèges cumul sur $siren " . print_r ( $tabTypes , true ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-22 17:41:28 +00:00
$iPriv = new MPrivileges ();
2010-12-06 14:05:50 +00:00
$ret = $iPriv -> getPrivilegesCumul ( $siren , $tabTypes );
$tabRet = array ();
if ( isset ( $ret [ '03' ]) && count ( $ret [ '03' ] > 0 )){
$value = $ret [ '03' ];
$priv = new PrivilegesCumul ();
$priv -> insType = '03' ;
$priv -> nb = $value [ 'nb' ];
$priv -> insTypeLib = $value [ 'insTypeLib' ];
$priv -> dateFraiche = $value [ 'dateFraiche' ];
$priv -> dateDerInsc = $value [ 'dateDerInsc' ];
$priv -> nomDerCre = $value [ 'nomDerCre' ];
$priv -> numDebiteur = $value [ 'numDebiteur' ];
$priv -> greffeLib = $value [ 'greffeLib' ];
$priv -> dateMajSD = $value [ 'dateMajSD' ];
$priv -> insCumul = $value [ 'insCumul' ];
$tabRet [] = $priv ;
2010-11-22 17:41:28 +00:00
}
2010-11-19 13:27:30 +00:00
2010-12-06 14:05:50 +00:00
if ( isset ( $ret [ '04' ]) && count ( $ret [ '04' ] > 0 )){
$value = $ret [ '04' ];
$priv = new PrivilegesCumul ();
$priv -> insType = '04' ;
$priv -> nb = $value [ 'nb' ];
$priv -> insTypeLib = $value [ 'insTypeLib' ];
$priv -> dateFraiche = $value [ 'dateFraiche' ];
$priv -> dateDerInsc = $value [ 'dateDerInsc' ];
$priv -> nomDerCre = $value [ 'nomDerCre' ];
$priv -> numDebiteur = $value [ 'numDebiteur' ];
$priv -> greffeLib = $value [ 'greffeLib' ];
$priv -> dateMajSD = $value [ 'dateMajSD' ];
$priv -> insCumul = $value [ 'insCumul' ];
$tabRet [] = $priv ;
}
2010-11-22 17:41:28 +00:00
2010-12-06 14:05:50 +00:00
$output = new PrivilegesCumulReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
}
2010-11-22 17:41:28 +00:00
2010-11-19 13:51:10 +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
2010-11-19 13:27:30 +00:00
*/
2010-11-19 13:51:10 +00:00
public function setSurveillance ( $siret , $email , $ref = '' , $source = 'annonces' , $delete = false , $encoursClient = 0 )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-19 13:51:10 +00:00
//Initialisation
if ( empty ( $ref )) $ref = '' ;
if ( empty ( $delete )) $delete = false ;
if ( empty ( $encoursClient )) $encoursClient = false ;
$error = new ErrorType ();
$tabRet = array ();
$siren = substr ( $siret , 0 , 9 );
$nic = substr ( $siret , 9 , 5 );
2010-11-19 13:27:30 +00:00
debugLog ( 'I' , " setSurveillances(siret= $siret , email= $email , ref= $ref , source= $source , delete= $delete ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
$tabIdentite = $iInsee -> getIdentiteLight ( $siren , $nic );
2010-11-19 13:51:10 +00:00
$iDb = new WDB ();
$login = $this -> tabInfoUser [ 'login' ];
$source = strtolower ( $source );
switch ( $source )
{
2010-11-19 13:27:30 +00:00
case 'insee' :
case 'annonces' :
case 'bilans' :
case 'actes' :
case 'privileges' :
2010-11-19 13:51:10 +00:00
case 'dir1igeants' : $encoursClient = 0 ; break ;
case 'score' : $encoursClient = $encoursClient * 1 ; break ;
default : $source = 'annonces' ; break ;
2010-11-19 13:27:30 +00:00
}
2010-11-19 13:51:10 +00:00
$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' ],
);
2010-11-19 13:27:30 +00:00
if ( $delete )
2010-11-19 13:51:10 +00:00
{
$tabUpdate = array_merge (
$tabUpdate ,
array ( 'dateSuppr' => date ( 'Y-m-d' ))
);
}
2010-11-19 13:27:30 +00:00
else
2010-11-19 13:51:10 +00:00
{
$tabUpdate = array_merge (
$tabUpdate ,
array ( 'dateAjout' => date ( 'Y-m-d' ), 'dateSuppr' => 0 )
);
}
if ( $delete || ! $iDb -> insert ( 'surveillances_site' , $tabUpdate ))
{
2010-11-19 13:27:30 +00:00
/*@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " debugSurv pour $login " ,
2010-11-19 13:51:10 +00:00
" source=' $source ' AND login=' $login ' AND email=' $email ' AND siren= $siren AND nic= $nic AND ref=' $ref ' " . EOL .
print_r ( $tabUpdate , true ) . EOL
); */
2010-11-19 13:27:30 +00:00
if ( ! $iDb -> update ( 'surveillances_site' , $tabUpdate , " source=' $source ' AND login=' $login ' AND email=' $email ' AND siren= $siren AND nic= $nic AND ref=' $ref ' " ))
2010-11-19 13:51:10 +00:00
{
$error -> errnum = 76841 ;
$error -> errmsg = 'Mise a jour impossible' ;
$result = 0 ;
}
else
{
$result = 1 ;
}
2010-11-19 13:27:30 +00:00
}
2010-11-19 13:51:10 +00:00
else
{
$result = 1 ;
}
$output = new SetSurveillanceReturn ();
$output -> error = $error ;
$output -> result = $result ;
2010-11-19 13:27:30 +00:00
}
2010-11-19 14:36:27 +00:00
/**
* Enter description here ...
* @ param string $siret
* @ param string $source
* @ param boolean $detail
* @ param integer $deb
* @ param integer $nbRet
* @ param string $tri
* @ return SurveillancesReturn
*/
public function getSurveillances ( $siret = '' , $source = 'annonces' , $detail = false , $deb = 0 , $nbRet = 100 , $tri = 'siren' )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-19 14:36:27 +00:00
//Initialisation
if ( empty ( $siret )) $siret = '' ;
if ( empty ( $source )) $source = 'annonces' ;
if ( empty ( $detail )) $detail = false ;
if ( empty ( $deb )) $deb = 0 ;
if ( empty ( $nbRet )) $nbRet = 100 ;
if ( empty ( $tri )) $tri = 'siren' ;
$error = new ErrorType ();
$tabRet = array ();
$siren = substr ( $siret , 0 , 9 ) * 1 ;
$nic = substr ( $siret , 9 , 5 ) * 1 ;
$tri = strtolower ( trim ( $tri ));
switch ( $tri )
{
2010-11-19 13:27:30 +00:00
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
}
2010-11-19 14:36:27 +00:00
$iDb = new WDB ();
$login = $this -> tabInfoUser [ 'login' ];
2010-11-19 13:27:30 +00:00
if ( $detail ) $strSelect = 'source, email, siren, nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi' ;
else $strSelect = 'source, email, siren, nic, ref, dateAjout, dateDerEnvoi' ;
if ( $source <> '' ) $strSource = " AND source=' $source ' " ;
else $strSource = '' ;
if ( $siren > 0 ) $strSiren = " AND siren= $siren " ;
else $strSiren = '' ;
// Il faut compter le nombre de siren au total
2010-11-19 14:36:27 +00:00
$tabTmp = $iDb -> select ( 'surveillances_site' , 'count(*) as nb' , " login=' $login ' AND dateSuppr=0 $strSiren $strSource " , false , MYSQL_ASSOC );
$nbRepTot = $tabTmp [ 0 ][ 'nb' ];
2010-11-19 13:27:30 +00:00
2010-11-19 14:36:27 +00:00
$tabTmp = $iDb -> select ( 'surveillances_site' , $strSelect , " login=' $login ' AND dateSuppr=0 $strSiren $strSource $orderBy LIMIT $deb , $nbRet " , false , MYSQL_ASSOC );
foreach ( $tabTmp as $i => $tabSurv )
{
2010-11-19 13:27:30 +00:00
if ( ! $detail )
2010-11-19 14:36:27 +00:00
{
2010-11-19 13:27:30 +00:00
$tabRet [] = array ( 'source' => $tabSurv [ 'source' ],
'email' => $tabSurv [ 'email' ],
'siren' => $tabSurv [ 'siren' ],
'nic' => $tabSurv [ 'nic' ],
'ref' => prepareString ( $tabSurv [ 'ref' ]),
'dateAjout' => $tabSurv [ 'dateAjout' ],
'dateDerEnvoi' => $tabSurv [ 'dateDerEnvoi' ],
);
2010-11-19 14:36:27 +00:00
}
else
{
2010-11-19 13:27:30 +00:00
if ( trim ( $tabSurv [ 'rs' ]) <> '' ) {
2010-11-19 14:36:27 +00:00
$rs = $tabSurv [ 'rs' ];
$cp = $tabSurv [ 'cp' ];
$ville = $tabSurv [ 'ville' ];
2010-11-19 13:27:30 +00:00
} else {
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
$tabIdentite = $iInsee -> getIdentiteLight ( $tabSurv [ 'siren' ], $tabSurv [ 'nic' ]);
2010-11-19 14:36:27 +00:00
$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
);
2010-11-19 13:27:30 +00:00
}
2010-11-19 14:36:27 +00:00
$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' ];
$liste -> encoursClient = $tabSurv [ 'encoursClient' ];
$liste -> rs = $rs ;
$liste -> cp = $cp ;
$liste -> ville = $ville ;
$liste -> dateDerEnvoi = $tabSurv [ 'dateDerEnvoi' ];
$tabRet [] = $liste ;
2010-11-19 13:27:30 +00:00
}
}
2010-11-19 14:36:27 +00:00
$criteres = new SurveillanceCriteres ();
$criteres -> siren = $siren ;
$criteres -> nic = $nic ;
$criteres -> source = $source ;
$result = new SurveillanceResult ();
$result -> criteres = $criteres ;
$result -> nbReponses = count ( $tabRet );
$result -> nbREponsesTotal = $nbRepTot ;
$result -> liste = $tabRet ;
$output = new SurveillanceReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-19 13:27:30 +00:00
}
2010-11-19 15:10:03 +00:00
/**
* Liste les mandataires correspondant à un nom donné
*
* @ param mixed $codeTribunal Identifiants BODACC du tribunal ou tableau d 'Identifiants numériques des cours d' appel
* @ param array $type Type de mandataire ( A ) dministrateur , ( M ) andataire , ( O ) ppositions , ( N ) otaires , a ( V ) ocat
* @ param int $cpDep Code postal ou département du mandataire
* @ return MandatairesReturn
*/
public function searchMandataires ( $nom , $type = array ( 'A' , 'M' ), $cpDep = 0 )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-19 15:10:03 +00:00
//Initialisation
if ( empty ( $type )) $type = array ( 'A' , 'M' );
if ( empty ( $cpDep )) $cpDep = 0 ;
$error = new ErrorType ();
$tabRet = array ();
2010-11-19 13:27:30 +00:00
debugLog ( 'I' , " Recherche de Mandataires ' $nom ' (Dep= $cpDep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
$tabTmp = $iInsee -> searchMandataires ( $nom , true , $type , $cpDep );
2010-11-19 15:10:03 +00:00
2010-11-19 13:27:30 +00:00
foreach ( $tabTmp as $i => $mand )
2010-11-19 15:10:03 +00:00
{
$mandataire = new Mandataire ();
$mandataire -> id = 'm' . $i ;
$mandataire -> mand = $mand ;
$tabRet [] = $mandataire ;
}
$output = new MandatairesReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
2010-11-19 13:27:30 +00:00
}
/**
2010-12-01 09:27:12 +00:00
* Retourne le bilan correspondant au siren , à l ' exercice et au formalisme demandé
2010-11-19 13:27:30 +00:00
*
2010-12-01 09:27:12 +00:00
* @ param string $siren Siren de l ' entreprise
* @ param string $millesime Date du bilan au format JJ / MM / AAAA
* @ param string $typeBilan N : Réel Normal , S : Réel Simplifié , C : Consolidé
* @ param string $ref Référence S & D obligatoire
* @ return BilanReturn
2010-11-19 13:27:30 +00:00
*/
2010-11-22 16:31:19 +00:00
public function getBilan ( $siren , $millesime , $typeBilan = 'N' , $ref = '' )
2010-11-19 13:27:30 +00:00
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-19 13:27:30 +00:00
//Initialisation
if ( empty ( $typeBilan )) { $typeBilan = 'N' ; }
if ( empty ( $ref )) { $ref = '' ; }
2010-11-22 16:31:19 +00:00
$error = new ErrorType ();
2010-11-19 13:27:30 +00:00
debugLog ( 'I' , " Bilan $millesime $typeBilan demandée pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-22 16:31:19 +00:00
$tabRet = array ();
2010-12-14 12:50:43 +00:00
if ( strlen ( $siren ) <> 9 ){
2010-11-19 13:27:30 +00:00
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-22 16:31:19 +00:00
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
2010-12-14 12:50:43 +00:00
} elseif ( $siren * 1 == 0 ) {
2010-11-19 13:27:30 +00:00
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-22 16:31:19 +00:00
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
2010-12-14 12:50:43 +00:00
} else {
2010-11-22 16:31:19 +00:00
$mBil = new MBilans ( $siren );
$tabBilan = $mBil -> getBilan ( $millesime , $typeBilan , $ref , true );
2010-11-19 13:27:30 +00:00
}
2010-12-02 16:26:07 +00:00
$resultBilan = new Bilan ();
$tabPoste = array ();
foreach ( $tabBilan as $key => $value ){
2010-12-14 12:50:43 +00:00
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' ))){
2010-12-02 16:26:07 +00:00
$resultPoste = new BilanPoste ();
2010-12-14 12:50:43 +00:00
$resultPoste -> id = $key ;
$resultPoste -> val = $value ;
$tabPoste [] = $resultPoste ;
2010-12-02 16:26:07 +00:00
} else {
2010-12-14 12:50:43 +00:00
$resultBilan -> $key = $value ;
2010-12-02 16:26:07 +00:00
}
}
$resultBilan -> POSTES = $tabPoste ;
2010-11-22 16:31:19 +00:00
$output = new BilanReturn ();
$output -> error = $error ;
2010-12-02 16:26:07 +00:00
$output -> result = $resultBilan ;
2010-11-22 16:31:19 +00:00
return $output ;
2010-11-19 13:27:30 +00:00
}
/**
* Retourne la liste des bilans disponible pour une entreprise
*
* @ param string $siren Siren de l ' entreprise
* @ return ListeBilansReturn
*/
public function getListeBilans ( $siren )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-19 13:27:30 +00:00
//Initialisation
$error = new ErrorType ();
$tabRet = array ();
debugLog ( 'I' , " Liste des Bilans demandée pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-12-03 17:12:59 +00:00
if ( strlen ( $siren ) <> 9 ) {
2010-11-19 13:27:30 +00:00
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
2010-12-03 17:12:59 +00:00
} elseif ( $siren * 1 == 0 ) {
2010-11-19 13:27:30 +00:00
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
2010-12-03 17:12:59 +00:00
} else {
2010-11-19 13:27:30 +00:00
$mBil = new MBilans ( $siren );
$tabBilans = $mBil -> listeBilans ( false );
foreach ( $tabBilans as $bilan )
{
$element = new ListeBilans ();
$element -> dateProvPartenaire = $bilan [ 'dateProvPartenaire' ];
$element -> dateInsert = $bilan [ 'dateInsert' ];
$element -> typeBilan = $bilan [ 'typeBilan' ];
$element -> dureeExercice = $bilan [ 'dureeExercice' ];
$element -> dateExercice = $bilan [ 'dateExercice' ];
$element -> millesime = $bilan [ 'millesime' ];
$element -> dateExercicePre = $bilan [ 'dateExercicePre' ];
$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__ );
$result = new ListeBilansResult ();
$result -> nbReponses = count ( $tabRet );
$result -> liste = $tabRet ;
$output = new ListeBilansReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
}
2010-11-19 15:27:05 +00:00
/**
* Vérifie si un siren existe en base Scores & Décisions
* @ param string $siren Siren de l ' entité
* @ return SirenExistantReturn
*/
public function isSirenExistant ( $siren )
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-19 15:27:05 +00:00
//Initialisation
$error = new ErrorType ();
$tabRet = array ();
$siren = trim ( substr ( $siren , 0 , 9 ));
$result = false ;
2010-11-19 13:27:30 +00:00
debugLog ( 'I' , " Siren existant demandée pour siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-19 15:27:05 +00:00
if ( $siren * 1 == 0 )
{
2010-11-19 13:27:30 +00:00
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
2010-11-19 15:27:05 +00:00
else
{
2010-11-25 10:34:00 +00:00
$iInsee = new MInsee ();
$entrep = $iInsee -> sirenExiste ( $siren );
2010-11-19 15:27:05 +00:00
if ( empty ( $entrep ))
{
debugLog ( 'W' , " Siren $siren non présent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
debugLog ( 'I' , " Siren $siren présent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$result = true ;
}
2010-11-19 13:27:30 +00:00
}
wsLog ( 'sirenExiste' , $siren );
2010-11-19 15:27:05 +00:00
$output = new SirenExistantReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-19 13:27:30 +00:00
}
2010-11-22 16:31:19 +00:00
/**
* 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
2010-11-22 17:04:51 +00:00
* @ return RechercheAnnonceReturn
*/
public function rechercheAnnonce ( $source , $dateAnnee , $numParution , $numAnnonce )
2010-11-22 16:31:19 +00:00
{
2010-11-25 10:40:35 +00:00
$this -> authenticate ();
2010-11-22 16:31:19 +00:00
//Initialisation
$error = new ErrorType ();
$tabRet = array ();
2010-11-19 13:27:30 +00:00
debugLog ( 'I' , " Annonce précise demandée pour $source , $dateAnnee , $numParution , $numAnnonce " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-22 16:31:19 +00:00
2010-11-19 13:27:30 +00:00
if ( strlen ( $dateAnnee ) == 4 ) $annee = $dateAnnee ;
else $annee = substr ( $dateAnnee , 0 , 4 );
2010-11-22 16:31:19 +00:00
$iDb = new WDB ( 'jo' );
2010-11-19 13:27:30 +00:00
2010-11-22 16:31:19 +00:00
switch ( strtoupper ( $source ))
{
2010-11-19 13:27:30 +00:00
case 'BODA' :
case 'BODB' :
case 'BODC' :
2010-11-22 17:04:51 +00:00
$lettre = substr ( strtoupper ( $source ), 3 , 1 );
2010-11-22 16:31:19 +00:00
if ( $annee < 2005 )
{
2010-11-22 17:04:51 +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 " ,
" e.JAL= $numJAL AND e.NOBOD= $numParution AND e.`DATE` BETWEEN $anneeDeb AND $anneeFin AND e.NOANN= $numAnnonce AND e.ANBASE=t.annonceNum " );
} else {
$res = $iDb -> select ( 'bodacc' ,
'Bodacc_Annee_Parution AS Annee_Parution, Bodacc_Num AS Num_Parution, Num_Annonce, Bodacc_Page AS Num_Page, Bodacc_Date_Parution AS Date_Parution, Tribunal_Dept AS Departement, Tribunal_Code, typeAnnonce, annonce' ,
" Bodacc_Code=' $lettre ' AND Bodacc_Annee_Parution= $annee AND Bodacc_Num= $numParution AND Num_Annonce= $numAnnonce " );
}
2010-11-19 13:27:30 +00:00
break ;
case 'ASSO' :
$res = $iDb -> select ( 'asso' , 'YEAR(Date_Parution) AS Annee_Parution, Num_Parution, Num_Annonce, pageDeb AS Num_Page, Date_Parution, Departement, codTribunal AS Tribunal_Code, typeAnnonce, Annonce_Html AS annonce' , " Date_Parution BETWEEN ' $annee -01-01' AND ' $annee -12-31' AND Num_Parution= $annee " . sprintf ( '%04d' , $numParution ) . " AND Num_Annonce= $numAnnonce " );
break ;
case 'BALO' :
$res = $iDb -> select ( 'balo' , " YEAR(Date_Parution) AS Annee_Parution, Num_Parution, Num_Affaire AS Num_Annonce, '' AS Num_Page, Date_Parution, '' AS Departement, '' AS Tribunal_Code, 'Insertion' AS typeAnnonce, Annonce_Html AS annonce " , " Date_Parution BETWEEN ' $annee -01-01' AND ' $annee -12-31' AND Num_Parution= $numParution AND Num_Affaire= $numAnnonce " );
break ;
}
2010-11-22 17:04:51 +00:00
2010-11-22 16:31:19 +00:00
if ( count ( $res ) > 0 )
{
2010-11-22 17:04:51 +00:00
$iBodacc = new MBodacc ();
2010-11-22 16:31:19 +00:00
foreach ( $res as $i => $etab )
{
$annonces = RechercheAnnonce ();
2010-11-22 17:04:51 +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' ];
$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 (
2010-11-22 16:31:19 +00:00
html_entity_decode ( $etab [ 'annonce' ]),
array ( '>' => '>' , '&' => '&' , '<' => '<' , '’' => " ' " )
));
2010-11-22 17:04:51 +00:00
$tabRet [] = $annonces ;
2010-11-19 13:27:30 +00:00
}
}
2010-11-22 17:04:51 +00:00
2010-11-22 16:31:19 +00:00
$nbTot = count ( $tabRet );
2010-11-22 17:04:51 +00:00
$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 ;
2010-11-22 16:31:19 +00:00
}
2010-11-17 16:45:20 +00:00
2010-12-02 17:02:48 +00:00
/**
* getRatios
* @ param string $siren
* @ param string $page
* @ return RatiosReturn
*/
public function getRatios ( $siren , $page = 'ratios' )
{
$this -> authenticate ();
//Initialisation
$error = new ErrorType ();
if ( empty ( $page )) $page = 'ratios' ;
2010-12-03 10:36:52 +00:00
$tabRatiosInfos = $tabRatiosSecteurs = $tabBilansR = array ();
$tabRatios2 = $tabRatiosEvol = array ();
2010-12-02 17:02:48 +00:00
$tabRet = array ();
debugLog ( 'I' , " Liste des Ratios demandée pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( strlen ( $siren ) <> 9 )
{
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
elseif ( $siren * 1 == 0 )
{
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
debugLog ( 'I' , " Liste des Ratios demandée pour $siren avant getIdentiteEntreprise " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iInsee = new MInsee ();
$tabIdentite = $iInsee -> getIdentiteEntreprise ( $siren , 0 , 0 , false , false );
debugLog ( 'I' , " Liste des Ratios demandée pour $siren après getIdentiteEntreprise " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$naf = $tabIdentite [ 'NafEnt' ];
$nafLib = $tabIdentite [ 'NafEntLib' ];
$efftr = $tabIdentite [ 'Effectif' ] * 1 ;
$fj = $tabIdentite [ 'FJ' ];
$mBil = new MBilans ( $siren );
$tabBilans = $mBil -> listeBilans ( true );
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getRatios sur $siren", print_r($tabBilans, true));
$nbBilans = count ( $tabBilans );
$tabBilan = $tabBil = array ();
2010-12-03 10:36:52 +00:00
if ( $nbBilans > 0 ){
2010-12-02 17:02:48 +00:00
$tabRatios =@ calculRatios ( $tabBilans , $tabIdentite , true );
2010-12-03 10:36:52 +00:00
}
2010-12-02 17:02:48 +00:00
$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 **/
2010-12-03 10:36:52 +00:00
$tabBorneMin = $tabBorneMax = array ();
2010-12-02 17:02:48 +00:00
foreach ( $tabFormules as $formule ) {
2010-12-03 10:36:52 +00:00
$id = $formule [ 'id' ] * 1 ;
$libelle = $formule [ 'libelle' ];
$unite = $formule [ 'unite' ];
$commentaires = $formule [ 'commentaires' ];
$ratiosInfos = new RatiosInfos ();
$ratiosInfos -> id = 'r' . $id ;
$ratiosInfos -> libelle = $formule [ 'libelle' ];
$ratiosInfos -> unite = $formule [ 'unite' ];
$ratiosInfos -> commentaires = $formule [ 'commentaires' ];
$tabRatiosInfos [] = $ratiosInfos ;
2010-12-02 17:02:48 +00:00
$tabBorneMin [ $id ] = $formule [ 'borneMin' ];
$tabBorneMax [ $id ] = $formule [ 'borneMax' ];
}
/** Tableau des années de bilans **/
$tabAnnees = array ();
// Tableau d'infos sur les bilans
foreach ( $tabRatios as $i => $R ) {
2010-12-03 10:36:52 +00:00
$bilansInfos = new RatiosBilansInfos ();
$bilansInfos -> dateCloture = $tabBilan [ $i ][ 'DATE_CLOTURE' ];
$bilansInfos -> duree = $tabBilan [ $i ][ 'DUREE_MOIS' ];
$bilansInfos -> devise = $tabBilan [ $i ][ 'MONNAIE' ];
$bilansInfos -> typeBilan = $tabBilan [ $i ][ 'CONSOLIDE' ];
$bilansInfos -> unite = 'U' ;
$tabBilansR [] = $bilansInfos ;
if ( substr ( $tabBilan [ $i ][ 'DATE_CLOTURE' ], 0 , 4 ) > 1900 ){
2010-12-02 17:02:48 +00:00
$tabAnnees [ $i ] = substr ( $tabBilan [ $i ][ 'DATE_CLOTURE' ], 0 , 4 );
2010-12-03 10:36:52 +00:00
}
2010-12-02 17:02:48 +00:00
}
2010-12-03 10:36:52 +00:00
2010-12-02 17:02:48 +00:00
foreach ( $tabRatios as $i => $R ) {
// Utilisation d'un index texte à cause du webservice
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 ];
}
2010-12-03 10:36:52 +00:00
$ratiosEntrep = new RatiosEntrep ();
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 );
}
$tabRatios2 [] = $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' ])))
2010-12-02 17:02:48 +00:00
)
$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' ;
2010-12-03 10:36:52 +00:00
$ratiosEntrepEvol = new RatiosEntrepEvol ();
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 , ',' , ' ' );
}
$tabRatiosEvol [] = $ratiosEntrepEvol ;
2010-12-02 17:02:48 +00:00
}
}
debugLog ( 'I' , " Liste des Ratios demandée pour $siren après EVOLUTION " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
/** Tableau des ratios secteurs */
2010-12-03 10:36:52 +00:00
$tabRatiosSecteurs = array ();
2010-12-02 17:02:48 +00:00
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 " , true , MYSQL_ASSOC );
$nbRatiosSec = 0 ;
$anneePre = $tabTmp [ 0 ][ 'annee' ];
$iAn = 0 ;
foreach ( $tabTmp as $tabTmp2 ) {
if ( $anneePre <> $tabTmp2 [ 'annee' ]) $iAn ++ ;
$Ridx = $tabTmp2 [ 'id' ];
if ( $tabTmp2 [ 'nombre' ] > $nbRatiosSec ) $nbRatiosSec = $tabTmp2 [ 'nombre' ];
if ( $tabRatiosInfos [ 'r' . $Ridx ][ '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 ];
2010-12-03 10:36:52 +00:00
$ratiosSecteur = new RatiosSecteur ();
if ( substr ( $montant , 0 , 1 ) == 'N' || substr ( $montant , 0 , 1 ) == '<' || substr ( $montant , 0 , 1 ) == '>' ){
$ratiosSecteur -> id = 'r' . $Ridx ;
$ratiosSecteur -> val = $montant ;
} else {
$ratiosSecteur -> id = 'r' . $Ridx ;
$ratiosSecteur -> val = round ( $montant , 2 );
}
$tabRatiosSecteurs [ $iAn ] = $ratiosSecteur ;
2010-12-02 17:02:48 +00:00
$anneePre = $tabTmp2 [ 'annee' ];
}
}
//$tabRatiosSecteurs=array(count($tabTmp), "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC");
$result = new RatiosResult ();
$result -> Nom = $tabIdentite [ 'Nom' ];
$result -> NafEnt = $tabIdentite [ 'NafEnt' ];
$result -> NafEntLib = $tabIdentite [ 'NafEntLib' ];
$result -> FJ = $fj ;
$result -> FJ_lib = $tabIdentite [ 'FJ_lib' ];
$result -> Siren = $siren ;
$result -> NbEntNaf = $nbRatiosSec ;
$result -> BilansInfos = $tabBilansR ;
$result -> RatiosInfos = $tabRatiosInfos ;
$result -> RatiosEntrep = $tabRatios2 ;
$result -> RatiosEntrepEvol = $tabRatiosEvol ;
$result -> RatiosSecteur = $tabRatiosSecteurs ;
2010-12-03 10:36:52 +00:00
2010-12-02 17:02:48 +00:00
debugLog ( 'I' , " Liste des Ratios demandée pour $siren RETURN " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( $page , $siren );
$output = new RatiosReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
}
}
2010-12-03 13:24:15 +00:00
/**
* getRapport
* @ param string $siren
* @ param integer $niveau
* @ param integer $id
* @ param boolean $forceVerif
* @ return RapportReturn
*/
public function getRapport ( $siren , $niveau = 3 , $id = 0 , $forceVerif = false )
{
$this -> authenticate ();
if ( empty ( $niveau )) $niveau = 3 ;
if ( empty ( $id )) $id = 0 ;
if ( empty ( $forceVerif )) $forceVerif = false ;
$error = new ErrorType ();
$result = new Rapport ();
$filtre = 0 ;
$idAnn = 0 ;
$accesDist = true ;
if ( $niveau == 1 ){
$result -> Indiscore = $this -> getIndiScore ( $siren , 0 , $accesDist );
} elseif ( $niveau == 2 ) {
$result -> Identite = $this -> getIdentite ( $siren , $id = 0 , $forceVerif );
$result -> Indiscore = $this -> getIndiScore ( $siren , 0 , $accesDist );
$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 , $forceVerif );
$result -> Indiscore = $this -> getIndiScore ( $siren , 0 , $accesDist );
$result -> Dirigeants = $this -> getDirigeants ( $siren , false );
$result -> Liens = $this -> getLiens ( $siren , true );
$result -> Ratios = $this -> getRatios ( $siren , $page = " rapport $niveau " );
$result -> Annonces = $this -> getAnnonces ( $siren , $filtre , $idAnn );
}
$output = new RapportReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
}
2010-12-02 17:02:48 +00:00
2010-09-08 13:40:57 +00:00
/**
2010-10-14 14:08:04 +00:00
* Retourne le statut du webservice
2010-11-08 17:25:06 +00:00
* @ return StatusReturn
2010-09-08 13:40:57 +00:00
*/
2010-11-08 17:25:06 +00:00
public function status ()
2010-09-15 16:18:38 +00:00
{
2010-09-13 09:54:49 +00:00
/* @ 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
2010-09-08 13:40:57 +00:00
*/
2010-09-23 16:20:08 +00:00
//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' ]);
2010-11-08 17:25:06 +00:00
$error = new StatusReturn ();
2010-10-18 10:04:21 +00:00
//Test connexion à la base de données
2010-11-05 09:54:50 +00:00
$db = new WDB ( 'jo' );
2010-10-18 10:04:21 +00:00
if ( $db === false )
{
$error -> statusCode = 1 ;
$error -> statusMsg = 'Erreur critique' ;
}
else
{
$error -> statusCode = 0 ;
$error -> statusMsg = 'Services disponible (beta)' ;
}
2010-09-08 13:40:57 +00:00
return $error ;
}
2010-11-08 17:25:06 +00:00
}
2010-11-25 09:11:42 +00:00
?>