Siret extraction

This commit is contained in:
Michael RICOIS 2012-06-01 10:30:44 +00:00
parent d567502e7d
commit 46a3115524
2 changed files with 22 additions and 9 deletions

View File

@ -185,26 +185,27 @@ class GestionController extends Zend_Controller_Action
}
/**
* Extract sirets from database
* Extract only SIRETs from database
* @todo : To csv file
*/
public function siretscsvAction()
public function extractAction()
{
$id = $this->getRequest()->getParam('id');
$table = new Application_Model_EnrichissementIdentifiants();
$sql = $table->select()
->where('idComptage = ?', $id);
$sql = $table->select()->where('idComptage = ?', $id);
$result = $table->fetchRow($sql);
if(!empty($result)) {
$result = $result->toArray();
$sirets = json_decode($result['identifiants'], true);
$content = '';
foreach($sirets as $siret) {
echo $siret."\n";
}
$content.= $siret.",";
}
$this->view->assign('content', $content);
}else {
echo 'Aucune commande d\'enrichissement sur ce comptage';
}
exit;
$this->view->assign('message', 'Aucune commande d\'enrichissement sur ce comptage');
}
}
/**

View File

@ -0,0 +1,12 @@
<?php
if ($this->content) {
$content_type = 'application/csv-tab-delimited-table';
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo $this->content;
} else {
echo $this->message;
}