Affichage de la liste des enrichissements avec possibilité de télécharger le fichier

This commit is contained in:
Michael RICOIS 2015-01-22 16:33:23 +00:00
parent d5057c314d
commit 07e5d2d316
2 changed files with 58 additions and 13 deletions

View File

@ -193,6 +193,7 @@ class GestionController extends Zend_Controller_Action
'e.nbLigneTotales',
'e.uniteInsee',
"DATE_FORMAT(e.dateAdded, '%Y/%m/%d %H:%i:%s') AS dateAdded",
"DATE_FORMAT(e.dateStart, '%Y/%m/%d %H:%i:%s') AS dateStart",
'e.fichier'
))
->join('ciblage_criteres', 'idCriteres = ciblage_criteres.id', array(
@ -206,6 +207,46 @@ class GestionController extends Zend_Controller_Action
$this->view->commandes = $commandesM->fetchAll($sql)->toArray();
}
/**
* Téléchargement des fichiers créer par les clients pour analyse
*/
public function enrichissementdlAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$id = $this->getRequest()->getParam('id');
$table = new Application_Model_CiblageEnrichissementIdentifiants();
$sql = $table->select()
->where('id = ?', $id);
$result = $table->fetchRow($sql);
if( !empty($result) ) {
$result = $result->toArray();
$date = substr($result['dateAdded'],0,4).substr($result['dateAdded'],5,2);
$c = Zend_Registry::get('config');
$path = $c->profil->path->data.'/'.$date.'/';
$file = $result['fichier'];
}
$content_type = 'application/csv-tab-delimited-table';
//Envoi du fichier sur la sortie standard
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
} else {
echo 'Impossible de charger le fichier.';
}
}
/**
* Load enrichissement batch to complete data
@ -214,7 +255,7 @@ class GestionController extends Zend_Controller_Action
{
$request = $this->getRequest();
$id = $request->getParam('id');
exec('php '.APPLICATION_PATH.'/../batch/enrichissement.php --id '.$id.' &');
exec('php '.APPLICATION_PATH.'/../scripts/jobs/enrichissement.php --id '.$id.' &');
}
/**

View File

@ -22,25 +22,29 @@ $Years = date('Y') - $YearBegin;
<div>
<table>
<tr>
<th><b>Date de création</b></th>
<th><b>Référence</b></th>
<th><b>Date</b></th>
<th><b>login</b></th>
<th><b>Références</b></th>
<th><b>Résultat</b></th>
<th><b>Insee</b></th>
<th><b>login</b></th>
<th><b>Reférence ciblage</b></th>
<th><b>Fichier</b></th>
</tr>
<?php foreach($this->commandes as $item): ?>
<?php foreach($this->commandes as $item) { ?>
<tr>
<td><?=$item['dateAdded']?></td>
<td><?=$item['commandeReference']?></td>
<td>
<?=$item['dateAdded']?><br/>
<?=$item['dateStart']?>
</td>
<td><?=$item['login']?></td>
<td>
<?=$item['commandeReference']?><br/>
<?=$item['critereReference']?><br/>
<a href="<?=$this->url(array('controller'=>'gestion','action'=>'enrichissementdl', 'id'=> $item['id']),
'default', true)?>"><?=$item['fichier']?></a>
</td>
<td><?=$item['nbLigneTotales']?></td>
<td><?=$item['uniteInsee']?></td>
<td><?=$item['login']?></td>
<td><?=$item['critereReference']?></td>
<td><?=$item['fichier']?></td>
</tr>
<?php endforeach; ?>
<?php } ?>
</table>
</div>
</div>