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
|
<?php
require('fpdf.php');
class PDF extends FPDF
{
//Chargement des données depuis ma base
function LoadData($base)
{
mysql_select_db($database_horaire, $horaire);
mysql_set_charset( 'utf8' );
if(!empty($_POST['classe']))
{
//Affichage de la classe
$claschoix='SELECT * FROM classe where id_cl ='.$_POST['classe'];
$reqclaschoix=mysql_query($claschoix)or die (mysql_error());
$req_claschoix=mysql_fetch_array($reqclaschoix);
//Affichage de la section
$secchoix='SELECT * FROM sections where id_section ='.$req_claschoix['id_sect'];
$reqsecchoix=mysql_query($secchoix)or die (mysql_error());
$req_secchoix=mysql_fetch_array($reqsecchoix);
}
//Affichage des cours de la classe
if(isset($_POST['classe']) and is_numeric($_POST['classe']))
{
$idclasse=$_POST['classe'];
$affcours='SELECT * FROM cours WHERE id_classe ='.$idclasse.' ORDER BY type ASC, nom_cours ASC';
$reqafcours=mysql_query($affcours) or die (mysql_error());
$cpt= 1 ;
while($row_affcours = mysql_fetch_array($reqafcours))
{
$classe='SELECT * FROM classe where id_cl ='.$row_affcours['id_classe'];
$reqclasse=mysql_query($classe)or die (mysql_error());
$req_classe=mysql_fetch_array($reqclasse);
$sect='SELECT * FROM sections where id_section ='.$req_classe['id_sect'];
$reqsect=mysql_query($sect)or die (mysql_error());
$req_section=mysql_fetch_array($reqsect);
//Travail sur la table horaires
$secaf=$req_section['id_section'];
$clasaf=$req_classe['id_cl'];
$coursaf=$row_affcours['id_c'];
$hor="SELECT * FROM horaires WHERE (id_clas='$clasaf' and id_cours='$coursaf')";
$reqhor=mysql_query($hor)or die (mysql_error());
$req_horaires=mysql_fetch_array($reqhor);
/*Partie du code ou je bloque et évidemment ce la est faux mais je comprend pas comment parsé ma variable $req_horaires avec fpdf */
$pdf->write($row_affcours['nom_cours'], 10);
$pdf->write($req_horaires['nbheures'], 10);
}
}
}
function tableauhoraire($header,$base)
{
//Couleurs, épaisseur du trait et police grasse
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//En-tête
$w=array(40,35);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',1);
$this->Ln();
//Restauration des couleurs et de la police
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
//Données
$fill=false;
foreach($base 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,number_format($row[2],0,',',' '),'LR',0,'R',$fill);
$this->Cell($w[3],6,number_format($row[3],0,',',' '),'LR',0,'R',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf=new PDF();
//Titres des colonnes
$header=array('Cours','Nb heure');
$pdf->SetFont('Arial','',14);
$pdf->AddPage();
$pdf->tableauhoraire($header,$base);
$pdf->Output();
?> |
Partager