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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| <?php
require('fpdf.php');
class PDF extends FPDF
{
//En-tête
function Header()
{
//Logo
$this->Image('Images/oddos3.jpg',20,10,50);
//Police Arial gras 15
$this->SetFont('Arial','B',8);
//Saut de ligne
$this->Ln(20);
}
//Pied de page
function Footer()
{
//Positionnement à 1,5 cm du bas
$this->SetY(-32);
//Police Arial italique 8
$this->SetFont('Arial','B',8);
$this->Cell(0,0,'ODDOS BURO');
$this->Cell(-26,0,'SIREN : 335 119 186', 0, 1, 'C');
$this->Ln(4);
$this->Cell(0,0,'15, rue du général Lionel de Marmier');
$this->Cell(-31,0,'TVA : FR 03 335 119 186', 0, 1, 'C');
$this->Ln(4);
$this->Cell(0,0,'31300 TOULOUSE');
$this->Cell(-34,0,'SIRET : 335 119 186 00054', 0, 1, 'C');
$this->Ln(4);
$this->Cell(0,-16,'Tél : 05 62 73 77 77 / Fax : 05 61 62 57 82',0,0, 'C');
$this->Cell(-42,0,'SARL au capital de 600 000 euros', 0, 1, 'C');
$this->Ln(4);
$this->Cell(0,-16,'www.oddos-buro.fr',0,0, 'C');
$this->Ln(4);
$this->Cell(0,-16,'contact@oddos-buro.fr',0,0, 'C');
$this->Ln(8);
$this->Cell(0,-16,'(Au terme de la loi de mai 1980, nos marchandises restent notre propriété jusqu\'à leur paiement intégral)');
//Numéro de page
$this->Cell(-10,0,'Page '.$this->PageNo().'/{nb}', 0, 1, 'C');
}
function LoadData($file)
{
//Lecture des lignes du fichier
$lines=file($file);
$data=array();
foreach($lines as $line)
$data[]=explode(';',chop($line));
return $data;
}
//Tableau coloré
function ExportTableau($header,$data)
{
//Couleurs, épaisseur du trait et police grasse
$this->SetFillColor(150,180,255); //fond des entetes de colonnes
$this->SetTextColor(0); //couleur du texte des entetes des colonnes
$this->SetDrawColor(0); // couleur des bordures
$this->SetLineWidth(.3); //epaisseur des traits
$this->SetFont('','B');
//En-tête
$w=array(35,20,50,20,45,20,27,27,45);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',1);
$this->Ln();
//Restauration des couleurs et de la police
$this->SetFillColor(224,235,255); //couleur du fond des cases
$this->SetTextColor(0); //couleur du texte des cases
$this->SetFont('');
//Données
$fill=false;
foreach($data as $row)
{
$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row[2],'LR',0,'L',$fill);
$this->Cell($w[3],6,$row[3],'LR',0,'L',$fill);
$this->Cell($w[4],6,$row[4],'LR',0,'L',$fill);
$this->Cell($w[5],6,$row[5],'LR',0,'L',$fill);
$this->Cell($w[6],6,$row[6],'LR',0,'L',$fill);
$this->Cell($w[7],6,$row[7],'LR',0,'L',$fill);
$this->Cell($w[8],6,$row[8],'LR',0,'L',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
}
}
// On se connecte à la base
require_once('connexion.php');
// On demande à la base de renvoyer les résultats en utf8
mysql_query("set names utf8");
//Requete SQL
$query = "SELECT ld.RefA, DescriptionA, Quantite, PrixUA, RemiseA, cast((Quantite*PrixUA*(1-RemiseA/100)) AS decimal(10,2)) as PrixHT, DescriptifCol, c.NomFrsCol FROM ARTICLES a, LIGNE_DEVIS ld, DEVIS d, COLLECTIONS c WHERE c.NomFrsCol=a.NomFrsCol AND a.RefA=ld.RefA AND ld.NumD=d.NumD AND ld.NumD='".$_GET['Devis']."'";
$result = mysql_query($query) or die ('Erreur SQL !<br />' . $query . '<br />' . mysql_error());
//Boucle sur les resultats
while($col = mysql_fetch_array($result))
{
$data = "$col[RefA];$col[DescriptionA];$col[Quantite];$col[PrixUA];$col[RemiseA];$col[PrixHT];$col[DescriptifCol];$col[NomFrsCol];";
$data = utf8_decode($data);
$data = array($data);
}
//Instanciation de la classe dérivée
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
$pdf->Ln(25);
$pdf->Cell(120);
$pdf->Cell(0,10,'Client :',1,0,'');
$pdf->Ln(20);
$pdf->ExportTableau($header,$data);
$pdf->Output();
?> |
Partager