This commit is contained in:
Michael RICOIS 2017-02-02 11:33:28 +01:00
parent 11487e840b
commit 5c6c6cc7a8

View File

@ -13,6 +13,12 @@ class Metier_Partenaires_MCadastre
*/
protected $conn;
/**
* Logger
* @var \Monolog\Logger
*/
protected $logger;
/**
* Droits des locaux
* @var array
@ -65,7 +71,7 @@ class Metier_Partenaires_MCadastre
'MP' => 'Maison partagée par une limite territoriale',
'PP' => 'ND',
'SM' => 'Sol de maison',
'U' => 'Etablissement industriel',
'U' => 'Etablissement industriel',
'U1' => 'Gare',
'U2' => 'Gare - Triage',
'U3' => 'Gare - Atelier matériel',
@ -133,7 +139,7 @@ class Metier_Partenaires_MCadastre
private static $natureParcelles = array(
'AB' => 'Terrains à batir',
'AG' => 'Terrains d\'agrément',
'B' => 'Bois',
'B' => 'Bois',
'BF' => 'Futaies feuillues',
'BM' => 'Futaies mixtes',
'BO' => 'Oseraies',
@ -143,18 +149,18 @@ class Metier_Partenaires_MCadastre
'BT' => 'Taillies simples',
'CA' => 'Carrières',
'CH' => 'Chemins de fer, Canaux de Navigation',
'E' => 'Eaux',
'J' => 'Jardins',
'L' => 'Landes',
'E' => 'Eaux',
'J' => 'Jardins',
'L' => 'Landes',
'LB' => 'Landes Boisées',
'P' => 'Prés',
'P' => 'Prés',
'PA' => 'Pâtures ou Pâturages',
'PC' => 'Pacages ou Pâtis',
'PE' => 'Prés d\'embouche',
'PH' => 'Herbages',
'PP' => 'Prés, Pâtures ou Herbages plantes',
'S' => 'Sols',
'T' => 'Terre',
'S' => 'Sols',
'T' => 'Terre',
'TP' => 'Terres plantées',
'VE' => 'Vergers',
'VI' => 'Vignes',
@ -167,6 +173,10 @@ class Metier_Partenaires_MCadastre
public function __construct($conn = null)
{
$this->conn = Zend_Registry::get('doctrine');
if (Zend_Registry::isRegistered('logger')) {
$this->logger = Zend_Registry::get('logger');
}
}
/**
@ -233,13 +243,22 @@ class Metier_Partenaires_MCadastre
$siren = $this->siren;
}
$locaux = array();
$sql = "SELECT e.INTCIF, e.DNUPER, e.CCOGRM, e.DDENPM, e.DSIPMO, e.DFORME, e.DSIREN, e.DLIGN3, e.DLIGN4, e.DLIGN5, e.DLIGN6, e.CCODEP, e.CCOCOM AS companyCCOCOM,
l.CCODRO, l.CCOCOM, l.CCOPRF, l.CCOSEC, l.DNUPLA, l.DNUBAT, l.DESC, l.DNIV, l.DPOR, l.CCONLC, l.CCOAFF0, l.DSUPOD0, l.CCOAFF1, l.DSUPOD1, l.CCOAFF2, l.DSUPOD2, l.CCOAFF3, l.DSUPOD3, l.CCOAFF4, l.DSUPOD4, l.CCOAFF5, l.DSUPOD5, l.CCOAFF6, l.DSUPOD6, l.CCOAFF7, l.DSUPOD7, l.CCOAFF8, l.DSUPOD8, l.CCOAFF9, l.DSUPOD9, l.CCODEP, l.DLICOM, l.CCORIV, l.CNAVOI, l.DLIVOI, l.DNUVOI, l.DLTNUV
FROM sdv1.cad_perloc l, sdv1.cad_permor e WHERE e.DSIREN='$siren' AND e.INTCIF=l.INTCIF AND e.DNUPER=l.DNUPER";
$stmt = $this->conn->executeQuery($sql);
$locaux = array();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->executeQuery($sql);
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($loc = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$format = array(
'idCentre' => $loc['INTCIF'],
@ -307,15 +326,23 @@ class Metier_Partenaires_MCadastre
if ($siren === null) {
$siren = $this->siren;
};
$parcelles = array();
$sql = "SELECT e.INTCIF, e.DNUPER, e.CCOGRM, e.DDENPM, e.DSIPMO, e.DFORME, e.DSIREN, e.DLIGN3, e.DLIGN4, e.DLIGN5, e.DLIGN6, e.CCODEP, e.CCOCOM AS companyCCOCOM,
p.CCODRO, p.CCOCOM, p.CCOPRF, p.CCOSEC, p.DNUPLA, p.DCNPAR, p.DSGRPF0, p.DCNSUF0, p.DSGRPF1, p.DCNSUF1, p.DSGRPF2, p.DCNSUF2, p.DSGRPF3, p.DCNSUF3, p.DSGRPF4, p.DCNSUF4, p.DSGRPF5, p.DCNSUF5, p.DSGRPF6, p.DCNSUF6, p.DSGRPF7, p.DCNSUF7, p.DSGRPF8, p.DCNSUF8, p.DSGRPF9, p.DCNSUF9, p.CCODEP, p.DLICOM, p.CCORIV, p.CNAVOI, p.DLIVOI, p.DNUVOI, p.DLTNUV
FROM sdv1.cad_perpar p, sdv1.cad_permor e
WHERE e.DSIREN='$siren' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER";
$stmt = $this->conn->executeQuery($sql);
$parcelles = array();
if ($stmt->rowCount() > 0) {
$nb = 0;
try {
$stmt = $this->conn->executeQuery($sql);
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
while ($loc = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$format = array(
'idCentre' => $loc['INTCIF'],
@ -387,8 +414,6 @@ class Metier_Partenaires_MCadastre
$sql = "SELECT count(*) AS itemTotal, (SUM(l.DSUPOD0) + SUM(l.DSUPOD1) + SUM(l.DSUPOD2) + SUM(l.DSUPOD3) + SUM(l.DSUPOD4) + SUM(l.DSUPOD5) + SUM(l.DSUPOD7) + SUM(l.DSUPOD8) + SUM(l.DSUPOD9)) AS surfaceTotal
FROM sdv1.cad_perloc l, sdv1.cad_permor e
WHERE e.DSIREN='".$this->siren."' AND e.INTCIF=l.INTCIF AND e.DNUPER=l.DNUPER".$droitSql;
$stmt = $this->conn->executeQuery($sql);
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
} elseif ($type == 'parcelle') {
$droitSql = " AND p.CCODRO='P'";
if ($droit != 'P') {
@ -397,7 +422,19 @@ class Metier_Partenaires_MCadastre
$sql = "SELECT count(*) AS itemTotal, sum(p.DCNPAR) AS surfaceTotal
FROM sdv1.cad_perpar p, sdv1.cad_permor e
WHERE e.DSIREN='".$this->siren."' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER".$droitSql;
}
$results = array();
$nb = 0;
try {
$stmt = $this->conn->executeQuery($sql);
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
if ($nb > 0) {
$results = $stmt->fetchAll(\PDO::FETCH_ASSOC);
}
@ -491,10 +528,19 @@ class Metier_Partenaires_MCadastre
"WHERE e.DSIREN='$this->siren' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER";
$sql = "SELECT * FROM ( ($locauxSql) UNION ALL ($parcellesSql) ) results";
$stmt = $this->conn->executeQuery($sql);
$nb = 0;
try {
$stmt = $this->conn->executeQuery($sql);
$nb = $stmt->rowCount();
} catch (\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
}
$list = array();
if ($stmt->rowCount() > 0) {
if ($nb > 0) {
while ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
// Libellé role
$result['roleLib'] = self::$codeDroit[trim($result['role'])];