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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
<?php
session_start();
$qTotal = $_SESSION['qTotal'];
$totalRegler = $_SESSION['totalRegler'];
require('fpdf/fpdf.php');
if($qTotal == 0) {
$retour = header("location:boutique.php");
}
$numero = $_GET['n'];
$txtCoordonnees = "coordonnees/".$numero.".txt";
$txtCommande = "commande/".$numero.".txt";
class PDF extends FPDF
{
//En-tête
function Header()
{
//Logo
$this->Image('images/pdf/haut.jpg',0,0,210);
//Police Arial gras 15
$this->SetFont('Arial','B',12);
//Décalage à droite
$this->Cell(80);
//Titre
$this->Ln(60);
}
//Chargement des données
function LoadData($file)
{
//Lecture des lignes du fichier
$lines=file($file);
$data=array();
foreach($lines as $line)
$data[]=explode(';',chop($line));
return $data;
}
// coordonnees du client ------------------------------------------------------------------ //
//Tableau simple
function tableCoordonnees($coordonnees)
{
//Couleurs, épaisseur du trait et police grasse
$this->SetFillColor(255,0,0);
$this->SetTextColor(115,0,39);
$this->SetDrawColor(255,255,255);
$this->SetLineWidth(.0);
$this->SetFont('','B');
//Largeurs des colonnes
$w=array(55,10,120);
//Restauration des couleurs et de la police
$this->SetFillColor(255);
$this->SetTextColor(0);
$this->SetFont('');
//Données
$fill=0;
foreach($coordonnees as $row)
{
$this->Cell($w[0],6,$row[0],'LR',0,'R',$fill);
$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row[2],'LR',0,'L',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
$this->Ln(10);
}
// Tableau de la commande ----------------------------------------------------------------- //
//Tableau simple
function tableCommande($header,$commande)
{
//Couleurs, épaisseur du trait et police grasse
$this->SetFillColor(255,0,0);
$this->SetTextColor(115,0,39);
$this->SetDrawColor(255,255,255);
$this->SetLineWidth(.0);
$this->SetFont('','B');
//Largeurs des colonnes
$w=array(85,20,35,20,0);
//En-tête
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C');
$this->Ln();
//Restauration des couleurs et de la police
$this->SetFillColor(235,235,235);
$this->SetTextColor(0);
$this->SetFont('');
//Données
$fill=0;
foreach($commande 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,'C',$fill);
$this->Cell($w[3],6,$row[3],'LR',0,'C',$fill);
$this->Cell($w[4],6,$row[4],'LR',0,'R',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
$this->Ln(10);
}
function tableRegler($totalRegler) {
$this->SetFont('Arial','B',16);
$this->Cell(40,10,'Vous devez régler une commande totale de '.$totalRegler);
}
//Pied de page
function Footer()
{
//Logo
$this->Image('images/pdf/bas.jpg',0,237,210);
}
}
$pdf=new PDF('P','mm','A4');
$header=array('Désignation',' ','Tarif','Qté','Montant');
//Chargement des données
$coordonnees=$pdf->LoadData($txtCoordonnees);
$commande=$pdf->LoadData($txtCommande);
$pdf->AddPage();
$pdf->SetFont('Arial','B',12);
$pdf->tableCoordonnees($coordonnees);
$pdf->tableCommande($header,$commande);
$pdf->tableRegler($totalRegler);
$pdf->Output();
$finCoordonnees = unlink("coordonnees/".$numero.".txt");
$finCommande = unlink("commande/".$numero.".txt");
session_destroy();
?> |
Partager