Fichier bodacc et historique
This commit is contained in:
parent
33dd9e5123
commit
d898342447
@ -421,20 +421,16 @@ class JuridiqueController extends Zend_Controller_Action
|
||||
}
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
$file = realpath($c->profil->path->data)
|
||||
.'/bodacc/'.$type.'/'.$annee.'/'.
|
||||
'BODACC_'.$type.'_'.$annee.'_'.$num.'.pdf';
|
||||
$file = realpath($c->profil->path->data).'/bodacc/'.$type.'/'.$annee.'/'.
|
||||
'BODACC_'.$type.'_'.$annee.'_'.$num.'.pdf';
|
||||
|
||||
if ( !file_exists($file) ) {
|
||||
exec('php ' . APPLICATION_PATH . "/../scripts/jobs/getBodaccPdf.php $type $annee $num >> getBodaccPdf.log");
|
||||
}
|
||||
|
||||
if (file_exists($file)) {
|
||||
$href = $this->view->url(array(
|
||||
'controller' => 'fichier',
|
||||
'action' => 'bodacc',
|
||||
'fichier' => basename($file),
|
||||
), 'default', true);
|
||||
$href = $this->view->url(array('module'=>'file', 'controller'=>'bodacc', 'action'=>'actual',
|
||||
'q' => basename($file)), 'default', true);
|
||||
echo "<a target=\"_blank\" href=\"".$href."\">Cliquer ici pour télécharger le fichier.</a>";
|
||||
} else {
|
||||
echo "Erreur lors du chargement du fichier.";
|
||||
|
@ -213,11 +213,8 @@ class RechercheController extends Zend_Controller_Action
|
||||
'annee' => $annonce->Annee,
|
||||
'code' => $code,
|
||||
'text' => $texte,
|
||||
'file' => $this->view->url(array(
|
||||
'controller'=>'telechargement',
|
||||
'action'=>'histopdf',
|
||||
'q' => $fichier,
|
||||
'host' => base64_encode($host)), 'default', true
|
||||
'file' => $this->view->url(array('controller'=>'telechargement', 'action'=>'histopdf',
|
||||
'q' => $fichier, 'host' => base64_encode($host)), 'default', true
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -17,13 +17,13 @@ class TelechargementController extends Zend_Controller_Action
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
$this->path = $c->profil->path->files;
|
||||
|
||||
|
||||
require_once 'Scores/WsScores.php';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Vérifie ou télécharge le fichier sur une url
|
||||
* @param string $url
|
||||
@ -57,12 +57,12 @@ class TelechargementController extends Zend_Controller_Action
|
||||
unlink($this->path.'/'.$file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --- Lock file exist
|
||||
if ( file_exists($this->path.'/'.$file.'.lock') ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// --- Recuperation du fichier sur le serveur
|
||||
if ( file_exists($this->path.'/'.$file) ) {
|
||||
return $file;
|
||||
@ -157,11 +157,11 @@ class TelechargementController extends Zend_Controller_Action
|
||||
// --- Get File Url
|
||||
if ( $start == 1) {
|
||||
$source = $request->getParam('source', '');
|
||||
|
||||
|
||||
$user = new Scores_Utilisateur();
|
||||
$login = $user->getLogin();
|
||||
$idClient = $user->getIdClient();
|
||||
|
||||
|
||||
$ws = new WsScores();
|
||||
$reponse = $ws->getListeSurveillancesCsv($source, $login, $idClient);
|
||||
if ( !empty($reponse->result->Url) ) {
|
||||
@ -174,7 +174,7 @@ class TelechargementController extends Zend_Controller_Action
|
||||
else {
|
||||
$url = $request->getParam('url', '');
|
||||
$file = $this->getFile($url);
|
||||
|
||||
|
||||
// --- En attente
|
||||
if ( $file === null ) {
|
||||
echo '';
|
||||
@ -189,7 +189,7 @@ class TelechargementController extends Zend_Controller_Action
|
||||
' target="_blank" href="/fichier/surveillance/'.$file.
|
||||
'">Cliquez-ici pour télécharger le fichier.</a></u>';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ class TelechargementController extends Zend_Controller_Action
|
||||
|
||||
$ws = new WsScores();
|
||||
$reponse = $ws->getPortefeuilleCsv($login, $idClient);
|
||||
|
||||
|
||||
if ( !empty($reponse->result->Url) ) {
|
||||
echo $reponse->result->Url;
|
||||
} else {
|
||||
@ -221,7 +221,7 @@ class TelechargementController extends Zend_Controller_Action
|
||||
} else {
|
||||
$url = $request->getParam('url', '');
|
||||
$file = $this->getFile($url);
|
||||
|
||||
|
||||
// --- En attente
|
||||
if ( $file === null ) {
|
||||
echo '';
|
||||
@ -270,9 +270,8 @@ class TelechargementController extends Zend_Controller_Action
|
||||
// --- Fichier disponible
|
||||
elseif ( file_exists($this->path.'/'.$file) ) {
|
||||
if (filesize($this->path.'/'.$file) > 0) {
|
||||
echo '<u><a title="Télécharger le fichier"'.
|
||||
' target="_blank" href="/fichier/histopdf/'.$file.
|
||||
'">Cliquez-ici pour télécharger le fichier.</a></u>';
|
||||
echo '<u><a title="Télécharger le fichier" target="_blank" href="/file/bodacc/histo/q/'.$file.
|
||||
'">Cliquez-ici pour télécharger le fichier.</a></u>';
|
||||
} else {
|
||||
echo "Erreur lors du téléchargement du fichier.";
|
||||
}
|
||||
|
72
application/modules/file/controllers/BodaccController.php
Normal file
72
application/modules/file/controllers/BodaccController.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
class File_BodaccController extends Zend_Controller_Action
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
}
|
||||
|
||||
public function actualAction()
|
||||
{
|
||||
$filename = $this->getRequest()->getParam('q');
|
||||
preg_match('/BODACC_(A|B|C)_([0-9]{4})_(.*)\.pdf/', $filename, $matches);
|
||||
$c = Zend_Registry::get('config');
|
||||
$file = realpath($c->profil->path->data).'/bodacc/'.$matches[1].'/'.$matches[2].'/'.$filename;
|
||||
$content_type = 'application/pdf';
|
||||
//Envoi du fichier sur la sortie standard
|
||||
if ( file_exists($file) ) {
|
||||
$modules = apache_get_modules();
|
||||
if (in_array('mod_xsendfile', $modules)) {
|
||||
header ('X-Sendfile: ' . $file);
|
||||
header ('Content-Type: ' . $content_type);
|
||||
header ('Content-Disposition: attachment; filename="' . $content_type . '"');
|
||||
exit;
|
||||
} else {
|
||||
ini_set('zlib.output_compression', '0');
|
||||
header('Content-Transfer-Encoding: none');
|
||||
header('Content-Type: ' . $content_type.'');
|
||||
header('Content-Length: ' . filesize($file));
|
||||
header('Content-MD5: ' . base64_encode(md5_file($file)));
|
||||
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
|
||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||
header('Pragma: public');
|
||||
readfile($file);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo "Impossible de charger le fichier";
|
||||
}
|
||||
}
|
||||
|
||||
public function histoAction()
|
||||
{
|
||||
$filename = $this->getRequest()->getParam('q');
|
||||
$c = Zend_Registry::get('config');
|
||||
$file = realpath($c->profil->path->files).'/'.$filename;
|
||||
$content_type = 'application/pdf';
|
||||
//Envoi du fichier sur la sortie standard
|
||||
if ( file_exists($file) ) {
|
||||
$modules = apache_get_modules();
|
||||
if (in_array('mod_xsendfile', $modules)) {
|
||||
header ('X-Sendfile: ' . $file);
|
||||
header ('Content-Type: ' . $content_type);
|
||||
header ('Content-Disposition: attachment; filename="' . $content_type . '"');
|
||||
exit;
|
||||
} else {
|
||||
ini_set('zlib.output_compression', '0');
|
||||
header('Content-Transfer-Encoding: none');
|
||||
header('Content-Type: ' . $content_type.'');
|
||||
header('Content-Length: ' . filesize($file));
|
||||
header('Content-MD5: ' . base64_encode(md5_file($file)));
|
||||
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
|
||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||
header('Pragma: public');
|
||||
readfile($file);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
echo "Impossible de charger le fichier";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user