Mise a jour de la prévisualisation

This commit is contained in:
Michael RICOIS 2014-12-17 15:46:12 +00:00
parent d0b6af7b1f
commit d51252b829
3 changed files with 60 additions and 53 deletions

View File

@ -262,36 +262,36 @@ class ComptageController extends Zend_Controller_Action
$joins = array();
foreach ( $profil as $item ) {
//Get item
if ( array_key_exists($item, $fields) ) {
$field = $fields[$item];
//Définition de l'entete
$tabEnteteLabel[] = $field['label'];
$tabEntete[] = $item;
//Construction de la requete SQL
if ( array_key_exists('sql', $field) ) {
$columns[] = $field['sql'];
} else {
$columns[] = $field['column'].' AS '.$item;
}
//Pour les champs de type "code", ajouter le libellé
if ( array_key_exists('join', $field) ) {
$tabEnteteLabel[] = $field['join']['label'];
$joinColumn = $item.'Lib';
$tabEntete[] = $joinColumn;
//Sql
$tableAlias = $item.'L';
$join['name'] = $field['join']['table'].' AS '.$tableAlias;
$join['col'] = $field['join']['column'].' AS '.$joinColumn;
$join['cond'] = $field['join']['cond'];
$joins[] = $join;
}
}
//Get item
if ( array_key_exists($item, $fields) ) {
$field = $fields[$item];
//Définition de l'entete
$tabEnteteLabel[] = $field['label'];
$tabEntete[] = $item;
//Construction de la requete SQL
if ( array_key_exists('sql', $field) ) {
$columns[] = $field['sql'];
} else {
$columns[] = $field['column'].' AS '.$item;
}
//Pour les champs de type "code", ajouter le libellé
if ( array_key_exists('join', $field) ) {
$tabEnteteLabel[] = $field['join']['label'];
$joinColumn = $item.'Lib';
$tabEntete[] = $joinColumn;
//Sql
$tableAlias = $item.'L';
$join['name'] = $field['join']['table'].' AS '.$tableAlias;
$join['col'] = $field['join']['column'].' AS '.$joinColumn;
$join['cond'] = $field['join']['cond'];
$joins[] = $join;
}
}
}
@ -300,7 +300,7 @@ class ComptageController extends Zend_Controller_Action
$i = 0;
foreach ( $sirets as $siret ) {
if ( $i>0 ) {
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)."'");
@ -309,13 +309,13 @@ class ComptageController extends Zend_Controller_Action
}
if (count($joins)) {
foreach ( $joins as $join ) {
$sql->joinLeft($join['name'], $join['cond'], $join['col']);
}
}
foreach ( $joins as $join ) {
$sql->joinLeft($join['name'], $join['cond'], $join['col']);
}
}
try {
$result = $db->fetchAll($sql);
$result = $db->fetchAll($sql, null, Zend_Db::FETCH_ASSOC);
} catch(Zend_Db_Exception $e) {
if (APPLICATION_ENV=='development') {
echo $e->getMessage();
@ -323,22 +323,29 @@ class ComptageController extends Zend_Controller_Action
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;
}
foreach ($result as $i => $tabData) {
//Trier pour la sortie
$tabSortie = array();
foreach($tabEntete as $key) {
//Add static values
if ( array_key_exists($key, $fields) ) {
if ( array_key_exists('values', $fields[$key]) ) {
$values = $fields[$key]['values'];
//Remplace value if exist
if ( array_key_exists($tabData[$key], $values) ) {
$tabData[$key] = $values[$tabData[$key]];
}
}
}
//Order data for CSV file
$tabSortie[] = isset($tabData[$key]) ? $tabData[$key] : '';
}
$liste[] = $tabSortie;
}
Zend_Registry::get('firebug')->info($liste);
$this->view->assign('label', $tabEnteteLabel);
$this->view->assign('liste', $liste);

View File

@ -7,7 +7,7 @@
<table width="100%" style="font-size:10px;">
<tr>
<?php foreach($this->label as $label): ?>
<th style="border-left:1px solid black;padding:2px;"><b><?=$label?></b></th>
<th style="border-left:1px solid black;padding:2px;" nowrap><b><?=$label?></b></th>
<?php endforeach; ?>
</tr>
<?php

View File

@ -170,7 +170,7 @@ foreach ($identifiants as $siret)
$result = $db->fetchRow($sql, null, Zend_Db::FETCH_ASSOC);
} catch(Exception $e) {
echo $sql."\n";
}
}
$tabData = $result;
//Trier pour la sortie
@ -186,10 +186,10 @@ foreach ($identifiants as $siret)
}
}
}
//Order data for CSV file
$tabSortie[] = isset($tabData[$key]) ? $tabData[$key] : '';
}
fputcsv($fp, $tabSortie, ',', '"');
//Mise à jour des lignes traitées dans la base