PageNo() == 1) { // Logos $this->Image('../../templates/dinant/images/lib/dlvc.jpg',10,10,15); $this->Image('../../templates/dinant/images/lib/logo_cdsi.gif',165,10,30); //Police Arial gras 15 $this->SetFont('Arial','B',12); //Décalage à droite $this->Cell(80); //Titre $this->Cell(30,10,$this->titre,0,0,'C'); $this->SetFont('Arial','I',8); $this->Ln(); $this->Cell(80); $this->Cell(30,10,'Annuaire dinantais - Version du '.date("d/m/Y - G:i:s"),0,0,'C'); //Saut de ligne $this->Ln(); } $this->Ln(); //Sauvegarde de l'ordonnée $this->y0=$this->GetY(); } function SetCol($col) { //Positionnement sur une colonne $this->col=$col; $x=10+$col*95; $this->SetLeftMargin($x); $this->SetX($x); } function AcceptPageBreak() { //Méthode autorisant ou non le saut de page automatique if($this->col<1) { //Passage à la colonne suivante $this->SetCol($this->col+1); //Ordonnée en haut $this->SetY($this->y0); //On reste sur la page return false; } else { //Retour en première colonne $this->SetCol(0); //Saut de page return true; } } function ShowTable($sth) { // Couleurs, épaisseur du trait et police grasse $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetDrawColor(36,50,80); $this->SetLineWidth(.3); $this->SetFont('','B'); //En-tête $widthTable = 90; // Restauration des couleurs et de la police $this->SetFillColor(224,235,255); $this->SetTextColor(0); $this->SetFont(''); // Données $fill=0; $old_libelle=''; while($row=mysql_fetch_object($sth)) { if($old_libelle<>$row->lib_rubrique) { $old_libelle=$row->lib_rubrique; $this->SetFillColor(36,50,80); $this->SetTextColor(255,255,255); $this->SetFont('Arial','B',10); $this->Cell(90,7,$old_libelle,'LR',0,'L',1); $this->SetFillColor(224,235,255); $this->SetTextColor(0,0,0); $this->SetFont('Arial','',8); $this->Ln(); } $this->SetFont('Arial','B',8); $this->Cell(90,4,stripslashes($row->nom),'LR',0,'L',$fill); $this->SetFont('Arial','',8); $this->Ln(); /*if($row->description != '') { $this->SetFont('Arial','I',8); $this->Cell(90,4,$row->description,'LR',0,'L',$fill); $this->SetFont('Arial','',8); $this->Ln(); }*/ $this->Cell(90,4,$row->lib_rue.', '.$row->numero,'LR',0,'L',$fill); $this->Ln(); $this->Cell(90,4,$row->cp.' '.$row->localite,'LR',0,'L',$fill); $this->Ln(); $phones = ''; if($row->telephone != '') $phones = $phones.'Tel: '.$row->telephone; if($phones != '') $phones = $phones.' '; if($row->fax != '') $phones = $phones.'Fax: '.$row->fax; if($phones != '') $phones = $phones.' '; if($row->gsm != '') $phones = $phones.'Portable: '.$row->gsm; if($phones != '') { $this->Cell(90,4,$phones,'LR',0,'L',$fill); $this->Ln(); } if($row->email != '') { $this->Cell(90,4,'Courriel : '.$row->email,'LR',0,'L',$fill); $this->Ln(); } if($row->url != '') { $this->Cell(90,4,'Site Web : '.$row->url,'LR',0,'L',$fill); $this->Ln(); } $fill=!$fill; } $this->Cell($widthTable,0,'','T'); mysql_free_result($sth); } function Footer() { $this->Ln(); // Positionnement à 1,5 cm du bas $this->SetY(-20); $this->SetX(10); // Police Arial italique 8 $this->SetFont('Arial','I',6); $this->Cell(0,5,'Un oubli ? Une erreur ? Merci de bien vouloir le signaler par courriel: pages-canari@dinant.be',0,0,'C'); $this->Ln(); // Numéro de page centre $this->Cell(0,5,'Page '.$this->PageNo(),0,0,'C'); $this->SetFont('Arial','',8); } } function gener_pdf($yp_pdf) { // Initialisation de la connexion à MySQL if (!init_database_connection()) { die('MySQL error.'); } $pdf=new PDF(); $pdf->titre = 'www.dinant.be : Les Pages Canari'; $pdf->SetFont('Arial','',8); $pdf->AddPage(); $stmt="SELECT dd.id annu_id, dd.nom, dd.description, dd.cp, dd.localite, dd.url, r.libelle lib_rubrique, r2.libelle lib_rue, dd.numero, dd.telephone, dd.fax, dd.gsm, dd.email FROM annu dd, annu_rub r, rues r2 WHERE (dd.rues_id=r2.id) AND (dd.annu_rub_id=r.id) ORDER BY r.libelle, dd.nom;"; $sth=mysql_query($stmt); $pdf->ShowTable($sth); $pdf->Output($yp_pdf); //close_database_connection(); } function download_pdf($yp_pdf) { header("Content-type: application/force-download"); //header("Location: http://www.dinant.be/pages-canari/pages-canari.pdf"); header("Location: pages-canari.pdf"); } $yp_pdf = "pages-canari.pdf"; if(file_exists($yp_pdf)) { if ((date("Y-m-d", filemtime($yp_pdf))) != (date("Y-m-d"))) { gener_pdf($yp_pdf); } } else { gener_pdf($yp_pdf); } download_pdf($yp_pdf); ?>