issue #0001784 : Amélioration de la prévisualisation avec Libellé
This commit is contained in:
parent
0ca2432493
commit
8fddb8367e
@ -252,15 +252,14 @@ class ComptageController extends Zend_Controller_Action
|
||||
$profil = array('raisonSociale');
|
||||
}
|
||||
|
||||
$extractSql = $extractLabel = array();
|
||||
$tabEntete = $tabEnteteLabel = array();
|
||||
require_once 'Scores/Enrichissement.php';
|
||||
$enrichissement = new Enrichissement();
|
||||
$data = $enrichissement->getFields();
|
||||
$fields = $enrichissement->getFields();
|
||||
|
||||
$sqlSelect = 'SELECT LPAD(siren, 9, 000000000) AS siren, LPAD(nic,5,00000) AS nic,';
|
||||
$sqlFrom = 'jo.etablissements_act';
|
||||
$sqlWhere = '';
|
||||
foreach ( $dataProfil as $item ) {
|
||||
$columns = array();
|
||||
$joins = array();
|
||||
foreach ( $profil as $item ) {
|
||||
|
||||
//Get item
|
||||
if ( array_key_exists($item, $fields) ) {
|
||||
@ -272,9 +271,9 @@ class ComptageController extends Zend_Controller_Action
|
||||
|
||||
//Construction de la requete SQL
|
||||
if ( array_key_exists('sql', $field) ) {
|
||||
$sqlSelect.= ' '.$field['sql'].', ';
|
||||
$columns[] = $field['sql'];
|
||||
} else {
|
||||
$sqlSelect.= ' '.$field['column'].' AS '.$item.',';
|
||||
$columns[] = $field['column'].' AS '.$item;
|
||||
}
|
||||
|
||||
//Pour les champs de type "code", ajouter le libellé
|
||||
@ -285,44 +284,60 @@ class ComptageController extends Zend_Controller_Action
|
||||
|
||||
//Sql
|
||||
$tableAlias = $item.'L';
|
||||
$sqlSelect.= $tableAlias.'.'.$field['join']['column'].' AS '.$joinColumn;
|
||||
$sqlFrom.= ','.$field['join']['column'].' AS '.$tableAlias;
|
||||
$sqlWhere = ' AND WHERE '.$field['join']['cond'];
|
||||
$join['name'] = $field['join']['table'].' AS '.$tableAlias;
|
||||
$join['col'] = $field['join']['column'].' AS '.$joinColumn;
|
||||
$join['cond'] = $field['join']['cond'];
|
||||
|
||||
$joins[] = $join;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$db = Zend_Db_Table::getDefaultAdapter();
|
||||
$sql = $sqlSelect . ' FROM jo.etablissements_act ' . $sqlFrom . ' WHERE ';
|
||||
$sql = $db->select()->from('jo.etablissements_act', $columns);
|
||||
|
||||
$i = 0;
|
||||
foreach ( $sirets as $siret ) {
|
||||
if ( $i>0 ) {
|
||||
$where.=' OR ';
|
||||
if ( $i>0 ) {
|
||||
$sql->orWhere("siren='".substr($siret,0,9)."' AND nic='".substr($siret,9,5)."'");
|
||||
} else {
|
||||
$sql->where("siren='".substr($siret,0,9)."' AND nic='".substr($siret,9,5)."'");
|
||||
}
|
||||
$where.= "(siren='".substr($siret,0,9)."' AND nic='".substr($siret,9,5)."')";
|
||||
$i++;
|
||||
}
|
||||
$sql.= $sqlWhere;
|
||||
|
||||
$result = $db->fetchAll($sql);
|
||||
|
||||
$liste = array();
|
||||
foreach ($result as $l => $line) {
|
||||
$tmp = array();
|
||||
foreach($line as $column => $data) {
|
||||
$valuesPredefine = $enrichissement->getColumnValue($column);
|
||||
if ($valuesPredefine!==false) {
|
||||
$tmp[] = $valuesPredefine[$data];
|
||||
} else {
|
||||
$tmp[] = $data;
|
||||
}
|
||||
if (count($joins)) {
|
||||
foreach ( $joins as $join ) {
|
||||
$sql->joinLeft($join['name'], $join['cond'], $join['col']);
|
||||
}
|
||||
$liste[] = $tmp;
|
||||
}
|
||||
|
||||
$this->view->assign('label', $extractLabel);
|
||||
try {
|
||||
$result = $db->fetchAll($sql);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
echo $e->getMessage();
|
||||
echo "<br/>";
|
||||
echo $sql->__toString();
|
||||
}
|
||||
|
||||
$liste = array();
|
||||
if ( count($result)>0 ) {
|
||||
foreach ($result as $l => $line) {
|
||||
$tmp = array();
|
||||
foreach($line as $column => $data) {
|
||||
$valuesPredefine = $enrichissement->getColumnValue($column);
|
||||
if ($valuesPredefine!==false) {
|
||||
$tmp[] = $valuesPredefine[$data];
|
||||
} else {
|
||||
$tmp[] = $data;
|
||||
}
|
||||
}
|
||||
$liste[] = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->assign('label', $tabEnteteLabel);
|
||||
$this->view->assign('liste', $liste);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user