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
| <?php
session_start();
require('./pdf/fpdf.php');
include ('askBDD.php');
if (isset($_POST['pdf']))
{
$pdf=new FPDF();
$pdf->SetFont('Arial','B',8);
$pdf->AddPage();
$pdf->Image('./banniere.jpg',30,10,150,20);
$pdf->SetXY(10,38);
$dataFacture = AfficheObjet('facture',$_POST['idFacture']);
$detail = $dataFacture['detail'];
$data = AfficheClient('client',$dataFacture['login']);
$x=$pdf->GetX();
$y=$pdf->GetX();
$pdf->Cell(100,8,$data['nom']." ".$data['prenom'],0,1,"L");
$pdf->Cell(100,8,$data['adresse'],0,1,"L");
$pdf->Cell(100,8,$data['ville']." ".$data['code_postal'],0,1,"L");
$pdf->SetXY($x,$y-2);
$pdf->Cell(80,28,"",0,1,"L");
$pdf->Cell(80,29,"",1,1,"L");
$pdf->SetY($pdf->GetY()+5);
$i = 0;
//$facture = $_SESSION['panier'];
/******************************************************************/
// HEADER
/******************************************************************/
$pdf->Cell(20,8,'Quantité',1,0,"C");
$pdf->SetXY($pdf->GetX()+0.5,$pdf->GetY());
$pdf->Cell(149,8,"Produit",1,0,"C");
$pdf->SetXY($pdf->GetX()+0.5,$pdf->GetY());
$pdf->Cell(20,8,"Prix",1,1,"C");
$pdf->SetY($pdf->GetY()+0.5);
/******************************************************************/
// Genration dynamique du tableau
/******************************************************************/
$tab = explode(' €', $detail);
$qte = explode(' x ', $detail);
$prix = explode(' : ', $detail);
while ($i<count($tab)-1)
{
$qte = explode(' x ', $table[$i]);
$prix = explode(' Prix : ', $table[$i]);
$pdf->Cell(20,8,$qte[1],1,0,"C");
$pdf->SetXY($pdf->GetX()+0.5,$pdf->GetY());
$pdf->Cell(149,8,$tab[$i]." €",1,0);
$pdf->SetXY($pdf->GetX()+0.5,$pdf->GetY());
$pdf->Cell(20,8," €" ,1,1,"C");
$pdf->SetY($pdf->GetY()+0.5);
$i++;
}
/******************************************************************/
// FOOTER
/******************************************************************/
$pdf->Cell(170,8,' Total',0,0);
$pdf->SetXY($pdf->GetX(),$pdf->GetY());
$pdf->Cell(20,8,$dataFacture['montant']."0 €",1,1,"C");
$pdf->Output();
}
?> |
Partager