59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
class DashboardController extends Zend_Controller_Action
|
|
{
|
|
public function indexAction(){}
|
|
|
|
public function reportAction()
|
|
{
|
|
//Extraire un fichier CSV des commandes
|
|
if ($mode == 'csv') {
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender(true);
|
|
|
|
$commandM = new Application_Model_Command();
|
|
|
|
|
|
$c = Zend_Registry::get('config');
|
|
$path = realpath($c->profil->path->files).'/export/';
|
|
|
|
$file = 'liste-commandes-'.$client.'.csv';
|
|
$handle = fopen($path . $file, 'w');
|
|
$header = $commandM->info('cols');
|
|
fputcsv($handle, $header);
|
|
$data = $commandM->fetchAll($sql);
|
|
foreach($users->toArray() as $item) {
|
|
fputcsv($handle, $item);
|
|
}
|
|
fclose($handle);
|
|
|
|
$content_type = 'application/csv-tab-delimited-table';
|
|
$c = Zend_Registry::get('config');
|
|
$path = realpath($c->profil->path->files).'/export/';
|
|
//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.';
|
|
}
|
|
|
|
}
|
|
//Lister les commandes OK eta = 0
|
|
else {
|
|
$commandM = new Application_Model_Command();
|
|
$sql = $commandM->select()->where('eta = ?',0);
|
|
$this->view->Commands = $commandM->fetchAll($sql);
|
|
//Télécharger le rapport
|
|
//Regénérer le rapport
|
|
//Télécharger la facture
|
|
}
|
|
}
|
|
|
|
} |