include_once(FWK_PATH.'common/curl.php');
/** La classe MEuridile permet de récupérer les informations suivantes :
** - Bilans
** - Identité complète (dirigeants, etablissements, etc...)
** - Liste des actes déposés aux greffes
**/
class MEuridile {
private $body = '';
private $header = '';
private $codeRetour = 0;
private $wrncsrv2=false;
private $reference = 0;
private $timeOut=0;
private $url='';
private $urlRacine='http://www.euridile.com';
private $weur='weur3'; // Version Web 3 d'Euridile
private $referer='';
private $curPage='';
public $siren;
private $tabBS2BN=array('AH'=>'010',
'AI'=>'012',
'AJ'=>'014',
'AK'=>'016',
'AT'=>'028',
'AU'=>'030',
'BH'=>'040',
'BI'=>'042',
'BJ'=>'044',
'BK'=>'048',
'BT'=>'060',
'BU'=>'062',
'BV'=>'064',
'BW'=>'066',
'BX'=>'068',
'BY'=>'070',
'BZ'=>'072',
'CA'=>'074',
'CD'=>'080',
'CE'=>'082',
'CF'=>'084',
'CG'=>'086',
'CH'=>'092',
'CI'=>'094',
'CJ'=>'096',
'CK'=>'098',
'CO'=>'110',
'1A'=>'112',
'DA'=>'120',
'DC'=>'124',
'DD'=>'126',
'DF'=>'130',
'DG'=>'132',
'DH'=>'134',
'DI'=>'136',
'DK'=>'140',
'DL'=>'142',
'DR'=>'154',
'DP'=>'154',
'DU'=>'156',
'DV'=>'169',
'DW'=>'164',
'DX'=>'166',
'EA'=>'172-169',
'EB'=>'174',
'EC'=>'176',
'EE'=>'180',
'EH'=>'156-195',
'FA'=>'210-209',
'FB'=>'209',
'FC'=>'210',
'FD'=>'214-215',
'FE'=>'215',
'FF'=>'214',
'FH'=>'217',
'FI'=>'218',
'FK'=>'209+215+217',
'FL'=>'210+214+218',
'FM'=>'222',
'FN'=>'224',
'FO'=>'226',
'FQ'=>'230',
'FR'=>'232',
'FS'=>'234',
'FT'=>'236',
'FU'=>'238',
'FV'=>'240',
'FW'=>'242',
'FX'=>'244',
'FY'=>'250',
'FZ'=>'252',
'GA'=>'254',
'GE'=>'262',
'GF'=>'264',
'GG'=>'270',
'GP'=>'280',
'GU'=>'294',
'GW'=>'270+280+294',
'HD'=>'290',
'HH'=>'300',
'HI'=>'290-300',
'HK'=>'306',
'HL'=>'232+280+290',
'HM'=>'264+294+300+306',
'HN'=>'310',
'YY'=>'374',
'YZ'=>'378',
'YP'=>'376',
);
function __construct() {
$this->partGetSession();
$this->partConnection();
}
function __destruct() {
$this->partSaveSession();
}
function getInfosDisponbiles($siren) {
$this->siren=$siren;
$this->partConnection();
return $this->partVitrine(true);
}
function listBilans($siren) {
$tabRet=array();
$tab=$this->getInfosDisponbiles($siren);
if ($tab['erreur']=='') {
$tabS=@array_reverse(@array_keys($tab['bilans']['S'])); // Réel simplifié
$tabN=@array_reverse(@array_keys($tab['bilans']['N'])); // Réel normal
$tabC=@array_reverse(@array_keys($tab['bilans']['C'])); // CONSOLIDE
$tabA=@array_reverse(@array_keys($tab['bilans']['A'])); // Assurance
$tabB=@array_reverse(@array_keys($tab['bilans']['B'])); // Banque
foreach ($tabS as $num=>$millesime) {
$delta1=round((Wdate::dateT('d/m/Y','Y',$millesime)-Wdate::dateT('d/m/Y','Y',$tabS[$num+1]))*12)
+round(Wdate::dateT('d/m/Y','m',$millesime)-Wdate::dateT('d/m/Y','m',$tabS[$num+1]));
$delta2=round((Wdate::dateT('d/m/Y','Y',$tabS[$num+1])-Wdate::dateT('d/m/Y','Y',$tabS[$num+2]))*12)
+round(Wdate::dateT('d/m/Y','m',$tabS[$num+1])-Wdate::dateT('d/m/Y','m',$tabS[$num+2]));
$tabRet['S'.$millesime]=array( 'dateProvPartenaire'=>date('Ymd'),
'dureeExercice' =>$delta1,
'dateExercicePre' =>Wdate::dateT('d/m/Y','Ymd',$tabS[$num+1]),
'dureeExercicePre' =>$delta2,
'monnaie' =>'EUR',
'source' =>0,
'ref' =>$tab['bilans']['S'][$millesime],
);
}
foreach ($tabN as $num=>$millesime) {
$delta1=round((Wdate::dateT('d/m/Y','Y',$millesime)-Wdate::dateT('d/m/Y','Y',$tabN[$num+1]))*12)
+round(Wdate::dateT('d/m/Y','m',$millesime)-Wdate::dateT('d/m/Y','m',$tabN[$num+1]));
$delta2=round((Wdate::dateT('d/m/Y','Y',$tabN[$num+1])-Wdate::dateT('d/m/Y','Y',$tabN[$num+2]))*12)
+round(Wdate::dateT('d/m/Y','m',$tabN[$num+1])-Wdate::dateT('d/m/Y','m',$tabN[$num+2]));
$tabRet['N'.$millesime]=array( 'dateProvPartenaire'=>date('Ymd'),
'dureeExercice' =>$delta1,
'dateExercicePre' =>Wdate::dateT('d/m/Y','Ymd',$tabN[$num+1]),
'dureeExercicePre' =>$delta2,
'monnaie' =>'EUR',
'source' =>0,
'ref' =>$tab['bilans']['N'][$millesime],
);
}
foreach ($tabC as $num=>$millesime) {
$delta1=round((Wdate::dateT('d/m/Y','Y',$millesime)-Wdate::dateT('d/m/Y','Y',$tabC[$num+1]))*12)
+round(Wdate::dateT('d/m/Y','m',$millesime)-Wdate::dateT('d/m/Y','m',$tabC[$num+1]));
$delta2=round((Wdate::dateT('d/m/Y','Y',$tabC[$num+1])-Wdate::dateT('d/m/Y','Y',$tabC[$num+2]))*12)
+round(Wdate::dateT('d/m/Y','m',$tabC[$num+1])-Wdate::dateT('d/m/Y','m',$tabC[$num+2]));
$tabRet['C'.$millesime]=array( 'dateProvPartenaire'=>date('Ymd'),
'dureeExercice' =>$delta1,
'dateExercicePre' =>Wdate::dateT('d/m/Y','Ymd',$tabC[$num+1]),
'dureeExercicePre' =>$delta2,
'monnaie' =>'EUR',
'source' =>0,
'ref' =>$tab['bilans']['C'][$millesime],
);
}
foreach ($tabA as $num=>$millesime) {
}
foreach ($tabB as $num=>$millesime) {
}
}
return $tabRet;
}
function getBilan($refBilan) {
return $this->partBilan($refBilan);
}
function getIdentite($siren) {
$this->siren=$siren;
return $this->partIdentite();
}
private function partConnection() {
if (!$this->wrncsrv2 || time()>$this->timeOut) {
$this->timeOut=time()+900;
$this->url=$this->urlRacine.'/index.ow';
$page=getUrl($this->url, '', '', $this->urlRacine, false, 'www.euridile.com');
$this->referer=$this->url;
$this->body=$page['body'];
$this->codeRetour=$page['code'];
$this->header=$page['header'];
//echo date('Y/m/d - H:i:s') ." - Initialisation URL = $this->url (Code retour = $this->codeRetour)
".EOL;
$fp=fopen('./euridile_connexion1.log', 'w');
fwrite($fp,print_r($page,true));
fclose($fp);
if (preg_match('//i', $this->body, $matches))
$this->url=$this->urlRacine.'/'.$matches[1];
else debugLog('E',"Erreur de communication - Redirection impossible sur ".$this->url,__LINE__,__FILE__,__FUNCTION__,__CLASS__);
debugLog('I','Redirection trouvée sur la page '.$this->url,__LINE__,__FILE__,__FUNCTION__,__CLASS__);
if (preg_match('/\.ow\?WRNCSRV2=(.*)$/i', $matches[1], $matches)) {
$this->wrncsrv2=$matches[1];
debugLog('I','Session partenaire WRNCSRV2='.$this->wrncsrv2,__LINE__,__FILE__,__FUNCTION__,__CLASS__);
}
else debugLog('E','Impossible d\'identifier le numéro de session partenaire',__LINE__,__FILE__,__FUNCTION__,__CLASS__);
$page=getUrl($this->url, '', '',$this->referer, false, 'www.euridile.com');
$this->referer=$this->url;
$this->body=$page['body'];
$this->codeRetour=$page['code'];
$this->header=$page['header'];
debugLog('D',"Page d'accueil URL = $this->url (Code retour = $this->codeRetour)",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
$fp=fopen('./euridile_connexion2.log', 'w');
fwrite($fp,print_r($page,true));
fclose($fp);
if (preg_match('/