MRncs : Dirigeants principaux

This commit is contained in:
Michael RICOIS 2017-01-12 11:09:56 +01:00
parent 1c3ec01d3e
commit caf10cc374

View File

@ -36,11 +36,11 @@ class Metier_Partenaires_MRncs
9100 => array('codeSd'=>'T', 'lib'=>'Conciliateur'),
);
public $tabDevises=array();
public $tabPays=array();
public $tabTribunaux=array();
public $tabMandataires=array();
public $tabJugements=array();
public $tabDevises = array();
public $tabPays = array();
public $tabTribunaux = array();
public $tabMandataires = array();
public $tabJugements = array();
private $iDb;
/** Partie Extranet IMR Infogreffe **/
@ -53,8 +53,26 @@ class Metier_Partenaires_MRncs
public $maxDemJour=10;
public $matching=null;
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
/**
* Flag to get remote data
* @var string
*/
protected $remote = false;
/**
*
* @param unknown $db
*/
public function __construct($db = null)
{
$this->conn = Zend_Registry::get('doctrine');
if ($db === null) {
$this->iDb = new Metier_Util_Db();
} else {
@ -67,6 +85,14 @@ class Metier_Partenaires_MRncs
$this->tabJugements = $this->getTabJugements();
}
/**
* Active la récupération des données distantes
*/
public function setRemote()
{
$this->remote = true;
}
public function getLibFctDir($codeFonctionDirectionRncs)
{
$codeFonctionDirectionRncs = $codeFonctionDirectionRncs*1;
@ -959,93 +985,106 @@ class Metier_Partenaires_MRncs
return false;
}
public function getDirigeantsPrin($siren, $nbDirs=2)
/**
* Dirigeants principaux
* @param sstring $siren
* @param number $nbDirs
* @return array
*/
public function getDirigeantsPrin($siren, $nbDirs = 2)
{
$siren = $siren*1;
$tabRet = array();
$dirs = $this->iDb->select(
'jo.rncs_dirigeants',
'siren, raisonSociale, dirRS, civilite, nom, prenom, naissance_nom, naissance_date, naissance_lieu, fonction_code, fonction_lib, cinf, dateFin, flux, dateInsert',
"siren=$siren AND actif%10=1 ORDER BY fonction_code DESC", true, MYSQL_ASSOC);
$sql = "SELECT siren, raisonSociale, dirRS, civilite, nom, prenom, naissance_nom, naissance_date, naissance_lieu, fonction_code, fonction_lib, cinf, dateFin, flux, dateInsert
FROM jo.rncs_dirigeants WHERE siren=:siren AND actif%10=1 ORDER BY fonction_code DESC";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
$numDir = 0;
foreach ($dirs as $k => $dir) {
$numDir++;
if ($dir['naissance_date']<>'0000-00-00') {
$dateNaiss = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $dir['naissance_date']);
} else {
$dateNaiss = '';
}
if ($dir['flux']<>'0000-00-00') {
$dateModif = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $dir['flux']);
} else {
$dateModif = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $dir['dateInsert']);
}
$nom = trim($dir['nom']);
$nomUsage = '';
if (trim($dir['naissance_nom']) != '') {
$nom = trim($dir['naissance_nom']);
$nomUsage = trim($dir['nom']);
}
$tabRet[] = array(
'Fonction' => $dir['fonction_code'],
'Titre' => $dir['fonction_lib'],
'Societe' => $dir['dirRS'],
'Civilite' => $dir['civilite'],
'Nom' => $nom,
'Prenom' => $dir['prenom'],
'NomUsage' => $nomUsage,
'NaissDate' => $dateNaiss,
'NaissVille' => $dir['naissance_lieu'],
'NaissDepPays' => '', // 25
'Ancien' => 0,
'DateFct' => $dateModif,
'Cinf' => $dir['cinf'],
);
if ($numDir >= $nbDirs) {
break;
}
}
if ($numDir == 0) {
$dirs = $this->iDb->select(
'jo.rncs_entrep',
"siren, raisonSociale, '' AS dirRS, IF(sexe='M', 'M', IF(sexe='F', 'MME', '')) AS civilite, nom, prenom, nomUsage AS naissance_nom, dateNaiss AS naissance_date, lieuNaiss AS naissance_lieu, 1050 AS fonction_code, 'Personne Physique' AS fonction_lib, 0 AS cinf, dateFer AS dateFin, flux, dateInsert",
"siren=$siren", true, MYSQL_ASSOC);
$numDir = 0;
foreach ($dirs as $k => $dir) {
if ($stmt->rowCount() > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$numDir++;
if ($dir['naissance_date'] != '0000-00-00') {
$dateNaiss = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $dir['naissance_date']);
if ($result['naissance_date'] != '0000-00-00') {
$dateNaiss = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $result['naissance_date']);
} else {
$dateNaiss = '';
}
if ($dir['flux']<>'0000-00-00') {
$dateModif = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $dir['flux']);
if ($result['flux'] != '0000-00-00') {
$dateModif = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $result['flux']);
} else {
$dateModif = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $dir['dateInsert']);
$dateModif = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $result['dateInsert']);
}
$nom = trim($dir['nom']);
$nom = trim($result['nom']);
$nomUsage = '';
if (trim($dir['naissance_nom']) != '') {
$nom = trim($dir['naissance_nom']);
$nomUsage = trim($dir['nom']);
if (trim($result['naissance_nom']) != '') {
$nom = trim($result['naissance_nom']);
$nomUsage = trim($result['nom']);
}
$tabRet[] = array(
'Fonction' => $dir['fonction_code'],
'Titre' => $dir['fonction_lib'],
'Societe' => $dir['dirRS'],
'Civilite' => $dir['civilite'],
'Nom' => $nom,
'Prenom' => $dir['prenom'],
'NomUsage' => $nomUsage,
'NaissDate' => $dateNaiss,
'NaissVille' => $dir['naissance_lieu'],
'NaissDepPays' => '', // 25
'Fonction' => $result['fonction_code'],
'Titre' => $result['fonction_lib'],
'Societe' => $result['dirRS'],
'Civilite' => $result['civilite'],
'Nom' => $nom,
'Prenom' => $result['prenom'],
'NomUsage' => $nomUsage,
'NaissDate' => $dateNaiss,
'NaissVille' => $result['naissance_lieu'],
'NaissDepPays' => '',
'Ancien' => 0,
'DateFct' => $dateModif,
'Cinf' => $dir['cinf'],
'DateFct' => $dateModif,
'Cinf' => $result['cinf'],
);
if ($numDir >= $nbDirs) {
break;
}
}
} else {
$sql = "SELECT siren, raisonSociale, '' AS dirRS, IF(sexe='M', 'M', IF(sexe='F', 'MME', '')) AS civilite, nom, prenom, nomUsage AS naissance_nom, dateNaiss AS naissance_date, lieuNaiss AS naissance_lieu, 1050 AS fonction_code, 'Personne Physique' AS fonction_lib, 0 AS cinf, dateFer AS dateFin, flux, dateInsert
FROM jo.rncs_entrep WHERE siren=:siren";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$numDir = 0;
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$numDir++;
if ($result['naissance_date'] != '0000-00-00') {
$dateNaiss = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $result['naissance_date']);
} else {
$dateNaiss = '';
}
if ($result['flux'] != '0000-00-00') {
$dateModif = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $result['flux']);
} else {
$dateModif = Metier_Util_Date::dateT('Y-m-d', 'd/m/Y', $result['dateInsert']);
}
$nom = trim($result['nom']);
$nomUsage = '';
if (trim($result['naissance_nom']) != '') {
$nom = trim($result['naissance_nom']);
$nomUsage = trim($result['nom']);
}
$tabRet[] = array(
'Fonction' => $result['fonction_code'],
'Titre' => $result['fonction_lib'],
'Societe' => $result['dirRS'],
'Civilite' => $result['civilite'],
'Nom' => $nom,
'Prenom' => $result['prenom'],
'NomUsage' => $nomUsage,
'NaissDate' => $dateNaiss,
'NaissVille' => $result['naissance_lieu'],
'NaissDepPays' => '',
'Ancien' => 0,
'DateFct' => $dateModif,
'Cinf' => $result['cinf'],
);
}
}
}
return $tabRet;
}
}