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
| <?php
ob_start();
if (isset($_GET["id_facture"])){if (is_numeric($_GET["id_facture"])){$id_facture=$_GET["id_facture"];}else{$id_facture=0;}}
$PARAM_hote='localhost'; // le chemin vers le serveur
$PARAM_nom_bd='gestion_l'; // le nom de votre base de données
$PARAM_utilisateur='root'; // nom d'utilisateur pour se connecter
$PARAM_mot_passe=''; // mot de passe de l'utilisateur pour se connecter
$bdd = new PDO('mysql:host='.$PARAM_hote.';dbname='.$PARAM_nom_bd, $PARAM_utilisateur, $PARAM_mot_passe);
$reponse = $bdd->query('SELECT * FROM l_facture
JOIN l_facture_item ON l_facture_item.id_facture = l_facture.id_facture
JOIN l_client ON l_client.id_client = l_facture.id_client
WHERE l_facture.id_facture='.$id_facture.'');
$donnees = $reponse->fetch();
$client_societe = $donnees['client_societe'];
$client_nom = $donnees['client_nom'];
$client_adresse = $donnees['client_adresse'];
$client_codepostal = $donnees['client_codepostal'];
$client_ville = $donnees['client_ville'];
$titre_facture = utf8_decode($donnees['titre_facture']);
$total_facture = $donnees['total_facture'];
$date_facture = $donnees['date_facture'];
$ref_facture = $donnees['ref_facture'];
$euro = chr(128);
require("pdf/fpdf.php");
$pdf=new FPDF();
$pdf->AddPage();
$pdf->AddFont('champagne');
//entrerpise
$raisonsoc = "blablabla \n";
$raisonsoc .= "blablabla \n";
$raisonsoc .= "blablabla \n";
$raisonsoc .= "blablabla \n";
$raisonsoc .= "blablabla ";
$pdf->AddFont('champagne','','champagne.php');
$pdf->SetFont('champagne','',20);
$pdf -> SetXY(15,10);
$pdf -> Cell(60,10,'blablabla ','L T R',1);
$pdf->SetFont('Arial','I',8);
$pdf -> SetXY(15,20);
$pdf -> Multicell(60,5,$raisonsoc,'B L R',1);
//FACTURE
$pdf -> SetFont('Arial','B',8);
$pdf -> SetXY(15,47);
$pdf -> Multicell(60,5,"FACTURE N°: ".$ref_facture."",1);
//CLIENT
$client = "".$client_nom." \n";
$client .= "".$client_adresse." \n";
$client .= "".$client_codepostal." \n";
$client .= "".$client_ville." \n";
$pdf->SetFont('champagne','',20);
$pdf -> SetXY(125,10);
$pdf -> Cell(60,10,$client_societe,'L T R',1);
$pdf -> SetFont('Arial','',8);
$pdf -> SetXY(125,20);
$pdf -> Multicell(60,5,$client,'B L R',1);
//DATE FACTURE
$pdf -> SetFont('Arial','I',12);
$pdf -> SetXY(145,47);
$pdf -> Cell(60,5,"Date : ".$date_facture."");
//HAUT prestation tarif
$pdf->SetFont('champagne','',20);
$pdf->SetY(80);
$pdf->SetX(15);
$pdf->Cell(130,10,'PRESTATIONS','B',0,'C',0);
$pdf->SetX(145);
$pdf->Cell(50,10,'PRIX HT','B',0,'C',0);
//WHILE prestation tarif ICI QUE J'AI UN PB
while($donnees = $reponse->fetch(PDO::FETCH_ASSOC)){
$desc_facture_item = utf8_decode(nl2br($donnees['desc_facture_item']));
$prix_facture_item = $donnees['prix_facture_item'];
$pdf->SetFont('Arial','',12);
$pdf->SetY(85);
$pdf->SetX(15);
$pdf->Cell(130,40,$desc_facture_item,"B","","C","");
$pdf->Cell(50,40,''.$prix_facture_item.' '.$euro.'',"B","","C","");
$pdf->Ln();
}
$pdf->Output()
?> |
Partager