-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf.php
More file actions
109 lines (86 loc) · 2.85 KB
/
Copy pathpdf.php
File metadata and controls
109 lines (86 loc) · 2.85 KB
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
<?php
include_once '../../Model/Produit.php';
include_once '../../Model/Categorie.php';
include_once '../../Controller/ProduitCRUD.php';
include_once '../../Controller/CategorieCRUD.php';
require_once('fpdf/fpdf.php');
$db = new PDO('mysql:host=localhost;dbname=the_globe','root','');
$ProduitCRUD = new ProduitCRUD();
$listeproduit=$ProduitCRUD->AfficherProduit();
$CategorieCRUD = new CategorieCRUD();
$listecategorietype=$CategorieCRUD->AfficherCategorie();
$error = "";
$Produit = null;
$Produits = new ProduitCRUD();
if (
isset($_POST['nom_produit']) &&
isset($_POST['categorie_produit']) &&
isset($_POST['quantite_produit']) &&
isset($_POST['prix_produit']) &&
isset($_POST['image_produit'])
) {
if (
!empty($_POST['nom_produit']) &&
!empty($_POST['categorie_produit']) &&
!empty($_POST['quantite_produit']) &&
!empty($_POST['prix_produit']) &&
!empty($_POST['image_produit'])
) {
$Produit = new Produit(
null,
$_POST['nom_produit'],
$_POST['categorie_produit'],
$_POST['quantite_produit'],
$_POST['prix_produit'],
$_POST['image_produit']
);
$Produits->AjouterProduit($Produit);
header('Location:AjouterProduit.php');
}
else
$error = "Missing information";
}
class PDF extends FPDF{
function header(){
$this->SetFont('Arial','B',24);
$this->Cell(0,10,'Liste des produits',0,0,'C');
$this->Ln();
$this->SetFont('Times','',20);
$this->Cell(0,10,'JASMINOUS',0,0,'C');
$this->Ln(20);
}
function footer(){
$this->SetY(-15);
$this->SetFont('Arial','',8);
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
function headerTable(){
$this->SetFont('Times','B',12);
$this->Cell(40,10,'nom',1,0,'C');
$this->Cell(30,10,'categorie',1,0,'C');
$this->Cell(30,10,'quantite',1,0,'C');
$this->Cell(20,10,'prix',1,0,'C');
$this->Cell(60,10,'image',1,0,'C');
$this->Ln();
}
function viewTable($db){
$this->SetFont('Times','',10);
$liste = $db->query('SELECT * FROM produits INNER JOIN categories ON id_cat=categorie_produit');
while($data = $liste->fetch(PDO::FETCH_OBJ)){
$this->Cell(40,10,$data->nom_produit,1,0,'C');
$this->Cell(30,10,$data->nom_cat,1,0,'C');
$this->Cell(30,10,$data->quantite_produit,1,0,'C');
$this->Cell(20,10,$data->prix_produit,1,0,'C');
$this->Cell(60,10,$data->image_produit,1,0,'C');
$this->Ln();
}
}
}
// Instantiation of FPDF class
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->headerTable();
$pdf->viewTable($db);
$pdf->Output("ListeDesProduit.pdf","D");
?>