Nombre d'éléments et surface, en utilisation dans la méthode de scoring
This commit is contained in:
Michael RICOIS 2016-09-29 09:53:43 +02:00
parent c17a045b44
commit 6e93199716
2 changed files with 56 additions and 33 deletions

View File

@ -368,6 +368,38 @@ class Metier_Partenaires_MCadastre
return $parcelles;
}
/**
* Nombre d'éléments et surface total
* @param string $types (local, parcelle)
* @param string $droit (P:Propriétaire, L:Locataire)
* @return mixed
* false | [itemTotal, surfaceTotal]
*/
public function getSurfaceTotal($type = 'local', $droit = 'P')
{
if ($type == 'local') {
$droitSql = " AND l.CCODRO='P'";
if ($droit != 'P') {
$droitSql = " AND l.CCODRO!='P'";
}
$results = $this->iDb->select('sdv1.cad_perloc l, sdv1.cad_permor e',
"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",
"e.DSIREN='".$this->siren."' AND e.INTCIF=l.INTCIF AND e.DNUPER=l.DNUPER".$droitSql, false, MYSQL_ASSOC);
}
elseif ($type == 'parcelle') {
$droitSql = " AND p.CCODRO='P'";
if ($droit != 'P') {
$droitSql = " AND p.CCODRO!='P'";
}
$results = $this->iDb->select('sdv1.cad_perpar p, sdv1.cad_permor e',
"count(*) AS itemTotal, sum(p.DCNPAR) AS surfaceTotal",
"e.DSIREN='".$this->siren."' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER".$droitSql, false, MYSQL_ASSOC);
}
return $results;
}
/**
* List des éléments du patrimoine
* @return array
@ -457,8 +489,6 @@ class Metier_Partenaires_MCadastre
$sql = "SELECT * FROM ( ($locauxSql) UNION ALL ($parcellesSql) ) results";
$db = Zend_Db_Table::getDefaultAdapter();
//$results = $this->iDb->query($sql, true);
$results = $db->fetchAll($sql, null, Zend_Db::FETCH_ASSOC);
$list = array();

View File

@ -3412,38 +3412,31 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
$CADTER_NB_NONPROP=0; // nombre de postes TERRAINS à l'adresse dont elle n'est pas propriétaire
$CADBAT_SURF_TOT=0; // Surface totale des batiments du SIREN
$CADTER_SURF_TOT=0; // Surface totale des terrains du SIREN
/**
@todo
$CADBAT_SURF_CUM=0; // Cumul Surfaces des batiments à l'addresse
$CADTER_SURF_CUM=0; // Cumul Surfaces des terrains à l'addresse
*/
// Locaux
$iCadastre = new Metier_Partenaires_MCadastre($siren, $iDb);
$tabTmp = $iCadastre->getLocaux();
if(count($tabTmp) > 0) {
foreach ($tabTmp as $iTmp => $cad) {
$CADBAT_NB_TOT++;
if ($cad['localDroit'] == 'P'){
$CADBAT_NB_PROP++;
}
else {
$CADBAT_NB_NONPROP++;
}
$CADBAT_SURF_TOT+= $cad['localSurface'];
}
}
// Parcelles
$tabTmp = $iCadastre->getParcelles();
foreach ($tabTmp as $iTmp => $cad) {
$CADTER_NB_TOT++;
if ($cad['parcelDroit'] == 'P') {
$CADTER_NB_PROP++;
}
else {
$CADTER_NB_NONPROP++;
}
$CADTER_SURF_TOT+= $cad['parcelSurface'];
}
// Locaux
$batimentP = $iCadastre->getSurfaceTotal('local');
if (count($batimentP) > 0) {
$CADBAT_NB_PROP = $batimentP['itemTotal'];
$CADBAT_SURF_TOT+= $batimentP['surfaceTotal'];
}
$batimentL = $iCadastre->getSurfaceTotal('local', 'L');
if (count($batiment) > 0) {
$CADBAT_NB_NONPROP = $batimentL['itemTotal'];
$CADBAT_SURF_TOT+= $batimentL['surfaceTotal'];
}
$CADBAT_NB_TOT = $CADBAT_NB_PROP + $CADBAT_NB_NONPROP;
// Parcelles
$terrainP = $iCadastre->getSurfaceTotal('parcelle');
if (count($terrainP) > 0) {
$CADTER_NB_PROP = $batimentP['itemTotal'];
$CADTER_SURF_TOT+= $batimentP['surfaceTotal'];
}
$terrainL = $iCadastre->getSurfaceTotal('parcelle', 'L');
if (count($terrainL) > 0) {
$CADTER_NB_NONPROP = $batimentL['itemTotal'];
$CADTER_SURF_TOT+= $batimentL['surfaceTotal'];
}
$CADTER_NB_TOT = $CADTER_NB_PROP + $CADTER_NB_NONPROP;
$timer['cadastre'] = microtime(true);
/** RPS : Entreprise avec négociations ou accord sur les RPS ? **/