MGreffes avec doctrine

This commit is contained in:
Michael RICOIS 2017-01-11 15:57:27 +01:00
parent 25db7c39a3
commit 304ee7214f
2 changed files with 92 additions and 94 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

@ -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;
}
}