1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| <?php
//*************************************************************************************************
// FICHIER DE GENERATION DE PDF *
// S'APPUYANT SUR LES FICHIERS : *
// fig1a.php, fig1b.php, fig2a.php, fig3a.php, fig3b.php, fig4.php *
//*************************************************************************************************
// utilisation des variables de session
session_cache_limiter('private');
session_start();
// inclusion de la classe fpdf
include("pdf/fpdf.php");
// inclusion du fichier de configuration
// besoin de : SERVER_NAME, SCRIPT_NAME, FPDF_FONTPATH
include "config.inc";
function gen_pdf()
{
// Création du PDF
$pdf=new FPDF();
$pdf->Open();
$pdf->AddPage();
// titre
$pdf->SetFont('Arial','B',16);
// premier 1 : texte encadré
// deuxième 1 : retour à la ligne
$pdf->Cell(190,10, 'STATISTIQUES :',1,1,'C');
// on gère chaque cas du panier
foreach($_SESSION["panier"] as $graph)
{
// saut de ligne
$pdf->ln();
// titre de la statistique
$pdf->Cell(190,10, $graph[3],0,1,'C');
// période de la statistique
$pdf->Cell(190,10, "Du ".$graph[1]." au ".$graph[2],0,1,'C');
switch($graph[0])
{
case "graphe1":
// graphique fig1a
$pdf->Image("http://".SERVER_NAME."/".SCRIPT_NAME."/fig1a.php?_jpg_csimd=1".$graph[4], 30,60,150, null, 'PNG') ;
// graphique fig1b
$pdf->Image("http://".SERVER_NAME."/".SCRIPT_NAME."/fig1b.php?_jpg_csimd=1".$graph[5], 30,120,150, null, 'PNG') ;
// on ajoute une page
$pdf->AddPage();
break;
case "graphe2":
// graphique fig2a
$pdf->Image("http://".SERVER_NAME."/".SCRIPT_NAME."/fig2a.php?_jpg_csimd=1".$graph[4], 30,60,150, null, 'PNG') ;
// on ajoute une page
$pdf->AddPage();
break;
case "graphe3":
// graphique fig3a
$pdf->Image("http://".SERVER_NAME."/".SCRIPT_NAME."/fig3a.php?_jpg_csimd=1".$graph[4], 30,60,150, null, 'PNG') ;
// graphique fig3b
$pdf->Image("http://".SERVER_NAME."/".SCRIPT_NAME."/fig3b.php?_jpg_csimd=1".$graph[5], 30,150,150, null, 'PNG') ;
// on ajoute une page
$pdf->AddPage();
break;
//graphique fig4
case "graphe4":
//Ci dessous, la version qui pose un problème
//$pdf->Image("http://".SERVER_NAME."/".SCRIPT_NAME."/fig4.php?_jpg_csimd=1&MYSID=".urlencode(session_id()) , 30,60,150, null, 'PNG');
//Ci dessous, on met un message d'indisponibilté temporaire pour ce graphique
$pdf->ln(30);
$pdf->Cell(0,0, 'Graphique momentanément indisponible',0,1,'C');
// on ajoute une page
$pdf->AddPage();
break;
}
}
// on génère le PDF
$pdf->Output();
// suppression du fichier
unlink($file);
}
// appel de la fonction de génération de PDF
gen_pdf();
?> |
Partager