<?php
/* $Id: pdf.class.php,v 1.9 2003/12/03 17:32:35 k-fish Exp $ */

class PDF extends FPDF{
    function PDF(){
	$this->FPDF();
    }

    // header
    function Header(){
	global $conn;

	// base settings
	$this->SetFont("Arial","B",12);
	$this->SetTextColor(0,0,210);

	// logo
	$this->Image("./templates/default/media/mgw_logo.png",148,12,50);

	// line at the top
	$this->SetLineWidth(0.8);
	$this->Line(10,10,200,10);
	$this->SetLineWidth(0.2);

	// company data
	$compname = (isset($this->row["name1"])) ? $this->row["name1"] : '';
	$compnr = (isset($this->row["telephone"])) ? $this->row["telephone"] : '';
	$url = (isset($this->row["company_url"])) ? $this->row["company_url"] : '';
	$this->SetY(14);
	$this->MultiCell(0,5.5,"$compname \n$compnr \n$url ",0,"L");
	$this->Line(10,$this->GetY()+2,200,$this->GetY()+2);

	// table header
	$this->SetTextColor(210,0,0);
	$this->Text(20,$this->GetY()+7,Lang::getLanguageString("pdfname"));
	$this->SetX(94);        
	$this->Text($this->GetX(),$this->GetY()+7,Lang::getLanguageString("pdfno"));
	$this->SetX(154);        
	$this->Text($this->GetX(),$this->GetY()+7,Lang::getLanguageString("pdfmobile"));
	$this->Line(10,$this->GetY()+9,200,$this->GetY()+9);

	// finish up
	$this->SetTextColor(0,0,0);
	$this->setY(35);
    }

    //Pied de page
    function Footer(){
	global $conn;

	$this->SetFont("Arial","",8);
	$this->SetY(-15);

	$this->SetLineWidth(0.8);
	$this->Line(10,$this->GetY(),200,$this->GetY());
	$this->Text(10,$this->GetY()+4,date($_SESSION["MGW"]->settings["datefmt"]." ".$_SESSION["MGW"]->settings["timefmt"]));
	$this->Text(100,$this->GetY()+4,Lang::getLanguageString("pdfpage")." ".$this->PageNo()."/{nb}");
    }

    function Body(&$res){
	$this->res =& $res;
	$this->row = $this->res->FetchRow();
	$this->rows = 1;
	$this->AddPage();
	$this->SetFont('Arial','',12);
	$y=$this->GetY()+3;

	do{
	    $y+=7;

	    $this->Text(20,$y,$this->row["lastname"].", ".$this->row["firstname"]);

	    // just show up only the personal nr (call-through nr)
	    if(!strrpos($this->row["tel_company"],"-")){
		$ctnr = substr($this->row["tel_company"], strrpos($this->row["tel_company"],"-"),strlen($this->row["tel_company"])-strrpos($this->row["tel_company"],"-"));
	    }
	    else{
		$ctnr = $this->row["tel_company"];
	    }
	    $this->Text(94,$y,$ctnr);
	    $this->Text(154,$y,$this->row["tel_mobile"]);                

	    if($this->rows++==34){
		$this->rows=1;
		$this->AddPage();
		$y=$this->GetY()+3;
	    }
	    else{
		$this->Line(10,$y+2,200,$y+2);
		$this->SetY($y+2);
	    }
	} while($this->row = $this->res->FetchRow());
    }
}
?>