extranet/www/exportpdf.php

76 lines
2.2 KiB
PHP
Raw Normal View History

2009-03-03 17:36:37 +01:00
<?php
2009-03-05 09:31:21 +01:00
2009-03-03 17:36:37 +01:00
function topdf($filename, $options = "") {
2009-03-09 09:51:12 +01:00
global $firephp;
2009-03-05 12:24:43 +01:00
$pdfFile = str_replace('.html','.pdf',$filename);
2009-03-09 09:51:12 +01:00
$firephp->log($pdfFile, 'pdfFile');
2009-03-05 12:24:43 +01:00
$pdfNameFile = substr($pdfFile, strrpos($pdfFile, "/")+1);
2009-03-09 09:51:12 +01:00
if (!file_exists($pdfFile)){
2009-03-05 12:24:43 +01: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 12:24:43 +01:00
}
2009-03-06 18:32:33 +01:00
if (file_exists($pdfFile)){
2009-03-05 12:24:43 +01:00
// Write the content type to the client...
header("Content-Type: application/pdf");
//header("Content-Disposition: inline; filename=\"$pdfFile\"");
2009-03-05 12:24:43 +01:00
header("Content-Disposition: attachement; filename=\"$pdfNameFile\"");
flush();
print file_get_contents($pdfFile);
}
2009-03-03 17:36:37 +01:00
}
//Start...
2009-03-05 09:31:21 +01:00
$page = $_REQUEST['page'];
2009-03-11 08:51:18 +01:00
$idEntreprise = $_REQUEST['idEntreprise'];
2009-03-05 09:31:21 +01:00
$siret = $_REQUEST['siret'];
$siren = substr($siret,0,9);
2009-03-06 18:12:26 +01:00
2009-03-03 17:36:37 +01:00
//Construire le titre du fichier PDF en fonction des param<61>tres fournis
2009-03-05 09:31:21 +01:00
$path = realpath(dirname(__FILE__).'/../cache/');
if (($siret*1)==0 || ($siren*1)<100){
2009-03-06 18:12:26 +01:00
$fileName = $path.'/'.$page.'-'.$idEntreprise;
2009-03-05 09:31:21 +01:00
}else{
$fileName = $path.'/'.$page.'-'.$siret;
2009-03-06 18:12:26 +01:00
}
2009-05-28 19:10:09 +02:00
//Gestion des cas particuliers
2009-03-06 18:12:26 +01:00
if($page=='dirigeants' && $_REQUEST['vue']=='histo'){
$fileName.= '-histo';
}elseif($page=='annonces'){
if(isset($_REQUEST['idan']) && $_REQUEST['idan']!=''){
$fileName.= '-'.$_REQUEST['idan'];
}
2009-05-28 19:10:09 +02:00
}elseif($page=='liasse'){
if(isset($_REQUEST['mil'])){
$mil = explode(',',$_REQUEST['mil']);
$annee = substr($mil[0],-10);
$annee = str_replace('/', '', $annee);
$firephp->log($annee, 'annee');
$fileName.= '-'.$annee;
}
2009-06-03 19:03:02 +02: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 09:31:21 +01:00
}
2009-03-06 18:12:26 +01:00
//Ajout de l'extension
$fileName.='.html';
2009-03-05 09:31:21 +01:00
$firephp->log($fileName, 'FICHIER');
2009-03-05 17:19:38 +01:00
topdf($fileName, '--no-links');
2009-03-03 17:36:37 +01:00
?>