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