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
|
<?php
require('../class/fpdf16/fpdf.php');
class PDF extends FPDF
{
function Header()
{
$w=array(40,40,35,37,37);
$header=array('Date de Commande','Date d\'expédition','N° Commande','Porteur ','Reference');
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],'LR',0,C,1);
//Saut de ligne
$this->Ln();
}
function LoadData($file)
{
include ("connexion.php");
$query_select="";
$stmt = oci_parse($conn, $query_select);
oci_execute($stmt, OCI_DEFAULT);
//Lecture des lignes du fichier
// $lines=file($file);
$i=0;
WHILE (oci_fetch($stmt) ) {
// On ecris dans un fichier texte les donnees qu'on extrait par la suite si l'on veux générer un PDF
$lines[$i]=oci_result($stmt, "DAT_CDE").";".oci_result($stmt, "DATE_EXPED").";".oci_result($stmt, "NO").";".oci_result($stmt, "CLIENT").";".oci_result($stmt, "REFERENCE");
$i++;
};
$data=array();
foreach($lines as $line)
// $data[]=explode(';',chop($line));
$data[]=explode(';',$line);
return $data;
}
//Tableau coloré
function FancyTable($header2,$data)
{
//Couleurs, épaisseur du trait et police grasse
// $this->SetFillColor(155,127,150);
// $this->SetTextColor(255);
// $this->SetDrawColor(155,127,150);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//En-tête
//$w=array(50,45,45,45); LE nombre d'argument dépond du nombre d'element de l'entete
$w=array(40,40,35,37,37);
/* for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],'LR',0,'C',1);
$this->Ln();*/
//Restauration des couleurs et de la police
$this->SetFillColor(246,246,246);
$this->SetTextColor(0);
$this->SetFont('');
//Données
$fill=false;
foreach($data as $row)
{
$this->Cell($w[0],6,$row[0],'LR',0,'C',$fill);
$this->Cell($w[1],6,$row[1],'LR',0,'C',$fill);
$this->Cell($w[2],6,$row[2],'LR',0,'C',$fill);
$this->Cell($w[3],6,$row[3],'LR',0,'C',$fill);
$this->Cell($w[4],6,$row[4],'LR',0,'C',$fill);
//$this->Cell($w[2],6,number_format($row[2],0,',',' '),'LR',0,'R',$fill);
/// $this->Cell($w[3],6,number_format($row[3],0,',',' '),'LR',0,'R',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf=new PDF();
//Titres des colonnes
$header=array('Date de Commande','Date d\'expédition','N° ,'client ','Reference');
//Chargement des données
$data=$pdf->LoadData('fichierPDF.txt');
$pdf->SetFont('Arial','',8);
$pdf->SetLeftMargin('10');
$pdf->AddPage();
//$pdf->BasicTable($header,$data);
//$pdf->AddPage();
//$pdf->ImprovedTable($header,$data);
//$pdf->AddPage();
$pdf->FancyTable($header,$data);
$pdf->Output();
?> |
Partager