Library Update
This commit is contained in:
parent
6bbc008724
commit
25fc679deb
@ -228,7 +228,7 @@ return array(
|
||||
array( 'var' => 'Situation', 'op' => 'SET', 'value' => ''),
|
||||
),
|
||||
),
|
||||
// --- Absorbé
|
||||
// --- Absorbé ?? ICI uniquement lorsque Situation = ''
|
||||
array(
|
||||
'name' => 'ABSORPTION',
|
||||
'value' => 'CONTINUE',
|
||||
|
@ -987,7 +987,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, e.adr_dep, LPAD(e.adr_com,3,0) AS adr_com,
|
||||
LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab,
|
||||
CONCAT(e.siren, e.nic) AS siret, e.actif, e.identite_pre, IF(e.siege=2,0.5,e.siege) AS triSiege,
|
||||
IF (e.adr_dep=99, (SELECT libPays FROM jo.tabPays p WHERE p.codePaysInsee=e.adr_com) , 'France') AS libPays";
|
||||
IF (e.adr_dep=99, (SELECT libPays FROM jo.tabPays p WHERE p.codePaysInsee=e.adr_com LIMIT 0,1) , 'France') AS libPays";
|
||||
|
||||
$strActif = $strDep = '';
|
||||
if (intval($actif) == 1) {
|
||||
@ -1701,7 +1701,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
$identite = $result;
|
||||
}
|
||||
}
|
||||
if (count($identite)>0) {
|
||||
if (count($identite) > 0) {
|
||||
// --- Actif
|
||||
$identite['Actif'] = 1;
|
||||
if (array_key_exists('insEVE', $identite)) {
|
||||
@ -1743,11 +1743,11 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
}
|
||||
rsort($tabDates);
|
||||
$dateProcol = str_replace('-', '', $tabDates[0])*1;
|
||||
if ($this->dureePlan>0 && date('Ymd')<$this->finPlan) {
|
||||
if ($this->dureePlan > 0 && date('Ymd') < $this->finPlan) {
|
||||
$identite['SituationJuridique'] = 'PL';
|
||||
}
|
||||
// Plan révolu
|
||||
elseif ($this->dureePlan>0 && date('Ymd')>=$this->finPlan) {
|
||||
elseif ($this->dureePlan > 0 && date('Ymd') >= $this->finPlan) {
|
||||
$identite['SituationJuridique'] = '';
|
||||
}
|
||||
// Appel de jugement
|
||||
@ -1758,9 +1758,13 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
else {
|
||||
$identite['SituationJuridique'] = 'P';
|
||||
}
|
||||
} elseif (count($this->getAnnoncesLegales($siren, 0, 'A', false)) > 0) {
|
||||
}
|
||||
// Absorption
|
||||
elseif (count($this->getAnnoncesLegales($siren, 0, 'A', false)) > 0) {
|
||||
$identite['SituationJuridique'] = 'A';
|
||||
} elseif (count($this->getAnnoncesLegales($siren, 0, 'D', false)) > 0) {
|
||||
}
|
||||
// Dissolution
|
||||
elseif (count($this->getAnnoncesLegales($siren, 0, 'D', false)) > 0) {
|
||||
$identite['SituationJuridique'] = 'D';
|
||||
}
|
||||
// Fin Situation Juridique
|
||||
@ -2036,7 +2040,10 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
$tdeb = microtime(1);
|
||||
}
|
||||
|
||||
$iTva = new Metier_Partenaires_MTva($siren, $accesDist, $this->iDb);
|
||||
$iTva = new Metier_Partenaires_MTva($this->iDb);
|
||||
$iTva->setCompanyId($siren);
|
||||
$iTva->setRemote();
|
||||
$iTva->getTVA();
|
||||
$vatNumber = $iTva->vatNumber;
|
||||
$vatDefined = $iTva->vatDefined;
|
||||
|
||||
@ -2074,7 +2081,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
$tdeb = microtime(1);
|
||||
}
|
||||
|
||||
$iTel = new Metier_Partenaires_MTel(false, $this->iDb);
|
||||
$iTel = new Metier_Partenaires_MTel($this->iDb);
|
||||
$tmp = $iTel->getTel($siren, $nic, true, 1);
|
||||
|
||||
if ($this->debugtime) {
|
||||
@ -2565,91 +2572,123 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "=== Situation Juridique ===\n");
|
||||
}
|
||||
$tabProcol = $this->getAnnoncesLegales($siren, 0, 'P', false);
|
||||
if (count($tabProcol) > 0) {
|
||||
|
||||
$tabAnn = $this->getAnnoncesLegales($siren, 0, '', false, false);
|
||||
|
||||
if (count($tabAnn) > 0) {
|
||||
// Date de dernière mise à jour
|
||||
$tabDates = array();
|
||||
foreach ($tabProcol as $iProcol => $procol) {
|
||||
$tabDates[] = $procol['dateJugement'];
|
||||
foreach ($tabAnn as $iAnn => $ann) {
|
||||
$tabDates[] = $ann['dateInsertionSD'];
|
||||
}
|
||||
rsort($tabDates);
|
||||
$dateProcol = str_replace('-', '', $tabDates[0])*1;
|
||||
// Plan
|
||||
if ($this->dureePlan > 0 && date('Ymd') < $this->finPlan) {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Plan (PL) : ".$this->dureePlan."-".$this->finPlan."\n", FILE_APPEND);
|
||||
}
|
||||
$tabRet['SituationJuridique'] = 'PL';
|
||||
}
|
||||
// Plan révolu
|
||||
elseif ($this->dureePlan > 0 && date('Ymd') >= $this->finPlan) {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Plan revolu : ".$this->dureePlan."-".$this->finPlan."\n", FILE_APPEND);
|
||||
}
|
||||
$tabRet['SituationJuridique'] = '';
|
||||
}
|
||||
// Appel de jugement
|
||||
elseif ($this->appelJugement) {
|
||||
$tabRet['SituationJuridique'] = 'PA';
|
||||
}
|
||||
// Jugement de cloture après LJ
|
||||
elseif ($this->SituationCloture) {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Cloture (CL) "."\n", FILE_APPEND);
|
||||
}
|
||||
$tabRet['SituationJuridique'] = 'CL';
|
||||
}
|
||||
// En cours de procédure
|
||||
else {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Procol (P) "."\n", FILE_APPEND);
|
||||
}
|
||||
$tabRet['SituationJuridique'] = 'P';
|
||||
$tabRet['dateMajANN'] = Metier_Util_Date::dateT('Y-m-d', 'Y-m-d', $tabDates[0]);
|
||||
if ($tabRet['dateMajANN'] == '--') {
|
||||
$tabRet['dateMajANN'] = '';
|
||||
} else {
|
||||
$dateAnnLastCompare = DateTime::createFromFormat('Y-m-d', $tabRet['dateMajANN']);
|
||||
}
|
||||
|
||||
// RAZ SituationJuridique si cutoff plus récent que dernière procol
|
||||
$stmt = $this->conn->executeQuery("SELECT encours, scoreSolv, scoreDir, scoreConf, DATE(dateInsert)*1 AS dateInsert, DATE(dateUpdate)*1 AS dateUpdate FROM jo.scores_cutoff WHERE siren=$siren");
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
if ($result['scoreSolv'] > 0) {
|
||||
//Tri des dates de procol
|
||||
$tabDates = array();
|
||||
foreach ($tabProcol as $iProcol=>$procol) {
|
||||
$tabDates[] = $procol['dateJugement'];
|
||||
// Procol
|
||||
$tabProcol = $this->getAnnoncesLegales($siren, 0, 'P', false);
|
||||
if (count($tabProcol) > 0) {
|
||||
$tabDates = array();
|
||||
foreach ($tabProcol as $iProcol => $procol) {
|
||||
$tabDates[] = $procol['dateJugement'];
|
||||
}
|
||||
rsort($tabDates);
|
||||
$dateProcol = str_replace('-', '', $tabDates[0])*1;
|
||||
// Plan
|
||||
if ($this->dureePlan > 0 && date('Ymd') < $this->finPlan) {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Plan (PL) : ".$this->dureePlan."-".$this->finPlan."\n", FILE_APPEND);
|
||||
}
|
||||
rsort($tabDates);
|
||||
$dateProcol = str_replace('-', '', $tabDates[0])*1;
|
||||
if ($result['dateUpdate'] > $result['dateInsert']) {
|
||||
$dateMaj = str_replace('-', '', $result['dateUpdate']);
|
||||
} else {
|
||||
$dateMaj = str_replace('-', '', $result['dateInsert']);
|
||||
$tabRet['SituationJuridique'] = 'PL';
|
||||
}
|
||||
// Plan révolu
|
||||
elseif ($this->dureePlan > 0 && date('Ymd') >= $this->finPlan) {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Plan revolu : ".$this->dureePlan."-".$this->finPlan."\n", FILE_APPEND);
|
||||
}
|
||||
if ($dateProcol <= $dateMaj) {
|
||||
$tabRet['SituationJuridique'] = '';
|
||||
$tabRet['SituationJuridique'] = '';
|
||||
}
|
||||
// Appel de jugement
|
||||
elseif ($this->appelJugement) {
|
||||
$tabRet['SituationJuridique'] = 'PA';
|
||||
}
|
||||
// Jugement de cloture après LJ
|
||||
elseif ($this->SituationCloture) {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Cloture (CL) "."\n", FILE_APPEND);
|
||||
}
|
||||
$tabRet['SituationJuridique'] = 'CL';
|
||||
}
|
||||
// En cours de procédure
|
||||
else {
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "Procol (P) "."\n", FILE_APPEND);
|
||||
}
|
||||
$tabRet['SituationJuridique'] = 'P';
|
||||
}
|
||||
|
||||
// RAZ SituationJuridique si cutoff plus récent que dernière procol
|
||||
$stmt = $this->conn->executeQuery("SELECT encours, scoreSolv, scoreDir, scoreConf, DATE(dateInsert)*1 AS dateInsert, DATE(dateUpdate)*1 AS dateUpdate FROM jo.scores_cutoff WHERE siren=$siren");
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
if ($result['scoreSolv'] > 0) {
|
||||
//Tri des dates de procol
|
||||
$tabDates = array();
|
||||
foreach ($tabProcol as $iProcol => $procol) {
|
||||
$tabDates[] = $procol['dateJugement'];
|
||||
}
|
||||
rsort($tabDates);
|
||||
$dateProcol = str_replace('-', '', $tabDates[0])*1;
|
||||
if ($result['dateUpdate'] > $result['dateInsert']) {
|
||||
$dateMaj = str_replace('-', '', $result['dateUpdate']);
|
||||
} else {
|
||||
$dateMaj = str_replace('-', '', $result['dateInsert']);
|
||||
}
|
||||
if ($dateProcol <= $dateMaj) {
|
||||
$tabRet['SituationJuridique'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Absorption
|
||||
if ($identite['SituationJuridique'] == '') {
|
||||
$tabAnn = $this->getAnnoncesLegales($siren, 0, 'A', false);
|
||||
$nbAnn = count($tabAnn);
|
||||
if (count($tabAnn) > 0) {
|
||||
$dateAnn = $tabAnn[$nbAnn-1]['dateInsertionSD'];
|
||||
$dateAnnCompare = DateTime::createFromFormat('Y-m-d H:i:s', $dateAnn);
|
||||
$dateAnnCompare->add(new DateInterval('P364D'));
|
||||
if ($dateAnnCompare >= $dateAnnLastCompare) {
|
||||
$tabRet['SituationJuridique'] = 'A';
|
||||
}
|
||||
}
|
||||
}
|
||||
// Dissolution
|
||||
if ($identite['SituationJuridique'] == '') {
|
||||
$tabAnn = $this->getAnnoncesLegales($siren, 0, 'D', false);
|
||||
$nbAnn = count($tabAnn);
|
||||
if (count($tabAnn) > 0) {
|
||||
$dateAnn = $tabAnn[$nbAnn-1]['dateInsertionSD'];
|
||||
$dateAnnCompare = DateTime::createFromFormat('Y-m-d H:i:s', $dateAnn);
|
||||
$dateAnnCompare->add(new DateInterval('P364D'));
|
||||
if ($dateAnnCompare >= $dateAnnLastCompare) {
|
||||
$tabRet['SituationJuridique'] = 'D';
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (count($this->getAnnoncesLegales($siren, 0, 'A', false)) > 0) {
|
||||
$tabRet['SituationJuridique'] = 'A';
|
||||
} elseif (count($this->getAnnoncesLegales($siren, 0, 'D', false)) > 0) {
|
||||
$tabRet['SituationJuridique'] = 'D';
|
||||
}
|
||||
|
||||
if ($this->debug) {
|
||||
file_put_contents('procol.log', "SituationJuridique = ".$tabRet['SituationJuridique']."\n", FILE_APPEND);
|
||||
}
|
||||
// Fin Situation Juridique
|
||||
|
||||
// Date de dernière mise à jour
|
||||
$tabAnn = $this->getAnnoncesLegales($siren, 0, '', false, false);
|
||||
$tabDates=array();
|
||||
foreach ($tabAnn as $iAnn=>$ann) {
|
||||
$tabDates[] = $ann['dateInsertionSD'];
|
||||
}
|
||||
rsort($tabDates);
|
||||
$tabRet['dateMajANN'] = Metier_Util_Date::dateT('Y-m-d', 'Y-m-d', $tabDates[0]);
|
||||
if ($tabRet['dateMajANN'] == '--') {
|
||||
$tabRet['dateMajANN'] = '';
|
||||
}
|
||||
$timer['getAnnoncesLegales']=microtime(true);
|
||||
$timer['getAnnoncesLegales'] = microtime(true);
|
||||
}
|
||||
|
||||
if (($tabInsee['CJ'] > 0 && $tabInsee['CJ'] < 20
|
||||
@ -3377,7 +3416,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
}
|
||||
}
|
||||
if (strtoupper($entrep['typeBilan'])=='S') {
|
||||
$mBil = new Metier_Partenaires_MBilans(0, $this->iDb);
|
||||
$mBil = new Metier_Partenaires_MBilans();
|
||||
$tabTmp = $mBil->bilanSimplifie2Normal($tabBilan);
|
||||
$tabBilan = array_merge($tabTmp, $tabBilan);
|
||||
}
|
||||
@ -4688,7 +4727,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1311, 1312, 1313,
|
||||
1500, 1501, 1502, 1503, 1504
|
||||
))) {
|
||||
$mBil = new Metier_Partenaires_MBilans($siren, $this->iDb);
|
||||
$mBil = new Metier_Partenaires_MBilans();
|
||||
$mBil->setSiren($siren);
|
||||
$tabBilans = $mBil->listeBilans(false);
|
||||
$derExercice = 0;
|
||||
foreach ($tabBilans as $idx => $bilan) {
|
||||
@ -4712,7 +4752,8 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
}
|
||||
// --- Dissolution mais bilan après événements
|
||||
elseif ($rubrique == 'D') {
|
||||
$mBil = new Metier_Partenaires_MBilans($siren, $this->iDb);
|
||||
$mBil = new Metier_Partenaires_MBilans();
|
||||
$mBil->setSiren($siren);
|
||||
$tabBilans = $mBil->listeBilans(false, 3);
|
||||
$derExercice = 0;
|
||||
foreach ($tabBilans as $idx => $bilan) {
|
||||
@ -5204,13 +5245,13 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
}
|
||||
} else {
|
||||
switch ($ann['Rubrique']) {
|
||||
case 'mmd': $codeEven='2313'; $libEven = "Modification(s) diverse(s)"; break;
|
||||
case 'comptes': $codeEven='3999'; $libEven = "Dépôt des comptes"; break;
|
||||
case 'creations': $codeEven='4999'; $libEven = "Création d'entreprise"; break;
|
||||
case 'procol': $codeEven='1999'; $libEven = "Procédure collective"; break;
|
||||
case 'radiations': $codeEven='6700'; $libEven = "Radiation"; break;
|
||||
case 'ventes': $codeEven='5999'; $libEven = "Vente/Cession"; break;
|
||||
default: $codeEven='0000'; $libEven = $ann['Rubrique']; break;
|
||||
case 'mmd': $codeEven='2313'; $libEven = "Modification(s) diverse(s)"; break;
|
||||
case 'comptes': $codeEven='3999'; $libEven = "Dépôt des comptes"; break;
|
||||
case 'creations': $codeEven='4999'; $libEven = "Création d'entreprise"; break;
|
||||
case 'procol': $codeEven='1999'; $libEven = "Procédure collective"; break;
|
||||
case 'radiations': $codeEven='6700'; $libEven = "Radiation"; break;
|
||||
case 'ventes': $codeEven='5999'; $libEven = "Vente/Cession"; break;
|
||||
default: $codeEven='0000'; $libEven = $ann['Rubrique']; break;
|
||||
}
|
||||
$tabRetEven[] = array(
|
||||
'CodeEven' => $codeEven,
|
||||
@ -5275,25 +5316,30 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
} elseif ($ann['JAL']==200) {
|
||||
$Bodacc_Code='BODB';
|
||||
}
|
||||
|
||||
// 4xxx
|
||||
if ($ann['CODEVE']<20) {
|
||||
$rub='creations';
|
||||
} // 4xxx
|
||||
}
|
||||
// 5xxx
|
||||
elseif ($ann['CODEVE']<=25) {
|
||||
$rub='ventes';
|
||||
} // 5xxx
|
||||
}
|
||||
// 2xxx
|
||||
elseif ($ann['CODEVE']<40) {
|
||||
$rub='mmd';
|
||||
} // 2xxx
|
||||
}
|
||||
// 6xxx
|
||||
elseif ($ann['CODEVE']<42) {
|
||||
$rub='radiations';
|
||||
} // 6xxx
|
||||
}
|
||||
// 2xxx
|
||||
elseif ($ann['CODEVE']<50) {
|
||||
$rub='mmd';
|
||||
} // 2xxx
|
||||
}
|
||||
// 1xxx
|
||||
elseif ($ann['CODEVE']<80) {
|
||||
$rub='procol';
|
||||
} // 1xxx
|
||||
}
|
||||
|
||||
$tabEvens = array();
|
||||
$newCodeEven = $this->HistoEvenConvert[$ann['CODEVE']];
|
||||
@ -5506,20 +5552,20 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
'LibEven' => $this->iBodacc->getEvenement($even)
|
||||
);
|
||||
if ($even>=1000 && $even<2000) {
|
||||
$rubriqueRet='procol';
|
||||
$rubriqueRet = 'procol';
|
||||
} elseif ($even>=2000 && $even<3000) {
|
||||
$rubriqueRet='mmd';
|
||||
} elseif ($even>=3000 && $even<4000) {
|
||||
$rubriqueRet='comptes';
|
||||
$rubriqueRet = 'comptes';
|
||||
} elseif ($even>=4000 && $even<5000) {
|
||||
$rubriqueRet='creations';
|
||||
$rubriqueRet = 'creations';
|
||||
} elseif ($even>=5000 && $even<6000) {
|
||||
$rubriqueRet='ventes';
|
||||
$rubriqueRet = 'ventes';
|
||||
} elseif ($even>=6000 && $even<7000) {
|
||||
$rubriqueRet='radiations';
|
||||
$rubriqueRet = 'radiations';
|
||||
}
|
||||
if ($even==2102 || $even==2100) {
|
||||
$capital=true;
|
||||
$capital = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
define('ARTISANAT_DISPO_WEB', 1);
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
class Metier_Partenaires_MArtisanat
|
||||
@ -29,14 +28,18 @@ class Metier_Partenaires_MArtisanat
|
||||
|
||||
public function getIdentite($siren)
|
||||
{
|
||||
$data = array();
|
||||
$siren = $siren * 1;
|
||||
$res = $this->iDb->select('jo.artisanat', 'id, siren, actif, numRM, denomination, sigle, nomCommercial, enseigne, fj, effectif, aprm, debutActivite, activite, adresse, cp, ville, cessation, radiation, nbInscriptions, nom, prenom, nomUsage, dateNaiss, lieuNaiss, natio, qualite, qualif, dateQualif, dateFctDeb, dateFctFin, IF(dateInsert>dateUpdate,dateInsert,dateUpdate) AS dateUpdate', "siren=$siren", false, MYSQL_ASSOC);
|
||||
if (count($res)>0 && !$this->remote) {
|
||||
$tabInsert = $res[0];
|
||||
} elseif (ARTISANAT_DISPO_WEB) {
|
||||
$tabInsert = $this->getRemoteIdentite();
|
||||
if ($this->remote) {
|
||||
$data = $this->getRemoteIdentite();
|
||||
} else {
|
||||
if (count($res) > 0) {
|
||||
$data = $res[0];
|
||||
}
|
||||
}
|
||||
return $tabInsert;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getRemoteIdentite()
|
||||
|
File diff suppressed because it is too large
Load Diff
365
library/Metier/Partenaires/MIntersud.php
Normal file
365
library/Metier/Partenaires/MIntersud.php
Normal file
@ -0,0 +1,365 @@
|
||||
<?php
|
||||
require_once 'framework/common/curl.php';
|
||||
/** @todo A faire et sortir du coup la méthode de commande d'enquêtes du WS **/
|
||||
class Metier_Partenaires_MIntersud {
|
||||
|
||||
private $body = '';
|
||||
private $header = '';
|
||||
private $codeRetour = 0;
|
||||
private $cookie=false;
|
||||
private $reference = 0;
|
||||
private $timeOut=0;
|
||||
private $url='';
|
||||
private $urlRacine='http://www.intersud.fr';
|
||||
private $referer='';
|
||||
private $curPage='';
|
||||
public $siren;
|
||||
|
||||
function __construct() {
|
||||
$this->partGetSession();
|
||||
$this->partConnection();
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
$this->partSaveSession();
|
||||
}
|
||||
|
||||
function getInfosDisponbiles($siren) {
|
||||
$this->siren=$siren;
|
||||
$this->partConnection();
|
||||
return $this->partVitrine(true);
|
||||
}
|
||||
|
||||
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)<br/>".EOL;
|
||||
$fp=fopen('./euridile_connexion1.log', 'w');
|
||||
fwrite($fp,print_r($page,true));
|
||||
fclose($fp);
|
||||
if (preg_match('/<META HTTP-EQUIV="Refresh" CONTENT="0; URL=(.*)">/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<75>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<75>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('/<form method="POST" name="abonnement" ACTION="(.*)" /i', $this->body, $matches)) {
|
||||
$postData=array('IDENT'=>'OK',
|
||||
'MDP'=>'3180',
|
||||
'cliref'=>'K5K3X5',
|
||||
'PASS'=>'3180',
|
||||
'WRNCSRV2'=>$this->wrncsrv2);
|
||||
/** @todo Fair une fonction qui g<EFBFBD>re les URL commen<EFBFBD>ant par ./ ou ../ ou / afin de pouvoir les concatener
|
||||
**/
|
||||
$this->url=$this->urlRacine.str_replace('..','',$matches[1]);
|
||||
debugLog('D',"Authentification possible vers $this->url",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
}
|
||||
else debugLog('E',"Authentification impossible car formulaire indisponible",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
|
||||
sleep(1);
|
||||
$page=getUrl($this->url,'', $postData, $this->referer, 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') ." - Apr<70>s authentification = $this->url (Code retour = $this->codeRetour)<br/>".EOL;
|
||||
$fp=fopen('./euridile_connexion3.log', 'w');
|
||||
fwrite($fp,print_r($page,true));
|
||||
fclose($fp);
|
||||
|
||||
if(preg_match('/\/'.$this->weur.'\/iden_evaluation_type_(.*)/i', $this->body, $matches))
|
||||
{ $tabTmp=explode('"', $matches[0]);
|
||||
$this->url=$this->urlRacine.$tabTmp[0];
|
||||
debugLog('D',"Page de recherche recherche trouv<75>e = $this->url>",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
} else debugLog('E',"Erreur de communication - Recherche introuvable !",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
|
||||
$this->curPage='recherche';
|
||||
} //else echo date('Y/m/d - H:i:s') ." - Deja connecte !<br/>".EOL;
|
||||
return true;
|
||||
}
|
||||
|
||||
private function partIdentite() {
|
||||
if ($this->curPage<>'vitrine')
|
||||
$this->partVitrine();
|
||||
|
||||
$iDb=new WDB();
|
||||
$ret=$iDb->select( 'jo.rncs_entrep',
|
||||
'siren, rcs, nom, adresse1, adresse2, adresse3, cp, ville, naiss_date, naiss_lieu, sexe, enseigne, sigle, '.
|
||||
'fj_lib, naf_code, naf_lib, date_crea, date_imma, greffe, num_gestion, capital_mnt, capital_dev, nationalite, '.
|
||||
'nb_etab, indRadiation, date_radiation, indProcol, dateUpdate, procedures, dirigeants, etablissements',
|
||||
"siren=$this->siren ORDER BY dateUpdate DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
if (count($ret)) {
|
||||
/** On v<EFBFBD>rifie qu'aucune annonce n'a <EFBFBD>t<EFBFBD> publi<EFBFBD> depuis au bodacc
|
||||
**/
|
||||
$tabRet=$ret[0];
|
||||
$ret=$iDb->select( 'jo.bodacc_detail', 'count(*)',
|
||||
"siren=$this->siren AND Bodacc_Date_Parution>='".$tabRet['dateUpdate']."'");
|
||||
if ($ret[0][0]==0) {
|
||||
$tabRet['procedures']=unserialize($tabRet['procedures']);
|
||||
$tabRet['dirigeants']=unserialize($tabRet['dirigeants']);
|
||||
$tabRet['etablissements']=unserialize($tabRet['etablissements']);
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
$url=$this->urlRacine.'/'.$this->weur.'/paie_abonnes_livraison_directe_informations.ow?flag_type_acces_direct_infos=FIC&WRNCSRV2='.$this->wrncsrv2;
|
||||
$page=getUrl($url, '', '', $this->referer, false, 'www.euridile.com');
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
//echo date('Y/m/d - H:i:s') ." - Fiche d'identit<69> = $url (Code retour = $this->codeRetour)<br/>".EOL;
|
||||
//$this->curPage='vitrine';
|
||||
$tabRet=array();
|
||||
|
||||
/**@todo Traiter le cas donn<EFBFBD>es provisoires :
|
||||
<TR><TD bgcolor='#fff0d0'><FONT COLOR=#100070 FACE=ARIAL SIZE=2><B><!-- Donn<6E>es provisoires --> En cours d'immatriculation, donn<6E>es provisoires</B></FONT></TD></TR><TR><TD bgcolor=#fff0d0><FONT COLOR=#100070 FACE=ARIAL SIZE=2>Nombre d'<27>tablissements : <FONT COLOR=#100070 FACE=ARIAL SIZE=2><B></B></TD></TR>
|
||||
</TABLE>
|
||||
*/
|
||||
// Identit<69>
|
||||
$tabRet['siren']=$this->siren;
|
||||
$tabRet['codeRetour']=$this->codeRetour;
|
||||
$tabRet['rcs']=@getTextInHtml($this->body, 'FACE="ARIAL,HELVETICA" SIZE=2>RCS : ', '<b>','</b>');
|
||||
$strTmp=@getTextInHtml($this->body, 'FACE="ARIAL,HELVETICA" SIZE=2>RCS : <b>', 'FACE="ARIAL,HELVETICA" SIZE=2><b>', '<img src=\'images/rouge.gif\'');
|
||||
$tabTmp=explode('</TD>', $strTmp);
|
||||
$tabRet['nom']=strip_tags($tabTmp[0]);
|
||||
// ... adresse
|
||||
for ($i=1; $i<5; $i++) {
|
||||
if (strpos($tabTmp[$i], 'Nom commercial - Enseigne :')===false &&
|
||||
strpos($tabTmp[$i], 'Sigle :')===false ) {
|
||||
$ligne=trim(strip_tags($tabTmp[$i]));
|
||||
if (preg_match("/^([0-9]{5,5})([\D]*)/i", $ligne, $matches)) {
|
||||
$tabRet['cp']=trim($matches[1]);
|
||||
$tabRet['ville']=trim($matches[2]);
|
||||
break;
|
||||
} else $tabRet['adresse'.$i]=$ligne;
|
||||
}
|
||||
}
|
||||
|
||||
$pp_nais=trim(strip_tags(@getTextInHtml($this->body, 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Date et lieu de naissance :', '<B>','</B>')));
|
||||
$tabTmp=explode(' <20> ', $pp_nais);
|
||||
$tabRet['naiss_date']=trim(str_replace('N<>(e) le ', '', strip_tags($tabTmp[0])));
|
||||
$tabRet['naiss_lieu']=trim(strip_tags($tabTmp[1]));
|
||||
$tabRet['sexe']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Sexe :', '<B>','</B>')));
|
||||
|
||||
$tabRet['enseigne']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Nom commercial - Enseigne :', '<B>','</B>')));
|
||||
$tabRet['sigle']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Sigle :', '<B>','</B>')));
|
||||
$tabRet['fj_lib']=@getTextInHtml($this->body, 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Forme juridique :', '<B>','</B>');
|
||||
$strTmp=@getTextInHtml($this->body, 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Activité :', '<B>','</B>');
|
||||
$tabTmp=explode(' - ', $strTmp);
|
||||
$tabRet['naf_code']=$tabTmp[0];
|
||||
$tabRet['naf_lib']=$tabTmp[1];
|
||||
$tabRet['date_crea']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Date de création :', '<B>','</B>')));
|
||||
$tabRet['date_imma']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Date d\'immatriculation :', '<B>','</B>')));
|
||||
$tabRet['greffe']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Greffe :', '<B>','</B>')));
|
||||
$tabRet['num_gestion']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>N<>de gestion :', '<B>','</B>')));
|
||||
$strTmp=@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Capital :', '<B>','</B>');
|
||||
if (preg_match('/([0-9\.,\s]*)([\D]*)/i', $strTmp, $matches)) {
|
||||
$tabRet['capital_mnt']=trim(str_replace(' ','',str_replace(',','.',$matches[1])));
|
||||
$tabRet['capital_dev']=$matches[2];
|
||||
}
|
||||
else {
|
||||
$tabRet['capital_mnt']=0;
|
||||
$tabRet['capital_dev']='';
|
||||
}
|
||||
$tabRet['nationalite']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Nationalité :', '<B>','</B>')));
|
||||
$tabRet['nb_etab']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Nombre d\'<27>tablissements :', '<B>','</B>')));
|
||||
if (strpos($this->body,'FACE=ARIAL SIZE=2><B>Radiation</B>')>0) {
|
||||
$tabRet['indRadiation']=true;
|
||||
$tabRet['date_radiation']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Entreprise radi<64>e le :', '<B>','</B>')));
|
||||
} else
|
||||
$tabRet['indRadiation']=false;
|
||||
|
||||
// Proc<6F>dures collectives
|
||||
if (strpos($this->body,'FACE=ARIAL SIZE=2><B>Les proc<6F>dures collectives</B>')>0) {
|
||||
$tabRet['indProcol']=true;
|
||||
$strTmp=@getTextInHtml($this->body, '<B>Les proc<6F>dures collectives</B></FONT>', "<img src='./images/rouge.gif' width=4 height=4 border='0'>",
|
||||
'</TABLE>');
|
||||
$tabTmp=explode("<img src='./images/rouge.gif' width=4 height=4 border='0'>", $strTmp);
|
||||
foreach ($tabTmp as $nproc=>$proc) {
|
||||
$tabTmp2=explode('</TD></TR>', $proc);
|
||||
$tabTmp3=explode(' du ', $tabTmp2[0]);
|
||||
$tabTmp2=explode('<TD WIDTH=99% ALIGN=LEFT BGCOLOR=#fff0d0 colspan=2><FONT COLOR=#100070 FACE=ARIAL SIZE=2>', $proc);
|
||||
$tabInter=array();
|
||||
for($nInter=1; isset($tabTmp2[$nInter]); $nInter++) {
|
||||
$tabTmp4=explode('</TD></TR>', $tabTmp2[$nInter]);
|
||||
$tabInter[]=array( 'type'=>trim(strip_tags($tabTmp4[0])),
|
||||
'nom'=>trim(str_replace(' ','',strip_tags($tabTmp4[1]))),
|
||||
'adresse'=>trim(str_replace(' ','',strip_tags($tabTmp4[2]))),
|
||||
'cpVille'=>trim(str_replace(' ','',strip_tags($tabTmp4[3]))));
|
||||
}
|
||||
$tabRet['procedures'][$nproc]=array('type'=>trim(strip_tags($tabTmp3[0])),
|
||||
'date'=>trim(strip_tags($tabTmp3[1])),
|
||||
'intervenant'=>$tabInter);
|
||||
}
|
||||
}
|
||||
else $tabRet['indProcol']=false;
|
||||
|
||||
// Dirigeants
|
||||
$strTmp=@getTextInHtml($this->body, '<B>Les dirigeants</B></FONT>', "<img src='./images/rouge.gif' width=4 height=4 border='0'>",'</TABLE>');
|
||||
$tabTmp=explode("<img src='./images/rouge.gif' width=4 height=4 border='0'>", $strTmp);
|
||||
foreach ($tabTmp as $ndir=>$dir) {
|
||||
$tabTmp2=explode('</TD>', $dir);
|
||||
$tabTmp3=explode('</B> ', $tabTmp2[1]);
|
||||
$nom=trim(strip_tags($tabTmp3[0]));
|
||||
$prenom=trim(strip_tags($tabTmp3[1]));
|
||||
$naiss=trim(strip_tags($tabTmp2[3]));
|
||||
if (strpos($naiss, 'N<>(e) le')===false) {
|
||||
$fonction=$naiss;
|
||||
} else {
|
||||
$tabTmp3=explode(' <20> ', $naiss);
|
||||
$naiss_date=trim(str_replace('N<>(e) le ', '', strip_tags($tabTmp3[0])));
|
||||
$naiss=trim(strip_tags($tabTmp3[1]));
|
||||
$tabTmp3=explode('(', $naiss);
|
||||
$naiss_ville=trim(strip_tags($tabTmp3[0]));
|
||||
$naiss_depPays=trim(str_replace(')','', strip_tags($tabTmp3[1])));
|
||||
$fonction=trim(strip_tags($tabTmp2[5]));
|
||||
}
|
||||
$tabTmp=explode(' n<>e ', $prenom);
|
||||
$prenom=$tabTmp[0];
|
||||
$naiss_nom=$tabTmp[1];
|
||||
$tabRet['dirigeants'][$ndir]=array( 'nom'=>$nom,
|
||||
'prenom'=>$prenom,
|
||||
'naiss_nom'=>$naiss_nom,
|
||||
'naiss_date'=>$naiss_date,
|
||||
'naiss_ville'=>$naiss_ville,
|
||||
'naiss_depPays'=>$naiss_depPays,
|
||||
'fonction'=>$fonction);
|
||||
}
|
||||
|
||||
// Dirigeants - Administrateurs
|
||||
$strTmp=trim(@getTextInHtml($this->body, '<B>Les administrateurs</B></FONT>', "<img src='./images/rouge.gif' width=4 height=4 border='0'>",'</TABLE>'));
|
||||
if ($strTmp<>'') {
|
||||
$tabTmp=explode("<img src='./images/rouge.gif' width=4 height=4 border='0'>", $strTmp);
|
||||
foreach ($tabTmp as $nadm=>$dir) {
|
||||
$tabTmp2=explode('</TD>', $dir);
|
||||
$tabTmp3=explode('</B> ', $tabTmp2[1]);
|
||||
$nom=trim(strip_tags($tabTmp3[0]));
|
||||
$prenom=trim(strip_tags($tabTmp3[1]));
|
||||
$naiss=trim(strip_tags($tabTmp2[3]));
|
||||
if (strpos($naiss, 'N<>(e) le')===false) {
|
||||
$naiss_date=$naiss_ville=$naiss_depPays='';
|
||||
$fonction=$naiss;
|
||||
} else {
|
||||
$tabTmp3=explode(' <20> ', $naiss);
|
||||
$naiss_date=trim(str_replace('N<>(e) le ', '', strip_tags($tabTmp3[0])));
|
||||
$naiss=trim(strip_tags($tabTmp3[1]));
|
||||
$tabTmp3=explode('(', $naiss);
|
||||
$naiss_ville=trim(strip_tags($tabTmp3[0]));
|
||||
$naiss_depPays=trim(str_replace(')','', strip_tags($tabTmp3[1])));
|
||||
$fonction=trim(strip_tags($tabTmp2[5]));
|
||||
}
|
||||
$tabTmp=explode(' n<>e ', $prenom);
|
||||
$prenom=$tabTmp[0];
|
||||
$naiss_nom=$tabTmp[1];
|
||||
$tabRet['dirigeants'][$nadm+$ndir+1]=array( 'nom'=>$nom,
|
||||
'prenom'=>$prenom,
|
||||
'naiss_nom'=>$naiss_nom,
|
||||
'naiss_date'=>$naiss_date,
|
||||
'naiss_ville'=>$naiss_ville,
|
||||
'naiss_depPays'=>$naiss_depPays,
|
||||
'fonction'=>$fonction);
|
||||
}
|
||||
}
|
||||
|
||||
// Etablissements
|
||||
$strTmp=@getTextInHtml($this->body, '<B>Les <20>tablissements</B></FONT>', "<img src='./images/rouge.gif' width=4 height=4 border='0'>",'</TABLE>');
|
||||
$tabTmp=explode("<img src='./images/rouge.gif' width=4 height=4 border='0'>", $strTmp);
|
||||
foreach ($tabTmp as $netab=>$dir) {
|
||||
$cp=$ville=$ensEtab=''; $j=0;
|
||||
$tabTmp2=explode('</TD>', $dir);
|
||||
for($i=1; $i<=9; $i=$i+2) {
|
||||
$next=$i+2;
|
||||
$strTmp=trim(strip_tags($tabTmp2[$i]));
|
||||
if (preg_match("/^([0-9]{5,5})([\D]*)/i", $strTmp, $matches)) {
|
||||
$adresse[$j]='';
|
||||
$cp=trim($matches[1]);
|
||||
$ville=trim($matches[2]);
|
||||
break;
|
||||
} else
|
||||
$adresse[$j]=$strTmp;
|
||||
|
||||
$j++;
|
||||
}
|
||||
/** Gestion des cas o<> la 1<>re ligne d'adresse contient l'enseigne de l'<27>tablissement */
|
||||
if (strtoupper($adresse[0])==strtoupper($tabRet['enseigne'])) {
|
||||
$ensEtab=$adresse[0];
|
||||
array_shift($adresse);
|
||||
}
|
||||
$strTmp=trim(strip_tags($tabTmp2[$next]));
|
||||
$tabTmp3=explode(' - ', $strTmp);
|
||||
$tabRet['etablissements'][$netab]=array( 'enseigne'=>$ensEtab,
|
||||
'adresse1'=>$adresse[0],
|
||||
'adresse2'=>$adresse[1],
|
||||
'adresse3'=>$adresse[2],
|
||||
'cp'=>$cp,
|
||||
'ville'=>$ville,
|
||||
'naf_code'=>$tabTmp3[0],
|
||||
'naf_lib'=>$tabTmp3[1]);
|
||||
}
|
||||
|
||||
$fp=fopen('./euridile_identite.log', 'w');
|
||||
fwrite($fp,print_r($page,true));
|
||||
fclose($fp);
|
||||
|
||||
$tabInsert=$tabRet;
|
||||
$tabInsert['procedures']=serialize($tabRet['procedures']);
|
||||
$tabInsert['dirigeants']=serialize($tabRet['dirigeants']);
|
||||
$tabInsert['etablissements']=serialize($tabRet['etablissements']);
|
||||
|
||||
$iDb->insert( 'jo.rncs_entrep', $tabInsert);
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
private function partSaveSession() {
|
||||
$fp=fopen('/tmp/php_rncs_session.id', 'w');
|
||||
fwrite($fp,$this->wrncsrv2.'^'.$this->timeOut.'^'.$this->curPage.'^'.$this->siren.'^'.$this->url.'^'.$this->referer);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
private function partGetSession() {
|
||||
$strTmp=@file_get_contents('/tmp/php_rncs_session.id');
|
||||
if ($strTmp) {
|
||||
$tabTmp=explode('^', $strTmp);
|
||||
$this->wrncsrv2=$tabTmp[0];
|
||||
$this->timeOut=$tabTmp[1];
|
||||
$this->curPage=$tabTmp[2];
|
||||
$this->siren=$tabTmp[3];
|
||||
$this->url=$tabTmp[4];
|
||||
$this->referer=$tabTmp[5];
|
||||
} else $this->timeOut=0;
|
||||
}
|
||||
|
||||
private function logEuridileError($message) {
|
||||
$fp=fopen('./euridile_error.log', 'w');
|
||||
fwrite($fp,date('Y/m/d H:i:s')." - Erreur : $message (".$this->wrncsrv2.'^'.$this->timeOut.'^'.$this->curPage.'^'.$this->siren.'^'.$this->url.'^'.$this->referer.')'.EOL);
|
||||
fwrite($fp,$this->body.EOL.'-------------------------------------------------------------------------------------'.EOL);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -1,6 +1,4 @@
|
||||
<?php
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
class Metier_Partenaires_MMarques
|
||||
{
|
||||
private $iDb;
|
||||
|
@ -8,20 +8,31 @@ class Metier_Partenaires_MOrias
|
||||
private $header = '';
|
||||
private $cookie = '';
|
||||
private $codeRetour = 0;
|
||||
private $accesDist=true;
|
||||
private $iDb;
|
||||
|
||||
public $enCache=false;
|
||||
public $force=false;
|
||||
public $annee=0;
|
||||
public $erreur='';
|
||||
|
||||
/**
|
||||
* Remote Flag
|
||||
* @var boolean
|
||||
*/
|
||||
protected $remote = false;
|
||||
|
||||
public function __construct($accesDist = true, $db = null)
|
||||
{
|
||||
$this->accesDist = $accesDist;
|
||||
/**
|
||||
* SIREN
|
||||
* @var string
|
||||
*/
|
||||
protected $siren;
|
||||
|
||||
/**
|
||||
* Num ORIAS
|
||||
* @var integer
|
||||
*/
|
||||
protected $num;
|
||||
|
||||
public function __construct($db = null)
|
||||
{
|
||||
if ($db === null) {
|
||||
$this->iDb = new Metier_Util_Db();
|
||||
} else {
|
||||
@ -37,6 +48,12 @@ class Metier_Partenaires_MOrias
|
||||
$this->remote = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Numero ORIAS
|
||||
* @param int $annee
|
||||
* @return string
|
||||
* Retourne le numéro ORIAS
|
||||
*/
|
||||
public function getMaxOrias($annee = 0)
|
||||
{
|
||||
if ($annee*1 > 0 && $annee*1 < 100) {
|
||||
@ -57,240 +74,263 @@ class Metier_Partenaires_MOrias
|
||||
return sprintf('%08d', $ret[0]['numOrias']);
|
||||
}
|
||||
|
||||
public function getInfosOrias($siren, $numOrias=0)
|
||||
/**
|
||||
* Infos ORIAS
|
||||
* @param string $siren
|
||||
* @param int $num
|
||||
*/
|
||||
public function getInfosOrias($siren, $num=0)
|
||||
{
|
||||
if ($siren*1 > 1000) {
|
||||
$strWhere = "siren=$siren";
|
||||
} elseif ($numOrias*1 > 0) {
|
||||
$strWhere = "numOrias=$numOrias";
|
||||
$this->siren = $siren;
|
||||
$this->num = $num;
|
||||
|
||||
// Remote
|
||||
if ($this->remote) {
|
||||
$result = $this->getRemoteInfosOrias();
|
||||
if ($result !== false && count($result) > 0) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
// Database
|
||||
if ($this->siren * 1 > 1000) {
|
||||
$strWhere = "siren=$this->siren";
|
||||
} elseif ($this->num * 1 > 0) {
|
||||
$strWhere = "numOrias=$this->num";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret = $this->iDb->select('sdv1.orias', 'siren, id, nom, cp, ville, adresse, numOrias, numOriasAttribue',
|
||||
$ret = $this->iDb->select('sdv1.orias',
|
||||
'siren, id, nom, cp, ville, adresse, numOrias, numOriasAttribue',
|
||||
$strWhere, false, MYSQL_ASSOC);
|
||||
if (!$this->force && count($ret) > 0) {
|
||||
$this->enCache = true;
|
||||
$tabRet = $ret[0];//array();
|
||||
$ret = $this->iDb->select('sdv1.orias', 'categorie, cat, dateInscription, typeStatut, rcsVille, rcsCode, rcsSiren, contact, encaissement, nature, paysPresta, paysEtab', $strWhere, false, MYSQL_ASSOC);
|
||||
if (count($ret) > 0) {
|
||||
$tabRet = $ret[0];
|
||||
$ret = $this->iDb->select('sdv1.orias',
|
||||
'categorie, cat, dateInscription, typeStatut, rcsVille, rcsCode, rcsSiren, contact, encaissement, nature, paysPresta, paysEtab',
|
||||
$strWhere, false, MYSQL_ASSOC);
|
||||
foreach ($ret as $i=>$tabTmp) {
|
||||
$tabRet['categories'][]=$tabTmp;
|
||||
$tabRet['categories'][] = $tabTmp;
|
||||
}
|
||||
} elseif ($this->accesDist == true) {
|
||||
$this->enCache = false;
|
||||
}
|
||||
|
||||
// Initialisation Cookies
|
||||
if ($numOrias>0) {
|
||||
$this->referer='http://www.orias.fr/orias/public/index.jsp';
|
||||
} else {
|
||||
$this->referer='http://www.orias.fr/orias/public/rechercheavance.html';
|
||||
}
|
||||
$page = getUrl($this->referer, '', '', '', false, '', '', 15);
|
||||
if ($page['code'] == 200) {
|
||||
$this->cookie = str_replace(' Path=/orias', '', $page['header']['Set-Cookie']);
|
||||
if (preg_match('/id="javax\.faces\.ViewState" value="(.*)"/Ui', $page['body'], $matches)) {
|
||||
$this->codeRetour = $matches[1];
|
||||
} else {
|
||||
echo 'Erreur Url='.$this->referer.PHP_EOL;
|
||||
print_r($page['body']);
|
||||
return false;
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
protected function getRemoteInfosOrias()
|
||||
{
|
||||
// Initialisation Cookies
|
||||
if ($this->num > 0) {
|
||||
$this->referer='http://www.orias.fr/orias/public/index.jsp';
|
||||
} else {
|
||||
$this->referer='http://www.orias.fr/orias/public/rechercheavance.html';
|
||||
}
|
||||
$page = getUrl($this->referer, '', '', '', false, '', '', 15);
|
||||
if ($page['code'] == 200) {
|
||||
$this->cookie = str_replace(' Path=/orias', '', $page['header']['Set-Cookie']);
|
||||
if (preg_match('/id="javax\.faces\.ViewState" value="(.*)"/Ui', $page['body'], $matches)) {
|
||||
$this->codeRetour = $matches[1];
|
||||
} else {
|
||||
echo 'Erreur Url='.$this->referer.PHP_EOL;
|
||||
print_r($page['body']);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($numOrias>0) {
|
||||
$url = 'http://www.orias.fr/orias/public/index.html';
|
||||
$post = array(
|
||||
'menu%3AiasSearchForm'=>'menu%3AiasSearchForm',
|
||||
'menu%3AiasSearchForm%3AiasInputText'=>sprintf('%08s', $numOrias),
|
||||
'javax.faces.ViewState'=>$this->codeRetour,
|
||||
'menu%3AiasSearchForm%3AiasSearch'=>'menu%3AiasSearchForm%3AiasSearch',
|
||||
if ($this->num > 0) {
|
||||
$url = 'http://www.orias.fr/orias/public/index.html';
|
||||
$post = array(
|
||||
'menu%3AiasSearchForm'=>'menu%3AiasSearchForm',
|
||||
'menu%3AiasSearchForm%3AiasInputText'=>sprintf('%08s', $this->num),
|
||||
'javax.faces.ViewState'=>$this->codeRetour,
|
||||
'menu%3AiasSearchForm%3AiasSearch'=>'menu%3AiasSearchForm%3AiasSearch',
|
||||
);
|
||||
} else {
|
||||
// Recherche avec Siren
|
||||
$url = 'http://www.orias.fr/orias/public/rechercheavance.html';
|
||||
$post = array(
|
||||
'j_id_id45'=>'j_id_id45',
|
||||
'j_id_id45%3Aj_id_id52'=>'',
|
||||
'j_id_id45%3AtagRCS'=>'',
|
||||
'j_id_id45%3AtagSIREN'=>$siren,//441921574,
|
||||
'j_id_id45%3Aj_id_id160'=>'',
|
||||
'j_id_id45%3Aj_id_id167'=>'',
|
||||
'j_id_id45%3Aj_id_id175'=>'',
|
||||
'javax.faces.ViewState'=>$this->codeRetour,
|
||||
'j_id_id45%3Aj_id_id203'=>'j_id_id45%3Aj_id_id203'
|
||||
);
|
||||
$this->referer = 'http://www.orias.fr/orias/public/list.html';
|
||||
}
|
||||
sleep(rand(1, 2));
|
||||
$page = getUrl($url, $this->cookie, $post, $this->referer, false, '', '', 15);
|
||||
$this->referer = $url;
|
||||
if ($page['code'] == 302) {
|
||||
$url = $page['header']['Location'];
|
||||
} else {
|
||||
if (preg_match("/Le numéro d'immatriculation n'existe pas/", $page['body'])) {
|
||||
$tabInsert = array(
|
||||
'actif' => 0,
|
||||
'numOrias' => $this->num,
|
||||
'numOriasAttribue' => 0,
|
||||
'dateInsert' => date('YmdHis')
|
||||
);
|
||||
} else {
|
||||
// Recherche avec Siren
|
||||
$url = 'http://www.orias.fr/orias/public/rechercheavance.html';
|
||||
$post = array(
|
||||
'j_id_id45'=>'j_id_id45',
|
||||
'j_id_id45%3Aj_id_id52'=>'',
|
||||
'j_id_id45%3AtagRCS'=>'',
|
||||
'j_id_id45%3AtagSIREN'=>$siren,//441921574,
|
||||
'j_id_id45%3Aj_id_id160'=>'',
|
||||
'j_id_id45%3Aj_id_id167'=>'',
|
||||
'j_id_id45%3Aj_id_id175'=>'',
|
||||
'javax.faces.ViewState'=>$this->codeRetour,
|
||||
'j_id_id45%3Aj_id_id203'=>'j_id_id45%3Aj_id_id203'
|
||||
);
|
||||
$this->referer = 'http://www.orias.fr/orias/public/list.html';
|
||||
}
|
||||
sleep(rand(1, 2));
|
||||
$page = getUrl($url, $this->cookie, $post, $this->referer, false, '', '', 15);
|
||||
$this->referer = $url;
|
||||
if ($page['code'] == 302) {
|
||||
$url = $page['header']['Location'];
|
||||
} else {
|
||||
if (preg_match("/Le numéro d'immatriculation n'existe pas/", $page['body'])) {
|
||||
$tabInsert = array(
|
||||
'actif' => 0,
|
||||
'numOrias' => $numOrias,
|
||||
'numOriasAttribue' => 0,
|
||||
'dateInsert' => date('YmdHis')
|
||||
);
|
||||
$this->erreur = 'Numéro Orias inexistant';
|
||||
// On enregistre ce numéro comme non attribué si < au dernier numéro attribué
|
||||
if ($numOrias < $this->getMaxOrias()) {
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
}
|
||||
$this->erreur = 'Numéro Orias inexistant';
|
||||
// On enregistre ce numéro comme non attribué si < au dernier numéro attribué
|
||||
if ($this->num < $this->getMaxOrias()) {
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($url == 'http://www.orias.fr/orias/public/intermediaire.html') {
|
||||
$page = getUrl($url, $this->cookie, '', $this->referer, false, '', '', 24);
|
||||
$this->referer = $url;
|
||||
$this->body = $page['body'];
|
||||
echo "Recherche par Orias : url=$url".PHP_EOL;
|
||||
die(print_r($page));
|
||||
}
|
||||
|
||||
// Liste contenant l'entreprise
|
||||
$url = 'http://www.orias.fr/orias/public/list.html';
|
||||
sleep(rand(1, 2));
|
||||
if ($url == 'http://www.orias.fr/orias/public/intermediaire.html') {
|
||||
$page = getUrl($url, $this->cookie, '', $this->referer, false, '', '', 24);
|
||||
$this->referer = $url;
|
||||
$this->body = $page['body'];
|
||||
echo "Recherche par Orias : url=$url".PHP_EOL;
|
||||
die(print_r($page));
|
||||
}
|
||||
|
||||
if (preg_match('/<td>R\é\;sultat\(s\) de votre recherche \:(?:.*)<strong>(.*)<(?:.*)Interm\é\;diaire\(s\)/Uis', $this->body, $matches)) {
|
||||
$nbInter = trim($matches[1])*1;
|
||||
if ($nbInter == 0) {
|
||||
return false;
|
||||
}
|
||||
if ($nbInter > 1) {
|
||||
return false;
|
||||
}
|
||||
// Liste contenant l'entreprise
|
||||
$url = 'http://www.orias.fr/orias/public/list.html';
|
||||
sleep(rand(1, 2));
|
||||
$page = getUrl($url, $this->cookie, '', $this->referer, false, '', '', 24);
|
||||
$this->referer = $url;
|
||||
$this->body = $page['body'];
|
||||
|
||||
if (preg_match('/<td>R\é\;sultat\(s\) de votre recherche \:(?:.*)<strong>(.*)<(?:.*)Interm\é\;diaire\(s\)/Uis', $this->body, $matches)) {
|
||||
$nbInter = trim($matches[1])*1;
|
||||
if ($nbInter == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initalisation du tableau retour
|
||||
$tabRet = array('siren'=>$siren);
|
||||
|
||||
//id="formResult:intermediariesList:13910
|
||||
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell haut " id="formResult\:intermediariesList\:(.*)\:j_id_id117">(?:.*)<center>(.*)<\/center>/Uis', $this->body, $matches)) {
|
||||
$tabRet['id'] = trim($matches[1]);
|
||||
$tabRet['nom'] = html_entity_decode(trim($matches[2]));
|
||||
}
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell r.cp_ville " id="formResult\:intermediariesList\:(?:.*)\:j_id_id124">(?:.*)<center>(.*)<\/center>/Uis', $this->body, $matches)) {
|
||||
$tabTmp = explode(' ', $matches[1]);
|
||||
$tabRet['cp'] = trim($tabTmp[0]);
|
||||
$tabRet['ville'] = html_entity_decode(trim($tabTmp[1]));
|
||||
}
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell r.adresse " id="formResult\:intermediariesList\:(?:.*)\:j_id_id133">(.*)<\/td>/Uis', $this->body, $matches)) {
|
||||
$tabRet['adresse'] = html_entity_decode(trim($matches[1]));
|
||||
}
|
||||
|
||||
$tabRet['actif'] = 1;
|
||||
$tabRet['numOriasAttribue'] = 1;
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell r.immat " id="formResult\:intermediariesList\:(?:.*)\:j_id_id138">(?:.*|)(<span style="white-space\: no-wrap;">|Radi\é\; le \:)(.*)(?:<\/span>|<\/td>)/Uis', $this->body, $matches)) {
|
||||
$str = trim(strtr($matches[2], array(' '=>'', ' '=>'')));
|
||||
if (html_entity_decode(trim(str_replace(':', '', $matches[1]))) == 'Radié le') {
|
||||
$tabRet['actif'] = 0;
|
||||
$tabRet['numOrias'] = $numOrias;
|
||||
$tabRet['dateRadiation'] = $str;
|
||||
} else {
|
||||
$tabRet['numOrias'] = $str;
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/ id="javax\.faces\.ViewState" value="(.*)" /Uis', $this->body, $matches)) {
|
||||
$this->codeRetour = $matches[1];
|
||||
}
|
||||
|
||||
$tabTmp = explode("<a href=\"#\" onclick=\"if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('formResult'),{'", $this->body);
|
||||
|
||||
foreach ($tabTmp as $i => $strCat) {
|
||||
if ($i == 0) {
|
||||
if (count($tabTmp) == 1) {
|
||||
$tabInsert = array_merge($tabRet, array('dateInsert'=>date('YmdHis')));
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
}
|
||||
$tabRet['categories'] = array();
|
||||
continue;
|
||||
}
|
||||
$tabCat = array();
|
||||
|
||||
if (preg_match('/<span style="text-align\: left">(.*)<\/span>/Ui', $strCat, $matches)) {
|
||||
$tabCat['categorie'] = html_entity_decode(trim($matches[1]));
|
||||
}
|
||||
if (preg_match('/intermediaryRoleIdParam\'\:\'(.*)\'/Uis', $strCat, $matches)) {
|
||||
$tabCat['cat'] = $matches[1];
|
||||
}
|
||||
|
||||
|
||||
// Tout est dans la même page Html
|
||||
if ($i==1) {
|
||||
// Construction du lien vers la fiche d'identité de l'entreprise
|
||||
$url = 'http://www.orias.fr/orias/public/list.html';
|
||||
$post = array(
|
||||
'formResult' => 'formResult',
|
||||
'formResult%3AajaxLoadingModalBoxOpenedState' => '',
|
||||
'javax.faces.ViewState' => $this->codeRetour,
|
||||
'intermediaryIdParam' => $tabRet['id'],
|
||||
'intermediaryRoleIdParam' => $tabCat['cat'],
|
||||
);
|
||||
if (preg_match('/(formResult\:intermediariesList\:(?:.*)),intermediaryIdParam,/Ui', $strCat, $matches)) {
|
||||
$tabTmp2 = explode(',', $matches[1]);
|
||||
$post[urlencode($tabTmp2[0])] = urlencode($tabTmp2[1]);
|
||||
}
|
||||
sleep(rand(1, 2));
|
||||
$page = getUrl($url, $this->cookie, $post, $this->referer, false, '', '', 24);
|
||||
$tmpCat = explode('class="dr-tbpnl-cntnt-pstn rich-tabpanel-content-position"', $page['body']);
|
||||
}
|
||||
|
||||
if (preg_match('/<dd class="col3">Date d\'inscription \: <strong>(.*)<\/strong><\/dd>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['dateInscription'] = trim($matches[1]);
|
||||
}
|
||||
if (preg_match('/<td align="right"(?: |)>Statut \:<\/td>(.*)<\/strong>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['typeStatut'] = trim(strip_tags($matches[1]));
|
||||
}
|
||||
if (preg_match('/<td align="right">RCS \:<\/td>(?:.*)<td width="5%"><\/td>(?:.*)<td width="70%"><strong>(.*)<\/strong>(.*)SIREN \:(?:.*)<strong>(.*)<\/strong>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['rcsVille'] = trim($matches[1]);
|
||||
$tabCat['rcsCode'] = trim(strtr(strip_tags($matches[2]), array(' '=>'', ' '=>'', chr(160)=>'', "\r"=>'', "\n"=>'')));
|
||||
$tabCat['rcsSiren'] = trim($matches[3]);
|
||||
if ($siren == 0) {
|
||||
$tabRet['siren'] = $tabCat['rcsSiren'];
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/<td align="right">Contact<\/td>(.*)<\/tr>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['contact'] = html_entity_decode(trim(strip_tags($matches[1])));
|
||||
}
|
||||
|
||||
if (preg_match("/<strong>(.*)Cet intermédiaire n'est pas autorisé à encaisser les primes ou cotisations d'assurances(.*)<\/strong>/Uis", $tmpCat[$i])) {
|
||||
$tabCat['encaissement'] = 0;
|
||||
} else {
|
||||
$tabCat['encaissement'] = 1;
|
||||
}
|
||||
|
||||
if (preg_match('/<span class="txt_ssTitre">(?:.*)Nature de l\'activit\é\; d\'interm\é\;diation(.*)<\/dd>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['nature'] = html_entity_decode(trim(strip_tags($matches[1])));
|
||||
}
|
||||
|
||||
if (preg_match('/<td width="50%" valign="top" align="left">\- Etats dans lesquels cet interm\é\;diaire exerce en libre prestation de service(.*)<\/table>(.*)<\/tr>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['paysPresta'] = trim(strip_tags($matches[1]));
|
||||
}
|
||||
|
||||
if (preg_match('/<td width="222" align="left">\- Etats dans lesquels cet interm\é\;diaire exerce en libert\é\; d\'\é\;tablissement(.*)<\/table>(.*)<\/tr>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['paysEtab'] =trim(strip_tags($matches[1]));
|
||||
}
|
||||
|
||||
$tabRet['categories'][] = $tabCat;
|
||||
|
||||
$tabInsert = $tabRet;
|
||||
unset($tabInsert['categories']);
|
||||
$tabInsert = array_merge($tabInsert, $tabCat, array('dateInsert'=>date('YmdHis')));
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
if ($nbInter > 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Initalisation du tableau retour
|
||||
$tabRet = array('siren'=>$siren);
|
||||
|
||||
//id="formResult:intermediariesList:13910
|
||||
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell haut " id="formResult\:intermediariesList\:(.*)\:j_id_id117">(?:.*)<center>(.*)<\/center>/Uis', $this->body, $matches)) {
|
||||
$tabRet['id'] = trim($matches[1]);
|
||||
$tabRet['nom'] = html_entity_decode(trim($matches[2]));
|
||||
}
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell r.cp_ville " id="formResult\:intermediariesList\:(?:.*)\:j_id_id124">(?:.*)<center>(.*)<\/center>/Uis', $this->body, $matches)) {
|
||||
$tabTmp = explode(' ', $matches[1]);
|
||||
$tabRet['cp'] = trim($tabTmp[0]);
|
||||
$tabRet['ville'] = html_entity_decode(trim($tabTmp[1]));
|
||||
}
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell r.adresse " id="formResult\:intermediariesList\:(?:.*)\:j_id_id133">(.*)<\/td>/Uis', $this->body, $matches)) {
|
||||
$tabRet['adresse'] = html_entity_decode(trim($matches[1]));
|
||||
}
|
||||
|
||||
$tabRet['actif'] = 1;
|
||||
$tabRet['numOriasAttribue'] = 1;
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell r.immat " id="formResult\:intermediariesList\:(?:.*)\:j_id_id138">(?:.*|)(<span style="white-space\: no-wrap;">|Radi\é\; le \:)(.*)(?:<\/span>|<\/td>)/Uis', $this->body, $matches)) {
|
||||
$str = trim(strtr($matches[2], array(' '=>'', ' '=>'')));
|
||||
if (html_entity_decode(trim(str_replace(':', '', $matches[1]))) == 'Radié le') {
|
||||
$tabRet['actif'] = 0;
|
||||
$tabRet['numOrias'] = $this->num;
|
||||
$tabRet['dateRadiation'] = $str;
|
||||
} else {
|
||||
$tabRet['numOrias'] = $str;
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/ id="javax\.faces\.ViewState" value="(.*)" /Uis', $this->body, $matches)) {
|
||||
$this->codeRetour = $matches[1];
|
||||
}
|
||||
|
||||
$tabTmp = explode("<a href=\"#\" onclick=\"if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('formResult'),{'", $this->body);
|
||||
|
||||
foreach ($tabTmp as $i => $strCat) {
|
||||
if ($i == 0) {
|
||||
if (count($tabTmp) == 1) {
|
||||
$tabInsert = array_merge($tabRet, array('dateInsert'=>date('YmdHis')));
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
}
|
||||
$tabRet['categories'] = array();
|
||||
continue;
|
||||
}
|
||||
$tabCat = array();
|
||||
|
||||
if (preg_match('/<span style="text-align\: left">(.*)<\/span>/Ui', $strCat, $matches)) {
|
||||
$tabCat['categorie'] = html_entity_decode(trim($matches[1]));
|
||||
}
|
||||
if (preg_match('/intermediaryRoleIdParam\'\:\'(.*)\'/Uis', $strCat, $matches)) {
|
||||
$tabCat['cat'] = $matches[1];
|
||||
}
|
||||
|
||||
|
||||
// Tout est dans la même page Html
|
||||
if ($i==1) {
|
||||
// Construction du lien vers la fiche d'identité de l'entreprise
|
||||
$url = 'http://www.orias.fr/orias/public/list.html';
|
||||
$post = array(
|
||||
'formResult' => 'formResult',
|
||||
'formResult%3AajaxLoadingModalBoxOpenedState' => '',
|
||||
'javax.faces.ViewState' => $this->codeRetour,
|
||||
'intermediaryIdParam' => $tabRet['id'],
|
||||
'intermediaryRoleIdParam' => $tabCat['cat'],
|
||||
);
|
||||
if (preg_match('/(formResult\:intermediariesList\:(?:.*)),intermediaryIdParam,/Ui', $strCat, $matches)) {
|
||||
$tabTmp2 = explode(',', $matches[1]);
|
||||
$post[urlencode($tabTmp2[0])] = urlencode($tabTmp2[1]);
|
||||
}
|
||||
sleep(rand(1, 2));
|
||||
$page = getUrl($url, $this->cookie, $post, $this->referer, false, '', '', 24);
|
||||
$tmpCat = explode('class="dr-tbpnl-cntnt-pstn rich-tabpanel-content-position"', $page['body']);
|
||||
}
|
||||
|
||||
if (preg_match('/<dd class="col3">Date d\'inscription \: <strong>(.*)<\/strong><\/dd>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['dateInscription'] = trim($matches[1]);
|
||||
}
|
||||
if (preg_match('/<td align="right"(?: |)>Statut \:<\/td>(.*)<\/strong>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['typeStatut'] = trim(strip_tags($matches[1]));
|
||||
}
|
||||
if (preg_match('/<td align="right">RCS \:<\/td>(?:.*)<td width="5%"><\/td>(?:.*)<td width="70%"><strong>(.*)<\/strong>(.*)SIREN \:(?:.*)<strong>(.*)<\/strong>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['rcsVille'] = trim($matches[1]);
|
||||
$tabCat['rcsCode'] = trim(strtr(strip_tags($matches[2]), array(' '=>'', ' '=>'', chr(160)=>'', "\r"=>'', "\n"=>'')));
|
||||
$tabCat['rcsSiren'] = trim($matches[3]);
|
||||
if ($siren == 0) {
|
||||
$tabRet['siren'] = $tabCat['rcsSiren'];
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/<td align="right">Contact<\/td>(.*)<\/tr>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['contact'] = html_entity_decode(trim(strip_tags($matches[1])));
|
||||
}
|
||||
|
||||
if (preg_match("/<strong>(.*)Cet intermédiaire n'est pas autorisé à encaisser les primes ou cotisations d'assurances(.*)<\/strong>/Uis", $tmpCat[$i])) {
|
||||
$tabCat['encaissement'] = 0;
|
||||
} else {
|
||||
$tabCat['encaissement'] = 1;
|
||||
}
|
||||
|
||||
if (preg_match('/<span class="txt_ssTitre">(?:.*)Nature de l\'activit\é\; d\'interm\é\;diation(.*)<\/dd>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['nature'] = html_entity_decode(trim(strip_tags($matches[1])));
|
||||
}
|
||||
|
||||
if (preg_match('/<td width="50%" valign="top" align="left">\- Etats dans lesquels cet interm\é\;diaire exerce en libre prestation de service(.*)<\/table>(.*)<\/tr>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['paysPresta'] = trim(strip_tags($matches[1]));
|
||||
}
|
||||
|
||||
if (preg_match('/<td width="222" align="left">\- Etats dans lesquels cet interm\é\;diaire exerce en libert\é\; d\'\é\;tablissement(.*)<\/table>(.*)<\/tr>/Uis', $tmpCat[$i], $matches)) {
|
||||
$tabCat['paysEtab'] =trim(strip_tags($matches[1]));
|
||||
}
|
||||
|
||||
$tabRet['categories'][] = $tabCat;
|
||||
|
||||
$tabInsert = $tabRet;
|
||||
unset($tabInsert['categories']);
|
||||
$tabInsert = array_merge($tabInsert, $tabCat, array('dateInsert'=>date('YmdHis')));
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
}
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,10 @@
|
||||
<?php
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
class Metier_Partenaires_MTel
|
||||
{
|
||||
public $body = '';
|
||||
public $header = '';
|
||||
public $codeRetour = 0;
|
||||
|
||||
public $cookie='';
|
||||
public $urlBase='http://www.pagespro.com/recherche.php';
|
||||
public $url='';
|
||||
public $referer='';
|
||||
public $enCache=false;
|
||||
private $accesDistant=false;
|
||||
|
||||
public $iDb;
|
||||
|
||||
protected $remote = false;
|
||||
|
||||
public function __construct($accesDistant=false, $db=null)
|
||||
public function __construct($db = null)
|
||||
{
|
||||
$this->accesDistant=$accesDistant;
|
||||
$this->accesDistant=false; // Accès bloqué par "pagespro"
|
||||
if ($this->accesDistant) {
|
||||
$this->url=$this->urlBase;
|
||||
$page=getUrl($this->url, $this->cookie, '', $this->referer, false, '', '', 3);
|
||||
$this->referer=$this->url;
|
||||
$this->cookie=$page['header']['Set-Cookie'];
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
}
|
||||
if ($db === null) {
|
||||
$this->iDb = new Metier_Util_Db();
|
||||
} else {
|
||||
@ -37,14 +12,6 @@ class Metier_Partenaires_MTel
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Active la récupération des données distantes
|
||||
*/
|
||||
public function setRemote()
|
||||
{
|
||||
$this->remote = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information contact
|
||||
* @param string $siret
|
||||
@ -127,9 +94,8 @@ class Metier_Partenaires_MTel
|
||||
if ($last) {
|
||||
if ($source==175 && !@isset($tabLast[$tabTel['typeTel']][1])) {
|
||||
@$tabLast[$tabTel['typeTel']][1]=$tabR;
|
||||
} elseif (($source==118 ||
|
||||
$source==250 ||
|
||||
$source==253) && !@isset($tabLast[$tabTel['typeTel']][2])) {
|
||||
} elseif (($source==118 || $source==250 || $source==253) &&
|
||||
!@isset($tabLast[$tabTel['typeTel']][2])) {
|
||||
@$tabLast[$tabTel['typeTel']][2]=$tabR;
|
||||
} elseif ($source<>2 && !@isset($tabLast[$tabTel['typeTel']][3])) {
|
||||
@$tabLast[$tabTel['typeTel']][3]=$tabR;
|
||||
@ -138,165 +104,6 @@ class Metier_Partenaires_MTel
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($this->accesDistant) {
|
||||
$this->enCache=false;
|
||||
$tabPost = array(
|
||||
'p_ACTION'=>'',
|
||||
'p_ORDRE'=>'AfficheRes',
|
||||
'a_PAGE'=>'1',
|
||||
'a_TAG'=>'',
|
||||
'a_OccRecherche'=>'',
|
||||
'typeRecherche'=>'express',
|
||||
'satellite'=>'siret',
|
||||
'a_activ'=>'',
|
||||
'a_rai_soc'=>'',
|
||||
'a_naf'=>'',
|
||||
'a_siren'=>$siret,
|
||||
'a_tel'=>'',
|
||||
'a_geo'=>'',
|
||||
'typeTri'=>'',
|
||||
'ordreTri'=>'',
|
||||
'a_session'=>'',
|
||||
);
|
||||
//$page=getUrl($this->url,$this->cookie,'',$this->referer, false, '', '', 3);
|
||||
$page=getUrl($this->url, $this->cookie, $tabPost, $this->referer, false, '', '', 3);
|
||||
$this->referer=$this->url;
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
|
||||
$nbResults=0;
|
||||
if (preg_match('/<b class="total_responses_nr">(.*)réponses<\/b>/Uisu', $this->body, $matches)) {
|
||||
$nbResults=trim(strtr(strip_tags($matches[1]), array(' '=>'', '–'=>'')));
|
||||
}
|
||||
|
||||
if ($nbResults>0) {
|
||||
$tabResultsHtml=explode('<div class="results_part1">', $this->body);
|
||||
for ($i=1; isset($tabResultsHtml[$i]);$i++) {
|
||||
$res=$tabTel=array();
|
||||
$body=$tabResultsHtml[$i];
|
||||
$res['nom']=trim(htm2txt(@getTextInHtml($body, '<div class="results_title">', '_title">', '</div>')));
|
||||
$res['adresse']=trim(htm2txt(@getTextInHtml($body, '<div class="coordonnees">', '<div>', '<table id="t_coord_')));
|
||||
|
||||
$res['urlSite']=trim(htm2txt(@getTextInHtml($body, '<b class="siteweb">Site Web :</b> ', "javascript:SiteURL('", "','")));
|
||||
$res['urlMail']=trim(htm2txt(@getTextInHtml($body, '<b>E-mail :</b>', "&mail=", "', ")));
|
||||
$res['urlLogo']=trim(htm2txt(@getTextInHtml($body, '<div class="results_inset_logo">', '" src="', '" border="')));
|
||||
$res['tefet']=trim(htm2txt(@getTextInHtml($body, '<b>Effectif établ : </b>', '</b>', '</div>')));
|
||||
|
||||
$res['tefet']=trim(htm2txt(@getTextInHtml($body, '<b>Effectif établ : </b>', '</b>', '</div>')));
|
||||
$res['siret']=trim(htm2txt(@getTextInHtml($body, '<b>Siret : </b>', '</b>', '</div>')));
|
||||
$res['nafet']=trim(htm2txt(strip_tags(@getTextInHtml($body, '<b>Code NAF : </b>', '</b>', '</div>'))));
|
||||
|
||||
$res['domaines']=trim(preg_replace('/ +/', ' ', preg_replace('/\r+|\n+|\s+/', ' ', htm2txt(strip_tags(@getTextInHtml($body, '<div class="puce_domaine">', '<strong>', '</div>'))))));
|
||||
|
||||
if ($res['urlSite']<>'') {
|
||||
$this->iDb->insert('jo.telephonie', array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>'web',
|
||||
'infoTel'=>$res['urlSite'],
|
||||
'telephone'=>0,
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
));
|
||||
$tabRet[] = array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'typeTel'=>'web',
|
||||
'infoTel'=>$res['urlSite'],
|
||||
'telephone'=>0,
|
||||
);
|
||||
}
|
||||
if ($res['urlLogo']<>'') {
|
||||
$this->iDb->insert('jo.telephonie', array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>'logo',
|
||||
'infoTel'=>$res['urlLogo'],
|
||||
'telephone'=>0,
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
));
|
||||
$tabRet[] = array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'typeTel'=>'logo',
|
||||
'infoTel'=>$res['urlLogo'],
|
||||
'telephone'=>0,
|
||||
);
|
||||
}
|
||||
if ($res['domaines']<>'') {
|
||||
$this->iDb->insert('jo.telephonie', array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>'domaines',
|
||||
'infoTel'=>$res['domaines'],
|
||||
'telephone'=>0,
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
));
|
||||
$tabRet[]=array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'typeTel'=>'domaines',
|
||||
'infoTel'=>$res['domaines'],
|
||||
'telephone'=>0,
|
||||
);
|
||||
}
|
||||
if ($res['urlMail']<>'') {
|
||||
$this->iDb->insert('jo.telephonie', array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>'mail',
|
||||
'infoTel'=>$res['urlMail'],
|
||||
'telephone'=>0,
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
));
|
||||
$tabRet[]=array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'typeTel'=>'mail',
|
||||
'infoTel'=>$res['urlMail'],
|
||||
'telephone'=>0,
|
||||
);
|
||||
}
|
||||
|
||||
if (preg_match_all('/<tr>(?:.*)<th>(?:.*)<span>(.*)(tél|fax)(?:.*)<\/span>(?:.*)<\/th>(?:.*)<td>(?:.*)<span>(.*)<\/span>(?:.*)<\/td>(?:.*)<\/tr>/Uis', $body, $matches)) {
|
||||
foreach ($matches[2] as $j=>$tmp) {
|
||||
$lib=$tmp;
|
||||
$precis=trim(strtr($matches[1][$j], array('-'=>' ')));
|
||||
$num=trim(strtr($matches[3][$j], array(' '=>'', '<br />'=>'')));
|
||||
$tabTel["$lib-$num"]=array('telFax'=>$lib,'type'=>$precis, 'telNum'=>$num);
|
||||
}
|
||||
$tabTel=array_values($tabTel);
|
||||
|
||||
foreach ($tabTel as $tabT) {
|
||||
$tabRet[]=array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'typeTel'=>Metier_Util_String::trimAccent($tabT['telFax']),
|
||||
'infoTel'=>$tabT['type'],
|
||||
'telephone'=>$tabT['telNum'],
|
||||
'actif'=>1,
|
||||
);
|
||||
$this->iDb->insert('jo.telephonie', array(
|
||||
'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'], -5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>Metier_Util_String::trimAccent($tabT['telFax']),
|
||||
'infoTel'=>$tabT['type'],
|
||||
'telephone'=>$tabT['telNum'],
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($last) {
|
||||
|
@ -1,24 +1,66 @@
|
||||
<?php
|
||||
require_once 'framework/common/curl.php';
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
class Metier_Partenaires_MTva
|
||||
{
|
||||
public $vatNumber = ''; // Numéro de TVA retourné
|
||||
public $vatDefined = false; // Le numéro de TVA est il validé ?
|
||||
public $errnum = 0; // Numéro de l'erreur en cas d'erreur
|
||||
public $errmsg = ''; // Message de l'erreur en cas d'erreur
|
||||
public $vatNumber = ''; // Numéro de TVA retourné
|
||||
public $vatDefined = false; // Le numéro de TVA est il validé ?
|
||||
public $errnum = 0; // Numéro de l'erreur en cas d'erreur
|
||||
public $errmsg = ''; // Message de l'erreur en cas d'erreur
|
||||
|
||||
/**
|
||||
* SIREN
|
||||
* @var string
|
||||
*/
|
||||
protected $siren;
|
||||
|
||||
/**
|
||||
* Cle de l'algorithme VAT
|
||||
* @var string
|
||||
*/
|
||||
protected $cle;
|
||||
|
||||
private $siren;
|
||||
protected $iDb;
|
||||
|
||||
/**
|
||||
* Remote Flag
|
||||
* @var boolean
|
||||
*/
|
||||
protected $remote = false;
|
||||
|
||||
public function __construct($siren, $accesDist=true, $db = null)
|
||||
/**
|
||||
*
|
||||
* @param unknown $db
|
||||
* @return boolean
|
||||
*/
|
||||
public function __construct($db = null)
|
||||
{
|
||||
$sirenIn = $siren*1;
|
||||
if ($sirenIn<000001000) {
|
||||
if ($this->siren * 1 < 000001000) {
|
||||
$this->vatNumber = 'FR00000000000';
|
||||
$this->vatDefined = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($db === null) {
|
||||
$this->iDb = new Metier_Util_Db();
|
||||
} else {
|
||||
$this->iDb = $db;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return TVA Struct
|
||||
* @param unknown $db
|
||||
* @return boolean
|
||||
*/
|
||||
public function getTVA()
|
||||
{
|
||||
if ($this->siren * 1 < 000001000) {
|
||||
$this->vatNumber = 'FR00000000000';
|
||||
$this->vatDefined = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -28,131 +70,52 @@ class Metier_Partenaires_MTva
|
||||
$this->iDb = $db;
|
||||
}
|
||||
|
||||
$siren = str_pad($siren, 9, '0', STR_PAD_LEFT);
|
||||
|
||||
$this->siren = $siren;
|
||||
$cleAlgo = $this->genereCleFr();
|
||||
|
||||
if ($cleAlgo<10) {
|
||||
$cleAlgo='0'.$cleAlgo;
|
||||
if ($cleAlgo < 10) {
|
||||
$this->cle = '0'.$cleAlgo;
|
||||
} else {
|
||||
$cleAlgo=''.$cleAlgo;
|
||||
$this->cle = ''.$cleAlgo;
|
||||
}
|
||||
|
||||
$tabRep=array();
|
||||
if (!$this->valideSiren($siren) && substr($siren, 0, 4)<>'0000') {
|
||||
$this->errnum=102;
|
||||
$this->errmsg='Siren invalide';
|
||||
$tabRep = array();
|
||||
if (!$this->valideSiren($this->siren) && substr($this->siren, 0, 4) != '0000') {
|
||||
$this->errnum = 102;
|
||||
$this->errmsg = 'Siren invalide';
|
||||
return false;
|
||||
}
|
||||
|
||||
$info = $this->iDb->select('sdv1.siren_tva', "LPAD(cle,2,0) AS cle, DATE_FORMAT(dateMod,'%Y%m%d') as DateMAJ", "siren=$siren", false, MYSQL_ASSOC);
|
||||
$tab=$info[0];
|
||||
if (count($tab)>0) {
|
||||
if ($tab['cle']<>null || ($tab['cle']==null && $tab['DateMAJ']>=date('Ymd', mktime(0, 0, 0, date('m')-6, date('d'), date('Y'))))) {
|
||||
$cle=$tab['cle'];
|
||||
if ($cle==null) {
|
||||
$attribue=false;
|
||||
$cle=$cleAlgo;
|
||||
} else {
|
||||
$attribue=true;
|
||||
}
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=$attribue;
|
||||
$info = $this->iDb->select('sdv1.siren_tva',
|
||||
"LPAD(cle,2,0) AS cle, DATE_FORMAT(dateMod,'%Y%m%d') as DateMAJ",
|
||||
"siren=".$this->siren, false, MYSQL_ASSOC);
|
||||
if (count($info) > 0) {
|
||||
$tab = $info[0];
|
||||
$cle = $tab['cle'];
|
||||
$dateRef = new DateTime();
|
||||
$dateRef->sub(new DateInterval('P6M'));
|
||||
$dateMaj = DateTime::createFromFormat('Ymd', $tab['DateMAJ']);
|
||||
$this->vatNumber = "FR".$this->cle.$this->siren;
|
||||
if ($cle !== null) {
|
||||
$this->vatDefined = true;
|
||||
return true;
|
||||
} elseif ($cle === null && $dateMaj >= $dateRef) {
|
||||
$this->vatDefined = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$cle=$cleAlgo;
|
||||
$nbIndispo=0;
|
||||
if ($accesDist) {
|
||||
while (true) {
|
||||
$postData=array( //'Lang'=>'FR',
|
||||
'ms'=>'FR',
|
||||
'iso'=>'FR',
|
||||
'vat'=>$cle.$siren,
|
||||
'BtnSubmitVat'=>'Verify');
|
||||
/*$postData=array(
|
||||
* 'Lang'=>'FR',
|
||||
'VAT'=>$cle.$siren,
|
||||
'ISO'=>'FR',
|
||||
'MS'=>'FR'
|
||||
);*/
|
||||
$tdeb = microtime(true);
|
||||
// $url='http://ec.europa.eu/taxation_customs/vies/cgi-bin/viesquer';
|
||||
// $referer='http://ec.europa.eu/taxation_customs/vies/fr/vieshome.htm';
|
||||
$url='http://ec.europa.eu/taxation_customs/vies/viesquer.do';
|
||||
$referer='http://ec.europa.eu/taxation_customs/vies/';
|
||||
|
||||
$page=getUrl($url, '', $postData, $referer, false, 'ec.europa.eu', '', 15);
|
||||
$duree = round(microtime(true)-$tdeb, 3);
|
||||
if ($page['err_num']<>0) {
|
||||
Metier_Util_Log::write('W', 'TVA Erreur CURL n°'. $page['err_num'] .', '. $page['err_msg'] ." sur le Siren $siren, numéro de TVA = FR $cle $siren. Durée = $duree s !", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
return true;
|
||||
}
|
||||
$code=$page['code'];// Code réponse Serveur
|
||||
$body=$page['body'];
|
||||
$header=$page['header'];
|
||||
if (preg_match('/Yes, valid VAT number/i', $body)) {
|
||||
$tabInsert=array('siren'=>$siren,'cle'=>$cle, 'duree'=>$duree);
|
||||
$tabUpdate=array('cle'=>$cle, 'duree'=>$duree);
|
||||
if (!$this->iDb->insert('sdv1.siren_tva', $tabInsert)) {
|
||||
if (!$this->iDb->update('sdv1.siren_tva', $tabUpdate, "siren=$siren")) {
|
||||
Metier_Util_Log::write('W', "Siren $siren, numéro de TVA = FR $cle $siren, impossible de MAJ la clef ($duree s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
}
|
||||
}
|
||||
//echo date ('Y/m/d - H:i:s') ." - Ligne $k/$nbk, N°TVA FR $cle $siren validé .".$eol;
|
||||
Metier_Util_Log::write('I', "Siren $siren, numéro de TVA = FR $cle $siren ($duree s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=true;
|
||||
return true;
|
||||
//return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>array('siren'=>$siren, 'vatNumber'=>"FR$cle$siren", 'vatDefined'=>true));
|
||||
} elseif (strpos($body, 'Service non disponible')>0 || strpos($body, 'ponse trop long.')>0) {
|
||||
$nbIndispo++;
|
||||
if ($nbIndispo<3) {
|
||||
//echo date ('Y/m/d - H:i:s') .' - '.$eol;
|
||||
Metier_Util_Log::write('I', "TVA Siren $siren, Service de l'état membre indisponible. Mise en sommeil...", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
sleep(rand(1, 2));
|
||||
$nbIndispo=0;
|
||||
//echo date ('Y/m/d - H:i:s') .' - Reprise du Siren = '. $siren . $eol;
|
||||
} else {
|
||||
$tabInsert=array('siren'=>$siren,'cle'=>'NULL', 'duree'=>$duree);
|
||||
$tabUpdate=array('cle'=>'NULL', 'duree'=>$duree);
|
||||
if (!$this->iDb->insert('sdv1.siren_tva', $tabInsert)) {
|
||||
if (!$this->iDb->update('sdv1.siren_tva', $tabUpdate, "siren=$siren")) {
|
||||
Metier_Util_Log::write('W', "Siren $siren, numéro de TVA = FR $cle $siren, impossible de MAJ la clef ($duree s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
}
|
||||
}
|
||||
Metier_Util_Log::write('I', "Siren $siren, numéro de TVA = FR $cle $siren vérification non disponible ($duree s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
return true;
|
||||
}
|
||||
//echo date ('Y/m/d - H:i:s') .' - Temporisation n°'.$nbIndispo . $eol;
|
||||
} else {
|
||||
$tabInsert=array('siren'=>$siren,'cle'=>'NULL', 'duree'=>$duree);
|
||||
$tabUpdate=array('cle'=>'NULL', 'duree'=>$duree);
|
||||
if (!$this->iDb->insert('sdv1.siren_tva', $tabInsert)) {
|
||||
if (!$this->iDb->update('sdv1.siren_tva', $tabUpdate, "siren=$siren")) {
|
||||
Metier_Util_Log::write('W', "Siren $siren, numéro de TVA = FR $cle $siren, impossible de MAJ la clef ($duree s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
}
|
||||
}
|
||||
Metier_Util_Log::write('I', "Siren $siren, numéro de TVA = FR $cle $siren non attribué ($duree s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ($this->remote) {
|
||||
return $this->getRemoteVAT();
|
||||
} else {
|
||||
$this->errnum=999;
|
||||
$this->errmsg="Pas d'accès à la base TVA";
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
$this->vatNumber = "FR".$this->cle.$this->siren;
|
||||
$this->vatDefined = false;
|
||||
$this->errnum = 999;
|
||||
$this->errmsg = "Pas d'accès à la base TVA";
|
||||
return true;
|
||||
}
|
||||
|
||||
Metier_Util_Log::write('W', "Erreur impossible (car l'algo ne devrait pas passer par ici) sur le Siren $siren, numéro de TVA = FR $cle $siren. Durée = $duree s. Cas impossible !", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
return true;//array('error'=>array('errnum'=>800, 'errmsg'=>'Erreur SGBDR'), 'result'=>$tabRet);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,6 +126,91 @@ class Metier_Partenaires_MTva
|
||||
$this->remote = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Id Company
|
||||
* @param string $siren
|
||||
*/
|
||||
public function setCompanyId($siren)
|
||||
{
|
||||
$this->siren = str_pad($siren, 9, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Data form website
|
||||
* @return boolean
|
||||
*/
|
||||
protected function getRemoteVAT()
|
||||
{
|
||||
$url = 'http://ec.europa.eu/taxation_customs/vies/vatResponse.html';
|
||||
|
||||
$client = new Client();
|
||||
try {
|
||||
$timeStart = microtime(true);
|
||||
$response = $client->request('POST', $url, [
|
||||
'form_params' => [
|
||||
'memberStateCode' => "FR",
|
||||
'number' => $this->cle.$this->siren,
|
||||
'traderName' => "",
|
||||
'traderStreet' => "",
|
||||
'traderPostalCode' => "",
|
||||
'traderCity' => "",
|
||||
'requesterMemberStateCode' => "",
|
||||
'requesterNumber' => "",
|
||||
'action' => "check",
|
||||
'check' => "Vérifier",
|
||||
],
|
||||
]);
|
||||
$timeStop = microtime(true);
|
||||
$time = $timeStop - $timeStart;
|
||||
|
||||
if ($response->getStatusCode() == 200) {
|
||||
$body = $response->getBody();
|
||||
if (preg_match('/Yes, valid VAT number/i', $body)
|
||||
|| preg_match('/Oui, numéro de TVA valide/i', $body)) {
|
||||
$tabInsert = array(
|
||||
'siren' => $this->siren,
|
||||
'cle' => $this->cle,
|
||||
'duree' => $time
|
||||
);
|
||||
if (!$this->iDb->insert('sdv1.siren_tva', $tabInsert)) {
|
||||
$tabUpdate = array(
|
||||
'cle' => $this->cle,
|
||||
'duree' => $time
|
||||
);
|
||||
if (!$this->iDb->update('sdv1.siren_tva', $tabUpdate, "siren=$this->siren")) {
|
||||
Metier_Util_Log::write('W', "Siren $this->siren, numéro de TVA = FR $this->cle $this->siren, impossible de MAJ la clef ($time s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
}
|
||||
}
|
||||
Metier_Util_Log::write('I', "Siren $this->siren, numéro de TVA = FR $this->cle $siren ($time s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber = "FR".$this->cle.$this->siren;
|
||||
$this->vatDefined = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (RequestException $e) {
|
||||
Metier_Util_Log::write('I', "TVA ".$e->getMessage(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
}
|
||||
|
||||
$tabInsert = array(
|
||||
'siren' => $this->siren,
|
||||
'cle' => 'NULL',
|
||||
'duree' => $time
|
||||
);
|
||||
$tabUpdate = array(
|
||||
'cle' => 'NULL',
|
||||
'duree' => $time
|
||||
);
|
||||
if (!$this->iDb->insert('sdv1.siren_tva', $tabInsert)) {
|
||||
if (!$this->iDb->update('sdv1.siren_tva', $tabUpdate, "siren=$this->siren")) {
|
||||
Metier_Util_Log::write('W', "Siren $this->siren, numéro de TVA = FR $this->cle $this->siren, impossible de MAJ la clef ($time s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
}
|
||||
}
|
||||
Metier_Util_Log::write('I', "Siren $this->siren, numéro de TVA = FR $this->cle $this->siren vérification non disponible ($time s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber = "FR".$this->cle.$this->siren;
|
||||
$this->vatDefined = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Génère la clé du numéro de TVA pour le siren fournit
|
||||
* (la validité du numéro de siren et son existance n'est pas effectué par cette méthode)
|
||||
|
@ -2203,24 +2203,22 @@ class Metier_Scores_ICotation
|
||||
$this->reTrtAuto = $retraitementAutomatique;
|
||||
$this->tabBilan = $tabBilan;
|
||||
|
||||
/** Situat° Remarque Notation Equiv. Grades Probabilité de
|
||||
** financière BDF Moody's Grades S&P défaillance
|
||||
**/
|
||||
$this->tabNotation['A+']=array('Excellente', 'Exceptionnelle', 'A3++', 'Aaa', 'AAA' ,'0.001');
|
||||
$this->tabNotation['A'] =array('Excellente', 'Excellente', 'A3+', 'Aa1 Aa2 Aa3', 'AA+ AA AA-','0.01');
|
||||
$this->tabNotation['B+']=array('Excellente', 'Très bonne', '3++', 'A1', 'A+' ,'0.02');
|
||||
$this->tabNotation['B'] =array('Bonne', 'Bonne', '3+', 'A2 A3', 'A A-' ,'0.04');
|
||||
$this->tabNotation['C+']=array('Bonne', 'Relativement correcte', '3', 'Baa1', 'BBB+' ,'0.15');
|
||||
$this->tabNotation['C'] =array('Bonne', 'Correcte', '3', 'Baa2', 'BBB' ,'0.30');
|
||||
$this->tabNotation['C-']=array('Bonne', 'Moyenne', '3', 'Baa3', 'BBB-' ,'0.60');
|
||||
$this->tabNotation['D+']=array('Moyenne', 'Passable', '4+', 'Ba1', 'BB+' ,'0.90');
|
||||
$this->tabNotation['D'] =array('Moyenne', 'Médiocre', '4', 'Ba2', 'BB' ,'1.25');
|
||||
$this->tabNotation['D-']=array('Moyenne', 'Très médiocre', '4', 'Ba3', 'BB-' ,'1.60');
|
||||
$this->tabNotation['E+']=array('Mauvaise', 'Assez mauvaise', '5', 'B1 B2 B3', 'B+ B B-', '5.00');
|
||||
$this->tabNotation['E'] =array('Mauvaise', 'Mauvaise', '6', 'Caa', 'CCC', '14.00');
|
||||
$this->tabNotation['E-']=array('Mauvaise', 'Très mauvais', '8', 'Ca C', 'CC C', '17.00');
|
||||
$this->tabNotation['F'] =array('Mauvaise', 'Signe de défaut', '8 9', 'D', 'D', 'En défaut');
|
||||
$this->tabNotation['Z'] =array('Mauvaise', 'Signe de défaut', 'P', '', '', 'En défaut');
|
||||
/* Situation Fiancière Remarque Notation BDF Equiv. Moody's Grades S&P Probabilité dedéfaillance */
|
||||
$this->tabNotation['A+']=array('Excellente', 'Exceptionnelle', 'A3++', 'Aaa', 'AAA', '0.001');
|
||||
$this->tabNotation['A'] =array('Excellente', 'Excellente', 'A3+', 'Aa1 Aa2 Aa3', 'AA+ AA AA-', '0.01');
|
||||
$this->tabNotation['B+']=array('Excellente', 'Très bonne', '3++', 'A1', 'A+', '0.02');
|
||||
$this->tabNotation['B'] =array('Bonne', 'Bonne', '3+', 'A2 A3', 'A A-', '0.04');
|
||||
$this->tabNotation['C+']=array('Bonne', 'Relativement correcte', '3', 'Baa1', 'BBB+', '0.15');
|
||||
$this->tabNotation['C'] =array('Bonne', 'Correcte', '3', 'Baa2', 'BBB', '0.30');
|
||||
$this->tabNotation['C-']=array('Bonne', 'Moyenne', '3', 'Baa3', 'BBB-', '0.60');
|
||||
$this->tabNotation['D+']=array('Moyenne', 'Passable', '4+', 'Ba1', 'BB+', '0.90');
|
||||
$this->tabNotation['D'] =array('Moyenne', 'Médiocre', '4', 'Ba2', 'BB', '1.25');
|
||||
$this->tabNotation['D-']=array('Moyenne', 'Très médiocre', '4', 'Ba3', 'BB-', '1.60');
|
||||
$this->tabNotation['E+']=array('Mauvaise', 'Assez mauvaise', '5', 'B1 B2 B3', 'B+ B B-', '5.00');
|
||||
$this->tabNotation['E'] =array('Mauvaise', 'Mauvaise', '6', 'Caa', 'CCC', '14.00');
|
||||
$this->tabNotation['E-']=array('Mauvaise', 'Très mauvais', '8', 'Ca C', 'CC C', '17.00');
|
||||
$this->tabNotation['F'] =array('Mauvaise', 'Signe de défaut', '8 9', 'D', 'D', 'En défaut');
|
||||
$this->tabNotation['Z'] =array('Mauvaise', 'Signe de défaut', 'P', '', '', 'En défaut');
|
||||
|
||||
$this->tabLibActivite[0]='';
|
||||
$this->tabLibActivite[15]='Industries Alimentaires : Collecte Appro';
|
||||
|
@ -998,10 +998,10 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
} else {
|
||||
$SAISONAT='P';
|
||||
}
|
||||
$CAPITAL=$tabIdentite['Capital'];
|
||||
$CAPITAL = $tabIdentite['Capital'];
|
||||
$CAPITAL_NBACTION = $tabIdentite['CapitalNbActions'];
|
||||
$CAPITAL_MTACTION = $tabIdentite['CapitalMtActions'];
|
||||
if ($CAPITAL>0) {
|
||||
if ($CAPITAL > 0) {
|
||||
switch ($tabIdentite['CapitalType']) {
|
||||
case 'V': $CAPITAL_TYPE = 'variable'; break;
|
||||
case 'S': $CAPITAL_TYPE = 'fixe'; break;
|
||||
@ -1049,7 +1049,8 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
|
||||
// --- Liste des bilans
|
||||
$tabBilan = $tabBil = $tabRegX = array();
|
||||
$mBil = new Metier_Partenaires_MBilans($siren, $iDb);
|
||||
$mBil = new Metier_Partenaires_MBilans();
|
||||
$mBil->setSiren($siren);
|
||||
$tabBilans = $mBil->listeBilans($accesDist);
|
||||
$NBBILAN = count($tabBilans);
|
||||
if ($NBBILAN > 0) {
|
||||
@ -2207,7 +2208,8 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
$TYPEMERE='PM';
|
||||
}
|
||||
}
|
||||
$mBilA = new Metier_Partenaires_MBilans($lien->siren, $iDb);
|
||||
$mBilA = new Metier_Partenaires_MBilans();
|
||||
$mBilA->setSiren($lien->siren);
|
||||
$tabBilansA = $mBilA->listeBilans(false, 2);
|
||||
$nbBilansA = count($tabBilansA);
|
||||
if ($nbBilansA > 0) {
|
||||
|
File diff suppressed because it is too large
Load Diff
96
library/Scores/Exec/Ref.php
Normal file
96
library/Scores/Exec/Ref.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
class Scores_Exec_Ref
|
||||
{
|
||||
protected $code;
|
||||
|
||||
/**
|
||||
* Enregistrement de l'execution d'un programme par son code
|
||||
* @param string $code
|
||||
*/
|
||||
public function __construct($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marqueur de démarrage
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
$data = array(
|
||||
'code' => $this->code,
|
||||
'dateStart' => date('YmdHis'),
|
||||
);
|
||||
|
||||
$model = new Application_Model_ExecutionProcessOut();
|
||||
try {
|
||||
$id = $model->insert($data);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marqueur du nombre d'éléments à traiter
|
||||
* @param int $id
|
||||
* @param int $num
|
||||
*/
|
||||
public function total($id, $num)
|
||||
{
|
||||
$data = array('unitTotal' => $num);
|
||||
$model = new Application_Model_ExecutionProcessOut();
|
||||
try {
|
||||
$result = $model->update($data, 'id='.$id);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marqueur increment
|
||||
* @param int $id
|
||||
* @param int $num
|
||||
* @return boolean|int
|
||||
*/
|
||||
public function increment($id, $num)
|
||||
{
|
||||
$data = array(
|
||||
'unitExec' => $num,
|
||||
'updated' => date('YmdHis'),
|
||||
);
|
||||
|
||||
$model = new Application_Model_ExecutionProcessOut();
|
||||
try {
|
||||
$result = $model->update($data, 'id='.$id);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marqueur de fin
|
||||
* @param int $id
|
||||
* @return boolean|int
|
||||
*/
|
||||
public function end($id)
|
||||
{
|
||||
$data = array(
|
||||
'dateEnd' => date('YmdHis'),
|
||||
);
|
||||
|
||||
$model = new Application_Model_ExecutionProcessOut();
|
||||
try {
|
||||
$result = $model->update($data, 'id='.$id);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
@ -213,8 +213,8 @@ class Scores_Ws_Server
|
||||
public $listError = array(
|
||||
'0000' => "Erreur indeterminé",
|
||||
'0900' => "Identifiant ou mot de passe incorrect",
|
||||
'0901' => "Accès WS non authorisé pour cet utilisateur",
|
||||
'0902' => "Méthode non authorisée dans votre profil",
|
||||
'0901' => "Accès WS non autorisé pour cet utilisateur",
|
||||
'0902' => "Méthode non autorisée dans votre profil",
|
||||
'0903' => "Période d'accès au service invalide",
|
||||
'0904' => "Adresse IP Invalide",
|
||||
'0905' => "Accès environnement de test non autorisé",
|
||||
|
@ -877,7 +877,10 @@ function nicSiegeData($siren, $nic, $values = false)
|
||||
|
||||
function tvaData($siren, $nic, $values = false)
|
||||
{
|
||||
$iTva = new Metier_Partenaires_MTva($siren, false);
|
||||
global $iDb;
|
||||
$iTva = new Metier_Partenaires_MTva($iDb);
|
||||
$iTva->setCompanyId($siren);
|
||||
$iTva->getTVA();
|
||||
$tabData['tva'] = isset($iTva->vatNumber) ? $iTva->vatNumber : '';
|
||||
return $tabData;
|
||||
}
|
||||
@ -1038,11 +1041,11 @@ function bilanNEntete($values)
|
||||
}
|
||||
function bilanNData($siren, $nic, $values = false)
|
||||
{
|
||||
global $iDb;
|
||||
$tabPostes = explode(',', $values);
|
||||
$annee = 0;
|
||||
$tabData = array();
|
||||
$mBil = new Metier_Partenaires_MBilans($siren, $iDb);
|
||||
$mBil = new Metier_Partenaires_MBilans();
|
||||
$mBil->setSiren($siren);
|
||||
/*
|
||||
* @todo : Pouvoir appeler la liste des bilans en fonction du TYPE, sans les chiffres
|
||||
* jo.bilans => Liste mais postes dans chaine de caractère
|
||||
@ -1082,11 +1085,11 @@ function bilanN1Entete($values)
|
||||
}
|
||||
function bilanN1Data($siren, $nic, $values = false)
|
||||
{
|
||||
global $iDb;
|
||||
$tabPostes = explode(',', $values);
|
||||
$annee = 1;
|
||||
$tabData = array();
|
||||
$mBil = new Metier_Partenaires_MBilans($siren, $iDb);
|
||||
$mBil = new Metier_Partenaires_MBilans();
|
||||
$mBil->setSiren($siren);
|
||||
$tabBilans = $mBil->listeBilans(false, 9);
|
||||
if (count($tabBilans)>0) {
|
||||
$tabBi = findBilan($siren, $tabBilans, $annee);
|
||||
@ -1125,7 +1128,8 @@ function bilanN2Data($siren, $nic, $values = false)
|
||||
$tabPostes = explode(',', $values);
|
||||
$annee = 2;
|
||||
$tabData = array();
|
||||
$mBil = new Metier_Partenaires_MBilans($siren, $iDb);
|
||||
$mBil = new Metier_Partenaires_MBilans();
|
||||
$mBil->setSiren($siren);
|
||||
$tabBilans = $mBil->listeBilans(false, 9);
|
||||
if (count($tabBilans)>0) {
|
||||
$tabBi = findBilan($siren, $tabBilans, $annee);
|
||||
@ -1144,8 +1148,8 @@ function bilanN2Data($siren, $nic, $values = false)
|
||||
|
||||
function findBilan($siren, $tabBilans, $position = 0)
|
||||
{
|
||||
global $iDb;
|
||||
$mBil = new Metier_Partenaires_MBilans($siren, $iDb);
|
||||
$mBil = new Metier_Partenaires_MBilans();
|
||||
$mBil->setSiren($siren);
|
||||
//Trier et Supprimer les bilans consolidés
|
||||
$tabBilN = $tabBilS = array();
|
||||
foreach ($tabBilans as $typeMil => $bilan) {
|
||||
@ -1557,7 +1561,7 @@ function TelOrderEntete()
|
||||
function TelOrderData($siren, $nic, $values)
|
||||
{
|
||||
global $iDb;
|
||||
$c = new Metier_Partenaires_MTel(false, $iDb);
|
||||
$c = new Metier_Partenaires_MTel($iDb);
|
||||
$result = $c->getTel($siren, $nic, true, 1);
|
||||
$tabData = array();
|
||||
if ( count($result)>0 ) {
|
||||
|
Loading…
Reference in New Issue
Block a user