Library Update

This commit is contained in:
Michael RICOIS 2017-01-12 10:33:39 +01:00
parent 10981d1038
commit ab99a00daf
3 changed files with 136 additions and 105 deletions

View File

@ -1820,7 +1820,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
// Si aucun résultat et siren est valide, on part chez Infogreffe
if ($accesDist && $nbEtab == 0 && $this->valideSiren($siren)) {
$iGeffes = new Metier_Partenaires_MGreffes($this->iDb);
$iGeffes = new Metier_Partenaires_MGreffes();
$etabG = $iGeffes->getIdentite($siren);
if ($etabG) {
$adr = $this->structureVoie($etabG['Adresse']);
@ -3332,7 +3332,7 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
$tdeb = microtime(1);
}
$iGeffes = new Metier_Partenaires_MGreffes($this->iDb);
$iGeffes = new Metier_Partenaires_MGreffes();
$etabG = $iGeffes->getIdentite($siren);
$iRncs = new Metier_Partenaires_MRncs($this->iDb);

View File

@ -9,13 +9,22 @@ class Metier_Partenaires_MArtisanat
public $referer='';
public $libErreur='';
public $cookie='';
public $iDb;
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Flag to get remote data
* @var string
*/
protected $remote = false;
public function __construct()
{
$this->iDb = new Metier_Util_Db();
$this->conn = Zend_Registry::get('doctrine');
}
/**
@ -26,22 +35,43 @@ class Metier_Partenaires_MArtisanat
$this->remote = true;
}
/**
* Informations artisan
* @param string $siren
* @return array
*/
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 ($this->remote) {
$data = $this->getRemoteIdentite();
} else {
if (count($res) > 0) {
$data = $res[0];
try {
$stmt = $this->conn->prepare("SELECT 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 FROM jo.artisanat
WHERE siren=:siren");
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$data = $stmt->fetch(\PDO::FETCH_ASSOC);
}
} catch (\Doctrine\DBAL\DBALException $e) {
}
}
return $data;
}
/**
* Download data from external website
* @return array
*/
public function getRemoteIdentite()
{
$url = 'http://www.cma-paris.fr/CMP/rm_recherche.php?dom=Gerer&fonction=recherche';
@ -295,12 +325,15 @@ class Metier_Partenaires_MArtisanat
}
// Insertion en base de données
$tabInsert['dateInsert'] = date('Y-m-d H:i:s');
$id = $this->iDb->insert('jo.artisanat', $tabInsert, true);
$tabInsert['id'] = $id;
foreach ($tabEtabs as $tabInsert2) {
$tabInsert2['dateInsert'] = $tabInsert['dateInsert'];
$id2 = $this->iDb->insert('jo.artisanat_etab', $tabInsert2, true);
try {
$tabInsert = array('dateInsert' => date('Y-m-d H:i:s'));
$this->conn->insert('jo.artisanat', $tabInsert);
$tabInsert['id'] = $this->conn->lastInsertId();
foreach ($tabEtabs as $etab) {
$etab['dateInsert'] = $tabInsert['dateInsert'];
$this->conn->insert('jo.artisanat_etab', $etab);
}
} catch (\Doctrine\DBAL\DBALException $e) {
}
$tabInsert['dateUpdate'] = substr($tabInsert['dateInsert'], 0, 10);

View File

@ -1,15 +1,18 @@
<?php
class Metier_Partenaires_MGreffes
{
public $iDb;
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
public function __construct($db = null)
/**
* Greffes
*/
public function __construct()
{
if ($db === null) {
$this->iDb = new Metier_Util_Db();
} else {
$this->iDb = $db;
}
$this->conn = Zend_Registry::get('doctrine');
}
/**
@ -18,71 +21,55 @@ class Metier_Partenaires_MGreffes
*/
public function getIdentite($siren)
{
$id = false;
$sql = "SELECT id, siren, nom, nomCommercial, adresse, adresse2, cp, ville, enseigne, siege,
fj, fjLib, naf, nafLib, numRC, numRC2, typeRCS, numGreffe, libGreffe, dateCreation,
dateRadiation, dateCloture, ca, res, eff, dateInsert
FROM jo.greffes_identite WHERE siren=:siren";
$res = $this->iDb->select('jo.greffes_identite',
'id, siren, nom, nomCommercial, adresse, adresse2, cp, ville, enseigne, siege, fj, fjLib, naf, nafLib, numRC, numRC2, typeRCS, numGreffe, libGreffe, dateCreation, dateRadiation, dateCloture, ca, res, eff, dateInsert',
"siren=$siren");
if (count($res) > 0) {
$ent=$res[0];
$id=$ent['id'];
$siren=$ent['siren'];
$siege=$ent['siege'];
$nom=$ent['nom'];
$nomCom=$ent['nomCommercial'];
$ens=$ent['ens'];
$adr=$ent['adresse'];
$adr2=$ent['adresse2'];
$cp=$ent['cp'];
$ville=$ent['ville'];
$cj=$ent['fj'];
$cjLib=$ent['fjLib'];
$naf=$ent['naf'];
$nafLib=$ent['nafLib'];
$numRC=$ent['numRC'];
$numRC2=$ent['numRC2'];
$greffe_num=$ent['numGreffe'];
$typeRCS=$ent['typeRCS'];
$dateCre=$ent['dateCreation'];
$dateRad=$ent['dateRadiation'];
$dateCloture=$ent['dateCloture'];
$dateInsert=$ent['dateInsert'];
}
if ($id) {
$tabRet = array(
'id' => $id,// A calculer après insert
'Pertinence' => 100,
'Siret' => $siren.'00000',
'Siege' => $siege,
'Nom' => $nom,
'Nom2' => $nomCom,
'Sigle' => '',
'Enseigne' => $ens,
'Adresse' => $adr,
'Adresse2' => $adr2,
'CP' => $cp,
'Ville' => $ville,
'Tel' => '',
'Fax' => '',
'FJ' => $cj,
'FJLib' => $cjLib,
'Siren' => $siren,
'Nic' => '00000',
'Actif' => 0,
'NafEtab' => $naf,
'NafEtabLib' => $nafLib,
'NafEnt' => $naf,
'NafEntLib' => $nafLib,
'NumRC' => $numRC,
'NumRC2' => $numRC2,
'NumGreffe' => $greffe_num,
'DateCreation' => $dateCre,
'DateRadiation' => $dateRad,
'DateCloture' => $dateCloture,
'DateUpdate' => substr($dateInsert, 0, 10),
);
return $tabRet;
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$result = $stmt->fetch(PDO::FETCH_ASSOC);
return array(
'id' => $result['id'],
'Pertinence' => 100,
'Siret' => $result['siren'].'00000',
'Siege' => $result['siege'],
'Nom' => $result['nom'],
'Nom2' => $result['nomCommercial'],
'Sigle' => '',
'Enseigne' => $result['ens'],
'Adresse' => $result['adresse'],
'Adresse2' => $result['adresse2'],
'CP' => $result['cp'],
'Ville' => $result['ville'],
'Tel' => '',
'Fax' => '',
'FJ' => $result['fj'],
'FJLib' => $result['fjLib'],
'Siren' => $result['siren'],
'Nic' => '00000',
'Actif' => 0,
'NafEtab' => $result['naf'],
'NafEtabLib' => $result['nafLib'],
'NafEnt' => $result['naf'],
'NafEntLib' => $result['nafLib'],
'NumRC' => $result['numRC'],
'NumRC2' => $result['numRC2'],
'NumGreffe' => $result['numGreffe'],
'DateCreation' => $result['dateCreation'],
'DateRadiation' => $result['dateRadiation'],
'DateCloture' => $result['dateCloture'],
'DateUpdate' => substr($result['dateInsert'], 0, 10),
);
}
} catch(\Doctrine\DBAL\DBALException $e) {
}
return false;
@ -94,29 +81,40 @@ class Metier_Partenaires_MGreffes
*/
public function getInfosCessions($siren)
{
$ret=$this->iDb->select('jo.greffes_cessions', 'id, siren, nom, libGreffe, inscrit, etat, dateImmat, dateJuge, dateConv, dateLJS, dateInventaire, dateBodacc, caDeclare, effectif, descriptif, pdfLink, pdfSize, pdfVer, pdfPage, descDateDepot, dateLimite, mandataire, dateInsert', "siren=$siren", false, MYSQL_ASSOC);
if (count($ret)>0) {
$tabCes=$ret[0];
if (count($ret)>1) {
$mail = new Metier_Common_Mail();
$mail->send('debug@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMGreffes.php : Debug getInfosCessions $siren", "Plus de 1 cession pour ce siren");
$sql = "SELECT id, siren, nom, libGreffe, inscrit, etat, dateImmat, dateJuge, dateConv,
dateLJS, dateInventaire, dateBodacc, caDeclare, effectif, descriptif, pdfLink, pdfSize,
pdfVer, pdfPage, descDateDepot, dateLimite, mandataire, dateInsert
FROM jo.greffes_cessions WHERE siren=:siren";
try {
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
if ($stmt->rowCount() > 1) {
$mail = new Metier_Common_Mail();
$mail->send('debug@scores-decisions.com', 'ylenaour@scores-decisions.com',
"classMGreffes.php : Debug getInfosCessions $siren", "Plus de 1 cession pour ce siren");
}
$result = $stmt->fetch(\PDO::FETCH_ASSOC);
return array(
'cessJuge' => $result['etat'],
'cessDateJuge' => $result['dateJuge'],
'cessDateConv' => $result['dateConv'],
'cessDateLJS' => $result['dateLJS'],
'cessDateInv' => $result['dateInventaire'],
'cessDateBod' => $result['dateBodacc'],
'cessCAdec' => $result['caDeclare'],
'cessEffectif' => $result['effectif'],
'cessDesc' => $result['descriptif'],
'cessDateDesc' => $result['descDateDepot'],
'cessDateLim' => $result['dateLimite'],
'cessMand' => $result['mandataire'],
);
}
return array(
'cessJuge'=> $tabCes['etat'],
'cessDateJuge'=>$tabCes['dateJuge'],
'cessDateConv'=>$tabCes['dateConv'],
'cessDateLJS'=> $tabCes['dateLJS'],
'cessDateInv'=> $tabCes['dateInventaire'],
'cessDateBod'=> $tabCes['dateBodacc'],
'cessCAdec'=> $tabCes['caDeclare'],
'cessEffectif'=>$tabCes['effectif'],
'cessDesc'=> $tabCes['descriptif'],
'cessDateDesc'=>$tabCes['descDateDepot'],
'cessDateLim'=> $tabCes['dateLimite'],
'cessMand'=> $tabCes['mandataire'],
);
} else {
return false;
} catch(\Doctrine\DBAL\DBALException $e) {
}
return false;
}
}