MRncs : getEvenements, getListeJugements

This commit is contained in:
Michael RICOIS 2017-01-12 12:12:44 +01:00
parent 338399980a
commit 334d5230b1

View File

@ -533,54 +533,68 @@ class Metier_Partenaires_MRncs
}
/**
*
* @param unknown $siren
* @return multitype:multitype:NULL unknown Ambigous <multitype:>
* Liste des jugements
* @param string $siren
* @return array
*/
public function getListeJugements($siren)
{
$siren = $siren*1;
$rep=$this->iDb->select(
'jo.rncs_jugements j, jo.tabJugeRncs l, jo.tabEvenements e',
'siren, j.dateEffet, j.codeJugement, j.flux, l.libJugement, e.codEven, e.libEven,
adm1id, adm1codeFct, adm1type, adm1nom, adm1adrNum, adm1adrInd, adm1adrType, adm1adrLibVoie, adm1adrVoie, adm1adr1, adm1adr2, adm1adr3, adm1adrCP, adm1adrVille,
adm2id, adm2codeFct, adm2type, adm2nom, adm2adrNum, adm2adrInd, adm2adrType, adm2adrLibVoie, adm2adrVoie, adm2adr1, adm2adr2, adm2adr3, adm2adrCP, adm2adrVille',
"j.siren=$siren AND j.codeJugement=l.codJugement AND l.codEven=e.codEven ORDER BY j.dateEffet DESC", false, MYSQL_ASSOC);
$tabDepots = array();
foreach ($rep as $iDepot=>$depot) {
$sql = "SELECT siren, j.dateEffet, j.codeJugement, j.flux, l.libJugement, e.codEven, e.libEven,
adm1id, adm1codeFct, adm1type, adm1nom, adm1adrNum, adm1adrInd, adm1adrType, adm1adrLibVoie, adm1adrVoie, adm1adr1, adm1adr2, adm1adr3, adm1adrCP, adm1adrVille,
adm2id, adm2codeFct, adm2type, adm2nom, adm2adrNum, adm2adrInd, adm2adrType, adm2adrLibVoie, adm2adrVoie, adm2adr1, adm2adr2, adm2adr3, adm2adrCP, adm2adrVille
FROM jo.rncs_jugements j, jo.tabJugeRncs l, jo.tabEvenements e
WHERE j.siren=:siren AND j.codeJugement=l.codJugement AND l.codEven=e.codEven ORDER BY j.dateEffet DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$tabDepots[] = array(
'codEven' => $depot['codEven'],
'libEven' => $depot['libEven'],
'dateEffet' => $depot['dateEffet'],
'adm1id' => $depot['adm1id'],
'adm1code' => $depot['adm1codeFct'],
'adm1type' => $depot['adm1type'],
'adm1fonction' => @$this->getLibFctDir($depot['adm1codeFct']),
'adm1nom' => $depot['adm1nom'],
'adm1adrNum' => $depot['adm1adrNum'],
'adm1adrInd' => $depot['adm1adrInd'],
'adm1adrType' => $depot['adm1adrType'],
'adm1adrVoie' => $depot['adm1adrLibVoie'], // @todo : adm1adr1, , adm1adr3,
'adm1adr2' => $depot['adm1adr2'],
'adm1adrCP' => $depot['adm1adrCP'],
'adm1adrVille' => $depot['adm1adrVille'],
'adm2id' => $depot['adm2id'],
'adm2code' => $depot['adm2codeFct'],
'adm2type' => $depot['adm2type'],
'adm2fonction' => @$this->getLibFctDir($depot['adm2codeFct']),
'adm2nom' => $depot['adm2nom'],
'adm2adrNum' => $depot['adm2adrNum'],
'adm2adrInd' => $depot['adm2adrInd'],
'adm2adrType' => $depot['adm2adrType'],
'adm2adrVoie' => $depot['adm2adrLibVoie'], // @todo : adm1adr1, adm1adr2, adm1adr3,
'adm2adr2' => $depot['adm2adr2'],
'adm2adrCP' => $depot['adm2adrCP'],
'adm2adrVille' => $depot['adm2adrVille'],
'codEven' => $result['codEven'],
'libEven' => $result['libEven'],
'dateEffet' => $result['dateEffet'],
'adm1id' => $result['adm1id'],
'adm1code' => $result['adm1codeFct'],
'adm1type' => $result['adm1type'],
'adm1fonction' => @$this->getLibFctDir($result['adm1codeFct']),
'adm1nom' => $result['adm1nom'],
'adm1adrNum' => $result['adm1adrNum'],
'adm1adrInd' => $result['adm1adrInd'],
'adm1adrType' => $result['adm1adrType'],
'adm1adrVoie' => $result['adm1adrLibVoie'], // @todo : adm1adr1, , adm1adr3,
'adm1adr2' => $result['adm1adr2'],
'adm1adrCP' => $result['adm1adrCP'],
'adm1adrVille' => $result['adm1adrVille'],
'adm2id' => $result['adm2id'],
'adm2code' => $result['adm2codeFct'],
'adm2type' => $result['adm2type'],
'adm2fonction' => @$this->getLibFctDir($result['adm2codeFct']),
'adm2nom' => $result['adm2nom'],
'adm2adrNum' => $result['adm2adrNum'],
'adm2adrInd' => $result['adm2adrInd'],
'adm2adrType' => $result['adm2adrType'],
'adm2adrVoie' => $result['adm2adrLibVoie'], // @todo : adm1adr1, adm1adr2, adm1adr3,
'adm2adr2' => $result['adm2adr2'],
'adm2adrCP' => $result['adm2adrCP'],
'adm2adrVille' => $result['adm2adrVille'],
);
}
}
return $tabDepots;
}
/**
* Evenements
* @param string $siren
* @param number $nic
* @param string $type
* @param string $dateDeb
* @param string $dateFin
* @return array
*/
public function getEvenements($siren, $nic=0, $type='', $dateDeb='', $dateFin='')
{
$tabEven = array(
@ -595,44 +609,67 @@ class Metier_Partenaires_MRncs
'pNRC' => 'Modification du numéro du RC',
'pNOM' => 'Modification de la dénomination',
);
$tabRet = array();
$siren = $siren*1;
if ($nic > 0) {
$strNic = " AND nic=$nic";
}
if ($type<>'') {
if ($type != '') {
$strType = " AND champs='$type'";
}
if ($dateDeb<>'') {
if ($dateDeb != '') {
$strDateDeb = " AND flux>='$dateDeb'";
}
if ($dateFin<>'') {
if ($dateFin != '') {
$strDateFin = " AND flux<='$dateFin'";
}
$rep=$this->iDb->select(
'jo.rncs_modifs',
'siren, nic, `table`, champs, valeur, flux, dateInsert',
"siren=$siren $strNic $strType $strDateDeb $strDateFin AND `table`='rncs_entrep' ORDER BY flux DESC", false, MYSQL_ASSOC);
foreach ($rep as $iModif=>$modif) {
$sql = "SELECT siren, nic, `table`, champs, valeur, flux, dateInsert FROM jo.rncs_modifs
WHERE siren=:siren $strNic $strType $strDateDeb $strDateFin AND `table`='rncs_entrep'
ORDER BY flux DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$codEve = array();
switch ($modif['champs']) {
switch ($result['champs']) {
case 'actif':
if ($modif['valeur']*1==0) {
// Cessation
if ($result['valeur']*1 == 0) {
$codEve[] = '410';
} // Cessation
elseif ($modif['valeur']*1==1) {
}
// Réactivation
elseif ($result['valeur']*1 == 1) {
$codEve[] = '120';
} // Réactivation
}
break;
case 'raisonSociale':
$codEve[] = 'NOM';
break;
case 'capitalMontant':
$codEve[] = 'CAP';
break;
case 'capitalType':
$codEve[] = 'CAT';
break;
case 'cj':
$codEve[] = 'CJ';
break;
case 'dateImma':
$codEve[] = 'IMM';
break;
case 'dateRad':
$codEve[] = 'RAD';
break;
case 'numGreffe':
$codEve[] = 'NTR';
break;
case 'numRC2':
$codEve[] = 'NRC';
break;
case 'raisonSociale': $codEve[]='NOM'; break;
case 'capitalMontant': $codEve[]='CAP'; break;
case 'capitalType': $codEve[]='CAT'; break;
case 'cj': $codEve[]='CJ'; break;
case 'dateImma': $codEve[]='IMM'; break;
case 'dateRad': $codEve[]='RAD'; break;
case 'numGreffe': $codEve[]='NTR'; break;
case 'numRC2': $codEve[]='NRC'; break;
}
foreach ($codEve as $even) {
$tabRet[] = array(
@ -643,13 +680,16 @@ class Metier_Partenaires_MRncs
'siege' => 1,
'libEven' => $tabEven['p'.trim($even)],
'libEvenDet' => '',
'dateMAJ' => $modif['dateInsert'],
'dateEven' => $modif['flux'],
'dateMAJ' => $result['dateInsert'],
'dateEven' => $result['flux'],
);
}
}
}
return $tabRet;
}
/**
* Intervenants
* @param string $siren