extranet/www/exportpdf.php

76 lines
2.2 KiB
PHP
Raw Normal View History

2009-03-03 16:36:37 +00:00
<?php
2009-03-05 08:31:21 +00:00
2009-03-03 16:36:37 +00:00
function topdf($filename, $options = "") {
2009-03-09 08:51:12 +00:00
global $firephp;
2009-03-05 11:24:43 +00:00
$pdfFile = str_replace('.html','.pdf',$filename);
2009-03-09 08:51:12 +00:00
$firephp->log($pdfFile, 'pdfFile');
2009-03-05 11:24:43 +00:00
$pdfNameFile = substr($pdfFile, strrpos($pdfFile, "/")+1);
2009-03-09 08:51:12 +00:00
if (!file_exists($pdfFile)){
2009-03-05 11:24:43 +00:00
// Run HTMLDOC to provide the PDF file to the user...
// Use the --no-localfiles option for enhanced security!
// Use ulimit to limit the maximum amount of memory used by each instance!
passthru("ulimit -m 16384 -t 10; htmldoc -t pdf14 --quiet --jpeg --webpage $options '$filename' -f $pdfFile");
2009-03-05 11:24:43 +00:00
}
2009-03-06 17:32:33 +00:00
if (file_exists($pdfFile)){
2009-03-05 11:24:43 +00:00
// Write the content type to the client...
header("Content-Type: application/pdf");
//header("Content-Disposition: inline; filename=\"$pdfFile\"");
2009-03-05 11:24:43 +00:00
header("Content-Disposition: attachement; filename=\"$pdfNameFile\"");
flush();
print file_get_contents($pdfFile);
}
2009-03-03 16:36:37 +00:00
}
//Start...
2009-03-05 08:31:21 +00:00
$page = $_REQUEST['page'];
2009-03-11 07:51:18 +00:00
$idEntreprise = $_REQUEST['idEntreprise'];
2009-03-05 08:31:21 +00:00
$siret = $_REQUEST['siret'];
$siren = substr($siret,0,9);
2009-03-06 17:12:26 +00:00
//Construire le titre du fichier PDF en fonction des paramètres fournis
2009-03-05 08:31:21 +00:00
$path = realpath(dirname(__FILE__).'/../cache/');
if (($siret*1)==0 || ($siren*1)<100){
2009-03-06 17:12:26 +00:00
$fileName = $path.'/'.$page.'-'.$idEntreprise;
2009-03-05 08:31:21 +00:00
}else{
$fileName = $path.'/'.$page.'-'.$siret;
2009-03-06 17:12:26 +00:00
}
2009-05-28 17:10:09 +00:00
//Gestion des cas particuliers
2009-03-06 17:12:26 +00:00
if($page=='dirigeants' && $_REQUEST['vue']=='histo'){
$fileName.= '-histo';
}elseif($page=='annonces'){
if(isset($_REQUEST['idan']) && $_REQUEST['idan']!=''){
$fileName.= '-'.$_REQUEST['idan'];
}
2009-05-28 17:10:09 +00:00
}elseif($page=='liasse'){
if(isset($_REQUEST['mil'])){
$mil = explode(',',$_REQUEST['mil']);
$annee = substr($mil[0],-10);
$annee = str_replace('/', '', $annee);
$indice = str_replace('/', '', substr($mil[0], 0, 11));
$fileName.= '-'.$indice;
2009-05-28 17:10:09 +00:00
}
2009-06-03 17:03:02 +00:00
}elseif($page=='ratios'){
if(isset($_REQUEST['mil'])){
$mil = explode(',',$_REQUEST['mil']);
$annee = substr($mil[0],-10);
$annee = str_replace('/', '', $annee);
$firephp->log($annee, 'annee');
$fileName.= '-'.$annee;
}
if(isset($_REQUEST['ratio'])){
$fileName.= '-'.$_REQUEST['ratio'];
}
}elseif($page=='synthese'){
if(isset($_REQUEST['ratio'])){
$fileName.= '-'.$_REQUEST['ratio'];
}
2009-03-05 08:31:21 +00:00
}
2009-03-06 17:12:26 +00:00
//Ajout de l'extension
$fileName.='.html';
2009-03-05 08:31:21 +00:00
$firephp->log($fileName, 'FICHIER');
2009-03-05 16:19:38 +00:00
topdf($fileName, '--no-links');
2009-03-03 16:36:37 +00:00
?>