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
|
<?php
$idvend = 310 ;
include ("./fpdf/fpdf.php");
include ("./admin/conec.php");
class PDF extends FPDF
{
//Tableau coloré
function ExportTableau($header,$data)
{
//Titre
$this->SetFont('Arial','B',8);
$this->SetTextColor(37,21,81);
$this->Cell(0,3,'ETAT GENERAL DES CONTRATS',0,1,'C');
$this->Ln(1);
//Imprime l'en-tête du tableau si nécessaire
parent::Header();
$this->SetFont('Arial','B',4);
//Couleurs, épaisseur du trait et police grasse
$this->SetFillColor(150,180,255); //fond des entetes de colonnes
$this->SetTextColor(37,21,81); //couleur du texte des entetes des colonnes
$this->SetDrawColor(37,21,81); // couleur des bordures
$this->SetLineWidth(.1); //epaisseur des traits
$this->SetFont('','B');
//En-tête
$w=array(20,40,20,20,20,20,20,20);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],3,$header[$i],1,0,'C',1); // 3 = hauteur entête
$this->Ln();
//Restauration des couleurs et de la police
$this->SetFillColor(224,235,255); //couleur du fond des cases
$this->SetTextColor(37,21,81); //couleur du texte des cases
$this->SetFont('');
//Données
$fill=false;
foreach($data as $row)
{
$this->Cell($w[0],2.3,$row[0],'LR',0,'C',$fill);
$this->Cell($w[1],2.3,$row[1],'LR',0,'L',$fill);
$this->Cell($w[2],2.3,$row[2],'LR',0,'C',$fill);
$this->Cell($w[3],2.3,$row[3],'LR',0,'C',$fill);
$this->Cell($w[4],2.3,$row[4],'LR',0,'C',$fill);
$this->Cell($w[5],2.3,$row[5],'LR',0,'C',$fill);
$this->Cell($w[6],2.3,$row[6],'LR',0,'C',$fill);
$this->Cell($w[7],2.3,$row[7],'LR',0,'C',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
}
}
$query = "SELECT date_contfr,nom,cpostal,type,contrat,statut,statut2,date_annulfr FROM contrats ORDER BY date_cont DESC ";
$result = mysql_query($query) or die ('Erreur SQL !<br />' . $query . '<br />' . mysql_error());
$data = array();
while($col = mysql_fetch_array($result)) { array($col); $data[] = $col; }
//Creation pdf
$pdf=new PDF('P');
//Titres des colonnes
$header=array('DATE DU CONTRAT','SOUSCRIPTEUR','CODE POSTAL','TYPE CONTRAT','N° DE CONTRAT', 'STATUT','EVENEMENT', 'DATE EVENEMENT');
//Tableau
$pdf->SetFont('Arial','',4);
$pdf->SetMargins(15,7);
$pdf->AddPage();
$pdf->ExportTableau($header,$data);
$pdf->Output('Situation au '.date("d/m/Y").'.pdf','I');
?> |