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
| <?php
require('fpdf.php');
$tableau=array();
class PDF extends FPDF
{
function tableau () {
include(".../../inc/conf.inc");
$www=mysql_query("SELECT Semaine FROM temp");
$ww = mysql_fetch_array($www);
$ww=$ww[0];
$tvar = array('NB','nb','NJ','nj','PB','pb','PJ','pj');
$tableau[0][0]= "Semaine $ww";
$sql = "SELECT * FROM regions ORDER BY regions_nom;";
$result = mysql_query($sql);
$cptreg = 0;
while ($rs = mysql_fetch_array($result)) {
$cptreg++;
$regions_nom = $rs['regions_nom'];
$treg[$cptreg] = $rs['regions_id'];
$tzone[$cptreg] = 0;
$tableau[0][$cptreg]=$regions_nom;
}
$tableau[0][4]="Total";
for ($n=1;$n<=4;$n++) {
$tableau[$n][0]=$tvar[($n-1)*2];
$result = mysql_query($sql);
$m = 0;
$totalvar = 0;
while ($rs = mysql_fetch_array($result)) {
$m++;
$tmp = "prev_".$tvar[($n*2)-1]."_ton";
$o = $treg[$m];
$sql2 = "SELECT SUM($tmp) AS nbre FROM prev, operateurs WHERE prev.operateurs_id = operateurs.operateurs_id AND regions_id = $o AND prev_ss = $ww;";
$result2 = mysql_query($sql2);
$rs2 = mysql_fetch_array($result2);
$nbre = $rs2['nbre']*1;
$tableau[$n][$m]=$nbre;
$tzone[$m] = $tzone[$m] + $nbre;
$totalvar = $totalvar + $nbre;
$x = array($nbre);
$tableau[$n][$m]=$nbre;
}
$tableau[$n][4]=$totalvar;
}
$tableau[5][0]="TOTAL";
$total = 0;
for ($k=1;$k<=$cptreg;$k++) {
$total = $total+$tzone[$k];
$tableau[5][$k]=$tzone[$k];
}
$tableau[5][4]=$total;
//Couleurs, épaisseur du trait et police grasse
$this->SetLineWidth(.4);
$w=array(30,30,30,30,30);
foreach($tableau as $row)
{
$this->Cell($w[0],6,$row[0],1,'LR','C');
$this->Cell($w[1],6,$row[1],1,'LR','C');
$this->Cell($w[2],6,$row[2],1,'LR','C');
$this->Cell($w[3],6,$row[3],1,'LR','C');
$this->Cell($w[4],6,$row[4],1,'LR','C');
$this->Ln();
}
}
}
$pdf=new PDF();
$pdf->SetFont('Arial','',12);
$pdf->AddPage();
$pdf->tableau();
$pdf->Image('.../graph_prev_region.png',10,60,120);
$pdf->Image('.../graph_prev_variete.png',10,150,120);
$pdf->Output();
?> |
Partager