Ajout méthode getListeEvenements, issue #0000379
This commit is contained in:
parent
197dc581fe
commit
867c9f58e9
@ -24,3 +24,6 @@ Type.22 = "LiensReturn"
|
||||
Type.23 = "LiensResult"
|
||||
Type.24 = "Actionnaire"
|
||||
Type.25 = "Participation"
|
||||
Type.26 = "InseeReturn"
|
||||
Type.27 = "InseeResult"
|
||||
Type.28 = "InseeEven"
|
39
library/WsScore/Types/InseeTypes.php
Normal file
39
library/WsScore/Types/InseeTypes.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
class InseeReturn
|
||||
{
|
||||
/** @var ErrorType */
|
||||
public $error;
|
||||
/** @var InseeResult */
|
||||
public $result;
|
||||
}
|
||||
|
||||
class InseeResult
|
||||
{
|
||||
/** @var int */
|
||||
public $nbReponses;
|
||||
/** @var InseeEven[] */
|
||||
public $evenements;
|
||||
}
|
||||
|
||||
class InseeEven
|
||||
{
|
||||
/** @var string */
|
||||
public $Nic;
|
||||
/** @var int */
|
||||
public $Siege;
|
||||
/** @var string */
|
||||
public $SiretAss;
|
||||
/** @var string */
|
||||
public $TypeSiretAss;
|
||||
/** @var string */
|
||||
public $EvenCode;
|
||||
/** @var string */
|
||||
public $EvenLib;
|
||||
/** @var string */
|
||||
public $EvenLibDet;
|
||||
/** @var string */
|
||||
public $EvenDate;
|
||||
/** @var string */
|
||||
public $DateInfo;
|
||||
}
|
@ -6,6 +6,7 @@ require_once realpath(dirname(__FILE__)).'/ListeEtablissementsTypes.php';
|
||||
require_once realpath(dirname(__FILE__)).'/DirigeantsTypes.php';
|
||||
require_once realpath(dirname(__FILE__)).'/AnnoncesTypes.php';
|
||||
require_once realpath(dirname(__FILE__)).'/LiensTypes.php';
|
||||
require_once realpath(dirname(__FILE__)).'/InseeTypes.php';
|
||||
|
||||
class ErrorType
|
||||
{
|
||||
|
@ -58,8 +58,8 @@ class WsEntreprise
|
||||
exit;
|
||||
}
|
||||
//Initialisation
|
||||
if (!empty($id)) { $id = 0; }
|
||||
if (!empty($forceVerif)) { $forceVerif = false; }
|
||||
if (empty($id)) { $id = 0; }
|
||||
if (empty($forceVerif)) { $forceVerif = false; }
|
||||
|
||||
$outputParams = new IdentiteReturn();
|
||||
$error = new ErrorType();
|
||||
@ -295,8 +295,8 @@ class WsEntreprise
|
||||
exit;
|
||||
}
|
||||
//Initialisation
|
||||
if (!empty($id)) { $id = 0; }
|
||||
if (!empty($forceVerif)) { $forceVerif = false; }
|
||||
if (empty($id)) { $id = 0; }
|
||||
if (empty($forceVerif)) { $forceVerif = false; }
|
||||
$error = new ErrorType();
|
||||
|
||||
debugLog('I',"Identité AGS demandée pour siret $siret (id=$id)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
@ -539,7 +539,6 @@ class WsEntreprise
|
||||
}
|
||||
$tabRet['Annonces'] = $tabRetAnn;
|
||||
|
||||
|
||||
//Identite Etab
|
||||
$iRncs=new MRncs();
|
||||
if ($entrep['Siege']==1 || $entrep['Siege']==11)
|
||||
@ -589,16 +588,22 @@ class WsEntreprise
|
||||
$tabA = $mLiens->getActionnaires($siren, 1);
|
||||
$nbA = count($tabA);
|
||||
$tabAct = array();
|
||||
foreach ($tabA as $i=>$lien)
|
||||
if ($nbA > 0)
|
||||
{
|
||||
$tabAct[] = array(
|
||||
'Pmin' => $lien['Pmin'],
|
||||
'MajMin' => $lien['MajMin'],
|
||||
'RaisonSociale' => $lien['RaisonSociale'],
|
||||
'Pays' => $lien['Pays'],
|
||||
'Siren' => $lien['Siren'],
|
||||
'Actif' => $lien['Actif'],
|
||||
);
|
||||
foreach ($tabA as $i => $lien)
|
||||
{
|
||||
$actionnaire = new Actionnaire();
|
||||
$actionnaire->Pmin = $lien['Pmin'];
|
||||
$actionnaire->MajMin = $lien['MajMin'];
|
||||
$actionnaire->RaisonSociale = $lien['RaisonSociale'];
|
||||
$actionnaire->Pays = $lien['Pays'];
|
||||
$actionnaire->Siren = $lien['Siren'];
|
||||
$actionnaire->Actif = $lien['Actif'];
|
||||
$actionnaire->Source = $lien['Source'];
|
||||
$actionnaire->DateLien = $lien['DateLien'];
|
||||
$actionnaire->DateMaj = $lien['DateMaj'];
|
||||
$tabAct[] = $actionnaire;
|
||||
}
|
||||
}
|
||||
$tabRet['Actionnaires'] = $tabAct;
|
||||
|
||||
@ -681,7 +686,7 @@ class WsEntreprise
|
||||
exit;
|
||||
}
|
||||
//Initialisation
|
||||
if (!empty($actifsUniquement)) { $actifsUniquement = true; }
|
||||
if (empty($actifsUniquement)) { $actifsUniquement = true; }
|
||||
$error = new ErrorType();
|
||||
$tabAct = $tabPar = array();
|
||||
|
||||
@ -703,6 +708,7 @@ class WsEntreprise
|
||||
$mLiens = new MLiens($siren);
|
||||
$tabA = $mLiens->getActionnaires($siren, $actifsUniquement);
|
||||
$nbA = count($tabA);
|
||||
$tabAct = array();
|
||||
if ($nbA > 0)
|
||||
{
|
||||
foreach ($tabA as $i => $lien)
|
||||
@ -723,6 +729,7 @@ class WsEntreprise
|
||||
debugLog('W', "$nbA actionnaires pour le siren $siren", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$tabP = $mLiens->getParticipations($siren, $actifsUniquement);
|
||||
$nbP = count($tabP);
|
||||
$tabPar[] = array();
|
||||
if ($nbP > 0)
|
||||
{
|
||||
foreach ($tabP as $i => $lien)
|
||||
@ -773,10 +780,10 @@ class WsEntreprise
|
||||
}
|
||||
|
||||
//Initialisation
|
||||
if (!empty($dep)) { $dep = 0; }
|
||||
if (!empty($actif)) { $actif = -1; }
|
||||
if (!empty($position)) { $position = 0; }
|
||||
if (!empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($dep)) { $dep = 0; }
|
||||
if (empty($actif)) { $actif = -1; }
|
||||
if (empty($position)) { $position = 0; }
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
|
||||
//Valeur max
|
||||
if($nbRep > 200) { $nbRep = 200; }
|
||||
@ -854,7 +861,7 @@ class WsEntreprise
|
||||
exit;
|
||||
}
|
||||
//Initialisation
|
||||
if (!empty($histo)) { $histo = false; }
|
||||
if (empty($histo)) { $histo = false; }
|
||||
|
||||
debugLog('I',"Dirigeants demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$tabRet = array();
|
||||
@ -928,10 +935,10 @@ class WsEntreprise
|
||||
}
|
||||
|
||||
//Initialisation
|
||||
if (!empty($filtre)) { $filtre = 0; }
|
||||
if (!empty($idAnn)) { $idAnn = 0; }
|
||||
if (!empty($position)) { $position = 0; }
|
||||
if (!empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($filtre)) { $filtre = 0; }
|
||||
if (empty($idAnn)) { $idAnn = 0; }
|
||||
if (empty($position)) { $position = 0; }
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
|
||||
//Valeur max
|
||||
if($nbRep > 200) { $nbRep = 200; }
|
||||
@ -1166,6 +1173,119 @@ class WsEntreprise
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluation indiScore d'une entreprise
|
||||
*
|
||||
* @param string $siren Siren de l'entreprise
|
||||
* @param string $nic
|
||||
* @param bool $accesDist
|
||||
* @param int $niveau
|
||||
* @return
|
||||
*/
|
||||
protected function getIndiScore($siren, $nic=0, $accesDist=true, $niveau=2)
|
||||
{
|
||||
//@todo
|
||||
//Authentification
|
||||
if (!$this->checkAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $_SERVER['REMOTE_ADDR']))
|
||||
{
|
||||
throw new SoapFault('900','Identifiant ou mot de passe incorrect !');
|
||||
exit;
|
||||
}
|
||||
//Initialisation
|
||||
if (empty($nic)) { $nic = 0; }
|
||||
if (empty($accesDist)) { $accesDist = true; }
|
||||
if (empty($niveau)) { $niveau = 2; }
|
||||
if ( !in_array($niveau, array(0,1,2,3,4,5)) ) { $niveau = 2; }
|
||||
$error = new ErrorType();
|
||||
|
||||
debugLog('I',"IndiScore demandée pour $siren en niveau $niveau",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$tabRet=array();
|
||||
if (strlen($siren)>9 || (substr($siren,0,9)*1)<100 )
|
||||
{
|
||||
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$error->errnum = 102;
|
||||
$error->errmsg = 'Siren incorrect';
|
||||
}
|
||||
$tDeb = microtime(true);
|
||||
require_once 'Metier/scores/classMScores.php';
|
||||
$tabRet = calculIndiScore($siren, $nic, $accesDist, $niveau);
|
||||
$duree = round(microtime(true)-$tDeb,3);
|
||||
debugLog('W', "indiscore DUREE = $duree s", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
wsLog('indiscore',$siren);
|
||||
|
||||
|
||||
|
||||
return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>$tabRet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste de tous les évènements enregistrés à l'INSEE pour une entreprise
|
||||
* @param string $siren Siren de l'entreprise
|
||||
* @param string $nic
|
||||
* @param integer $deb
|
||||
* @param integer $max
|
||||
* @return InseeReturn
|
||||
**/
|
||||
public function getListeEvenements($siren, $nic=0, $deb=0, $max=1000)
|
||||
{
|
||||
//Authentification
|
||||
if (!$this->checkAuth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $_SERVER['REMOTE_ADDR']))
|
||||
{
|
||||
throw new SoapFault('900','Identifiant ou mot de passe incorrect !');
|
||||
exit;
|
||||
}
|
||||
//Initialisation
|
||||
if (empty($nic)) { $nic = 0; }
|
||||
if (empty($max) || $max>1000) { $max = 1000; }
|
||||
$error = new ErrorType();
|
||||
|
||||
debugLog('I',"Liste des évènements pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$tabRet=array();
|
||||
if (strlen($siren)<>9)
|
||||
{
|
||||
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$error->errnum = 102;
|
||||
$error->errmsg = 'Siren inexistant';
|
||||
}
|
||||
elseif ($siren*1==0)
|
||||
{
|
||||
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$error->errnum = 102;
|
||||
$error->errmsg = 'Siren inexistant';
|
||||
}
|
||||
else
|
||||
{
|
||||
$evens = $this->iInsee->getEvenements($siren, $nic, $deb, $max);
|
||||
$tabRet = array();
|
||||
if (count($evens)>0)
|
||||
{
|
||||
foreach ($evens as $nb=>$even)
|
||||
{
|
||||
$iEven = new InseeEven();
|
||||
$iEven->Nic = $even['nic'];
|
||||
$iEven->Siege = $even['siege'];
|
||||
$iEven->SiretAss = $even['siretAssocie'];
|
||||
$iEven->TypeSiretAss = $even['typeSiretAss'];
|
||||
$iEven->EvenCode = $even['codeEven'];
|
||||
$iEven->EvenLib = $even['libEven'];
|
||||
$iEven->EvenLibDet = $even['libEvenDet'];
|
||||
$iEven->EvenDate = $even['dateEven'];
|
||||
$iEven->DateInfo = $even['dateMAJ'];
|
||||
$tabRet[] = $iEven;
|
||||
}
|
||||
}
|
||||
}
|
||||
debugLog('I', 'Nb évènements retournés = '. count($tabRet), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
//wsLog('etablissements',$siren);
|
||||
|
||||
$result = new InseeResult();
|
||||
$result->nbReponses = count($tabRet);
|
||||
$output = new InseeReturn();
|
||||
$output->error = $error;
|
||||
$output->result = $result;
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recherche
|
||||
|
Loading…
x
Reference in New Issue
Block a user