1405 lines
56 KiB
PHP
1405 lines
56 KiB
PHP
<?php
|
|
require_once __DIR__ . '/Types.php';
|
|
|
|
class Entreprise extends Scores_Ws_Server
|
|
{
|
|
/**
|
|
* 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;
|
|
|
|
$tabRet = array();
|
|
$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');
|
|
}
|
|
|
|
$db = new Metier_Util_Db();
|
|
|
|
$iInsee = new Metier_Insee_MInsee($db);
|
|
$iInsee->setLogger();
|
|
$entrep = $iInsee->getIdentiteEntreprise($siren, $nic, $id, $forceVerif);
|
|
if (empty($entrep) || empty($entrep['id']) ) {
|
|
$this->sendError('1020');
|
|
}
|
|
|
|
$identite = new Identite();
|
|
$identite->id = $entrep['id'];
|
|
$identite->Siret = $entrep['Siret'];
|
|
$identite->SiretSiege = $entrep['SiretSiege'];
|
|
$identite->Siege = $entrep['Siege'];
|
|
$identite->AncienSiege = $entrep['AncienSiege'];
|
|
$identite->AncienSiegeDateFin = $entrep['AncienSiegeDateFin'];
|
|
$identite->TribunalCode = $entrep['Tribunal'];
|
|
$identite->TribunalLib = $entrep['TribunalLib'];
|
|
$identite->NumRC = $entrep['numRC'];
|
|
$identite->Actif = $entrep['Actif'];
|
|
$identite->ActifEco = $entrep['ActifEco'];
|
|
$identite->ActifEcoDate = $entrep['ActifEcoDate'];
|
|
$identite->ActifEcoType = $entrep['ActifEcoType'];
|
|
$identite->EntActiveRCS = $entrep['EntActiveRCS'];
|
|
$identite->AutreId = $entrep['AutreId'];
|
|
$identite->Source = $entrep['Source'];
|
|
$identite->SourceId = $entrep['SourceId'];
|
|
$identite->Isin = $entrep['Isin'];
|
|
$identite->Nom = $entrep['NOMEN_LONG'];
|
|
if (empty($identite->Nom)) {
|
|
$identite->Nom = strtr($entrep['Nom'],'/*',' ');
|
|
}
|
|
$identite->Nom2 = $entrep['Nom2'];
|
|
$identite->NomLong = $entrep['nomLong'];
|
|
$identite->NomCommercial = $entrep['NomCommercial'];
|
|
$identite->Siret = $entrep['Siret'];
|
|
$identite->Sigle = $entrep['Sigle'];
|
|
$identite->SigleLong = $entrep['sigleLong'];
|
|
$identite->Enseigne = $entrep['Enseigne'];
|
|
$identite->EnseigneLong = $entrep['enseigneLong'];
|
|
$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->AdresseDistSP = $entrep['AdresseDistSP'];
|
|
$identite->CP = $entrep['CP'];
|
|
$identite->Ville = $entrep['Ville'];
|
|
$identite->Pays = $entrep['Pays'];
|
|
$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'];
|
|
|
|
// --- Indicateur Adresse RNVP
|
|
try {
|
|
$rnvpM = new Application_Model_VillesRnvpSources();
|
|
$sql = $rnvpM->select(true)->columns(array('dateRetourRnvp','codeRetour'))
|
|
->where('source=?', $entrep['Source'])->where('source_id=?', $entrep['SourceId']);
|
|
$rnvpResult = $rnvpM->fetchRow($sql);
|
|
if ($rnvpResult !== null) {
|
|
$identite->AdresseRnvpDate = $rnvpResult->dateRetourRnvp;
|
|
$identite->AdresseRnvpCode = $rnvpResult->codeRetour;
|
|
}
|
|
} catch (Zend_Db_Exception $e) {}
|
|
|
|
$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'];
|
|
|
|
$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'];
|
|
$identite->FJ2_Lib = $entrep['FJ2_Lib'];
|
|
$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'];
|
|
$identite->CapitalType = $entrep['CapitalType'];
|
|
|
|
$identite->DateCreaEt = Metier_Util_Date::dateT('Ymd','Y-m-d',$entrep['DateCreaEt']);
|
|
$identite->DateCreaEn = Metier_Util_Date::dateT('Ymd','Y-m-d',$entrep['DateCreaEn']);
|
|
$identite->DateClotEt = $entrep['DateClotEt']; //@todo : date
|
|
$identite->DateImmat = $entrep['dateImmat'];
|
|
$identite->DateRadiation = $entrep['dateRad'];
|
|
$identite->EffEnTr = $entrep['EffEnTr'];
|
|
$identite->EffEnTrLib = $entrep['EffEnTrLib'];
|
|
$identite->Effectif = $entrep['Effectif'];
|
|
$identite->EffEtTr = $entrep['EffEtTr'];
|
|
$identite->EffEtTrLib = $entrep['EffEtTrLib'];
|
|
$identite->EffectifEtab = $entrep['EffectifEtab'];
|
|
$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->TrancheCAType = $entrep['TrancheCAType'];
|
|
$identite->dir1Code = $entrep['dir1Code'];
|
|
$identite->dir1Titre = $entrep['dir1Titre'];
|
|
$identite->dir1NomPrenom = $entrep['dir1NomPrenom'];
|
|
$identite->dir1DateFct = $entrep['dir1DateFct']; //@todo : date
|
|
$identite->dir1DateNaiss = $entrep['dir1DateNaiss']; //@todo : date
|
|
$identite->dir1LieuNaiss = $entrep['dir1LieuNaiss'];
|
|
$identite->dir2Code = $entrep['dir2Code'];
|
|
$identite->dir2Titre = $entrep['dir2Titre'];
|
|
$identite->dir2NomPrenom = $entrep['dir2NomPrenom'];
|
|
$identite->dir2DateFct = $entrep['dir2DateFct']; //@todo : date
|
|
$identite->dir2DateNaiss = $entrep['dir2DateNaiss']; //@todo : date
|
|
$identite->dir2LieuNaiss = $entrep['dir2LieuNaiss'];
|
|
$identite->Rivoli = $entrep['Rivoli'];
|
|
|
|
$identite->InfosIris = new stdClass();
|
|
$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->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 = new stdClass();
|
|
$identite->Bilan->Millesime = $entrep['bilanAnnee'];
|
|
$identite->Bilan->Cloture = $entrep['bilanDate']; //@todo : date
|
|
$identite->Bilan->Duree = $entrep['bilanMois'];
|
|
$identite->Bilan->Devise = $entrep['bilanDevise'];
|
|
$identite->Bilan->Capital = $entrep['bilanDA'];
|
|
$identite->Bilan->CA = $entrep['bilanFL'];
|
|
$identite->Bilan->CAestime = $entrep['bilanFLestime'];
|
|
$identite->Bilan->Resultat = $entrep['bilanHN'];
|
|
$identite->Bilan->Effectif = $entrep['bilanYP'];
|
|
|
|
$iBourse = new Metier_Partenaires_MBourse();
|
|
$bourse = $iBourse->getInfosBourse($siren);
|
|
if (count($bourse) > 0 ) {
|
|
$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
|
|
|
|
// --- Ancien NAF
|
|
if (preg_match('/NAF4/i', $this->User->pref)) {
|
|
$entrep2 = $iInsee->getNaf4($siren, $nic, $id);
|
|
if ( $entrep2 !== false ) {
|
|
$identite->Naf4Ent = $entrep2['apen4'];
|
|
$identite->Naf4Etab = $entrep2['apet4'];
|
|
$identite->Naf4EntLib = $entrep2['apen4_lib'];
|
|
$identite->Naf4EtabLib = $entrep2['apet4_lib'];
|
|
}
|
|
}
|
|
|
|
// --- Détermination du groupe - Tête de groupe
|
|
if (intval($siren) > 100) {
|
|
$lienM = new Metier_Liens_Base();
|
|
$lienM->setId($siren, 'siren');
|
|
$grpHeadId = $lienM->getHead(null, 50);
|
|
$grpFiche = $lienM->getIdentity();
|
|
if ($grpFiche->id != $grpHeadId) {
|
|
$grpHeadFiche = $lienM->getIdentity($grpHeadId);
|
|
$identite->GroupeId = str_pad($grpHeadFiche->id, 20, 0, STR_PAD_LEFT); // Ajouter source
|
|
$identite->GroupeName = $grpHeadFiche->RS;
|
|
// --- Recherche code Isin
|
|
$nbIdNum = 3;
|
|
for ($i=0;$i<$nbIdNum;$i++) {
|
|
if( !empty($grpHeadFiche->{'idLoc'.$i.'Num'}) && $grpHeadFiche->{'idLoc'.$i.'Type'} == 63 ) {
|
|
$identite->GroupeIsin = $grpHeadFiche->{'idLoc'.$i.'Num'};
|
|
break;
|
|
}
|
|
}
|
|
$identite->GroupeCountryCode = $grpHeadFiche->adresse_pays;
|
|
if (!empty($grpHeadFiche->adresse_pays)) {
|
|
try {
|
|
$countryM = new Application_Model_JoTabPays();
|
|
$sql = $countryM->select()->from($countryM, array('codPays3', 'libPays'));
|
|
$result = $countryM->fetchAll($sql);
|
|
} catch (Zend_Db_Adapter_Exception $e) {}
|
|
|
|
$tabPays = array();
|
|
if ( $result->count()>0 ) {
|
|
foreach ( $result as $item ) {
|
|
$tabPays[$item->codPays3] = $item->libPays;
|
|
}
|
|
}
|
|
$libPays = '';
|
|
if ($grpHeadFiche->adresse_pays!='') {
|
|
$libPays = array_key_exists($grpHeadFiche->adresse_pays, $tabPays) ?
|
|
$tabPays[$grpHeadFiche->adresse_pays] : $grpHeadFiche->adresse_pays;
|
|
} else {
|
|
$libPays = $tabPays['FRA'];
|
|
}
|
|
$identite->GroupeCountryLabel = $libPays;
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->wsLog('identite', $siret, $id);
|
|
|
|
return $identite;
|
|
}
|
|
|
|
/**
|
|
* Avis RNCS
|
|
* @param string $siren
|
|
* @return AvisRncs
|
|
*/
|
|
public function getAvisRncs($siren)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('avisrncs');
|
|
|
|
$len = strlen($siren);
|
|
if ( $len != 9 ) {
|
|
$this->sendError('1020');
|
|
}
|
|
|
|
$output = new AvisRncs();
|
|
$iDb = new Metier_Util_Db();
|
|
$rncs = new Metier_Partenaires_MRncs();
|
|
|
|
//jo.etablissements => insee uniquement, rncs ?
|
|
|
|
//Entreprise
|
|
$infosEtab = $rncs->getIdentiteEtab($siren);
|
|
if ( $infosEtab === false ) {
|
|
throw new SoapFault('MSG', "Cette entreprise n'est pas inscrite au RNCS ou radié depuis plus de 5 ans.");
|
|
}
|
|
|
|
$output->Nom = $infosEtab['raisonSociale']; //@todo personne physique
|
|
$output->Sigle = $infosEtab['sigle'];
|
|
$output->Enseigne = $infosEtab['enseigne'];
|
|
$output->NomCommercial = $infosEtab['nomCommercial'];
|
|
|
|
$output->Siren = $infosEtab['siren'];
|
|
$output->NumGest = $infosEtab['numRC'];
|
|
$output->RadiationDate = $infosEtab['dateRad'];
|
|
$output->ImmatDate = $infosEtab['dateImma'];
|
|
$output->NafCode = $infosEtab['nafEnt'];
|
|
$output->NafLabel = $infosEtab['nafEntLib'];
|
|
|
|
if (empty($infosEtab['dateRad']) || $infosEtab['dateRad'] = '0000-00-00') {
|
|
$output->TribunalCode = $infosEtab['triCode']; //@todo
|
|
$output->TribunalLabel = $infosEtab['libGreffe']; // @todo
|
|
$output->FjCode = $infosEtab['cj'];
|
|
$output->FjLabel = $infosEtab['cjLib'];
|
|
$output->Capital = $infosEtab['capital'];
|
|
$output->CapitalDev = 'EUR';
|
|
if ( !empty($infosEtab['capitalDevIso'])) {
|
|
$output->CapitalDev = $infosEtab['capitalDevIso'];
|
|
}
|
|
$output->CapitalType = $infosEtab['capitalType'];
|
|
|
|
$output->SiegeAdresseNum = intval($infosEtab['adrNumVoie']);
|
|
$output->SiegeAdresseBtq = $infosEtab['adrIndRep'];
|
|
$output->SiegeAdresseVoieType = $infosEtab['adrTypeVoie'] ;
|
|
$output->SiegeAdresseVoieLabel = $infosEtab['adrVoie'];
|
|
$output->SiegeAdresseComp = $infosEtab['adrComp'];
|
|
$output->SiegeAdresseCP = $infosEtab['cp'];
|
|
$output->SiegeAdresseVille = $infosEtab['commune'];
|
|
|
|
$output->DateMajRCS = $infosEtab['DateMajRCS'];
|
|
|
|
//Durée de la société - impossible
|
|
$output->DureeDate = '';
|
|
|
|
//Date du dernier bilan - MOIS/JOUR au pire chercher dans l'annonce
|
|
try {
|
|
$bilanM = new Application_Model_JoBilans();
|
|
$sql = $bilanM->select(true)
|
|
->columns(array('dateExercice'))
|
|
->where('siren=?', $siren)
|
|
->order('dateExercice DESC')->limit(1);
|
|
$result = $bilanM->fetchRow($sql);
|
|
if ($result !== null) {
|
|
$output->CompteArretMois = substr($result->dateExercice,4,2);
|
|
$output->CompteArretJour = substr($result->dateExercice,6,2);
|
|
}
|
|
} catch(Zend_Db_Exception $e) {}
|
|
|
|
//=> Avec l'adresse du premier siège
|
|
$output->ConstitutionTribunalCode = '';
|
|
$output->ConstitutionTribunalLabel = '';
|
|
|
|
$iInsee = new Metier_Insee_MInsee($iDb);
|
|
$dirs = $iInsee->getDirigeants($siren, false);
|
|
$liste = array();
|
|
foreach ($dirs as $nb => $dir)
|
|
{
|
|
$dirigeant = new AvisRncsAdmin();
|
|
|
|
$dirigeant->Code = $dir['Fonction'];
|
|
$dirigeant->Label = $dir['Titre'];
|
|
$dirigeant->CompanyName = $dir['Societe'];
|
|
$dirigeant->CompanyId = (array_key_exists('Siren', $dir) && intval($dir['Siren'])!=0) ? $dir['Siren'] : '' ;
|
|
$dirigeant->Civilite = $dir['Civilite'];
|
|
$dirigeant->Nom = $dir['Nom'];
|
|
$dirigeant->Prenom = $dir['Prenom'];
|
|
$dirigeant->NomUsage = $dir['NomUsage'];
|
|
$dirigeant->NaissanceDate = $dir['NaissDate'];
|
|
$dirigeant->NaissanceVille = $dir['NaissVille'];
|
|
$dirigeant->NaissanceCp = $dir['NaissDepPays'];
|
|
$liste[] = $dirigeant;
|
|
}
|
|
$output->Administration = $liste;
|
|
|
|
$insee = $iInsee->getIdentiteEntreprise($siren);
|
|
|
|
//Origine, code à transformer - getIdentiteEntreprise - insee
|
|
$output->Origine = $insee['OrigineCreation'];
|
|
|
|
//Activité réelle - getIdentiteEntreprise - insee
|
|
$output->Activite = $insee['Activite'];
|
|
$output->BodaccActivite = $insee['Activite'];
|
|
|
|
//Date de création à l'insee - getIdentiteEntreprise - insee
|
|
//@todo : Aller cherche dans les annonces bodacc création + acquisition
|
|
$output->ActiviteDate = substr($insee['DateCreaEn'],0,4).'-'.substr($insee['DateCreaEn'],4,2).'-'.substr($insee['DateCreaEn'],6,2);
|
|
|
|
//Type d'exploitation - getIdentiteEntreprise - insee
|
|
$output->Exploitation = $insee['TypeExploitation'];
|
|
|
|
//Liste des jugements
|
|
$output->Evenements = array();
|
|
$evens = $rncs->getListeJugements($siren);
|
|
if ( count($evens)>0 ) {
|
|
foreach ( $evens as $even ) {
|
|
$output->Evenements[] = $even['dateEffet'] . ' - ' . $even['libEven'];
|
|
}
|
|
}
|
|
|
|
//Liste des dépots
|
|
$output->Depots = array();
|
|
$infogreffe = new Metier_Infogreffe_DocAC();
|
|
$infogreffe->setSiren($siren);
|
|
$depots = $infogreffe->getList();
|
|
if ( count($depots)>0 ) {
|
|
$i = 0;
|
|
$listNumDepot = array();
|
|
foreach ( $depots as $depot ) {
|
|
$acte = new AvisRncsDepot();
|
|
$acte->DepotNum = $depot->DepotNum;
|
|
$acte->DepotDate = $depot->DepotDate;
|
|
$acte->ActeNum = $depot->ActeNum;
|
|
$acte->ActeDate = $depot->ActeDate;
|
|
$acte->ActeType = $depot->ActeType;
|
|
$acte->ActeTypeLabel = $depot->ActeTypeLabel;
|
|
$acte->infos = $depot->infos;
|
|
$result = $rncs->getListeDepots($siren, $depot->DepotDate);
|
|
if (count($result)>0) {
|
|
foreach ($result as $infos) {
|
|
$acte->infos[] = $infos['libDepot'];
|
|
}
|
|
}
|
|
|
|
//Acte constitutif - Statut
|
|
//@todo : STATUTS CONSTITUTIFS
|
|
$date = substr($depot->ActeDate,0,4);
|
|
if ( in_array($depot->ActeType, array('04')) && intval($date)>1995 ) {
|
|
$output->ConstitutionActeDate = $depot->ActeDate;
|
|
$output->ConstitutionDepotDate = $depot->DepotDate;
|
|
}
|
|
|
|
$i++;
|
|
if ($i < 4 || $i > count($depots)-4) {
|
|
$output->Depots[] = $acte;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//Liste des établissements actifs au RNCS
|
|
$output->Etablissements = array();
|
|
$result = $iInsee->getEtablissements($siren, '', 0, 200, 200, 0, 1);
|
|
if ( count($result['reponses'])>0 ) {
|
|
foreach ( $result['reponses'] as $item ) {
|
|
$output->Etablissements[] = $item['Adresse'] . ' ' . $item['Adresse2'] . ' - ' .
|
|
$item['CP'] . ' ' . strtoupper($item['Ville']);
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->wsLog('avisrncs', $siren);
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* RNVP
|
|
* @param string $companyId
|
|
* Identifiant etablissement
|
|
* @param string $type (sd|siren, sd ou null par defaut)
|
|
* Type de l'identifiant :
|
|
* sd|null = Identifiant Scores & Decisions
|
|
* siren = SIRET de l'etablissement
|
|
* @throws SoapFault
|
|
* @return Rnvp
|
|
*/
|
|
public function getRNVP($companyId, $type = null)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('RNVP');
|
|
|
|
// --- Identifiant SD : source + id
|
|
if ($type === null) {
|
|
$source = substr($companyId,0,3);
|
|
$sourceId = substr($companyId,3,20);
|
|
}
|
|
// --- Siren
|
|
elseif (strtolower($type) == 'siren') {
|
|
if ( strlen($companyId) != 14 || intval($siren) == 0 ) {
|
|
throw new SoapFault('ERR', 'Identifiant incorrect.');
|
|
}
|
|
try {
|
|
$etabM = new Application_Model_JoEtablissements();
|
|
$sql = $etabM->select(true)->columns(array('LPAD(source,3,0) AS source', 'LPAD(source_id,20,0) AS sourceId'))
|
|
->where('siren=?', substr($companyId,0,9))
|
|
->where('nic=?', substr($companyId,9,5));
|
|
$etabResult = $etabM->fetchRow($sql);
|
|
if ($etabResult === null) {
|
|
throw new SoapFault('MSG', 'Etablissement inconnu.');
|
|
}
|
|
$source = $etabResult->source;
|
|
$sourceId = $etabResult->source_id;
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
}
|
|
// --- Erreur
|
|
else {
|
|
throw new SoapFault('ERR', 'type identifiant inconnu');
|
|
}
|
|
|
|
// --- Info RNVP
|
|
try {
|
|
$rnvp = new Metier_Rnvp_Adresse();
|
|
$rnvp->setCompanyId($companyId);
|
|
$infoRNVP = new Rnvp();
|
|
$infoRNVP = $rnvp->format();
|
|
} catch (Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
$this->wsLog('rnvp', 0, $companyId);
|
|
|
|
if ($infoRNVP === null) {
|
|
throw new SoapFault('MSG', 'Aucun résultat.');
|
|
}
|
|
|
|
return $infoRNVP;
|
|
}
|
|
|
|
/**
|
|
* Liste des privilèges
|
|
* @param string $companyId
|
|
* @throws SoapFault
|
|
* @return PrivilegeList
|
|
*/
|
|
public function getPrivilegeList($companyId)
|
|
{
|
|
$this->authenticate();
|
|
if ( strlen($companyId) != 9 ) {
|
|
throw new SoapFault('ERR', 'Identifiant incorrect.');
|
|
}
|
|
|
|
// --- Durée de vie
|
|
$privSecuLifetime = 900;
|
|
$privTresLifetime = 1460;
|
|
|
|
$privSql = "SELECT id, dateEven, greffe , numDebiteur, sirenage, typeEven, dateFraiche, codeRev,
|
|
debRaisonSociale, debSigle, debCiv, debNom, debPrenom, debConjoint, debUsage, debEnseigne,
|
|
debNumVoie, debTypVoie, debLibVoie, debAdrComp, debCP, debVille, debPays,
|
|
insType, insLib, insNum, insDate, insObjet, insMontant, insDev, insDateEch, insDateFin,
|
|
creNom, creNumVoi, creTypVoi, creLibVoi, creAdrComp1, creAdrComp2, creCP, creVille, crePays, creAutres,
|
|
radDate, radMention, radPartiel, radPartMt, radDev, radDiv, idFichier, DATE_FORMAT(dateInsert,'%Y-%m-%d') AS dateInsert
|
|
FROM jo.greffes_privileges
|
|
WHERE siren=$companyId AND (
|
|
(insType='03' AND DATEDIFF(NOW(),insDate) <= $privSecuLifetime) OR
|
|
(insType='04' AND DATEDIFF(NOW(),insDate) <= $privTresLifetime)
|
|
)
|
|
ORDER BY insDate DESC;";
|
|
|
|
try {
|
|
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
|
|
$privResult = $db->fetchAll($privSql, null, Zend_Db::FETCH_OBJ);
|
|
} catch(Zend_Db_Exception $e) {
|
|
if ($this->User->idClient==1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
$output = new PrivilegeList();
|
|
$output->NbTotal = 0;
|
|
$output->MtTotal = 0;
|
|
$output->Cumul = array();
|
|
|
|
$privileges = array();
|
|
$cumul = array();
|
|
if (count($privResult) > 0) {
|
|
foreach($privResult as $p) {
|
|
// --- Cumul des privileges par type (Nb, Montant)
|
|
$output->NbTotal++;
|
|
$output->MtTotal+= $p->insMontant;
|
|
if ( array_key_exists($p->insType, $cumul) ) {
|
|
$cumul[$p->insType]['Nb']++;
|
|
$cumul[$p->insType]['Mt'] = $cumul[$p->insType]['Mt'] + $p->insMontant;
|
|
} else {
|
|
$cumul[$p->insType]['Nb'] = 1;
|
|
$cumul[$p->insType]['Mt'] = $p->insMontant;
|
|
}
|
|
// --- Liste des privileges
|
|
$privilege = new Privilege();
|
|
$privilege->Id = $p->id;
|
|
$privilege->Type = $p->insType;
|
|
|
|
$privilege->TypeLabel = '';
|
|
switch ($p->insType) {
|
|
case '03':
|
|
$privilege->TypeLabel = 'Privilèges de la sécurité sociale et des régimes complémentaires';
|
|
break;
|
|
case '04':
|
|
$privilege->TypeLabel = 'Privilèges du trésor public';
|
|
break;
|
|
}
|
|
$privilege->Date = $p->insDate;
|
|
$privilege->Mt = $p->insMontant;
|
|
$privilege->CreancierNom = $p->creNom;
|
|
$privilege->CreancierAdresse1 = trim($p->creNumVoi);
|
|
$privilege->CreancierAdresse1.= ' '.trim($p->creTypVoi);
|
|
$privilege->CreancierAdresse1.= ' '.trim($p->creLibVoi);
|
|
$privilege->CreancierAdresse2 = $p->creAdrComp1;
|
|
$privilege->CreancierAdresse3 = $p->creAdrComp2;
|
|
$privilege->CreancierCP = $p->creCP;
|
|
$privilege->CreancierVille = $p->creVille;
|
|
$privilege->CreancierPays = $p->crePays;
|
|
$privilege->CreancierAutres = $p->creAutres;
|
|
|
|
$privileges[] = $privilege;
|
|
}
|
|
}
|
|
$output->List = $privileges;
|
|
|
|
if (count($cumul) > 0 ) {
|
|
foreach ($cumul as $k => $v) {
|
|
$c = new PrivilegeCumul();
|
|
$c->Type = $k;
|
|
$c->Nb = $v['Nb'];
|
|
$c->Mt = $v['Mt'];
|
|
$output->Cumul[] = $c;
|
|
}
|
|
}
|
|
|
|
// --- Log
|
|
$this->wsLog('privlist', $companyId);
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Détail d'un privilège
|
|
* @param string $companyId
|
|
* @param int $id
|
|
* @throws SoapFault
|
|
* @return PrivilegeDetail
|
|
*/
|
|
public function getPrivilegeDetail($companyId, $id)
|
|
{
|
|
$this->authenticate();
|
|
if ( strlen($companyId) != 9 ) {
|
|
throw new SoapFault('ERR', 'Identifiant incorrect.');
|
|
}
|
|
|
|
$privSql = "SELECT id, dateEven, greffe , numDebiteur, sirenage, typeEven, dateFraiche, codeRev,
|
|
debRaisonSociale, debSigle, debCiv, debNom, debPrenom, debConjoint, debUsage, debEnseigne,
|
|
debNumVoie, debTypVoie, debLibVoie, debAdrComp, debCP, debVille, debPays,
|
|
insType, insLib, insNum, insDate, insObjet, insMontant, insDev, insDateEch, insDateFin,
|
|
creNom, creNumVoi, creTypVoi, creLibVoi, creAdrComp1, creAdrComp2, creCP, creVille, crePays, creAutres,
|
|
radDate, radMention, radPartiel, radPartMt, radDev, radDiv, idFichier, DATE_FORMAT(dateInsert,'%Y-%m-%d') AS dateInsert
|
|
FROM jo.greffes_privileges
|
|
WHERE siren=$companyId AND id=$id";
|
|
|
|
try {
|
|
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
|
|
$p = $db->fetchRow($privSql, null, Zend_Db::FETCH_OBJ);
|
|
} catch(Zend_Db_Exception $e) {
|
|
if ($this->User->idClient==1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
$iRncs = new Metier_Partenaires_MRncs();
|
|
|
|
$privilege = new PrivilegeDetail();
|
|
$privilege->Id = $p->id;
|
|
$privilege->Type = $p->insType;
|
|
$privilege->TypeLabel = '';
|
|
switch ($p->insType) {
|
|
case '03':
|
|
$privilege->TypeLabel = 'Privilèges de la sécurité sociale et des régimes complémentaires';
|
|
break;
|
|
case '04':
|
|
$privilege->TypeLabel = 'Privilèges du trésor public';
|
|
break;
|
|
}
|
|
$privilege->Num = $p->insNum;
|
|
$privilege->Objet = $p->insObjet;
|
|
$privilege->Date = $p->insDate;
|
|
$privilege->DateFresh = $p->dateFraiche;
|
|
$privilege->DateInsert = $p->dateInsert;
|
|
$privilege->DateEcheance = $p->insDateEch;
|
|
$privilege->DateFin = $p->insDateFin;
|
|
$privilege->Mt = $p->insMontant;
|
|
$privilege->Devise = $p->insDev;
|
|
$privilege->DebiteurNum = $p->numDebiteur;
|
|
$privilege->Greffe = $p->greffe;
|
|
$privilege->GreffeLabel = $iRncs->getLibTribunal($p->greffe);
|
|
$privilege->RadiationDate = $p->radDate;
|
|
$privilege->RadiationMention = $p->radMention;
|
|
$privilege->RadiationPartiel = $p->radPartiel;
|
|
$privilege->RadiationMt = $p->radPartMt;
|
|
$privilege->RadiationDevise = $p->radDev;
|
|
$privilege->CreancierNom = $p->creNom;
|
|
$privilege->CreancierAdresse1 = trim($p->creNumVoi);
|
|
$privilege->CreancierAdresse1.= ' '.trim($p->creTypVoi);
|
|
$privilege->CreancierAdresse1.= ' '.trim($p->creLibVoi);
|
|
$privilege->CreancierAdresse2 = $p->creAdrComp1;
|
|
$privilege->CreancierAdresse3 = $p->creAdrComp2;
|
|
$privilege->CreancierCP = $p->creCP;
|
|
$privilege->CreancierVille = $p->creVille;
|
|
$privilege->CreancierPays = $p->crePays;
|
|
$privilege->CreancierAutres = $p->creAutres;
|
|
|
|
// --- Log
|
|
$this->wsLog('privdetail', $companyId, $id);
|
|
|
|
return $privilege;
|
|
}
|
|
|
|
protected function getPrivilegeHisto($companyId)
|
|
{
|
|
$this->authenticate();
|
|
if ( strlen($companyId) != 9 ) {
|
|
throw new SoapFault('ERR', 'Identifiant incorrect.');
|
|
}
|
|
|
|
// Liste de tous les privileges actif et inactif
|
|
|
|
// --- Log
|
|
$this->wsLog('privhisto', $companyId);
|
|
}
|
|
|
|
/**
|
|
* Liste des contentieux
|
|
* @param string $companyId
|
|
* Siren de l'entité
|
|
* @param string $tiers
|
|
* Type du tier DE=Demandeur, DF=Defendeur
|
|
* @param int $p
|
|
* offset
|
|
* @param int $limit
|
|
* Nombre d'éléments par page
|
|
* @throws SoapFault
|
|
* @return GreffeAffaireList
|
|
*/
|
|
public function getGreffeAffaireList($companyId, $tiers = 'DE', $p = 0, $limit = 20)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('contentieux');
|
|
|
|
if ( strlen($companyId) != 9 ) {
|
|
throw new SoapFault('ERR', 'Identifiant incorrect.');
|
|
}
|
|
if (!in_array($tiers, array('DE', 'DF'))) {
|
|
$tiers = 'DE';
|
|
}
|
|
|
|
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
|
|
|
|
// --- Recherche de tiers (type DE ou DF) apparaissant dans les affaires
|
|
$tierSql = "SELECT count(idAffaire) AS Nb FROM jo.greffes_affaires_siren " .
|
|
"WHERE entSiren=".$companyId." AND qualite='".$tiers."'";
|
|
try {
|
|
$tierResult = $db->fetchRow($tierSql, null, Zend_DB::FETCH_OBJ);
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient==1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
$totalNb = 0;
|
|
if ($tierResult !== null) {
|
|
$totalNb = $tierResult->Nb;
|
|
}
|
|
|
|
$output = new GreffeAffaireList();
|
|
$output->Nb = $totalNb;
|
|
|
|
if (count($totalNb) > 0) {
|
|
// --- Selection des affaires
|
|
$tierSubQuery = "SELECT idAffaire FROM jo.greffes_affaires_siren " .
|
|
"WHERE entSiren=".$companyId." AND qualite='".$tiers."' GROUP BY idAffaire";
|
|
$affaireSql = "SELECT id, idAffaire, numGreffe, natureDemande, codNatureDemande, etatAffaire, dateEnrolement FROM jo.greffes_affaires ".
|
|
"WHERE idAffaire IN (".$tierSubQuery.") ORDER BY dateEnrolement DESC LIMIT $p,$limit";
|
|
try {
|
|
$affaireResult = $db->fetchAll($affaireSql, null, Zend_DB::FETCH_OBJ);
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient==1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
$status = include APPLICATION_PATH . '/../library/Metier/Ctx/AffaireStatus.php';
|
|
$categories = include APPLICATION_PATH . '/../library/Metier/Table/AffairesTypes.php';
|
|
|
|
$affaireList = array();
|
|
if (count($affaireResult) > 0) {
|
|
foreach ($affaireResult as $a) {
|
|
|
|
// --- Formattage
|
|
$item = new GreffeAffaire();
|
|
$item->Id = $a->id;
|
|
$item->StatusCode = $a->etatAffaire;
|
|
$item->StatusLabel = $a->etatAffaire;
|
|
if (array_key_exists($a->etatAffaire, $status)) {
|
|
$item->StatusLabel = $status[$a->etatAffaire];
|
|
}
|
|
$item->CategoryCode = $a->codNatureDemande;
|
|
$item->CategoryLabel = $a->codNatureDemande;
|
|
if (array_key_exists($a->codNatureDemande, $categories)) {
|
|
$item->CategoryLabel = $categories[$a->codNatureDemande];
|
|
}
|
|
$item->Label = $a->natureDemande;
|
|
$item->Date = $a->dateEnrolement;
|
|
|
|
// --- Récupération des tiers
|
|
if ($tiers == 'DE') {
|
|
$tiersQualite = 'DF';
|
|
} elseif ($tiers == 'DF') {
|
|
$tiersQualite = 'DE';
|
|
}
|
|
$tierSql = "SELECT nomPartie FROM jo.greffes_affaires_siren WHERE idAffaire='".$a->idAffaire."' AND qualite='".$tiersQualite."'";
|
|
try {
|
|
$tierResult = $db->fetchAll($tierSql, null, Zend_DB::FETCH_OBJ);
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient==1) {
|
|
throw new SoapFault('ERR', $tierSql . " - " . $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
if (count($tierResult) > 0) {
|
|
foreach ($tierResult as $t) {
|
|
$item->TierName[] = $t->nomPartie;
|
|
}
|
|
}
|
|
$affaireList[] = $item;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
$output->List = $affaireList;
|
|
$this->wsLog('affairelist', $companyId);
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Detail d'un contentieux
|
|
* @param int $id
|
|
* @throws SoapFault
|
|
* @return GreffeAffaireDetail
|
|
*/
|
|
public function getGreffeAffaireDetail($id)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('contentieux');
|
|
|
|
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
|
|
|
|
$affaireSql = "SELECT id, idAffaire, numGreffe, natureDemande, codNatureDemande, etatAffaire, dateEnrolement FROM jo.greffes_affaires ".
|
|
"WHERE id=".$id;
|
|
try {
|
|
$affaireResult = $db->fetchRow($affaireSql, null, Zend_DB::FETCH_OBJ);
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
// --- Aucun resultat
|
|
if ($affaireResult === null) {
|
|
throw new SoapFault('MSG', "Aucun résultat");
|
|
}
|
|
|
|
// --- Selection des Entités
|
|
$tiers = array();
|
|
$entiteSql = "SELECT * FROM jo.greffes_affaires_siren WHERE idAffaire='".$affaireResult->idAffaire."' ORDER BY FIELD(qualite, 'DE', 'DF')";
|
|
try {
|
|
$entiteResult = $db->fetchAll($entiteSql, null, Zend_DB::FETCH_OBJ);
|
|
if (count($entiteResult) > 0) {
|
|
foreach ($entiteResult as $item) {
|
|
$entite = new GreffeAffaireTiers();
|
|
$entite->companyId = $item->entSiren;
|
|
$entite->companyNom = $item->nomPartie;
|
|
$entite->TypeCode = $item->qualite;
|
|
switch($item->qualite) {
|
|
case 'DE':
|
|
$entite->TypeLabel = 'Demandeur';
|
|
break;
|
|
case 'DF':
|
|
$entite->TypeLabel = 'Defendeur';
|
|
break;
|
|
}
|
|
$acteurMax = 3;
|
|
for($i = 0; $i < $acteurMax; $i++) {
|
|
if (!empty($item->{'rep'.$i.'nom'})) {
|
|
$acteur = new GreffeAffaireActeur();
|
|
$acteur->Nom = $item->{'rep'.$i.'nom'};
|
|
$acteur->Type = "";
|
|
$entite->Acteur[] = $acteur;
|
|
}
|
|
}
|
|
$tiers[] = $entite;
|
|
}
|
|
}
|
|
|
|
} catch (Zend_Db_Exception $e) {
|
|
if ($this->User->idClient == 1) {
|
|
throw new SoapFault('ERR', $e->getMessage());
|
|
} else {
|
|
throw new SoapFault('ERR', "Application error");
|
|
}
|
|
}
|
|
|
|
// --- Selection de l'historique
|
|
$histo = array();
|
|
$histoSql = "SELECT * FROM jo.greffes_affaires_histo WHERE idAffaire='".$affaireResult->idAffaire."' ORDER BY dateDecision DESC";
|
|
try {
|
|
$histoResult = $db->fetchAll($histoSql, null, Zend_DB::FETCH_OBJ);
|
|
if (count($histoResult) > 0) {
|
|
foreach ($histoResult as $h){
|
|
$decision = new GreffeAffaireHisto();
|
|
$decision->Label = $h->libelleDecision;
|
|
$decision->Date = $h->dateDecision;
|
|
$decision->Desc = $h->commentaireDecision;
|
|
$histo[] = $decision;
|
|
}
|
|
}
|
|
|
|
} catch (Zend_Db_Exception $e) {}
|
|
|
|
// --- Formattage
|
|
$status = include APPLICATION_PATH . '/../library/Metier/Ctx/AffaireStatus.php';
|
|
$categories = include APPLICATION_PATH . '/../library/Metier/Table/AffairesTypes.php';
|
|
|
|
$output = new GreffeAffaireDetail();
|
|
$output->Id = $affaireResult->id;
|
|
$output->StatusCode = $affaireResult->etatAffaire;
|
|
$output->StatusLabel = $affaireResult->etatAffaire;
|
|
if (array_key_exists($affaireResult->etatAffaire, $status)) {
|
|
$output->StatusLabel = $status[$affaireResult->etatAffaire];
|
|
}
|
|
$output->CategoryCode = $affaireResult->codNatureDemande;
|
|
$output->CategoryLabel = $affaireResult->codNatureDemande;
|
|
if (array_key_exists($affaireResult->codNatureDemande, $categories)) {
|
|
$output->CategoryLabel = $categories[$affaireResult->codNatureDemande];
|
|
}
|
|
$output->Label = $affaireResult->natureDemande;
|
|
$output->Date = $affaireResult->dateEnrolement;
|
|
$output->GreffeNum = $affaireResult->numGreffe;
|
|
|
|
$rncs = new Metier_Partenaires_MRncs();
|
|
$output->GreffeLabel = $rncs->getLibTribunal($affaireResult->numGreffe);
|
|
|
|
$output->Tiers = $tiers;
|
|
$output->Histo = $histo;
|
|
|
|
$this->wsLog('affairedetail', $companyId);
|
|
|
|
return $output;
|
|
}
|
|
|
|
|
|
/**
|
|
* Formatte les informations de calculIndiscore
|
|
* @param array $infos
|
|
* @return stdClass
|
|
*/
|
|
protected function formatIndiscore($infos)
|
|
{
|
|
$output = new stdClass();
|
|
foreach($infos 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();
|
|
if (count($value)>0) {
|
|
foreach($value as $comment) {
|
|
$tab[] = Scores_Locale_String::fixEncoding($comment);
|
|
}
|
|
}
|
|
$output->tabCommentaires = $tab;
|
|
|
|
} elseif ($key=='tabVariables') {
|
|
|
|
$tab = $value['CA_Y'];
|
|
$tabVar = array();
|
|
if (count($tab)>0) {
|
|
foreach($tab as $varName => $varVal){
|
|
$var = new CA_Y();
|
|
$var->id = $varName;
|
|
$var->val = $varVal;
|
|
$tabVar[] = $var;
|
|
}
|
|
}
|
|
$variables = new IndiscoreVariables();
|
|
$variables->CA_Y = $tabVar;
|
|
$output->tabVariables = $variables;
|
|
|
|
} elseif ($key=='Bilans') {
|
|
|
|
$tab = array();
|
|
foreach($value as $item)
|
|
{
|
|
$objet = new IndiscoreBilans();
|
|
$objet->Millesime = $item['Millesime'];
|
|
$objet->FraisPerso = $item['FraisPerso'];
|
|
$objet->CA = $item['CA'];
|
|
$objet->EBE = $item['EBE'];
|
|
$objet->TxInvest = $item['TxInvest'];
|
|
$objet->TxEndett = $item['TxEndett'];
|
|
$objet->DettesCT = $item['DettesCT'];
|
|
$objet->FraisFi = $item['FraisFi'];
|
|
$objet->BFR = $item['BFR'];
|
|
$objet->FR = $item['FR'];
|
|
$objet->FondsPr = $item['FondsPr'];
|
|
$objet->DelaiCli = $item['DelaiCli'];
|
|
$objet->DelaiFour = $item['DelaiFour'];
|
|
$tab[] = $objet;
|
|
}
|
|
$output->$key = $tab;
|
|
} else {
|
|
$output->$key = $value;
|
|
}
|
|
}
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* Evaluation IndiScore
|
|
* @param string $companyId
|
|
* Siren de l'entreprise
|
|
* @return stdClass
|
|
*/
|
|
protected function getIndiScore($companyId)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('INDISCORE');
|
|
/*
|
|
Evaluation indiscore d'une entreprise
|
|
Ne pas renvoyer les commentaires tabCommentaires
|
|
|
|
*/
|
|
$siren = substr($companyId, 0, 9);
|
|
if (intval($siren) < 100 ) {
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$scoring = new Metier_Scoring_Base();
|
|
$indiscoreStruct = $scoring->calculIndiScore($siren);
|
|
|
|
$output = new Indiscore();
|
|
$output = $this->formatIndiscore($indiscoreStruct);
|
|
|
|
return $output;
|
|
}
|
|
|
|
protected function getReportSynthese($companyId)
|
|
{
|
|
$this->authenticate();
|
|
$this->permission('INDISCORE2');
|
|
|
|
$siren = substr($companyId, 0, 9);
|
|
if (intval($siren) < 100 ) {
|
|
$this->sendError('1010');
|
|
}
|
|
|
|
$reportStruct = new ReportSynthese();
|
|
|
|
$identiteStruct = $this->getIdentite($siren);
|
|
|
|
$scoring = new Metier_Scoring_Base();
|
|
//$scoring->injectIdentite();
|
|
$indiscoreStruct = $scoring->calculIndiScore($siren);
|
|
|
|
//$ratiosStruct = $this->getRatios($siren);
|
|
|
|
|
|
}
|
|
|
|
protected function getReportComment($companyId)
|
|
{
|
|
$this->authenticate();
|
|
|
|
$this->permission('INDISCORE3');
|
|
|
|
$reportStruct = new Report();
|
|
|
|
$scoring = new Metier_Scoring_Base();
|
|
$indiscoreStruct = $scoring->calculIndiScore($siren);
|
|
|
|
/*
|
|
Commentaires suivant niveau
|
|
|
|
$identite = $ws->getIdentite($siren);
|
|
$indiscore = $ws->getIndiScore($siren);
|
|
$infos = $ws->getRatios($siren, 'indiscore2');
|
|
|
|
ou -
|
|
|
|
$result->Identite = $this->getIdentite($siren, $id=0);
|
|
$result->Indiscore = $this->getIndiScore($siren, 0, $nivComment, $plus, $ref, $encours, $email);
|
|
$result->Ratios = $this->getRatios($siren, $page="rapport$niveau");
|
|
$result->Dirigeants = $this->getDirigeants($siren, false);
|
|
$result->Liens = $this->getLiens($siren, true);
|
|
|
|
ou
|
|
|
|
$result->Identite = $this->getIdentite($siren, $id=0);
|
|
$result->Indiscore = $this->getIndiScore($siren, 0, $nivComment, $plus, $ref, $encours, $email);
|
|
$result->Ratios = $this->getRatios($siren, $page="rapport$niveau");
|
|
$result->Dirigeants = $this->getDirigeants($siren, false);
|
|
$result->Liens = $this->getLiens($siren, true);
|
|
$result->Annonces = $this->getAnnonces($siren, $filtre, $idAnn);
|
|
|
|
|
|
*/
|
|
|
|
|
|
return $reportStruct;
|
|
}
|
|
|
|
protected function getValo(){}
|
|
|
|
/**
|
|
* Cadastre et propriétés (beta)
|
|
* @param string $companyId
|
|
* SIREN
|
|
* @param int $p
|
|
* @param int $limit
|
|
* @throws SoapFault
|
|
* @return Patrimoine[]
|
|
*/
|
|
public function getCadastrePatrimoine($companyId, $p = 0, $limit = 100)
|
|
{
|
|
$this->authenticate();
|
|
//$this->permission('cadastre');
|
|
|
|
if ( strlen($companyId) != 9 ) {
|
|
throw new SoapFault('ERR', 'Identifiant incorrect.');
|
|
}
|
|
|
|
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
|
|
|
|
$cadastre = new Metier_Partenaires_MCadastre();
|
|
$cadastre->setId($companyId);
|
|
$patrimoine = array();
|
|
$results = $cadastre->patrimoine();
|
|
|
|
if (count($results) > 0) {
|
|
foreach ($results as $r) {
|
|
$part = new Patrimoine();
|
|
$part->Type = $r['type'];
|
|
$part->Role = $r['role'];
|
|
$part->RoleLib = $r['roleLib'];
|
|
$part->AdresseNum = $r['adresseNum'];
|
|
$part->AdresseInd = $r['adresseInd'];
|
|
$part->AdresseType = $r['adresseType'];
|
|
$part->AdresseLib = $r['adresseLib'];
|
|
$part->Departement = $r['departement'];
|
|
$part->CommuneCode = $r['communeCode'];
|
|
$part->CommuneLib = $r['communeLib'];
|
|
$part->Section = $r['section'];
|
|
$part->PlanNum = $r['planNum'];
|
|
$part->Fantoir = $r['fantoir'];
|
|
$part->Batiment = $r['batiment'];
|
|
$part->Ent = $r['ent'];
|
|
$part->Niveau = $r['niveau'];
|
|
$part->SurfaceTotal = intval($r['surfaceTotal']);
|
|
|
|
$surfaceDetail = array();
|
|
for($j = 0; $j < 10; $j++) {
|
|
if ($r['nature'.$j] != '' && $r['surface'.$j] > 0) {
|
|
$surface = new PatrimoineSurface();
|
|
$surface->Code = $r['nature'.$j];
|
|
if ($r['type'] == 'local') {
|
|
$surface->Label = $cadastre->getNatureLabel($r['nature'.$j], 'local');
|
|
} elseif ($r['type'] == 'parcelle') {
|
|
$surface->Label = $cadastre->getNatureLabel($r['nature'.$j], 'parcelle');
|
|
}
|
|
$surface->Surface = intval($r['surface'.$j]);
|
|
$surfaceDetail[] = $surface;
|
|
}
|
|
}
|
|
|
|
$part->SurfaceDetail = $surfaceDetail;
|
|
|
|
$patrimoine[] = $part;
|
|
}
|
|
|
|
$this->wsLog('cadastre', $companyId);
|
|
}
|
|
|
|
return $patrimoine;
|
|
}
|
|
}
|
|
|
|
?>
|