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
| <?php
$semaineactuelle = date('W');
$bddname = 'XXX';
$hostname = 'XXX';
$username = 'XXX';
$password = 'XXX';
$db = mysqli_connect ($hostname, $username, $password, $bddname);
mysqli_select_db ( $db,'cantine') ;
require('fpdf.php');
class PDF extends FPDF {
function Header()
{
// Logo
$this->Image('Logo C&D Foods.png',10,6,25);
// Logo
$this->Image('Menuavecbordure.png',110,6,60);
// Logo
$this->Image('Elior Logo.png',230,12,60);
}
}
// Activation de la classe
$pdf = new PDF ('L','mm','A4');
$pdf->AddPage();
$pdf->SetFont('Helvetica','',11);
$pdf->SetTextColor(0);
$req1 = "SELECT * FROM menus WHERE Semaine = $semaineactuelle ";
$rep1 = mysqli_query($db, $req1);
$row1 = mysqli_fetch_array($rep1);
$position_entete = 58;
function entete_table($position_entete){
global $pdf;
$pdf->SetDrawColor(183); // Couleur du fond
$pdf->SetFillColor(221); // Couleur des filets
$pdf->SetTextColor(0); // Couleur du texte
$pdf->SetY($position_entete);
$pdf->SetX(3);
$pdf->Cell(30,12,'Date',1,0,'C',1);
$pdf->SetX(33);
$pdf->Cell(30,12,'Entree1',1,0,'C',1);
$pdf->SetX(63);
$pdf->Cell(30,12,'Entree2',1,0,'C',1);
$pdf->SetX(93);
$pdf->Cell(30,12,'Plat1',1,0,'C',1);
$pdf->SetX(123);
$pdf->Cell(30,12,'Plat2',1,0,'C',1);
$pdf->SetX(153);
$pdf->Cell(40,12,'Accompagnement1',1,0,'C',1);
$pdf->SetX(193);
$pdf->Cell(40,12,'Accompagnement2',1,0,'C',1);
$pdf->SetX(233);
$pdf->Cell(30,12,'Dessert1',1,0,'C',1);
$pdf->SetX(263);
$pdf->Cell(30,12,'Dessert2',1,0,'C',1);
$pdf->SetX(293);
}
entete_table($position_entete);
$position_detail = 70; // Position à 8mm de l'entête
$reponse = mysqli_query($db,"SELECT * FROM menus WHERE Semaine = $semaineactuelle");
while($donnees = mysqli_fetch_array($reponse))
{
$pdf->SetY($position_detail);
$pdf->SetX(3);
$pdf->MultiCell(30,12,utf8_decode($donnees['Date']),1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(33);
$pdf->MultiCell(30,12,$donnees['Entree1'],1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(63);
$pdf->MultiCell(30,12,$donnees['Entree2'],1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(93);
$pdf->MultiCell(30,12,$donnees['Plat1'],1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(123);
$pdf->MultiCell(30,12,$donnees['Plat2'],1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(153);
$pdf->MultiCell(40,12,$donnees['Accompagnement1'],1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(193);
$pdf->MultiCell(40,12,$donnees['Accompagnement2'],1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(233);
$pdf->MultiCell(30,12,$donnees['Dessert1'],1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(263);
$pdf->MultiCell(30,12,$donnees['Dessert2'],1,'C');
$pdf->SetY($position_detail);
$pdf->SetX(293);
}
// Nom du fichier
$nom = 'menucantine.pdf';
// Création du PDF
$pdf->Output();
?> |
Partager